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.

  • 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?

Reply Children
  • 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.

  • Hi.

    Thanks for the suggestion.

    I have some news.
    I found that if I enter the statement CONFIG_FLASH_LOAD_OFFSET=0x27000 without bootloader it doesn't work. No reply. Not even if I start debugging.

    The only thing I can tell you is that on the debug terminal I read the following lines:

    JLinkGDBServerCL: SEGGER J-Link GDB Server V7.94e Command Line Version
    JLinkGDBServerCL: 
    JLinkGDBServerCL: JLinkARM.dll V7.94e (DLL compiled Jan 15 2024 15:18:46)
    JLinkGDBServerCL: 
    JLinkGDBServerCL: -----GDB Server start settings-----
    JLinkGDBServerCL: GDBInit file:                  none
    JLinkGDBServerCL: GDB Server Listening port:     55862
    JLinkGDBServerCL: SWO raw output listening port: 2332
    JLinkGDBServerCL: Terminal I/O port:             2333
    JLinkGDBServerCL: Accept remote connection:      localhost only
    JLinkGDBServerCL: Generate logfile:              off
    JLinkGDBServerCL: Verify download:               off
    JLinkGDBServerCL: Init regs on start:            off
    JLinkGDBServerCL: Silent mode:                   on
    JLinkGDBServerCL: Single run mode:               on
    JLinkGDBServerCL: Target connection timeout:     0 ms
    JLinkGDBServerCL: ------J-Link related settings------
    JLinkGDBServerCL: J-Link Host interface:         USB
    JLinkGDBServerCL: J-Link script:                 none
    JLinkGDBServerCL: J-Link settings file:          none
    JLinkGDBServerCL: ------Target related settings------
    JLinkGDBServerCL: Target device:                 nrf52840_xxaa
    JLinkGDBServerCL: Target device parameters:      none
    JLinkGDBServerCL: Target interface:              SWD
    JLinkGDBServerCL: Target interface speed:        12000kHz
    JLinkGDBServerCL: Target endian:                 little
    JLinkGDBServerCL: 
    =thread-group-added,id="i1"
    =cmd-param-changed,param="pagination",value="off"
    0xfffffffe in ?? ()
    [New Remote target]
    [New Thread 536886128]
    [New Thread 536885944]
    [New Thread 536885728]
    [New Thread 536886312]
    [New Thread 536881984]
    [New Thread 536881440]
    [New Thread 536882200]
    [New Thread 536882384]
    [New Thread 536885544]
    
    Thread 2 received signal SIGTRAP, Trace/breakpoint trap.
    0xfffffffe in ?? ()
    Execute debugger commands using "-exec <command>" or "`<command>", for example "-exec info registers" or "`info registers" will list registers in use (when GDB is the debugger)

    At this point I created another project that only prints Hello Word.

    With the instruction CONFIG_FLASH_LOAD_OFFSET=0x27000 without bootloader it doesn't work.

    However with the instruction CONFIG_FLASH_LOAD_OFFSET=0x27000 with bootloader IT WORKS.

    What could my problem be?

Related