Bootloader from SDCard

Hi, 

I need to add to my project that uses NRF5340 a bootloader that reads new firmware from SDCard. Is there an example where I can find information? Someone has just encountered this kind of issue and can tell me some tips?

Thanks

Marco

Parents Reply Children
  • Hi Vidar, 

    By using the nrfjprog the update works:

    *** Booting Zephyr OS build v3.1.99-ncs1-1  ***
    I: Starting bootloader
    I: Primary image: magic=good, swap_type=0x2, copy_done=0x1, image_ok=0x3
    I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    I: Swap type: revert
    I: Starting swap using move algorithm.
    I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Bootloader chainload address offset: 0xc000
    *** Booting Zephyr OS build v3.1.99-ncs1-1  ***
    Hello from AM Microsystems!

    I also checked the address and it is correct. Why doesn't work with SD? Maybe need I to enable some flag after copy the firmware?

    Best

    Marco 

  • Hi Marco,

    Can you read the memory content in the secondary slot after loading it from the sd card and after programming the .hex to see if there is any difference? 

    $ nrfjprog --memrd <secondary slot start address> --n <size of secondary slot in bytes > secondary_slot.txt

    Best,

    Vidar

  • Hi Vidar, 

    sorry, I need to fix my last answer: yes, I can send the new firmware by using your command into the second partition and mcuboot recognize it (the code of my last answer), but the firmware is not updated! Sob

    Anyway, I try to read the secondary partition and the two version differ only on the last 256Byte. But I don't know why!

    Best,

    Marco

  • Hi Vidar,

    Sorry again, but there is something strange: after a firmware update correct (only with your method, not by SD), the microcontroller start with a string that print the new version value... but after a reset a new firmware update was performed without my command and turn back to the first version. What is it wrong? The log is the following.

    *** Booting Zephyr OS build v3.1.99-ncs1-1  ***
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    I: Swap type: none
    I: Bootloader chainload address offset: 0xc000
    *** Booting Zephyr OS build v3.1.99-ncs1-1  ***
    Hello from AM Microsystems!
    Version: 1.0.1
    
    update from usb by using nrfjprog
    
    *** Booting Zephyr OS build v3.1.99-ncs1-1  ***
    I: Starting bootloader
    I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Secondary image: magic=good, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    I: Swap type: test
    I: Starting swap using move algorithm.
    I: Bootloader chainload address offset: 0xc000
    *** Booting Zephyr OS build v3.1.99-ncs1-1  ***
    Hello from AM Microsystems!
    Version: 1.0.5
    
    ... application running
    
    *** Booting Zephyr OS build v3.1.99-ncs1-1  ***
    I: Starting bootloader
    I: Primary image: magic=good, swap_type=0x2, copy_done=0x1, image_ok=0x3
    I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Boot source: none
    I: Swap type: revert
    I: Starting swap using move algorithm.
    I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
    I: Bootloader chainload address offset: 0xc000
    *** Booting Zephyr OS build v3.1.99-ncs1-1  ***
    Hello from AM Microsystems!
    Starting SGuideV3 from VOX
    Version: 1.0.1
    
    application running

    By SD no magic word was set!

    Best,

    Marco

  • Hi Marco,

    After the image was copied from the SD card to the secondary slot, did you run boot_set_pending()? This marks the image as a pending update, which includes writing of the magic word.

    warcomeb-am said:
    but after a reset a new firmware update was performed without my command and turn back to the first version.

    MCUBoot will revert the update if the image is not confirmed as the hex file contains a "test" image. You can read more about the different swap types here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/mcuboot/design.html#boot-swap-types.

    To make a "test" image permanent, you can call boot_set_confirmed() from the new app.

    Best,

    Vidar

Related