New bootrom

+ Add common area at end of RAM to communicate between main os and bootrom
+ Lower stack end to make room for common area
+ Implement CMD_DEVICE_INFO in both OS and bootrom to give information about the current state and supported features
+ Allow hands-free firmware update: When CMD_START_FLASH is received over USB in OS mode, the device will reset and enter the bootrom
  Pressing the button in hands-free update mode takes precedence: releasing the button will immediately abort firmware update and 
  perform a reset. Do not press the button.
+ Require each flash sequence to be preceded by a CMD_START_FLASH to set up the boundaries for the following flash sequence
  Not compatible with linux flasher before SVN revision 200
  Currently no compatible flasher for Windows. WINDOWS USERS: DO NOT UPDATE YOUR BOOTROM YET
+ Protect bootrom flash area unless magic unlock sequence is given in CMD_START_FLASH
This commit is contained in:
henryk@ploetzli.ch 2009-09-01 14:44:38 +00:00
commit 8fcbf652da
8 changed files with 202 additions and 49 deletions

View file

@ -13,7 +13,6 @@
#include "LCD.h"
#endif
//=============================================================================
// A buffer where we can queue things up to be sent through the FPGA, for
// any purpose (fake tag, as reader, whatever). We go MSB first, since that
@ -23,6 +22,7 @@
BYTE ToSend[256];
int ToSendMax;
static int ToSendBit;
struct common_area common_area __attribute__((section(".commonarea")));
void BufferClear(void)
{
@ -669,7 +669,23 @@ void UsbPacketReceived(BYTE *packet, int len)
// We're going to reset, and the bootrom will take control.
}
break;
case CMD_START_FLASH:
if(common_area.flags.bootrom_present) {
common_area.command = COMMON_AREA_COMMAND_ENTER_FLASH_MODE;
}
USB_D_PLUS_PULLUP_OFF();
RSTC_CONTROL = RST_CONTROL_KEY | RST_CONTROL_PROCESSOR_RESET;
for(;;);
break;
case CMD_DEVICE_INFO: {
UsbCommand c;
c.cmd = CMD_DEVICE_INFO;
c.ext1 = DEVICE_INFO_FLAG_OSIMAGE_PRESENT | DEVICE_INFO_FLAG_CURRENT_MODE_OS;
if(common_area.flags.bootrom_present) c.ext1 |= DEVICE_INFO_FLAG_BOOTROM_PRESENT;
UsbSendPacket((BYTE*)&c, sizeof(c));
}
break;
default:
DbpString("unknown command");
break;
@ -680,6 +696,14 @@ void AppMain(void)
{
memset(BigBuf,0,sizeof(BigBuf));
SpinDelay(100);
if(common_area.magic != COMMON_AREA_MAGIC || common_area.version != 1) {
/* Initialize common area */
memset(&common_area, 0, sizeof(common_area));
common_area.magic = COMMON_AREA_MAGIC;
common_area.version = 1;
}
common_area.flags.osimage_present = 1;
LED_D_OFF();
LED_C_OFF();

View file

@ -22,4 +22,8 @@ SECTIONS
__bss_start__ = .;
.bss : { *(.bss) } >ram
__bss_end__ = .;
.commonarea (NOLOAD) : {
*(.commonarea)
} >commonarea
}