summaryrefslogtreecommitdiffstatshomepage
path: root/cc3200/bootmgr
diff options
context:
space:
mode:
authorDaniel Campora <daniel@wipy.io>2015-08-05 17:05:41 +0200
committerDaniel Campora <daniel@wipy.io>2015-08-09 19:22:19 +0200
commit31f6a6fa70aa9140a6587a1e3f23bb604e5abbca (patch)
tree651796d59756e4e67dec24840179b87d1f978f00 /cc3200/bootmgr
parente54a4f1f4856f6c33a2cea720ab2f2e4fe70f586 (diff)
downloadmicropython-31f6a6fa70aa9140a6587a1e3f23bb604e5abbca.tar.gz
micropython-31f6a6fa70aa9140a6587a1e3f23bb604e5abbca.zip
cc3200: Enable bootloader safe boot on latest firmware.
The first safe boot level executes the latest firmware but skips 'main.py' and 'boot.py'.
Diffstat (limited to 'cc3200/bootmgr')
-rw-r--r--cc3200/bootmgr/main.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/cc3200/bootmgr/main.c b/cc3200/bootmgr/main.c
index 95df47c297..32210e6de9 100644
--- a/cc3200/bootmgr/main.c
+++ b/cc3200/bootmgr/main.c
@@ -64,14 +64,16 @@
#define BOOTMGR_HASH_SIZE 32
#define BOOTMGR_BUFF_SIZE 512
-#define BOOTMGR_WAIT_SAFE_MODE_0_MS 3000
-#define BOOTMGR_WAIT_SAFE_MODE_0_BLINK_MS 500
+#define BOOTMGR_WAIT_SAFE_MODE_0_MS 500
#define BOOTMGR_WAIT_SAFE_MODE_1_MS 3000
#define BOOTMGR_WAIT_SAFE_MODE_1_BLINK_MS 250
-#define BOOTMGR_WAIT_SAFE_MODE_2_MS 1500
-#define BOOTMGR_WAIT_SAFE_MODE_2_BLINK_MS 100
+#define BOOTMGR_WAIT_SAFE_MODE_2_MS 3000
+#define BOOTMGR_WAIT_SAFE_MODE_2_BLINK_MS 250
+
+#define BOOTMGR_WAIT_SAFE_MODE_3_MS 1500
+#define BOOTMGR_WAIT_SAFE_MODE_3_BLINK_MS 100
//*****************************************************************************
// Exported functions declarations
@@ -85,6 +87,7 @@ static void bootmgr_board_init (void);
static bool bootmgr_verify (_u8 *image);
static void bootmgr_load_and_execute (_u8 *image);
static bool wait_while_blinking (uint32_t wait_time, uint32_t period, bool force_wait);
+static bool safe_boot_request_start (uint32_t wait_time);
static void wait_for_safe_boot (sBootInfo_t *psBootInfo);
static void bootmgr_image_loader (sBootInfo_t *psBootInfo);
@@ -260,24 +263,33 @@ static bool wait_while_blinking (uint32_t wait_time, uint32_t period, bool force
return MAP_GPIOPinRead(MICROPY_SAFE_BOOT_PORT, MICROPY_SAFE_BOOT_PORT_PIN) ? true : false;
}
+static bool safe_boot_request_start (uint32_t wait_time) {
+ if (MAP_GPIOPinRead(MICROPY_SAFE_BOOT_PORT, MICROPY_SAFE_BOOT_PORT_PIN)) {
+ UtilsDelay(UTILS_DELAY_US_TO_COUNT(wait_time * 1000));
+ }
+ return MAP_GPIOPinRead(MICROPY_SAFE_BOOT_PORT, MICROPY_SAFE_BOOT_PORT_PIN) ? true : false;
+}
+
//*****************************************************************************
//! Check for the safe mode pin
//*****************************************************************************
static void wait_for_safe_boot (sBootInfo_t *psBootInfo) {
- if (wait_while_blinking(BOOTMGR_WAIT_SAFE_MODE_0_MS, BOOTMGR_WAIT_SAFE_MODE_0_BLINK_MS, false)) {
- // go back one step in time
- psBootInfo->ActiveImg = psBootInfo->PrevImg;
+ if (safe_boot_request_start(BOOTMGR_WAIT_SAFE_MODE_0_MS)) {
if (wait_while_blinking(BOOTMGR_WAIT_SAFE_MODE_1_MS, BOOTMGR_WAIT_SAFE_MODE_1_BLINK_MS, false)) {
- // go back directly to the factory image
- psBootInfo->ActiveImg = IMG_ACT_FACTORY;
- wait_while_blinking(BOOTMGR_WAIT_SAFE_MODE_2_MS, BOOTMGR_WAIT_SAFE_MODE_2_BLINK_MS, true);
+ // go back one step in time
+ psBootInfo->ActiveImg = psBootInfo->PrevImg;
+ if (wait_while_blinking(BOOTMGR_WAIT_SAFE_MODE_2_MS, BOOTMGR_WAIT_SAFE_MODE_2_BLINK_MS, false)) {
+ // go back directly to the factory image
+ psBootInfo->ActiveImg = IMG_ACT_FACTORY;
+ wait_while_blinking(BOOTMGR_WAIT_SAFE_MODE_3_MS, BOOTMGR_WAIT_SAFE_MODE_3_BLINK_MS, true);
+ }
}
// turn off the system led
MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, 0);
// request a safe boot to the application
PRCMRequestSafeBoot();
}
- // uninit the safe boot pin
+ // deinit the safe boot pin
mperror_deinit_sfe_pin();
}