Updated Bootloader 2.0 to remove RAM upload option. RAM upload now returns DFU error errWRITE ( 0x03) and displays the initial message 'Bootloader 2.0 ERROR. Upload to RAM is not supported'. Ram upload code has been commented out, definitions have been added for DFU alt strings to make them easier to change, not javascript util has been added at the bottom usb_description.c which can be used to generate modified DFU ALT ID descriptor text if needed
This commit is contained in:
parent
0631786008
commit
10861ba517
|
@ -113,7 +113,7 @@ ELFSIZE = $(SIZE) -A $(TARGET).elf
|
|||
|
||||
# go!
|
||||
all: begin gccversion build sizeafter finished end
|
||||
maple-mini: begin gccversion build_maple-mini sizeafter finished end
|
||||
maple-mini: begin gccversion build_maple-mini sizeafter finished copy_maple_mini end
|
||||
maple-rev3: begin gccversion build_maple-rev3 sizeafter finished end
|
||||
|
||||
build: elf bin lss sym
|
||||
|
@ -121,6 +121,12 @@ build: elf bin lss sym
|
|||
|
||||
build_maple-mini: TARGETFLAGS= -DTARGET_MAPLE_MINI
|
||||
build_maple-mini: elf bin lss sym
|
||||
copy_maple_mini:
|
||||
@echo
|
||||
@echo "Copying to binaries folder"
|
||||
@echo
|
||||
cp $(TARGET).bin binaries/maple_mini_boot20.bin
|
||||
@echo
|
||||
|
||||
build_maple-rev3: TARGETFLAGS= -DTARGET_MAPLE_REV3
|
||||
build_maple-rev3: elf bin lss sym
|
||||
|
|
Binary file not shown.
|
@ -85,10 +85,13 @@ bool dfuUpdateByRequest(void) {
|
|||
dfuAppStatus.bState = dfuDNLOAD_SYNC;
|
||||
switch(pInformation->Current_AlternateSetting)
|
||||
{
|
||||
/*
|
||||
Roger Clark. removed upload to RAM option
|
||||
case 0:
|
||||
userAppAddr = USER_CODE_RAM;
|
||||
userUploadType = DFU_UPLOAD_RAM;
|
||||
break;
|
||||
*/
|
||||
case 1:
|
||||
userAppAddr = USER_CODE_FLASH0X8005000;
|
||||
userUploadType = DFU_UPLOAD_FLASH_0X8005000;
|
||||
|
@ -107,8 +110,9 @@ bool dfuUpdateByRequest(void) {
|
|||
flashUnlock();
|
||||
break;
|
||||
default:
|
||||
userAppAddr = USER_CODE_RAM;
|
||||
userUploadType = DFU_UPLOAD_RAM;
|
||||
// Roger Clark. Report error
|
||||
dfuAppStatus.bState = dfuERROR;
|
||||
dfuAppStatus.bStatus = errWRITE;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
@ -125,9 +129,11 @@ bool dfuUpdateByRequest(void) {
|
|||
userFirmwareLen = uploadBlockLen * pInformation->USBwValue;
|
||||
switch(pInformation->Current_AlternateSetting)
|
||||
{
|
||||
/*
|
||||
case 0:
|
||||
userAppAddr = USER_CODE_RAM;
|
||||
userAppEnd = RAM_END;
|
||||
*/
|
||||
case 1:
|
||||
userAppAddr = USER_CODE_FLASH0X8005000;
|
||||
userAppEnd = FLASH_END;
|
||||
|
@ -137,8 +143,11 @@ bool dfuUpdateByRequest(void) {
|
|||
userAppEnd = FLASH_END;
|
||||
break;
|
||||
default:
|
||||
userAppAddr = USER_CODE_RAM;
|
||||
userAppEnd = RAM_END;
|
||||
// Roger Clark.
|
||||
// Changed this to report error that its unable to write to this memory
|
||||
// However the code should never get here as only AlternateSetting 1 and 2 are allowed (see above)
|
||||
dfuAppStatus.bState = dfuERROR;
|
||||
dfuAppStatus.bStatus = errWRITE;
|
||||
break;
|
||||
}
|
||||
} else if (pInformation->USBbRequest == DFU_ABORT) {
|
||||
|
@ -158,10 +167,14 @@ bool dfuUpdateByRequest(void) {
|
|||
|
||||
if (pInformation->USBbRequest == DFU_GETSTATUS) {
|
||||
/* todo, add routine to wait for last block write to finish */
|
||||
if (userUploadType == DFU_UPLOAD_RAM) {
|
||||
|
||||
/* Roger Clark. Commented out code associated with RAM upload
|
||||
|
||||
if (userUploadType == DFU_UPLOAD_RAM)
|
||||
{
|
||||
if (code_copy_lock == WAIT) {
|
||||
code_copy_lock = BEGINNING;
|
||||
dfuAppStatus.bwPollTimeout0 = 0x20; /* 32 ms */
|
||||
dfuAppStatus.bwPollTimeout0 = 0x20; // 32 ms
|
||||
dfuAppStatus.bwPollTimeout1 = 0x00;
|
||||
dfuAppStatus.bState = dfuDNBUSY;
|
||||
|
||||
|
@ -177,7 +190,10 @@ bool dfuUpdateByRequest(void) {
|
|||
dfuAppStatus.bState = dfuDNLOAD_IDLE;
|
||||
}
|
||||
|
||||
} else {
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
dfuAppStatus.bState = dfuDNLOAD_IDLE;
|
||||
dfuCopyBufferToExec();
|
||||
}
|
||||
|
@ -384,16 +400,20 @@ void dfuCopyBufferToExec() {
|
|||
int i;
|
||||
u32 *userSpace;
|
||||
|
||||
/* Roger Clark.
|
||||
Commented out code associated with upload to RAM
|
||||
|
||||
if (userUploadType == DFU_UPLOAD_RAM)
|
||||
{
|
||||
userSpace = (u32 *)(USER_CODE_RAM + userFirmwareLen);
|
||||
/* we dont need to handle when thisBlock len is not divisible by 4,
|
||||
since the linker will align everything to 4B anyway */
|
||||
// we dont need to handle when thisBlock len is not divisible by 4,
|
||||
// since the linker will align everything to 4B anyway
|
||||
for (i = 0; i < thisBlockLen; i = i + 4) {
|
||||
*userSpace++ = *(u32 *)(recvBuffer + i);
|
||||
}
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
if (userUploadType == DFU_UPLOAD_FLASH_0X8005000)
|
||||
{
|
||||
|
@ -429,8 +449,15 @@ bool dfuUploadStarted() {
|
|||
}
|
||||
|
||||
void dfuFinishUpload() {
|
||||
while (1) {
|
||||
if (userUploadType==DFU_UPLOAD_RAM) {
|
||||
while (1)
|
||||
{
|
||||
__asm("nop");
|
||||
|
||||
/* Roger Clark.
|
||||
Commented out code associated with upload to RAM
|
||||
|
||||
if (userUploadType==DFU_UPLOAD_RAM)
|
||||
{
|
||||
if (code_copy_lock == BEGINNING) {
|
||||
code_copy_lock = MIDDLE;
|
||||
strobePin(LED_BANK, LED, 2, 0x1000);
|
||||
|
@ -439,6 +466,9 @@ void dfuFinishUpload() {
|
|||
code_copy_lock = END;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/* otherwise do nothing, dfu state machine resets itself */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,31 +61,24 @@ int main()
|
|||
}
|
||||
}
|
||||
|
||||
if (userUploadType==DFU_UPLOAD_RAM)
|
||||
|
||||
if (checkUserCode(USER_CODE_FLASH0X8002000))
|
||||
{
|
||||
// if we have just uploaded to RAM, then run whats in RAM
|
||||
jumpToUser(USER_CODE_RAM);
|
||||
jumpToUser(USER_CODE_FLASH0X8002000);
|
||||
}
|
||||
else
|
||||
{
|
||||
// This may be an upload to flash or a cold boot
|
||||
|
||||
if (checkUserCode(USER_CODE_FLASH0X8002000))
|
||||
if (checkUserCode(USER_CODE_FLASH0X8005000))
|
||||
{
|
||||
jumpToUser(USER_CODE_FLASH0X8002000);
|
||||
jumpToUser(USER_CODE_FLASH0X8005000);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (checkUserCode(USER_CODE_FLASH0X8005000))
|
||||
{
|
||||
jumpToUser(USER_CODE_FLASH0X8005000);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Nothing to execute in either Flash or RAM
|
||||
strobePin(LED_BANK, LED, 5, BLINK_FAST);
|
||||
systemHardReset();
|
||||
}
|
||||
// Nothing to execute in either Flash or RAM
|
||||
strobePin(LED_BANK, LED, 5, BLINK_FAST);
|
||||
systemHardReset();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;// Added to please the compiler
|
||||
}
|
|
@ -152,66 +152,85 @@ ONE_DESCRIPTOR usbConfigDescriptorDFU = {
|
|||
u8_usbConfigDescriptorDFU_LENGTH
|
||||
};
|
||||
|
||||
u8 u8_usbStringLangId[0x04] = {
|
||||
0x04,
|
||||
#define USB_STR_LANG_ID_LEN 0x04
|
||||
u8 u8_usbStringLangId[USB_STR_LANG_ID_LEN] = {
|
||||
USB_STR_LANG_ID_LEN,
|
||||
0x03,
|
||||
0x09,
|
||||
0x04 /* LangID = 0x0409: U.S. English */
|
||||
};
|
||||
|
||||
u8 u8_usbStringVendor[0x12] = {
|
||||
0x12,
|
||||
#define USB_VENDOR_STR_LEN 0x12
|
||||
u8 u8_usbStringVendor[USB_VENDOR_STR_LEN] = {
|
||||
USB_VENDOR_STR_LEN,
|
||||
0x03,
|
||||
'L', 0, 'e', 0, 'a', 0, 'f', 0, 'L', 0, 'a', 0, 'b', 0, 's', 0
|
||||
};
|
||||
|
||||
u8 u8_usbStringProduct[0x14] = {
|
||||
0x14,
|
||||
#define USB_PRODUCT_STR_LEN 0x14
|
||||
u8 u8_usbStringProduct[USB_PRODUCT_STR_LEN] = {
|
||||
USB_PRODUCT_STR_LEN,
|
||||
0x03,
|
||||
'M', 0, 'a', 0, 'p', 0, 'l', 0, 'e', 0, ' ', 0, '0', 0, '0', 0, '3', 0
|
||||
};
|
||||
|
||||
u8 u8_usbStringSerial[0x10] = {
|
||||
0x10,
|
||||
#define USB_SERIAL_STR_LEN 0x10
|
||||
u8 u8_usbStringSerial[USB_SERIAL_STR_LEN] = {
|
||||
USB_SERIAL_STR_LEN,
|
||||
0x03,
|
||||
'L', 0, 'L', 0, 'M', 0, ' ', 0, '0', 0, '0', 0, '3', 0
|
||||
};
|
||||
|
||||
u8 u8_usbStringAlt0[0x36] = {
|
||||
0x36,
|
||||
0x03,
|
||||
'D', 0, 'F', 0, 'U', 0, ' ', 0, 'P', 0, 'r', 0, 'o', 0, 'g', 0, 'r', 0,
|
||||
'a', 0, 'm', 0, ' ', 0, 'R', 0, 'A', 0, 'M', 0, ' ', 0, '0', 0, 'x', 0,
|
||||
'2', 0, '0', 0, '0', 0, '0', 0, '0', 0, 'C', 0, '0', 0, '0', 0
|
||||
#define ALT0_STR_LEN 0x6A
|
||||
u8 u8_usbStringAlt0[ALT0_STR_LEN] = {
|
||||
ALT0_STR_LEN,
|
||||
0x03,
|
||||
'B',0,'o',0,'o',0,'t',0,'l',0,'o',0,'a',0,'d',0,'e',0,'r',0,' ',0,'2',0,'.',0,'0',0,' ',0,'E',0,'R',0,'R',0,'O',0,'R',0,'.',0,' ',0,'U',0,'p',0,'l',0,'o',0,'a',0,'d',0,' ',0,'t',0,'o',0,' ',0,'R',0,'A',0,'M',0,' ',0,'i',0,'s',0,' ',0,'n',0,'o',0,'t',0,' ',0,'s',0,'u',0,'p',0,'p',0,'o',0,'r',0,'t',0,'e',0,'d',0
|
||||
};
|
||||
|
||||
u8 u8_usbStringAlt1[0x3A] = {
|
||||
0x3A,
|
||||
0x03,
|
||||
'D', 0, 'F', 0, 'U', 0, ' ', 0, 'P', 0, 'r', 0, 'o', 0, 'g', 0, 'r', 0,
|
||||
'a', 0, 'm', 0, ' ', 0, 'F', 0, 'L', 0, 'A', 0, 'S', 0, 'H', 0, ' ', 0,
|
||||
'0', 0, 'x', 0, '0', 0, '8', 0, '0', 0, '0', 0, '5', 0, '0', 0, '0', 0,
|
||||
'0', 0
|
||||
#define ALT1_STR_LEN 0x62
|
||||
u8 u8_usbStringAlt1[ALT1_STR_LEN] = {
|
||||
ALT1_STR_LEN,
|
||||
0x03,
|
||||
'B',0,'o',0,'o',0,'t',0,'l',0,'o',0,'a',0,'d',0,'e',0,'r',0,' ',0,'2',0,'.',0,'0',0,' ',0,'U',0,'p',0,'l',0,'o',0,'a',0,'d',0,' ',0,'t',0,'o',0,' ',0,'F',0,'l',0,'a',0,'s',0,'h',0,' ',0,'a',0,'d',0,'d',0,'r',0,'e',0,'s',0,'s',0,' ',0,'0',0,'x',0,'8',0,'0',0,'0',0,'5',0,'0',0,'0',0,'0',0
|
||||
};
|
||||
|
||||
u8 u8_usbStringAlt2[0x3A] = {
|
||||
0x3A,
|
||||
0x03,
|
||||
'D', 0, 'F', 0, 'U', 0, ' ', 0, 'P', 0, 'r', 0, 'o', 0, 'g', 0, 'r', 0,
|
||||
'a', 0, 'm', 0, ' ', 0, 'F', 0, 'L', 0, 'A', 0, 'S', 0, 'H', 0, ' ', 0,
|
||||
'0', 0, 'x', 0, '0', 0, '8', 0, '0', 0, '0', 0, '2', 0, '0', 0, '0', 0,
|
||||
'0', 0
|
||||
#define ALT2_STR_LEN 0x62
|
||||
u8 u8_usbStringAlt2[ALT2_STR_LEN] = {
|
||||
ALT2_STR_LEN,
|
||||
0x03,
|
||||
'B',0,'o',0,'o',0,'t',0,'l',0,'o',0,'a',0,'d',0,'e',0,'r',0,' ',0,'2',0,'.',0,'0',0,' ',0,'U',0,'p',0,'l',0,'o',0,'a',0,'d',0,' ',0,'t',0,'o',0,' ',0,'F',0,'l',0,'a',0,'s',0,'h',0,' ',0,'a',0,'d',0,'d',0,'r',0,'e',0,'s',0,'s',0,' ',0,'0',0,'x',0,'8',0,'0',0,'0',0,'2',0,'0',0,'0',0,'0',0
|
||||
};
|
||||
|
||||
u8 u8_usbStringInterface = NULL;
|
||||
|
||||
ONE_DESCRIPTOR usbStringDescriptor[STR_DESC_LEN] = {
|
||||
{ (u8 *)u8_usbStringLangId, 0x04 },
|
||||
{ (u8 *)u8_usbStringVendor, 0x12 },
|
||||
{ (u8 *)u8_usbStringProduct, 0x20 },
|
||||
{ (u8 *)u8_usbStringSerial, 0x10 },
|
||||
{ (u8 *)u8_usbStringAlt0, 0x36 },
|
||||
{ (u8 *)u8_usbStringAlt1, 0x3A },
|
||||
{ (u8 *)u8_usbStringAlt2, 0x3A }
|
||||
{ (u8 *)u8_usbStringLangId, USB_STR_LANG_ID_LEN },
|
||||
{ (u8 *)u8_usbStringVendor, USB_VENDOR_STR_LEN },
|
||||
{ (u8 *)u8_usbStringProduct, USB_PRODUCT_STR_LEN },
|
||||
{ (u8 *)u8_usbStringSerial, USB_SERIAL_STR_LEN },
|
||||
{ (u8 *)u8_usbStringAlt0, ALT0_STR_LEN },
|
||||
{ (u8 *)u8_usbStringAlt1, ALT1_STR_LEN },
|
||||
{ (u8 *)u8_usbStringAlt2, ALT2_STR_LEN }
|
||||
};
|
||||
/*
|
||||
Roger.
|
||||
Javascript utility to make new ALT ID text structs
|
||||
|
||||
<html>
|
||||
<script>
|
||||
function convertText(txt,idNum)
|
||||
{
|
||||
|
||||
var txt2 ="#define ALT"+idNum+"_STR_LEN 0x"+(txt.length*2 + 2).toString(16).toUpperCase()+"<br/>u8 u8_usbStringAlt"+idNum+"[ALT"+idNum+"_STR_LEN] = {<br/>ALT"+idNum+"_STR_LEN,<br/>0x03,<br/>";
|
||||
for (var i=0;i<txt.length;i++)
|
||||
{
|
||||
txt2+="'"+txt[i]+"',0,";
|
||||
}
|
||||
return txt2.substring(0,txt2.length-1)+"<br/>};<br/>";
|
||||
}
|
||||
document.write("<pre>");
|
||||
document.write(convertText("Bootloader 2.0 ERROR. Upload to RAM is not supported",0)+"<br/>");
|
||||
document.write(convertText("Bootloader 2.0 Upload to Flash address 0x8005000",1)+"<br/>");
|
||||
document.write(convertText("Bootloader 2.0 Upload to Flash address 0x8002000",2)+"<br/>");
|
||||
document.write("</pre>");
|
||||
</script>
|
||||
</html>
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue