Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/develop fa73ce595 -> 8d58f7e1e


split - Use _start_split symbol in app.

If the loader and app both use the same start symbol (_start), the
loader's main() gets used by the app, rather than the app's main.  This
causes the linker to strip pretty much all functionality from the app.

The solution is to use a different start symbol for the "application"
half of a split image.  Rather than _start, the app uses _start_split.
In addition, due to the way newt builds split images, _start_split has
to reside in a package that the loader doesn't use.  If it is in a
shared package, the entire package gets put in the loader, and
_start_split would erroneously reference the loader's main().


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

Branch: refs/heads/develop
Commit: 8d58f7e1e16a1f698f1fe4ba22d8a9712649d1e1
Parents: fa73ce5
Author: Christopher Collins <[email protected]>
Authored: Tue Jan 10 12:13:50 2017 -0800
Committer: Christopher Collins <[email protected]>
Committed: Tue Jan 10 12:17:40 2017 -0800

----------------------------------------------------------------------
 apps/splitty/pkg.yml                            | 11 ++---
 boot/split_app/pkg.yml                          | 25 +++++++++++
 boot/split_app/src/split_app.c                  | 46 ++++++++++++++++++++
 .../arch/cortex_m4/gcc_startup_nrf52_split.s    |  2 +-
 .../arch/cortex_m4/gcc_startup_nrf52_split.s    |  2 +-
 .../arch/cortex_m0/gcc_startup_nrf51_split.s    |  2 +-
 .../arch/cortex_m0/gcc_startup_nrf51_split.s    |  2 +-
 .../arch/cortex_m0/gcc_startup_nrf51_split.s    |  2 +-
 .../arch/cortex_m4/gcc_startup_nrf52_split.s    |  2 +-
 .../arch/cortex_m4/gcc_startup_nrf52_split.s    |  2 +-
 .../arch/cortex_m4/gcc_startup_nrf52_split.s    |  2 +-
 11 files changed, 85 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8d58f7e1/apps/splitty/pkg.yml
----------------------------------------------------------------------
diff --git a/apps/splitty/pkg.yml b/apps/splitty/pkg.yml
index 32ce40b..0bacc60 100644
--- a/apps/splitty/pkg.yml
+++ b/apps/splitty/pkg.yml
@@ -25,15 +25,16 @@ pkg.homepage: "http://mynewt.apache.org/";
 pkg.keywords:
 
 pkg.deps:
-    - sys/console/full
+    - boot/bootutil
+    - boot/split
+    - boot/split_app
+    - kernel/os
     - mgmt/imgmgr
     - mgmt/newtmgr
     - mgmt/newtmgr/transport/nmgr_shell
-    - kernel/os
-    - boot/bootutil
-    - sys/shell
     - sys/config
+    - sys/console/full
     - sys/id
     - sys/log
+    - sys/shell
     - sys/stats
-    - boot/split

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8d58f7e1/boot/split_app/pkg.yml
----------------------------------------------------------------------
diff --git a/boot/split_app/pkg.yml b/boot/split_app/pkg.yml
new file mode 100644
index 0000000..4aae64a
--- /dev/null
+++ b/boot/split_app/pkg.yml
@@ -0,0 +1,25 @@
+#
+# 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.
+#
+
+pkg.name: boot/split_app
+pkg.description: Required by the application half of a split image.  The split 
image library helps manage and configure split image operation.
+pkg.author: "Apache Mynewt <[email protected]>"
+pkg.homepage: "http://mynewt.apache.org/";
+pkg.keywords:
+    - split

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8d58f7e1/boot/split_app/src/split_app.c
----------------------------------------------------------------------
diff --git a/boot/split_app/src/split_app.c b/boot/split_app/src/split_app.c
new file mode 100644
index 0000000..aa533bb
--- /dev/null
+++ b/boot/split_app/src/split_app.c
@@ -0,0 +1,46 @@
+/*
+ * 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 <stdlib.h>
+
+extern int main(int argc, char **argv);
+
+/**
+ * Rudimentary startup function.  Only called in the "application" half of a
+ * split image.
+ *
+ * If the loader and app both used the same start symbol (_start), the
+ * loader's main() gets used by the app, rather than the app's main.  This
+ * causes the linker to strip pretty much all functionality from the app.
+ *
+ * The solution is to use a different start symbol for the "application"
+ * half of a split image.  Rather than _start, the app uses _start_split.
+ *
+ * In addition, due to the way newt builds split images, _start_split has
+ * to reside in a package that the loader doesn't use.  If it is in a
+ * shared package, the entire package gets put in the loader, and
+ * _start_split would erroneously reference the loader's main().
+ */
+void
+_start_split(void)
+{
+    int rc;
+
+    rc = main(0, NULL);
+    exit(rc);
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8d58f7e1/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 7426848..5ed4bc6 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
@@ -138,7 +138,7 @@ Reset_Handler_split:
 
     LDR     R0, =SystemInit
     BLX     R0
-    LDR     R0, =_start
+    LDR     R0, =_start_split
     BX      R0
 
     .pool

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8d58f7e1/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 7426848..5ed4bc6 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
@@ -138,7 +138,7 @@ Reset_Handler_split:
 
     LDR     R0, =SystemInit
     BLX     R0
-    LDR     R0, =_start
+    LDR     R0, =_start_split
     BX      R0
 
     .pool

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8d58f7e1/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 ed5f207..1cbe305 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
@@ -153,7 +153,7 @@ Reset_Handler_split:
 
     LDR     R0, =SystemInit
     BLX     R0
-    LDR     R0, =_start
+    LDR     R0, =_start_split
     BX      R0
 
     .pool

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8d58f7e1/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 e44c725..06ce64d 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
@@ -153,7 +153,7 @@ Reset_Handler_split:
 
     LDR     R0, =SystemInit
     BLX     R0
-    LDR     R0, =_start
+    LDR     R0, =_start_split
     BX      R0
 
     .pool

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8d58f7e1/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 ed5f207..1cbe305 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
@@ -153,7 +153,7 @@ Reset_Handler_split:
 
     LDR     R0, =SystemInit
     BLX     R0
-    LDR     R0, =_start
+    LDR     R0, =_start_split
     BX      R0
 
     .pool

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8d58f7e1/hw/bsp/nrf52840pdk/src/arch/cortex_m4/gcc_startup_nrf52_split.s
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf52840pdk/src/arch/cortex_m4/gcc_startup_nrf52_split.s 
b/hw/bsp/nrf52840pdk/src/arch/cortex_m4/gcc_startup_nrf52_split.s
index 7d42423..2afbfca 100755
--- a/hw/bsp/nrf52840pdk/src/arch/cortex_m4/gcc_startup_nrf52_split.s
+++ b/hw/bsp/nrf52840pdk/src/arch/cortex_m4/gcc_startup_nrf52_split.s
@@ -139,7 +139,7 @@ Reset_Handler_split:
 
     LDR     R0, =SystemInit
     BLX     R0
-    LDR     R0, =_start
+    LDR     R0, =_start_split
     BX      R0
 
     .pool

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8d58f7e1/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 7426848..5ed4bc6 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
@@ -138,7 +138,7 @@ Reset_Handler_split:
 
     LDR     R0, =SystemInit
     BLX     R0
-    LDR     R0, =_start
+    LDR     R0, =_start_split
     BX      R0
 
     .pool

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/8d58f7e1/hw/bsp/rb-nano2/src/arch/cortex_m4/gcc_startup_nrf52_split.s
----------------------------------------------------------------------
diff --git a/hw/bsp/rb-nano2/src/arch/cortex_m4/gcc_startup_nrf52_split.s 
b/hw/bsp/rb-nano2/src/arch/cortex_m4/gcc_startup_nrf52_split.s
index 7426848..5ed4bc6 100755
--- a/hw/bsp/rb-nano2/src/arch/cortex_m4/gcc_startup_nrf52_split.s
+++ b/hw/bsp/rb-nano2/src/arch/cortex_m4/gcc_startup_nrf52_split.s
@@ -138,7 +138,7 @@ Reset_Handler_split:
 
     LDR     R0, =SystemInit
     BLX     R0
-    LDR     R0, =_start
+    LDR     R0, =_start_split
     BX      R0
 
     .pool

Reply via email to