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

Writing an SPI bootloader for nRF51822 - no softDevice in bl

Hi,

As I’ve mentioned in a previous post (answered ! Thank you Aryan !), I'm writing a bootloader for nrf51822 to be able to update the nRF51's firmware through SPI (data transferred via an STM32 retrieving the file through USB).

My idea is to place a very basic bootloader at @0x0 through 0x37FF, and the firmware starting at 0x3800 to 0x3FFFF.

I want to keep memory usage as low as possible and to have the possibility to upgrade softDevice later. That's why I would rather not having softdevice in the bootloader. In the user code, I don’t use Bluetooth and intend, for now, to use only esb protocol. So, I just include esb_sd_resources_arm.lib

Without the bootloader it’s working fine. But when I try to relocate the user code to 0x3800, problems happen.

With a simple program blinking an LED (no interrupt) the whole bootloader + update + boot is working.

But with the same blinking program modified to use timer interrupt instead of a simple loop, it doesn’t work (and it’s obviously the same with my main program, using interrupts and esb). I’m pretty sure something is wrong with the interrupt vector table. I’ve read that due to Cortex M0 limitations, IVT cannot be relocated. But my idea was to branch, in my bootloader, each interrupt I use in the user code to a specific address at the beginning of user code, which would again branch to the interrupt handler function. This way I should be able to re-root my interrupt and still be not limited with a pre-defined size for each interrupt handler.

To do that, do I have to make any modification to arm_startup_nrf51.s?

Is there something wrong with my idea? Should it work or am I misdirecting?

No doubt a little more information about how esb_sd_resources_arm.lib manages the interrupt would help… Can you please describe how it works, where the handler are placed in memory, etc? I’ve been looking for an application note of some kind about this but without success.

Thank you for your help and concern

Regards

Landry

Related