From b9ce8e4acf030f4b387f3539a28e250dfe5c6451 Mon Sep 17 00:00:00 2001 From: Serge Date: Sat, 13 Oct 2018 22:33:50 -0700 Subject: [PATCH] Read full d868uv image: 67 mbytes. --- d868uv.c | 19 ++++++------------- radio.c | 2 +- serial.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ util.h | 7 ++----- 4 files changed, 59 insertions(+), 19 deletions(-) diff --git a/d868uv.c b/d868uv.c index 0a5c937..adee543 100644 --- a/d868uv.c +++ b/d868uv.c @@ -41,7 +41,8 @@ #define NSCANL 250 #define NMESSAGES 100 -#define MEMSZ 0xd0000 +//#define MEMSZ 0x100000 +#define MEMSZ 0x4300000 // // Print a generic information about the device. @@ -72,12 +73,10 @@ static void d868uv_print_version(radio_device_t *radio, FILE *out) // static void d868uv_download(radio_device_t *radio) { - //TODO -#if 0 - int bno; + int addr; - for (bno=0; bno> 24; + cmd[2] = (addr + n) >> 16; + cmd[3] = (addr + n) >> 8; + cmd[4] = addr + n; + cmd[5] = DATASZ; + send_recv(cmd, 6, reply, sizeof(reply)); + if (reply[0] != CMD_WRITE[0] || reply[7+DATASZ] != CMD_ACK[0]) { + fprintf(stderr, "%s: Wrong read reply %02x-...-%02x, expected %02x-...-%02x\n", + __func__, reply[0], reply[7+DATASZ], CMD_WRITE[0], CMD_ACK[0]); + exit(-1); + } + memcpy(data + n, reply + 6, DATASZ); + } +} + +void serial_write_region(int addr, unsigned char *data, int nbytes) +{ + //TODO +#if 0 + unsigned char ack, cmd[4+32]; + int n; + + for (n=0; n> 8; + cmd[2] = addr + n; + cmd[3] = 32; + memcpy(cmd + 4, data + n, 32); + send_recv(cmd, 4+32, &ack, 1); + if (ack != CMD_ACK[0]) { + fprintf(stderr, "%s: Wrong acknowledge %#x, expected %#x\n", + __func__, ack, CMD_ACK[0]); + exit(-1); + } + } +#endif +} diff --git a/util.h b/util.h index a64cf47..037bbfa 100644 --- a/util.h +++ b/util.h @@ -83,11 +83,8 @@ void hid_write_finish(void); int serial_init(int vid, int pid); const char *serial_identify(void); void serial_close(void); -//void serial_send_recv(const unsigned char *data, unsigned nbytes, unsigned char *rdata, unsigned rlength); -//void serial_read_block(int bno, unsigned char *data, int nbytes); -//void serial_read_finish(void); -//void serial_write_block(int bno, unsigned char *data, int nbytes); -//void serial_write_finish(void); +void serial_read_region(int addr, unsigned char *data, int nbytes); +void serial_write_region(int addr, unsigned char *data, int nbytes); // // Delay in milliseconds.