Author Topic: Finding AE sensors  (Read 10415 times)

pravdomil

  • Member
  • ***
  • Posts: 166
Finding AE sensors
« on: August 31, 2013, 07:50:28 PM »
Well I need some help with reverse engineering.
I want to find brightness sensors in viewfinder.
If we found it we can implement ETTR in shooting mode or "auto exposure compensation" as I call it. I will describe it later.

There is a few ways how to find it. I choose debug flag.
After some research with nanomad I found that AE_VALUE is probably set in function copyOlcDataToStorage.
Nanomad says that function copies computed AE_VALUE from Toshiba MCU.
So my first step is find the address from is the data copied. I tried to set debug flag here, but it doest work, my flag wasn't triggered. There is some reasons why:
I spy wrong address (maybe I have ROM image wrong loaded)
AE_VALUE is set somewhere else
g3gg0 iirc some cameras permanently cleared the ICACHE in PwrMgr task, not sure if this is the case on 5D2

So please could anybody spy this?
Code: [Select]
LDRB            R0, [R8,#2]      ; R8 is what we need
STRB            R0, [R9,#0x1D]   ; 0x1D is struct offset of AE_VALUE

use this https://bitbucket.org/hudson/magic-lantern/pull-request/193/debugger-module

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Finding AE sensors
« Reply #1 on: August 31, 2013, 08:21:05 PM »
All I see is:

Code: [Select]
ROM:FF9C6624                 CMP     R6, R4
ROM:FF9C6628                 BLT     loc_FF9C6600
ROM:FF9C662C                 LDR     R9, =0x13008

Maybe you need to decompile this function?

I think R8 comes from the stack pointer.

Code: [Select]
ROM:FF9C65D0                 LDMIB   R5, {R0,R4}
ROM:FF9C65D4                 LDRB    R7, [R0]
ROM:FF9C65D8                 LDRB    R10, [R0,#1]
ROM:FF9C65DC                 LDR     R8, [R5]

Code: [Select]
ROM:FF89143C                 STMIA   R0, {R4,R5,R9}
ROM:FF891440                 ADD     R0, SP, #0x40+var_34
ROM:FF891444                 BL      str_copyOlcDataToStorage
ROM:FF891448                 MOV     R0, R5
ROM:FF89144C                 BL      sub_FF86F4FC
ROM:FF891450                 LDR     R1, [SP,#0x40+var_28+4]
ROM:FF891454                 LDR     R0, =0x10000095


1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Finding AE sensors
« Reply #3 on: August 31, 2013, 08:37:08 PM »
It looks like its passed into the function when its called from that big jump table.
FF891444

Break point that and see?

pravdomil

  • Member
  • ***
  • Posts: 166
Re: Finding AE sensors
« Reply #4 on: September 01, 2013, 10:23:08 AM »
not triggered anywhere
Code: [Select]
ADD             R0, SP, #0xC ; jumptable FF8A02B0 case 59
STMIA           R0, {R4,R5,R9}
ADD             R0, SP, #0xC
BL              sub_FF9D65B0 ; copyOlcDataToStorage

pravdomil

  • Member
  • ***
  • Posts: 166
Re: Finding AE sensors
« Reply #5 on: September 01, 2013, 05:10:17 PM »
maybe we can use mem_spy but where it can be stored? what address?

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Finding AE sensors
« Reply #6 on: September 01, 2013, 05:21:36 PM »
Possible to step through the function with GDB and look at all register addresses/contents?

pravdomil

  • Member
  • ***
  • Posts: 166
Re: Finding AE sensors
« Reply #7 on: September 01, 2013, 05:28:52 PM »
what GDB?

1%

  • Developer
  • Hero Member
  • *****
  • Posts: 5936
  • 600D/6D/50D/EOSM/7D
Re: Finding AE sensors
« Reply #8 on: September 01, 2013, 06:23:36 PM »
Well you set a breakpoint/watchpoint at some address.. or you can cache hack and take over the copyolcdata function and read out its parameters then send it on its way? Somehow this is done for the cmos/adtg functions?


pravdomil

  • Member
  • ***
  • Posts: 166
Re: Finding AE sensors
« Reply #9 on: September 01, 2013, 06:50:37 PM »
I tried gdb_add_watchpoint into copyOlcDataToStorage func and to jump table, but it wasn't triggered.

or you can cache hack and take over the copyolcdata function and read out its parameters then send it on its way?
well this is too hard for me, I take a look at cache hack functions

pravdomil

  • Member
  • ***
  • Posts: 166
Re: Finding AE sensors
« Reply #10 on: September 30, 2013, 01:43:12 PM »
you can cache hack and take over the copyolcdata function and read out its parameters then send it on its way? Somehow this is done for the cmos/adtg functions?

could please you send me some hints how to do it?