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 2015/11/10 23:35:06 UTC

[3/3] incubator-mynewt-larva git commit: Switch to use boot loader with Olimex 407 platform by default.

Switch to use boot loader with Olimex 407 platform by default.


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

Branch: refs/heads/master
Commit: 2df2509a825de3c8d724a4cb0dc6e437ca067663
Parents: e24ee00
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Tue Nov 10 14:34:16 2015 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Tue Nov 10 14:34:16 2015 -0800

----------------------------------------------------------------------
 .../boot-olimex_stm32-e407_devboard.ld          | 10 +++---
 hw/bsp/olimex_stm32-e407_devboard/egg.yml       |  1 +
 .../olimex_stm32-e407_devboard.ld               | 18 +++++++----
 .../olimex_stm32-e407_devboard_download.sh      | 33 ++++++++++++++++++--
 hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c  | 31 ++++++++++++++++++
 5 files changed, 79 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/2df2509a/hw/bsp/olimex_stm32-e407_devboard/boot-olimex_stm32-e407_devboard.ld
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/boot-olimex_stm32-e407_devboard.ld b/hw/bsp/olimex_stm32-e407_devboard/boot-olimex_stm32-e407_devboard.ld
index 135785e..3c8f137 100755
--- a/hw/bsp/olimex_stm32-e407_devboard/boot-olimex_stm32-e407_devboard.ld
+++ b/hw/bsp/olimex_stm32-e407_devboard/boot-olimex_stm32-e407_devboard.ld
@@ -19,9 +19,9 @@
 /* Linker script to configure memory regions. */
 MEMORY
 { 
-  FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
+  FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
   CCM (rwx) : ORIGIN = 0x10000000, LENGTH = 64K
-  RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x20000
+  RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 128K
 }
 
 /* Linker script to place sections and symbol values. Should be used together
@@ -87,18 +87,18 @@ SECTIONS
         *(.rodata*)
 
         KEEP(*(.eh_frame*))
-    } > RAM
+    } > FLASH
 
     .ARM.extab : 
     {
         *(.ARM.extab* .gnu.linkonce.armextab.*)
-    } > RAM
+    } > FLASH
 
     __exidx_start = .;
     .ARM.exidx :
     {
         *(.ARM.exidx* .gnu.linkonce.armexidx.*)
-    } > RAM
+    } > FLASH
 
     __exidx_end = .;
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/2df2509a/hw/bsp/olimex_stm32-e407_devboard/egg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/egg.yml b/hw/bsp/olimex_stm32-e407_devboard/egg.yml
index 5319542..0e710d1 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/egg.yml
+++ b/hw/bsp/olimex_stm32-e407_devboard/egg.yml
@@ -6,3 +6,4 @@ egg.debugscript: "olimex_stm32-e407_devboard_debug.sh"
 egg.cflags: -DSTM32F407xx
 egg.deps: 
     - hw/mcu/stm/stm32f4xx
+    - libs/util

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/2df2509a/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard.ld
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard.ld b/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard.ld
index 952b728..7e02215 100755
--- a/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard.ld
+++ b/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard.ld
@@ -13,15 +13,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- 
-/* Linker script for STM32F407 when running from flash and not using the bootloader */
+
+/* Linker script for STM32F407 when running from flash and using the bootloader */
 
 /* Linker script to configure memory regions. */
 MEMORY
 { 
-  FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
-  CCM (rwx) : ORIGIN = 0x10000000, LENGTH = 64K
-  RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x20000 
+  FLASH (rx) :  ORIGIN = 0x08020000, LENGTH = 384K /* First image slot. */
+  CCM (rwx) :   ORIGIN = 0x10000000, LENGTH = 64K
+  RAM (rwx) :   ORIGIN = 0x20000000, LENGTH = 128K
 }
 
 /* Linker script to place sections and symbol values. Should be used together
@@ -55,12 +55,18 @@ MEMORY
  *   __corebss_start__
  *   __corebss_end__
  *   __ecoredata
- *   __ecorebs
+ *   __ecorebss
  */
 ENTRY(Reset_Handler)
 
 SECTIONS
 {
+    /* Reserve space at the start of the image for the header. */
+    .imghdr (NOLOAD):
+    {
+        . = . + 0x20;
+    } > FLASH
+
     .text :
     {
         __isr_vector_start = .;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/2df2509a/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh b/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh
index f1cdf56..0c35c71 100755
--- a/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh
+++ b/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh
@@ -12,10 +12,37 @@ if [ $# -lt 1 ]; then
     exit 1
 fi
 
-FLASH_OFFSET=0x08000000
-FILE_NAME=$1.elf.bin
+BASENAME=$1
+IS_BOOTLOADER=0
+BIN2IMG=project/bin2img/bin/bin2img/bin2img.elf
+VER=11.22.3333.0
+VER_FILE=version.txt # or somewhere else
 
-echo "Downloading" $FILE_NAME
+# Look for 'bootloader' from 2nd arg onwards
+shift
+while [ $# -gt 0 ]; do
+    if [ $1 == "bootloader" ]; then
+	IS_BOOTLOADER=1
+    fi
+    shift
+done
+
+if [ $IS_BOOTLOADER -eq 1 ]; then
+    FLASH_OFFSET=0x08000000
+    FILE_NAME=$BASENAME.elf.bin
+else
+    FLASH_OFFSET=0x08020000
+    FILE_NAME=$BASENAME.elf.img
+    if [ -f $VER_FILE ]; then
+	VER=`echo $VER_FILE`
+    fi
+    echo "Version is >" $VER "<"
+    $BIN2IMG $BASENAME.elf.bin $FILE_NAME $VER
+    if [ "$?" -ne 0 ]; then
+	exit 1
+    fi
+fi
+echo "Downloading" $FILE_NAME "to" $FLASH_OFFSET
 
 openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -s hw/bsp/olimex_stm32-e407_devboard -f f407.cfg -c init -c "reset halt" -c "flash write_image erase $FILE_NAME $FLASH_OFFSET" -c "reset run" -c shutdown
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/2df2509a/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c b/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c
index 383173a..10074af 100644
--- a/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c
+++ b/hw/bsp/olimex_stm32-e407_devboard/src/os_bsp.c
@@ -13,6 +13,35 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+/*
+ * XXXX for now have this here.
+ */
+#include <util/flash_map.h>
+
+static struct flash_area bsp_flash_areas[] = {
+    [FLASH_AREA_BOOTLOADER] = {
+        .fa_flash_id = 0,	/* internal flash */
+        .fa_off = 0x08000000,	/* beginning */
+        .fa_size = (64 * 1024)  /* XXX need to shrink this */
+    },
+    [FLASH_AREA_IMAGE_0] = {
+        .fa_flash_id = 0,
+        .fa_off = 0x08020000,
+        .fa_size = (384 * 1024)
+    },
+    [FLASH_AREA_IMAGE_1] = {
+        .fa_flash_id = 0,
+        .fa_off = 0x08080000,
+        .fa_size = (384 * 1024)
+    },
+    [FLASH_AREA_IMAGE_SCRATCH] = {
+        .fa_flash_id = 0,
+        .fa_off = 0x080e0000,
+        .fa_size = (128 * 1024)
+    }
+};
+
 void *_sbrk(int incr);
 void _close(int fd);
 
@@ -24,6 +53,8 @@ os_bsp_init(void)
      */
     _sbrk(0);
     _close(0);
+    flash_area_init(bsp_flash_areas,
+                    sizeof(bsp_flash_areas) / sizeof(bsp_flash_areas[0]));
 }
 
 


Switch to use boot loader with Olimex 407 platform by default.

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

I made the Olimex BSP defaults such that it’ll have bootloader present.

What this means is that in order to download blinky, you’ll need
3 things built. bin2img the tool, bootloader and blinky itself.

This is what newt targets to use:
[marko@IsMyLaptop:~/src3/larva]$ newt target show bin2img
bin2img
	bsp: hw/bsp/native
	name: bin2img
	arch: sim
	compiler: sim
	project: bin2img
	compiler_def: debug
[marko@IsMyLaptop:~/src3/larva]$ newt target show boot_olimex
boot_olimex
	compiler: arm-none-eabi-m4
	project: boot
	compiler_def: optimized
	bsp: hw/bsp/olimex_stm32-e407_devboard
	name: boot_olimex
	arch: cortex_m4
[marko@IsMyLaptop:~/src3/larva]$ newt target show blink_olimex
blink_olimex
	compiler: arm-none-eabi-m4
	project: blinky
	compiler_def: debug
	bsp: hw/bsp/olimex_stm32-e407_devboard
	name: blink_olimex
	arch: cortex_m4

And then build them, and download bootloader and blinky (or
any other project).

[marko@IsMyLaptop:~/src3/larva]$ newt target build bin2img
Building target bin2img (project = bin2img)
Linking bin2img.elf
Successfully run!
[marko@IsMyLaptop:~/src3/larva]$ newt target build boot_olimex
Building target boot_olimex (project = boot)
Linking boot.elf
Successfully run!
[marko@IsMyLaptop:~/src3/larva]$ newt target build blink_olimex
Building target blink_olimex (project = blinky)
Linking blinky.elf
Successfully run!
[marko@IsMyLaptop:~/src3/larva]$ newt target download boot_olimex
Downloading with /Users/marko/src3/larva/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh
[marko@IsMyLaptop:~/src3/larva]$ newt target download blink_olimex
Downloading with /Users/marko/src3/larva/hw/bsp/olimex_stm32-e407_devboard/olimex_stm32-e407_devboard_download.sh


> Begin forwarded message:
> 
> From: marko@apache.org
> Subject: [3/3] incubator-mynewt-larva git commit: Switch to use boot loader with Olimex 407 platform by default.
> Date: November 10, 2015 at 2:35:06 PM PST
> To: commits@mynewt.incubator.apache.org
> Reply-To: dev@mynewt.incubator.apache.org
> 
> Switch to use boot loader with Olimex 407 platform by default.
> 
>