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.
This commit is contained in:
Michael McMaster 2015-05-04 23:51:11 +10:00
parent 84112d50dc
commit e309282563

View File

@ -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