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

Haldex Flashing struggles #144

Open
KiethBurton69 opened this issue Sep 25, 2024 · 47 comments
Open

Haldex Flashing struggles #144

KiethBurton69 opened this issue Sep 25, 2024 · 47 comments

Comments

@KiethBurton69
Copy link

KiethBurton69 commented Sep 25, 2024

Hi,

I cant get the Haldex flasher to flash past block 1 using CLI in vs code python v3.11.

I have a complete modified dump i need to flash but also cant get any FRF's to flash. The driver block 0 will flash fine but it then gives up, have you got any ideas? I have a "dashing module not loaded" message at the top of the terminal however all other functions are working as intended i have comms with interface and controller.

flash.log
flash_details.log

Please find logs attached

Thanks

@ConnorHowell
Copy link
Contributor

Could you send over the files you're trying to flash? Preferably the first file you tried to flash? The log is showing as every single checksum being incorrect which doesn't sound right...

@KiethBurton69
Copy link
Author

KiethBurton69 commented Sep 25, 2024

Hi Connor,

Here is the files, it gives the same checksum errors when flashing the mod. My plan was to flash the frf which is the same version on the controller currently to ensure a complete flash and then the mod.

Thanks

@KiethBurton69
Copy link
Author

KiethBurton69 commented Sep 25, 2024

I also tried removing the checksum checks as @threepotMR2 did in the bin.py file as both the odx and mod file dont need any checksum corrections i need it to flash untouched.
flash.log
flash_details.log

I tried again with all normal code in place and it gets stuck even sooner here is logs

@KiethBurton69
Copy link
Author

udsoncan.log
Looking at the uds log its returning a conditions not correct error before aborting, which is odd because the driver block meets conditions and flashes no problem. This is a 2019 S3 8V which requires the hood to be open while flashing. Have you had any issues like this on the later years?

@threepotMR2
Copy link

threepotMR2 commented Sep 25, 2024

It will not flash for me either, it fully completes the write, but then the module is bricked (party time!)
I've tried it twice.
I will dump a failed written until later tonight.

@KiethBurton69
Copy link
Author

KiethBurton69 commented Sep 25, 2024

@threepotMR2

Thanks for extracting it! Thats odd it actually fully flashed for you but bricked, did you leave checksum alone? Also ive just realised you will have the mod file please keep that to yourself as it was super expensive to obtain :) I just need to figure out a way to flash it which is my main obstacle. The only reason i wanted to flash the odx was to insure it could complete the process.

@threepotMR2
Copy link

threepotMR2 commented Sep 25, 2024

I will have a play either later tonight or tomorrow.
Yes I let VW_flash do whatever check summing it fancied.

@threepotMR2
Copy link

threepotMR2 commented Sep 25, 2024

My two units are soft bricked because the last block of data has not been written.

I've messed with alot of these Gen 5 haldex files, and this file is the only one I've seen so far with data after that 0x4DBF0 line with the checksum at the end.

@bri3d
Copy link
Owner

bri3d commented Sep 25, 2024

I think that what's going on here is twofold:

  • This RS3 file has been tampered with in various ways to cross-flash back onto a Golf R successfully
  • The VW_Flash Haldex support was written with only Golf R files as a base (you'll note this K version is not in the Flashdaten, so we never had it as a sample), so it does not understand this weird extra data after the "version" block. I think this is the issue with the Transporter files too.

Connor's going to look into fixing up the flasher to support variable-length blocks; no other control unit really does this thing where different versions are flashed as different sizes.

@threepotMR2
Copy link

threepotMR2 commented Sep 25, 2024

There is only 1 table that has actually been modified in this file, and its a DTC/fault code table that's has some codes deleted out of it.

So I'd say that is almost certainly correct that its the RS3 file fudged to run on the MQB's golf/a3/tt etc.

@ConnorHowell
Copy link
Contributor

There is only 1 table that has actually been modified in this file, and its a DTC/fault code table that's has some codes deleted out of it.

Screenshot at 2024-09-25 21-40-16

So I'd say that is almost certainly correct that its the RS3 file fudged to run on the MQB's golf/a3/tt etc. 100% the source of this file is the 0CQ907554K__7762

Yep this is definitely it, noticed that earlier! These are all U112200 codes so almost certainly just to facilitate the cross flash onto an RS3 file

@ConnorHowell
Copy link
Contributor

@threepotMR2 @KiethBurton69 I've just done some really hacky changes to make it use variable lengths for the ASW & VERSION blocks on my fork (https://github.com/connorhowell/vw_flash)

Passing a bin file to either the CLI or GUI will now take the block lengths from the checksum header instead of assuming a fixed length.

@threepotMR2
Copy link

@ConnorHowell I'll give it a blast now and see how many more I can brick today.

@KiethBurton69
Copy link
Author

@threepotMR2 how did you get on? I still cant get it to flash it does not even attempt the first block now just fails. Here are the logs. Im using this prompt in the cli python VW_Flash.py --action flash_bin --input_bin "INSERT FILE" --interface J2534 --unsafe_haldex

Tried using the gui also but it rejects the file as not being a valid bin or frf, does it make a difference that the mod file is saved in hex? I tried converting to bin also but thats the same outcome

flash.log
flash_details.log
udsoncan.log

@ConnorHowell
Copy link
Contributor

@threepotMR2 how did you get on? I still cant get it to flash it does not even attempt the first block now just fails. Here are the logs. Im using this prompt in the cli python VW_Flash.py --action flash_bin --input_bin "INSERT FILE" --interface J2534 --unsafe_haldex

Tried using the gui also but it rejects the file as not being a valid bin or frf, does it make a difference that the mod file is saved in hex? I tried converting to bin also but thats the same outcome

flash.log flash_details.log udsoncan.log

Yep absolutely matters that it's a .hex, even converting that to a bin file won't put the data in the places that VW_Flash expects, I'll email you over your files in the correct format shortly.

@threepotMR2
Copy link

threepotMR2 commented Sep 26, 2024

exactly this ^^^^

It will never write with vw_flash because its file size and formatting isn't correct.

But worry not, this is 100% flash-able with a bit of playing.

I faied to write it last night as at the same time I went to my lab at 11pm last night Github had some problem and was down. But at some point later today I will have a play and get it working - but its two stages to get it working. Firstly we have to hope @ConnorHowell's testing purposes fixes to the flash tool which have been aptly called "[haldex hack]" actually work, and then that the file correctly checksums when it is written as your mod file has the checksums missing.

@threepotMR2
Copy link

threepotMR2 commented Sep 26, 2024

Did you dump this hex file yourself from a control unit?

@KiethBurton69
Copy link
Author

@threepotMR2 how are you un bricking modules, using Odis or the miniwriggler?

@ConnorHowell
Copy link
Contributor

@threepotMR2 how are you un bricking modules, using Odis or the miniwriggler?

Only the miniwiggler will allow you to unbrick (it's what you'd usually call a boot mode on commercial tools), you should just be able to flash the .hex file you have to get it back to a working state.

@threepotMR2
Copy link

threepotMR2 commented Sep 26, 2024

If they are "soft bricked" as I call them, as in it will no longer comm but it will still talk to miniwiggler, then you can write the broken blocks with miniwiggler.

But if they cannot be communicated to with miniwigger I just chuck them in the drawer for parts... a person more clever than me will be able to unbrick them with the infineon CAN bootloader but I've not invested the time to get that working yet. Just figuring out the miniwiggler stuff that I shared on nefmoto took many many nights.

@ConnorHowell
Copy link
Contributor

@threepotMR2 I think you're going to need a bigger drawer soon lol

Interesting those aren't recoverable with a miniwiggler though...

@threepotMR2
Copy link

If mess with some of the earlier memory blocks then the Jtag bootloader doesn't work. So be very very careful which blocks you choose to write with miniwiggler/memtool.

Not all those boards were bricked, some are just too badly corroded or burnt out.

If you are writing using vw_flash then you cannot hard brick a Haldex controller, it can only be soft bricked, because it seems like it stays away from erasing those blocks.

@threepotMR2
Copy link

threepotMR2 commented Sep 26, 2024

You are better doing a full read, in both hex and bin format.... then post it here, then I'll direct you to only write those broken blocks

@threepotMR2
Copy link

threepotMR2 commented Sep 26, 2024

You need to write just the area C0B400 to C0EFFF

It still has the data between C0B410 to C0EFFF from the old "mod" flash.

e.g. FLASHDATA_Addr_0002.bin section never was written.

@threepotMR2
Copy link

I've always wondered why if I try to erase/write the full chip with Memtool then it always stops connecting via JTAG.
Maybe this in the datasheet has something to do with it....

Screenshot at 2024-09-27 00-09-47

"DBGPRR value in Flash addr. C001F0 H"
"The last column of this table shows the value, which must be written into Flash location C001F0 H"

When I erase the block 0 being c00000 to c00FFF it fills that whole area with 00 bytes which means the DBGPRR value is 0000h being "Debug Interface = not available"

Block 0 upto end of to Block 8 being C08FFF contain the same data in every Gen 5 VAG haldex or VAQ ediff controller, it is the start of the internal program, its some kind of boot loader or something.

So I would guess NEVER NEVER NEVER try to erase Block 0 = C00000 to C00FFF
And Basically only flash block 9 onwards.

@threepotMR2
Copy link

Also found this late last night in the document (xc27x4X_Errata_Sheet_v1.7.pdf) :-

Screenshot at 2024-09-27 08-45-21

@threepotMR2
Copy link

Here is a video showing how to program only a selection of blocks at a time.

https://www.youtube.com/watch?v=4pfTHcWgl7Y

@gt-inno
Copy link

gt-inno commented Sep 27, 2024

Is there any public pinout diagram for the haldex connection with miniwiggler ?

@KiethBurton69
Copy link
Author

KiethBurton69 commented Sep 27, 2024

Here is a video showing how to program only a selection of blocks at a time.

https://www.youtube.com/watch?v=4pfTHcWgl7Y

Well thats made me feel stupid the second i saw you select the sections it clicked, thank you! Only issue im having now is that it wont begin erasing and fails. Reads out fine and the first 8 bytes are intact so should flash fine.

image

@threepotMR2
Copy link

@gt-inno

Jteg%20Boot%20Pins%20for%20Gen%205%20Haldex

@gt-inno
Copy link

gt-inno commented Sep 27, 2024

@threepotMR2 Thank you.

@bri3d
Copy link
Owner

bri3d commented Sep 27, 2024

"DBGPRR value in Flash addr. C001F0 H" "The last column of this table shows the value, which must be written into Flash location C001F0 H"

When I erase the block 0 being c00000 to c00FFF it fills that whole area with 00 bytes which means the DBGPRR value is 0000h being "Debug Interface = not available"

Block 0 upto end of to Block 8 being C08FFF contain the same data in every Gen 5 VAG haldex or VAQ ediff controller, it is the start of the internal program, its some kind of boot loader or something.

So I would guess NEVER NEVER NEVER try to erase Block 0 = C00000 to C00FFF And Basically only flash block 9 onwards.

Have you tried using the HWCFG pins to pull the device into CAN or UART Bootstrap Loader mode rather than using debug (JTAG) to access Flash? Bootstrap Loader should always work regardless of the state of Flash, and should allow these "hard bricked" units to be recovered.

@threepotMR2
Copy link

I am confident the CAN bootstrap loader is still accessible, and will probably be a more straight forward method to manipulate the flash, as looking at the PCB config resistors its setup to be in CAN BSL from the factory. With a good tool we should be able to just plug in to the external haldex connector and do the CAN BSL.

If there is some easy to use software and some supported CAN interface you suggest I will happily buy it and play. I do not have any software tools or hardware to try the CAN bootstrap method.

@bri3d
Copy link
Owner

bri3d commented Sep 27, 2024

I am confident the CAN bootstrap loader is still accessible, and will probably be a more straight forward method to manipulate the flash, as looking at the PCB config resistors its setup to be in CAN BSL from the factory. With a good tool we should be able to just plug in to the external haldex connector and do the CAN BSL.

If there is some easy to use software and some supported CAN interface you suggest I will happily buy it and play. I do not have any software tools or hardware to try the CAN bootstrap method.

For CAN development I use a Raspberry Pi with a CAN hat and SocketCAN, programmed in Python.

I believe https://github.com/bri3d/TC1791_CAN_BSL/blob/main/bootloader.py#L303 is the same protocol for XC2000 as Tricore (XC2000 is basically our good enemy C167 with Tricore peripherals synthesized onto it).

But, of course, a C167-compatible BSL binary will need to be compiled.

https://www.infineon.com/dgdl/ap1616410_XE16x_FlashViaCANBSL.pdf?fileId=db3a3043243b5f1701245769271d09cc covers this in depth.

It sounds like the Hitex debug tool HiTOP53-UConnect-XE164 can also do this using provided software, but it is probably more of an expensive pain in the ass to find all of this stuff than to write a little BSL binary like I did for Tricore (famous last words... C167 is so evil...).

@threepotMR2
Copy link

I have been hunting for an Infineon Uconnect for about 2 years on and off. There is a proper infineon CAN flashing file driver for minimon that I found years ago, but the Uconnect usb dongle eludes me!

The dutch guy who is vd Veer Engineering I think has managed to do CAN BSL stuff on these. But again he is good at programming like yourself - I am just a mere bodger.

@gt-inno
Copy link

gt-inno commented Sep 27, 2024

I have been hunting for an Infineon Uconnect for about 2 years on and off. There is a proper infineon CAN flashing file driver for minimon that I found years ago, but the Uconnect usb dongle eludes me!

The dutch guy who is vd Veer Engineering I think has managed to do CAN BSL stuff on these. But again he is good at programming like yourself - I am just a mere bodger.

We had only problems with his controller though... DTCS, Burnt clutches etc..

@threepotMR2
Copy link

The controller isn't perfect, it is a man in the middle attack. But he is a very clever guy to get as far as he has with that project! PCB design, embedded software, reverses engineering all the CAN analytics, and the phone app - that's pretty good going for one guy as a side project. The clutches will always get nailed if you use them outside of OEM application, Haldex is really designed to get a Yeti or a Tiguan out of the snow. Haldex is not a real 4wd system, if people want to play with high power 4wd they need a central differential not a clutched PTO.

@threepotMR2
Copy link

threepotMR2 commented Oct 1, 2024

Hello @ConnorHowell

There is some other issue with VW_Flash that is a slight problem, so when you have an unsuccessful flash that correctly writes the C10000 area OK but there is an error in the C0B400 area, the haldex ECU will connect via UDS, it'll give you its part number, but it will not reply with fault codes or anything else.

When you try to do a flash, it always checks for fault codes, and when they are partially corrupted like this you cannot recover it with VW_Flash..... but I can write them with VCP instead luckily. I think we need VW_Flash fixing so it does not check the fault code status first.

@KiethBurton69
Miniwiggler will not write those earlier blocks either for me on some units, but it will always write the C10000 and onwards. If that area is fixed then VCP will write a standard FRF file to the whole unit which get you the unit working again, and if Connor can can address that problem above then VW_Flash will be able to recover it too.

Also can you please email me the files formatted by Connor as I can't seem to get this file flashed with the files formatted by myself and its driving me nuts! I'm obviously doing something stupid.

@KiethBurton69
Copy link
Author

Hi @threepotMR2

I see! Recovery with VW Flash would be super handy as its a pain getting the module setup on the bench.
Send me your email and ill fire them over, i have access to early non public Sgo files if needed however they are not cheap. I have been waiting on another test car to arrive to test Connors last tweak. On friday i managed to set fire to my miniwriggler by moving power pins and shorting it while live lol, new one is here now and i have another haldex module so can mess around getting the other going another day. Test car will be here Thursday but let me know if you have success flashing our modified file.

@threepotMR2
Copy link

threepotMR2 commented Oct 1, 2024

@KiethBurton69

threepot@hotmail.co.uk

I am experimenting with xprog which is has support for this micro and I think it works over CAN.

@ConnorHowell
Copy link
Contributor

@threepotMR2

Interesting, I believe it's only trying to erase codes but is probably causing the issue. Erasing codes is usually a prerequisite to flashing some ECUs which is why VW_Flash will try to do it. I'll push a commit to my branch shortly to skip that step for the Haldex; then once it's all confirmed working I just need to fix all my hacky code lol!

Regarding the RS3 file, an sgo file is what you'd normally have for pre-uds control modules. FRFs are what is used for anything modern, these are essentially encrypted zip files that contain an ODX file which contains the flash procedure and everything required to perform the flash (data, encryption/compression identifiers, checksums etc.)

To be honest it would be trivial to fix the checksums in a haldex file, update the flash checksums & data in the ODX and use that with VCP to flash a modded file.

@threepotMR2
Copy link

threepotMR2 commented Oct 1, 2024

This is killing me! It will not flash the modded.bin or stock.bin.

I always get the partial brick problem... comms but not properly....

broken
broken3
broken2

here are my logs.... help!!

flash.log
flash_details.log
udsoncan.log

Its always that FD_3Data area, something isn't playing ball.

But this does go to show, that as long as FD_2Data writes OK you always end up with functioning comm's with the unit - e.g. you can screw up FD_1 or FD_3 then it still recovers OK with VCP.

@bri3d
Copy link
Owner

bri3d commented Oct 1, 2024

Try changing STMin_TX

@KiethBurton69
Copy link
Author

KiethBurton69 commented Oct 1, 2024 via email

@threepotMR2
Copy link

threepotMR2 commented Oct 1, 2024

@KiethBurton69 Yes, it never works for me... (do you have VCP too?)

@bri3d I've just changed STMIN_TX to 200 and its done the same. I'll try it at 400 instead.

But I don't think its a hardware issue, I think its something screwed up with the variable size block 4 data.

@ConnorHowell I've just packed an SGO file as you suggested and VCP has wrote it first time.

@ConnorHowell
Copy link
Contributor

Wasn't an stmin issue, I was only half overriding the block lengths. @threepotMR2 try the latest change on my fork.

@threepotMR2
Copy link

@ConnorHowell It works!

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

No branches or pull requests

5 participants