Skip to content

Commit 0365f94

Browse files
committed
remove length and offset settings for flash, accept flash mode packets with shorter length from some Lseng clone
1 parent c2b0d57 commit 0365f94

File tree

2 files changed

+7
-27
lines changed

2 files changed

+7
-27
lines changed

README

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
k5prog - Quansheng UV-K5 EEPROM and flash programmer v0.7
1+
k5prog - Quansheng UV-K5 EEPROM and flash programmer v0.8
22
(c) 2023 Jacek Lipkowski <[email protected]>
33

44
This program can read and write the eeprom of Quansheng UV-K5.
@@ -41,7 +41,7 @@ For licensing see the file LICENSE.
4141
for help run the programwithout arguments, or with the -h option.
4242

4343
The configuration options are:
44-
Quansheng UV-K5 EEPROM programmer v0.5 (c) 2023 Jacek Lipkowski <[email protected]>
44+
Quansheng UV-K5 EEPROM programmer v0.8 (c) 2023 Jacek Lipkowski <[email protected]>
4545

4646
cmdline opts:
4747
-f <file> filename that contains the eeprom dump (default: k5_eeprom.raw)
@@ -50,8 +50,6 @@ cmdline opts:
5050
-D wait for the message from the radio flasher, print it's version
5151
-F flash firmware, WARNING: this will likely brick your radio!
5252
-M <ver> Set the firmware major version to <ver> during the flash process (default: *.01.23)
53-
-O offset of block to flash in hex (default: 0)
54-
-L length of file to flash in hex (default: all)
5553
-r read eeprom
5654
-w write eeprom like the original software does
5755
-W write most of the eeprom (but without what i think is calibration data)

k5prog.c

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Quansheng UV-K5 EEPROM programmer v0.7
1+
/* Quansheng UV-K5 EEPROM programmer v0.8
22
* (c) 2023 Jacek Lipkowski <[email protected]>
33
*
44
* This program can read and write the eeprom of Quansheng UVK5 Mark II
@@ -50,7 +50,7 @@
5050
#include <stdint.h>
5151
#include "uvk5.h"
5252

53-
#define VERSION "Quansheng UV-K5 EEPROM programmer v0.7 (c) 2023 Jacek Lipkowski <[email protected]>"
53+
#define VERSION "Quansheng UV-K5 EEPROM programmer v0.8 (c) 2023 Jacek Lipkowski <[email protected]>"
5454

5555
#define MODE_NONE 0
5656
#define MODE_READ 1
@@ -581,7 +581,8 @@ int wait_flash_message(int fd,int ntimes) {
581581
destroy_k5_struct(cmd);
582582
continue;
583583
}
584-
if (cmd->len!=36) {
584+
/* 36 is normal length, 22 is sent by some LSENG UV-K5 clone */
585+
if ((cmd->len!=36)&&(cmd->len!=22)) {
585586
printf("wait_flash_message: got unexpected command length %i\n",cmd->len);
586587
destroy_k5_struct(cmd);
587588
continue;
@@ -750,8 +751,6 @@ void helpme()
750751
"-D \twait for the message from the radio flasher, print it's version\n"
751752
"-F \tflash firmware, WARNING: this will likely brick your radio!\n"
752753
"-M <ver> \tSet the firmware major version to <ver> during the flash process (default: " DEFAULT_FLASH_VERSION ")\n"
753-
"-O \toffset of block to flash in hex (default: 0)\n"
754-
"-L \tlength of file to flash in hex (default: all)\n"
755754
"-r \tread eeprom\n"
756755
"-w \twrite eeprom like the original software does\n"
757756
"-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)
813812
{
814813
int opt;
815814

816-
int res;
817815
/* cmdline opts:
818816
* -f <file>
819817
* -b <flash file>
820818
* -F (flash firmware)
821-
* -O (hex offset)
822-
* -L (hex length)
823819
* -r (read)
824820
* -w (write)
825821
* -p <port>
@@ -831,7 +827,7 @@ void parse_cmdline(int argc, char **argv)
831827
* -Y (i know what i'm doing)
832828
*/
833829

834-
while ((opt=getopt(argc,argv,"f:rwWBp:s:hvDFYb:L:O:M:"))!=EOF)
830+
while ((opt=getopt(argc,argv,"f:rwWBp:s:hvDFYb:M:"))!=EOF)
835831
{
836832
switch (opt)
837833
{
@@ -863,20 +859,6 @@ void parse_cmdline(int argc, char **argv)
863859
case 'M':
864860
strncpy(flash_version_string,optarg,sizeof(flash_version_string)-1);
865861
break;
866-
case 'O':
867-
res=sscanf(optarg,"%x",&write_offset);
868-
if (res!=1) {
869-
fprintf(stderr,"ERROR, could not parse offset %s\n",optarg);
870-
exit(1);
871-
}
872-
break;
873-
case 'L':
874-
res=sscanf(optarg,"%x",&write_length);
875-
if (res!=1) {
876-
fprintf(stderr,"ERROR, could not parse length %s\n",optarg);
877-
exit(1);
878-
}
879-
break;
880862
case 'W':
881863
mode=MODE_WRITE_MOST;
882864
break;

0 commit comments

Comments
 (0)