RomRaider Logo

RomRaider

Open Source ECU Tools
 FAQ •  Register •  Login 

RomRaider

Documentation

Community

Developers

It is currently Sat Feb 21, 2026 10:05 pm

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Need a bit of help tracing the neutral position switch
PostPosted: Sat Dec 14, 2013 3:13 am 
Offline
RomRaider Donator

Joined: Thu Dec 29, 2011 2:04 am
Posts: 181
Hi guys,

So as some of you may have noticed, I am slowly trying to pick up reverse engineering skills. I was able to get some of the stuff that I needed for my own purpose done but I recently had someone ask me to see if I could take a look at inverting the polarity of the neutral position switch on a specific JDM ECU because, apparently, some transmissions have it reversed. Anyway, I figured, maybe I can do this ...

First thing I realized is that the CAL ID the person is looking at using is a 16 bit rom ... I have only so far played with the sh7058 so that took me back a few steps. Anyhow, my plan was to trace back the IO location for that sensor through the SSM functions. Using Dshultz scripts and documantation (you rock dude), I was able to figure out I think where the function I am interested in is located namely

PtrSSM_switches_4_5_x_6...

Image

I assume this points out to a ram variable where the switch state is stored ?

If my assumption is correct, I tried to locate where in the code that ram variable is set and I found this section, looking at the logic, seems to make sense

Image

So the information that I would be after would be this :

Neutral position switch is switch 4, its either the MSB or LSB assuming MSB

Code:
ROM: 1A3EE brclr 0x0F9, Z, #40h, loc_1A3F6


I am still not 100% on how the addressing on the 16 bit ECU work and I would like someone to explain me what 0x0F9 resolves to ? Another RAM variable, a GPI ??? I'll spend more time looking at the CPU documentation but maybe some quick guidance would make alot of difference for me.

Could anybody, sorta peer review my thought process and give me a pointer as to how to resolve the 0x0F9 address ?

Thanks !


Top
 Profile  
 
 Post subject: Re: Need a bit of help tracing the neutral position switch
PostPosted: Sat Dec 14, 2013 3:49 am 
Offline
RomRaider Donator

Joined: Thu Dec 29, 2011 2:04 am
Posts: 181
Assuming I am not wrong in my previous assumption, looks like 00F9 is another ram variable which is set sepending on what's at 0x0898 bit 1 ...

Do we have a part number/spec of the processor that is being used on the 16 bit, I am using a generic M68H16 datasheet to figure out what the instruction are but it would be nice to see how the IO are mapped on that particular chip ? From quickly reading a dshultz post, looks like address are dependent on some register settings, I am not taking any of that into account right now so I could be looking at completely the wrong thing ...

Thanks


Top
 Profile  
 
 Post subject: Re: Need a bit of help tracing the neutral position switch
PostPosted: Sat Dec 14, 2013 2:30 pm 
Offline
RomRaider Donator

Joined: Thu Dec 29, 2011 2:04 am
Posts: 181
Seems like this has been done numorous times. I'll check my thought process looking at those images


Top
 Profile  
 
 Post subject: Re: Need a bit of help tracing the neutral position switch
PostPosted: Sat Dec 14, 2013 3:55 pm 
Offline
RomRaider Developer

Joined: Thu May 21, 2009 1:49 am
Posts: 7323
Location: Canada eh!
whitewater wrote:
Code:
ROM: 1A3EE brclr 0x0F9, Z, #40h, loc_1A3F6


All references to RAM are indexed using X, Y, Z as the high nibble to the base word (20 bit addressing).
So in the case above the opcode above is to clr the bit in the byte stored at 0xZ00F9 using the bit mask 0x40 (i.e.: bit 6).
In all cases accessing RAM X, Y, Z will be 2.
Y is used 99% of the time to access Tables to lookup data.
Z is often used to emulate the SP when in certain subs.

If you right click on the operand 0x0F9 you can usually force the addition of the index register by selecting the appropriate Offset.
I made a script (Convert16bitOperand.idc) that you can tie to a function key in IDA that will do the hard work.

To find the switch real address work back through the SsmGet_Switches sub and locate: staa Ssm_Switches_4_5_x_6_7_8_9_x, Z
You want to find where it sets or clears bit 7 (0x80) and what triggers that.
Once you find that source trigger bit/byte, create an Enum and then you can go mark all the locations that use the same combination.
Code:
00000001 ; enum Enum_Flags_217C4 (bitfield) (width 1 byte)
00000001 NPS:             set 1


Top
 Profile  
 
 Post subject: Re: Need a bit of help tracing the neutral position switch
PostPosted: Sat Dec 14, 2013 6:04 pm 
Offline
RomRaider Donator

Joined: Thu Dec 29, 2011 2:04 am
Posts: 181
Thanks Dale, found your script and got it to work. I also found this thread and it confirmed that I wasn't super far from tracing it back

viewtopic.php?f=15&t=8540

After chasing a few variable down, I could locate the ram variable/logic that is mentioned in the thread above and stop there. But it seems to be another RAM variable that is affected by some other logic, I'd really like to trace this all
back to the IO port just to make me feel better about this (Not my car so I can't really run it an verify assumptions by logging ram variable).

The only logic that I could find that set this variable look like this (Variable is at 0x20893):

Code:
ROM:1B0E                 ldaa    #1
ROM:1B10                 jsr     sub_1D86
ROM:1B14                 pshm    D
ROM:1B16                 eora    unk_20893, Z
ROM:1B1A                 tab
ROM:1B1C                 anda    unk_20892, Z
ROM:1B20                 comb
ROM:1B22                 andb    unk_20893, Z
ROM:1B26                 aba
ROM:1B28                 staa    unk_20892, Z
ROM:1B2C                 pulm    D
ROM:1B2E                 staa    unk_20893, Z


White the following subroutine in the middle

Code:
ROM:1D86 sub_1D86:                               ; CODE XREF: sub_1A9A+52p
ROM:1D86                                         ; sub_1A9A+76p ...
ROM:1D86                 ldab    #0Fh
ROM:1D88                 tbyk
ROM:1D8A                 ldy     #0FA00h
ROM:1D8E                 pshm    CCR
ROM:1D90                 orp     #0E0h
ROM:1D94                 andp    #0FFFFh
ROM:1D98                 oraa    #80h
ROM:1D9A                 staa    28h, Y
ROM:1D9C                 ldaa    #0
ROM:1D9E                 staa    2Dh, Y
ROM:1DA0                 bclr    19h, Y, #10h
ROM:1DA4                 mul
ROM:1DA6                 nop
ROM:1DA8                 nop
ROM:1DAA                 ldaa    2Bh, Y
ROM:1DAC                 bset    19h, Y, #10h
ROM:1DB0                 pulm    CCR
ROM:1DB2                 rts



Could this be an IO subroutine ? Do we have a spec or part # for that CPU so I can get an IO of how IO interface work for this ECU. EDIT : Maybe these micro don't have GPIO and rely on external component attached to a BUS to perform those task.

Could could be heading into the wrong direction ...

Thanks


Last edited by whitewater on Sat Dec 14, 2013 6:51 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Need a bit of help tracing the neutral position switch
PostPosted: Sat Dec 14, 2013 6:07 pm 
Offline
RomRaider Donator

Joined: Thu Dec 29, 2011 2:04 am
Posts: 181
Just for completeness, I believe that what the thread I linked to is suggesting is to change the mask at 0x1c02 from 0xF7 to 0xF6 to invert the logic.
Code:
ROM:1BFE                 ldaa    unk_20892, Z
ROM:1C02
ROM:1C02 NPS_BIT:
ROM:1C02                 eora    #0F7h                              # Change this ...
ROM:1C04                 brclr   byte_200E4, Z, #10h, loc_1C0E
ROM:1C0A                 anda    #0FFh
ROM:1C0C                 bra     loc_1C22


Now as I said, I'd still like to trace 0x20892 to the actual IO ...


Top
 Profile  
 
 Post subject: Re: Need a bit of help tracing the neutral position switch
PostPosted: Sat Dec 14, 2013 8:08 pm 
Offline
RomRaider Developer

Joined: Thu May 21, 2009 1:49 am
Posts: 7323
Location: Canada eh!
It looks like you are on the right track.
The details of the CPU are scarce at best. You are looking for MC68HC16Y5TSJ_Rev1


Top
 Profile  
 
 Post subject: Re: Need a bit of help tracing the neutral position switch
PostPosted: Sat Dec 14, 2013 8:09 pm 
Offline
Experienced
User avatar

Joined: Tue Aug 30, 2011 7:17 pm
Posts: 900
Prior to that ram address there is a subroutine that pulls the data directly from the hardware. It's a separate memory section that is controlled by the tpu if I recall correctly.


Hardware access is usually done via the Y register offset


Top
 Profile  
 
 Post subject: Re: Need a bit of help tracing the neutral position switch
PostPosted: Sat Dec 14, 2013 9:17 pm 
Offline
RomRaider Donator

Joined: Thu Dec 29, 2011 2:04 am
Posts: 181
Ok perfect thanks guys, I'll ask the guy to log a few ram variable for me just to make sure that I am looking at the right thing.

That's way more fun than advanced sudoku puzzles :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 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