This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Protect bootloader from overwrite/erase

I am using Nordics sample bootloader and I really want to make sure that given a freak accident in sending it the firmware or in the firmware code itself that the bootloader is never erased or overwritten. In its current state, is the bootloader protected against that or are there measures I can take to accomplish it?

I have also noticed the call sd_flash_protect, but I am not sure if that is the proper approach and if so how to use it.

Thanks,

Parents
  • You can use the registers PROTENSETx to protect you bootloader. If you have enabled the softdevice these registers are accessed through the sd_flash_protect call. PROTENSETx enables you to protect 64 different blocks of the memory. For the nRF51x22 these blocks are 4 k big.

    Update: main.c I edited the standard .../nRF6310/S110/bla_app_hrs example. The main file is above here. I added code to set the PROTENSET and protect the upper half of flash and then try to write to that area. It fails and gives me an error code.

    UPDATE 2: Always make sure that you are using nRF51 of second revision if you are using sd_flash_protect() or PROTENSET. On nRF51 revision 1 this functionality is not available.

  • I added in the call sd_flash_protect(0,0xFFFFFFFF); to the bootloader after the softdevice is enabled just to verify that it will hardfault(per spec) instead of completing its process. I know the bootloader is not only erasing that area, but my firmware is getting written to that area as it is almost 100K in size. Using this to test, I not only have been able to successfully write firmware every time, but I have been able to erase the bootloader.

    I have tested this with and without a debugger connected.

Reply
  • I added in the call sd_flash_protect(0,0xFFFFFFFF); to the bootloader after the softdevice is enabled just to verify that it will hardfault(per spec) instead of completing its process. I know the bootloader is not only erasing that area, but my firmware is getting written to that area as it is almost 100K in size. Using this to test, I not only have been able to successfully write firmware every time, but I have been able to erase the bootloader.

    I have tested this with and without a debugger connected.

Children
No Data
Related