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

buttonless DFU - bootloader hangs

hi,

I am trying to integrate buttonless switch to boot loader as explained in the documentation and the hrs experimental example.

I am working on SDK7.2.0 and using the nrf51DK so far - later on I will port everything to my own hardware, but the DK is convenient for now.

Here is what I did:

I have compiled the boot loader project in the SDK7.2 with Keil, and programmed it to my nrf51dk together with the soft device. Then I also compiled the experimental hrs example, generated a zip file to flash with the nrf toolbox from my iphone, and that all worked fine. Also was able to flash my own application when switching to boot loader via the button+reset. So far so good.

Then, i integrated the dfu service as described in the documentation of the experimental example:

  • Add DFU related files to BLE example project: bootloader_util_arm.c,ble_dfu.c,dfu_app_handler.c
  • Implement the reset_prepare() function
  • Initialize the DFU Service
  • Propagate SoftDevice BLE events to the DFU Service.

Now, when my own application is running, I can see the DFU service, and can make the application switch to boot loader by enabling notifications and writing 0x0104 to the control point, or at least I have the impression it switched to boot loader, as LED1 and LED3 are lit, just like when I switch to boot loader. When I then go to nRF Toolbox > DFU, I can select my device, can select my file and so on, and tap 'Upload', and then nothing seems to happen: progress bar appears but stays at 0.

One thing I need to note: I commented out the content of du_app_set_peer_data, as it uses a function from the device_manager, but I do not use any security, so I do not use the device manager. Could this cause the behavior I am seeing? Or is there something else that could cause this?

Update: added the device_manager and all necessary files, and that does not make any difference.

Can the fact that I compiled the boot loader with Keil and my application with GCC be the cause? I checked everything else again, and do not really see any difference between how I integrated it and how it was done in the example.

  • I did exactly that but got the error message during the linking stage as described in my previous comment:

    /.../src/dfu/bootloader_util.c: In function 'bootloader_util_reset':
    /.../src/dfu/bootloader_util.c:106:1: error: r7 cannot be used in asm here
     }
     ^
    lto-wrapper: /Applications/gcc-arm-none-eabi-4_9-2015q1/bin/arm-none-eabi-gcc returned 1 exit status
    /Applications/gcc-arm-none-eabi-4_9-2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld: lto-wrapper failed
    collect2: error: ld returned 1 exit status
    

    So it complains about the last line, about r7. How can I solve this? Is it a linker script issue with the SDK7.2.0 linker script?

  • @wim: I'm testing here, the compiler didn't complain. I attached the file in my answer. Could you try my file ?

    If you still have the issue, please send us your project (including the whole project, where all other example is removed).

  • I tried also with your file. The file compiles ok, but the linker complains. I have noticed that in SDK9 each gcc makefile project is accompanied by its own .ld file, while in sdk7.2.0 the general toolchain .ld file is used. Should I do the same? are there any differences? Also, I use version 4.9 of gcc, is that ok?

  • Could you post the error log ? Also I notice that you use bootloader_util.c instead of bootloader_util_gcc.c, do you have other modification ?

  • Hi, i just recompiled with your boot loader_util_gcc.c. Previous compilation was with just the sdk9 file copied into my project. Here is the complete log (please note that I do not use make, but a qbs project in QtCreator with bare metal plugin (see my blog on this topic). So I could send you my project in this format if you'd find this useful):

    compiling SEGGER_RTT.c
    compiling app_timer.c
    compiling softdevice_handler.c
    compiling ble_my_service.c
    compiling app.c
    compiling nrf_assert.c
    compiling dfu_app_handler.c
    compiling device_manager_peripheral.c
    compiling app_ble.c
    compiling main.c
    compiling ble_advdata.c
    compiling ble_dfu.c
    compiling bootloader_util_gcc.c
    compiling ble_srv_common.c
    compiling hw_init.c
    compiling pstorage.c
    compiling system_nrf51.c
    compiling app_gpiote.c
    compiling ble_conn_params.c
    compiling app_button.c
    compiling nrf_delay.c
    compiling SEGGER_RTT_printf.c
    compiling spi_master.c
    compiling gcc_startup_nrf51.s
    compiling interval_record.c
    compiling app_scheduler.c
    compiling app_error.c
    linking myproject.elf
    /Applications/gcc-arm-none-eabi-4_9-2015q1/bin/arm-none-eabi-gcc /myproject/build/.obj/0da82cc593b2789a/softdevice_handler.c.o /myproject/build/.obj/10b4b06de9fa4197/app_timer.c.o /myproject/build/.obj/2119f2cbff76308c/ble_my_service.c.o /myproject/build/.obj/2a94b74f64a12597/hw_init.c.o /myproject/build/.obj/3f21d9844c5aeb60/spi_master.c.o /myproject/build/.obj/52e6ddd7334b868d/app.c.o /myproject/build/.obj/52e6ddd7334b868d/app_ble.c.o /myproject/build/.obj/53d20156d67b39d5/interval_record.c.o /myproject/build/.obj/65c02569a3cb2e93/pstorage.c.o /myproject/build/.obj/7e838a4599280656/gcc_startup_nrf51.s.o /myproject/build/.obj/83b245554f8d0dc8/app_gpiote.c.o /myproject/build/.obj/84f1db46c2de65db/SEGGER_RTT.c.o /myproject/build/.obj/84f1db46c2de65db/SEGGER_RTT_printf.c.o /myproject/build/.obj/9a6794832d15ad24/nrf_delay.c.o /myproject/build/.obj/9b63ec1070f3e8e0/app_error.c.o /myproject/build/.obj/9b63ec1070f3e8e0/nrf_assert.c.o /myproject/build/.obj/a232a46d3525d371/device_manager_peripheral.c.o /myproject/build/.obj/a64b663017d02128/app_scheduler.c.o /myproject/build/.obj/bfa30bb80df21156/system_nrf51.c.o /myproject/build/.obj/d814ef6a0ceb640b/ble_advdata.c.o /myproject/build/.obj/d814ef6a0ceb640b/ble_conn_params.c.o /myproject/build/.obj/d814ef6a0ceb640b/ble_srv_common.c.o /myproject/build/.obj/d9b86cfc338eea47/ble_dfu.c.o /myproject/build/.obj/d9b86cfc338eea47/bootloader_util_gcc.c.o /myproject/build/.obj/d9b86cfc338eea47/dfu_app_handler.c.o /myproject/build/.obj/e0aeaa9c3d490126/app_button.c.o /myproject/build/.obj/f27fede2220bcd32/main.c.o -g -Wl,-undefined,error -Xlinker -Map=/myproject/build/myproject.map -mthumb -mabi=aapcs -L/Users/wim/Projects/nordic/myproject/../nRF51_SDK_7.2.0/components/toolchain/gcc/ -T/Users/wim/Projects/nordic/myproject/../nRF51_SDK_7.2.0/components/toolchain/gcc/gcc_nrf51_s110_xxaa.ld -mcpu=cortex-m0 -Wl,--gc-sections --specs=nano.specs -lc -lnosys -o /myproject/build/myproject.elf
    /Users/wim/Projects/nordic/myproject_no_rf_sdk720/src/dfu/bootloader_util_gcc.c: In function 'StartApplication':
    /Users/wim/Projects/nordic/myproject_no_rf_sdk720/src/dfu/bootloader_util_gcc.c:64:1: error: r7 cannot be used in asm here
     }
     ^
    lto-wrapper: /Applications/gcc-arm-none-eabi-4_9-2015q1/bin/arm-none-eabi-gcc returned 1 exit status
    /Applications/gcc-arm-none-eabi-4_9-2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld: lto-wrapper failed
    collect2: error: ld returned 1 exit status
    Process failed with exit code 1.
    The following products could not be built for configuration qtc_nrf51822_9693700c-debug:
    	myproject
    Error while building/deploying project myproject_norf_sdk720 (kit: nrf51822)
    When executing step "Qbs Build"
    17:33:13: Elapsed time: 00:02.
    
Related