From 6f218d74725e38e71aeed27250d8c67dd83401d8 Mon Sep 17 00:00:00 2001
From: Daniel Campora <daniel@wipy.io>
Date: Wed, 29 Apr 2015 16:01:51 +0200
Subject: [PATCH] cc3200: Move wlan_init0() to the boot section.

This one creates a semaphore, therefore it must be executed only
after a hard reset (or when coming out of hibernation).
---
 cc3200/mods/modwlan.c | 1 +
 cc3200/mptask.c       | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/cc3200/mods/modwlan.c b/cc3200/mods/modwlan.c
index 95c418da4..dd76bed37 100644
--- a/cc3200/mods/modwlan.c
+++ b/cc3200/mods/modwlan.c
@@ -379,6 +379,7 @@ void SimpleLinkSockEventHandler(SlSockEvent_t *pSock) {
 // SimpleLink Asynchronous Event Handlers -- End
 //*****************************************************************************
 
+__attribute__ ((section (".boot")))
 void wlan_init0 (void) {
     // create the wlan lock
     ASSERT(OSI_OK == sl_LockObjCreate(&wlan_LockObj, "WlanLock"));
diff --git a/cc3200/mptask.c b/cc3200/mptask.c
index d9c0ed8f7..6d3ef825d 100644
--- a/cc3200/mptask.c
+++ b/cc3200/mptask.c
@@ -126,7 +126,6 @@ soft_reset:
     pin_init0();
     readline_init0();
     mod_network_init0();
-    wlan_init0();
 #if MICROPY_HW_ENABLE_RNG
     rng_init0();
 #endif
@@ -273,6 +272,9 @@ STATIC void mptask_pre_init (void) {
     // this one allocates memory for the nvic vault
     pybsleep_pre_init();
 
+    // this one allocates mameory for the WLAN semaphore
+    wlan_init0();
+
 #if MICROPY_HW_HAS_SDCARD
     pybsd_init0();
 #endif
-- 
GitLab