nrf9160 always recovers when updating applications

Hello,

I used two samples, application_update and SLM, to test and try updating the app from application_update to SLM. I first downloaded the firmware of application_update v1 version to 9160, and the LED 1 on 9160dk lit up to indicate that the v1 version was being used. Then, I renamed the bin file of SLM to app_2RF9160dk_2.50_v2. bin and uploaded it to the server. Next, I pressed the button 1, 9160dk to download the v2 firmware normally (but in reality, it was SLM). After downloading, I pressed the button 1 again to update the app to SLM, 9160dk also successfully ran SLM,but after restarting, the bootloader restored the firmware to application_update, even though I had already called boot_writd_img_confirmed in the main function of SLM. I also try to call boot_is_img_confirmed in the main function of slm to check whether the firmware is confirmed. The return value is 0, indicating that it is normal.

When I tested with application_update, everything was fine. 9160 can switch between v1 and v2 versions without automatically restoring to the previous version, but replacing v2's bin with SLM is not possible. I don't know which step I overlooked or made wrong?

Thank you.

  • hi JyriLehtinen

    Thank you for your reply. I tried according to your method, but there was an error during the build.

    I am now trying to directly port the code of app_update to SLM, so that there is no need to update from app_update to SLM, which can probably avoid partition issues

  • Hi,

    llly said:
    I am now trying to directly port the code of app_update to SLM, so that there is no need to update from app_update to SLM, which can probably avoid partition issues

    I hope that you will be successful. When you are done, please provide an update.

    llly said:
    hank you for your help. I also think it's a partition issue, but I'm still researching how to adjust it. I tried to copy the content of app_update/build/partitions.yml to slm/pm_static.yml using JyriLehtinen's method, and added set(PM_STATIC_YML_FILE ${CMAKE_CURRENT_LIST_DIR}/pm_static.yml CACHE INTERNAL "") to the SLM project CMakeLists.txt, but there was an error during the build process

    To examine this, we would need build log.

    Best regards,
    Dejan

  • Thank you for your wishes.The method of porting code was not very successful. It was able to download the firmware normally and prompted to restart to apply the new firmware after the download was completed. The first startup after the restart was much slower than normal, which should be when the new firmware was applied, but it was still running the old firmware after startup.I will continue to study this in the future.

  • This is about the error message after using pm_static.yml

    -- Found partition manager static configuration: F:/nrf9160_app/serial_lte_modem/pm_static.yml
    Partition 'mcuboot' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_pad' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_primary' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_primary_app' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_secondary' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_sram' is not included in the dynamic resolving since it is statically defined.
    Partition 'nrf_modem_lib_ctrl' is not included in the dynamic resolving since it is statically defined.
    Partition 'nrf_modem_lib_rx' is not included in the dynamic resolving since it is statically defined.
    Partition 'nrf_modem_lib_sram' is not included in the dynamic resolving since it is statically defined.
    Partition 'nrf_modem_lib_tx' is not included in the dynamic resolving since it is statically defined.
    Partition 'sram_nonsecure' is not included in the dynamic resolving since it is statically defined.
    Partition 'sram_secure' is not included in the dynamic resolving since it is statically defined.
    Partition 'tfm' is not included in the dynamic resolving since it is statically defined.
    Partition 'tfm_nonsecure' is not included in the dynamic resolving since it is statically defined.
    Partition 'tfm_secure' is not included in the dynamic resolving since it is statically defined.
    Partition 'tfm_sram' is not included in the dynamic resolving since it is statically defined.
    Partition manager failed: End of last partition is after last valid address
    Failed to partition region sram_primary, size of region: 262144
    Partition Configuration:
    mcuboot_sram:
    size: 32768
    nrf_modem_lib_ctrl:
    placement:
    after:
    - tfm_sram
    - start
    size: 1256
    nrf_modem_lib_rx:
    placement:
    after:
    - nrf_modem_lib_tx
    size: 8192
    nrf_modem_lib_sram:
    size: 17768
    nrf_modem_lib_trace:
    placement: {}
    size: 16384
    nrf_modem_lib_tx:
    placement:
    after:
    - nrf_modem_lib_ctrl
    size: 8320
    sram_nonsecure:
    size: 229376
    sram_primary:
    size: 211608
    sram_secure:
    size: 32768
    tfm_sram:
    placement:
    after:
    - start
    size: 32768

    CMake Error at F:/nordic/ncs_v2.6.1/nrf/cmake/partition_manager.cmake:331 (message):
    Partition Manager failed, aborting. Command:
    C:/ncs/toolchains/cf2149caf2/opt/bin/python.exe;F:/nordic/ncs_v2.6.1/nrf/scripts/partition_manager.py;--input-files;F:/nrf9160_app/serial_lte_modem/build/mcuboot/zephyr/include/generated/pm.yml;F:/nrf9160_app/serial_lte_modem/build/zephyr/include/generated/pm.yml;F:/nrf9160_app/serial_lte_modem/build/modules/nrf/subsys/partition_manager/pm.yml.settings;F:/nrf9160_app/serial_lte_modem/build/modules/nrf/subsys/partition_manager/pm.yml.libmodem;F:/nrf9160_app/serial_lte_modem/build/modules/nrf/subsys/partition_manager/pm.yml.tfm;F:/nrf9160_app/serial_lte_modem/build/modules/nrf/subsys/partition_manager/pm.yml.trustzone;F:/nrf9160_app/serial_lte_modem/build/modules/nrf/subsys/partition_manager/pm.yml.mcuboot;--regions;sram_primary;otp;flash_primary;--output-partitions;F:/nrf9160_app/serial_lte_modem/build/partitions.yml;--output-regions;F:/nrf9160_app/serial_lte_modem/build/regions.yml;--static-config;F:/nrf9160_app/serial_lte_modem/pm_static.yml;--sram_primary-size;0x40000;--sram_primary-base-address;0x20000000;--sram_primary-placement-strategy;complex;--sram_primary-dynamic-partition;sram_primary;--otp-size;756;--otp-base-address;0xff8108;--otp-placement-strategy;start_to_end;--flash_primary-size;0x100000;--flash_primary-base-address;0x0;--flash_primary-placement-strategy;complex;--flash_primary-device;flash_controller;--flash_primary-default-driver-kconfig;CONFIG_SOC_FLASH_NRF
    Call Stack (most recent call first):
    F:/nordic/ncs_v2.6.1/zephyr/cmake/modules/kernel.cmake:248 (include)
    F:/nordic/ncs_v2.6.1/zephyr/cmake/modules/zephyr_default.cmake:138 (include)
    F:/nordic/ncs_v2.6.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
    F:/nordic/ncs_v2.6.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:97 (include_boilerplate)
    CMakeLists.txt:9 (find_package)


    -- Configuring incomplete, errors occurred!
    See also "F:/nrf9160_app/serial_lte_modem/build/CMakeFiles/CMakeOutput.log".
    See also "F:/nrf9160_app/serial_lte_modem/build/CMakeFiles/CMakeError.log".
    FAILED: build.ninja
    C:\ncs\toolchains\cf2149caf2\opt\bin\cmake.exe --regenerate-during-build -SF:\nrf9160_app\serial_lte_modem -BF:\nrf9160_app\serial_lte_modem\build
    ninja: error: rebuilding 'build.ninja': subcommand failed
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\cf2149caf2\opt\bin\cmake.EXE' --build 'f:\nrf9160_app\serial_lte_modem\build'

    This is the content in CMakeError. log

    Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
    Compiler: C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    Build flags:
    Id flags:

    The output was:
    1
    c:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.exe: c:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/lib\libc.a(lib_a-exit.o): in function `exit':
    exit.c:(.text.exit+0x34): undefined reference to `_exit'
    collect2.exe: error: ld returned 1 exit status


    Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
    Compiler: C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    Build flags:
    Id flags:

    The output was:
    1
    c:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.exe: c:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/lib\libc.a(lib_a-exit.o): in function `exit':
    exit.c:(.text.exit+0x34): undefined reference to `_exit'
    collect2.exe: error: ld returned 1 exit status

    This is the content in CMakeOutput.log

    The target system is: Generic - 3.5.99 - arm
    The host system is: Windows - 10.0.19045 - AMD64
    Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
    Compiler: C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    Build flags:
    Id flags: -c

    The output was:
    0


    Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CMakeCCompilerId.o"

    The C compiler identification is GNU, found in "F:/nrf9160_app/serial_lte_modem/build/CMakeFiles/3.21.0/CompilerIdC/CMakeCCompilerId.o"

    Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
    Compiler: C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    Build flags:
    Id flags: -c

    The output was:
    0


    Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CMakeCXXCompilerId.o"

    The CXX compiler identification is GNU, found in "F:/nrf9160_app/serial_lte_modem/build/CMakeFiles/3.21.0/CompilerIdCXX/CMakeCXXCompilerId.o"

    Checking whether the ASM compiler is GNU using "--version" matched "(GNU assembler)|(GCC)|(Free Software Foundation)":
    arm-zephyr-eabi-gcc.exe (Zephyr SDK 0.16.5) 12.2.0
    Copyright (C) 2022 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    I don't know if these are helpful in solving this problem?

  • (By the way, you can use the formatting tools in your posts to help the reader. For example, the build output could have been a code block)

    Based on the output, the build fails at the partition_manager.py. The magic line is

    Partition manager failed: End of last partition is after last valid address
    Failed to partition region sram_primary, size of region: 262144

    The error is most likely in your pm_static.yml.
    Actually, you might as well share the file here, wouldn't hurt.

Related