From 0365f94b019372c4fb728a2245d5d243bc00a0e2 Mon Sep 17 00:00:00 2001 From: sq5bpf Date: Tue, 10 Oct 2023 21:58:55 +0200 Subject: [PATCH] remove length and offset settings for flash, accept flash mode packets with shorter length from some Lseng clone --- README | 6 ++---- k5prog.c | 28 +++++----------------------- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/README b/README index 7756211..3814b25 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -k5prog - Quansheng UV-K5 EEPROM and flash programmer v0.7 +k5prog - Quansheng UV-K5 EEPROM and flash programmer v0.8 (c) 2023 Jacek Lipkowski This program can read and write the eeprom of Quansheng UV-K5. @@ -41,7 +41,7 @@ For licensing see the file LICENSE. for help run the programwithout arguments, or with the -h option. The configuration options are: -Quansheng UV-K5 EEPROM programmer v0.5 (c) 2023 Jacek Lipkowski +Quansheng UV-K5 EEPROM programmer v0.8 (c) 2023 Jacek Lipkowski cmdline opts: -f filename that contains the eeprom dump (default: k5_eeprom.raw) @@ -50,8 +50,6 @@ cmdline opts: -D wait for the message from the radio flasher, print it's version -F flash firmware, WARNING: this will likely brick your radio! -M Set the firmware major version to during the flash process (default: *.01.23) --O offset of block to flash in hex (default: 0) --L length of file to flash in hex (default: all) -r read eeprom -w write eeprom like the original software does -W write most of the eeprom (but without what i think is calibration data) diff --git a/k5prog.c b/k5prog.c index 4a00d38..a48e04e 100644 --- a/k5prog.c +++ b/k5prog.c @@ -1,4 +1,4 @@ -/* Quansheng UV-K5 EEPROM programmer v0.7 +/* Quansheng UV-K5 EEPROM programmer v0.8 * (c) 2023 Jacek Lipkowski * * This program can read and write the eeprom of Quansheng UVK5 Mark II @@ -50,7 +50,7 @@ #include #include "uvk5.h" -#define VERSION "Quansheng UV-K5 EEPROM programmer v0.7 (c) 2023 Jacek Lipkowski " +#define VERSION "Quansheng UV-K5 EEPROM programmer v0.8 (c) 2023 Jacek Lipkowski " #define MODE_NONE 0 #define MODE_READ 1 @@ -581,7 +581,8 @@ int wait_flash_message(int fd,int ntimes) { destroy_k5_struct(cmd); continue; } - if (cmd->len!=36) { + /* 36 is normal length, 22 is sent by some LSENG UV-K5 clone */ + if ((cmd->len!=36)&&(cmd->len!=22)) { printf("wait_flash_message: got unexpected command length %i\n",cmd->len); destroy_k5_struct(cmd); continue; @@ -750,8 +751,6 @@ void helpme() "-D \twait for the message from the radio flasher, print it's version\n" "-F \tflash firmware, WARNING: this will likely brick your radio!\n" "-M \tSet the firmware major version to during the flash process (default: " DEFAULT_FLASH_VERSION ")\n" - "-O \toffset of block to flash in hex (default: 0)\n" - "-L \tlength of file to flash in hex (default: all)\n" "-r \tread eeprom\n" "-w \twrite eeprom like the original software does\n" "-W \twrite most of the eeprom (but without what i think is calibration data)\n" @@ -813,13 +812,10 @@ void parse_cmdline(int argc, char **argv) { int opt; - int res; /* cmdline opts: * -f * -b * -F (flash firmware) - * -O (hex offset) - * -L (hex length) * -r (read) * -w (write) * -p @@ -831,7 +827,7 @@ void parse_cmdline(int argc, char **argv) * -Y (i know what i'm doing) */ - while ((opt=getopt(argc,argv,"f:rwWBp:s:hvDFYb:L:O:M:"))!=EOF) + while ((opt=getopt(argc,argv,"f:rwWBp:s:hvDFYb:M:"))!=EOF) { switch (opt) { @@ -863,20 +859,6 @@ void parse_cmdline(int argc, char **argv) case 'M': strncpy(flash_version_string,optarg,sizeof(flash_version_string)-1); break; - case 'O': - res=sscanf(optarg,"%x",&write_offset); - if (res!=1) { - fprintf(stderr,"ERROR, could not parse offset %s\n",optarg); - exit(1); - } - break; - case 'L': - res=sscanf(optarg,"%x",&write_length); - if (res!=1) { - fprintf(stderr,"ERROR, could not parse length %s\n",optarg); - exit(1); - } - break; case 'W': mode=MODE_WRITE_MOST; break;