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

FOTA, nrf52833_DK and Zephyr

Hi and nice to meet you,

I freshly get my nrf52833 DK. I'm working on windows. I have installed via nRF Desktop all necessary tools.

We are moving our project from nxp KW41Z to Nordic 52833 ;) expecting to have easiest developpement , and we have a lot of hope concerning OTA that was a nightmarre from android point of view with nxp...

I followed the tutorial and i'm able to list with nrf Connect for mobile the SMP service that i add to peripheral_hr sample project. Also, I see a DFU picture now, giving me the possibility to upload the new image i have generated ( blinky led example with CONFIG_BOOTLOADER_MCUBOOT=y.

But When i upload, nothing end, it run in loop doing nothing...

1) With DFU from NRf Toolbox, after selecting the file, App ask for an "Init packet", so i have the feeling DFU from Toolbox is not usable with Zephyr FOTA process. I'm i right ? 

2) I have a doubt concerning the bootloader flashed into my device. I'm not sure if it is the good MCUboot required to do OTA firmware update. So i would like to flash this MCUBoot bootloader. I tried to build it for my board, so i checkout the mcuboot_master, and try to build it for nrf52833_pca10100.overlay that i create from dts file and keep only the flash0 section.

Before to go deeper, is it the good step to follow please, i'm doubting if i have to do all this step and if it is the good direction to take? Is the bootloader the probleme please ?

Please find below the console boot sequence.

So it seems it is mcuboot, but does it support OTA or do i need a special mcuboot, this i'm not sure.

Thanks a lot for your explaination and i hope to succeed with this nrf52833 

<NUL>*** Booting Zephyr OS build v2.1.99-ncs1  ***
[00:00:00.002,960] <ESC>[0m<inf> mcuboot: Starting bootloader<ESC>[0m
[00:00:00.009,185] <ESC>[0m<inf> mcuboot: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3<ESC>[0m
[00:00:00.019,622] <ESC>[0m<inf> mcuboot: Boot source: none<ESC>[0m
[00:00:00.025,299] <ESC>[0m<inf> mcuboot: Swap type: none<ESC>[0m
[00:00:00.252,502] <ESC>[0m<inf> mcuboot: Bootloader chainload address offset: 0xc000<ESC>[0m
[00:00:00.260,437] <ESC>[0m<inf> mcuboot: Jumping to the first image slot<ESC>[0m
*** Booting Zephyr OS build v2.1.99-ncs1  ***
Bluetooth initialized
Advertising successfully started
[00:00:00.005,615] <ESC>[0m<inf> bt_hci_core: HW Platform: Nordic Semiconductor (0x0002)<ESC>[0m
[00:00:00.005,615] <ESC>[0m<inf> bt_hci_core: HW Variant: nRF52x (0x0002)<ESC>[0m
[00:00:00.005,615] <ESC>[0m<inf> bt_hci_core: Firmware: Standard Bluetooth controller (0x00) Version 2.1 Build 99<ESC>[0m
[00:00:00.006,317] <ESC>[0m<inf> bt_hci_core: Identity: c1:55:9c:f4:51:dd (random)<ESC>[0m
[00:00:00.006,317] <ESC>[0m<inf> bt_hci_core: HCI: version 5.1 (0x0a) revision 0x0000, manufacturer 0x05f1<ESC>[0m
[00:00:00.006,317] <ESC>[0m<inf> bt_hci_core: LMP: version 5.1 (0x0a) subver 0xffff<ESC>[0m
Connected

  • Hello, 

    My apologies for the late reply. I will look into this. 

    What is the application you are targeting? Do you need NCS or could you use the nRF5 SDK? Thanks for clarifying! 

    Kind regards,
    Øyvind

  • HI Oyvind, 

    It is a professionnal project, Thomas can give you more details about it :).

    As we are redesign it, i would start from the latest sdk to benefit of better support. Learn and work on an Rtos also interested me more to get state of the art knowledge.

    I spent time to instal linux in dual boot with windows. I think it is easier to develop as all the tools are not supported on windows for OTA ( mainly mcumgr).

    So at the moment, i can build and debug on my nRF52833 DK. I started with peripheral_hr sample from zephyr folder.

    My idea is to follow this plan:

    1.  OTA Nordic :  
      1. Add the three lines of code to have the smp services like I did before by following this guide http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_nrf52.html#fota-upgrades .
      2. Check that i can update firmware Over the air with nrfConnect android app. NXP didn't give the source for android. It is the main reason for us to change to nordic, you have to develope all the protocol stack.... We use Flutter. It seems there is source code for flutter that should works with previous sdk5. I found here smartphone code for Android and Ios to update with mcuboot, so Zephyr so NrfConnect new sdk. But is is not flutter but native code. Do you plan to post official sources for flutter to avoid having two separate App please ? This question is really crucial for us and can decide if we should continue with thenewest sdk or not.
      3. Source for mobile app:https://github.com/fengqiangboy/flutter-nordic-dfu   and new sdk : https://github.com/JuulLabs-OSS/mcumgr-android   and    https://github.com/JuulLabs-OSS/mcumgr-ios
    2. Then add my drivers to connect my sensors in i2c and spi ( just use gpio and delay_us function).
    3. Add my ble services for my sensors and check communication with our mobile app.
    4. Buy the Power profile kit to optimize sleep mode and consumption (this tool looks very nice and will help us a lot! )

    So as you can understand, OTA is really determinant for us and the more we use offical and robust solution the best it is. Thomas recommand me to use latest sdk. I'm also personnaly interested in working on rtos. I understood that if we choose sdk5 we will never be able to go on new connect sdk because of compatibilty to upgrade bootloader will not work anymore. So here is the really important decision :) . OTA is not just to enjoy, our product is placed somewhere you can't easily access, so even during protype and developpement step, we will use it a lot.

    The best will be to use latest sdk, with flutter source code that works for sdk5. I don't know yet if it possible. I have the feeling that no, because i can't dfu my zephyr based software with nrfconnect mobile app. that's why i go on Linux, to try with mcumgr and check if problem comes from compatibility with nrfconnect app or not. I don't know if dfu and fota prcedure are similar because zephyr use smp service to do it and nordic i don't know yet. But what is interrested is that afdter followng the tutorial, i see DFU picture appear on nordic mobil app.

    Sorry to be a bit long, i hope we will clearify the situation to move ahead.

  • Hi,

    I succeed in uploading with nrf Connect android app the blinky example. I first flashed the SMP_SVR example from zephyr ( we can see that it automatically build mcu boot ) . Then i flash ( we also see that it erase and flash bootloader AND application in one operation). So main difference with my first test was that i started from smp_svr and not Heart rate sensor peripheral in samples where i add the three lines of code. 

    Another stuff was that i was not able to generate by command line the signed hex. i get this error : 

    flo@TP:~/nordic/ncs/zephyr/samples/basic/blinky$ west sign -t imgtool -- --key ../../../../bootloader/mcuboot/root-rsa-2048.pem 
    === image configuration:
    partition offset: 49152 (0xc000)
    partition size: 204800 (0x32000)
    text section offset: 0 (0x0)
    === signed binaries:
    bin: /home/flo/nordic/ncs/zephyr/samples/basic/blinky/build/zephyr/zephyr.signed.bin
    Usage: imgtool sign [OPTIONS] INFILE OUTFILE
    
    Error: Invalid value for "-H" / "--header-size": Minimum value for -H/--header-size is 32
    ERROR: command exited with status 2: /home/flo/.local/bin/imgtool sign --version 0.0.0+0 --align 4 --header-size 0 --slot-size 204800 --key ../../../../bootloader/mcuboot/root-rsa-2048.pem /home/flo/nordic/ncs/zephyr/samples/basic/blinky/build/zephyr/zephyr.bin /home/flo/nordic/ncs/zephyr/samples/basic/blinky/build/zephyr/zephyr.signed.bin

    I was able to receive echo "Hello" from smp server by using mcumgr with Linux command line but only in root. I add lp ,bluetooth and dialout group to my user but i still get hci0 permission error:

    flo@TP:~/nordic/ncs/zephyr/samples/basic/blinky/build/zephyr$ mcumgr --conntype ble --connstring 'peer_name=Zephyr' image list
    Error: [hci0]: can't init hci: can't down device: operation not permitted
    

    So now i have pieces of information. I think flutter source code should work if nrfConnect use the same base code .  Can you confirm this or give more advanced detail on how it works between both side please ? Thank you :)

    I would like also understand why the three lines of code didn't allow me to flash properly. Maybe smp_svr should always be the base for my application where i add code for services etc instead of starting from HRS example. ALso , the hex looks quiet heavy. I need to understand deeper if it always flash in slot0 or if it split the memory in two to securely move from slot0 to slot1 after checking by mcu boot. if .hex is too big who decide of the slot0 only or slot0/1 strategye please ?

    Thanks a lot for your help

  • Hi Olfox,

    I am doing a similar thing and here is some advice on doing FOTA with Zephyr and MCUboot:
    * good point of start is smp_svr application you already found, read more in this issue: https://devzone.nordicsemi.com/f/nordic-q-a/60991/nrf52-zephyr-dfu

    * you do not have to sign the image as this is done automatically by west command, I am still waiting on some responses on this subject check the issue: https://devzone.nordicsemi.com/f/nordic-q-a/61048/signing-zephyr-images---west-sign

    * if you want to add FOTA to your application, it is best to "merge" it with smp_svr app.

    Best regards,
    Vojislav.

  • Hi Vojislav :) . I previously saw your topics on the same sugbject :) it help me a lot to succeed thanks you.

    This morning i made a test. I did two copy of smp_svr folder that i rename blink_fas and blink_slow. I merged into the main.c the code of basic example blinky.

    Then, i flash my nrf52833DK with west flash and blink slow.

    Next step, i was able to update with nrfConnect mobil app the blink_fast.bin (app_update.bin. of blinck fast project renammed). I took let say 1minutes because it upload at only 1.1kb /sec. I had to do it two times , first rsulting in a fail i don't know why.

    Success, the led blick fast now, and i can also update firmware because there is still smp server running.

    I try to upload with Nrf Toolbox but it doesn't work : DFU characteristik not found ... normal let say. But this means nrfToolbox and nrfConnect doesn't use the same code to do dfu operation. I hope flutter code has been generated with nrfConnect source as model.

    Third test: i want to upload blinck_slow, this time not by using the cable but OTA. Ans it takes like 5 sec ! It is just a verification step, what proov that a check is done internally ( i don't know by who in the software) to know if this image is already inside on the second slot or not, if yes, it just check it is ok and reply OK to the mobil app. It confirm me that there is well the two software on the two slot.

    But i don't know yet what's happen if the .bin is bigger than the size of one slot. May bewe loose this behavior and image will always overide the tull memory.

    So next step is to integrate new ble service and also check with flutter code that it works !

    How do you manage the mobil app side Vojislav ?

    Thanks ;)

Related