X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=ROM2%2Fmain_basic.c;h=8d86585ad771845cf0fec0f7101758dc9929051b;hb=c107bf29a234bf80a7762e838628ac613456f838;hp=cddfb12d967f79413cbf57e18cbada66b3f14145;hpb=db71d9706715bf39fa5c5696108019bacd8181fa;p=uccvend-snackrom.git diff --git a/ROM2/main_basic.c b/ROM2/main_basic.c index cddfb12..8d86585 100644 --- a/ROM2/main_basic.c +++ b/ROM2/main_basic.c @@ -14,6 +14,7 @@ #include "sci.h" #include "vend.h" #include "xmodem.h" +//#include "sha1.h" u8 last_standalone; u8 last_switch_input; @@ -323,16 +324,22 @@ void getrom() { send_string("Writing to serial port (maybe). Size is 0x"); send_string(u82hex(_rom_src_len >> 8)); send_string(u82hex(_rom_src_len & 0xff)); + send_string("@0x"); + send_string(u82hex((u16)(&_rom_src_data) >> 8)); + send_string(u82hex((u16)(&_rom_src_data) & 0xff)); send_string(" with signature "); s[0] = _rom_src_data[0]; s[1] = _rom_src_data[1]; s[2] = _rom_src_data[2]; s[3] = '\0'; send_string(s); - send_string(CRLF " Type YES to download via XMODEM: "); + send_string(CRLF " Type YES to download rom.tar.bz2 via XMODEM: "); msg_clr(); while (!sci_have_packet); /* spin */ - if (!my_strncmp("YES", (char*)sci_rx_buf, 3)) return; + if (!my_strncmp("YES", (char*)sci_rx_buf, 3)) { + send_string(CRLF "Transfer cancelled." CRLF); + return; + } sci_init(); sci_doing_xmodem = 1; @@ -345,16 +352,19 @@ void getrom() { char *end = (char*)_rom_src_data+_rom_src_len; bool aborted = 0; while (1) { - if (!xmodem_send_packet((char*)p, 128)) { - aborted = 1; - break; - } - p += 128; if (p + 128 > end) { /* send partial packet */ if (!xmodem_send_packet((char*)p, end-p)) aborted = 1; break; + } if ((u16)p == 0xb600) { + /* we have an eeprom here. skip it. */ + p += 0x0200; + continue; + } else if (!xmodem_send_packet((char*)p, 128)) { + aborted = 1; + break; } + p += 128; } xmodem_finish_xfer(); @@ -372,6 +382,9 @@ void quit() { unknown_command(); } +//SHA1_CTX ctx; +//u8 sha1_digest[SHA1_SIGNATURE_SIZE]; + int main() { u8 i; for (i = 0; i < 11; i++) @@ -451,6 +464,11 @@ int main() { } if (sci_have_packet) { + if (must_verify()) { + //SHA1_Init(&ctx); + //SHA1_Update(&ctx, sci_rx_buf, my_strlen(sci_rx_buf)); + //SHA1_Final(sha1_digest, &ctx); + } switch (sci_rx_buf[0]) { case '\0': case '#':