-->
Page 1 of 1

node.bootreason missing in build for esp32

PostPosted: Wed Dec 30, 2020 7:43 am
by aribi
When doing a firmware build for esp32 the image does not contain an entry for bootreason() in the "node" table
Code: Select all> print(node.bootreason())
stdin:1: attempt to call field 'bootreason' (a nil value)
stack traceback:
        stdin:1: in main chunk

This seems to be inline with the github repo of the firmware; file components/modules/node.c does not contain an LROT_FUNCENTRY for this function.
Yet, the docs do mention this functionality (docs/modules/node.md)
Functionality is basically there in sdk/esp32-esp-idf/components/esp32/reset_reason.c as esp_reset_reason().

Are there any hints or patches to get this working?

Re: node.bootreason missing in build for esp32

PostPosted: Mon Jan 11, 2021 3:51 pm
by aribi
Well, seems I need to do this myself.
Attached is a patch to the firmware that will implement a working node.bootreason()
Probably not ready for commit, but it works for me.
This implementation of node.bootreason will distinguish a panic on the lua level from other types of reboot.
It can be used to intelligently handle a panic situation in init.lua (see demo-init.lua)

Hope this might be useful for someone - it helped me to workout my rather complex system setup