Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flasher version check fail #9

Open
rakenrowl7 opened this issue Sep 28, 2023 · 14 comments
Open

Flasher version check fail #9

rakenrowl7 opened this issue Sep 28, 2023 · 14 comments

Comments

@rakenrowl7
Copy link

Hello!

I'm running k5prog under cygwin and successfully read eeprom data with radio in normal mode

$ ./k5prog -r -v -p /dev/com3
Quansheng UV-K5 EEPROM programmer v0.5 (c) 2023 Jacek Lipkowski <[email protected]>

k5_prepare: try 0
******  Connected to firmware version: [2.01.31]
Sucessfuly read eeprom


However, when reading flasher/bootloader version, the program fails

$ ./k5prog -r -D -Y -vvv -p /dev/com3
Quansheng UV-K5 EEPROM programmer v0.5 (c) 2023 Jacek Lipkowski <[email protected]>

"I know what i'm doing" value set to 1
wait_flash_message try 9999
RXRXRX:

0x000004 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00                                       ....
magic:

0x000004 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00                                       ....
RXRXRX:

0x000018 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a 24 44 16 81   .i../..B/f..$D..
0x000010: 86 6c 9e e6 ff ff dc ba                           .l......
bad crc 0x6ed1 (should be 0x7f14)
********  k5 command hexdump [obf_len:28 clear_len:22 crc_ok:0 **********
## obfuscated ##

0x00001c |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a   .....i../..B/f..
0x000010: 24 44 16 81 86 6c 9e e6 ff ff dc ba               $D...l......
## cleartext ##

0x000016 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 18 05 00 00 01 02 02 02 0e 53 50 4a 37 47 ff 01   .........SPJ7G..
0x000010: 90 00 8a 00 d1 6e                                 .....n
*****************
********  k5 command hexdump [obf_len:28 clear_len:20 crc_ok:0 **********
## obfuscated ##

0x00001c |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a   .....i../..B/f..
0x000010: 24 44 16 81 86 6c 9e e6 ff ff dc ba               $D...l......
## cleartext ##

0x000014 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 18 05 00 00 01 02 02 02 0e 53 50 4a 37 47 ff 01   .........SPJ7G..
0x000010: 90 00 8a 00                                       ....
*****************
********  k5 command hexdump [obf_len:28 clear_len:20 crc_ok:0 **********
## obfuscated ##

0x00001c |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a   .....i../..B/f..
0x000010: 24 44 16 81 86 6c 9e e6 ff ff dc ba               $D...l......
## cleartext ##

0x000014 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 18 05 00 00 01 02 02 02 0e 53 50 4a 37 47 ff 01   .........SPJ7G..
0x000010: 90 00 8a 00                                       ....
*****************
wait_flash_message: got unexpected command length 20
wait_flash_message try 9998

I'm using a generic ch340 'baofeng' serial cable, cygwin under windows 11. I can confirm the radio and cable works with official QS updater.

I suspect that this issue prevents flashing firmware through k5prog and k5prog-win. https://github.com/OneOfEleven/k5prog-win/issues/4

@sq5bpf
Copy link
Owner

sq5bpf commented Sep 28, 2023

Might be a timeout issue on some operating systems and some usb/serial drivers which have more latency (buffer more etc)

Please modify all occurrences of k5_receive(fd,10000); change to k5_receive(fd,100000);
and line 697:
l=5; change to l=50;
and see if it works (and post the dump)

Could you also try running it on linux?

@OneOfEleven
Copy link

Their radios bootloader is sending a different packet than normal, so k5prog see's that as an invalid packet to move forward with the flash upload.

I'd like to know what bootloader version is in the radio.

@rakenrowl7
Copy link
Author

Please modify all occurrences of k5_receive(fd,10000); change to k5_receive(fd,100000); and line 697: l=5; change to l=50; and see if it works (and post the dump)

$ ./k5prog -r -D -Y -vvv -p /dev/com3
Quansheng UV-K5 EEPROM programmer v0.5 (c) 2023 Jacek Lipkowski <[email protected]>

"I know what i'm doing" value set to 1
wait_flash_message try 9999
RXRXRX:

0x000004 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00                                       ....
magic:

0x000004 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00                                       ....
RXRXRX:

0x000018 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a 24 44 16 81   .i../..B/f..$D..
0x000010: 86 6c 9e e6 ff ff dc ba                           .l......
bad crc 0x6ed1 (should be 0x7f14)
********  k5 command hexdump [obf_len:28 clear_len:22 crc_ok:0 **********
## obfuscated ##

0x00001c |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a   .....i../..B/f..
0x000010: 24 44 16 81 86 6c 9e e6 ff ff dc ba               $D...l......
## cleartext ##

0x000016 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 18 05 00 00 01 02 02 02 0e 53 50 4a 37 47 ff 01   .........SPJ7G..
0x000010: 90 00 8a 00 d1 6e                                 .....n
*****************
********  k5 command hexdump [obf_len:28 clear_len:20 crc_ok:0 **********
## obfuscated ##

0x00001c |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a   .....i../..B/f..
0x000010: 24 44 16 81 86 6c 9e e6 ff ff dc ba               $D...l......
## cleartext ##

0x000014 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 18 05 00 00 01 02 02 02 0e 53 50 4a 37 47 ff 01   .........SPJ7G..
0x000010: 90 00 8a 00                                       ....
*****************
********  k5 command hexdump [obf_len:28 clear_len:20 crc_ok:0 **********
## obfuscated ##

0x00001c |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a   .....i../..B/f..
0x000010: 24 44 16 81 86 6c 9e e6 ff ff dc ba               $D...l......
## cleartext ##

0x000014 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 18 05 00 00 01 02 02 02 0e 53 50 4a 37 47 ff 01   .........SPJ7G..
0x000010: 90 00 8a 00                                       ....
*****************
wait_flash_message: got unexpected command length 20
wait_flash_message try 9998

Could you also try running it on linux?

same issue it seems
2023-09-28-182531_1366x768_scrot

@sq5bpf
Copy link
Owner

sq5bpf commented Sep 28, 2023

EDIT: don't use this one, use the one in the next post

Please try this version and see what debug log it produces.
gcc k5prog_test.c -o k5prog_test -DSTRANGE_FIRMWARE

also if it doesn't work, try changing 0x9 the byte in line 664 to 0x8 and 0xa and see if that helps

test.zip

@sq5bpf
Copy link
Owner

sq5bpf commented Sep 28, 2023

No, try this one and see if it works with your radio
gcc k5prog_test.c -o k5prog_test -DSTRANGE_FIRMWARE

test2.zip

@rakenrowl7
Copy link
Author

hello, sorry for the slow reply

compiling and running the test2.zip content, im getting the same issue


:~/k5prog# ./k5prog_test -r -D -Y -vvv
Quansheng UV-K5 EEPROM programmer v0.5 (c) 2023 Jacek Lipkowski <[email protected]>

"I know what i'm doing" value set to 1
wait_flash_message try 9999
RXRXRX:

0x000004 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00                                       ....               
magic:

0x000004 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00                                       ....               
RXRXRX:

0x000018 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a 24 44 16 81   .i../..B/f..$D..   
0x000010: 86 6c 9e e6 ff ff dc ba                           .l......           
bad crc 0x6ed1 (should be 0x7f14)
********  k5 command hexdump [obf_len:28 clear_len:22 crc_ok:0 **********
## obfuscated ##

0x00001c |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a   .....i../..B/f..   
0x000010: 24 44 16 81 86 6c 9e e6 ff ff dc ba               $D...l......       
## cleartext ##

0x000016 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 18 05 00 00 01 02 02 02 0e 53 50 4a 37 47 ff 01   .........SPJ7G..   
0x000010: 90 00 8a 00 d1 6e                                 .....n             
*****************
********  k5 command hexdump [obf_len:28 clear_len:20 crc_ok:0 **********
## obfuscated ##

0x00001c |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a   .....i../..B/f..   
0x000010: 24 44 16 81 86 6c 9e e6 ff ff dc ba               $D...l......       
## cleartext ##

0x000014 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 18 05 00 00 01 02 02 02 0e 53 50 4a 37 47 ff 01   .........SPJ7G..   
0x000010: 90 00 8a 00                                       ....               
*****************
********  k5 command hexdump [obf_len:28 clear_len:20 crc_ok:0 **********
## obfuscated ##

0x00001c |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a   .....i../..B/f..   
0x000010: 24 44 16 81 86 6c 9e e6 ff ff dc ba               $D...l......       
## cleartext ##

0x000014 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 18 05 00 00 01 02 02 02 0e 53 50 4a 37 47 ff 01   .........SPJ7G..   
0x000010: 90 00 8a 00                                       ....               
*****************
wait_flash_message: got unexpected command length 20
wait_flash_message try 9998
^C

@sq5bpf
Copy link
Owner

sq5bpf commented Oct 10, 2023

Please check out the latest version of k5prog and see if it works for you with this radio

@rakenrowl7
Copy link
Author

apologies for late response. a few days ago, i was testing the update with the previous commands, i was still getting the got unexpected command length 20 error with v0.8. i'll test v0.9 later at home.

@rakenrowl7
Copy link
Author

$ ./k5prog -r -D -Y -vvv
Quansheng UV-K5 EEPROM programmer v0.9 (c) 2023 Jacek Lipkowski <[email protected]>

"I know what i'm doing" value set to 1
wait_flash_message try 9999
RXRXRX:

0x000004 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00                                       ....
magic:

0x000004 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00                                       ....
RXRXRX:

0x000018 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a 24 44 16 81   .i../..B/f..$D..
0x000010: 86 6c 9e e6 ff ff dc ba                           .l......
bad crc 0x6ed1 (should be 0x7f14)
********  k5 command hexdump [obf_len:28 clear_len:22 crc_ok:0 **********
## obfuscated ##

0x00001c |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a   .....i../..B/f..
0x000010: 24 44 16 81 86 6c 9e e6 ff ff dc ba               $D...l......
## cleartext ##

0x000016 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 18 05 00 00 01 02 02 02 0e 53 50 4a 37 47 ff 01   .........SPJ7G..
0x000010: 90 00 8a 00 d1 6e                                 .....n
*****************
********  k5 command hexdump [obf_len:28 clear_len:20 crc_ok:0 **********
## obfuscated ##

0x00001c |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a   .....i../..B/f..
0x000010: 24 44 16 81 86 6c 9e e6 ff ff dc ba               $D...l......
## cleartext ##

0x000014 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 18 05 00 00 01 02 02 02 0e 53 50 4a 37 47 ff 01   .........SPJ7G..
0x000010: 90 00 8a 00                                       ....
*****************
********  k5 command hexdump [obf_len:28 clear_len:20 crc_ok:0 **********
## obfuscated ##

0x00001c |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a   .....i../..B/f..
0x000010: 24 44 16 81 86 6c 9e e6 ff ff dc ba               $D...l......
## cleartext ##

0x000014 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 18 05 00 00 01 02 02 02 0e 53 50 4a 37 47 ff 01   .........SPJ7G..
0x000010: 90 00 8a 00                                       ....
*****************
wait_flash_message: got unexpected packet contents
wait_flash_message try 9998
^C

@rakenrowl7
Copy link
Author

rakenrowl7 commented Oct 15, 2023

i have made some alterations to the c code, and now it results to this:

$ ./k5prog -r -D -Y -vvv
Quansheng UV-K5 EEPROM programmer v0.9 (c) 2023 Jacek Lipkowski <[email protected]>

"I know what i'm doing" value set to 1
wait_flash_message try 9999
RXRXRX:

0x000004 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00                                       ....
magic:

0x000004 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00                                       ....
RXRXRX:

0x000018 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a 24 44 16 81   .i../..B/f..$D..
0x000010: 86 6c 9e e6 ff ff dc ba                           .l......
bad crc 0x6ed1 (should be 0x7f14)
********  k5 command hexdump [obf_len:28 clear_len:22 crc_ok:0 **********
## obfuscated ##

0x00001c |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a   .....i../..B/f..
0x000010: 24 44 16 81 86 6c 9e e6 ff ff dc ba               $D...l......
## cleartext ##

0x000016 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 18 05 00 00 01 02 02 02 0e 53 50 4a 37 47 ff 01   .........SPJ7G..
0x000010: 90 00 8a 00 d1 6e                                 .....n
*****************
********  k5 command hexdump [obf_len:28 clear_len:20 crc_ok:0 **********
## obfuscated ##

0x00001c |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a   .....i../..B/f..
0x000010: 24 44 16 81 86 6c 9e e6 ff ff dc ba               $D...l......
## cleartext ##

0x000014 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 18 05 00 00 01 02 02 02 0e 53 50 4a 37 47 ff 01   .........SPJ7G..
0x000010: 90 00 8a 00                                       ....
*****************
********  k5 command hexdump [obf_len:28 clear_len:20 crc_ok:0 **********
## obfuscated ##

0x00001c |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a   .....i../..B/f..
0x000010: 24 44 16 81 86 6c 9e e6 ff ff dc ba               $D...l......
## cleartext ##

0x000014 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 18 05 00 00 01 02 02 02 0e 53 50 4a 37 47 ff 01   .........SPJ7G..
0x000010: 90 00 8a 00                                       ....
*****************
Flasher version is: []

with the same modification was able to successfully flash a custom firmware and boot successfully:

$ ./k5prog -b firmware.bin -YYYYYY -F
Quansheng UV-K5 EEPROM programmer v0.9 (c) 2023 Jacek Lipkowski <[email protected]>

"I know what i'm doing" value set to 6
Writing blocks from address 0x0 until 0xf000, firmware size is 0xef20
********  k5 command hexdump [obf_len:28 clear_len:20 crc_ok:0 **********
## obfuscated ##

0x00001c |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 14 00 0e 69 14 e6 2f 93 0f 42 2f 66 85 0a   .....i../..B/f..
0x000010: 24 44 16 81 86 6c 9e e6 ff ff dc ba               $D...l......
## cleartext ##

0x000014 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 18 05 00 00 01 02 02 02 0e 53 50 4a 37 47 ff 01   .........SPJ7G..
0x000010: 90 00 8a 00                                       ....
*****************
Flasher version is: []
*** FLASH at 0x0000 length 0x0100  result=1
*** FLASH at 0x0100 length 0x0100  result=1
*** FLASH at 0x0200 length 0x0100  result=1
*** FLASH at 0x0300 length 0x0100  result=1
*** FLASH at 0x0400 length 0x0100  result=1
*** FLASH at 0x0500 length 0x0100  result=1
...
*** FLASH at 0xe900 length 0x0100  result=1
*** FLASH at 0xea00 length 0x0100  result=1
*** FLASH at 0xeb00 length 0x0100  result=1
*** FLASH at 0xec00 length 0x0100  result=1
*** FLASH at 0xed00 length 0x0100  result=1
*** FLASH at 0xee00 length 0x0100  result=1
*** FLASH at 0xef00 length 0x0020  result=1


prior to this modification, when attempting to flash firmware with v0.9, a similar got unexpected packet contents prints out

@sq5bpf
Copy link
Owner

sq5bpf commented Oct 15, 2023

thanks, seems the "i'm in flashing mode" packet detection has to be redone. also see:
#6 (few end comments)

i will try to look what the new vendor flasher looks for using k5emulator. won't use your patch right now because i don't want to break support for the majority of radios (which do work), but maybe i will use it or something similar later.

interesting thing about your debug output: the packet is somethimes 20 bytes and sometimes 22 bytes

@sq5bpf
Copy link
Owner

sq5bpf commented Dec 29, 2023

please see if this version works for you

@kamilsss655
Copy link

I got exactly same issue on the new batch of UV-K5. Seems like they changed the bootloader?
Flashing with UVMOD works.

k5prog -F -YYY -vvv -b compiled-firmware/firmware.bin
Quansheng UV-K5 EEPROM programmer v0.9 (c) 2023 Jacek Lipkowski <[email protected]>

"I know what i'm doing" value set to 3
Read file compiled-firmware/firmware.bin success
Writing blocks from address 0x0 until 0xec00, firmware size is 0xeba0
wait_flash_message try 9999
RXRXRX:

0x000004 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 24 00                                       ..$.               
magic:

0x000004 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 24 00                                       ..$.               
RXRXRX:

0x000028 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 0e 69 34 e6 2f 93 0e 42 2d 66 9f 73 5e 40 16 8d   .i4./..B-f.s^@..   
0x000010: 1d 6c 61 e6 1c bf 3d 70 0f 05 e3 40 27 09 e9 80   .la...=p...@'...   
0x000020: 16 6c 14 c6 ff ff dc ba                           .l......           
bad crc 0x6ed1 (should be 0x9f17)
********  k5 command hexdump [obf_len:44 clear_len:38 crc_ok:0 **********
## obfuscated ##

0x00002c |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: ab cd 24 00 0e 69 34 e6 2f 93 0e 42 2d 66 9f 73   ..$..i4./..B-f.s   
0x000010: 5e 40 16 8d 1d 6c 61 e6 1c bf 3d 70 0f 05 e3 40   ^@...la...=p...@   
0x000020: 27 09 e9 80 16 6c 14 c6 ff ff dc ba               '....l......       
## cleartext ##

0x000026 |0 |1 |2 |3 |4 |5 |6 |7 |8 |9 |a |b |c |d |e |f |
---------+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+------------
0x000000: 18 05 20 00 01 02 03 02 0c 53 4a 33 4d 43 ff 0d   .. ......SJ3MC..   
0x000010: 0b 00 75 00 32 2e 30 30 2e 30 36 00 34 0a 00 00   ..u.2.00.06.4...   
0x000020: 00 00 00 20 d1 6e                                 ... .n             
*****************
********  k5 command hexdump [obf_len:44 clear_len:36 crc_ok:0 **********
## obfuscated ##

@kamilsss655
Copy link

Ohh, I see this is fixed in main. Sorry and thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants