You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/06/17 23:26:37 UTC

[1/2] incubator-mynewt-core git commit: boot_serial: don't advertise BOOT_SERIAL feature.

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop 2d6142642 -> dd71f0014


boot_serial: don't advertise BOOT_SERIAL feature.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/92514e96
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/92514e96
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/92514e96

Branch: refs/heads/develop
Commit: 92514e96e4e6b3bb6ee09701fb53a74bafc08352
Parents: 2d61426
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Jun 17 16:23:06 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Jun 17 16:23:06 2016 -0700

----------------------------------------------------------------------
 libs/boot_serial/pkg.yml | 3 ---
 1 file changed, 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/92514e96/libs/boot_serial/pkg.yml
----------------------------------------------------------------------
diff --git a/libs/boot_serial/pkg.yml b/libs/boot_serial/pkg.yml
index 4c1002a..0b66bb6 100644
--- a/libs/boot_serial/pkg.yml
+++ b/libs/boot_serial/pkg.yml
@@ -25,9 +25,6 @@ pkg.keywords:
     - boot
     - bootloader
 
-pkg.features:
-    - BOOT_SERIAL
-
 pkg.deps:
     - hw/hal
     - libs/os


Re: boot_serial support

Posted by Christopher Collins <cc...@apache.org>.
On Sat, Jun 18, 2016 at 11:38:02AM +0200, Kevin Townsend wrote:
> Hi Marko,
> 
> Thanks for getting this into the development branch! ... I was just 
> setting things up to test it out, and I had a look at the code directly 
> on github in the 'develop' branch, but despite my project being on 
> '0-dev' it doesn't pull the changes locally when I run 'newt upgrade'. 

Unfortunately, pulling from git manually (as you did) is currently the
only way to get the latest changes.  This is a known shortcoming, and
there is a fix planned (https://issues.apache.org/jira/browse/MYNEWT-307).

Thanks,
Chris

boot_serial support

Posted by Kevin Townsend <ke...@adafruit.com>.
Hi Marko,

Thanks for getting this into the development branch! ... I was just 
setting things up to test it out, and I had a look at the code directly 
on github in the 'develop' branch, but despite my project being on 
'0-dev' it doesn't pull the changes locally when I run 'newt upgrade'. 
My project.yml is shown below:

    # Use github's distribution mechanism for core ASF libraries.
    # This provides mirroring automatically for us.
    #
    repository.apache-mynewt-core:
         type: github
         vers: 0-dev
         user: apache
         repo: incubator-mynewt-core

Is that still the correct 'vers' field, or should it be changed to 
something else? I thought this particular name mapped to 'develop' in 
the repo.

I can pull the remote changes via git easily enough, but I'd like to 
stick to using 'upgrade' if possible simply to avoid issues moving forward?

I assume these should be defined at the BSP level as well? 
https://github.com/apache/incubator-mynewt-core/blob/develop/apps/boot/src/boot.c#L184

K.


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\u2019s set to specific state during
> bootup, it\u2019ll enter the serial downloader, awaiting these commands.
> Again for testing, I added the pin config to use for Arduino MKR1000
> BSP.
>
> Here\u2019s 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, marko@apache.org wrote:
>>
>> boot; conditionally check whether to expect image download commands
>> over serial. Whether code gets built in depends on target features.
>>
>>


Re: [2/2] incubator-mynewt-core git commit: boot; conditionally check whether to expect image download commands over serial. Whether code gets built in depends on target features.

Posted by marko kiiskila <ma...@runtime.io>.
Hi,

indeed, bootloader does get bigger. I didn’t try this out on Nordic to see
if something gets out of whack. I’ll check it to see if there are pieces
that came in with unintentionally. ‘newt size <target>’  will show what
components get bigger.

To make the bootloader fit, there’s 2 options:
- make bootloader flash area larger, or
- don’t use NFFS, instead switch over to using FCB

To increase area for bootloader, you need to adjust the linker scripts for
bootloader and the image, as well as the BSP’s flash map. And that should
be it. Nordic has 1k sectors, so the adjustments can be pretty fine-grained.
This are in the files Wayne pointed out.

Or don’t use NFFS, instead use FCB for config. This will drop the size
of the bootloader quite a bit, close to 8k. We’ll want to make the bootloader
vs app comm to take place via some other method than NFFS. NFFS
support brings in a lot of text.

I briefly talked about this with Peter Snyder, and thought we should see
if we can steal some bytes from the end of the 2nd image slot for this.

However, in the short term, I suggest increasing the bootloader area.

> On Jun 18, 2016, at 3:29 AM, Kevin Townsend <ke...@adafruit.com> 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, marko@apache.org wrote:
>>> 
>>> boot; conditionally check whether to expect image download commands
>>> over serial. Whether code gets built in depends on target features.
>>> 
>>> 
> 


Re: [2/2] incubator-mynewt-core git commit: boot; conditionally check whether to expect image download commands over serial. Whether code gets built in depends on target features.

Posted by Wayne Keenan <wa...@gmail.com>.
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 <ke...@adafruit.com> 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, marko@apache.org wrote:
>>>
>>> boot; conditionally check whether to expect image download commands
>>> over serial. Whether code gets built in depends on target features.
>>>
>>>
>>>
>

Re: [2/2] incubator-mynewt-core git commit: boot; conditionally check whether to expect image download commands over serial. Whether code gets built in depends on target features.

Posted by Kevin Townsend <ke...@adafruit.com>.
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\u2019s set to specific state during
> bootup, it\u2019ll enter the serial downloader, awaiting these commands.
> Again for testing, I added the pin config to use for Arduino MKR1000
> BSP.
>
> Here\u2019s 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, marko@apache.org wrote:
>>
>> boot; conditionally check whether to expect image download commands
>> over serial. Whether code gets built in depends on target features.
>>
>>


Re: [2/2] incubator-mynewt-core git commit: boot; conditionally check whether to expect image download commands over serial. Whether code gets built in depends on target features.

Posted by marko kiiskila <ma...@runtime.io>.
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, marko@apache.org wrote:
> 
> boot; conditionally check whether to expect image download commands
> over serial. Whether code gets built in depends on target features.
> 
> 


[2/2] incubator-mynewt-core git commit: boot; conditionally check whether to expect image download commands over serial. Whether code gets built in depends on target features.

Posted by ma...@apache.org.
boot; conditionally check whether to expect image download commands
over serial. Whether code gets built in depends on target features.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/dd71f001
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/dd71f001
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/dd71f001

Branch: refs/heads/develop
Commit: dd71f0014d8a4188abfd3308f5fa185db67ef4b3
Parents: 92514e9
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Jun 17 16:24:20 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Jun 17 16:25:16 2016 -0700

----------------------------------------------------------------------
 apps/boot/pkg.yml    | 20 +++++++++++++++-----
 apps/boot/src/boot.c | 26 ++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dd71f001/apps/boot/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/boot/pkg.yml b/apps/boot/pkg.yml
index 07d12a0..10ec482 100644
--- a/apps/boot/pkg.yml
+++ b/apps/boot/pkg.yml
@@ -26,18 +26,28 @@ pkg.keywords:
     - loader
 
 pkg.features: bootloader
+
 pkg.deps:
     - sys/config
     - fs/nffs
     - libs/bootutil
-    - libs/console/stub
     - libs/mbedtls
     - libs/os
     - libs/util
-pkg.cflags: -DLOG_LEVEL=255
+    - libs/console/stub
 
+pkg.cflags: -DLOG_LEVEL=255
 pkg.cflags.NFFS:
-    - "-DNFFS_PRESENT"
-
+    - -DNFFS_PRESENT
 pkg.cflags.FCB:
-    - "-DFCB_PRESENT"
+    - -DFCB_PRESENT
+
+#
+# Define BOOT_SERIAL in target features to include serial downloader.
+# And uncomment 'libs/console/stub' from pkg.deps.
+#
+pkg.deps.BOOT_SERIAL.OVERWRITE:
+    - libs/console/full
+    - libs/boot_serial
+pkg.cflags.BOOT_SERIAL:
+    - -DBOOT_SERIAL

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dd71f001/apps/boot/src/boot.c
----------------------------------------------------------------------
diff --git a/apps/boot/src/boot.c b/apps/boot/src/boot.c
index 9b8bd62..b546cc1 100755
--- a/apps/boot/src/boot.c
+++ b/apps/boot/src/boot.c
@@ -36,6 +36,10 @@
 #else
 #error "Need NFFS or FCB for config storage"
 #endif
+#ifdef BOOT_SERIAL
+#include <hal/hal_gpio.h>
+#include <boot_serial/boot_serial.h>
+#endif
 #include "bootutil/image.h"
 #include "bootutil/loader.h"
 #include "bootutil/bootutil_misc.h"
@@ -45,6 +49,15 @@
 #define BOOT_AREA_DESC_MAX  (256)
 #define AREA_DESC_MAX       (BOOT_AREA_DESC_MAX)
 
+#ifdef BOOT_SERIAL
+#define BOOT_SER_PRIO_TASK          1
+#define BOOT_SER_STACK_SZ           512
+#define BOOT_SER_CONS_INPUT         128
+
+static struct os_task boot_ser_task;
+static os_stack_t boot_ser_stack[BOOT_SER_STACK_SZ];
+#endif
+
 #ifdef NFFS_PRESENT
 #define MY_CONFIG_FILE "/cfg/run"
 
@@ -163,6 +176,19 @@ main(void)
 #endif
     bootutil_cfg_register();
 
+#ifdef BOOT_SERIAL
+    /*
+     * Configure a GPIO as input, and compare it against expected value.
+     * If it matches, await for download commands from serial.
+     */
+    hal_gpio_init_in(BOOT_SERIAL_DETECT_PIN, BOOT_SERIAL_DETECT_PIN_CFG);
+    if (hal_gpio_read(BOOT_SERIAL_DETECT_PIN) == BOOT_SERIAL_DETECT_PIN_VAL) {
+        rc = boot_serial_task_init(&boot_ser_task, BOOT_SER_PRIO_TASK,
+          boot_ser_stack, BOOT_SER_STACK_SZ, BOOT_SER_CONS_INPUT);
+        assert(rc == 0);
+        os_start();
+    }
+#endif
     rc = boot_go(&req, &rsp);
     assert(rc == 0);