Closed embed-me closed 1 week ago
I have no Idea, what the problem could be. I would try to add more output in the Memory class and the flash methods of the RP2040 platform. The save code is not that much magic. No idea what could go wrong there.
Debugging this problem led me down a rabbit hole, however, I think I found the issue.
During registration of callbacks, getGroupObject is called.
GroupObject& getGroupObject(uint16_t goNr)
{
return _bau.groupObjectTable().get(goNr);
}
Then the groupObjectTable object is returned.
GroupObjectTableObject& BauSystemBDevice::groupObjectTable()
{
return _groupObjTable;
}
Since the input in my example was 0, and an unsigned type is used, the output will be: (uint16_t)0-1 = -1 = 0xffff = 65535
GroupObject& GroupObjectTableObject::get(uint16_t asap)
{
return _groupObjects[asap - 1];
}
Since group objects are raw pointers...
GroupObject* _groupObjects = 0;
... and they reside on the heap, this can't go well once you access your "GroupObject" to register your callback or similar.
bool GroupObjectTableObject::initGroupObjects()
{
//...
_groupObjects = new GroupObject[goCount];
//...
In my case, once I ran through the blocks on the heap during store/free one of the next pointers in the linked list was corrupted and pointed to an address that was NOT 32bit aligned (which the RP4020 requires!) and therefore triggered an exception. The code even contains a check for freeing a block that was never allocated that could have pointed me in the right direction from the very beginning, however, the exception happened before this part of the code 😓
I assume checking goNr in getGroupObject(uint16_t goNr)
to avoid such scenarios in the future could be helpful.
Thank you for you the analysis. As the root cause is solved. I'll close this issue.
Hello,
When I try to program the device the stack gets completely stuck. I use an RP2040 with an attached external flash (128Mbit) on QSPI.
Platformio.ini is based on the example provided in
knx/examples/knx-demo
and looks like below:main.cpp is trivial atm and contains only the bare minimum:
Output on serial line:
Sometimes it goes through, but most of the time not. Also the location where it gets stuck is always slightly different.
Any ideas on how to continue?