Skip to content

Commit 7da2fdc

Browse files
author
Daniel Campora
committed
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.
1 parent 2673374 commit 7da2fdc

2 files changed

Lines changed: 17 additions & 8 deletions

File tree

cc3200/bootmgr/main.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ static void bootmgr_board_init(void) {
157157
// mandatory MCU initialization
158158
PRCMCC3200MCUInit();
159159

160+
// clear all the special bits, since we can't trust their content after reset
161+
PRCMClearSpecialBit(PRCM_SAFE_BOOT_BIT);
162+
PRCMClearSpecialBit(PRCM_WDT_RESET_BIT);
163+
PRCMClearSpecialBit(PRCM_FIRST_BOOT_BIT);
164+
165+
// check the reset after clearing the special bits
160166
mperror_bootloader_check_reset_cause();
161167

162168
#if MICROPY_HW_ANTENNA_DIVERSITY
@@ -169,9 +175,6 @@ static void bootmgr_board_init(void) {
169175

170176
// init the system led and the system switch
171177
mperror_init0();
172-
173-
// clear the safe boot flag, since we can't trust its content after reset
174-
PRCMClearSpecialBit(PRCM_SAFE_BOOT_BIT);
175178
}
176179

177180
//*****************************************************************************
@@ -373,7 +376,7 @@ int main (void) {
373376
}
374377
sl_FsClose(fhandle, 0, 0, 0);
375378
}
376-
// boot info file not present (or read failed)
379+
// boot info file not present, it means that this is the first boot after being programmed
377380
if (!bootapp) {
378381
// create a new boot info file
379382
_u32 BootInfoCreateFlag = _FS_FILE_OPEN_FLAG_COMMIT | _FS_FILE_PUBLIC_WRITE | _FS_FILE_PUBLIC_READ;
@@ -385,6 +388,8 @@ int main (void) {
385388
}
386389
sl_FsClose(fhandle, 0, 0, 0);
387390
}
391+
// signal the first boot to the application
392+
PRCMSetSpecialBit(PRCM_FIRST_BOOT_BIT);
388393
}
389394

390395
if (bootapp) {

cc3200/mptask.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,13 @@ void TASK_Micropython (void *pvParameters) {
106106
uint32_t sp = gc_helper_get_sp();
107107
gc_collect_init (sp);
108108

109+
bool safeboot = false;
110+
mptask_pre_init();
111+
109112
#ifndef DEBUG
110-
bool safeboot = PRCMGetSpecialBit(PRCM_SAFE_BOOT_BIT);
113+
safeboot = PRCMGetSpecialBit(PRCM_SAFE_BOOT_BIT);
111114
#endif
112115

113-
mptask_pre_init();
114-
115116
soft_reset:
116117

117118
// GC init
@@ -372,9 +373,12 @@ STATIC void mptask_init_sflash_filesystem (void) {
372373
}
373374

374375
STATIC void mptask_enter_ap_mode (void) {
376+
// append the mac only if it's not the first boot
377+
bool append_mac = !PRCMGetSpecialBit(PRCM_FIRST_BOOT_BIT);
378+
375379
// enable simplelink in ap mode (use the MAC address to make the ssid unique)
376380
wlan_sl_enable (ROLE_AP, MICROPY_PORT_WLAN_AP_SSID, strlen(MICROPY_PORT_WLAN_AP_SSID), MICROPY_PORT_WLAN_AP_SECURITY,
377-
MICROPY_PORT_WLAN_AP_KEY, strlen(MICROPY_PORT_WLAN_AP_KEY), MICROPY_PORT_WLAN_AP_CHANNEL, true);
381+
MICROPY_PORT_WLAN_AP_KEY, strlen(MICROPY_PORT_WLAN_AP_KEY), MICROPY_PORT_WLAN_AP_CHANNEL, append_mac);
378382
}
379383

380384
STATIC void mptask_create_main_py (void) {

0 commit comments

Comments
 (0)