Pages: [1] 2
Author Topic: Write Read Eeprom Mirror  (Read 6003 times)
benni4000
Newbie
*

Karma: +0/-1
Offline Offline

Posts: 24


« on: August 17, 2022, 10:58:35 PM »

Hey Guys,

i am working on a MapSwitch Routine with saving choosed map in eeprom.
Map Selectin is working but i stuck at the save part to the EEPROM.


What works:
1.) When the code is saving to Eeprom and i read eeprom to check for changes i can't see any chances but the data must be saved somewhere, because even when i remove complete Power from ECU and check LastMap again the LastMap is saved/buffered correcly, even when i turn off and turn on Ignition again.
So where the data is tempoarily saved?

The Problem:
2.) Now my real problem is when Ignition is turned of for > 10s, so thats the ECU finished the After Run Cycle then data will be lost.

Does someone has an Idea to resolve?

My own Idea:
I think that's data is saved first in "Flash Eeprom" -> I've read something about that in FR.
After Ignition off > 10s the Eeprom Mirror fails CRC and that the entire reason why data is lost.
Could that be right?



Regards Benni
Logged
prj
Hero Member
*****

Karma: +1072/-481
Offline Offline

Posts: 6037


« Reply #1 on: August 18, 2022, 02:11:13 AM »

Assuming you are talking about ME7 here.

There's subroutines that write a word or byte to an eeprom page and offset.
The pages are based on a config, as is the EEPROM mirror layout.

If you use the correct subroutines to write, then there is no problem.
If you just write to a ram cell, then IIRC ME7 is not like the later ECU's and if the checksum doesn't match it's not stored.

Also obviously make sure nothing else is using that place in the EEPROM.
Logged

PM's will not be answered, so don't even try.
Log your car properly - WinOLS database - Tools/patches
nihalot
Full Member
***

Karma: +41/-3
Offline Offline

Posts: 117


« Reply #2 on: August 18, 2022, 04:02:24 AM »

in my experience, you can update ME7 EEP mirror in RAM and it will correct cks on ignition off and store to EEP.
Logged

www.tangentmotorsport.com

multimap/LC/rolling antilag for MG1/MED17/EDC17/MED9/EDC15

contact for reverse engineering services of any ECU/TCU
benni4000
Newbie
*

Karma: +0/-1
Offline Offline

Posts: 24


« Reply #3 on: August 18, 2022, 04:02:33 AM »

Yes i am talking about ME7.

Do i understand that there are subroutines which i can use to write Single Byte to Place in eeprom?

But is it possible to only changing a RAMcell + Update both RAMcell of the Crc?

Later i will check routines for writing codings.

Gesendet von meinem SM-G990B mit Tapatalk

Logged
nihalot
Full Member
***

Karma: +41/-3
Offline Offline

Posts: 117


« Reply #4 on: August 18, 2022, 04:06:36 AM »

It's easier to find EEP mirror and then just update any 1 free cell.
CRC is taken care of by the shutdown routines
Logged

www.tangentmotorsport.com

multimap/LC/rolling antilag for MG1/MED17/EDC17/MED9/EDC15

contact for reverse engineering services of any ECU/TCU
benni4000
Newbie
*

Karma: +0/-1
Offline Offline

Posts: 24


« Reply #5 on: August 18, 2022, 04:07:30 AM »

in my experience, you can update ME7 EEP mirror in RAM and it will correct cks on ignition off and store to EEP.
Do you have an example?
Then it should also work for me.

I am also sure that i am on the correct adresse because first i read address via me7logger to Check if it matches with Byte of eeprom readout and it does.

 Then i Used  next adress which was "zero" and write only this ram cell.
It works for short ignition off and on but not when the after run Routine Finished.




Gesendet von meinem SM-G990B mit Tapatalk

Logged
nihalot
Full Member
***

Karma: +41/-3
Offline Offline

Posts: 117


« Reply #6 on: August 18, 2022, 04:09:41 AM »

sorry, I worked on this long ago, don't have the sources handy.
But a lot of multimap files posted on this forum use the NVRAM method to save map slot, those should help you.
Logged

www.tangentmotorsport.com

multimap/LC/rolling antilag for MG1/MED17/EDC17/MED9/EDC15

contact for reverse engineering services of any ECU/TCU
terminator
Sr. Member
****

Karma: +15/-4
Offline Offline

Posts: 425


« Reply #7 on: August 18, 2022, 06:55:52 AM »

It works for short ignition off and on but not when the after run Routine Finished.

It works because the ECU was not powered off. It takes some seconds. 
You have to calculate CRC and insert it into the mirror.
Logged
prj
Hero Member
*****

Karma: +1072/-481
Offline Offline

Posts: 6037


« Reply #8 on: August 18, 2022, 03:05:05 PM »

in my experience, you can update ME7 EEP mirror in RAM and it will correct cks on ignition off and store to EEP.
I always did it with the OEM routines, and only used the mirror for reading.
There's a lot of configuration going on there, it's possible that not everything can be written to and the routine was a foolproof way, which is why I used it.

But it's I think 8 years ago now, I don't remember.
Logged

PM's will not be answered, so don't even try.
Log your car properly - WinOLS database - Tools/patches
benni4000
Newbie
*

Karma: +0/-1
Offline Offline

Posts: 24


« Reply #9 on: August 18, 2022, 03:23:25 PM »

Hi,

Some Infos about now:

This line is 0x60 from the EEPROM and the red bytes (0x6C) i wanna write
00 00 81 0D 2F 0E 00 00 86 03 01 00 00 00 A5 FE

This function is called when a new Maps has been selected. I've copied and edited it from other Mirror accesses but this routine seems to be working because its updating my byte i wanna write and checksum (0x6E and 0x6F) in RAM Mirror correctly like ME7Logger shows me. (If Map-Value goes Higher the CRC goes down)

Code:
sub_8B468C:
mov     r12, r4
mov     r13, #6
mov     r14, #0BD6Ch
mov     r2, #0BD00h
sub     r14, r2
and     r14, #0Fh
calls   8Ah, sub_8A120C
rets


My Var in Ram is 0x383D5C (len = 2)
CRC in Ram is 0x383D5E (len =2)

Does anyone has an Idea?
Logged
benni4000
Newbie
*

Karma: +0/-1
Offline Offline

Posts: 24


« Reply #10 on: August 18, 2022, 06:13:17 PM »

I've forgot something.

Will eeprom also be saved or ecu getting in after run when ecu is connected on bench? Just poeered,Ignition and CC Switch?
Cause when i select map and then use vcds for New coding it will be saved then.
I just have to find where its getting saved or Set a Specified Flag for ding that.

Have a nice Day!
Logged
prj
Hero Member
*****

Karma: +1072/-481
Offline Offline

Posts: 6037


« Reply #11 on: August 24, 2022, 06:31:30 PM »

If you turn off Kl 30 and ignition at once then there will never be afterrun and mirror won't be saved.
Logged

PM's will not be answered, so don't even try.
Log your car properly - WinOLS database - Tools/patches
woj
Hero Member
*****

Karma: +43/-3
Offline Offline

Posts: 500


« Reply #12 on: August 25, 2022, 05:52:07 AM »

What I did in my E85 code (the eeprom saved value was the last know ethanol content and fuel level to detect a fuel-up):

1. Made a hook-up to the init raster to read the old value from the eeprom *image*. I chose an arbitrary nullsub procedure there, replaced it with mine, and checked by testing that the eeprom image is already valid / ready at that point.
2. Made a hoop-up to the shutdown raster where I save my values directly to eeprom using the OEM functions for that (the ones that prj mentioned). Here I could not find a nullsub, so I hooked up to the procedure that saves the OBD readiness information with its own eeprom write calls.

Looking at the code I concluded (perhaps wrongly) that the eeprom image is not saved on shutdown (otherwise why would the factory routines write to the eeprom directly?). Or not all of it is saved. What is done (also concluded by common sense and what I was seeing rather than having a hard proof) is that the eeprom is checked-summed on shutdown. Hence it is important to hook up before that is done.

What you should definitely not do is to write to eeprom periodically in any of the regular rasters, due to eeprom wear-out possibility.
Logged
prj
Hero Member
*****

Karma: +1072/-481
Offline Offline

Posts: 6037


« Reply #13 on: August 25, 2022, 06:24:27 AM »

I mean there are two routines for reading - word and byte and two routines for writing - word and byte.
Almost all of the code uses those and they do sums as well.

I don't see why not use them. They do not write to EEPROM directly, they write to the mirror.
I haven't reversed the entire config, but I think it depends on page. Some pages check the sums when saving some don't.
Logged

PM's will not be answered, so don't even try.
Log your car properly - WinOLS database - Tools/patches
woj
Hero Member
*****

Karma: +43/-3
Offline Offline

Posts: 500


« Reply #14 on: August 25, 2022, 07:25:42 AM »

I mean there are two routines for reading - word and byte and two routines for writing - word and byte.
Almost all of the code uses those and they do sums as well.

I don't see why not use them. They do not write to EEPROM directly, they write to the mirror.
I haven't reversed the entire config, but I think it depends on page. Some pages check the sums when saving some don't.

That's what I meant too. I reversed it a long time ago so forgot most of it, what I seem to remember is that it queues up an actual eeprom write that happens periodically,  and I guess then updates the mirror while at it. Or updates the mirror and marks the row as changed and needing writing, or something like this.

In any case, this is what should be used.
Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Page created in 0.022 seconds with 17 queries. (Pretty URLs adds 0.001s, 0q)