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

nRF51822 over the air bootloader with gcc

For my current project, I need to compile the »over the air bootloader« with gcc (because our buildserver runs on linux, developers using Mac … no Windows and no Keil so far).

But unfortunaly, the bootloader example from the sdk (5.1) examples won't compile with gcc. It's missing gcc makefile and even there are at least 2 Keil specific files in the project (arm_startup_nrf51.s and bootloader_util_arm.c).

Could you provide support to help me on this topic?

I'd also checked:- devzone.nordicsemi.com/index.php/nrf51822-bootloader-with-gcc

Parents
  • Hi, thanks for sharing both your codes. I'm working on both OSX and Linux, and I've made some modifications (more or less like the ones made by Nikita) to make the bootloader code compile with gcc. I build the code with the standard gcc configuration (not hlnd/pure-gcc).

    The problem is that using 0x3C000 as BOOTLOADER_REGION_START, with FLASH (rx) : ORIGIN = 0x0003C000, LENGTH = 0x4000 ends with:

    
    _build/dfu_single_bank_ble_s110.out section `.text' will not fit in region `FLASH'
    ...
    ld: region `FLASH' overflowed by 10600 bytes
    
    

    My current Makefile is this:

    
    TARGET_CHIP := NRF51822_QFAA_CA
    BOARD := BOARD_NRF6310
    CFLAGS += -DBLE_STACK_SUPPORT_REQD -DBOOTLOADER_BANKED
    
    SDK_PATH = /opt/nrf51/nrf51_sdk_v5_2_0_39364/nrf51822/
    
    C_SOURCE_FILES = main.c
    C_SOURCE_FILES += bootloader_util_arm.c
    C_SOURCE_FILES += bootloader.c
    C_SOURCE_FILES += dfu_single_bank.c
    C_SOURCE_FILES += dfu_transport_ble.c
    
    C_SOURCE_FILES += $(SDK_PATH)Source/app_common/app_timer.c
    C_SOURCE_FILES += $(SDK_PATH)Source/app_common/app_scheduler.c
    C_SOURCE_FILES += $(SDK_PATH)Source/app_common/app_gpiote.c
    C_SOURCE_FILES += $(SDK_PATH)Source/app_common/crc16.c
    C_SOURCE_FILES += $(SDK_PATH)Source/sd_common/softdevice_handler.c
    C_SOURCE_FILES += $(SDK_PATH)Source/app_common/pstorage.c
    C_SOURCE_FILES += $(SDK_PATH)Source/app_common/hci_mem_pool.c
    
    C_SOURCE_FILES += $(SDK_PATH)Source/ble/ble_conn_params.c
    C_SOURCE_FILES += $(SDK_PATH)Source/ble/ble_advdata.c
    C_SOURCE_FILES += $(SDK_PATH)Source/ble/ble_services/ble_srv_common.c
    C_SOURCE_FILES += $(SDK_PATH)Source/ble/ble_services/ble_dfu.c
    
    INCLUDEPATHS += -I"../include"
    INCLUDEPATHS += -I"../include/ble_transport"
    INCLUDEPATHS += -I"$(SDK_PATH)Include/ble"
    INCLUDEPATHS += -I"$(SDK_PATH)Include/s110"
    INCLUDEPATHS += -I"$(SDK_PATH)Include/app_common"
    INCLUDEPATHS += -I"$(SDK_PATH)Include/ble/ble_services"
    INCLUDEPATHS += -I"$(SDK_PATH)Include/sd_common"
    
    OUTPUT_FILENAME := dfu_single_bank_ble_s110
    
    # Use custom linker script
    LINKER_SCRIPT := gcc_nrf51_s110_xxaa_bl.ld
    
    CFLAGS += -Os -flto -ffunction-sections -fdata-sections -fno-builtin
    LDFLAGS += --specs=nano.specs -lc -lnosys -Wl,--gc-sections
    
    include $(SDK_PATH)Source/templates/gcc/Makefile.common
    
    

    Have you experienced these problems with executable size when dealing with bootloader code at 0x3C000? Are there any compiler settings to set to reduce code size to fit at 0x3C000?

    Thanks for any help.

    Samuele.

  • Hi Joe, thanks for your answer.

    Yes, I have noticed that the Makefile.common was discarding the -Os flag, so I slightly modified it and now I'm able to compile with the -Os flag set.

    Regarding the linker script, I don't think it's wrong, it depends on how you define the MEMORY blocks and the sections in the other file. If you put the .bootloader_settings section inside the FLASH memory block, I think it should work too. In other words, I think that you can define the FLASH with ORIGIN = 0x3C000 and LENGTH = 0x4000 as a memory block and then in the other file define the bootloader_settings section as: .bootloader_settings 0x3FC00 : { KEEP(*(.bootloader_settings)) } > FLASH but you should put it in the right place in the script.

    Regarding the .bin file format, the only small workaround I've found is the rknrfgo software (on SourceForge), that runs on OSX and seems to be able to program the nRF51822 using hex files, but I still haven't tried it yet.

    Thanks for all your considerations and suggestions!

Reply
  • Hi Joe, thanks for your answer.

    Yes, I have noticed that the Makefile.common was discarding the -Os flag, so I slightly modified it and now I'm able to compile with the -Os flag set.

    Regarding the linker script, I don't think it's wrong, it depends on how you define the MEMORY blocks and the sections in the other file. If you put the .bootloader_settings section inside the FLASH memory block, I think it should work too. In other words, I think that you can define the FLASH with ORIGIN = 0x3C000 and LENGTH = 0x4000 as a memory block and then in the other file define the bootloader_settings section as: .bootloader_settings 0x3FC00 : { KEEP(*(.bootloader_settings)) } > FLASH but you should put it in the right place in the script.

    Regarding the .bin file format, the only small workaround I've found is the rknrfgo software (on SourceForge), that runs on OSX and seems to be able to program the nRF51822 using hex files, but I still haven't tried it yet.

    Thanks for all your considerations and suggestions!

Children
No Data
Related