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
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