bleprph - Add loader support (split image).

This makes the bleprph app suitable as a loader (first stage of a split
image setup).  This commit consists of two changes:

1. When configured to run as a loader, jump into the application rather
than starting the OS (end of main()).

2. Increase bleprph stack size (336 --> 428).  This change was necessary
for processing some of the image management newtmgr commands.


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

Branch: refs/heads/develop
Commit: 6aa1112cb50a0c4d35320f35dc671655c303fb49
Parents: d886fa1
Author: Christopher Collins <[email protected]>
Authored: Mon Jan 16 12:20:36 2017 -0800
Committer: Christopher Collins <[email protected]>
Committed: Mon Jan 16 14:21:46 2017 -0800

----------------------------------------------------------------------
 apps/bleprph/pkg.yml    |  1 +
 apps/bleprph/src/main.c | 26 ++++++++++++++++++++++----
 2 files changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6aa1112c/apps/bleprph/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/bleprph/pkg.yml b/apps/bleprph/pkg.yml
index 2aa4245..a5ad1d6 100644
--- a/apps/bleprph/pkg.yml
+++ b/apps/bleprph/pkg.yml
@@ -23,6 +23,7 @@ pkg.homepage: "http://mynewt.apache.org/";
 pkg.keywords:
 
 pkg.deps: 
+    - boot/split
     - kernel/os 
     - sys/log
     - mgmt/newtmgr

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/6aa1112c/apps/bleprph/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bleprph/src/main.c b/apps/bleprph/src/main.c
index 08f1baf..df5b847 100755
--- a/apps/bleprph/src/main.c
+++ b/apps/bleprph/src/main.c
@@ -27,6 +27,9 @@
 #include "bsp/bsp.h"
 #include "hal/hal_gpio.h"
 #include "console/console.h"
+#include "hal/hal_system.h"
+#include "config/config.h"
+#include "split/split.h"
 
 /* BLE */
 #include "nimble/ble.h"
@@ -41,7 +44,7 @@ struct log bleprph_log;
 
 /** bleprph task settings. */
 #define BLEPRPH_TASK_PRIO           1
-#define BLEPRPH_STACK_SIZE          (OS_STACK_ALIGN(336))
+#define BLEPRPH_STACK_SIZE          (OS_STACK_ALIGN(428))
 
 struct os_eventq bleprph_evq;
 struct os_task bleprph_task;
@@ -269,12 +272,12 @@ main(void)
 {
     int rc;
 
-    /* Set initial BLE device address. */
-    memcpy(g_dev_addr, (uint8_t[6]){0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a}, 6);
-
     /* Initialize OS */
     sysinit();
 
+    /* Set initial BLE device address. */
+    memcpy(g_dev_addr, (uint8_t[6]){0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a}, 6);
+
     /* Initialize the bleprph log. */
     log_register("bleprph", &bleprph_log, &log_console_handler, NULL,
                  LOG_SYSLEVEL);
@@ -306,6 +309,21 @@ main(void)
     /* Set the default eventq for packages that lack a dedicated task. */
     os_eventq_dflt_set(&bleprph_evq);
 
+    conf_load();
+
+    /* If this app is acting as the loader in a split image setup, jump into
+     * the second stage application instead of starting the OS.
+     */
+#if MYNEWT_VAL(SPLIT_LOADER)
+    {
+        void *entry;
+        rc = split_app_go(&entry, true);
+        if (rc == 0) {
+            hal_system_start(entry);
+        }
+    }
+#endif
+
     /* Start the OS */
     os_start();
 

Reply via email to