From: Michael McMaster Date: Mon, 4 May 2015 13:51:11 +0000 (+1000) Subject: Hardcode a default config, which is written to flash on first boot. X-Git-Tag: v4.02.04 X-Git-Url: http://git.codesrc.com/gitweb.cgi?a=commitdiff_plain;h=e5ee8860531728d2042fcd349b4550d538e0baa2;p=SCSI2SD-V6.git Hardcode a default config, which is written to flash on first boot. The bootloader fails checksums if the config is defined within a code section, then later modified. Hacking the .hex file isn't possible either because PSoC Programmer checks that the non-bootloadable part of the flash is empty. --- diff --git a/software/SCSI2SD/src/config.c b/software/SCSI2SD/src/config.c index 26f0fe8b..bb31e0d2 100755 --- a/software/SCSI2SD/src/config.c +++ b/software/SCSI2SD/src/config.c @@ -34,6 +34,17 @@ static const uint16_t FIRMWARE_VERSION = 0x0424; +// 1 flash row +static const uint8_t DEFAULT_CONFIG[256] = +{ + 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x3F, 0x00, + 0x00, 0x02, 0x3F, 0x00, 0xFF, 0x00, 0x20, 0x63, 0x6F, 0x64, 0x65, 0x73, + 0x72, 0x63, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x53, + 0x43, 0x53, 0x49, 0x32, 0x53, 0x44, 0x20, 0x31, 0x2E, 0x30, 0x31, 0x32, + 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, + 0x37, 0x38, 0x00, 0x00 +}; + enum USB_ENDPOINTS { USB_EP_OUT = 1, @@ -61,6 +72,24 @@ void configInit() USBFS_Start(0, USBFS_5V_OPERATION); usbInEpState = usbDebugEpState = USB_IDLE; usbReady = 0; // We don't know if host is connected yet. + + int invalid = 1; + uint8_t* rawConfig = getConfigByIndex(0); + int i; + for (i = 0; i < 64; ++i) + { + if (rawConfig[i]) + { + invalid = 0; + break; + } + } + if (invalid) + { + // Save a default config. + CySetTemp(); + CyWriteRowData(SCSI_CONFIG_ARRAY, SCSI_CONFIG_0_ROW, DEFAULT_CONFIG); + } } static void