logo elektroda
logo elektroda
X
logo elektroda

NodeMCU V1 reset using interrupts after Arduino IDE 1.8.12 update

globalinfo 762 17
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 18599487
    globalinfo
    Level 13  
    Hello,
    I have a problem using interrupts and WiFi on a NodeMcu V1 module.
    The worst part is that everything worked for a year.
    Now I have updated the Arduino IDE to version 1.8.12 and after uploading the code to the module, it resets.
    After deleting the line and with the interrupt code, the chip does not reset.
    Please give me a hint on how to deal with this.

    Below is an excerpt from the code which, when inserted, causes a reset.
    Code: C / C++
    Log in, to see the code
    .
    Here the error message.
    Quote:
    Here is the error message.
    User exception (panic/abort/assert)
    Abort called

    >>>stack>>

    ctx: cont
    sp: 3ffffef0 end: 3fffffc0 offset: 0000
    3ffffef0: feefeffe feefeffe feefeffe 00000100
    3fffff00: 000000fe 00000000 00000000 00000000
    3fffff10: 00000000 00000000 00000000 00ff0000
    3fffff20: 5ffffe00 5ffffe00 3ffef394 00000000
    3fffff30: 00000002 00000000 3ffee4c8 40203f1a
    3fffff40: 4010046a 51eefae7 ffffff00 40203f30
    3fffff50: 401055b9 00000001 3ffee4c8 40204431
    3fffff60: 00000000 3ffee6b4 00000002 40204624
    3fffff70: 00000004 00000000 00000064 3ffee540
    3fffff80: 3fffdad0 00000000 3ffee4c8 402044e0
    3fffff90: 3fffdad0 00000000 3ffee4c8 40201240
    3fffffa0: feefeffe feefeffe 3ffee500 40203b70
    3fffffb0: feefeffe feefeffe 3ffe84f0 40100d75
    <<<stack<<<
    .
  • ADVERTISEMENT
  • #2 18599559
    Anonymous
    Level 1  
  • #3 18599623
    globalinfo
    Level 13  
    drobok wrote:
    And when you give empty count_production and count_use it restarts too ? I would look there for the problem.


    These are function references, how am I supposed to count pulses if I don't execute the function.

    Below is the code for these functions.
    Code: C / C++
    Log in, to see the code
    .
  • #4 18599885
    Anonymous
    Level 1  
  • #5 18599978
    globalinfo
    Level 13  
    drobok wrote:
    A place where you use production_Wh and consumption_Wh ? This is not a problem with the interrupt itself. You need to pre-bug it when it specifically resets for you. If I were you, I would compare the resulting asm of one version with the other and start looking where the differences are.
    .

    The program resets when it hasn't executed the whole void setup() .
    I've added some checks and it does a reset between spr3 and spr4, so this is an interrupt issue.
    Below is the code with the checks added and the error message.
    Code: C / C++
    Log in, to see the code
    .
    Quote:
    .
    spr1
    Connecting to ComNet_2EX........................
    Connected - IP: 192.168.100.120 RSSI: -75 dBm

    spr2
    spr3
    ISR not in IRAM!

    User exception (panic/abort/assert)
    Abort called

    >>>stack>>

    ctx: cont
    sp: 3ffffef0 end: 3fffffc0 offset: 0000
    3ffffef0: 3ffe86cb ffffffb5 3ffee4d8 4020408a
    3fffff00: 000000fe 00000000 00000000 00000000
    3fffff10: 00000000 00000000 00000000 00ff0000
    3fffff20: 5ffffe00 5ffffe00 000a0d0a 00000000
    3fffff30: 00000002 00000000 3ffee4d8 40203f9a
    3fffff40: 4010046a 9bcfb0b8 3ffee400 40203fb0
    3fffff50: 401055b9 009baf90 3ffee4d8 402044b1
    3fffff60: 00000000 3ffee5ac 00002710 3ffee550
    3fffff70: 00000000 3ffee5ac 00002710 3ffee550
    3fffff80: 00000000 00002710 3ffee4d8 40204560
    3fffff90: 00000000 00002710 3ffee4d8 402012a1
    3fffffa0: 3fffdad0 00000000 3ffee510 40203bf0
    3fffffb0: feefeffe feefeffe 3ffe84f0 40100d75
    <<<stack<<<

    ets Jan 8 2013,rst cause:2, boot mode:( 3,6)

    load 0x4010f000, len 1392, room 16
    tail 0
    chksum 0xd0
    csum 0xd0
    v3d128e5c
    ~ld

    .
  • ADVERTISEMENT
  • #7 18600112
    globalinfo
    Level 13  
    I added 2 lines and everything works.
    Thank you for your guidance.

    Code: C / C++
    Log in, to see the code
    .
  • ADVERTISEMENT
  • #8 18600211
    khoam
    Level 42  
    The variables production_Wh and use_Wh should be declared as atomic if you use them in interrupts and the main program.
  • #9 18600722
    globalinfo
    Level 13  
    khoam wrote:
    Variables production_Wh and use_Wh should be declared as atomic, if you use them in interrupts and the main program.
    .
    I have so declared
    Code: C / C++
    Log in, to see the code
    .
    Please give me a hint as to what this means
    Quote:
    declared as atomic
    .
  • #10 18600813
    khoam
    Level 42  
    They should be declared as:
    Code: C / C++
    Log in, to see the code
    I also need to remember to include the header file:
    Code: C / C++
    Log in, to see the code
    .
    globalinfo wrote:
    Please suggest what this means
    .
    Atomic type objects allow basic operations (assigning and reading values) to be performed on them in a indivisible way and provide a proper ordering of memory access operations. In your program, these variables are referenced by the interrupt handler routines and the main program itself (the main thread). There are also WiFi-related threads running in the background in ESP, from which such references may also occur if you use the WiFi function.
  • #11 18602349
    globalinfo
    Level 13  
    It cannot compile for me after inserting these codes.
    Quote:

    collect2.exe: error: ld returned 1 exit status

    exit status 1
    Compilation error for the NodeMCU 1.0 board (ESP-12E Module).
    .
  • #12 18602362
    khoam
    Level 42  
    And what are the compilation errors? What a colleague has shown is just the end result. I compiled the needed code snippet before posting it.
  • ADVERTISEMENT
  • #13 18602395
    globalinfo
    Level 13  
    I have cropped the paths because it is not possible to paste whole access paths.
    Quote:
    .
    /ld.exe: sketch\ Countermoj7042020.ino.cpp.o:( .iram.text.Countermoj7042020.ino.72.1+0x4): undefined reference to `__atomic_fetch_add_4'

    Licznikmoj7042020.ino.cpp.o: in function `count_use()':
    bits/atomic_base.h:614: undefined reference to `__atomic_fetch_add_4'.
    xtensa-lx106-elf/bin/ld.exe: sketch_countmoj7042020.ino.cpp.o: in function `count_productions()':

    atomic_base.h:614: undefined reference to `__atomic_fetch_add_4'.

    collect2.exe: error: ld returned 1 exit status

    exit status 1
    Compilation error for NodeMCU 1.0 board (ESP-12E Module).
    .
  • #14 18602410
    khoam
    Level 42  
    What does the code for the count_use() and count_production() functions look like at the moment?
  • #15 18602414
    globalinfo
    Level 13  
    khoam wrote:
    What does the code for the count_use() and count_production() functions look like at the moment?

    Code: C / C++
    Log in, to see the code
    .
  • #16 18602432
    khoam
    Level 42  
    Are you including the header file <atomic>?
  • #17 18602476
    globalinfo
    Level 13  
    Yes and they still can't compile.
  • #18 18603608
    khoam
    Level 42  
    There is a bug in the HAL for the ESP8266, but without going into detail I suggest modifying these functions:
    Code: C / C++
    Log in, to see the code
    It should compile and work.

Topic summary

The discussion revolves around issues faced by a user with a NodeMCU V1 module after updating the Arduino IDE to version 1.8.12. The user reports that the module resets when using interrupts for pulse counting, specifically when the interrupt functions are included in the code. Various responses suggest checking the interrupt handler functions, ensuring they are placed in IRAM, and declaring shared variables as atomic to prevent race conditions. The user successfully resolves the issue by adding the ICACHE_RAM_ATTR attribute to the interrupt functions. Additional advice includes modifying the increment operations within the interrupt handlers to ensure proper compilation and functionality.
Summary generated by the language model.
ADVERTISEMENT