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

Add a UART command in APP to enter Bootloader?

I want to add a command ordering by uart to make MCU entering Bootloader mode in app. To achieve this function, I plan to use the two following example in SDK 8.0

ex1.\peripheral\uart

ex2.\dfu\bootloader\pca10028\dual_bank_serial_s110

The procedure would be:

update the app(ex1) by UART dfu → enter app → Enter bootloader mode if the uart port received the letter "q" or "Q".

  1. How do I set the memory of the app(ex1.) if the bootloader memory map is

    IROM1: Start: 0x3C000 Size: 0x3C0 IRAM1: Start: 0x20002C00 Size: 0x1380 IRAM2: Start: 0x20003F80 Size: 0x80

I set the memory like this

IROM1:   Start: 0x18000     Size: 28000
IRAM1:   Start: 0x20002000  Size: 2000

Q1-1/ should I halve the size to 14000 for the dual bank function?

Q1-2/ Can the ram of app and bootloader overlap? Or I have to change the ram size of app to 0xC00?

  1. I add the following two line after the discriminant "if (cr == 'q' || cr == 'Q')" in main.c of ex1.

    NRF_POWER->GPREGRET = 0xB1; NVIC_SystemReset();

Q2-1/ After download the app by uart dfu, the app is work. it will reset and enter bootloader if I send the letter "q", but the uart bootloader can't work again. It stuck in the following line

ble_stack_init(!app_reset);

does the program stuck because the function above only for BLE_UART? Have I run this in UART DFU or I can skip it?

  • @sdrest: Q1-1: The maximum size of application should be smaller than DFU_IMAGE_MAX_SIZE_BANKED as calculated in the bootloader (dfu_types.h). Q1-2: Yes, they can. When switching between bootloader and application, we go through the reset handler for each of them so they can be overlapped. Except for the IRAM2 where we set it at NoInit. But you only need IRAM2 if you planing to share bondinformation between application and bootloader.

    Q2-1: Please have a look at Question #C in this blog.

    If you want to follow our approach to re-use the bondinformation, you should follow what we do in the ble_app_hrs_dfu. In that approach, we don't do reset when jumping to bootloader, therefore we don't do softdevice re-initialization. This is why you have trouble starting bootloader with your code.

    If you set the NRF_POWER->GPREGRET equal something not 0xB1, you should be fine.

Related