so this is something weird I encountered.
Every time I use an eraseall statement and download my firmware, the chip doesnt start up immediately unless I reset it 4 times. Any idea on this?
so this is something weird I encountered.
Every time I use an eraseall statement and download my firmware, the chip doesnt start up immediately unless I reset it 4 times. Any idea on this?
Hi,
Seen from the nRF there is nothing that explains why you would need 4 resets. It could be that something happens on external circuitry (that is affected by your firmware running and behaving differently on each iteration based on that), or that you read and write persistent data to flash and act differently on that, for instance. There could also be something else.
To fix the issue, you first need to understand what is going on. To figure that out, I suggest you erase, download firmware, and reset once, then attach your debugger to see what state the device/your firmware is in.
Hi,
Seen from the nRF there is nothing that explains why you would need 4 resets. It could be that something happens on external circuitry (that is affected by your firmware running and behaving differently on each iteration based on that), or that you read and write persistent data to flash and act differently on that, for instance. There could also be something else.
To fix the issue, you first need to understand what is going on. To figure that out, I suggest you erase, download firmware, and reset once, then attach your debugger to see what state the device/your firmware is in.
Hi I have done that, my firmware halts at this point:
thought your suggestion on the flash writes might be right since it doesn't happen if I don't erase all data

some more info:
the first thing I do is to init ble. after that I will init my flash (but it doesn't reach that point when the nRF hardfaults)
I am using SDK 17.1. without Zephyr. I am using a custom PCB but I don't really understand how a circuit could be the problem, can you maybe elaborate on this?
Hi,
From the call stack I see that you ended up in the hardfault handler. That could be caused by several things, like for instance dereferencing an invalid pointer (or something else). I suggest you start by adding a hardfault handler and take it from there. See for instance How to add the hardfault handler on nRF SDK.
I tried this once but the hardfault handler doesn't trigger although I followed those steps meticulously
after enabling the hardfault breakpoint the call stack just doesn't show anything any more
That is odd. Alternatively then you can look at what happens before, where you are writing to flash via fstorage. Could it be that some pointer values are wrong for some reason? Are you basing something upon data that will be but have not yet been written to flash, or something else? If it is difficult to find it by inspection, and you cannot get the hardfault handler working, then a third alternative could be to comment out parts of your code and gradually include more to narrow down the problematic part.