NefMoto

Technical => Reverse Engineering => Topic started by: maZer.GTi on April 14, 2015, 06:36:36 AM



Title: how to find value of SY_FREQCPU from binary
Post by: maZer.GTi on April 14, 2015, 06:36:36 AM
Does someone have an idea to find out the value of this constant by binary? without having the .ecu file or definition present? :)
thanks


Title: Re: how to find value of SY_FREQCPU from binary
Post by: IamwhoIam on April 14, 2015, 07:29:09 AM
I don't think you can... just out of interest, what binary do you need this on?


Title: Re: how to find value of SY_FREQCPU from binary
Post by: daniel2345 on April 14, 2015, 08:33:01 AM
You cannot from bin.

SY_* (system constants) are only used during code compilation at system supplier (=Bosch).

They are switches to use different code parts and leave other away. After code compilation they are written to a2l but can not be found in bin...




Title: Re: how to find value of SY_FREQCPU from binary
Post by: maZer.GTi on April 14, 2015, 09:55:23 AM
It should work on near all ME7 binarys, but there must be a way to reverse calculate the frequency.
its enaugh if we can read a value and calculate back to frequency.
Its needed for the new version of launch script.


Title: Re: how to find value of SY_FREQCPU from binary
Post by: daniel2345 on April 14, 2015, 12:39:33 PM
You can try to reverse the base os timing Interrupt settings or the clock settings for the can/serial divider registers.

With that you can recalculate the clock frequency / external osc.

Take formula from Datasheet for those registers and evaluate the formula to the term you need. Mostly fOsc or fCpu. Insert register values loaded in binary and you should have it.

Again: no way to get the SY_* directly.

Good luck


Title: Re: how to find value of SY_FREQCPU from binary
Post by: maZer.GTi on April 14, 2015, 07:38:43 PM
You can try to reverse the base os timing Interrupt settings or the clock settings for the can/serial divider registers.

With that you can recalculate the clock frequency / external osc.

Take formula from Datasheet for those registers and evaluate the formula to the term you need. Mostly fOsc or fCpu. Insert register values loaded in binary and you should have it.

Again: no way to get the SY_* directly.

Good luck

Im not sure this way is safe, but i found the "SSC Baudrate Register".
I hope with this register i can get the safe cpu clock.

-- Cutted ASM Code
mov     r12, #4637h
mov     r13, #13h
mov     r14, #2
mov     word_F0B4, r13


-- Notes from me ( values are in hex )
13 = 40MHz
0F = 32MHz
0B = 24MHz
09 = 20MHz


If someone can correct me or have better idea, please tell me.


Edit:
Seems values are very near,
32000KHz / 0Fh = 855h
855h x 13 = 40527 KHz
855h x 0F = 31995 KHz
855h x 0B = 23463 KHz
855h x 09 = 19197 KHz


Title: Re: how to find value of SY_FREQCPU from binary
Post by: dragon187 on October 26, 2021, 04:25:29 AM
Im not sure this way is safe, but i found the "SSC Baudrate Register".
I hope with this register i can get the safe cpu clock.

-- Cutted ASM Code
mov     r12, #4637h
mov     r13, #13h
mov     r14, #2
mov     word_F0B4, r13


-- Notes from me ( values are in hex )
13 = 40MHz
0F = 32MHz
0B = 24MHz
09 = 20MHz


If someone can correct me or have better idea, please tell me.


Edit:
Seems values are very near,
32000KHz / 0Fh = 855h
855h x 13 = 40527 KHz
855h x 0F = 31995 KHz
855h x 0B = 23463 KHz
855h x 09 = 19197 KHz

Can someone please confirm that this is working ?

Thank you


Title: Re: how to find value of SY_FREQCPU from binary
Post by: dragon187 on October 27, 2021, 11:55:44 AM
Tried it, seems to be ok.

Regards