Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I also made some BLE DFU OTA code for gcc just today and I made this changes to nrf6310\device_firmware_updates\bootloader project:
- 1. Linker scripts:
- 1.1. gcc_nrf51_common.ld
- Add sections:
- SECTIONS
- {
- .bootloader_settings_block 0x0003FC00 :
- {
- KEEP(*(.bootloader_settings_sect))
- } > bootloader_settings
- .NRF_UICR_BOOT_START_BLOCK 0x10001014 :
- {
- KEEP(*(.NRF_UICR_BOOT_START_SECT))
- } > NRF_UICR_BOOT_START
- ...
- }
- 1.2. gcc_nrf51_s110_xxaa.ld
- MEMORY
- {
- FLASH (rx) : ORIGIN = 0x3C000, LENGTH = 0x3C00 /* bootloader */
- bootloader_settings (rwx) : ORIGIN = 0x3FC00, LENGTH = 0x400 /* bootloader specific settings */
- NRF_UICR_BOOT_START (rwx) : ORIGIN = 0x10001014, LENGTH = 0x4 /* bootloader start address in UICR register */
- RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0x2000 /* 8 kB, 8 kB is taken by S110. */
- }
- 2. bootloader_util_arm.c
- uint8_t __attribute__((section (".bootloader_settings_sect"))) m_boot_settings[CODE_PAGE_SIZE] __attribute__((used));
- uint32_t __attribute__((section (".NRF_UICR_BOOT_START_SECT"))) m_uicr_bootloader_start_address = BOOTLOADER_REGION_START;
- inline void StartApplication(uint32_t start_addr)
- {
- asm volatile("LDR R2, [R0] \n\t" // Get App MSP.
- "MSR MSP, R2 \n\t" //Set the main stack pointer to the applications MSP.
- "LDR R3, [R0, #0x00000004] \n\t" //Get application reset vector address.
- "BX R3 \n\t" //No return - stack code is now activated only through SVC and plain interrupts.
- ".ALIGN"
- );
- }
- 3. dfu_types.h
- #define BOOTLOADER_REGION_START 0x0003C000
- 4. pstorage_platform.h
- I had error from some check in pstorage, so I had to change PSTORAGE_MIN_BLOCK_SIZE value from 0x0010 to 0x000C:
- #define PSTORAGE_MIN_BLOCK_SIZE 0x000C
- UPD:
- But I think additional padding word for bootloader_settings_t is better solution for PSTORAGE_MIN_BLOCK_SIZE problem.
- UPD2:
- And with -Os optimization I have:
- 'Invoking: Cross ARM GNU Print Size'
- arm-none-eabi-size --format=berkeley "nRF51822_BLE_DFU.elf"
- text data bss dec hex filename
- 13988 2128 2096 18212 4724 nRF51822_BLE_DFU.elf
- 'Finished building: nRF51822_BLE_DFU.siz'
- ' '
- Compiled with gcc version 4.8.3 20131129 (release) [ARM/embedded-4_8-branch revision 205641] (GNU Tools for ARM Embedded Processors).
- UPD3:
- I forgot that I deleted DFU start from button push and replaced it with NRF_POWER->GPREGRET check so code size was a bit smaller.
- With button usage:
- 'Invoking: Cross ARM GNU Print Size'
- arm-none-eabi-size --format=berkeley "nRF51822_BLE_DFU.elf"
- text data bss dec hex filename
- 14128 2136 2096 18360 47b8 nRF51822_BLE_DFU.elf
- 'Finished building: nRF51822_BLE_DFU.siz'
- ' '
- UPD4:
- I attached eclipse project for bootloader.
- UPD 2014.06.26:
- I attached updated eclipse project for bootloader:
- [C:\fakepath\Eclipse_workspace_2.rar](/attachment/50d398306ed418fa1a9fc86385457b3f)
- Changes:
- - Added the function of simultaneous flashing bootloader and application via J-Link from this question:
- https://devzone.nordicsemi.com/question/12800/flashing-bootloader-and-application-via-j-link/
- - Added additional optimization as Joe Merten suggested:
- --specs=nano.specs
- -flto
- For -flto optimization you need to change your SDK files and add __attribute__ ((used, section(".Vectors"))) to the IRQ handlers (GPIOTE_IRQHandler, RTC1_IRQHandler, SWI0_IRQHandler, SWI2_IRQHandler) like this:
- void __attribute__ ((used, section(".Vectors"))) GPIOTE_IRQHandler(void)
- {
- ...
- }
- in files:
- app_common/app_gpiote.c
- app_timer/app_gpiote.c
- sd_common/softdevice_handler.c
- To tim,
- I don't use makefile, but you can find autogenerated by Eclipse makefile in attached Eclipse_workspace_2.rar in this folder:
- nRF51822_BLE_DFU_flashing_with_app\Debug
- But if you want to use pure Makefile project then I would suggest you use the Joe Merten's project.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement