From 4c13a829ffa94e40c8f0b7c997c71fa87c63aab1 Mon Sep 17 00:00:00 2001 From: Kristian Sloth Lauszus Date: Mon, 15 May 2017 00:49:13 +0200 Subject: [PATCH] Blink the green LED when the new firmware has been programmed --- boot_usb_msc.c | 14 ++++++++------ ramdisk.c | 4 ++-- ramdisk.h | 2 ++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/boot_usb_msc.c b/boot_usb_msc.c index 83642f1..7622e56 100644 --- a/boot_usb_msc.c +++ b/boot_usb_msc.c @@ -179,12 +179,14 @@ int main(void) UARTprintf("Bootloader started\n\n"); #endif - ROM_GPIOPinTypeGPIOOutput(LED_GPIO_BASE, LED_BLUE); + ROM_GPIOPinTypeGPIOOutput(LED_GPIO_BASE, LED_GREEN | LED_BLUE); while(1) { - // Blink the blue LED so the user knows we're in a bootloader mode - ROM_GPIOPinWrite(LED_GPIO_BASE, LED_BLUE, LED_BLUE); - ROM_SysCtlDelay(ROM_SysCtlClockGet() / 4 / 2); - ROM_GPIOPinWrite(LED_GPIO_BASE, LED_BLUE, 0); - ROM_SysCtlDelay(ROM_SysCtlClockGet() / 4 / 2); + // Blink the blue LED so the user knows we are in bootloader mode + // The green LED will blink when the new firmware has been programmed + const uint32_t led = newFirmwareStartSet ? LED_GREEN : LED_BLUE; // TODO: Use different flag + ROM_GPIOPinWrite(LED_GPIO_BASE, LED_GREEN | LED_BLUE, led); + ROM_SysCtlDelay(ROM_SysCtlClockGet() / 4 / 2); + ROM_GPIOPinWrite(LED_GPIO_BASE, LED_GREEN | LED_BLUE, 0); + ROM_SysCtlDelay(ROM_SysCtlClockGet() / 4 / 2); } } diff --git a/ramdisk.c b/ramdisk.c index c32c8e9..14663c9 100644 --- a/ramdisk.c +++ b/ramdisk.c @@ -56,7 +56,7 @@ #define FIRMWARE_START_SECTOR (DATA_REGION_SECTOR + (firmware_start_cluster - 2) * SECTORS_PER_CLUSTER) int massStorageDrive = 0; -int newFirmwareStartSet = 0; +bool newFirmwareStartSet = false; unsigned long firmware_start_cluster = FIRMWARE_BIN_CLUSTER; unsigned char bootSector[] = { @@ -306,7 +306,7 @@ unsigned long massStorageWrite(void *drive, unsigned char *data, unsigned long b else if (blockNumber >= FIRMWARE_START_SECTOR) { if (isFirmwareStart(data)) { // TODO: Reset flag after when the firmware has been read // the host tried to write actual data to the data region, we assume this is the new firmware - newFirmwareStartSet = 1; + newFirmwareStartSet = true; firmware_start_cluster = (blockNumber - DATA_REGION_SECTOR) / SECTORS_PER_CLUSTER + 2; #ifdef DEBUGUART UARTprintf("New firmware start\n"); diff --git a/ramdisk.h b/ramdisk.h index 61d2d9a..4124763 100644 --- a/ramdisk.h +++ b/ramdisk.h @@ -31,4 +31,6 @@ extern unsigned long massStorageRead(void *drive, unsigned char *data, unsigned extern unsigned long massStorageWrite(void *drive, unsigned char *data, unsigned long blockNumber, unsigned long numberOfBlocks); extern unsigned long massStorageNumBlocks(void *drive); +extern bool newFirmwareStartSet; + #endif