New firmware with Zephyr and old bootloader

HI,

two years ago I started my adventure with the nRF52840 microcontroller. I started using SEGGER Embedded Studio for ARM as my development IDE. I created a peripheral BLE device and am able to update the firmware via bluetooth following the pca10056_s140_ble_debug example of the SDK.

Now I want to use Zephyr OS.

My question is: can I still use the bootloader I used previously?

If not, how can I update my device with the new firmware developed with the Zephyr?

Thank you.

Parents
  • Hi,

    It is possible to use the nRF5 Bootloader for nRF Connect SDK application. See  One bootloader to rule them all
    While more complicated, it is also possible to upgrade your application and the bootloader from nRF5 SDK to nRF Connect SDK over OTA. See Hang with nRF5 SDK 17.1.0 Bootloader and nRF Connect SDK 2.1.0 application .

    However, I would start by asking yourself: Do you need to upgrade the firmware on the devices in the field to the nRF Connect SDK? Or could you get by with keeping devices in the field to nRF5 SDK and then use nRF Connect SDK for new devices?

    Regards,
    Sigurd Hellesvik

  • HI,

    I didn't quite understand.

    My situation is this:

    1) I program nRF52840 microcontroller using nRF5_SDK_17.1.0 and SEGGER Embedded Studio for ARM.

    2) as bootloader I used the example pca10056_s140_ble_debug available in the SDK

    3) I create the DFU package using nrfutil tool and the following command

    python nordicsemi/__main__.py pkg generate --application myApplication.hex myApplication.zip --hw-version 1 --sd-req 0x100 --application-version 1 --key-file priv.pem

    4) finally I switch my device to DFU mode and, via the "nRF Connect" app on my smartphone, I connect and send the DFU package.

    Everything works fine.

    Now I want to switch to using the Zephyr.

    I wrote the code for my application using the Zephyr and it works.

    Now I want to create a DFU package to install my application on my device without changing the bootloader. It can be done?

    I tried to create the DFU package using the .hex file generated by the Zephyr:

    python nordicsemi/__main__.py pkg generate --application myZephyrApplication.hex myZephyrApplication.zip --hw-version 1 --sd-req 0x100 --application-version 1 --key-file priv.pem

    The DFU package is created but when I install it on my device nothing works.

    How can I do?

    Thank you

  • I bet you forgot CONFIG_FLASH_LOAD_OFFSET, and your zephyr image will overwrite the MBR

  • Hi Sigurd Hellesvik,

    Thanks for the reply.
    I actually entered the CONFIG_FLASH_LOAD_OFFSET command.
    Below I report the contents of my prj.conf file:

    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    CONFIG_MAIN_STACK_SIZE=4096
    
    CONFIG_BT=y
    CONFIG_LOG=y
    
    CONFIG_BT_SMP=y
    CONFIG_BT_SIGNING=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DIS=y
    CONFIG_BT_ATT_PREPARE_COUNT=5
    CONFIG_BT_PRIVACY=y
    
    CONFIG_BT_DEVICE_NAME="My app"
    CONFIG_BT_DEVICE_APPEARANCE=833
    CONFIG_BT_DEVICE_NAME_DYNAMIC=y
    CONFIG_BT_DEVICE_NAME_MAX=65
    CONFIG_BT_KEYS_OVERWRITE_OLDEST=y
    CONFIG_BT_SETTINGS=y
    
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_SETTINGS=y
    
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_RTT_CONSOLE=y
    CONFIG_CONSOLE=y
    CONFIG_PRINTK=y
    CONFIG_LOG_PRINTK=n
    
    CONFIG_GPIO=y
    CONFIG_PWM=y
    CONFIG_LED=y
    CONFIG_I2C=y
    CONFIG_ADC=y
    CONFIG_DEBUG_OPTIMIZATIONS=y
    CONFIG_DEBUG_THREAD_INFO=y
    CONFIG_LOG_MODE_IMMEDIATE=y
    
    CONFIG_FLASH_LOAD_OFFSET=0x27000 <-------

    Below are the images of the flash after the firmware update:

    As you can see, the firmware is loaded correctly starting from address 0x27000. However, the application doesn't work. How come? Can you help me? Am I forgetting some settings?

    Thank you
    Best regards.

Reply
  • Hi Sigurd Hellesvik,

    Thanks for the reply.
    I actually entered the CONFIG_FLASH_LOAD_OFFSET command.
    Below I report the contents of my prj.conf file:

    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    CONFIG_MAIN_STACK_SIZE=4096
    
    CONFIG_BT=y
    CONFIG_LOG=y
    
    CONFIG_BT_SMP=y
    CONFIG_BT_SIGNING=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DIS=y
    CONFIG_BT_ATT_PREPARE_COUNT=5
    CONFIG_BT_PRIVACY=y
    
    CONFIG_BT_DEVICE_NAME="My app"
    CONFIG_BT_DEVICE_APPEARANCE=833
    CONFIG_BT_DEVICE_NAME_DYNAMIC=y
    CONFIG_BT_DEVICE_NAME_MAX=65
    CONFIG_BT_KEYS_OVERWRITE_OLDEST=y
    CONFIG_BT_SETTINGS=y
    
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_NVS=y
    CONFIG_SETTINGS=y
    
    CONFIG_USE_SEGGER_RTT=y
    CONFIG_RTT_CONSOLE=y
    CONFIG_CONSOLE=y
    CONFIG_PRINTK=y
    CONFIG_LOG_PRINTK=n
    
    CONFIG_GPIO=y
    CONFIG_PWM=y
    CONFIG_LED=y
    CONFIG_I2C=y
    CONFIG_ADC=y
    CONFIG_DEBUG_OPTIMIZATIONS=y
    CONFIG_DEBUG_THREAD_INFO=y
    CONFIG_LOG_MODE_IMMEDIATE=y
    
    CONFIG_FLASH_LOAD_OFFSET=0x27000 <-------

    Below are the images of the flash after the firmware update:

    As you can see, the firmware is loaded correctly starting from address 0x27000. However, the application doesn't work. How come? Can you help me? Am I forgetting some settings?

    Thank you
    Best regards.

Children
  • Stefano1984 said:

    How come? Can you help me? Am I forgetting some settings?

    How does the same addr map look for a nRF5 application?

    Do you get any logs at all?

  • Hi Sigurd Hellesvik,

    Thanks for the reply.

    I don't understand what I need to check.

    Can you explain it better? I'm new to Zephyr.

    Thank you.

  • I want to see if this image looks the same for NCS and nRF5 apps.

    Sigurd Hellesvik said:
    Do you get any logs at all?

    Specifically UART logs from the application

    Stefano1984 said:
    Can you explain it better? I'm new to Zephyr.

    In case you have not seen it yet, I highly recommend https://academy.nordicsemi.com/ to learn.

  • Thanks for the suggestion.
    Actually if I start the firmware in debug I get an error when I execute the following line of code (I think):


    err = bt_enable(NULL);

    The error is as follows:

    [00:00:00.474,182] <inf> fs_nvs: No GC Done marker found: restarting gc
    [00:00:00.474,945] <err> os: ***** BUS FAULT *****
    [00:00:00.475,280] <err> os:   Imprecise data bus error
    [00:00:00.475,646] <err> os: r0/a1:  0x00000000  r1/a2:  0x00000000  r2/a3:  0x00000040
    [00:00:00.476,135] <err> os: r3/a4:  0x00000000 r12/ip:  0x00000000 r14/lr:  0x0006e9cf
    [00:00:00.476,623] <err> os:  xpsr:  0x41000000
    [00:00:00.476,959] <err> os: Faulting instruction address (r15/pc): 0x0004b760
    [00:00:00.477,416] <err> os: >>> ZEPHYR FATAL ERROR 26: Unknown error on CPU 0
    [00:00:00.477,874] <err> os: Current thread: 0x20003ab8 (idle)
    [00:00:00.483,184] <err> fatal_error: Resetting system

    This below is the image of the flash with only the bootloader:

    Below is the image of the flash with the bootloader and the nRF5 application:

    Finally, below is the image of the flash with the bootloader and the Zephyr application:

  • Stefano1984 said:
    The error is as follows:

    It is very good to know that we get logs! It does mean that we are indeed able to run the new app.
    So, that means we know that load offset is correct.

    In that case, we need to debug the application itself.

    Just to sanity-check: The application works with only zephyr (No bootloader), correct?

     The bus fault happens in the idle thread (Current thread: 0x20003ab8 (idle)).
    Try increasing CONFIG_IDLE_STACK_SIZE.

    Stefano1984 said:
    err = bt_enable(NULL);

    Then try to DFU to an application without BLE first. For example hello_world. Seeing if such an app works would give valuable information.

    If such an app works, try to update into one of our BLE examples, unchanged aside from flash load offset. Then see if those work.

Related