RomRaider Logo

RomRaider

Open Source ECU Tools
 FAQ •  Register •  Login 

RomRaider

Documentation

Community

Developers

It is currently Tue Dec 23, 2025 11:13 am

All times are UTC - 5 hours [ DST ]





Post new topic Reply to topic  [ 48 posts ]  Go to page Previous  1, 2, 3, 4  Next
Author Message
 Post subject: Re: MS43 - Finding maps in IDA Pro?
PostPosted: Wed Feb 25, 2015 8:43 pm 
Offline
RomRaider Developer

Joined: Wed May 20, 2009 9:49 pm
Posts: 7314
Location: Canada eh!
The default c167cr memory map that comes with IDA is not accurate for the MS43 memory layout.

Attachment:
MS43.png
In reference to this memory map (my best guess) I created a custom c166.cfg file to replace the one that comes with IDA tailored for the MS43.
Save it in the "C:\Program Files (x86)\IDA 6.7\cfg\" folder.

Before you play, make a copy of your current .idb file so you can go back to what you had before.
Open your Flash read file with IDA. Select Siemens c166 family as the processor. OK all the dialogues to open the ROM, but when asked for the processor select C167CR-LM_MS43.
Once you have it open Load the script file to set the DPPs and format each segment.

You will need to manually adjust (alt-g) the value of DPP0 to assist in proper referencing of maps in the 0x70000 segment. For example:
Attachment:
DPP.PNG


Refer to the Infineon C167 User Manual to get a better understand of DPP Registers and segment addressing.


You do not have the required permissions to view the files attached to this post.


Last edited by dschultz on Thu Feb 26, 2015 10:39 am, edited 1 time in total.
Fixed IDA script syntax error


Top
 Profile  
 
 Post subject: Re: MS43 - Finding maps in IDA Pro?
PostPosted: Thu Feb 26, 2015 3:21 am 
Offline
Experienced

Joined: Sat Mar 15, 2014 6:46 pm
Posts: 276
Location: Belarus
thanks!


Top
 Profile  
 
 Post subject: Re: MS43 - Finding maps in IDA Pro?
PostPosted: Thu Feb 26, 2015 11:10 pm 
Offline
Experienced

Joined: Thu Dec 04, 2014 6:37 pm
Posts: 139
Yay! Now I need to learn how to use Ida ;)


Top
 Profile  
 
 Post subject: Re: MS43 - Finding maps in IDA Pro?
PostPosted: Fri Feb 27, 2015 4:57 am 
Offline
Experienced

Joined: Wed Aug 27, 2014 7:57 am
Posts: 259
Me too :lol:

Thank you soooo much :)

_________________
MS43 wiki

MS42 wiki


Top
 Profile  
 
 Post subject: Re: MS43 - Finding maps in IDA Pro?
PostPosted: Fri Feb 27, 2015 10:29 am 
Offline
RomRaider Developer

Joined: Wed May 20, 2009 9:49 pm
Posts: 7314
Location: Canada eh!
hobbit382 wrote:
Yay! Now I need to learn how to use Ida ;)


Cloudforce wrote:
Me too :lol:

Thank you soooo much :)


Your IDA learning curve is going to be much shorter than the learning curve to think like the C167 CPU. This is going to be your greater challenge. IDA (the memory map and segment format script I provided) only makes it easier for you to see what the CPU is being asked to do. So learn to think like the CPU, understand the various addressing schemes, the jump conditions, bit manipulation, etc. Then you can start to incorporate your understanding of the "tuning" process into your code analysis. Start with the hardware reset vector and follow along what the CPU is doing. Initially this is configuring the system and all the peripherals for the required mode of operation.


Top
 Profile  
 
 Post subject: Re: MS43 - Finding maps in IDA Pro?
PostPosted: Fri Feb 27, 2015 10:56 am 
Offline
Experienced

Joined: Wed Aug 27, 2014 7:57 am
Posts: 259
Is there somekind of "easy" comparison between whats in the flash at a certain point and where its "used" in IDA?

Is it possible to compare two different flash files directly?

_________________
MS43 wiki

MS42 wiki


Last edited by Cloudforce on Fri Feb 27, 2015 10:58 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: MS43 - Finding maps in IDA Pro?
PostPosted: Fri Feb 27, 2015 10:57 am 
Offline
RomRaider Developer

Joined: Wed May 20, 2009 9:49 pm
Posts: 7314
Location: Canada eh!
Cloudforce wrote:
Is there somekind of "easy" comparison between whats in the flash at a certain point and where its "used" in IDA?

Yes, it's right here: download/file.php?id=23555&mode=view


Top
 Profile  
 
 Post subject: Re: MS43 - Finding maps in IDA Pro?
PostPosted: Fri Feb 27, 2015 2:27 pm 
Offline
Newbie

Joined: Tue Mar 18, 2014 6:23 am
Posts: 31
Cloudforce wrote:
Me too :lol:

Thank you soooo much :)

yeah daniel it will take you 2 years just to understand what it all means.

Quote:
In reference to this memory map (my best guess) I created a custom c166.cfg file to replace the one that comes with IDA tailored for the MS43.


Thanks. What this means is that we have to start using it and see if it is correct or not and make corrections if it wrong. This could take a lot of research and testing.


Top
 Profile  
 
 Post subject: Re: MS43 - Finding maps in IDA Pro?
PostPosted: Fri Feb 27, 2015 2:38 pm 
Offline
Senior Member

Joined: Fri Feb 10, 2006 7:04 pm
Posts: 2661
Location: RIP
MS43 already has a DAMOS/A2L file available. With the memory map that Dale has figured out, it should be extremely straightforward to simply search for code that uses already known map addresses.

MS41 was very different because we didn't have known map addresses. So the code had to be analyzed to figure out what the maps were and how they interacted. This is significantly more difficult to do.

MS43 is a piece of cake in comparison.

_________________
MS41 Project Leader & Co-Developer (2012 - 2023)
MS41.3 https://sites.google.com/site/openms41/custom-code---ms41-3
MS41 ECU Portal https://sites.google.com/site/openms41/ms41-ecu-portal


Top
 Profile  
 
 Post subject: Re: MS43 - Finding maps in IDA Pro?
PostPosted: Fri Feb 27, 2015 2:40 pm 
Offline
RomRaider Developer

Joined: Wed May 20, 2009 9:49 pm
Posts: 7314
Location: Canada eh!
hakentt wrote:
Thanks. What this means is that we have to start using it and see if it is correct or not and make corrections if it wrong. This could take a lot of research and testing.
Yes, please share any info related to changes needed to the memory map and IDA definition.
Thanks


Top
 Profile  
 
 Post subject: Re: MS43 - Finding maps in IDA Pro?
PostPosted: Fri Feb 27, 2015 2:44 pm 
Offline
RomRaider Developer

Joined: Wed May 20, 2009 9:49 pm
Posts: 7314
Location: Canada eh!
mrf582 wrote:
MS43 already has a DAMOS/A2L file available. With the memory map that Dale has figured out, it should be extremely straightforward to simply search for code that uses already known map addresses.
MS43 is a piece of cake in comparison.
Agreed. The A2L file can be converted to RomRaider format and instantly we have all the maps defined. Of course that doesn't help explain the logic or use of all the maps. That's where the code analysis is needed.


Top
 Profile  
 
 Post subject: Re: MS43 - Finding maps in IDA Pro?
PostPosted: Fri Feb 27, 2015 3:31 pm 
Offline
Experienced

Joined: Wed Aug 27, 2014 7:57 am
Posts: 259
dschultz wrote:
hakentt wrote:
Thanks. What this means is that we have to start using it and see if it is correct or not and make corrections if it wrong. This could take a lot of research and testing.
Yes, please share any info related to changes needed to the memory map and IDA definition.
Thanks


:lol: Shure, he will help others... for free :roll: Profit is the only word thats important to him :wink:

_________________
MS43 wiki

MS42 wiki


Top
 Profile  
 
 Post subject: Re: MS43 - Finding maps in IDA Pro?
PostPosted: Sat Feb 28, 2015 12:55 am 
Offline
Experienced

Joined: Thu Dec 04, 2014 6:37 pm
Posts: 139
mrf582 wrote:
MS43 already has a DAMOS/A2L file available. With the memory map that Dale has figured out, it should be extremely straightforward to simply search for code that uses already known map addresses.

MS41 was very different because we didn't have known map addresses. So the code had to be analyzed to figure out what the maps were and how they interacted. This is significantly more difficult to do.

MS43 is a piece of cake in comparison.


Now that's more encouraging :)


Top
 Profile  
 
 Post subject: Re: MS43 - Finding maps in IDA Pro?
PostPosted: Mon Mar 02, 2015 8:43 pm 
Offline
RomRaider Developer

Joined: Wed May 20, 2009 9:49 pm
Posts: 7314
Location: Canada eh!
Segmentation, Pages and DPP# Example

You will need to do some reverse math to locate references to maps within code.

Remember I mentioned you need to think like the CPU and understand the segmentation?

For the MS43... It uses 1MB of linear address space.
In 1MB of memory there are 16 x 64kB segments.
Each segment has 4 - 16kB pages.
Therefore in 1MB of memory you will have 64 pages.
In code a DPP# is used to assist accessing linear memory and it contains a page reference or index.

You need 21 bits to address up to 1MB of memory.
When forming an address the CPU uses a word operand.
The top two bits 14 & 15 of the word is the DPP#.
i.e.:
00 = DPP0
01 = DPP1
10 = DPP2
11 = DPP3
The lower bits 0 - 13 is the offset within a page.
Each DPP is loaded with a value which is then combined with the page offset to form the linear memory address.
Attachment:
addressing.png


Now the math...
The map axis/data segment is from 0x70000 - 0x7FFFF. Converted to pages this is:
0x70000/0x4000 = 0x1C
0x74000/0x4000 = 0x1D
0x78000/0x4000 = 0x1E
0x7C000/0x4000 = 0x1F

Assuming the code uses DPP0 in the operand the top two bits of the word will be 00.
Therefore in binary:
00xx xxxx xxxx xxxx
Remember the xxxx's are the offset within a page.

For example, assume an axis at 0x74AD4 and data at 0x7581E, these are both within the 0x74000 (0x1D) page.
One thing to remember about the axis is that the code reference is to the axis size value not the axis values so you need to subtract 1 for byte or two for word. Let's assume the axis is word data, therefore 0x74AD4 - 2 = 0x74AD2
0x74AD2 in binary:
0111 0100 1010 1101 0010
Attachment:
calc1.png


Now remove the 0x1D page reference from the binary (remember 1D starts at bit 14 and up):
0000 0000 1010 1101 0010
Attachment:
calc2.png


In the Calculator you can toggle bits by clicking them, where I underscored in red.
You are left with 0xAD2. Since we are assuming DPP0 then we can leave bits 14 & 15 at 00, otherwise we would toggle these bits on/off depending on the DPP# in the code.

For the data address 0x7581E with 0x1D removed you are left with 0x181E.

Since IDA has no idea that this is a memory reference (since the values are loaded in a register and then a sub_ is called to process them) you will need to search for the offset and tell IDA how to view it.

Initially IDA will show the offset as a word value. In this example #0AD2 and #181E. You can Text search for those strings assuming all subroutines have been defined as code or hex search for 0AD2 and 181E.
Attachment:
search.png


In the results you can see the code line below the reference has a value of #1Dh which is the value to be loaded into DPP0 within the sub_. At the code reference to your search value you press alt-g and set DPP0 to 1D. Then at the code reference to your search value right click on the operand and set the Offset to the 0x7xxxx item.
Attachment:
setDPP.png


Rinse and repeat...


You do not have the required permissions to view the files attached to this post.


Top
 Profile  
 
 Post subject: Re: MS43 - Finding maps in IDA Pro?
PostPosted: Mon Mar 02, 2015 9:04 pm 
Offline
Newbie

Joined: Tue Mar 18, 2014 6:23 am
Posts: 31
Thank you dschultz. I will give this a try and will post results.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 48 posts ]  Go to page Previous  1, 2, 3, 4  Next

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subsilver by phpBBservice.nl