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 Nikita, thanks for your answer. Like Ole Morten told me in this post: https://devzone.nordicsemi.com/index.php/compiling-nrf51822-bootloader-example-using-gcc it seems that the .bin files doesn't allow jumps, so keeping the uicr write at address 0x10001014 makes the code increase to around 256MB. If I remove the KEEP from UICR section in the linker script, the code reduce to a few KB.

    In the post you have linked, I see that it's possible to use the nrfjprog tool to pre-program the UICR.BOOTLOADERADDR register, like this: nrfjprog --memwr 0x10001014 --val 0x3C000

    So, maybe it's possible to remove the m_uicr_bootloader_start_address from the source file and the ".bootloader_address" section from the linker script and only use the nrfjprog tool to program the bootloader address before installing the bootloader firmware...

Reply Children
No Data
Related