upgrade: gnuk side working now
This commit is contained in:
@@ -114,7 +114,7 @@ SECTIONS
|
||||
|
||||
PROVIDE(end = .);
|
||||
_end = .;
|
||||
. = ALIGN(256);
|
||||
. = ALIGN(512);
|
||||
_regnual_start = .;
|
||||
|
||||
@CERTDO_SUPPORT_START@
|
||||
|
||||
17
src/main.c
17
src/main.c
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include "gnuk.h"
|
||||
#include "usb_lld.h"
|
||||
#include "usb-cdc.h"
|
||||
@@ -473,9 +474,23 @@ main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
usb_lld_shutdown ();
|
||||
/* erase by mass erase */
|
||||
USB_Cable_Config (0);
|
||||
set_led (1);
|
||||
chThdSleep (MS2ST (100));
|
||||
port_disable ();
|
||||
/* set vector */
|
||||
SCB->VTOR = (uint32_t)&_regnual_start;
|
||||
#if 0
|
||||
/* SYSRESETREQ to invoke regnual */
|
||||
NVIC_SystemReset ();
|
||||
#else
|
||||
{
|
||||
/* Not yet: erase by mass erase and go to entry */
|
||||
void (**func)(void) = (void (**)(void))(&_regnual_start + 4);
|
||||
|
||||
(**func) ();
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ static const uint8_t data_rate_table[] = { 0x80, 0x25, 0, 0, }; /* dwDataRate */
|
||||
static const uint8_t lun_table[] = { 0, 0, 0, 0, };
|
||||
#endif
|
||||
|
||||
static const uint8_t *mem_info[] = { &_regnual_start, &__heap_end__, };
|
||||
static const uint8_t *const mem_info[] = { &_regnual_start, &__heap_end__, };
|
||||
|
||||
#define USB_FSIJ_GNUK_MEMINFO 0
|
||||
#define USB_FSIJ_GNUK_DOWNLOAD 1
|
||||
@@ -197,6 +197,14 @@ static const uint8_t *mem_info[] = { &_regnual_start, &__heap_end__, };
|
||||
|
||||
static int download_check_crc32 (const uint8_t *p)
|
||||
{
|
||||
uint32_t crc32 = 0;
|
||||
|
||||
crc32 += (*--p << 24);
|
||||
crc32 += (*--p << 16);
|
||||
crc32 += (*--p << 8);
|
||||
crc32 += (*--p);
|
||||
|
||||
/* Not yet: Calculate crc32 from &_regnual_start to p, then compare */
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -238,7 +246,7 @@ gnuk_setup (uint8_t req, uint8_t req_no,
|
||||
if (icc_state_p == NULL || *icc_state_p != ICC_STATE_EXITED)
|
||||
return USB_UNSUPPORT;
|
||||
|
||||
/* There is a trailer at addr: size, crc32 */
|
||||
/* There is a trailer at addr: crc32 */
|
||||
return download_check_crc32 (addr);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user