Thought I'd make a little noise on this topic just to let people know that I'm still working my way through this albeit at a very slow pace.
QEMU is under active development so before posting anything I pull in the latest commits and merge my EOSM2 and Mac specific build tweaks.
Ok, so here's where I left off:
Alright, so let's start from where we've left off.
...
This 0x648 looks like a counter that tells how many nested interrupts we are handling (yes, they can be nested - unfortunately, as this makes it a lot harder to understand, debug, emulate and so on). Let's confirm its functionality with RAM tracing:
./run_canon_fw.sh EOSM2,firmware="boot=0" -d io,int,ram,nochain -singlestep
...
[tcm_code] at 0x000004D4:19980218 [0x00000648] -> 0x0
[tcm_code] at 0x000004E0:19980218 [0x00000648] <- 0x1 : was 0x0;
...
[tcm_code] at 0x0000050C:0000050C [0x00000684] -> 0xC0201004
[INT] at 0x00000510:0000050C [0xC0201004] -> 0x28 : Requested int reason 28 (INT 0Ah)
[tcm_code] at 0x00000514:0000050C [0x0000064C] <- 0x28 : was 0x0;
...
[INT] at 0x00000594:00000568 [0xC0201010] <- 0xA : Enabled interrupt 0Ah
[tcm_code] at 0x00000598:00000568 [0x00000648] -> 0x1
[tcm_code] at 0x000005A0:00000568 [0x00000648] <- 0x0 : was 0x1;
Looks right!
I'm seeing pretty much the same only with some additional information probably as a result of some of the enhancements a1ex has been adding to QEMU.
...
[tcm_code] at TaskM:000004D4:19980218 [0x00000648] -> 0x0
[tcm_code] at TaskM:000004E0:19980218 [0x00000648] <- 0x1 : was 0x0;
...
[tcm_code] at init:0000050C:0000050C [0x00000684] -> 0xC0201004
[INT] at init:00000510:0000050C [0xC0201004] -> 0x28 : Requested int reason 28 (INT 0Ah)
[tcm_code] at init:00000514:0000050C [0x0000064C] <- 0x28 : was 0x0;
...
[INT] at init:00000594:00000568 [0xC0201010] <- 0xA : Enabled interrupt 0Ah
[tcm_code] at init:00000598:00000568 [0x00000648] -> 0x1
[tcm_code] at init:000005A0:00000568 [0x00000648] <- 0x0 : was 0x1;
In some cases I'm getting errors that shouldn't be happening. For example:
./run_canon_fw.sh EOSM2,firmware="boot=0" -d callstack,ramw |& grep -B 20 "not restored"
-bash: syntax error near unexpected token `&'
The '|&' shorthand was added to bash 4 as an abbreviation for '2>&1 |' and I'm running this version of bash:
GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin16.3.0)
Go figure -- must be a Mac thing. Changing '|&' to '2>&1 |' still didn't give me the same results a1ex posted.
./run_canon_fw.sh EOSM2,firmware="boot=0" -d callstack,ramw 2>&1 | grep -B 20 "not restored"
[tcm_data] at 0x0010DA10:00000040 [0x40000F60] <- 0x4 : was 0x4C;
[tcm_data] at 0x0010DA10:00000040 [0x40000F64] <- 0x20 : was 0x4C;
[tcm_data] at 0x0010DA10:00000040 [0x40000F68] <- 0x8 : was 0x4C;
[tcm_data] at 0x0010DA10:00000040 [0x40000F6C] <- 0x40 : was 0x1F;
[tcm_data] at 0x0010DA08:00000100 [0x40000F70] <- 0x10 : was 0x4C;
[tcm_data] at 0x0010DA08:00000100 [0x40000F74] <- 0x80 : was 0x4C;
[tcm_data] at 0x0010DA08:00000100 [0x40000F78] <- 0x20 : was 0x40;
[tcm_data] at 0x0010DA08:00000100 [0x40000F7C] <- 0x100 : was 0x40;
[tcm_data] at 0x0010DA10:00000C00 [0x40000F80] <- 0x40 : was 0x1F;
[tcm_data] at 0x0010DA10:00000C00 [0x40000F84] <- 0x200 : was 0x1;
[tcm_data] at 0x0010DA10:00000C00 [0x40000F88] <- 0x80 : was 0x0;
[tcm_data] at 0x0010DA10:00000C00 [0x40000F8C] <- 0xC00 : was 0x0;
[tcm_data] at 0x0010DA2C:00000C00 [0x40000F90] <- 0xFF : was 0x7;
[tcm_data] at 0x0010DA2C:00000C00 [0x40000F94] <- 0xFFF : was 0x1;
[tcm_data] at 0x0010329C:001000C8 [0x40000F9C] <- 0x1 : was 0x0;
[tcm_data] at 0x0010329C:001000C8 [0x40000FA0] <- 0x1000C8 : was 0x10007C;
[tcm_data] at 0x0010329C:001000F8 [0x40000F9C] <- 0x1 : was 0x1;
[tcm_data] at 0x0010329C:001000F8 [0x40000FA0] <- 0x1000F8 : was 0x1000C8;
[tcm_data] at 0x001022C0:0010013C [0x40000F9C] <- 0x1 : was 0x1;
[tcm_data] at 0x001022C0:0010013C [0x40000FA0] <- 0x10013C : was 0x1000F8;
Warning: R10 not restored (0xa -> 0x1) at [ffff101c:ffff09cc]
Moving on or I'll never get through this. Here we can finally see some indication of the different firmware versions that we're looking at, a1ex on EOSM2 1.0.2 while I'm on 1.0.3.
./run_canon_fw.sh EOSM2 -s -S & arm-none-eabi-gdb -x EOSM2/debugmsg.gdb
...
[ init:ff352264 ] task_create(PowerMgr, prio=20, stack=400, entry=ff352088, arg=0)
[ init:ff1470d4 ] (00:01) [PM] DisablePowerSave (Counter = 1)
[ init:0003671c ] task_create(DbgMgr, prio=1f, stack=0, entry=36628, arg=46e584)
[ init:ff0c3334 ] (8b:16)
K355 ICU Firmware Version 1.0.2 ( 6.0.5 )
[ init:ff0c3348 ] (8b:05)
ICU Release DateTime 2013.12.02 09:28:54
[ init:ff0f5ea0 ] (00:03) [SEQ] CreateSequencer (Startup, Num = 6)
[ init:ff0f5f28 ] task_create(Startup, prio=19, stack=2800, entry=ff0f5d6c, arg=46e880)
[ init:ff0f60f4 ] (00:02) [SEQ] NotifyComplete (Startup, Flag = 0x10000)
[ init:ff0f6158 ] (00:03) [SEQ] NotifyComplete (Cur = 0, 0x10000, Flag = 0x10000)
[ init:ff0c33d4 ] task_create(TaskMain, prio=1d, stack=0, entry=ff0c28d8, arg=0)
[ Startup:ff0f5db4 ] (00:05) [SEQ] seqEventDispatch (Startup, 0)
[ Startup:ff0c373c ] (8b:05) startupEntry
[ Startup:ff0c375c ] task_create(Startup2, prio=11, stack=400, entry=ff0c3604, arg=0)
[ Startup2:ff1310c4 ] (02:16) PROPAD_CreateFROMPropertyHandle DRAMAddr 0x416d5b00
[ Startup2:ff14a204 ] (00:01) [SF] IsAddressSerialFlash 0x2d0000
...
And my results running that same command.
./run_canon_fw.sh EOSM2 -s -S & arm-none-eabi-gdb -x EOSM2/debugmsg.gdb
...
[ init:ff352260 ] task_create(PowerMgr, prio=20, stack=400, entry=ff352084, arg=0)
[ init:ff1470d0 ] (00:01) [PM] DisablePowerSave (Counter = 1)
[ init:0003671c ] task_create(DbgMgr, prio=1f, stack=0, entry=36628, arg=46e584)
[ init:ff0c3334 ] (8b:16)
K355 ICU Firmware Version 1.0.3 ( 6.0.6 )
[ init:ff0c3348 ] (8b:05)
ICU Release DateTime 2016.08.09 13:28:42
[ init:ff0f5e9c ] (00:03) [SEQ] CreateSequencer (Startup, Num = 6)
[ init:ff0f5f24 ] task_create(Startup, prio=19, stack=2800, entry=ff0f5d68, arg=46e880)
[ init:ff0f60f0 ] (00:02) [SEQ] NotifyComplete (Startup, Flag = 0x10000)
[ init:ff0f6154 ] (00:03) [SEQ] NotifyComplete (Cur = 0, 0x10000, Flag = 0x10000)
[ init:ff0c33d4 ] task_create(TaskMain, prio=1d, stack=0, entry=ff0c28d8, arg=0)
[ Startup:ff0f5db0 ] (00:05) [SEQ] seqEventDispatch (Startup, 0)
[ Startup:ff0c373c ] (8b:05) startupEntry
[ Startup:ff0c375c ] task_create(Startup2, prio=11, stack=400, entry=ff0c3604, arg=0)
[ Startup2:ff1310c0 ] (02:16) PROPAD_CreateFROMPropertyHandle DRAMAddr 0x416d5b00
[ Startup2:ff14a200 ] (00:01) [SF] IsAddressSerialFlash 0x2d0000
...
Crawling along to a1ex's next post I ran into the '|&' issue again.
./run_canon_fw.sh EOSM2,firmware="boot=0" -d romcpy |& grep ROMCPY
[ROMCPY] 0xFFFF0000 -> 0x0 size 0x40 at 0xFFFF0980
[ROMCPY] 0xFFFE0000 -> 0x100000 size 0xFF2C at 0xFFFF0FCC
[ROMCPY] 0xFFD1F02C -> 0x1900 size 0xB70A0 at 0xFF0C000C
[ROMCPY] 0xFF0C0E04 -> 0x4B0 size 0x1E8 at 0xFF0C0D70
[ROMCPY] 0xFFA12904 -> 0x4E0E98 size 0xC7C at 0x8645C
Only this time substituting '2>&1 |' worked, sort of. Seems it ended a little earlier.
./run_canon_fw.sh EOSM2,firmware="boot=0" -d romcpy 2>&1 | grep ROMCPY
[ROMCPY] 0xFFFF0000 -> 0x0 size 0x40 at 0xFFFF0980
[ROMCPY] 0xFFFE0000 -> 0x100000 size 0xFF2C at 0xFFFF0FCC
[ROMCPY] 0xFFD1F0E4 -> 0x1900 size 0xB70A0 at 0xFF0C000C
[ROMCPY] 0xFF0C0E04 -> 0x4B0 size 0x1E8 at 0xFF0C0D70
Binary file (standard input) matches