From 7da2fdc3cdd422d0cba60b40146aba07881bdc97 Mon Sep 17 00:00:00 2001 From: Daniel Campora Date: Sun, 9 Aug 2015 19:17:48 +0200 Subject: [PATCH] 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. --- cc3200/bootmgr/main.c | 13 +++++++++---- cc3200/mptask.c | 14 +++++++++----- 2 files changed, 18 insertions(+), 9 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); -#ifndef DEBUG - bool safeboot = PRCMGetSpecialBit(PRCM_SAFE_BOOT_BIT); -#endif - + bool safeboot = false; mptask_pre_init(); +#ifndef DEBUG + safeboot = PRCMGetSpecialBit(PRCM_SAFE_BOOT_BIT); +#endif + 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) {