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/12/19 23:31:26 UTC

[3/3] incubator-mynewt-core git commit: Revert "MYNEWT-512 Replace gen. sysinit with linker sect"

Revert "MYNEWT-512 Replace gen. sysinit with linker sect"

This reverts commit 43a5ef8860cbf4bc5bf43fde8a29fe74361536fa.


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

Branch: refs/heads/develop
Commit: c870a0fe51e8e2ecc0e42a952799272bb45ef825
Parents: 049f8f5
Author: Christopher Collins <cc...@apache.org>
Authored: Mon Dec 19 15:26:12 2016 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Mon Dec 19 15:31:16 2016 -0800

----------------------------------------------------------------------
 boot/split/include/split/split.h                |   4 +
 boot/split/pkg.yml                              |   3 +
 boot/split/src/split.c                          |   4 +-
 fs/fatfs/pkg.yml                                |   3 +
 fs/fatfs/src/mynewt_glue.c                      |   4 +-
 fs/nffs/pkg.yml                                 |   3 +
 fs/nffs/src/nffs.c                              |   4 +-
 hw/mcu/nordic/nrf51xxx/nrf51.ld                 |   7 --
 hw/mcu/nordic/nrf52xxx/nrf52.ld                 |   7 +-
 hw/mcu/stm/stm32f4xx/stm32f401.ld               |   8 --
 hw/mcu/stm/stm32f4xx/stm32f407.ld               |   8 --
 kernel/os/pkg.yml                               |   3 +
 kernel/os/src/os.c                              |   5 +-
 mgmt/imgmgr/include/imgmgr/imgmgr.h             |   2 +
 mgmt/imgmgr/pkg.yml                             |   3 +
 mgmt/imgmgr/src/imgmgr.c                        |   4 +-
 mgmt/newtmgr/pkg.yml                            |   3 +
 mgmt/newtmgr/src/newtmgr.c                      |   4 +-
 mgmt/newtmgr/transport/ble/pkg.yml              |   3 +
 mgmt/newtmgr/transport/ble/src/newtmgr_ble.c    |   4 +-
 mgmt/newtmgr/transport/nmgr_shell/pkg.yml       |   3 +
 .../transport/nmgr_shell/src/nmgr_shell.c       |   4 +-
 mgmt/newtmgr/transport/nmgr_uart/pkg.yml        |   3 +
 .../newtmgr/transport/nmgr_uart/src/nmgr_uart.c |   4 +-
 mgmt/oicmgr/pkg.yml                             |   3 +
 mgmt/oicmgr/src/oicmgr.c                        |   6 +-
 net/ip/mn_socket/test/src/mn_sock_test.c        |   4 -
 net/ip/native_sockets/pkg.yml                   |   3 +
 net/ip/native_sockets/src/native_sock.c         |  21 ++--
 .../controller/include/controller/ble_ll.h      |   3 +
 net/nimble/controller/pkg.yml                   |   3 +
 net/nimble/controller/src/ble_ll.c              |   4 +-
 net/nimble/host/include/host/ble_hs.h           |   1 +
 net/nimble/host/pkg.yml                         |   3 +
 .../ans/include/services/ans/ble_svc_ans.h      |   2 +
 net/nimble/host/services/ans/pkg.yml            |   3 +
 net/nimble/host/services/ans/src/ble_svc_ans.c  |   4 +-
 .../services/bleuart/include/bleuart/bleuart.h  |   2 +
 net/nimble/host/services/bleuart/pkg.yml        |   3 +
 net/nimble/host/services/bleuart/src/bleuart.c  |   4 +-
 .../gap/include/services/gap/ble_svc_gap.h      |   2 +
 net/nimble/host/services/gap/pkg.yml            |   3 +
 net/nimble/host/services/gap/src/ble_svc_gap.c  |   4 +-
 .../gatt/include/services/gatt/ble_svc_gatt.h   |   1 +
 net/nimble/host/services/gatt/pkg.yml           |   3 +
 .../host/services/gatt/src/ble_svc_gatt.c       |   4 +-
 .../ias/include/services/ias/ble_svc_ias.h      |   1 +
 net/nimble/host/services/ias/pkg.yml            |   3 +
 net/nimble/host/services/ias/src/ble_svc_ias.c  |   4 +-
 .../tps/include/services/tps/ble_svc_tps.h      |   4 +
 net/nimble/host/services/tps/pkg.yml            |   3 +
 net/nimble/host/services/tps/src/ble_svc_tps.c  |   4 +-
 net/nimble/host/src/ble_hs.c                    |   6 +-
 net/nimble/host/store/ram/pkg.yml               |   3 +
 net/nimble/host/store/ram/src/ble_store_ram.c   |   4 +-
 net/nimble/transport/ram/pkg.yml                |   3 +
 net/nimble/transport/ram/src/ble_hci_ram.c      |   4 +-
 .../uart/include/transport/uart/ble_hci_uart.h  |  33 +++++
 net/nimble/transport/uart/pkg.yml               |   3 +
 net/nimble/transport/uart/src/ble_hci_uart.c    |   8 +-
 sys/config/pkg.yml                              |   3 +
 sys/config/src/config_init.c                    |   4 +-
 sys/console/full/pkg.yml                        |   3 +
 sys/console/full/src/cons_tty.c                 |   4 +-
 sys/flash_map/include/flash_map/flash_map.h     |   8 +-
 sys/flash_map/pkg.yml                           |   3 +
 sys/flash_map/src/flash_map.c                   |  13 --
 sys/id/include/id/id.h                          |   5 +
 sys/id/pkg.yml                                  |   3 +
 sys/id/src/id.c                                 |   7 +-
 sys/log/include/log/log.h                       |   1 +
 sys/log/pkg.yml                                 |   3 +
 sys/log/src/log.c                               |   4 +-
 sys/mfg/pkg.yml                                 |   4 +
 sys/reboot/pkg.yml                              |   3 +
 sys/reboot/src/log_reboot.c                     |   4 +-
 sys/shell/include/shell/shell.h                 |   1 +
 sys/shell/pkg.yml                               |   3 +
 sys/shell/src/shell.c                           |   4 +-
 sys/stats/include/stats/stats.h                 |   1 +
 sys/stats/pkg.yml                               |   3 +
 sys/stats/src/stats.c                           |   4 +-
 sys/sysinit/include/sysinit/sysinit.h           | 122 +++++--------------
 sys/sysinit/src/sysinit.c                       |  37 +-----
 sys/sysinit/src/sysinit_priv.h                  |  28 -----
 sys/sysinit/src/sysinit_section.c               |  64 ----------
 test/crash_test/include/crash_test/crash_test.h |  35 ++++++
 test/crash_test/pkg.yml                         |   3 +
 test/crash_test/src/crash_cli.c                 |   1 +
 test/crash_test/src/crash_nmgr.c                |   1 +
 test/crash_test/src/crash_test.c                |   5 +-
 test/runtest/pkg.yml                            |   3 +
 test/runtest/src/runtest.c                      |   4 +-
 util/mem/src/mem.c                              |   1 -
 94 files changed, 295 insertions(+), 366 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/boot/split/include/split/split.h
----------------------------------------------------------------------
diff --git a/boot/split/include/split/split.h b/boot/split/include/split/split.h
index 10084f0..e1341d7 100644
--- a/boot/split/include/split/split.h
+++ b/boot/split/include/split/split.h
@@ -51,6 +51,10 @@ typedef enum {
     SPLIT_STATUS_MATCHING =     2,
 } split_status_t;
 
+/*
+  * Initializes the split application library */
+void split_app_init(void);
+
 /**
   * checks the split application state.
   * If the application is configured to be run (and valid)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/boot/split/pkg.yml
----------------------------------------------------------------------
diff --git a/boot/split/pkg.yml b/boot/split/pkg.yml
index 960bddf..6948235 100644
--- a/boot/split/pkg.yml
+++ b/boot/split/pkg.yml
@@ -26,3 +26,6 @@ pkg.keywords:
 
 pkg.deps: 
     - boot/bootutil
+
+pkg.init_function: split_app_init
+pkg.init_stage: 5

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/boot/split/src/split.c
----------------------------------------------------------------------
diff --git a/boot/split/src/split.c b/boot/split/src/split.c
index b663eca..b29a627 100644
--- a/boot/split/src/split.c
+++ b/boot/split/src/split.c
@@ -34,7 +34,7 @@ static int8_t split_mode_cur;
 static int8_t split_app_active;
 
 void
-split_app_init(struct sysinit_init_ctxt *ctxt)
+split_app_init(void)
 {
     int rc;
 
@@ -45,8 +45,6 @@ split_app_init(struct sysinit_init_ctxt *ctxt)
     assert(rc == 0);
 }
 
-SYSINIT_REGISTER_INIT(split_app_init, 5);
-
 split_status_t
 split_check_status(void)
 {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/fs/fatfs/pkg.yml
----------------------------------------------------------------------
diff --git a/fs/fatfs/pkg.yml b/fs/fatfs/pkg.yml
index 2809608..7318674 100644
--- a/fs/fatfs/pkg.yml
+++ b/fs/fatfs/pkg.yml
@@ -34,3 +34,6 @@ pkg.deps:
     - sys/flash_map
     - sys/log
     - sys/stats
+
+pkg.init_function: fatfs_pkg_init
+pkg.init_stage: 2

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/fs/fatfs/src/mynewt_glue.c
----------------------------------------------------------------------
diff --git a/fs/fatfs/src/mynewt_glue.c b/fs/fatfs/src/mynewt_glue.c
index 276ef9b..0f45cfb 100644
--- a/fs/fatfs/src/mynewt_glue.c
+++ b/fs/fatfs/src/mynewt_glue.c
@@ -398,12 +398,10 @@ get_fattime(void)
 }
 
 void
-fatfs_pkg_init(struct sysinit_init_ctxt *ctxt)
+fatfs_pkg_init(void)
 {
     /* Ensure this function only gets called by sysinit. */
     SYSINIT_ASSERT_ACTIVE();
 
     fs_register(&fatfs_ops);
 }
-
-SYSINIT_REGISTER_INIT(fatfs_pkg_init, 2);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/fs/nffs/pkg.yml
----------------------------------------------------------------------
diff --git a/fs/nffs/pkg.yml b/fs/nffs/pkg.yml
index edf74d8..6010aae 100644
--- a/fs/nffs/pkg.yml
+++ b/fs/nffs/pkg.yml
@@ -35,3 +35,6 @@ pkg.deps:
     - sys/flash_map
     - sys/log
     - sys/stats
+
+pkg.init_function: nffs_pkg_init
+pkg.init_stage: 2

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/fs/nffs/src/nffs.c
----------------------------------------------------------------------
diff --git a/fs/nffs/src/nffs.c b/fs/nffs/src/nffs.c
index 4c10a96..8f25cb5 100644
--- a/fs/nffs/src/nffs.c
+++ b/fs/nffs/src/nffs.c
@@ -741,7 +741,7 @@ nffs_init(void)
 }
 
 void
-nffs_pkg_init(struct sysinit_init_ctxt *ctxt)
+nffs_pkg_init(void)
 {
     struct nffs_area_desc descs[NFFS_AREA_MAX + 1];
     int cnt;
@@ -792,5 +792,3 @@ nffs_pkg_init(struct sysinit_init_ctxt *ctxt)
         break;
     }
 }
-
-SYSINIT_REGISTER_INIT(nffs_pkg_init, 2);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/hw/mcu/nordic/nrf51xxx/nrf51.ld
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf51xxx/nrf51.ld b/hw/mcu/nordic/nrf51xxx/nrf51.ld
index 8be1aba..820510f 100755
--- a/hw/mcu/nordic/nrf51xxx/nrf51.ld
+++ b/hw/mcu/nordic/nrf51xxx/nrf51.ld
@@ -83,13 +83,6 @@ SECTIONS
         . = ALIGN(4);
     } > FLASH
 
-    /* The sysinit section contains package initialization information. */
-    .sysinit :
-    {
-        __sysinit_start__ = .;
-        KEEP(*(sysinit))
-        __sysinit_end__ = .;
-    } > FLASH
 
     .ARM.extab :
     {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/hw/mcu/nordic/nrf52xxx/nrf52.ld
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf52xxx/nrf52.ld b/hw/mcu/nordic/nrf52xxx/nrf52.ld
index 408417e..fda1a8e 100755
--- a/hw/mcu/nordic/nrf52xxx/nrf52.ld
+++ b/hw/mcu/nordic/nrf52xxx/nrf52.ld
@@ -80,15 +80,10 @@ SECTIONS
         *(.rodata*)
 
         *(.eh_frame*)
-
-        /* The sysinit section contains package initialization information. */
-        __sysinit_start__ = .;
-        KEEP(*(sysinit))
-        __sysinit_end__ = .;
-
         . = ALIGN(4);
     } > FLASH
 
+
     .ARM.extab :
     {
         *(.ARM.extab* .gnu.linkonce.armextab.*)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/hw/mcu/stm/stm32f4xx/stm32f401.ld
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/stm32f401.ld b/hw/mcu/stm/stm32f4xx/stm32f401.ld
index d52d358..3533cfb 100644
--- a/hw/mcu/stm/stm32f4xx/stm32f401.ld
+++ b/hw/mcu/stm/stm32f4xx/stm32f401.ld
@@ -89,14 +89,6 @@ SECTIONS
         KEEP(*(.eh_frame*))
     } > FLASH
 
-    /* The sysinit section contains package initialization information. */
-    .sysinit :
-    {
-        __sysinit_start__ = .;
-        KEEP(*(sysinit))
-        __sysinit_end__ = .;
-    } > FLASH
-
     .ARM.extab :
     {
         *(.ARM.extab* .gnu.linkonce.armextab.*)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/hw/mcu/stm/stm32f4xx/stm32f407.ld
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/stm32f407.ld b/hw/mcu/stm/stm32f4xx/stm32f407.ld
index d834797..1d06f76 100644
--- a/hw/mcu/stm/stm32f4xx/stm32f407.ld
+++ b/hw/mcu/stm/stm32f4xx/stm32f407.ld
@@ -89,14 +89,6 @@ SECTIONS
         KEEP(*(.eh_frame*))
     } > FLASH
 
-    /* The sysinit section contains package initialization information. */
-    .sysinit :
-    {
-        __sysinit_start__ = .;
-        KEEP(*(sysinit))
-        __sysinit_end__ = .;
-    } > FLASH
-
     .ARM.extab :
     {
         *(.ARM.extab* .gnu.linkonce.armextab.*)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/kernel/os/pkg.yml
----------------------------------------------------------------------
diff --git a/kernel/os/pkg.yml b/kernel/os/pkg.yml
index 6ad08bd..896ed5e 100644
--- a/kernel/os/pkg.yml
+++ b/kernel/os/pkg.yml
@@ -35,3 +35,6 @@ pkg.deps.OS_CLI:
 
 pkg.deps.OS_COREDUMP:
     - sys/coredump
+
+pkg.init_function: os_pkg_init
+pkg.init_stage: 0

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/kernel/os/src/os.c
----------------------------------------------------------------------
diff --git a/kernel/os/src/os.c b/kernel/os/src/os.c
index 5fd47bd..c313a26 100644
--- a/kernel/os/src/os.c
+++ b/kernel/os/src/os.c
@@ -192,17 +192,14 @@ os_start(void)
 }
 
 void
-os_pkg_init(struct sysinit_init_ctxt *ctxt)
+os_pkg_init(void)
 {
     /* Ensure this function only gets called by sysinit. */
     SYSINIT_ASSERT_ACTIVE();
 
-    os_init();
     os_msys_init();
 }
 
-SYSINIT_REGISTER_INIT(os_pkg_init, 0);
-
 /**
  *   }@ General OS functions
  * }@ OS Kernel

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/mgmt/imgmgr/include/imgmgr/imgmgr.h
----------------------------------------------------------------------
diff --git a/mgmt/imgmgr/include/imgmgr/imgmgr.h b/mgmt/imgmgr/include/imgmgr/imgmgr.h
index 161aa4f..a6bed55 100644
--- a/mgmt/imgmgr/include/imgmgr/imgmgr.h
+++ b/mgmt/imgmgr/include/imgmgr/imgmgr.h
@@ -40,6 +40,8 @@ extern "C" {
 
 extern int boot_current_slot;
 
+void imgmgr_module_init(void);
+
 struct image_version;
 
 /*

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/mgmt/imgmgr/pkg.yml
----------------------------------------------------------------------
diff --git a/mgmt/imgmgr/pkg.yml b/mgmt/imgmgr/pkg.yml
index 97d7652..bfe30f9 100644
--- a/mgmt/imgmgr/pkg.yml
+++ b/mgmt/imgmgr/pkg.yml
@@ -41,3 +41,6 @@ pkg.deps.IMGMGR_COREDUMP:
 
 pkg.deps.IMGMGR_SHELL:
     - sys/shell
+
+pkg.init_function: imgmgr_module_init
+pkg.init_stage: 5

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/mgmt/imgmgr/src/imgmgr.c
----------------------------------------------------------------------
diff --git a/mgmt/imgmgr/src/imgmgr.c b/mgmt/imgmgr/src/imgmgr.c
index 0f2b079..1ca37a0 100644
--- a/mgmt/imgmgr/src/imgmgr.c
+++ b/mgmt/imgmgr/src/imgmgr.c
@@ -393,7 +393,7 @@ err:
 }
 
 void
-imgmgr_module_init(struct sysinit_init_ctxt *ctxt)
+imgmgr_module_init(void)
 {
     int rc;
 
@@ -408,5 +408,3 @@ imgmgr_module_init(struct sysinit_init_ctxt *ctxt)
     SYSINIT_PANIC_ASSERT(rc == 0);
 #endif
 }
-
-SYSINIT_REGISTER_INIT(imgmgr_module_init, 5);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/mgmt/newtmgr/pkg.yml
----------------------------------------------------------------------
diff --git a/mgmt/newtmgr/pkg.yml b/mgmt/newtmgr/pkg.yml
index 622e206..12e5c33 100644
--- a/mgmt/newtmgr/pkg.yml
+++ b/mgmt/newtmgr/pkg.yml
@@ -35,3 +35,6 @@ pkg.deps.NEWTMGR_BLE_HOST:
 
 pkg.apis:
     - newtmgr
+
+pkg.init_function: nmgr_pkg_init
+pkg.init_stage: 5

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/mgmt/newtmgr/src/newtmgr.c
----------------------------------------------------------------------
diff --git a/mgmt/newtmgr/src/newtmgr.c b/mgmt/newtmgr/src/newtmgr.c
index 7fb7e2b..cbb0958 100644
--- a/mgmt/newtmgr/src/newtmgr.c
+++ b/mgmt/newtmgr/src/newtmgr.c
@@ -362,7 +362,7 @@ err:
 }
 
 void
-nmgr_pkg_init(struct sysinit_init_ctxt *ctxt)
+nmgr_pkg_init(void)
 {
     int rc;
 
@@ -372,5 +372,3 @@ nmgr_pkg_init(struct sysinit_init_ctxt *ctxt)
     rc = nmgr_task_init();
     SYSINIT_PANIC_ASSERT(rc == 0);
 }
-
-SYSINIT_REGISTER_INIT(nmgr_pkg_init, 5);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/mgmt/newtmgr/transport/ble/pkg.yml
----------------------------------------------------------------------
diff --git a/mgmt/newtmgr/transport/ble/pkg.yml b/mgmt/newtmgr/transport/ble/pkg.yml
index c5d4179..54c0ba5 100644
--- a/mgmt/newtmgr/transport/ble/pkg.yml
+++ b/mgmt/newtmgr/transport/ble/pkg.yml
@@ -30,3 +30,6 @@ pkg.deps:
     - mgmt/mgmt
     - mgmt/newtmgr
     - net/nimble/host
+
+pkg.init_function: newtmgr_ble_pkg_init
+pkg.init_stage: 5

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/mgmt/newtmgr/transport/ble/src/newtmgr_ble.c
----------------------------------------------------------------------
diff --git a/mgmt/newtmgr/transport/ble/src/newtmgr_ble.c b/mgmt/newtmgr/transport/ble/src/newtmgr_ble.c
index 5f38c06..395e866 100644
--- a/mgmt/newtmgr/transport/ble/src/newtmgr_ble.c
+++ b/mgmt/newtmgr/transport/ble/src/newtmgr_ble.c
@@ -231,7 +231,7 @@ err:
 }
 
 void
-newtmgr_ble_pkg_init(struct sysinit_init_ctxt *ctxt)
+newtmgr_ble_pkg_init(void)
 {
     int rc;
 
@@ -241,5 +241,3 @@ newtmgr_ble_pkg_init(struct sysinit_init_ctxt *ctxt)
     rc = nmgr_ble_gatt_svr_init();
     SYSINIT_PANIC_ASSERT(rc == 0);
 }
-
-SYSINIT_REGISTER_INIT(newtmgr_ble_pkg_init, 5);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/mgmt/newtmgr/transport/nmgr_shell/pkg.yml
----------------------------------------------------------------------
diff --git a/mgmt/newtmgr/transport/nmgr_shell/pkg.yml b/mgmt/newtmgr/transport/nmgr_shell/pkg.yml
index 7b6a405..e56b2db 100644
--- a/mgmt/newtmgr/transport/nmgr_shell/pkg.yml
+++ b/mgmt/newtmgr/transport/nmgr_shell/pkg.yml
@@ -29,3 +29,6 @@ pkg.deps:
     - kernel/os
     - sys/shell
     - mgmt/newtmgr
+
+pkg.init_function: nmgr_shell_pkg_init
+pkg.init_stage: 5

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/mgmt/newtmgr/transport/nmgr_shell/src/nmgr_shell.c
----------------------------------------------------------------------
diff --git a/mgmt/newtmgr/transport/nmgr_shell/src/nmgr_shell.c b/mgmt/newtmgr/transport/nmgr_shell/src/nmgr_shell.c
index 2f2206a..c57e9b1 100644
--- a/mgmt/newtmgr/transport/nmgr_shell/src/nmgr_shell.c
+++ b/mgmt/newtmgr/transport/nmgr_shell/src/nmgr_shell.c
@@ -55,7 +55,7 @@ nmgr_shell_in(struct os_mbuf *m, void *arg)
 }
 
 void
-nmgr_shell_pkg_init(struct sysinit_init_ctxt *ctxt)
+nmgr_shell_pkg_init(void)
 {
     int rc;
 
@@ -69,5 +69,3 @@ nmgr_shell_pkg_init(struct sysinit_init_ctxt *ctxt)
     rc = shell_nlip_input_register(nmgr_shell_in, &nmgr_shell_transport);
     assert(rc == 0);
 }
-
-SYSINIT_REGISTER_INIT(nmgr_shell_pkg_init, 5);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/mgmt/newtmgr/transport/nmgr_uart/pkg.yml
----------------------------------------------------------------------
diff --git a/mgmt/newtmgr/transport/nmgr_uart/pkg.yml b/mgmt/newtmgr/transport/nmgr_uart/pkg.yml
index 25d62a2..449e3ef 100644
--- a/mgmt/newtmgr/transport/nmgr_uart/pkg.yml
+++ b/mgmt/newtmgr/transport/nmgr_uart/pkg.yml
@@ -29,3 +29,6 @@ pkg.deps:
     - kernel/os
     - hw/drivers/uart
     - mgmt/newtmgr
+
+pkg.init_function: nmgr_uart_pkg_init
+pkg.init_stage: 5

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/mgmt/newtmgr/transport/nmgr_uart/src/nmgr_uart.c
----------------------------------------------------------------------
diff --git a/mgmt/newtmgr/transport/nmgr_uart/src/nmgr_uart.c b/mgmt/newtmgr/transport/nmgr_uart/src/nmgr_uart.c
index d4ccfd0..adb7e37 100644
--- a/mgmt/newtmgr/transport/nmgr_uart/src/nmgr_uart.c
+++ b/mgmt/newtmgr/transport/nmgr_uart/src/nmgr_uart.c
@@ -344,7 +344,7 @@ nmgr_uart_rx_char(void *arg, uint8_t data)
 }
 
 void
-nmgr_uart_pkg_init(struct sysinit_init_ctxt *ctxt)
+nmgr_uart_pkg_init(void)
 {
     struct nmgr_uart_state *nus = &nmgr_uart_state;
     int rc;
@@ -371,5 +371,3 @@ nmgr_uart_pkg_init(struct sysinit_init_ctxt *ctxt)
 
     nus->nus_cb_ev.ev_cb = nmgr_uart_rx_frame;
 }
-
-SYSINIT_REGISTER_INIT(nmgr_uart_pkg_init, 5);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/mgmt/oicmgr/pkg.yml
----------------------------------------------------------------------
diff --git a/mgmt/oicmgr/pkg.yml b/mgmt/oicmgr/pkg.yml
index 95c7bff..fd9dd46 100644
--- a/mgmt/oicmgr/pkg.yml
+++ b/mgmt/oicmgr/pkg.yml
@@ -34,3 +34,6 @@ pkg.deps:
 
 pkg.apis:
     - newtmgr
+
+pkg.init_function: oicmgr_init
+pkg.init_stage: 5

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/mgmt/oicmgr/src/oicmgr.c
----------------------------------------------------------------------
diff --git a/mgmt/oicmgr/src/oicmgr.c b/mgmt/oicmgr/src/oicmgr.c
index 10d882a..df86c5f 100644
--- a/mgmt/oicmgr/src/oicmgr.c
+++ b/mgmt/oicmgr/src/oicmgr.c
@@ -208,8 +208,8 @@ omgr_event_start(struct os_event *ev)
     oc_add_resource(res);
 }
 
-void
-oicmgr_init(struct sysinit_init_ctxt *ctxt)
+int
+oicmgr_init(void)
 {
     int rc;
 
@@ -225,5 +225,3 @@ oicmgr_init(struct sysinit_init_ctxt *ctxt)
 err:
     return (rc);
 }
-
-SYSINIT_REGISTER_INIT(oicmgr_init, 5);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/ip/mn_socket/test/src/mn_sock_test.c
----------------------------------------------------------------------
diff --git a/net/ip/mn_socket/test/src/mn_sock_test.c b/net/ip/mn_socket/test/src/mn_sock_test.c
index 95e2496..92b489a 100644
--- a/net/ip/mn_socket/test/src/mn_sock_test.c
+++ b/net/ip/mn_socket/test/src/mn_sock_test.c
@@ -77,10 +77,6 @@ mn_socket_test_init()
 }
 
 #if MYNEWT_VAL(SELFTEST)
-
-/* Ensure the native sock sysinit entry is included during linking. */
-SYSINIT_KEEP(native_sock_init);
-
 int
 main(int argc, char **argv)
 {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/ip/native_sockets/pkg.yml
----------------------------------------------------------------------
diff --git a/net/ip/native_sockets/pkg.yml b/net/ip/native_sockets/pkg.yml
index 89cb030..003fd3f 100644
--- a/net/ip/native_sockets/pkg.yml
+++ b/net/ip/native_sockets/pkg.yml
@@ -28,3 +28,6 @@ pkg.keywords:
 pkg.deps:
     - kernel/os
     - net/ip/mn_socket
+
+pkg.init_function: native_sock_init
+pkg.init_stage: 2

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/ip/native_sockets/src/native_sock.c
----------------------------------------------------------------------
diff --git a/net/ip/native_sockets/src/native_sock.c b/net/ip/native_sockets/src/native_sock.c
index 6cc0fc5..9e2d3d6 100644
--- a/net/ip/native_sockets/src/native_sock.c
+++ b/net/ip/native_sockets/src/native_sock.c
@@ -723,8 +723,8 @@ socket_task(void *arg)
     }
 }
 
-void
-native_sock_init(struct sysinit_init_ctxt *ctxt)
+int
+native_sock_init(void)
 {
     struct native_sock_state *nss = &native_sock_state;
     int i;
@@ -738,14 +738,19 @@ native_sock_init(struct sysinit_init_ctxt *ctxt)
         STAILQ_INIT(&native_socks[i].ns_rx);
     }
     sp = malloc(sizeof(os_stack_t) * SOCK_STACK_SZ);
-    SYSINIT_PANIC_ASSERT(sp != NULL);
-
+    if (!sp) {
+        return -1;
+    }
     os_mutex_init(&nss->mtx);
     i = os_task_init(&nss->task, "socket", socket_task, &native_sock_state,
       SOCK_PRIO, OS_WAIT_FOREVER, sp, SOCK_STACK_SZ);
-    SYSINIT_PANIC_ASSERT(i == 0);
+    if (i) {
+        return -1;
+    }
+    i = mn_socket_ops_reg(&native_sock_ops);
+    if (i) {
+        return -1;
+    }
 
-    mn_socket_ops_reg(&native_sock_ops);
+    return 0;
 }
-
-SYSINIT_REGISTER_INIT(native_sock_init, 2);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/controller/include/controller/ble_ll.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll.h b/net/nimble/controller/include/controller/ble_ll.h
index c17b67b..e349d71 100644
--- a/net/nimble/controller/include/controller/ble_ll.h
+++ b/net/nimble/controller/include/controller/ble_ll.h
@@ -288,6 +288,9 @@ struct ble_dev_addr
 #define BLE_CONNECT_REQ_PDU_LEN     (BLE_CONNECT_REQ_LEN + BLE_LL_PDU_HDR_LEN)
 
 /*--- External API ---*/
+/* Initialize the Link Layer */
+void ble_ll_init(void);
+
 /* Reset the Link Layer */
 int ble_ll_reset(void);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/controller/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/controller/pkg.yml b/net/nimble/controller/pkg.yml
index a60d2d7..7761c53 100644
--- a/net/nimble/controller/pkg.yml
+++ b/net/nimble/controller/pkg.yml
@@ -33,3 +33,6 @@ pkg.deps:
     - kernel/os
     - sys/stats
     - net/nimble
+
+pkg.init_function: ble_ll_init
+pkg.init_stage: 2

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/controller/src/ble_ll.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll.c b/net/nimble/controller/src/ble_ll.c
index db72729..63b3cac 100644
--- a/net/nimble/controller/src/ble_ll.c
+++ b/net/nimble/controller/src/ble_ll.c
@@ -1211,7 +1211,7 @@ ble_ll_seed_prng(void)
  * @return int
  */
 void
-ble_ll_init(struct sysinit_init_ctxt *ctxt)
+ble_ll_init(void)
 {
     int rc;
     uint8_t features;
@@ -1323,8 +1323,6 @@ ble_ll_init(struct sysinit_init_ctxt *ctxt)
     ble_hci_trans_cfg_ll(ble_ll_hci_cmd_rx, NULL, ble_ll_hci_acl_rx, NULL);
 }
 
-SYSINIT_REGISTER_INIT(ble_ll_init, 2);
-
 #ifdef BLE_LL_LOG
 void
 ble_ll_log_dump_index(int i)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/include/host/ble_hs.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/include/host/ble_hs.h b/net/nimble/host/include/host/ble_hs.h
index d227d2c..4ee6c79 100644
--- a/net/nimble/host/include/host/ble_hs.h
+++ b/net/nimble/host/include/host/ble_hs.h
@@ -153,6 +153,7 @@ extern struct ble_hs_cfg ble_hs_cfg;
 int ble_hs_synced(void);
 int ble_hs_start(void);
 void ble_hs_evq_set(struct os_eventq *evq);
+void ble_hs_init(void);
 
 #ifdef __cplusplus
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/pkg.yml b/net/nimble/host/pkg.yml
index 96bca58..65b4284 100644
--- a/net/nimble/host/pkg.yml
+++ b/net/nimble/host/pkg.yml
@@ -41,3 +41,6 @@ pkg.deps.BLE_SM_SC:
 pkg.req_apis:
     - ble_transport
     - console
+
+pkg.init_function: "ble_hs_init"
+pkg.init_stage: 2

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/services/ans/include/services/ans/ble_svc_ans.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/ans/include/services/ans/ble_svc_ans.h b/net/nimble/host/services/ans/include/services/ans/ble_svc_ans.h
index 3b84b21..8d3e3cf 100644
--- a/net/nimble/host/services/ans/include/services/ans/ble_svc_ans.h
+++ b/net/nimble/host/services/ans/include/services/ans/ble_svc_ans.h
@@ -79,5 +79,7 @@ int ble_svc_ans_new_alert_add(uint8_t cat_id,
                               const char * info_str);
 int ble_svc_ans_unr_alert_add(uint8_t cat_id);
 
+void ble_svc_ans_init(void);
+
 #endif
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/services/ans/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/ans/pkg.yml b/net/nimble/host/services/ans/pkg.yml
index 91a92c6..41a738c 100644
--- a/net/nimble/host/services/ans/pkg.yml
+++ b/net/nimble/host/services/ans/pkg.yml
@@ -29,3 +29,6 @@ pkg.keywords:
 
 pkg.deps:
     - net/nimble/host
+
+pkg.init_function: ble_svc_ans_init
+pkg.init_stage: 3

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/services/ans/src/ble_svc_ans.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/ans/src/ble_svc_ans.c b/net/nimble/host/services/ans/src/ble_svc_ans.c
index b670483..ca4ee8a 100644
--- a/net/nimble/host/services/ans/src/ble_svc_ans.c
+++ b/net/nimble/host/services/ans/src/ble_svc_ans.c
@@ -441,7 +441,7 @@ ble_svc_ans_chr_write(struct os_mbuf *om, uint16_t min_len,
  * @return 0 on success, non-zero error code otherwise.
  */
 void
-ble_svc_ans_init(struct sysinit_init_ctxt *ctxt)
+ble_svc_ans_init(void)
 {
     int rc;
 
@@ -457,5 +457,3 @@ ble_svc_ans_init(struct sysinit_init_ctxt *ctxt)
     ble_svc_ans_new_alert_cat = MYNEWT_VAL(BLE_SVC_ANS_NEW_ALERT_CAT);
     ble_svc_ans_unr_alert_cat = MYNEWT_VAL(BLE_SVC_ANS_UNR_ALERT_CAT);
 }
-
-SYSINIT_REGISTER_INIT(ble_svc_ans_init, 3);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/services/bleuart/include/bleuart/bleuart.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/bleuart/include/bleuart/bleuart.h b/net/nimble/host/services/bleuart/include/bleuart/bleuart.h
index d8b1c59..a8c29c1 100644
--- a/net/nimble/host/services/bleuart/include/bleuart/bleuart.h
+++ b/net/nimble/host/services/bleuart/include/bleuart/bleuart.h
@@ -24,6 +24,8 @@
 extern "C" {
 #endif
 
+void
+bleuart_init(void);
 int
 bleuart_svc_register(void);
 int

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/services/bleuart/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/bleuart/pkg.yml b/net/nimble/host/services/bleuart/pkg.yml
index 46ed1e6..9850125 100644
--- a/net/nimble/host/services/bleuart/pkg.yml
+++ b/net/nimble/host/services/bleuart/pkg.yml
@@ -32,3 +32,6 @@ pkg.deps:
 
 pkg.req_apis:
     - console
+
+pkg.init_function: bleuart_init
+pkg.init_stage: 5

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/services/bleuart/src/bleuart.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/bleuart/src/bleuart.c b/net/nimble/host/services/bleuart/src/bleuart.c
index 83b8195..3c26ffc 100644
--- a/net/nimble/host/services/bleuart/src/bleuart.c
+++ b/net/nimble/host/services/bleuart/src/bleuart.c
@@ -189,7 +189,7 @@ bleuart_set_conn_handle(uint16_t conn_handle) {
  * @param Maximum input
  */
 void
-bleuart_init(struct sysinit_init_ctxt *ctxt)
+bleuart_init(void)
 {
     int rc;
 
@@ -202,5 +202,3 @@ bleuart_init(struct sysinit_init_ctxt *ctxt)
     console_buf = malloc(MYNEWT_VAL(BLEUART_MAX_INPUT));
     SYSINIT_PANIC_ASSERT(console_buf != NULL);
 }
-
-SYSINIT_REGISTER_INIT(bleuart_init, 5);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/services/gap/include/services/gap/ble_svc_gap.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/gap/include/services/gap/ble_svc_gap.h b/net/nimble/host/services/gap/include/services/gap/ble_svc_gap.h
index 142b96d..cb8d625 100644
--- a/net/nimble/host/services/gap/include/services/gap/ble_svc_gap.h
+++ b/net/nimble/host/services/gap/include/services/gap/ble_svc_gap.h
@@ -38,6 +38,8 @@ struct ble_hs_cfg;
 const char *ble_svc_gap_device_name(void);
 int ble_svc_gap_device_name_set(const char *name);
 
+void ble_svc_gap_init(void);
+
 #ifdef __cplusplus
 }
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/services/gap/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/gap/pkg.yml b/net/nimble/host/services/gap/pkg.yml
index b84e816..376a555 100644
--- a/net/nimble/host/services/gap/pkg.yml
+++ b/net/nimble/host/services/gap/pkg.yml
@@ -29,3 +29,6 @@ pkg.keywords:
 
 pkg.deps:
     - net/nimble/host
+
+pkg.init_function: ble_svc_gap_init
+pkg.init_stage: 3

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/services/gap/src/ble_svc_gap.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/gap/src/ble_svc_gap.c b/net/nimble/host/services/gap/src/ble_svc_gap.c
index b00a84a..e0ccd7c 100644
--- a/net/nimble/host/services/gap/src/ble_svc_gap.c
+++ b/net/nimble/host/services/gap/src/ble_svc_gap.c
@@ -151,7 +151,7 @@ ble_svc_gap_device_name_set(const char *name)
 }
 
 void
-ble_svc_gap_init(struct sysinit_init_ctxt *ctxt)
+ble_svc_gap_init(void)
 {
     int rc;
 
@@ -164,5 +164,3 @@ ble_svc_gap_init(struct sysinit_init_ctxt *ctxt)
     rc = ble_gatts_add_svcs(ble_svc_gap_defs);
     SYSINIT_PANIC_ASSERT(rc == 0);
 }
-
-SYSINIT_REGISTER_INIT(ble_svc_gap_init, 3);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h b/net/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h
index 1cf8857..06c4478 100644
--- a/net/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h
+++ b/net/nimble/host/services/gatt/include/services/gatt/ble_svc_gatt.h
@@ -31,6 +31,7 @@ struct ble_hs_cfg;
 #define BLE_SVC_GATT_CHR_SERVICE_CHANGED_UUID16     0x2a05
 
 void ble_svc_gatt_changed(uint16_t start_handle, uint16_t end_handle);
+void ble_svc_gatt_init(void);
 
 #ifdef __cplusplus
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/services/gatt/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/gatt/pkg.yml b/net/nimble/host/services/gatt/pkg.yml
index b8fdabe..ec0eb1e 100644
--- a/net/nimble/host/services/gatt/pkg.yml
+++ b/net/nimble/host/services/gatt/pkg.yml
@@ -29,3 +29,6 @@ pkg.keywords:
 
 pkg.deps:
     - net/nimble/host
+
+pkg.init_function: ble_svc_gatt_init
+pkg.init_stage: 3

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/services/gatt/src/ble_svc_gatt.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/gatt/src/ble_svc_gatt.c b/net/nimble/host/services/gatt/src/ble_svc_gatt.c
index ecab64b..666e672 100644
--- a/net/nimble/host/services/gatt/src/ble_svc_gatt.c
+++ b/net/nimble/host/services/gatt/src/ble_svc_gatt.c
@@ -93,7 +93,7 @@ ble_svc_gatt_changed(uint16_t start_handle, uint16_t end_handle)
 }
 
 void
-ble_svc_gatt_init(struct sysinit_init_ctxt *ctxt)
+ble_svc_gatt_init(void)
 {
     int rc;
 
@@ -106,5 +106,3 @@ ble_svc_gatt_init(struct sysinit_init_ctxt *ctxt)
     rc = ble_gatts_add_svcs(ble_svc_gatt_defs);
     SYSINIT_PANIC_ASSERT(rc == 0);
 }
-
-SYSINIT_REGISTER_INIT(ble_svc_gatt_init, 3);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/services/ias/include/services/ias/ble_svc_ias.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/ias/include/services/ias/ble_svc_ias.h b/net/nimble/host/services/ias/include/services/ias/ble_svc_ias.h
index c6a6d81..b63b458 100644
--- a/net/nimble/host/services/ias/include/services/ias/ble_svc_ias.h
+++ b/net/nimble/host/services/ias/include/services/ias/ble_svc_ias.h
@@ -31,6 +31,7 @@
 typedef int ble_svc_ias_event_fn(uint8_t alert_level); 
 
 void ble_svc_ias_set_cb(ble_svc_ias_event_fn *cb);
+void ble_svc_ias_init(void);
 
 #endif
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/services/ias/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/ias/pkg.yml b/net/nimble/host/services/ias/pkg.yml
index 1badb00..3879906 100644
--- a/net/nimble/host/services/ias/pkg.yml
+++ b/net/nimble/host/services/ias/pkg.yml
@@ -29,3 +29,6 @@ pkg.keywords:
 
 pkg.deps:
     - net/nimble/host
+
+pkg.init_function: ble_svc_ias_init
+pkg.init_stage: 3

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/services/ias/src/ble_svc_ias.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/ias/src/ble_svc_ias.c b/net/nimble/host/services/ias/src/ble_svc_ias.c
index 2719483..5644ccd 100644
--- a/net/nimble/host/services/ias/src/ble_svc_ias.c
+++ b/net/nimble/host/services/ias/src/ble_svc_ias.c
@@ -132,7 +132,7 @@ ble_svc_ias_set_cb(ble_svc_ias_event_fn *cb)
  * Initialize the IAS package.
  */
 void
-ble_svc_ias_init(struct sysinit_init_ctxt *ctxt)
+ble_svc_ias_init(void)
 {
     int rc;
     
@@ -145,5 +145,3 @@ ble_svc_ias_init(struct sysinit_init_ctxt *ctxt)
     rc = ble_gatts_add_svcs(ble_svc_ias_defs);
     SYSINIT_PANIC_ASSERT(rc == 0);
 }
-
-SYSINIT_REGISTER_INIT(ble_svc_ias_init, 3);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/services/tps/include/services/tps/ble_svc_tps.h
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/tps/include/services/tps/ble_svc_tps.h b/net/nimble/host/services/tps/include/services/tps/ble_svc_tps.h
index d43d09d..ec4cd79 100644
--- a/net/nimble/host/services/tps/include/services/tps/ble_svc_tps.h
+++ b/net/nimble/host/services/tps/include/services/tps/ble_svc_tps.h
@@ -20,8 +20,12 @@
 #ifndef H_BLE_SVC_TPS_
 #define H_BLE_SVC_TPS_
 
+struct ble_hs_cfg;
+
 #define BLE_SVC_TPS_UUID16                                      0x1804
 #define BLE_SVC_TPS_CHR_UUID16_TX_POWER_LEVEL                   0x2a07
 
+void ble_svc_tps_init(void);
+
 #endif
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/services/tps/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/tps/pkg.yml b/net/nimble/host/services/tps/pkg.yml
index f22a395..17b2b87 100644
--- a/net/nimble/host/services/tps/pkg.yml
+++ b/net/nimble/host/services/tps/pkg.yml
@@ -29,3 +29,6 @@ pkg.keywords:
 
 pkg.deps:
     - net/nimble/host
+
+pkg.init_function: ble_svc_tps_init
+pkg.init_stage: 3

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/services/tps/src/ble_svc_tps.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/services/tps/src/ble_svc_tps.c b/net/nimble/host/services/tps/src/ble_svc_tps.c
index 7287d77..74c2df4 100644
--- a/net/nimble/host/services/tps/src/ble_svc_tps.c
+++ b/net/nimble/host/services/tps/src/ble_svc_tps.c
@@ -92,7 +92,7 @@ ble_svc_tps_access(uint16_t conn_handle, uint16_t attr_handle,
  * Initialize the TPS
  */
 void
-ble_svc_tps_init(struct sysinit_init_ctxt *ctxt)
+ble_svc_tps_init(void)
 {
     int rc;
 
@@ -105,5 +105,3 @@ ble_svc_tps_init(struct sysinit_init_ctxt *ctxt)
     rc = ble_gatts_add_svcs(ble_svc_tps_defs);
     SYSINIT_PANIC_ASSERT(rc == 0);
 }
-
-SYSINIT_REGISTER_INIT(ble_svc_tps_init, 3);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/src/ble_hs.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs.c b/net/nimble/host/src/ble_hs.c
index 1e2b426..0d35a88 100644
--- a/net/nimble/host/src/ble_hs.c
+++ b/net/nimble/host/src/ble_hs.c
@@ -538,13 +538,15 @@ ble_hs_tx_data(struct os_mbuf *om)
  * NimBLE by processing events generated by the host.
  */
 void
-ble_hs_init(struct sysinit_init_ctxt *ctxt)
+ble_hs_init(void)
 {
     int rc;
 
     /* Ensure this function only gets called by sysinit. */
     SYSINIT_ASSERT_ACTIVE();
 
+    log_init();
+
     /* Create memory pool of OS events */
     rc = os_mempool_init(&ble_hs_hci_ev_pool, BLE_HS_HCI_EVT_COUNT,
                          sizeof (struct os_event), ble_hs_hci_os_event_buf,
@@ -605,5 +607,3 @@ ble_hs_init(struct sysinit_init_ctxt *ctxt)
     /* Configure the HCI transport to communicate with a host. */
     ble_hci_trans_cfg_hs(ble_hs_hci_rx_evt, NULL, ble_hs_rx_data, NULL);
 }
-
-SYSINIT_REGISTER_INIT(ble_hs_init, 2);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/store/ram/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/host/store/ram/pkg.yml b/net/nimble/host/store/ram/pkg.yml
index f43e7a5..afa638f 100644
--- a/net/nimble/host/store/ram/pkg.yml
+++ b/net/nimble/host/store/ram/pkg.yml
@@ -29,3 +29,6 @@ pkg.keywords:
 
 pkg.deps:
     - net/nimble/host
+
+pkg.init_function: ble_store_ram_init
+pkg.init_stage: 5

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/host/store/ram/src/ble_store_ram.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/store/ram/src/ble_store_ram.c b/net/nimble/host/store/ram/src/ble_store_ram.c
index 16dcd58..65a76cc 100644
--- a/net/nimble/host/store/ram/src/ble_store_ram.c
+++ b/net/nimble/host/store/ram/src/ble_store_ram.c
@@ -469,7 +469,7 @@ ble_store_ram_delete(int obj_type, union ble_store_key *key)
 }
 
 void
-ble_store_ram_init(struct sysinit_init_ctxt *ctxt)
+ble_store_ram_init(void)
 {
     /* Ensure this function only gets called by sysinit. */
     SYSINIT_ASSERT_ACTIVE();
@@ -483,5 +483,3 @@ ble_store_ram_init(struct sysinit_init_ctxt *ctxt)
     ble_store_ram_num_peer_secs = 0;
     ble_store_ram_num_cccds = 0;
 }
-
-SYSINIT_REGISTER_INIT(ble_store_ram_init, 5);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/transport/ram/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/transport/ram/pkg.yml b/net/nimble/transport/ram/pkg.yml
index f66eae0..60d9d96 100644
--- a/net/nimble/transport/ram/pkg.yml
+++ b/net/nimble/transport/ram/pkg.yml
@@ -31,3 +31,6 @@ pkg.deps:
 
 pkg.apis:
     - ble_transport
+
+pkg.init_function: ble_hci_ram_pkg_init
+pkg.init_stage: 1

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/transport/ram/src/ble_hci_ram.c
----------------------------------------------------------------------
diff --git a/net/nimble/transport/ram/src/ble_hci_ram.c b/net/nimble/transport/ram/src/ble_hci_ram.c
index fd356ed..1c0cc6a 100644
--- a/net/nimble/transport/ram/src/ble_hci_ram.c
+++ b/net/nimble/transport/ram/src/ble_hci_ram.c
@@ -241,7 +241,7 @@ err:
 }
 
 void
-ble_hci_ram_pkg_init(struct sysinit_init_ctxt *ctxt)
+ble_hci_ram_pkg_init(void)
 {
     int rc;
 
@@ -251,5 +251,3 @@ ble_hci_ram_pkg_init(struct sysinit_init_ctxt *ctxt)
     rc = ble_hci_ram_init();
     SYSINIT_PANIC_ASSERT(rc == 0);
 }
-
-SYSINIT_REGISTER_INIT(ble_hci_ram_pkg_init, 1);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/transport/uart/include/transport/uart/ble_hci_uart.h
----------------------------------------------------------------------
diff --git a/net/nimble/transport/uart/include/transport/uart/ble_hci_uart.h b/net/nimble/transport/uart/include/transport/uart/ble_hci_uart.h
new file mode 100644
index 0000000..d54fd66
--- /dev/null
+++ b/net/nimble/transport/uart/include/transport/uart/ble_hci_uart.h
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+#ifndef H_BLE_HCI_UART_
+#define H_BLE_HCI_UART_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int ble_hci_uart_init(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/transport/uart/pkg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/transport/uart/pkg.yml b/net/nimble/transport/uart/pkg.yml
index b3a7f68..be76509 100644
--- a/net/nimble/transport/uart/pkg.yml
+++ b/net/nimble/transport/uart/pkg.yml
@@ -33,3 +33,6 @@ pkg.deps:
 
 pkg.apis:
     - ble_transport
+
+pkg.init_function: ble_hci_uart_init
+pkg.init_stage: 5

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/net/nimble/transport/uart/src/ble_hci_uart.c
----------------------------------------------------------------------
diff --git a/net/nimble/transport/uart/src/ble_hci_uart.c b/net/nimble/transport/uart/src/ble_hci_uart.c
old mode 100644
new mode 100755
index fb6433e..1ace2b0
--- a/net/nimble/transport/uart/src/ble_hci_uart.c
+++ b/net/nimble/transport/uart/src/ble_hci_uart.c
@@ -37,6 +37,8 @@
 #include "nimble/hci_common.h"
 #include "nimble/ble_hci_trans.h"
 
+#include "transport/uart/ble_hci_uart.h"
+
 #define BLE_HCI_UART_EVT_COUNT  \
     (MYNEWT_VAL(BLE_HCI_EVT_HI_BUF_COUNT) + MYNEWT_VAL(BLE_HCI_EVT_LO_BUF_COUNT))
 
@@ -957,8 +959,8 @@ ble_hci_trans_reset(void)
  * @return                      0 on success;
  *                              A BLE_ERR_[...] error code on failure.
  */
-void
-ble_hci_uart_init(struct sysinit_init_ctxt *ctxt)
+int
+ble_hci_uart_init(void)
 {
     int acl_data_length;
     int acl_block_size;
@@ -1060,5 +1062,3 @@ err:
     ble_hci_uart_free_mem();
     return rc;
 }
-
-SYSINIT_REGISTER_INIT(ble_hci_uart_init, 5);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/config/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/config/pkg.yml b/sys/config/pkg.yml
index 76b56ef..ac7b15a 100644
--- a/sys/config/pkg.yml
+++ b/sys/config/pkg.yml
@@ -34,3 +34,6 @@ pkg.deps.CONFIG_FCB:
     - fs/fcb
 pkg.deps.CONFIG_NFFS:
     - fs/nffs
+
+pkg.init_function: config_pkg_init
+pkg.init_stage: 3

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/config/src/config_init.c
----------------------------------------------------------------------
diff --git a/sys/config/src/config_init.c b/sys/config/src/config_init.c
index 61e8248..53a5f25 100644
--- a/sys/config/src/config_init.c
+++ b/sys/config/src/config_init.c
@@ -92,7 +92,7 @@ config_init_fcb(void)
 #endif
 
 void
-config_pkg_init(struct sysinit_init_ctxt *ctxt)
+config_pkg_init(void)
 {
     /* Ensure this function only gets called by sysinit. */
     SYSINIT_ASSERT_ACTIVE();
@@ -105,5 +105,3 @@ config_pkg_init(struct sysinit_init_ctxt *ctxt)
     config_init_fcb();
 #endif
 }
-
-SYSINIT_REGISTER_INIT(config_pkg_init, 3);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/console/full/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/console/full/pkg.yml b/sys/console/full/pkg.yml
index 9e26e05..3ad880a 100644
--- a/sys/console/full/pkg.yml
+++ b/sys/console/full/pkg.yml
@@ -28,3 +28,6 @@ pkg.deps:
     - kernel/os
     - hw/drivers/uart
 pkg.apis: console
+
+pkg.init_function: console_pkg_init
+pkg.init_stage: 0

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/console/full/src/cons_tty.c
----------------------------------------------------------------------
diff --git a/sys/console/full/src/cons_tty.c b/sys/console/full/src/cons_tty.c
index 31ac2b3..50870f1 100644
--- a/sys/console/full/src/cons_tty.c
+++ b/sys/console/full/src/cons_tty.c
@@ -562,7 +562,7 @@ console_init(console_rx_cb rx_cb)
 }
 
 void
-console_pkg_init(struct sysinit_init_ctxt *ctxt)
+console_pkg_init(void)
 {
     int rc;
 
@@ -572,5 +572,3 @@ console_pkg_init(struct sysinit_init_ctxt *ctxt)
     rc = console_init(NULL);
     SYSINIT_PANIC_ASSERT(rc == 0);
 }
-
-SYSINIT_REGISTER_INIT(console_pkg_init, 0);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/flash_map/include/flash_map/flash_map.h
----------------------------------------------------------------------
diff --git a/sys/flash_map/include/flash_map/flash_map.h b/sys/flash_map/include/flash_map/flash_map.h
index 974fa37..c0c9489 100644
--- a/sys/flash_map/include/flash_map/flash_map.h
+++ b/sys/flash_map/include/flash_map/flash_map.h
@@ -55,6 +55,12 @@ extern const struct flash_area *flash_map;
 extern int flash_map_entries;
 
 /*
+ * Initializes flash map. Memory will be referenced by flash_map code
+ * from this on.
+ */
+void flash_map_init(void);
+
+/*
  * Start using flash area.
  */
 int flash_area_open(uint8_t id, const struct flash_area **);
@@ -83,8 +89,6 @@ int flash_area_to_sectors(int idx, int *cnt, struct flash_area *ret);
 int flash_area_id_from_image_slot(int slot);
 int flash_area_id_to_image_slot(int area_id);
 
-void flash_map_init(void);
-
 #ifdef __cplusplus
 }
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/flash_map/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/flash_map/pkg.yml b/sys/flash_map/pkg.yml
index 1d26643..400ae47 100644
--- a/sys/flash_map/pkg.yml
+++ b/sys/flash_map/pkg.yml
@@ -29,3 +29,6 @@ pkg.deps:
     - sys/defs
     - sys/flash_map
     - sys/mfg
+
+pkg.init_function: flash_map_init
+pkg.init_stage: 0

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/flash_map/src/flash_map.c
----------------------------------------------------------------------
diff --git a/sys/flash_map/src/flash_map.c b/sys/flash_map/src/flash_map.c
index 9666034..b652de0 100644
--- a/sys/flash_map/src/flash_map.c
+++ b/sys/flash_map/src/flash_map.c
@@ -269,16 +269,3 @@ flash_map_init(void)
         flash_map_entries = num_areas;
     }
 }
-
-/*
- * Initializes flash map. Memory will be referenced by flash_map code
- * from this on.
- */
-static void
-flash_map_pkg_init(struct sysinit_init_ctxt *ctxt)
-{
-    flash_map_init();
-}
-
-/* Stage 0; sys/flash_map must get initialized before sys/mfg. */
-SYSINIT_REGISTER_INIT(flash_map_pkg_init, 0);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/id/include/id/id.h
----------------------------------------------------------------------
diff --git a/sys/id/include/id/id.h b/sys/id/include/id/id.h
index b3ce392..7712bcb 100644
--- a/sys/id/include/id/id.h
+++ b/sys/id/include/id/id.h
@@ -29,6 +29,11 @@ extern "C" {
  */
 #define ID_SERIAL_MAX_LEN       64
 
+/*
+ * Initialize manufacturing info storage/reporting.
+ */
+void id_init(void);
+
 #ifdef __cplusplus
 }
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/id/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/id/pkg.yml b/sys/id/pkg.yml
index 982259c..c9499dc 100644
--- a/sys/id/pkg.yml
+++ b/sys/id/pkg.yml
@@ -32,3 +32,6 @@ pkg.deps:
     - sys/config
     - sys/mfg
     - encoding/base64
+
+pkg.init_function: id_init
+pkg.init_stage: 5

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/id/src/id.c
----------------------------------------------------------------------
diff --git a/sys/id/src/id.c b/sys/id/src/id.c
index 930c850..7a964ad 100644
--- a/sys/id/src/id.c
+++ b/sys/id/src/id.c
@@ -144,11 +144,8 @@ id_read_mfghash(void)
     base64_encode(raw_hash, sizeof raw_hash, id_mfghash, 1);
 }
 
-/**
- * Initialize manufacturing info storage/reporting.
- */
 void
-id_init(struct sysinit_init_ctxt *ctxt)
+id_init(void)
 {
     int rc;
 
@@ -161,5 +158,3 @@ id_init(struct sysinit_init_ctxt *ctxt)
     /* Attempt to read the manufacturing image hash from the meta region. */
     id_read_mfghash();
 }
-
-SYSINIT_REGISTER_INIT(id_init, 5);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/log/include/log/log.h
----------------------------------------------------------------------
diff --git a/sys/log/include/log/log.h b/sys/log/include/log/log.h
index 764edb5..1411ab4 100644
--- a/sys/log/include/log/log.h
+++ b/sys/log/include/log/log.h
@@ -189,6 +189,7 @@ struct log {
 #define LOGS_NMGR_OP_LOGS_LIST    (5)
 
 /* Log system level functions (for all logs.) */
+void log_init(void);
 struct log *log_list_get_next(struct log *);
 
 /* Log functions, manipulate a single log */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/log/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/log/pkg.yml b/sys/log/pkg.yml
index a5620f7..0e0a4f0 100644
--- a/sys/log/pkg.yml
+++ b/sys/log/pkg.yml
@@ -36,3 +36,6 @@ pkg.deps.LOG_CLI:
 
 pkg.deps.LOG_NEWTMGR:
     - mgmt/mgmt
+
+pkg.init_function: log_init
+pkg.init_stage: 1

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/log/src/log.c
----------------------------------------------------------------------
diff --git a/sys/log/src/log.c b/sys/log/src/log.c
index 613f6f4..89f2741 100644
--- a/sys/log/src/log.c
+++ b/sys/log/src/log.c
@@ -46,7 +46,7 @@ struct shell_cmd g_shell_log_cmd = {
 #endif
 
 void
-log_init(struct sysinit_init_ctxt *ctxt)
+log_init(void)
 {
     int rc;
 
@@ -74,8 +74,6 @@ log_init(struct sysinit_init_ctxt *ctxt)
 #endif
 }
 
-SYSINIT_REGISTER_INIT(log_init, 1);
-
 struct log *
 log_list_get_next(struct log *log)
 {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/mfg/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/mfg/pkg.yml b/sys/mfg/pkg.yml
index 5a66fbe..4c999dc 100644
--- a/sys/mfg/pkg.yml
+++ b/sys/mfg/pkg.yml
@@ -27,3 +27,7 @@ pkg.keywords:
 pkg.deps:
     - kernel/os
     - sys/flash_map
+
+# sys/flash_map must get initialized before sys/mfg.
+pkg.init_function: mfg_init
+pkg.init_stage: 1

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/reboot/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/reboot/pkg.yml b/sys/reboot/pkg.yml
index 61ab868..ca4fcbe 100644
--- a/sys/reboot/pkg.yml
+++ b/sys/reboot/pkg.yml
@@ -35,3 +35,6 @@ pkg.deps.REBOOT_LOG_FCB:
     - fs/fcb
 pkg.req_apis:
     - console
+
+pkg.init_function: log_reboot_pkg_init
+pkg.init_stage: 2

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/reboot/src/log_reboot.c
----------------------------------------------------------------------
diff --git a/sys/reboot/src/log_reboot.c b/sys/reboot/src/log_reboot.c
index ed1127d..7a02414 100644
--- a/sys/reboot/src/log_reboot.c
+++ b/sys/reboot/src/log_reboot.c
@@ -230,7 +230,7 @@ err:
 }
 
 void
-log_reboot_pkg_init(struct sysinit_init_ctxt *ctxt)
+log_reboot_pkg_init(void)
 {
     int type;
     int rc;
@@ -251,5 +251,3 @@ log_reboot_pkg_init(struct sysinit_init_ctxt *ctxt)
     SYSINIT_PANIC_ASSERT(rc == 0);
 #endif
 }
-
-SYSINIT_REGISTER_INIT(log_reboot_pkg_init, 2);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/shell/include/shell/shell.h
----------------------------------------------------------------------
diff --git a/sys/shell/include/shell/shell.h b/sys/shell/include/shell/shell.h
index 6e18147..d5473c2 100644
--- a/sys/shell/include/shell/shell.h
+++ b/sys/shell/include/shell/shell.h
@@ -46,6 +46,7 @@ int shell_nlip_input_register(shell_nlip_input_func_t nf, void *arg);
 int shell_nlip_output(struct os_mbuf *m);
 
 void shell_evq_set(struct os_eventq *evq);
+void shell_init(void);
 
 int shell_cmd_list_lock(void);
 int shell_cmd_list_unlock(void);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/shell/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/shell/pkg.yml b/sys/shell/pkg.yml
index ad0b7c5..02d9810 100644
--- a/sys/shell/pkg.yml
+++ b/sys/shell/pkg.yml
@@ -30,3 +30,6 @@ pkg.deps:
     - util/crc
 pkg.req_apis:
     - console
+
+pkg.init_function: shell_init
+pkg.init_stage: 5

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/shell/src/shell.c
----------------------------------------------------------------------
diff --git a/sys/shell/src/shell.c b/sys/shell/src/shell.c
index 311ccd9..f11086b 100644
--- a/sys/shell/src/shell.c
+++ b/sys/shell/src/shell.c
@@ -562,7 +562,7 @@ shell_help_cmd(int argc, char **argv)
 }
 
 void
-shell_init(struct sysinit_init_ctxt *ctxt)
+shell_init(void)
 {
     /* Ensure this function only gets called by sysinit. */
     SYSINIT_ASSERT_ACTIVE();
@@ -608,5 +608,3 @@ shell_init(struct sysinit_init_ctxt *ctxt)
     os_mqueue_init(&g_shell_nlip_mq, shell_event_data_in, NULL);
     console_init(shell_console_rx_cb);
 }
-
-SYSINIT_REGISTER_INIT(shell_init, 5);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/stats/include/stats/stats.h
----------------------------------------------------------------------
diff --git a/sys/stats/include/stats/stats.h b/sys/stats/include/stats/stats.h
index 4db4846..f7bb5f8 100644
--- a/sys/stats/include/stats/stats.h
+++ b/sys/stats/include/stats/stats.h
@@ -107,6 +107,7 @@ const struct stats_name_map STATS_NAME_MAP_NAME(__sectname)[] = {
 
 #endif /* MYNEWT_VAL(STATS_NAME) */
 
+void stats_module_init(void);
 int stats_init(struct stats_hdr *shdr, uint8_t size, uint8_t cnt,
     const struct stats_name_map *map, uint8_t map_cnt);
 int stats_register(char *name, struct stats_hdr *shdr);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/stats/pkg.yml
----------------------------------------------------------------------
diff --git a/sys/stats/pkg.yml b/sys/stats/pkg.yml
index 3f5bf63..5d122dd 100644
--- a/sys/stats/pkg.yml
+++ b/sys/stats/pkg.yml
@@ -30,3 +30,6 @@ pkg.deps.STATS_CLI:
     - sys/shell
 pkg.deps.STATS_NEWTMGR:
     - mgmt/mgmt
+
+pkg.init_function: stats_module_init
+pkg.init_stage: 0

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/stats/src/stats.c
----------------------------------------------------------------------
diff --git a/sys/stats/src/stats.c b/sys/stats/src/stats.c
index 14507d4..b2009f6 100644
--- a/sys/stats/src/stats.c
+++ b/sys/stats/src/stats.c
@@ -168,7 +168,7 @@ err:
  * ASSERT's if it fails, as something is likely h0rked system wide.
  */
 void
-stats_module_init(struct sysinit_init_ctxt *ctxt)
+stats_module_init(void)
 {
     int rc;
 
@@ -196,8 +196,6 @@ stats_module_init(struct sysinit_init_ctxt *ctxt)
     SYSINIT_PANIC_ASSERT(rc == 0);
 }
 
-SYSINIT_REGISTER_INIT(stats_module_init, 0);
-
 
 /**
  * Initialize a statistics structure, pointed to by hdr.

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/sysinit/include/sysinit/sysinit.h
----------------------------------------------------------------------
diff --git a/sys/sysinit/include/sysinit/sysinit.h b/sys/sysinit/include/sysinit/sysinit.h
index 8b70c44..32839aa 100644
--- a/sys/sysinit/include/sysinit/sysinit.h
+++ b/sys/sysinit/include/sysinit/sysinit.h
@@ -23,21 +23,6 @@
 #include "syscfg/syscfg.h"
 #include "bootutil/bootutil.h"
 
-#if __APPLE__
-
-/* mach-o uses segment,section pairs. */
-#define SYSINIT_SEGMENT     "__TEXT"
-#define SYSINIT_SECTION     "sysinit"
-#define SYSINIT_SECT_STR    SYSINIT_SEGMENT "," SYSINIT_SECTION
-
-#else
-
-#define SYSINIT_SECT_STR    "sysinit"
-
-#endif
-
-#define SECT_SYSINIT        __attribute__((section(SYSINIT_SECT_STR)))
-
 #if MYNEWT_VAL(SPLIT_APPLICATION)
 #include "split/split.h"
 #endif
@@ -47,62 +32,9 @@ extern "C" {
 #endif
 
 extern uint8_t sysinit_active;
-void sysinit_init_pkgs(void);
-
-struct sysinit_init_ctxt;
-
-/* Package initialization function. */
-typedef void sysinit_init_fn(struct sysinit_init_ctxt *ctxt);
-
-struct sysinit_entry {
-    /* Initializes a package. */
-    sysinit_init_fn *init_fn;
 
-    /* Specifies when the init function gets called.  0=first, 1=next, etc. */
-    uint8_t stage;
-};
-
-struct sysinit_init_ctxt {
-    /* Corresponds to the init function currently executing. */
-    const struct sysinit_entry *entry;
-
-    /* The stage that sysinit is currently processing. */
-    uint8_t cur_stage;
-};
-
-#define SYSINIT_ENTRY_NAME(fn_name) fn_name ## _sysinit_entry
-
-/**
- * Registers a package initialization function
- *
- * @param init_cb               Pointer to the init function to register.
- * @param init_stage            Indicates when this init function gets called,
- *                                  relative to other init functions.  0=first,
- *                                  1=next, etc.
- */
-#define SYSINIT_REGISTER_INIT(init_cb, init_stage)                          \
-    const SECT_SYSINIT struct sysinit_entry SYSINIT_ENTRY_NAME(init_cb) = { \
-        .init_fn = (init_cb),                                               \
-        .stage = (init_stage),                                              \
-    }
-
-#define SYSINIT_CONCAT_3(a,b,c)  a##_##b##_##c
-#define SYSINIT_CONCAT_2(a,b) SYSINIT_CONCAT_3(sysinit_keep, a, b)
-#define SYSINIT_UNIQUE_ID(a) SYSINIT_CONCAT_2(a,__COUNTER__)
-
-/**
- * This macro addresses some linker woes involved in sim builds.  Use this
- * macro to force the specified sysinit entry to be included in the build.
- * This macro is the solution when a package does not get initialized in a sim
- * build.
- *
- * This macro is not necessary for non-sim builds, because the linker script
- * ensures that the sysinit section gets included.
- */
-#define SYSINIT_KEEP(init_cb)                       \
-    extern const SECT_SYSINIT struct sysinit_entry  \
-        SYSINIT_ENTRY_NAME(init_cb);                \
-    const void *SYSINIT_UNIQUE_ID(init_cb) = &SYSINIT_ENTRY_NAME(init_cb)
+void sysinit_start(void);
+void sysinit_end(void);
 
 typedef void sysinit_panic_fn(const char *file, int line);
 
@@ -136,31 +68,43 @@ void MYNEWT_VAL(SYSINIT_PANIC_FN)(const char *file, int line);
 #define SYSINIT_ASSERT_ACTIVE()
 #endif
 
-/**
- * In a split app, this macro records that a split app is running.  imgmgt
- * needs to know whether one is running.  In a loader or unified image, this
- * macro is a no-op.
- *
- * Note: This check has to happen here in a macro, rather than in a package's
- * initialization function.  The reason is: only the app package knows whether
- * it is running as a loader/unified or second-stage-app; other packages don't
- * have this information because they may be used both both stages.
- */
-#if MYNEWT_VAL(SPLIT_APPLICATION)
-#define SYSINIT_SPLIT_INIT() split_app_active_set(1)
+#if MYNEWT_VAL(SPLIT_LOADER)
+
+/*** System initialization for loader (first stage of split image). */
+void sysinit_loader(void);
+#define sysinit() do                                                        \
+{                                                                           \
+    sysinit_start();                                                        \
+    sysinit_loader();                                                       \
+    sysinit_end();                                                          \
+} while (0)
+
+#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. */    \
+    split_app_active_set(1);                                                \
+    sysinit_start();                                                        \
+    sysinit_app();                                                          \
+    sysinit_end();                                                          \
+} while (0)
+
 #else
-#define SYSINIT_SPLIT_INIT()
-#endif
 
-/**
- * Initializes all packages in the system.
- */
+/*** System initialization for a unified image (no split). */
+void sysinit_app(void);
 #define sysinit() do                                                        \
 {                                                                           \
-    SYSINIT_SPLIT_INIT();                                                   \
-    sysinit_init_pkgs();                                                    \
+    sysinit_start();                                                        \
+    sysinit_app();                                                          \
+    sysinit_end();                                                          \
 } while (0)
 
+#endif
+
 #ifdef __cplusplus
 }
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/sysinit/src/sysinit.c
----------------------------------------------------------------------
diff --git a/sys/sysinit/src/sysinit.c b/sys/sysinit/src/sysinit.c
index beef089..e8430d0 100644
--- a/sys/sysinit/src/sysinit.c
+++ b/sys/sysinit/src/sysinit.c
@@ -17,45 +17,18 @@
  * under the License.
  */
 
-#include <limits.h>
 #include "sysinit/sysinit.h"
-#include "sysinit_priv.h"
 
 uint8_t sysinit_active;
 
 void
-sysinit_init_pkgs(void)
+sysinit_start(void)
 {
-    const struct sysinit_entry *entry;
-    const struct sysinit_entry *start;
-    const struct sysinit_entry *end;
-    struct sysinit_init_ctxt ctxt;
-    int next_stage;
-    int cur_stage;
-
     sysinit_active = 1;
+}
 
-    /* Determine the start and end of the sysinit linker section. */
-    sysinit_section_bounds(&start, &end);
-
-    cur_stage = 0;
-    do {
-        /* Assume this is the final stage. */
-        next_stage = INT_MAX;
-
-        /* Execute all init functions corresponding to the current stage. */
-        for (entry = start; entry != end; entry++) {
-            if (cur_stage == entry->stage) {
-                ctxt.entry = entry;
-                ctxt.cur_stage = cur_stage;
-                entry->init_fn(&ctxt);
-            } else if (cur_stage < entry->stage && next_stage > entry->stage) {
-                /* Found a stage to execute next. */
-                next_stage = entry->stage;
-            }
-        }
-        cur_stage = next_stage;
-    } while (cur_stage != INT_MAX);
-
+void
+sysinit_end(void)
+{
     sysinit_active = 0;
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/sysinit/src/sysinit_priv.h
----------------------------------------------------------------------
diff --git a/sys/sysinit/src/sysinit_priv.h b/sys/sysinit/src/sysinit_priv.h
deleted file mode 100644
index 3ff2b40..0000000
--- a/sys/sysinit/src/sysinit_priv.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef H_SYSINIT_PRIV_
-#define H_SYSINIT_PRIV_
-
-struct sysinit_entry;
-
-void sysinit_section_bounds(const struct sysinit_entry **out_start,
-                            const struct sysinit_entry **out_end);
-
-#endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/sys/sysinit/src/sysinit_section.c
----------------------------------------------------------------------
diff --git a/sys/sysinit/src/sysinit_section.c b/sys/sysinit/src/sysinit_section.c
deleted file mode 100644
index ae88caa..0000000
--- a/sys/sysinit/src/sysinit_section.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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 <stddef.h>
-#include <assert.h>
-#include "sysinit_priv.h"
-
-#if __APPLE__
-
-#include <mach-o/getsect.h>
-
-#elif BSP_native && __GNUC__
-
-/* Non-Apple sim (Linux).  gcc automatically creates these symbols at the start
- * and end of each section.
- */
-extern const struct sysinit_entry __start_sysinit;
-extern const struct sysinit_entry __stop_sysinit;
-
-#else
-
-/* These symbols are specified in the linker script. */
-extern const struct sysinit_entry __sysinit_start__;
-extern const struct sysinit_entry __sysinit_end__;
-
-#endif
-
-void
-sysinit_section_bounds(const struct sysinit_entry **out_start,
-                       const struct sysinit_entry **out_end)
-{
-#if __APPLE__
-    unsigned long secsize;
-    char *secstart;
-
-    secstart = getsectdata("__TEXT", "sysinit", &secsize);
-    assert(secstart != NULL);
-
-    *out_start = (void *)secstart;
-    *out_end = (void *)(secstart + secsize);
-#elif BSP_native
-    *out_start = &__start_sysinit;
-    *out_end = &__stop_sysinit;
-#else
-    *out_start = &__sysinit_start__;
-    *out_end = &__sysinit_end__;
-#endif
-}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/test/crash_test/include/crash_test/crash_test.h
----------------------------------------------------------------------
diff --git a/test/crash_test/include/crash_test/crash_test.h b/test/crash_test/include/crash_test/crash_test.h
new file mode 100644
index 0000000..5613d34
--- /dev/null
+++ b/test/crash_test/include/crash_test/crash_test.h
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+#ifndef __CRASH_TEST_H__
+#define __CRASH_TEST_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Adds the crash commands to your shell/newtmgr.
+ */
+void crash_test_init(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __CRASH_TEST_H__ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/test/crash_test/pkg.yml
----------------------------------------------------------------------
diff --git a/test/crash_test/pkg.yml b/test/crash_test/pkg.yml
index 55feb15..8d406ed 100644
--- a/test/crash_test/pkg.yml
+++ b/test/crash_test/pkg.yml
@@ -31,3 +31,6 @@ pkg.deps.CRASH_TEST_NEWTMGR:
 
 pkg.deps.CRASH_TEST_NEWTMGR:
     - encoding/json
+
+pkg.init_function: crash_test_init
+pkg.init_stage: 5

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/test/crash_test/src/crash_cli.c
----------------------------------------------------------------------
diff --git a/test/crash_test/src/crash_cli.c b/test/crash_test/src/crash_cli.c
index 168b573..e04c8a2 100644
--- a/test/crash_test/src/crash_cli.c
+++ b/test/crash_test/src/crash_cli.c
@@ -27,6 +27,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "crash_test/crash_test.h"
 #include "crash_test_priv.h"
 
 static int crash_cli_cmd(int argc, char **argv);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/test/crash_test/src/crash_nmgr.c
----------------------------------------------------------------------
diff --git a/test/crash_test/src/crash_nmgr.c b/test/crash_test/src/crash_nmgr.c
index cd888de..7ffd969 100644
--- a/test/crash_test/src/crash_nmgr.c
+++ b/test/crash_test/src/crash_nmgr.c
@@ -27,6 +27,7 @@
 #include "cborattr/cborattr.h"
 #include "console/console.h"
 
+#include "crash_test/crash_test.h"
 #include "crash_test_priv.h"
 
 static int crash_test_nmgr_write(struct mgmt_cbuf *);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/test/crash_test/src/crash_test.c
----------------------------------------------------------------------
diff --git a/test/crash_test/src/crash_test.c b/test/crash_test/src/crash_test.c
index 8d064b1..3b469b0 100644
--- a/test/crash_test/src/crash_test.c
+++ b/test/crash_test/src/crash_test.c
@@ -26,6 +26,7 @@
 #include "os/os.h"
 #include "console/console.h"
 
+#include "crash_test/crash_test.h"
 #include "crash_test_priv.h"
 
 #if MYNEWT_VAL(CRASH_TEST_CLI)
@@ -63,7 +64,7 @@ crash_device(char *how)
 }
 
 void
-crash_test_init(struct sysinit_init_ctxt *ctxt)
+crash_test_init(void)
 {
     /* Ensure this function only gets called by sysinit. */
     SYSINIT_ASSERT_ACTIVE();
@@ -75,5 +76,3 @@ crash_test_init(struct sysinit_init_ctxt *ctxt)
     mgmt_group_register(&crash_test_nmgr_group);
 #endif
 }
-
-SYSINIT_REGISTER_INIT(crash_test_init, 5);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/test/runtest/pkg.yml
----------------------------------------------------------------------
diff --git a/test/runtest/pkg.yml b/test/runtest/pkg.yml
index 0b1685f..e64f12a 100644
--- a/test/runtest/pkg.yml
+++ b/test/runtest/pkg.yml
@@ -31,3 +31,6 @@ pkg.deps.RUNTEST_NEWTMGR:
 
 pkg.deps.RUNTEST_NEWTMGR:
     - encoding/json
+
+pkg.init_function: runtest_init
+pkg.init_stage: 5

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/test/runtest/src/runtest.c
----------------------------------------------------------------------
diff --git a/test/runtest/src/runtest.c b/test/runtest/src/runtest.c
index 00c9961..3a68185 100644
--- a/test/runtest/src/runtest.c
+++ b/test/runtest/src/runtest.c
@@ -45,7 +45,7 @@ extern int run_nmgr_register_group();
  * Package init routine to register newtmgr "run" commands
  */
 void
-runtest_init(struct sysinit_init_ctxt *ctxt)
+runtest_init(void)
 {
     int rc;
 
@@ -61,5 +61,3 @@ runtest_init(struct sysinit_init_ctxt *ctxt)
     SYSINIT_PANIC_ASSERT(rc == 0);
 #endif
 }
-
-SYSINIT_REGISTER_INIT(runtest_init, 5);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c870a0fe/util/mem/src/mem.c
----------------------------------------------------------------------
diff --git a/util/mem/src/mem.c b/util/mem/src/mem.c
index 1e107b1..340e60e 100644
--- a/util/mem/src/mem.c
+++ b/util/mem/src/mem.c
@@ -243,4 +243,3 @@ err:
     os_mbuf_free_chain(frag);
     return NULL;
 }
-