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

Custom firmware updater (dual bank) on nrf51822 + s130 ?

Hello.

How to write custom firmware updater, which:

  1. Takes new firmware from other device on SPI or I2C bus.

  2. Writes it to flash ("bank1" at 0x1B000, or "bank2" at 0x25000), for example, with ble_flash_word_write() (BLE radio is off at that moment).

3) Updates something in flash memory to start from "bank1" or "bank0", so selected firmware starts after reset. ?

Especially interested in (3) - where to change firmware starting address? By default firmware starting address in flash memory is 0x1B000 - how to change this default?

Thanks!

P.S.

Keil reports "Component is incompatible with versions of other selected components" when I select nRF_Libraries->DFU->dfu_bootloader and asks me to use s110 stack, while I'm using s130 2.0.0-7.alpha That's why I decided to write own simple firmware updater rather than use existing DFU, incompatible with s130.

Parents
  • I'd recommend downloading SDK v.11.0.0 alpha as it's already configured for the s130 2.0.0-7.alpha and includes the serial bootlaoder. Note that this example is using UART, but can be modified to use a different transport layer as long as it's reliable.

    The sd_softdevice_vector_table_base_set() call is used to tell the softdevice to where the application is located. That is, where it should forward interrupts. This SV instruction is called from the bootloader before branching to the application.

  • Thanks.

    But examples at examples\dfu\bootloader\ are for nRF51422_xxAC chip, while I'm have nRF51822_xxAA with less RAM and Flash.

    Could you please explain how "forward interrupts" works internally? I.e. does sd_softdevice_vector_table_base_set() copy new interrupt vector table to default location or someting else?

    Now I'm trying to implement bare minimum bootloader, where all functions are in main.c only, which:

    1. starts itself - it works now.
    2. starts default application - it doesn't work now, it hangs (HardFault interrupt) at sd_softdevice_vector_table_base_set(CODE_REGION_1_START) call.

    http://pastebin.com/S4wt1fsn - all the bootloader code is 325 lines, it initializes UART and waits 's' char from terminal to start application at 0x1B000 (for test purposes) that already flashed aerlier. But unfortunately it doesn't work, maybe I forgot some initialization code? should I initialize s130 in bootloader if s130 softdevice present in flash ?

Reply
  • Thanks.

    But examples at examples\dfu\bootloader\ are for nRF51422_xxAC chip, while I'm have nRF51822_xxAA with less RAM and Flash.

    Could you please explain how "forward interrupts" works internally? I.e. does sd_softdevice_vector_table_base_set() copy new interrupt vector table to default location or someting else?

    Now I'm trying to implement bare minimum bootloader, where all functions are in main.c only, which:

    1. starts itself - it works now.
    2. starts default application - it doesn't work now, it hangs (HardFault interrupt) at sd_softdevice_vector_table_base_set(CODE_REGION_1_START) call.

    http://pastebin.com/S4wt1fsn - all the bootloader code is 325 lines, it initializes UART and waits 's' char from terminal to start application at 0x1B000 (for test purposes) that already flashed aerlier. But unfortunately it doesn't work, maybe I forgot some initialization code? should I initialize s130 in bootloader if s130 softdevice present in flash ?

Children
No Data
Related