You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/10/11 22:03:45 UTC
[1/3] incubator-mynewt-core git commit: imgmgr - "image state"
command.
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop 5fff7319f -> 2056cc633
imgmgr - "image state" command.
This command is intended to replace the following:
* image list
* image boot
* split status
It remains a separate command until it is complete.
Still to do:
* Write op.
* Don't autoconfirm unified images and loaders.
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/7d8ebeff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/7d8ebeff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/7d8ebeff
Branch: refs/heads/develop
Commit: 7d8ebeff8debd2dae28eb34c3c66e8f71cc4d63c
Parents: 5fff731
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Oct 10 19:25:52 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Oct 11 14:31:46 2016 -0700
----------------------------------------------------------------------
boot/bootutil/include/bootutil/bootutil_misc.h | 22 ++-
boot/bootutil/src/bootutil_misc.c | 27 ++-
boot/split/include/split/split.h | 8 +-
boot/split/src/split.c | 58 +++++--
boot/split/src/split_config.c | 8 +-
boot/split/src/split_netmgr.c | 3 +-
boot/split/src/split_priv.h | 1 -
.../src/arch/cortex_m4/gcc_startup_nrf52.s | 5 -
.../arch/cortex_m4/gcc_startup_nrf52_split.s | 2 -
.../src/arch/cortex_m4/gcc_startup_nrf52.s | 6 -
.../arch/cortex_m4/gcc_startup_nrf52_split.s | 2 -
hw/bsp/native/syscfg.yml | 4 +-
.../src/arch/cortex_m0/gcc_startup_nrf51.s | 5 -
.../arch/cortex_m0/gcc_startup_nrf51_split.s | 2 -
.../src/arch/cortex_m0/gcc_startup_nrf51.s | 5 -
.../arch/cortex_m0/gcc_startup_nrf51_split.s | 2 -
.../src/arch/cortex_m0/gcc_startup_nrf51.s | 5 -
.../arch/cortex_m0/gcc_startup_nrf51_split.s | 2 -
.../src/arch/cortex_m4/gcc_startup_nrf52.s | 5 -
.../arch/cortex_m4/gcc_startup_nrf52_split.s | 2 -
hw/bsp/nrf52dk/syscfg.yml | 2 +-
mgmt/imgmgr/include/imgmgr/imgmgr.h | 25 +--
mgmt/imgmgr/pkg.yml | 1 +
mgmt/imgmgr/src/imgmgr.c | 6 +-
mgmt/imgmgr/src/imgmgr_priv.h | 1 +
mgmt/imgmgr/src/imgmgr_state.c | 167 +++++++++++++++++++
sys/sysinit/include/sysinit/sysinit.h | 23 ++-
sys/sysinit/pkg.yml | 1 +
28 files changed, 304 insertions(+), 96 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/boot/bootutil/include/bootutil/bootutil_misc.h
----------------------------------------------------------------------
diff --git a/boot/bootutil/include/bootutil/bootutil_misc.h b/boot/bootutil/include/bootutil/bootutil_misc.h
index ead86d5..32b5456 100644
--- a/boot/bootutil/include/bootutil/bootutil_misc.h
+++ b/boot/bootutil/include/bootutil/bootutil_misc.h
@@ -27,11 +27,22 @@ extern "C" {
#endif
typedef enum {
- SPLIT_NONE = 0,
- SPLIT_TEST,
- SPLIT_RUN,
+ /** Loader only. */
+ BOOT_SPLIT_MODE_LOADER = 0,
+
+ /** Loader + app; revert to loader on reboot. */
+ BOOT_SPLIT_MODE_TEST_APP = 1,
+
+ /** Loader + app; no change on reboot. */
+ BOOT_SPLIT_MODE_APP = 2,
+
+ /** Loader only, revert to loader + app on reboot. */
+ BOOT_SPLIT_MODE_TEST_LOADER = 3,
} boot_split_mode_t;
+/** Count of valid enum values. */
+#define BOOT_SPLIT_MODE_CNT 4
+
extern int8_t boot_split_mode;
int boot_vect_read_test(int *slot);
@@ -39,11 +50,12 @@ int boot_vect_read_main(int *slot);
int boot_vect_write_test(int slot);
int boot_vect_write_main(void);
-void boot_set_image_slot_split(void);
-
boot_split_mode_t boot_split_mode_get(void);
int boot_split_mode_set(boot_split_mode_t split_mode);
+int boot_split_app_active_get(void);
+void boot_split_app_active_set(int active);
+
#ifdef __cplusplus
}
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/boot/bootutil/src/bootutil_misc.c
----------------------------------------------------------------------
diff --git a/boot/bootutil/src/bootutil_misc.c b/boot/bootutil/src/bootutil_misc.c
index 9f7d055..4e096ec 100644
--- a/boot/bootutil/src/bootutil_misc.c
+++ b/boot/bootutil/src/bootutil_misc.c
@@ -35,6 +35,7 @@
int boot_current_slot;
int8_t boot_split_mode;
+int8_t boot_split_app_active;
/*
* Read the image trailer from a given slot.
@@ -65,7 +66,8 @@ boot_vect_read_img_trailer(int slot, struct boot_img_trailer *bit)
*
* @param slot On success, the slot number of image to boot.
*
- * @return 0 on success; nonzero on failure.
+ * @return 0 if a test image was found;
+ * nonzero if there is no test image.
*/
int
boot_vect_read_test(int *slot)
@@ -122,6 +124,9 @@ boot_vect_read_main(int *slot)
/**
* Write the test image version number from the boot vector.
*
+ * @param slot The image slot to write to. Note: this is an
+ * image slot index, not a flash area ID.
+ *
* @return 0 on success; nonzero on failure.
*/
int
@@ -327,12 +332,6 @@ boot_clear_status(void)
hal_flash_write(flash_id, off, &val, sizeof(val));
}
-void
-boot_set_image_slot_split(void)
-{
- boot_current_slot = 1;
-}
-
boot_split_mode_t
boot_split_mode_get(void)
{
@@ -342,10 +341,22 @@ boot_split_mode_get(void)
int
boot_split_mode_set(boot_split_mode_t split_mode)
{
- if (split_mode < 0 || split_mode > SPLIT_RUN) {
+ if (split_mode < 0 || split_mode >= BOOT_SPLIT_MODE_CNT) {
return EINVAL;
}
boot_split_mode = split_mode;
return 0;
}
+
+int
+boot_split_app_active_get(void)
+{
+ return boot_split_app_active;
+}
+
+void
+boot_split_app_active_set(int active)
+{
+ boot_split_app_active = !!active;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/boot/split/include/split/split.h
----------------------------------------------------------------------
diff --git a/boot/split/include/split/split.h b/boot/split/include/split/split.h
index ac90ced..6e81727 100644
--- a/boot/split/include/split/split.h
+++ b/boot/split/include/split/split.h
@@ -27,9 +27,9 @@ extern "C" {
#define SPLIT_NMGR_OP_SPLIT 0
typedef enum {
- SPLIT_INVALID,
- SPLIT_NOT_MATCHING,
- SPLIT_MATCHING,
+ SPLIT_STATUS_INVALID = 0,
+ SPLIT_STATUS_NOT_MATCHING = 1,
+ SPLIT_STATUS_MATCHING = 2,
} split_status_t;
/*
@@ -51,6 +51,8 @@ void split_app_init(void);
* @Returns zero on success, non-zero on failures */
int split_app_go(void **entry, int toboot);
+split_status_t split_check_status(void);
+
#ifdef __cplusplus
}
#endif
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/boot/split/src/split.c
----------------------------------------------------------------------
diff --git a/boot/split/src/split.c b/boot/split/src/split.c
index e3ae1c6..ce7a409 100644
--- a/boot/split/src/split.c
+++ b/boot/split/src/split.c
@@ -35,10 +35,10 @@ split_app_init(void)
int rc;
rc = split_conf_init();
- assert(rc==0);
+ assert(rc == 0);
rc = split_nmgr_register();
- assert(rc==0);
+ assert(rc == 0);
}
split_status_t
@@ -48,44 +48,72 @@ split_check_status(void)
int rc;
rc = split_go(LOADER_IMAGE_SLOT, SPLIT_IMAGE_SLOT, &entry);
+ switch (rc) {
+ case SPLIT_GO_ERR:
+ return SPLIT_STATUS_INVALID;
- if(rc == SPLIT_GO_ERR) {
- return SPLIT_INVALID;
- } else if (rc) {
- }
+ case SPLIT_GO_NON_MATCHING:
+ return SPLIT_STATUS_NOT_MATCHING;
+
+ case SPLIT_GO_OK:
+ return SPLIT_STATUS_MATCHING;
- return SPLIT_MATCHING;
+ default:
+ assert(0);
+ return SPLIT_STATUS_INVALID;
+ }
}
/**
* This validates and provides the loader image data
*
- * @param req Contains information about the flash layout.
- * @param rsp On success, indicates how booting should occur.
- *
* @return 0 on success; nonzero on failure.
*/
int
split_app_go(void **entry, int toboot)
{
boot_split_mode_t split_mode;
+ int run_app;
int rc;
if (toboot) {
split_mode = boot_split_mode_get();
/* if we are told not to, then we don't boot an app */
- if (split_mode == SPLIT_NONE) {
+ if (split_mode == BOOT_SPLIT_MODE_LOADER) {
return -1;
}
/* if this is a one-time test, reset the split mode */
- if (split_mode == SPLIT_TEST) {
- split_write_split(SPLIT_NONE);
+ switch (split_mode) {
+ case BOOT_SPLIT_MODE_LOADER:
+ run_app = 0;
+ break;
+
+ case BOOT_SPLIT_MODE_TEST_APP:
+ split_write_split(BOOT_SPLIT_MODE_LOADER);
+ run_app = 1;
+ break;
+
+ case BOOT_SPLIT_MODE_TEST_LOADER:
+ split_write_split(BOOT_SPLIT_MODE_APP);
+ run_app = 0;
+ break;
+
+ case BOOT_SPLIT_MODE_APP:
+ run_app = 1;
+ break;
+
+ default:
+ run_app = 0;
+ break;
+ }
+
+ if (!run_app) {
+ return -1;
}
}
rc = split_go(LOADER_IMAGE_SLOT, SPLIT_IMAGE_SLOT, entry);
-
- return (rc);
+ return rc;
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/boot/split/src/split_config.c
----------------------------------------------------------------------
diff --git a/boot/split/src/split_config.c b/boot/split/src/split_config.c
index a8f9cfa..fab8594 100644
--- a/boot/split/src/split_config.c
+++ b/boot/split/src/split_config.c
@@ -55,13 +55,17 @@ split_conf_set(int argc, char **argv, char *val)
if (argc == 1) {
if (!strcmp(argv[0], "status")) {
- split_mode = boot_split_mode_get();
rc = CONF_VALUE_SET(val, CONF_INT8, split_mode);
if (rc != 0) {
return rc;
}
- boot_split_mode_set(split_mode);
+ rc = boot_split_mode_set(split_mode);
+ if (rc != 0) {
+ return rc;
+ }
+
+ return 0;
}
}
return -1;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/boot/split/src/split_netmgr.c
----------------------------------------------------------------------
diff --git a/boot/split/src/split_netmgr.c b/boot/split/src/split_netmgr.c
index fa65ad7..79a4e9e 100644
--- a/boot/split/src/split_netmgr.c
+++ b/boot/split/src/split_netmgr.c
@@ -65,8 +65,7 @@ imgr_splitapp_read(struct mgmt_jbuf *njb)
JSON_VALUE_INT(&jv, x)
json_encode_object_entry(enc, "splitMode", &jv);
- x = split_check_status();
- JSON_VALUE_INT(&jv, x)
+ JSON_VALUE_INT(&jv, split_check_status())
json_encode_object_entry(enc, "splitStatus", &jv);
JSON_VALUE_INT(&jv, MGMT_ERR_EOK);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/boot/split/src/split_priv.h
----------------------------------------------------------------------
diff --git a/boot/split/src/split_priv.h b/boot/split/src/split_priv.h
index 2c9706d..4858c1a 100644
--- a/boot/split/src/split_priv.h
+++ b/boot/split/src/split_priv.h
@@ -30,7 +30,6 @@ int split_conf_init(void);
int split_nmgr_register(void);
int split_read_split(boot_split_mode_t *split);
int split_write_split(boot_split_mode_t mode);
-split_status_t split_check_status(void);
#ifdef __cplusplus
}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/hw/bsp/arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52.s
----------------------------------------------------------------------
diff --git a/hw/bsp/arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52.s b/hw/bsp/arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52.s
index 54b76ad..fb804fd 100755
--- a/hw/bsp/arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52.s
+++ b/hw/bsp/arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52.s
@@ -138,11 +138,6 @@ __isr_vector:
Reset_Handler:
.fnstart
- /* This is called but current_slot is in the data section so it is
- * overwritten. its only called here to ensure that the global and this
- * function are linked into the loader */
- BL boot_set_image_slot_split
-
/* Loop to copy data from read only memory to RAM. The ranges
* of copy from/to are specified by following symbols evaluated in
* linker script.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/hw/bsp/arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52_split.s
----------------------------------------------------------------------
diff --git a/hw/bsp/arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52_split.s b/hw/bsp/arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52_split.s
index 26bb3a8..7426848 100755
--- a/hw/bsp/arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52_split.s
+++ b/hw/bsp/arduino_primo_nrf52/src/arch/cortex_m4/gcc_startup_nrf52_split.s
@@ -136,8 +136,6 @@ Reset_Handler_split:
LDR R1, =__HeapLimit
BL _sbrkInit
- BL boot_set_image_slot_split
-
LDR R0, =SystemInit
BLX R0
LDR R0, =_start
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52.s
----------------------------------------------------------------------
diff --git a/hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52.s b/hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52.s
index d37a701..fb804fd 100755
--- a/hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52.s
+++ b/hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52.s
@@ -138,12 +138,6 @@ __isr_vector:
Reset_Handler:
.fnstart
- /* This is called but current_slot is in the data section so it is
- * overwritten. its only called here to ensure that the global and this
- * function are linked into the loader */
- BL boot_set_image_slot_split
-
-
/* Loop to copy data from read only memory to RAM. The ranges
* of copy from/to are specified by following symbols evaluated in
* linker script.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52_split.s
----------------------------------------------------------------------
diff --git a/hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52_split.s b/hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52_split.s
index 26bb3a8..7426848 100755
--- a/hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52_split.s
+++ b/hw/bsp/bmd300eval/src/arch/cortex_m4/gcc_startup_nrf52_split.s
@@ -136,8 +136,6 @@ Reset_Handler_split:
LDR R1, =__HeapLimit
BL _sbrkInit
- BL boot_set_image_slot_split
-
LDR R0, =SystemInit
BLX R0
LDR R0, =_start
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/hw/bsp/native/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/native/syscfg.yml b/hw/bsp/native/syscfg.yml
index d648bb0..31ce1c0 100644
--- a/hw/bsp/native/syscfg.yml
+++ b/hw/bsp/native/syscfg.yml
@@ -1,2 +1,2 @@
-syscfg.vals:
- NFFS_FLASH_AREA: FLASH_AREA_NFFS
+#syscfg.vals:
+ #NFFS_FLASH_AREA: FLASH_AREA_NFFS
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51.s
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51.s b/hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51.s
index 4c1a09a..e4a887b 100755
--- a/hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51.s
+++ b/hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51.s
@@ -149,11 +149,6 @@ Reset_Handler:
ORRS R2, R1
STR R2, [R0]
- /* This is called but current_slot is in the data section so it is
- * overwritten. its only called here to ensure that the global and this
- * function are linked into the loader */
- BL boot_set_image_slot_split
-
/* Loop to copy data from read only memory to RAM. The ranges
* of copy from/to are specified by following symbols evaluated in
* linker script.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51_split.s
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51_split.s b/hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51_split.s
index 88998f4..ed5f207 100755
--- a/hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51_split.s
+++ b/hw/bsp/nrf51-blenano/src/arch/cortex_m0/gcc_startup_nrf51_split.s
@@ -151,8 +151,6 @@ Reset_Handler_split:
LDR R1, =__HeapLimit
BL _sbrkInit
- BL boot_set_image_slot_split
-
LDR R0, =SystemInit
BLX R0
LDR R0, =_start
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/hw/bsp/nrf51dk-16kbram/src/arch/cortex_m0/gcc_startup_nrf51.s
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk-16kbram/src/arch/cortex_m0/gcc_startup_nrf51.s b/hw/bsp/nrf51dk-16kbram/src/arch/cortex_m0/gcc_startup_nrf51.s
index aa89b81..73c6265 100755
--- a/hw/bsp/nrf51dk-16kbram/src/arch/cortex_m0/gcc_startup_nrf51.s
+++ b/hw/bsp/nrf51dk-16kbram/src/arch/cortex_m0/gcc_startup_nrf51.s
@@ -149,11 +149,6 @@ Reset_Handler:
ORRS R2, R1
STR R2, [R0]
- /* This is called but current_slot is in the data section so it is
- * overwritten. its only called here to ensure that the global and this
- * function are linked into the loader */
- BL boot_set_image_slot_split
-
/* Loop to copy data from read only memory to RAM. The ranges
* of copy from/to are specified by following symbols evaluated in
* linker script.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/hw/bsp/nrf51dk-16kbram/src/arch/cortex_m0/gcc_startup_nrf51_split.s
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk-16kbram/src/arch/cortex_m0/gcc_startup_nrf51_split.s b/hw/bsp/nrf51dk-16kbram/src/arch/cortex_m0/gcc_startup_nrf51_split.s
index 8eac1a5..e44c725 100755
--- a/hw/bsp/nrf51dk-16kbram/src/arch/cortex_m0/gcc_startup_nrf51_split.s
+++ b/hw/bsp/nrf51dk-16kbram/src/arch/cortex_m0/gcc_startup_nrf51_split.s
@@ -151,8 +151,6 @@ Reset_Handler_split:
LDR R1, =__HeapLimit
BL _sbrkInit
- BL boot_set_image_slot_split
-
LDR R0, =SystemInit
BLX R0
LDR R0, =_start
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/hw/bsp/nrf51dk/src/arch/cortex_m0/gcc_startup_nrf51.s
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk/src/arch/cortex_m0/gcc_startup_nrf51.s b/hw/bsp/nrf51dk/src/arch/cortex_m0/gcc_startup_nrf51.s
index 7fbba5c..fbc88bd 100755
--- a/hw/bsp/nrf51dk/src/arch/cortex_m0/gcc_startup_nrf51.s
+++ b/hw/bsp/nrf51dk/src/arch/cortex_m0/gcc_startup_nrf51.s
@@ -149,11 +149,6 @@ Reset_Handler:
ORRS R2, R1
STR R2, [R0]
- /* This is called but current_slot is in the data section so it is
- * overwritten. its only called here to ensure that the global and this
- * function are linked into the loader */
- BL boot_set_image_slot_split
-
/* Loop to copy data from read only memory to RAM. The ranges
* of copy from/to are specified by following symbols evaluated in
* linker script.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/hw/bsp/nrf51dk/src/arch/cortex_m0/gcc_startup_nrf51_split.s
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk/src/arch/cortex_m0/gcc_startup_nrf51_split.s b/hw/bsp/nrf51dk/src/arch/cortex_m0/gcc_startup_nrf51_split.s
index 88998f4..ed5f207 100755
--- a/hw/bsp/nrf51dk/src/arch/cortex_m0/gcc_startup_nrf51_split.s
+++ b/hw/bsp/nrf51dk/src/arch/cortex_m0/gcc_startup_nrf51_split.s
@@ -151,8 +151,6 @@ Reset_Handler_split:
LDR R1, =__HeapLimit
BL _sbrkInit
- BL boot_set_image_slot_split
-
LDR R0, =SystemInit
BLX R0
LDR R0, =_start
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/hw/bsp/nrf52dk/src/arch/cortex_m4/gcc_startup_nrf52.s
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52dk/src/arch/cortex_m4/gcc_startup_nrf52.s b/hw/bsp/nrf52dk/src/arch/cortex_m4/gcc_startup_nrf52.s
index 54b76ad..fb804fd 100755
--- a/hw/bsp/nrf52dk/src/arch/cortex_m4/gcc_startup_nrf52.s
+++ b/hw/bsp/nrf52dk/src/arch/cortex_m4/gcc_startup_nrf52.s
@@ -138,11 +138,6 @@ __isr_vector:
Reset_Handler:
.fnstart
- /* This is called but current_slot is in the data section so it is
- * overwritten. its only called here to ensure that the global and this
- * function are linked into the loader */
- BL boot_set_image_slot_split
-
/* Loop to copy data from read only memory to RAM. The ranges
* of copy from/to are specified by following symbols evaluated in
* linker script.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/hw/bsp/nrf52dk/src/arch/cortex_m4/gcc_startup_nrf52_split.s
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52dk/src/arch/cortex_m4/gcc_startup_nrf52_split.s b/hw/bsp/nrf52dk/src/arch/cortex_m4/gcc_startup_nrf52_split.s
index 26bb3a8..7426848 100755
--- a/hw/bsp/nrf52dk/src/arch/cortex_m4/gcc_startup_nrf52_split.s
+++ b/hw/bsp/nrf52dk/src/arch/cortex_m4/gcc_startup_nrf52_split.s
@@ -136,8 +136,6 @@ Reset_Handler_split:
LDR R1, =__HeapLimit
BL _sbrkInit
- BL boot_set_image_slot_split
-
LDR R0, =SystemInit
BLX R0
LDR R0, =_start
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/hw/bsp/nrf52dk/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52dk/syscfg.yml b/hw/bsp/nrf52dk/syscfg.yml
index c6a60fd..1168d42 100644
--- a/hw/bsp/nrf52dk/syscfg.yml
+++ b/hw/bsp/nrf52dk/syscfg.yml
@@ -90,5 +90,5 @@ syscfg.defs:
syscfg.vals:
CONFIG_FCB_FLASH_AREA: FLASH_AREA_NFFS
REBOOT_LOG_FLASH_AREA: FLASH_AREA_REBOOT_LOG
- NFFS_FLASH_AREA: FLASH_AREA_REBOOT_LOG
+ NFFS_FLASH_AREA: FLASH_AREA_NFFS
COREDUMP_FLASH_AREA: FLASH_AREA_IMAGE_1
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/mgmt/imgmgr/include/imgmgr/imgmgr.h
----------------------------------------------------------------------
diff --git a/mgmt/imgmgr/include/imgmgr/imgmgr.h b/mgmt/imgmgr/include/imgmgr/imgmgr.h
index 4ec754c..45c77c7 100644
--- a/mgmt/imgmgr/include/imgmgr/imgmgr.h
+++ b/mgmt/imgmgr/include/imgmgr/imgmgr.h
@@ -20,24 +20,27 @@
#ifndef _IMGMGR_H_
#define _IMGMGR_H_
+#include <inttypes.h>
+
#ifdef __cplusplus
extern "C" {
#endif
-#define IMGMGR_NMGR_OP_LIST 0
-#define IMGMGR_NMGR_OP_UPLOAD 1
-#define IMGMGR_NMGR_OP_BOOT 2
-#define IMGMGR_NMGR_OP_FILE 3
-#define IMGMGR_NMGR_OP_LIST2 4
-#define IMGMGR_NMGR_OP_BOOT2 5
-#define IMGMGR_NMGR_OP_CORELIST 6
-#define IMGMGR_NMGR_OP_CORELOAD 7
+#define IMGMGR_NMGR_OP_LIST 0
+#define IMGMGR_NMGR_OP_UPLOAD 1
+#define IMGMGR_NMGR_OP_BOOT 2
+#define IMGMGR_NMGR_OP_FILE 3
+#define IMGMGR_NMGR_OP_LIST2 4
+#define IMGMGR_NMGR_OP_BOOT2 5
+#define IMGMGR_NMGR_OP_CORELIST 6
+#define IMGMGR_NMGR_OP_CORELOAD 7
+#define IMGMGR_NMGR_OP_STATE 8
-#define IMGMGR_NMGR_MAX_MSG 400
+#define IMGMGR_NMGR_MAX_MSG 400
#define IMGMGR_NMGR_MAX_NAME 64
-#define IMGMGR_NMGR_MAX_VER 25 /* 255.255.65535.4294967295\0 */
+#define IMGMGR_NMGR_MAX_VER 25 /* 255.255.65535.4294967295\0 */
-#define IMGMGR_HASH_LEN 32
+#define IMGMGR_HASH_LEN 32
extern int boot_current_slot;
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/mgmt/imgmgr/pkg.yml
----------------------------------------------------------------------
diff --git a/mgmt/imgmgr/pkg.yml b/mgmt/imgmgr/pkg.yml
index d514670..bfe30f9 100644
--- a/mgmt/imgmgr/pkg.yml
+++ b/mgmt/imgmgr/pkg.yml
@@ -25,6 +25,7 @@ pkg.keywords:
pkg.deps:
- boot/bootutil
+ - boot/split
- encoding/base64
- mgmt/mgmt
- sys/flash_map
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/mgmt/imgmgr/src/imgmgr.c
----------------------------------------------------------------------
diff --git a/mgmt/imgmgr/src/imgmgr.c b/mgmt/imgmgr/src/imgmgr.c
index 28a6ff0..2bc4eec 100644
--- a/mgmt/imgmgr/src/imgmgr.c
+++ b/mgmt/imgmgr/src/imgmgr.c
@@ -85,7 +85,11 @@ static const struct mgmt_handler imgr_nmgr_handlers[] = {
.mh_read = NULL,
.mh_write = NULL
#endif
- }
+ },
+ [IMGMGR_NMGR_OP_STATE] = {
+ .mh_read = imgr_state_read,
+ .mh_write = NULL,//imgr_state_write,
+ },
};
#define IMGR_HANDLER_CNT \
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/mgmt/imgmgr/src/imgmgr_priv.h
----------------------------------------------------------------------
diff --git a/mgmt/imgmgr/src/imgmgr_priv.h b/mgmt/imgmgr/src/imgmgr_priv.h
index bdf1449..7f8a0bf 100644
--- a/mgmt/imgmgr/src/imgmgr_priv.h
+++ b/mgmt/imgmgr/src/imgmgr_priv.h
@@ -111,6 +111,7 @@ int imgr_core_load(struct mgmt_jbuf *);
int imgr_core_erase(struct mgmt_jbuf *);
int imgr_splitapp_read(struct mgmt_jbuf *);
int imgr_splitapp_write(struct mgmt_jbuf *);
+int imgr_state_read(struct mgmt_jbuf *njb);
int imgr_find_by_ver(struct image_version *find, uint8_t *hash);
int imgr_find_by_hash(uint8_t *find, struct image_version *ver);
int imgr_cli_register(void);
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/mgmt/imgmgr/src/imgmgr_state.c
----------------------------------------------------------------------
diff --git a/mgmt/imgmgr/src/imgmgr_state.c b/mgmt/imgmgr/src/imgmgr_state.c
new file mode 100644
index 0000000..4fdd8cb
--- /dev/null
+++ b/mgmt/imgmgr/src/imgmgr_state.c
@@ -0,0 +1,167 @@
+/**
+ * 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.
+ */
+
+#include <assert.h>
+
+#include "bootutil/image.h"
+#include "bootutil/bootutil_misc.h"
+#include "base64/base64.h"
+#include "split/split.h"
+#include "mgmt/mgmt.h"
+#include "imgmgr/imgmgr.h"
+#include "imgmgr_priv.h"
+
+#define IMGMGR_STATE_F_PENDING 0x01
+#define IMGMGR_STATE_F_CONFIRMED 0x02
+#define IMGMGR_STATE_F_ACTIVE 0x04
+
+static uint8_t
+imgmgr_state_flags(int query_slot)
+{
+ boot_split_mode_t split_mode;
+ uint8_t flags;
+ int slot;
+ int rc;
+
+ assert(query_slot == 0 || query_slot == 1);
+
+ flags = 0;
+
+ /* Determine if this is is pending or confirmed (only applicable for
+ * unified images and loaders.
+ */
+ rc = boot_vect_read_test(&slot);
+ if (rc == 0 && slot == query_slot) {
+ flags |= IMGMGR_STATE_F_PENDING;
+ }
+ rc = boot_vect_read_main(&slot);
+ if (rc == 0 && slot == query_slot) {
+ flags |= IMGMGR_STATE_F_CONFIRMED;
+ }
+
+ /* Slot 0 is always active. Slot 1 is also active if a split app is
+ * currently running.
+ */
+ /* XXX: The slot 0 assumption only holds when running from flash. */
+ if (query_slot == 0 || boot_split_app_active_get()) {
+ flags |= IMGMGR_STATE_F_ACTIVE;
+ }
+
+ /* Read the split/status config state to determine any pending split-image
+ * state changes.
+ */
+ split_mode = boot_split_mode_get();
+ switch (split_mode) {
+ case BOOT_SPLIT_MODE_LOADER:
+ break;
+
+ case BOOT_SPLIT_MODE_APP:
+ if (query_slot == 1) {
+ flags |= IMGMGR_STATE_F_CONFIRMED;
+ }
+ break;
+
+ case BOOT_SPLIT_MODE_TEST_LOADER:
+ if (query_slot == 0) {
+ flags |= IMGMGR_STATE_F_PENDING;
+ }
+ break;
+
+ case BOOT_SPLIT_MODE_TEST_APP:
+ if (query_slot == 1) {
+ flags |= IMGMGR_STATE_F_PENDING;
+ }
+ break;
+
+ default:
+ assert(0);
+ break;
+ }
+
+ /* An image cannot be both pending and confirmed. */
+ assert(!(flags & IMGMGR_STATE_F_PENDING) ||
+ !(flags & IMGMGR_STATE_F_CONFIRMED));
+
+ return flags;
+}
+
+int
+imgr_state_read(struct mgmt_jbuf *njb)
+{
+ struct json_encoder *enc;
+ int i;
+ int rc;
+ uint32_t flags;
+ struct image_version ver;
+ uint8_t hash[IMGMGR_HASH_LEN]; /* SHA256 hash */
+ struct json_value jv;
+ char vers_str[IMGMGR_NMGR_MAX_VER];
+ char hash_str[IMGMGR_HASH_STR + 1];
+ int ver_len;
+ uint8_t state_flags;
+
+ enc = &njb->mjb_enc;
+
+ json_encode_object_start(enc);
+ json_encode_array_name(enc, "images");
+ json_encode_array_start(enc);
+ for (i = 0; i < 2; i++) {
+ rc = imgr_read_info(i, &ver, hash, &flags);
+ if (rc != 0) {
+ continue;
+ }
+
+ state_flags = imgmgr_state_flags(i);
+
+ json_encode_object_start(enc);
+
+ JSON_VALUE_INT(&jv, i);
+ json_encode_object_entry(enc, "slot", &jv);
+
+ ver_len = imgr_ver_str(&ver, vers_str);
+ JSON_VALUE_STRINGN(&jv, vers_str, ver_len);
+ json_encode_object_entry(enc, "version", &jv);
+
+ base64_encode(hash, IMGMGR_HASH_LEN, hash_str, 1);
+ JSON_VALUE_STRING(&jv, hash_str);
+ json_encode_object_entry(enc, "hash", &jv);
+
+ JSON_VALUE_BOOL(&jv, !(flags & IMAGE_F_NON_BOOTABLE));
+ json_encode_object_entry(enc, "bootable", &jv);
+
+ JSON_VALUE_BOOL(&jv, state_flags & IMGMGR_STATE_F_PENDING);
+ json_encode_object_entry(enc, "test-pending", &jv);
+
+ JSON_VALUE_BOOL(&jv, state_flags & IMGMGR_STATE_F_CONFIRMED);
+ json_encode_object_entry(enc, "confirmed", &jv);
+
+ JSON_VALUE_BOOL(&jv, state_flags & IMGMGR_STATE_F_ACTIVE);
+ json_encode_object_entry(enc, "active", &jv);
+
+ json_encode_object_finish(enc);
+ }
+ json_encode_array_finish(enc);
+
+ JSON_VALUE_INT(&jv, split_check_status());
+ json_encode_object_entry(enc, "splitStatus", &jv);
+
+ json_encode_object_finish(enc);
+
+ return 0;
+}
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/sys/sysinit/include/sysinit/sysinit.h
----------------------------------------------------------------------
diff --git a/sys/sysinit/include/sysinit/sysinit.h b/sys/sysinit/include/sysinit/sysinit.h
index 4b61754..4e6fcb7 100644
--- a/sys/sysinit/include/sysinit/sysinit.h
+++ b/sys/sysinit/include/sysinit/sysinit.h
@@ -21,6 +21,7 @@
#define H_SYSINIT_
#include "syscfg/syscfg.h"
+#include "bootutil/bootutil_misc.h"
#ifdef __cplusplus
extern "C" {
@@ -42,12 +43,30 @@ typedef void sysinit_panic_fn(const char *file, int line);
} \
} while (0)
+
#if MYNEWT_VAL(SPLIT_LOADER)
+
+/*** System initialization for loader (first stage of split image). */
void sysinit_loader(void);
-#define sysinit sysinit_loader
+#define sysinit() sysinit_loader()
+
+#elif MYNEWT_VAL(SPLIT_APPLICATION)
+
+/*** System initialization for split-app (second stage of split image). */
+void sysinit_app(void);
+#define sysinit() do \
+{ \
+ /* Record that a split app is running; imgmgt needs to know this. */ \
+ boot_split_app_active_set(1); \
+ sysinit_app(); \
+} while (0)
+
#else
+
+/*** System initialization for a unified image (no split). */
void sysinit_app(void);
-#define sysinit sysinit_app
+#define sysinit() sysinit_app()
+
#endif
#ifdef __cplusplus
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/7d8ebeff/sys/sysinit/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/sysinit/pkg.yml b/sys/sysinit/pkg.yml
index 2b1c3bc..f45e07a 100644
--- a/sys/sysinit/pkg.yml
+++ b/sys/sysinit/pkg.yml
@@ -25,4 +25,5 @@ pkg.keywords:
- init
pkg.deps:
+ - boot/bootutil
- kernel/os
[3/3] incubator-mynewt-core git commit: native bsp - Uncomment NFFS
AREA designation.
Posted by cc...@apache.org.
native bsp - Uncomment NFFS AREA designation.
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/2056cc63
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/2056cc63
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/2056cc63
Branch: refs/heads/develop
Commit: 2056cc633cbd3f506d303c77ae37a2e4a9d2ac36
Parents: dbb3d6b
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Oct 11 15:03:24 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Oct 11 15:03:24 2016 -0700
----------------------------------------------------------------------
hw/bsp/native/syscfg.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2056cc63/hw/bsp/native/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/native/syscfg.yml b/hw/bsp/native/syscfg.yml
index 31ce1c0..d648bb0 100644
--- a/hw/bsp/native/syscfg.yml
+++ b/hw/bsp/native/syscfg.yml
@@ -1,2 +1,2 @@
-#syscfg.vals:
- #NFFS_FLASH_AREA: FLASH_AREA_NFFS
+syscfg.vals:
+ NFFS_FLASH_AREA: FLASH_AREA_NFFS
[2/3] incubator-mynewt-core git commit: olimex bsp - Add flash area
comments.
Posted by cc...@apache.org.
olimex bsp - Add flash area comments.
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/dbb3d6bb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/dbb3d6bb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/dbb3d6bb
Branch: refs/heads/develop
Commit: dbb3d6bbe504cd9b70592f942cf35ed80a0647c1
Parents: 7d8ebef
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Oct 11 13:04:34 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Oct 11 14:31:47 2016 -0700
----------------------------------------------------------------------
hw/mcu/stm/stm32f4xx/src/hal_flash.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/dbb3d6bb/hw/mcu/stm/stm32f4xx/src/hal_flash.c
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/src/hal_flash.c b/hw/mcu/stm/stm32f4xx/src/hal_flash.c
index 29a1e7b..75ddbb6 100644
--- a/hw/mcu/stm/stm32f4xx/src/hal_flash.c
+++ b/hw/mcu/stm/stm32f4xx/src/hal_flash.c
@@ -39,18 +39,18 @@ static const struct hal_flash_funcs stm32f4_flash_funcs = {
};
static const uint32_t stm32f4_flash_sectors[] = {
- 0x08000000,
- 0x08004000,
- 0x08008000,
- 0x0800c000,
- 0x08010000,
- 0x08020000,
- 0x08040000,
- 0x08060000,
- 0x08080000,
- 0x080a0000,
- 0x080c0000,
- 0x080e0000,
+ 0x08000000, /* 16kB */
+ 0x08004000, /* 16kB */
+ 0x08008000, /* 16kB */
+ 0x0800c000, /* 16kB */
+ 0x08010000, /* 64kB */
+ 0x08020000, /* 128kB */
+ 0x08040000, /* 128kB */
+ 0x08060000, /* 128kB */
+ 0x08080000, /* 128kB */
+ 0x080a0000, /* 128kB */
+ 0x080c0000, /* 128kB */
+ 0x080e0000, /* 128kB */
0x08100000 /* End of flash */
};