diff options
author | Daniel Campora <daniel@wipy.io> | 2015-08-09 19:17:48 +0200 |
---|---|---|
committer | Daniel Campora <daniel@wipy.io> | 2015-08-09 22:16:45 +0200 |
commit | 7da2fdc3cdd422d0cba60b40146aba07881bdc97 (patch) | |
tree | c3f9a0caa791ed05ad528dba71438fc7949120c9 | |
parent | 2673374d18c529800a4c89dc0a9d66c5b9dafb54 (diff) | |
download | micropython-7da2fdc3cdd422d0cba60b40146aba07881bdc97.tar.gz micropython-7da2fdc3cdd422d0cba60b40146aba07881bdc97.zip |
cc3200: On the first boot, always make AP ssid='wipy-wlan'.
On the first boot don't add the MAC address, this is to speed up
factory testing.
-rw-r--r-- | cc3200/bootmgr/main.c | 13 | ||||
-rw-r--r-- | cc3200/mptask.c | 12 |
2 files changed, 17 insertions, 8 deletions
diff --git a/cc3200/bootmgr/main.c b/cc3200/bootmgr/main.c index ecf6de99b4..0115772fd6 100644 --- a/cc3200/bootmgr/main.c +++ b/cc3200/bootmgr/main.c @@ -157,6 +157,12 @@ static void bootmgr_board_init(void) { // mandatory MCU initialization PRCMCC3200MCUInit(); + // clear all the special bits, since we can't trust their content after reset + PRCMClearSpecialBit(PRCM_SAFE_BOOT_BIT); + PRCMClearSpecialBit(PRCM_WDT_RESET_BIT); + PRCMClearSpecialBit(PRCM_FIRST_BOOT_BIT); + + // check the reset after clearing the special bits mperror_bootloader_check_reset_cause(); #if MICROPY_HW_ANTENNA_DIVERSITY @@ -169,9 +175,6 @@ static void bootmgr_board_init(void) { // init the system led and the system switch mperror_init0(); - - // clear the safe boot flag, since we can't trust its content after reset - PRCMClearSpecialBit(PRCM_SAFE_BOOT_BIT); } //***************************************************************************** @@ -373,7 +376,7 @@ int main (void) { } sl_FsClose(fhandle, 0, 0, 0); } - // boot info file not present (or read failed) + // boot info file not present, it means that this is the first boot after being programmed if (!bootapp) { // create a new boot info file _u32 BootInfoCreateFlag = _FS_FILE_OPEN_FLAG_COMMIT | _FS_FILE_PUBLIC_WRITE | _FS_FILE_PUBLIC_READ; @@ -385,6 +388,8 @@ int main (void) { } sl_FsClose(fhandle, 0, 0, 0); } + // signal the first boot to the application + PRCMSetSpecialBit(PRCM_FIRST_BOOT_BIT); } if (bootapp) { diff --git a/cc3200/mptask.c b/cc3200/mptask.c index 6d66c90742..3a62c46238 100644 --- a/cc3200/mptask.c +++ b/cc3200/mptask.c @@ -106,12 +106,13 @@ void TASK_Micropython (void *pvParameters) { uint32_t sp = gc_helper_get_sp(); gc_collect_init (sp); + bool safeboot = false; + mptask_pre_init(); + #ifndef DEBUG - bool safeboot = PRCMGetSpecialBit(PRCM_SAFE_BOOT_BIT); + safeboot = PRCMGetSpecialBit(PRCM_SAFE_BOOT_BIT); #endif - mptask_pre_init(); - soft_reset: // GC init @@ -372,9 +373,12 @@ STATIC void mptask_init_sflash_filesystem (void) { } STATIC void mptask_enter_ap_mode (void) { + // append the mac only if it's not the first boot + bool append_mac = !PRCMGetSpecialBit(PRCM_FIRST_BOOT_BIT); + // enable simplelink in ap mode (use the MAC address to make the ssid unique) wlan_sl_enable (ROLE_AP, MICROPY_PORT_WLAN_AP_SSID, strlen(MICROPY_PORT_WLAN_AP_SSID), MICROPY_PORT_WLAN_AP_SECURITY, - MICROPY_PORT_WLAN_AP_KEY, strlen(MICROPY_PORT_WLAN_AP_KEY), MICROPY_PORT_WLAN_AP_CHANNEL, true); + MICROPY_PORT_WLAN_AP_KEY, strlen(MICROPY_PORT_WLAN_AP_KEY), MICROPY_PORT_WLAN_AP_CHANNEL, append_mac); } STATIC void mptask_create_main_py (void) { |