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/12/04 23:03:07 UTC

[1/6] incubator-mynewt-larva git commit: Make routine which starts executing program from bootloader to be MCU specific.

Repository: incubator-mynewt-larva
Updated Branches:
  refs/heads/master f396cc2bf -> 086d157d0


Make routine which starts executing program from bootloader to be MCU
specific.


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/f19c3acf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/f19c3acf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/f19c3acf

Branch: refs/heads/master
Commit: f19c3acf655cc7817d7a9cbca93032e58c466fc8
Parents: f396cc2
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Dec 4 13:37:02 2015 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Dec 4 13:37:02 2015 -0800

----------------------------------------------------------------------
 hw/hal/include/hal/hal_system.h             | 10 +++-
 hw/mcu/stm/stm32f3xx/src/hal_system_start.c | 45 ++++++++++++++++++
 hw/mcu/stm/stm32f4xx/src/hal_system_start.c | 51 ++++++++++++++++++++
 project/boot/src/boot.c                     | 60 ++++++++----------------
 4 files changed, 124 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f19c3acf/hw/hal/include/hal/hal_system.h
----------------------------------------------------------------------
diff --git a/hw/hal/include/hal/hal_system.h b/hw/hal/include/hal/hal_system.h
index 19f5ed1..1cf43c4 100644
--- a/hw/hal/include/hal/hal_system.h
+++ b/hw/hal/include/hal/hal_system.h
@@ -4,7 +4,7 @@
  * Licensed 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
@@ -17,6 +17,14 @@
 #ifndef H_HAL_SYSTEM_
 #define H_HAL_SYSTEM_
 
+/*
+ * System reset.
+ */
 void system_reset(void) __attribute((noreturn));
 
+/*
+ * Called by bootloader to start loaded program.
+ */
+void system_start(void *img_start) __attribute((noreturn));
+
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f19c3acf/hw/mcu/stm/stm32f3xx/src/hal_system_start.c
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f3xx/src/hal_system_start.c b/hw/mcu/stm/stm32f3xx/src/hal_system_start.c
new file mode 100644
index 0000000..0479a75
--- /dev/null
+++ b/hw/mcu/stm/stm32f3xx/src/hal_system_start.c
@@ -0,0 +1,45 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed 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.
+ */
+
+#include <stddef.h>
+#include <inttypes.h>
+#include <mcu/cortex_m4.h>
+
+/**
+ * Boots the image described by the supplied image header.
+ *
+ * @param hdr                   The header for the image to boot.
+ */
+void
+system_start(void *img_start)
+{
+    typedef void jump_fn(void);
+
+    uint32_t base0entry;
+    uint32_t jump_addr;
+    jump_fn *fn;
+
+    /* First word contains initial MSP value. */
+    __set_MSP(*(uint32_t *)img_start);
+
+    /* Second word contains address of entry point (Reset_Handler). */
+    base0entry = *(uint32_t *)(img_start + 4);
+    jump_addr = base0entry;
+    fn = (jump_fn *)jump_addr;
+
+    /* Jump to image. */
+    fn();
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f19c3acf/hw/mcu/stm/stm32f4xx/src/hal_system_start.c
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/src/hal_system_start.c b/hw/mcu/stm/stm32f4xx/src/hal_system_start.c
new file mode 100644
index 0000000..1fc2a9b
--- /dev/null
+++ b/hw/mcu/stm/stm32f4xx/src/hal_system_start.c
@@ -0,0 +1,51 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed 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.
+ */
+
+#include <assert.h>
+#include <stddef.h>
+#include <inttypes.h>
+#include <mcu/cortex_m4.h>
+
+/**
+ * Boots the image described by the supplied image header.
+ *
+ * @param hdr                   The header for the image to boot.
+ */
+void
+system_start(void *img_start)
+{
+    typedef void jump_fn(void);
+
+    uint32_t base0entry;
+    uint32_t jump_addr;
+    jump_fn *fn;
+
+    /* First word contains initial MSP value. */
+    __set_MSP(*(uint32_t *)img_start);
+
+    /* Second word contains address of entry point (Reset_Handler). */
+    base0entry = *(uint32_t *)(img_start + 4);
+    jump_addr = base0entry;
+    fn = (jump_fn *)jump_addr;
+
+    /* Remap memory such that flash gets mapped to the code region. */
+    SYSCFG->MEMRMP = 0;
+    __DSB();
+
+    /* Jump to image. */
+    fn();
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/f19c3acf/project/boot/src/boot.c
----------------------------------------------------------------------
diff --git a/project/boot/src/boot.c b/project/boot/src/boot.c
index a13c380..052d8c0 100755
--- a/project/boot/src/boot.c
+++ b/project/boot/src/boot.c
@@ -19,49 +19,14 @@
 #include <inttypes.h>
 #include <util/flash_map.h>
 #include <os/os.h>
+#include <hal/hal_system.h>
 #include "nffs/nffs.h"
 #include "bootutil/image.h"
 #include "bootutil/loader.h"
 
-#define NFFS_AREA_MAX	16
+#define NFFS_AREA_MAX	32
 #define SEC_CNT_MAX	8
 
-/**
- * Boots the image described by the supplied image header.
- *
- * @param hdr                   The header for the image to boot.
- */
-static void
-boot_jump(const struct image_header *hdr, uint32_t image_addr)
-{
-    typedef void jump_fn(void);
-
-    uint32_t base0entry;
-    uint32_t img_start;
-    uint32_t jump_addr;
-    jump_fn *fn;
-
-    /* PIC code not currently supported. */
-    assert(!(hdr->ih_flags & IMAGE_F_PIC));
-
-    img_start = image_addr + hdr->ih_hdr_size;
-
-    /* First word contains initial MSP value. */
-    __set_MSP(*(uint32_t *)img_start);
-
-    /* Second word contains address of entry point (Reset_Handler). */
-    base0entry = *(uint32_t *)(img_start + 4);
-    jump_addr = base0entry;
-    fn = (jump_fn *)jump_addr;
-
-    /* Remap memory such that flash gets mapped to the code region. */
-    SYSCFG->MEMRMP = 0;
-    __DSB();
-
-    /* Jump to image. */
-    fn();
-}
-
 int
 main(void)
 {
@@ -81,31 +46,44 @@ main(void)
     };
 
     os_init();
-    rc = flash_area_to_nffs_desc(FLASH_AREA_IMAGE_0, &cnt, NULL);
-    assert(rc == 0 && cnt);
+
+    cnt = (NFFS_AREA_MAX / 2) - 3;
     rc = flash_area_to_nffs_desc(FLASH_AREA_IMAGE_0, &cnt, descs);
     img_starts[0] = 0;
     total = cnt;
 
+    cnt = (NFFS_AREA_MAX / 2) - 3;
     rc = flash_area_to_nffs_desc(FLASH_AREA_IMAGE_1, &cnt, &descs[total]);
     assert(rc == 0);
     img_starts[1] = total;
     total += cnt;
 
+    cnt = 1;
     rc = flash_area_to_nffs_desc(FLASH_AREA_IMAGE_SCRATCH, &cnt, &descs[total]);
     assert(rc == 0);
     req.br_scratch_area_idx = total;
-
     total += 1;
+
     req.br_num_image_areas = total;
 
     for (cnt = 0; cnt < total; cnt++) {
         img_areas[cnt] = cnt;
     }
+
+    cnt = 2;
+    rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, &cnt, &descs[total]);
+    assert(rc == 0);
+    total += cnt;
+    descs[total].nad_length = 0;
+
+    nffs_config.nc_num_inodes = 50;
+    nffs_config.nc_num_blocks = 50;
+    nffs_config.nc_num_cache_blocks = 32;
+
     rc = boot_go(&req, &rsp);
     assert(rc == 0);
 
-    boot_jump(rsp.br_hdr, rsp.br_image_addr);
+    system_start((void *)(rsp.br_image_addr + rsp.br_hdr->ih_hdr_size));
 
     return 0;
 }


[3/6] incubator-mynewt-larva git commit: Allow caller to limit the number of NFFS descriptors returned for given flash area. Can be used when underlying flash has large number of small sectors.

Posted by ma...@apache.org.
Allow caller to limit the number of NFFS descriptors returned for
given flash area. Can be used when underlying flash has large number
of small sectors.


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/b43cedc5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/b43cedc5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/b43cedc5

Branch: refs/heads/master
Commit: b43cedc52c80f6ffbec083d5b16b5de1750e1cf7
Parents: fb12884
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Dec 4 13:50:38 2015 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Dec 4 13:50:38 2015 -0800

----------------------------------------------------------------------
 libs/util/src/flash_map.c | 48 +++++++++++++++++++++++++++++++++++-------
 1 file changed, 40 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/b43cedc5/libs/util/src/flash_map.c
----------------------------------------------------------------------
diff --git a/libs/util/src/flash_map.c b/libs/util/src/flash_map.c
index 28f26c9..9493a0d 100644
--- a/libs/util/src/flash_map.c
+++ b/libs/util/src/flash_map.c
@@ -82,35 +82,67 @@ flash_area_to_sectors(int idx, int *cnt, struct flash_area *ret)
 }
 
 #ifdef NFFS_PRESENT
+/*
+ * Turn flash region into a set of areas for NFFS use.
+ *
+ * Limit the number of regions we return to be less than *cnt.
+ * If sector count within region exceeds that, collect multiple sectors
+ * to a region.
+ */
 int
 flash_area_to_nffs_desc(int idx, int *cnt, struct nffs_area_desc *nad)
 {
-    int i;
+    int i, j;
     const struct hal_flash *hf;
     const struct flash_area *fa;
+    int max_cnt, move_on;
+    int first_idx, last_idx;
     uint32_t start, size;
+    uint32_t min_size;
 
     if (!flash_map || idx >= flash_map_entries) {
         return -1;
     }
+    first_idx = last_idx = -1;
+    max_cnt = *cnt;
     *cnt = 0;
+
     fa = &flash_map[idx];
 
     hf = bsp_flash_dev(fa->fa_flash_id);
     for (i = 0; i < hf->hf_sector_cnt; i++) {
         hf->hf_itf->hff_sector_info(i, &start, &size);
         if (start >= fa->fa_off && start < fa->fa_off + fa->fa_size) {
-            if (nad) {
-                nad->nad_flash_id = fa->fa_flash_id;
-                nad->nad_offset = start;
-                nad->nad_length = size;
-                nad++;
+            if (first_idx == -1) {
+                first_idx = i;
             }
+            last_idx = i;
             *cnt = *cnt + 1;
         }
     }
-    if (nad) {
-        memset(nad, 0, sizeof(*nad));
+    if (*cnt > max_cnt) {
+        min_size = fa->fa_size / max_cnt;
+    } else {
+        min_size = 0;
+    }
+    *cnt = 0;
+
+    move_on = 1;
+    for (i = first_idx, j = 0; i < last_idx + 1; i++) {
+        hf->hf_itf->hff_sector_info(i, &start, &size);
+        if (move_on) {
+            nad[j].nad_flash_id = fa->fa_flash_id;
+            nad[j].nad_offset = start;
+            nad[j].nad_length = size;
+            *cnt = *cnt + 1;
+            move_on = 0;
+        } else {
+            nad[j].nad_length += size;
+        }
+        if (nad[j].nad_length >= min_size) {
+            j++;
+            move_on = 1;
+        }
     }
     return 0;
 }


[4/6] incubator-mynewt-larva git commit: Allow up to 6 NFFS sectors in bootloader.

Posted by ma...@apache.org.
Allow up to 6 NFFS sectors in bootloader.


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/9ee69e41
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/9ee69e41
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/9ee69e41

Branch: refs/heads/master
Commit: 9ee69e415f0bd86c389054eb64249bad17ea18cb
Parents: b43cedc
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Dec 4 13:52:24 2015 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Dec 4 13:52:24 2015 -0800

----------------------------------------------------------------------
 project/boot/src/boot.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/9ee69e41/project/boot/src/boot.c
----------------------------------------------------------------------
diff --git a/project/boot/src/boot.c b/project/boot/src/boot.c
index 052d8c0..454e8c1 100755
--- a/project/boot/src/boot.c
+++ b/project/boot/src/boot.c
@@ -24,7 +24,7 @@
 #include "bootutil/image.h"
 #include "bootutil/loader.h"
 
-#define NFFS_AREA_MAX	32
+#define NFFS_AREA_MAX	34
 #define SEC_CNT_MAX	8
 
 int
@@ -70,7 +70,7 @@ main(void)
         img_areas[cnt] = cnt;
     }
 
-    cnt = 2;
+    cnt = 6;
     rc = flash_area_to_nffs_desc(FLASH_AREA_NFFS, &cnt, &descs[total]);
     assert(rc == 0);
     total += cnt;


[6/6] incubator-mynewt-larva git commit: Shell depends on libs/util now.

Posted by ma...@apache.org.
Shell depends on libs/util now.


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/086d157d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/086d157d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/086d157d

Branch: refs/heads/master
Commit: 086d157d0482ac3481fe1ed8519333ddd1688888
Parents: 1479915
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Dec 4 14:02:43 2015 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Dec 4 14:02:43 2015 -0800

----------------------------------------------------------------------
 libs/shell/egg.yml | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/086d157d/libs/shell/egg.yml
----------------------------------------------------------------------
diff --git a/libs/shell/egg.yml b/libs/shell/egg.yml
index 6910ffa..e064e6e 100644
--- a/libs/shell/egg.yml
+++ b/libs/shell/egg.yml
@@ -3,5 +3,6 @@ egg.vers: 0.1
 egg.deps:
     - libs/console/full
     - libs/os
+    - libs/util
 egg.identities:
     - SHELL 


[5/6] incubator-mynewt-larva git commit: Use bootloader with STM32F3 as well.

Posted by ma...@apache.org.
Use bootloader with STM32F3 as well.


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/14799154
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/14799154
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/14799154

Branch: refs/heads/master
Commit: 14799154f26545ea142f339474a3c3bc0d54e276
Parents: 9ee69e4
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Dec 4 14:01:21 2015 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Dec 4 14:01:21 2015 -0800

----------------------------------------------------------------------
 .../stm32f3discovery/boot-stm32f3discovery.ld   | 191 +++++++++++++++++++
 hw/bsp/stm32f3discovery/src/os_bsp.c            |  23 ++-
 hw/bsp/stm32f3discovery/src/sbrk.c              |  11 +-
 hw/bsp/stm32f3discovery/stm32f3discovery.ld     |  11 +-
 .../stm32f3discovery_download.sh                |  34 +++-
 5 files changed, 254 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14799154/hw/bsp/stm32f3discovery/boot-stm32f3discovery.ld
----------------------------------------------------------------------
diff --git a/hw/bsp/stm32f3discovery/boot-stm32f3discovery.ld b/hw/bsp/stm32f3discovery/boot-stm32f3discovery.ld
new file mode 100755
index 0000000..dc01788
--- /dev/null
+++ b/hw/bsp/stm32f3discovery/boot-stm32f3discovery.ld
@@ -0,0 +1,191 @@
+/**
+ * Copyright (c) 2015 Runtime Inc.
+ *
+ * Licensed 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.
+ */
+/*
+*****************************************************************************
+**
+**  File        : stm32_flash.ld
+**
+**  Abstract    : Linker script for bootloader on STM32F303VC Device with
+**                256KByte FLASH, 40KByte RAM
+**
+**                Set heap size, stack size and stack location according
+**                to application requirements.
+**
+**                Set memory bank area and size if external memory is used.
+**
+**  Target      : STMicroelectronics STM32
+**
+**  Distribution: The file is distributed �as is,� without any warranty
+**                of any kind.
+**
+**  (c)Copyright Atollic AB.
+**  You may use this file as-is or modify it according to the needs of your
+**  project. This file may only be built (assembled or compiled and linked)
+**  using the Atollic TrueSTUDIO(R) product. The use of this file together
+**  with other tools than Atollic TrueSTUDIO(R) is not permitted.
+**
+*****************************************************************************
+*/
+
+/* Entry Point */
+ENTRY(Reset_Handler)
+
+/* Highest address of the user mode stack */
+_estack = 0x10002000;    /* end of CCMRAM */
+
+/* Generate a link error if heap and stack don't fit into RAM */
+_Min_Heap_Size = 0x2000;      /* required amount of heap  */
+_Min_Stack_Size = 0x200; /* required amount of stack */
+
+/* Specify the memory areas */
+MEMORY
+{
+	FLASH (rx)      : ORIGIN = 0x8000000, LENGTH = 32K
+	RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 40K
+	CCMRAM (rw)      : ORIGIN = 0x10000000, LENGTH = 8K
+}
+
+/* Define output sections */
+SECTIONS
+{
+  /* The startup code goes first into FLASH */
+  .isr_vector :
+  {
+    . = ALIGN(4);
+    __isr_vector = .;
+    KEEP(*(.isr_vector)) /* Startup code */
+    __isr_vector_end = .;
+    . = ALIGN(4);
+  } >FLASH
+
+  /* The program code and other data goes into FLASH */
+  .text :
+  {
+    . = ALIGN(4);
+    *(.text)           /* .text sections (code) */
+    *(.text*)          /* .text* sections (code) */
+    *(.glue_7)         /* glue arm to thumb code */
+    *(.glue_7t)        /* glue thumb to arm code */
+    *(.eh_frame)
+
+    KEEP (*(.init))
+    KEEP (*(.fini))
+
+    . = ALIGN(4);
+    _etext = .;        /* define a global symbols at end of code */
+  } >FLASH
+
+  /* Constant data goes into FLASH */
+  .rodata :
+  {
+    . = ALIGN(4);
+    *(.rodata)         /* .rodata sections (constants, strings, etc.) */
+    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
+    . = ALIGN(4);
+  } >FLASH
+
+  .ARM.extab   : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
+  .ARM : {
+    __exidx_start = .;
+    *(.ARM.exidx*)
+    __exidx_end = .;
+  } >FLASH
+
+  .preinit_array     :
+  {
+    PROVIDE_HIDDEN (__preinit_array_start = .);
+    KEEP (*(.preinit_array*))
+    PROVIDE_HIDDEN (__preinit_array_end = .);
+  } >FLASH
+  .init_array :
+  {
+    PROVIDE_HIDDEN (__init_array_start = .);
+    KEEP (*(SORT(.init_array.*)))
+    KEEP (*(.init_array*))
+    PROVIDE_HIDDEN (__init_array_end = .);
+  } >FLASH
+  .fini_array :
+  {
+    PROVIDE_HIDDEN (__fini_array_start = .);
+    KEEP (*(SORT(.fini_array.*)))
+    KEEP (*(.fini_array*))
+    PROVIDE_HIDDEN (__fini_array_end = .);
+  } >FLASH
+
+  /* used by the startup to initialize data */
+  _sidata = LOADADDR(.data);
+
+  .vector_relocation :
+  {
+     . = ALIGN(4);
+     __vector_tbl_reloc__ = .;
+     . = . + (__isr_vector_end - __isr_vector);
+     . = ALIGN(4);
+  } > CCMRAM
+
+  /* Initialized data sections goes into RAM, load LMA copy after code */
+  .data : 
+  {
+    . = ALIGN(4);
+    _sdata = .;        /* create a global symbol at data start */
+    *(.data)           /* .data sections */
+    *(.data*)          /* .data* sections */
+
+    . = ALIGN(4);
+    _edata = .;        /* define a global symbol at data end */
+    _sccmram = .;       /* create a global symbol at ccmram start */
+    *(.ccmram)
+    *(.ccmram*)
+    
+    . = ALIGN(4);
+    _eccmram = .;       /* create a global symbol at ccmram end */
+  } >CCMRAM AT> FLASH
+
+  /* Uninitialized data section */
+  . = ALIGN(4);
+  .bss :
+  {
+    /* This is used by the startup in order to initialize the .bss secion */
+    _sbss = .;         /* define a global symbol at bss start */
+    __bss_start__ = _sbss;
+    *(.bss)
+    *(.bss*)
+    *(COMMON)
+
+    . = ALIGN(4);
+    _ebss = .;         /* define a global symbol at bss end */
+    __bss_end__ = _ebss;
+  } >CCMRAM
+
+  /* User_heap_stack section, placed at the end of RAM */
+  PROVIDE(_user_heap_start = ORIGIN(RAM) + LENGTH(RAM) - _Min_Heap_Size);
+  PROVIDE(_user_heap_end = ORIGIN(RAM) + LENGTH(RAM));
+
+  .stack_dummy :
+  {
+    . = . + _Min_Stack_Size;
+  } > CCMRAM
+
+  /* Remove information from the standard libraries */
+  /DISCARD/ :
+  {
+    libc.a ( * )
+    libm.a ( * )
+    libgcc.a ( * )
+  }
+
+  .ARM.attributes 0 : { *(.ARM.attributes) }
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14799154/hw/bsp/stm32f3discovery/src/os_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/stm32f3discovery/src/os_bsp.c b/hw/bsp/stm32f3discovery/src/os_bsp.c
index aa69c45..153a255 100644
--- a/hw/bsp/stm32f3discovery/src/os_bsp.c
+++ b/hw/bsp/stm32f3discovery/src/os_bsp.c
@@ -22,15 +22,30 @@ void _close(int fd);
 #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 = (32 * 1024)
+    },
     [FLASH_AREA_IMAGE_0] = {
         .fa_flash_id = 0,
-        .fa_off = 0x08000000,
-        .fa_size = (192 * 1024)
+        .fa_off = 0x08008000,
+        .fa_size = (104 * 1024)
+    },
+    [FLASH_AREA_IMAGE_1] = {
+        .fa_flash_id = 0,
+        .fa_off = 0x08022000,
+        .fa_size = (104 * 1024)
+    },
+    [FLASH_AREA_IMAGE_SCRATCH] = {
+        .fa_flash_id = 0,
+        .fa_off = 0x0803c000,
+        .fa_size = (8 * 1024)
     },
     [FLASH_AREA_NFFS] = {
         .fa_flash_id = 0,
-        .fa_off = 0x08030000,
-        .fa_size = (32 * 1024)
+        .fa_off = 0x0803e000,
+        .fa_size = (8 * 1024)
     }
 };
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14799154/hw/bsp/stm32f3discovery/src/sbrk.c
----------------------------------------------------------------------
diff --git a/hw/bsp/stm32f3discovery/src/sbrk.c b/hw/bsp/stm32f3discovery/src/sbrk.c
index 73abc2f..c339bf4 100644
--- a/hw/bsp/stm32f3discovery/src/sbrk.c
+++ b/hw/bsp/stm32f3discovery/src/sbrk.c
@@ -16,14 +16,13 @@
 
 #include <errno.h>
 
-extern char _end;
+extern char _user_heap_start;
 extern char _user_heap_end;
+static char *_brk = &_user_heap_start;
 
 void *
 _sbrk(int incr)
 {
-    static char *brk = &_end;
-
     void *prev_brk;
 
     if (incr < 0) {
@@ -31,9 +30,9 @@ _sbrk(int incr)
         prev_brk = (void *)-1;
     } else {
         /* Allocating memory from the heap. */
-        if (&_user_heap_end - brk >= incr) {
-            prev_brk = brk;
-            brk += incr;
+        if (&_user_heap_end - _brk >= incr) {
+            prev_brk = _brk;
+            _brk += incr;
         } else {
             prev_brk = (void *)-1;
             errno = ENOMEM;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14799154/hw/bsp/stm32f3discovery/stm32f3discovery.ld
----------------------------------------------------------------------
diff --git a/hw/bsp/stm32f3discovery/stm32f3discovery.ld b/hw/bsp/stm32f3discovery/stm32f3discovery.ld
index 2b6b536..e9098d4 100755
--- a/hw/bsp/stm32f3discovery/stm32f3discovery.ld
+++ b/hw/bsp/stm32f3discovery/stm32f3discovery.ld
@@ -55,7 +55,7 @@ _Min_Stack_Size = 0x200; /* required amount of stack */
 /* Specify the memory areas */
 MEMORY
 {
-	FLASH (rx)      : ORIGIN = 0x8000000, LENGTH = 256K
+	FLASH (rx)      : ORIGIN = 0x8008000, LENGTH = 104K
 	RAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 40K
 	CCMRAM (rw)      : ORIGIN = 0x10000000, LENGTH = 8K
 }
@@ -63,6 +63,12 @@ MEMORY
 /* Define output sections */
 SECTIONS
 {
+    /* Reserve space at the start of the image for the header. */
+    .imghdr (NOLOAD):
+    {
+        . = . + 0x20;
+    } > FLASH
+
   /* The startup code goes first into FLASH */
   .isr_vector :
   {
@@ -190,8 +196,7 @@ SECTIONS
   ._user_heap :
   {
     . = ALIGN(4);
-    PROVIDE ( end = . );
-    PROVIDE ( _end = . );
+    PROVIDE ( _user_heap_start = . );
     . = . + _Min_Heap_Size;
     . = ALIGN(4);
   } >RAM  

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/14799154/hw/bsp/stm32f3discovery/stm32f3discovery_download.sh
----------------------------------------------------------------------
diff --git a/hw/bsp/stm32f3discovery/stm32f3discovery_download.sh b/hw/bsp/stm32f3discovery/stm32f3discovery_download.sh
index 4682d56..abfa9cc 100755
--- a/hw/bsp/stm32f3discovery/stm32f3discovery_download.sh
+++ b/hw/bsp/stm32f3discovery/stm32f3discovery_download.sh
@@ -12,10 +12,38 @@ 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=0x08008000
+    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 board/stm32f3discovery.cfg -c init -c "reset halt" -c "flash write_image erase $FILE_NAME $FLASH_OFFSET" -c "reset run" -c shutdown
 


[2/6] incubator-mynewt-larva git commit: Remove defines which were under #if 0.

Posted by ma...@apache.org.
Remove defines which were under #if 0.


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/fb12884e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/tree/fb12884e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/diff/fb12884e

Branch: refs/heads/master
Commit: fb12884e515dae41c2fd2185b1980da89f4b06ef
Parents: f19c3ac
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Dec 4 13:38:05 2015 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Dec 4 13:38:05 2015 -0800

----------------------------------------------------------------------
 libs/nffs/include/nffs/nffs.h | 25 +------------------------
 1 file changed, 1 insertion(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-larva/blob/fb12884e/libs/nffs/include/nffs/nffs.h
----------------------------------------------------------------------
diff --git a/libs/nffs/include/nffs/nffs.h b/libs/nffs/include/nffs/nffs.h
index f57ac80..9854bc8 100644
--- a/libs/nffs/include/nffs/nffs.h
+++ b/libs/nffs/include/nffs/nffs.h
@@ -20,32 +20,9 @@
 #include <stddef.h>
 #include <inttypes.h>
 
-#if 0
-#define NFFS_ACCESS_READ        0x01
-#define NFFS_ACCESS_WRITE       0x02
-#define NFFS_ACCESS_APPEND      0x04
-#define NFFS_ACCESS_TRUNCATE    0x08
-#endif
-
 #define NFFS_FILENAME_MAX_LEN   256  /* Does not require null terminator. */
-
 #define NFFS_MAX_AREAS          256
-#if 0
-#define NFFS_EOK                0
-#define NFFS_ECORRUPT           1
-#define NFFS_EFLASH_ERROR       2
-#define NFFS_ERANGE             3
-#define NFFS_EINVAL             4
-#define NFFS_ENOMEM             5
-#define NFFS_ENOENT             6
-#define NFFS_EEMPTY             7
-#define NFFS_EFULL              8
-#define NFFS_EUNEXP             9
-#define NFFS_EOS                10
-#define NFFS_EEXIST             11
-#define NFFS_EACCESS            12
-#define NFFS_EUNINIT            13
-#endif
+
 struct nffs_config {
     /** Maximum number of inodes; default=1024. */
     uint32_t nc_num_inodes;