Hi Kevin, Coming at it from another angle...
When my app took up too much space that optimising was not going to fix I simply changed the application FLASH ORIGIN in Newt's nrf51 linker script hw/bsp/nrf51dk/*nrf51dk.ld* That was fine for my testing as I didn't really have to worry about the knock on effect of it's (Newt logically defined) neighbouring regions higher up in FLASH. However, the boot loader obviously can't go over 0x8000 without moving the app... I've found that in apps/boot/pkg.yml is: pkg.features: bootloader This must be being used to choose the linker script because in this file: apache-mynewt-core/hw/bsp/nrf51dk/pkg.ym there are these 2 lines: pkg.linkerscript: "*nrf51dk.ld*" pkg.linkerscript.bootloader.OVERWRITE: "*boot-nrf51dk.ld*" In order for the boot loader to know the start address of the app (default of 0x8000) I found a Newt configuration structure for the 'logical' flash areas in: repos/apache-mynewt-core/hw/bsp/nrf51dk/src/os_bsp.c It would appear you would need to alter: 1. FLASH LENGTH in the boot-nrf51dk.ld and 2. FLASH ORIGIN in the nrf51dk.ld linker scripts and also 3. change the 'fa_off' for each flash area in the bsp_flash_areas structure. That's my (untested) working out for increasing the flash space for the boot loader. Hope it works. Dear Newt Devs, It would be nice to be able to specify the flash areas in the pkg.yml (or project.yml) and for the Newt OS 'flash areas structure' and (perhaps templated) linker scripts to pick the values up from that single configuration place. All the best Wayne On 18 June 2016 at 11:29, Kevin Townsend <[email protected]> wrote: > I was able to build manually pulling via git, and adding the following > macros in my custom BSP: > > /* BOOT_SERIAL pins */ > /* DFU pin is set to 0.07 on the BLEFRIEND32 */ > #define BOOT_SERIAL_DETECT_PIN (7) > /* 0 = No pullup, 1 = Pull Up, 2 = Pull Down */ > #define BOOT_SERIAL_DETECT_PIN_CFG (0) > /* Board has external pullup and the tact switch sets the pin to GND */ > #define BOOT_SERIAL_DETECT_PIN_VAL (0) > > This corresponds to the HW bootloader pin on this board: > https://cdn-learn.adafruit.com/assets/assets/000/024/297/original/adafruit_products_schem.png?1428267509 > > Even with the new nrf51_bootser target set to optimized, though, it's > running over the .text region limit for the nRF51: > > Error: > > > /Users/ktown/prog/gcc-arm-none-eabi-4_9-2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld: > > > /Users/ktown/Dropbox/microBuilder/code/nRF52/Mynewt/bletest/bin/nrf51_bootser/apps/boot/boot.elf > section `.text' will not fit in region `FLASH' > > > /Users/ktown/prog/gcc-arm-none-eabi-4_9-2015q1/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld: > region `FLASH' overflowed by 1288 bytes > > > /Users/ktown/Dropbox/microBuilder/code/nRF52/Mynewt/bletest/bin/nrf51_bootser/libs/os/os.a(os_arch_arm.o): > In function `os_arch_os_init': > > > /Users/ktown/Dropbox/microBuilder/Code/nRF52/Mynewt/bletest/repos/apache-mynewt-core/libs/os/src/arch/cortex_m0/os_arch_arm.c:218: > undefined reference to `bsp_init' > > There do tend to be meaningful gains in optimisation between releases, so > I switched to 2016q1 (5.3.1) and it's closer, but still not quite small > enough: > > Linking boot.elf > Error: > > > /Users/ktown/prog/gcc-arm-none-eabi-5_3-2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/bin/ld: > > > /Users/ktown/Dropbox/microBuilder/code/nRF52/Mynewt/bletest/bin/nrf51_bootser/apps/boot/boot.elf > section `.text' will not fit in region `FLASH' > > > /Users/ktown/prog/gcc-arm-none-eabi-5_3-2016q1/bin/../lib/gcc/arm-none-eabi/5.3.1/../../../../arm-none-eabi/bin/ld: > region `FLASH' overflowed by 700 bytes > > > /Users/ktown/Dropbox/microBuilder/code/nRF52/Mynewt/bletest/bin/nrf51_bootser/libs/os/os.a(os_arch_arm.o): > In function `os_arch_os_init': > > > /Users/ktown/Dropbox/microBuilder/Code/nRF52/Mynewt/bletest/repos/apache-mynewt-core/libs/os/src/arch/cortex_m0/os_arch_arm.c:218: > undefined reference to `bsp_init' > collect2: error: ld returned 1 exit status > > Looking at what 'optimized' gets converted to, it seems like it's '-Os' > which is the best we'll get for size (compiler.yml states: > "compiler.flags.optimized: [compiler.flags.default, -Os -ggdb]") > > Which version of GCC were you using yourself? > > Best regards, > Kevin > > > On 18/06/16 01:44, marko kiiskila wrote: > >> Hi, >> >> I checked in a package that can be included in bootloader, and >> it will accept image upgrades over serial port. >> >> It expects that the image upgrade is done using the newtmgr >> protocol. Command set that it supports is limited; it can list images, >> accept an image upload command (stores it to slot 0), and also reset. >> >> For testing, I added a snippet of code to apps/boot which can >> be conditionally compiled in by defining target features for boot loader >> to include BOOT_SERIAL. >> The code monitors a GPIO pin, and if it’s set to specific state during >> bootup, it’ll enter the serial downloader, awaiting these commands. >> Again for testing, I added the pin config to use for Arduino MKR1000 >> BSP. >> >> Here’s my target definition for using this, in case you want to try this >> out: >> [marko@IsMyLaptop:~/src/incubator-mynewt-blinky]$ newt target show >> boot_mkr1000 >> targets/boot_mkr1000 >> app=@apache-mynewt-core/apps/boot >> bsp=@mynewt-arduino-zero/hw/bsp/arduino_mkr1000 >> build_profile=optimized >> features=BOOT_SERIAL >> >> Feedback appreciated, >> M >> >> On Jun 17, 2016, at 4:26 PM, [email protected] wrote: >>> >>> boot; conditionally check whether to expect image download commands >>> over serial. Whether code gets built in depends on target features. >>> >>> >>> >
