Darn, I forgot to mention a critical point. To use the slot-1 stub solution, you will probably need to build and upload a new boot loader. Stub slot support was added to the develop branch on Dec. 21, 2016 (https://issues.apache.org/jira/browse/MYNEWT-520).
Chris On Fri, Dec 30, 2016 at 03:39:40PM -0800, Christopher Collins wrote: > Hi Jacob, > > On Fri, Dec 30, 2016 at 03:28:08PM -0700, Jacob Rosenthal wrote: > > I think deps are a part of the story, but yeah the goal is to successfully > > get a target bsp back to 1 larger flash image, or as many as the common set > > of deps require but shrunk way down. > > So you just want to eliminate the need for a second image slot in the > flash map? > > There are four flash areas that are relevant here. Just to be clear: a > flash area is simply a named region of flash. Each BSP's bsp.yml file > defines its flash map as a sequence of flash areas. > > Anyway, the four relevant flash areas are: > * FLASH_AREA_BOOTLOADER: > * FLASH_AREA_IMAGE_0: > * FLASH_AREA_IMAGE_1: > * FLASH_AREA_IMAGE_SCRATCH: > > The boot loader area is placed at the board's start address in flash. > That is, the device boots directly into the boot loader. The boot > loader then possibly swaps the two image slots and jumps to the image in > slot 0. This process is described in some detail in > boot/bootutil/design.txt. > > If your device only needs a single image, you have two options: > 1. slot-1 stub > 2. no boot loader > > Option 1 is the simplest, but option 2 gives you more flash space. I > will describe both options below. > > *** Slot-1 stub: > > This option involves greatly reducing the size of the FLASH_AREA_IMAGE_1 > area. When I did this with the nRF51dk, I used an area size of 2kB. I > think you shld be able to reduce it to the size of an individual > sector (1kB), but I have not tried this. > > There are two changes you need to make: > * (bsp.yml) > o Increase the size of FLASH_AREA_IMAGE_0. > o Reduce the size of FLASH_AREA_IMAGE_1. > o Increase the offset of FLASH_AREA_IMAGE_0. > > * (nrf51xxac.ld) > o Increase the size of the FLASH region. > > I have attached modified versions of these two files that you can try. > > *** No boot loader: > > This option involves removing the boot loader entirely. > Instead of a boot loader, the image binary is placed at the board's > start address in flash such that the device boots directly into it. > Without a boot loader, you can eliminate the following two areas from > the flash map: > * FLASH_AREA_BOOTLOADER: > * FLASH_AREA_IMAGE_1: > > Unfortunately, the scratch area cannot be eliminated at the moment, > since it is required by the reboot log. I think this is something we > should address soon, but in the meantime, you are stuck with the scratch > area. > > It has been a while since I've tried running an image without a boot > loader, so my memory might be a bit foggy. I think the following steps > are all you need: > * (bsp.yml) > o Remove FLASH_AREA_BOOTLOADER > o Remove FLASH_AREA_IMAGE_1 > o Increase the size of FLASH_AREA_IMAGE_0. > o Reduce the offset of FLASH_AREA_IMAGE_0. > > * (nrf51xxac.ld) > o Increase the size of the FLASH region. > o Set _imghdr_size to 0. > > You will probably also need to move the reboot log flash area. > Currently, most BSPs place it right between the boot loader and image > slot 0. > > Let me know if you have any questions. > > Thanks, > Chris > # > # Licensed to the Apache Software Foundation (ASF) under one > # or more contributor license agreements. See the NOTICE file > # distributed with this work for additional information > # regarding copyright ownership. The ASF licenses this file > # to you under the Apache License, Version 2.0 (the > # "License"); you may not use this file except in compliance > # with the License. You may obtain a copy of the License at > # > # http://www.apache.org/licenses/LICENSE-2.0 > # > # Unless required by applicable law or agreed to in writing, > # software distributed under the License is distributed on an > # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY > # KIND, either express or implied. See the License for the > # specific language governing permissions and limitations > # under the License. > # > > bsp.arch: cortex_m0 > bsp.compiler: compiler/arm-none-eabi-m0 > bsp.linkerscript: > - "hw/bsp/nrf51dk/nrf51xxac.ld" > - "hw/mcu/nordic/nrf51xxx/nrf51.ld" > bsp.linkerscript.BOOT_LOADER.OVERWRITE: > - "hw/bsp/nrf51dk/boot-nrf51xxac.ld" > - "hw/mcu/nordic/nrf51xxx/nrf51.ld" > bsp.part2linkerscript: "hw/bsp/nrf51dk/split-nrf51dk.ld" > bsp.downloadscript: "hw/bsp/nrf51dk/nrf51dk_download.sh" > bsp.debugscript: "hw/bsp/nrf51dk/nrf51dk_debug.sh" > > bsp.flash_map: > areas: > # System areas. > FLASH_AREA_BOOTLOADER: > device: 0 > offset: 0x00000000 > size: 16kB > FLASH_AREA_IMAGE_0: > device: 0 > offset: 0x00008000 > size: 218kB > FLASH_AREA_IMAGE_1: > device: 0 > offset: 0x0003e800 > size: 2kB > FLASH_AREA_IMAGE_SCRATCH: > device: 0 > offset: 0x0003f000 > size: 2kB > > # User areas. > FLASH_AREA_REBOOT_LOG: > user_id: 0 > device: 0 > offset: 0x00004000 > size: 16kB > FLASH_AREA_NFFS: > user_id: 1 > device: 0 > offset: 0x0003f800 > size: 2kB > /* Linker script for Nordic Semiconductor nRF5 devices > * > * Version: Sourcery G++ 4.5-1 > * Support: https://support.codesourcery.com/GNUToolchain/ > * > * Copyright (c) 2007, 2008, 2009, 2010 CodeSourcery, Inc. > * > * The authors hereby grant permission to use, copy, modify, distribute, > * and license this software and its documentation for any purpose, provided > * that existing copyright notices are retained in all copies and that this > * notice is included verbatim in any distributions. No written agreement, > * license, or royalty fee is required for any of the authorized uses. > * Modifications to this software may be copyrighted by their authors > * and need not follow the licensing terms described here, provided that > * the new terms are clearly indicated on the first page of each file where > * they apply. > */ > MEMORY > { > FLASH (rx) : ORIGIN = 0x00008000, LENGTH = 0x36800 > RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x8000 > } > > /* This linker script is used for images and thus contains an image header */ > _imghdr_size = 0x20;