travisgoodspeed / md380tools

Python tools and patched firmware for the TYT-MD380
803 stars 244 forks source link

flipped screen on MD390, new Vocoder, no GPS #178

Closed iball closed 8 years ago

iball commented 8 years ago

Pulled down the latest md380tools as of 16JUL16 @ 1227hrs CST and flashed my MD-390 that does NOT have a GPS.
Now the screen is flipped upside down and the text is all backwards. Everything works just fine except for that, even loading the DMR ID database (i.e. users.csv). I'm kind of laughing about the whole thing myself. So strange. img_0049

iball commented 8 years ago

Additional notes: Upgrade was performed on a brand-new, never used, fresh-from-the-box MD-390 that does not have a GPS module.
Upgrade was performed using latest md380tools on a fully-updated Raspberry Pi 3. Even flashed the latest from https://pd0zry.nl/md380-fw/ just to see if my development environment was somehow screwed up but while it flashes just fine, it exhibits the same exact behavior of a flipped and upside-down screen.

travisgoodspeed commented 8 years ago

Howdy!

Which version of firmware did the radio have when it arrived? Do you see the same problem when running unmodified, stock firmware from the manufacturer?

Cheers from New York, -Travis

iball commented 8 years ago

It had the 13.09 firmware on it and it was fine out-of-the-box. Don't see the problem at all with stock firmware.

iball commented 8 years ago

Yup, just reflashed D013.009 back on it and the screen is now normal. But putting the latest flashed firmware on it makes the screen flip upside-down and backwards.

d235j commented 8 years ago

Does the D013.020 firmware work properly?

iball commented 8 years ago

I have not flashed the D013.020 on it, just kept it on the .009 for now. To be honest, I have no idea which of the "new" firmwares to use what with all this "new" and "old" vocoder stuff.
To be honest, I have no idea which radio I have - the MD-390 no-gps-new-vocoder or the MD-390 no-gps-old-vocoder.

iball commented 8 years ago

Nevermind, I've figured out the difference with the vocoders. Really, Tyt? Really? You make it this psychotic to figure out?

iball commented 8 years ago

Works just fine with the new vocoder firmware D013.020. Just had a good chat on the BM 31201 BYRG talkgroup via the DVMEGA to test it.

aeickho commented 8 years ago

Ok, Iball With this Info: you have an "new vocoder" radio.

And with the info that D013.020 is working correctly on your radio .. I'll tray to locate differences near the display communication. There is no flip with D013.020 on both MD380.

I'm thinking that the electrical display interface on md390 is changed. .

Please confirm the facts:

Tnx for your assistance😉 Alex

d235j commented 8 years ago

@aeickho it's very possible a vocoder-patched D003.020 will work too — chances are newer versions of the firmware have support for hardware updates.

aeickho commented 8 years ago

My aplu bypass on 2.032. And D013.020 disabled not the complete alpu interface ... only functions the while 1 loops. It is possible that the radio read hardware info's /config from the dongle.

aeickho commented 8 years ago

I'll tray to compare the low level interface to the display.. good: this behaviour contains all display output.

iball commented 8 years ago

MD-390, no GPS, new vocoder - CONFIRMED

D002.032 (experimental) works....display is flipped and upside-down - CONFIRMED

No problems at all with the D013.020 firmware - CONFIRMED

iball commented 8 years ago

Rebuilt and reflashed the latest firmware using latest md380tools as of a few minutes ago. Still having the same flipped display issue. Everything else in the experimental firmware works just fine. Reloaded D013.020 on it and the display is fine again.

aeickho commented 8 years ago

I see an difference between "F_1075_display_init" D002.032 @ 0x08031fc4 and D003.020 @ 0x0803356e

on D003.020 0x08033586 is a test and this set the display command 0x36 to 0x8 (old D002.032) or 0x48

aeickho commented 8 years ago

http://www.ncsys.co.jp/webshop/GTV350MPZI04(ILI9481).pdf page 79

・ Bit B6 – Column Address Order ‘0’ = Left to Right ‘1’ = Right to Left

but... why is this clanged ? :confused:

aeickho commented 8 years ago

also command 0xfd is changed old 0x40 now 0x40 or 0x4f

but I can't find documentation about the display command: 0xfd

@iball .. you have interest? to look at a modified D002.32 (exp) whether this is "flip-probelm" then dissolved? then I write a small patch for you...
or... for us to learn more about the differences of the radios you can build fw?

iball commented 8 years ago

Well, right now I have a Raspberry Pi 3 w/7" display that's "dedicated" to just doing stuff with the md380 firmware.
I can run the md380tools set on it just fine and it flashes the radio, so I guess I could test out a patch from a separate code branch or something. Just let me know what I have to do on my end and I'll get it done.

aeickho commented 8 years ago

ok, i'll start now :)

aeickho commented 8 years ago

please checkout: https://github.com/aeickho/md380tools.git branch : display_flip_test

make clean :)

iball commented 8 years ago

OK, on it. I'll let you know what I find out.

iball commented 8 years ago

Well, I'll be - that fixed it! Of course, I wanted to check to see how your patch affects the regular MD-380 so I reflashed it as well and now the regular MD-380 is showing the backwards/flipped display. No biggie, I can always just re-clone the latest from Travis' repo and get the MD-380 sorted out right.

Now for the hard part I guess.
Adding in the code to detect the display chip in the radio so it knows whether or not to apply the patch for it?

aeickho commented 8 years ago

tnx, for testing. there are 2 temporary solutions before @travisgoodspeed has an new experimental firmware based of the lasted official images.

  1. try to understand the functionality to detect the hardware .. on D003.020 .. Handling of 0x2001dcf8
  2. make an new additional global config setting to init the display ... but the initialisation is very early.. hopefully after the handling of the read the additional global config .

@travisgoodspeed what you mean?

travisgoodspeed commented 8 years ago

Let's try and detect it for proper handling at runtime in 2.032, while we wait on proper portability between versions.

Does anyone know where to order the upside-down hardware in America or Germany?

iball commented 8 years ago

Travis,

I got mine from associatedradio.com (located in Overland Park, KS) from a ham fest yesterday in Warrensburg, MO.
Not listed on their website just yet as they just got them in.
Give them a call at 1-800-497-1457 and tell them you want one of the waterproof MD-390's that don't have a GPS. Tell them you're a friend of a friend of Chuck's (K0XM) who set up the Brandmeister repeater there.

travisgoodspeed commented 8 years ago

Thanks, Chuck. I'll give them a call on Monday, and maybe they'll be able to find an old-codec GPS unit too.

-Travis

aeickho commented 8 years ago

I think I've found it: the hw configuration is configured by the radio tuning parameters

gn

iball commented 8 years ago

I'm not Chuck, I'm just a friend of Chuck's.
Chuck is well-known round these parts.
All the locals know him. He got together with some others and they made the www.byrg.net website and repeaters.

Anyway, thanks to you and @aeickho for resolving this flipped-display issue with the MD-390 non-GPS and I hope you can get it rolled into the main soon.

aeickho commented 8 years ago

tuning parameter +0x1d &0x1

aeickho commented 8 years ago

f2

;) product of thinking errors

aeickho commented 8 years ago

f2

aeickho commented 8 years ago

@iball please check with your "md390, old vocoder, no gps"

and reopen this issue if problem not solved

iball commented 8 years ago

@aeickho I will check once I get home from work, probably in about 6 hours from now. And this is the MD-390 with the new vocoder, no GPS, remember? Here's what I'll do - I'll pull down the latest code from github and reflash both my MD-390 and my MD-380 and let you know what I'm seeing.
Heck, I'll even throw in testing it with the MD-380 VHF unit as well. :-)

aeickho commented 8 years ago

the patch is on travis/master yes please check him with your MD-390 ... on MD-380 the patch make no changes, i hope so ;)

iball commented 8 years ago

Nope. The MD-390 screen is flipped and backwards with this update. The MD-380 is fine as always.

aeickho commented 8 years ago

this is bad

aeickho commented 8 years ago

D003.020

|           0x08033586      6748           ldr r0, [pc, 0x19c]         ; [0x8033724:4]=0x2001dcf8                           
|           0x08033588      407f           ldrb r0, [r0, 0x1d]                                                              
|           0x0803358a      c007           lsls r0, r0, 0x1f                                                                
|       ,=< 0x0803358c      03d5           bpl 0x8033596               ;[4]                                                 
|       |   0x0803358e      0820           movs r0, 8                  ; 8                                                  
|       |   0x08033590      fff7d0ff       bl F_835_Write_Data_2display ;[3]                                                
|      ,==< 0x08033594      02e0           b 0x803359c                 ;[5]                                                 
|      |`-> 0x08033596      4820           movs r0, 0x48               ; 'H' ; 72                                           
|      |    0x08033598      fff7ccff       bl F_835_Write_Data_2display ;[3]                                                
|      `--> 0x0803359c      fe20           movs r0, 0xfe               ; 254                                                
|           0x0803359e      fff7c5ff       bl F_834_Write_Command_2display ;[2]     

New function for D002.032

/ (fcn) fcn.080a0348 20                                                                                                                                                                
|  ||||||   0x080a0348      044b           ldr r3, [pc, 0x10]          ; 0x80a035c:4]=0x2001d39b                                                                                      
|  ||||||   0x080a034a      5b7f           ldrb r3, [r3, 0x1d]                                                                                                                         
|  ||||||   0x080a034c      db07           lsls r3, r3, 0x1f                                                                                                                           
| ,=======< 0x080a034e      02d4           bmi 0x80a0356               ;[1]                                                                                                            
| |||||||   0x080a0350      0820           movs r0, 8                  ; 8                                                                                                             
| |||`====< 0x080a0352      91f713be       b.w F_835_Write_Data_2display ;[2]                                                                                                          
| `-------> 0x080a0356      4820           movs r0, 0x48               ; 'H' ; 72                                                                                                      
\  || `===< 0x080a0358      91f710be       b.w F_835_Write_Data_2display ;[2]   
aeickho commented 8 years ago

@iball please try the next experiment

if this patch also not working now ... I'm :confused:

iball commented 8 years ago

Did you do a fresh commit?

aeickho commented 8 years ago

yes ... https://github.com/travisgoodspeed/md380tools/commit/6c476b270fa8281c5ea926ef1c42a42996405e51

iball commented 8 years ago

Alrighty then, I'll flush my current md380tools directory and clone it new and try it out. Gimme a few minutes...

iball commented 8 years ago

Nope. Still upside-down and flipped backwards.

aeickho commented 8 years ago

ok, tnx for your assistance, I'll learn tomorrow more about the tuning parameter ..

iball commented 8 years ago

No problem. I'm around if you need further testing.

aeickho commented 8 years ago

.... trouble with radare2, wrong offset calc :(

aeickho commented 8 years ago

https://github.com/radare/radare2/issues/5347

aeickho commented 8 years ago

reverse engineering by hand

on D003.020 @ 0x8033586 .. 0x8033724 -> 2001dcf8

0x80230e4 0x2001dcf8
0x8033724 0x2001dcf8
0x808f7c0 0x2001dcf8
0x80903cc 0x2001dcf8
 802253a:       f8df 0ba8       ldr.w   r0, [pc, #2984] ; 0x80230e4
 8022542:       f8df 0ba0       ldr.w   r0, [pc, #2976] ; 0x80230e4
 8022560:       f8df 0b80       ldr.w   r0, [pc, #2944] ; 0x80230e4

 8033586:       4867            ldr     r0, [pc, #412]  ; (0x8033724)
 80335c6:       4857            ldr     r0, [pc, #348]  ; (0x8033724)

 808f3f0:       f8df 23cc       ldr.w   r2, [pc, #972]  ; 0x808f7c0
 808f42a:       f8df 1394       ldr.w   r1, [pc, #916]  ; 0x808f7c0

 808f8a8:       f8df 2b20       ldr.w   r2, [pc, #2848] ; 0x80903cc
 808f97e:       f8df 1a4c       ldr.w   r1, [pc, #2636] ; 0x80903cc
 0x08022534      4022           movs r2, 0x40               ; '@' ; 64                             
 0x08022536      4ff44051       mov.w r1, 0x3000                                                   
 0x0802253a      dff8a80b       ldr.w r0, [pc, 0xba8]       ; **[0x80230e8:4]=0xb2c0b580 Wrog **             
 0x0802253e      0ff0b7f9       bl spiflash_Read_Security_Registers_48h ;[1]                       

ok is on spiflash_Read_Security_Registers_48h . 0x3000

D002.032
 0x08021656      4022           movs r2, 0x40
 0x08021658      4ff44051       mov.w r1, 0x3000
 0x0802165c      dff8880b       ldr.w r0, [pc, 0xb88]       ; [0x80221e8:4]=0x2001c974
 0x08021660      0ef0acfd       bl spiflash_Read_Security_Registers_48h

ok try next try 0x2001c974

-> https://github.com/travisgoodspeed/md380tools/commit/b2ba501751aabfa5a768494139f519baad45decb

iball commented 8 years ago

@aeickho I can test this later today when I get off work in about 7 hours if you'd like.

aeickho commented 8 years ago

Sounds great. Give it a go.

iball commented 8 years ago

Testing it now.