Hints for the patch writers
#1
Evolved Member
Thread Starter
Hints for the patch writers
Tools
KPIT Cummins is a good assembler - I write using notepad, and then use a batch file to assemble and link "latestasm.txt" to "test.hex" which I then load into...
xvi32 is a good hex editor which I use to copy the patches from their assembled and linked files into the correct place in the ECU flash image.
IDA Pro is a good check to disassemble your patch to make sure you branch correctly and that your data is all aligned.
simsh from Lauterbach (download the demo, then just close the c application it opens with, load your hex file, open the registers and dump window and you can step through your code - you can change the PC and register values to get it to simulate all sorts of scenarios).
Common errors
Reading/writing the wrong type whether byte, word or long
Forgetting that an address is always long
Forgetting to indirect to read the contents of an address rather than just the address
If reading a byte and then writing it as a word or long, or reading a word and writing it as a long, make sure you do an extu.b or extu.w to avoid old rubbish from the top of the register being written to your variable
Not pushing all the registers used in interrupts
Watch our for alignment when reading words and longs - assembler should alert
Remember the nops after the branches to look after the pipeline
More ECU specific - having your variables or hardware configurations overwritten by the ECU which helpfully housekeeps for itself, but clears up your stuff thinking it is rubbish unless you stop it!
Think about how your variables will be in a random state after a reflash or power down and plan accordingly. For example, on the realtime stuff I use a variable in RAM that doesn't get erased on engine off to record which map we have selected. I have modified an ECU loop to test that the header information for the map is present - if it isn't that set is disabled. Don't assume data integrity until you've tested it.
KPIT Cummins is a good assembler - I write using notepad, and then use a batch file to assemble and link "latestasm.txt" to "test.hex" which I then load into...
xvi32 is a good hex editor which I use to copy the patches from their assembled and linked files into the correct place in the ECU flash image.
IDA Pro is a good check to disassemble your patch to make sure you branch correctly and that your data is all aligned.
simsh from Lauterbach (download the demo, then just close the c application it opens with, load your hex file, open the registers and dump window and you can step through your code - you can change the PC and register values to get it to simulate all sorts of scenarios).
Common errors
Reading/writing the wrong type whether byte, word or long
Forgetting that an address is always long
Forgetting to indirect to read the contents of an address rather than just the address
If reading a byte and then writing it as a word or long, or reading a word and writing it as a long, make sure you do an extu.b or extu.w to avoid old rubbish from the top of the register being written to your variable
Not pushing all the registers used in interrupts
Watch our for alignment when reading words and longs - assembler should alert
Remember the nops after the branches to look after the pipeline
More ECU specific - having your variables or hardware configurations overwritten by the ECU which helpfully housekeeps for itself, but clears up your stuff thinking it is rubbish unless you stop it!
Think about how your variables will be in a random state after a reflash or power down and plan accordingly. For example, on the realtime stuff I use a variable in RAM that doesn't get erased on engine off to record which map we have selected. I have modified an ECU loop to test that the header information for the map is present - if it isn't that set is disabled. Don't assume data integrity until you've tested it.
Last edited by jcsbanks; Jan 19, 2008 at 09:48 AM.
Thread
Thread Starter
Forum
Replies
Last Post
mrfred
ECU Flash
496
Sep 14, 2022 07:08 PM
logic
ECU Flash
78
Nov 8, 2018 04:17 AM
mrfred
ECU Flash
78
Nov 22, 2014 02:39 PM
mrfred
ECU Flash
50
Feb 21, 2011 06:01 PM