This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Flashing alternating applications nRFgo Studio

Two applications using the same softdevice, s110, blinky and beacon from the examples.

Flashing softdevice and beacon successfully. Replacing beacon app by blinky successfully. Trying to replace blinky by beacon:

"Application .. programming failed. The flash is not erased."

To get beacon back on I have to erase and reflash softdevice! May seem like a minor, but why? Makes me think that there is something that I do not understand about the memory structure.

Why can't I freely flash back and forth different applications in the 0x18000 area without going back and reflash softdevice?

Sorry did not know how to do this since I couldn't add images to comment. Yes both Blinky and Beacon start in 0x18000. But they are using a different address type Extended Segment instead of Extended Linear, I am using the armgcc toolchain if that has something to do with it. image description image description

  • Ok this is now even further narrowed down. When the flash is erased all ones are written to every position, writing to any of the positions works nicely since this means that some positions will go from 1 to 0. Once a position has gone to 0 it can not be brought back to 1 with another write only by a full erase of the flash. Hardware, firmware issue? Doing the same thing in the RAM section works perfectly!

  • nothing surprising there - that's how flash memory works. erase clears it to 1s, only 0s can be written to it, once a bit is zero, it stays that way until everything is erased back to 1.

    but your test above is bogus and has nothing to do with programming the chip. You're just writing words in memory which does exactly that, writes a word in memory. That's not what nrfgo does when it writes a file to memory, it's not what JLink does when it does the equivalent of 'loadbin', it erases the flash it's going to write to (JLink knows how to erase pages) and then writes. Make yourself 2 4-byte bin files and use loadbin to write them alternately to the flash at the same address instead of using w4.

  • Sorry tried this also two bin files one with 0x20002060 and the other with 0x0001830D. Erased flash, flashed the first to memory with loadbin, checked the position with mem32 and correctly read 0x20002060. Flashed the second file with loadbin, checked with mem32, and all zeros.

  • definitely odd as that's why my RKNRFGO code does, just loadbin to replace data (after enabling writes).

    You are passing -device nrf51 to the jlink command line exe right? Just to be sure as that tends to break things if you don't

  • What can I say, no I didn't. Never suspected this since interaction with the device worked nicely in all other aspects. The option -device nrf51 did the trick, also w4 works correctly when having this. Many thanks for you persistence!!

Related