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

Very simple SPI bootloader

Hi,

I'm implementing a simple bootloader which will not use BLE.

  • Application will transfer the data from mobile devices using BLE and this data will be stored to external SPI flash memory. I've already managed to make writing/reading data over SPI.
  • Custom bootloader should only read and verify data from external SPI flash and write that data to nRF flash. Bootloader should be able to update any address on the chip except itself, meaning that we want this bootloader to be able to update SoftDevice also. After it flashes what it needs to flash, it should go into newly flashed application.

I have trouble understanding vector mapping and how to do it right. Can someone please give an example with a bit more explanation?

Thnx!

  • Exactly! Basically I need a simple "app" which can read SPI flash, write nRF flash, blink some LEDs, and print to uart(debug). I've already done something like that but when I change addressees of flash as they are in DFU examples, my bootloader example won't start when flashed. Must I change some other stuff too? Also, vector handling is a problem here since I can't use sd_softdevice_vector_table_base_set(), correct?

  • UICR->BOOTLOADERADDR must correspond to the start address of your bootloader so the MBR will start forwarding interrupts to the bootlaoder and "jump" to the bootloader on startup.

    You can use sd_softdevice_vector_table_base_set() once you have invoked the softdevice. See the functions that needs to be called to enter the application above in my answer

  • My small code example works ok now! UICR->BOOTLOADERADDR was the problem. Thank you!

    I would like to make this bootloader totally independent of SoftDevice. Is that possible? Imagine this scenario. There is no SD. App does not use SD. MBR is flashed and valid. How would I jump from bootloader to application? And how would I set interrupt forwarding address (application vector table) to application and vice versa without SD?

    If I code a bootloader which will use sd_softdevice_vector_table_base_set(CODE_REGION_1_START), what would happen if you change the address of that function(example: SD becomes bigger than 96kb) in new SD version? My bootloader would become invalid(outdated), correct? And I would have to update a new bootloader also. But the idea is to make this bootloader as MBR, it should never ever need an update. Is that possible? If yes, how?

  • The CODE_REGION_1_START is stored in the SDs info structure at 0x3000, and thus updated when you have uploaded a new SD. In your case it's the application that's actually receiving the image, and the bootloader will only handle the swapping of images, right? So you need to ensure that your application is always compatible with the SD to allow new DFU attempts. There should not be any need to update the bootloader itself.

Related