You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mynewt.apache.org by Jacob Rosenthal <ja...@gmail.com> on 2016/12/30 20:25:11 UTC
Removing or shrinking flash areas
I worked with Sterling to shrink the nimble stack for 256k flash devices,
but Im starting to cut into pretty basic functionality. Ive noticed that
even not using splitty/flash reboot logging those are enable in the bsp I
forked (nrf51dk-16kbram)
Any guidance on removing or shrinking those? Whats mandatory? Ive tried but
Im tending to run into compile errors of nested deps looking for them.
Related, anyone done a more basic dfu style bootload without netwmgr and
such as I wont have flash or ram for all of that.
Re: Removing or shrinking flash areas
Posted by Jacob Rosenthal <ja...@gmail.com>.
I think were on the same page now.
We were talking about 'stub' in previous posts, which Im going to you've
listed here as 'Single image'
The nrf51dk-16kbram Im forking for my target seems set up for Dual bank,
with two equal sized flash areas.
Sounds like split is what Im actually looking for with apps/splitty being
the demo I should look at.
On Fri, Dec 30, 2016 at 6:03 PM, Christopher Collins <cc...@apache.org>
wrote:
> * Split (Kernel in slot 0, application in slot 1)
>
Re: Removing or shrinking flash areas
Posted by Christopher Collins <cc...@apache.org>.
Hi Jacob,
On Fri, Dec 30, 2016 at 05:42:06PM -0700, Jacob Rosenthal wrote:
> It seems like the current bootloader can receive bytes over serial, but
> mainly boots or swaps flash areas, presuming newtmgr already received and
> placed the update in flash 1
> For 'single bank' style it seems like I would need some kind of softdevice
> style solution like nordic so the bootloader has (unduplicated)access to
> nimble so it could receive bytes via bluetooth in the bootloader without
> duplicating that code...
> Whats the newt way :) Thoughts?
I think it might help if you could clarify what you are looking for. In
particular, I am not sure what you mean by "single bank." Mynewt lets
you use the following setups:
* Dual bank (two standalone images)
* Split (Kernel in slot 0, application in slot 1)
* Single image (One large image; upgrade not supported)
The split option is closest to Nordic's DFU solution. In this setup,
functionality is partitioned among the two slots as follows:
* Slot 0 (loader):
o OS.
o BLE stack.
o Anything else required for image upgrade.
* Slot 1 (application):
o Parts of Mynewt not required for image upgrade.
o Application-specific code.
The split image setup saves flash space because the application image
doesn't need to contain the OS and network stack. However, image
upgrade is a bit more complicated, and there is no automatic fallback to
the previous image on upgrade failure.
Chris
Re: Removing or shrinking flash areas
Posted by Jacob Rosenthal <ja...@gmail.com>.
It seems like the current bootloader can receive bytes over serial, but
mainly boots or swaps flash areas, presuming newtmgr already received and
placed the update in flash 1
For 'single bank' style it seems like I would need some kind of softdevice
style solution like nordic so the bootloader has (unduplicated)access to
nimble so it could receive bytes via bluetooth in the bootloader without
duplicating that code...
Whats the newt way :) Thoughts?
On Fri, Dec 30, 2016 at 5:13 PM, Jacob Rosenthal <ja...@gmail.com>
wrote:
> I think I want a bootloader, and Im ok with stub solutions 'losing' a
> little flash space, especially if some other dep might still want a little
> bit of that space.
>
> For nrf51 targets it seems like I just wont have room to split equally at
> the very least. What other deps use flash areas? My understanding is the
> flash area 1 was sized such so that it mainly was used for a 'dual bank'
> style solution?
>
> What about split-nrf51dk-16kbram.ld? Does bsp.part2linkerscript not get
> used unless the split dep is utilized?
>
> Has anyone done anything like that yet, without newtmgr etc? IE dfu
> 'single bank' style dfu service like nordic has?
>
> Thanks for all the info and for such a customizable platform.
>
> On Fri, Dec 30, 2016 at 4:41 PM, Christopher Collins <cc...@apache.org>
> wrote:
>
>> probably need to build and upload a new boot loader.
>> Stub slot support was ad
>>
>
>
Re: Removing or shrinking flash areas
Posted by Jacob Rosenthal <ja...@gmail.com>.
I think I want a bootloader, and Im ok with stub solutions 'losing' a
little flash space, especially if some other dep might still want a little
bit of that space.
For nrf51 targets it seems like I just wont have room to split equally at
the very least. What other deps use flash areas? My understanding is the
flash area 1 was sized such so that it mainly was used for a 'dual bank'
style solution?
What about split-nrf51dk-16kbram.ld? Does bsp.part2linkerscript not get
used unless the split dep is utilized?
Has anyone done anything like that yet, without newtmgr etc? IE dfu 'single
bank' style dfu service like nordic has?
Thanks for all the info and for such a customizable platform.
On Fri, Dec 30, 2016 at 4:41 PM, Christopher Collins <cc...@apache.org>
wrote:
> probably need to build and upload a new boot loader.
> Stub slot support was ad
>
Re: Removing or shrinking flash areas
Posted by Christopher Collins <cc...@apache.org>.
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;
Re: Removing or shrinking flash areas
Posted by Christopher Collins <cc...@apache.org>.
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
Re: Removing or shrinking flash areas
Posted by Jacob Rosenthal <ja...@gmail.com>.
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.
On Fri, Dec 30, 2016 at 2:32 PM, Christopher Collins <cc...@apache.org>
wrote:
> nted to remove unnecessary packages dependencies from your
> build, but now I think y
>
Re: Removing or shrinking flash areas
Posted by Christopher Collins <cc...@apache.org>.
On rereading, I realize I might have misunderstood your question. I
assumed you wanted to remove unnecessary packages dependencies from your
build, but now I think you might just want to reduce the size of some
areas in your BSP's flash map (in bsp.yml). Sorry if I'm just being
slow (I usually am!), but could you clarify which one you asking about?
Thanks,
Chris
On Fri, Dec 30, 2016 at 01:30:28PM -0800, Christopher Collins wrote:
> Hi Jacob,
>
> On Fri, Dec 30, 2016 at 01:25:11PM -0700, Jacob Rosenthal wrote:
> > I worked with Sterling to shrink the nimble stack for 256k flash devices,
> > but Im starting to cut into pretty basic functionality. Ive noticed that
> > even not using splitty/flash reboot logging those are enable in the bsp I
> > forked (nrf51dk-16kbram)
> >
> > Any guidance on removing or shrinking those? Whats mandatory? Ive tried but
> > Im tending to run into compile errors of nested deps looking for them.
> >
> > Related, anyone done a more basic dfu style bootload without netwmgr and
> > such as I wont have flash or ram for all of that.
>
> I don't think we have a clear picture of exactly which packages are
> required. The following commands might be helpful for determining who
> depends on what:
>
> newt target dep <target-name>
> newt target revdep <target-name>
>
> The first shows a dependency graph; for each package in the build, show
> the list of packages that it depends on.
>
> The second shows the reverse dependency graph; for each pacakge in the
> build, show the list of packages that depend on it.
>
> Unfortunately, I am sure there are some dependencies that are necessary
> for the wrong reasons. We may need to do some work to remove these
> dependencies, or add syscfg settings so that they can be compiled out.
>
> If you could post the output of the two commands I mentioned above, I
> can take a look to see if anything can be removed.
>
> Chris
Re: Removing or shrinking flash areas
Posted by Christopher Collins <cc...@apache.org>.
Hi Jacob,
On Fri, Dec 30, 2016 at 01:25:11PM -0700, Jacob Rosenthal wrote:
> I worked with Sterling to shrink the nimble stack for 256k flash devices,
> but Im starting to cut into pretty basic functionality. Ive noticed that
> even not using splitty/flash reboot logging those are enable in the bsp I
> forked (nrf51dk-16kbram)
>
> Any guidance on removing or shrinking those? Whats mandatory? Ive tried but
> Im tending to run into compile errors of nested deps looking for them.
>
> Related, anyone done a more basic dfu style bootload without netwmgr and
> such as I wont have flash or ram for all of that.
I don't think we have a clear picture of exactly which packages are
required. The following commands might be helpful for determining who
depends on what:
newt target dep <target-name>
newt target revdep <target-name>
The first shows a dependency graph; for each package in the build, show
the list of packages that it depends on.
The second shows the reverse dependency graph; for each pacakge in the
build, show the list of packages that depend on it.
Unfortunately, I am sure there are some dependencies that are necessary
for the wrong reasons. We may need to do some work to remove these
dependencies, or add syscfg settings so that they can be compiled out.
If you could post the output of the two commands I mentioned above, I
can take a look to see if anything can be removed.
Chris