Magic Lantern Forum

Developing Magic Lantern => Camera-specific Development => Archived porting threads => Topic started by: Pelican on October 02, 2012, 11:40:53 AM

Title: Canon 7D ML
Post by: Pelican on October 02, 2012, 11:40:53 AM
Thanks to g3gg0 it's coming soon now, so it's time to open this topic... :-)
I've already built 7D ML from the latest source and started to check the features.
What is the workflow of the developing?
Title: Re: Canon 7D ML
Post by: a1ex on October 02, 2012, 12:25:07 PM
The current problem is how to enable the bootflag without having to distribute Canon code.

Currently, user code runs after loading the FIR, but the camera gets restarted after a very small period of time (g3gg0 estimated 50ms). It's probably not safe to alter the ROM in this situation.

Indy's solution was to post a bspatch. I don't like to use this idea for regular users (for developers may be OK) because:

1) it's not that easy to use
2) it enables other users to do a derivative work from Canon's copyrighted code (the updater); if they post it online, I smell trouble.

Point 2) applies to any program that patches the original firmware IMO.
Title: Re: Canon 7D ML
Post by: Pelican on October 02, 2012, 12:41:29 PM
I see.
I enabled the bootflag on my camera with a patched firmware update too.
Hmm. And we cannot make a magiclantern.fir file as for the other cameras...
Title: Re: Canon 7D ML
Post by: g3gg0 on October 02, 2012, 03:04:44 PM
Quote from: Pelican on October 02, 2012, 12:41:29 PM
I see.
I enabled the bootflag on my camera with a patched firmware update too.
Hmm. And we cannot make a magiclantern.fir file as for the other cameras...

you enabled the flag on 7D? Or did you enable it on models where we can run our own (not canon patched) updater code?

thats the problem on 7D. we can run our updater code, but it seems we must do some special comm, else the slave cpu gets reset.
i dont know if it is IPC comm with master processor, or if it is some watchdog or whatever.

the "normal" firmware boot with ML enabled is now possible because of the ipc command register, we have to write with 0x80000010. see reboot.c.
if we don't write that command, both digics are out of sync and firmware will halt.
(see http://magiclantern.wikia.com/wiki/Register_Map in section IPC - there is a list of Slave->Master commands
written to that register.

a more cleaner version of that missing piece for 7D looks like that:

        /* clear IPC interrupt lines */
        *(volatile int*)0xC0A0000C = *(volatile int*)0xC0A00008;
        /* send command to master processor, so it is in right state for rebooting */
        *(volatile int*)0xC0A00024 = 0x80000010;
        /* wait for interrupt */
        asm("MCR p15, 0, R0, c7, c0, 4\n":::"r0");
       
        /* clear IPC interrupt lines */
        *(volatile int*)0xC0A0000C = *(volatile int*)0xC0A00008;

Title: Re: Canon 7D ML
Post by: Pelican on October 02, 2012, 05:28:23 PM
Quote from: g3gg0 on October 02, 2012, 03:04:44 PM
you enabled the flag on 7D?
Yes, I've enabled the bootflag with the original Canon 1.1.0 fw updater patched by TH (or Indy?) wich makes the ROM dumps.
Title: Re: Canon 7D ML
Post by: g3gg0 on October 02, 2012, 05:56:01 PM
very good :)

at the moment i am focusing on how to make the first alpha user-ready.

features and how good they are working are explained here:
    http://magiclantern.wikia.com/wiki/7D_support
many features work fine, some not due to property setting is still disabled.
(enabling property setting could cause some unrecoverable error!)


as soon there is a clean way to run ML without patching/distributing canon code,
i will head over to the alpha feature set. this means i will disable all the functions that
are not working clean or dont work at all. (like alex' 5D3 alpha)
Title: Re: Canon 7D ML
Post by: Pelican on October 02, 2012, 07:36:56 PM
And why you cannot purify the updater fir to a very very basic one which would set the bootflag only and do nothing else?
It could contain almost none Canon code.

(That was my idea to run ML long time ago: put the whole ML to the updater and run as a fw update, but never got working.)
Title: Re: Canon 7D ML
Post by: g3gg0 on October 02, 2012, 08:07:02 PM
do you mean to keep some basic canon code that statisfies the wdt behavior?
then we still have legal issues. so this is a (almost) no-go

if you mean we should jump to reset vector/firmware from our updater1 context, then
we still have the problem i am stuck at - master processor is in a different state due to
the slave bootloader sending it there right before the .fir gets executed.

the commands sent before executing .fir updater1 (slave side)

0x80000052 (fromutil_ipc_wakeup)
0x80000031 (before entering autoexec.bin)
   to undo:   0x80000010, then boot normal firmware
0x80000034 or 0x80000030 (before entering FIR load code)
   to cancel: 0xC8000000, then continue fromutil
0x88000001 (when going to load .FIR)
   to cancel: 0xC8000000, then continue fromutil
0x98000000 (when going to execute .FIR)
0xB8000000|fir_length (when going to execute .FIR)
0x80000040 (when going to execute .FIR)
   to cancel: no idea

when bootflag is set and our autoexec.bin was executed, we simply
can send command 0x80000010 and can continue normal boot.

when updater1 gets executed - we are already at bottom of the list. 0x80000040.
and i have no clue (yet) how to go back


and the problem we have everywhere - there is some watchdog. either master processor is resetting us
or there is some dedicated WDT module
Title: Re: Canon 7D ML
Post by: Pelican on October 02, 2012, 08:59:04 PM
This patched updater does its job and right after the camera restarts.
No hang up just restart.
It could be enough for us, isn't it?
I mean you don't have to return from updater1...
I don't remember how the dumper code ended but you can check it.
Title: Re: Canon 7D ML
Post by: Pelican on October 02, 2012, 09:10:58 PM
code from the end of dumper.c:


...
abort_firmup1();
LOG();
abort_firmup2();
LOG();
uint32_t dummy = 0;
reboot_icu( 0x80010003, dummy, 4 );
...


Maybe this is how you can finish the fw update...
Title: Re: Canon 7D ML
Post by: g3gg0 on October 02, 2012, 10:25:15 PM
i tried another way. and the results look promising :)
Title: Re: Canon 7D ML
Post by: Pelican on October 02, 2012, 10:38:58 PM
Good to hear... :)
Title: Re: Canon 7D ML
Post by: g3gg0 on October 02, 2012, 10:53:22 PM
was able to boot ML from fir ;)
will release a video in a few minutes.

about the technical details:
i couldnt get further with resetting master processor into the fitting state.
no idea how to get that done, as the master updater already was running.
so i decided to replace master updater code with a plain reboot into firmware main at 0xF8010000
whereas the slave does the same with magic lantern enabled.

one + for this methos is - we can also hook master firmware now using cache hacks ;)
but only as long we run ML from .fir. when switching to autoexec.bat, this feature is lost.
but that would help to get e.g. a bootrom dump from master processor.
Title: Re: Canon 7D ML
Post by: Pelican on October 02, 2012, 11:54:31 PM
Congratulations! :)
Waiting for the video...
Title: Re: Canon 7D ML
Post by: g3gg0 on October 02, 2012, 11:56:17 PM
will appear here in some minutes:
http://youtu.be/cyZRC16XEQw
Title: Re: Canon 7D ML
Post by: jplxpto on October 03, 2012, 01:22:18 AM
Congratulations, you seem not to sleep ... everyday surprises us more ... every day more big news ...
Title: Re: Canon 7D ML
Post by: g3gg0 on October 03, 2012, 01:41:42 AM
haha "you seem not to sleep" - you sound like my girlfriend ;)

well, this demonstrated .fir wouldnt have been possible if indy wouldnt have made that great tools for replacing updaters
and also if trammels initial work on the 7D had failed and we wouldnt have any bootrom dump.
i just put the missing piece of code between some lines ;)
Title: Re: Canon 7D ML
Post by: LaLigueParis on October 03, 2012, 02:06:52 AM
you're our hero lol
good work
Title: Re: Canon 7D ML
Post by: jplxpto on October 03, 2012, 02:29:59 AM
Quote from: LaLigueParis on October 03, 2012, 02:06:52 AM
you're our hero lol
good work

I thought the same ...:)
Title: Re: Canon 7D ML
Post by: g3gg0 on October 03, 2012, 06:03:43 PM
yeeha
using the FIR method i was able to hijack both processors.
so i am running my own RPC handler on both devices.

one ML can send commands and data via "official" RPC interfaces to the other processor.
e.g. triggered via RPC call the code
  "master_write_memory("ROM1.BIN", 0xf8000000, 0x00800000);"
on the master processor.

master_write_memory is a canon function that uses FIO_WriteFile over RPC to write files on slave device.
so i was able to dump the master processor ROM (8MiB)
Title: Re: Canon 7D ML
Post by: tonybeccar on October 03, 2012, 07:20:43 PM
Sorry to intervene, but WOW, does this mean that you can take advantage of BOTH processors of the 7D?? Will we be seeing awesome features because of their power??

I'm checking the forums every day.. and I never thanked you.. THANK YOU!!!!!!!!! YOU'RE MY HERO!!!!
Title: Re: Canon 7D ML
Post by: g3gg0 on October 03, 2012, 08:17:49 PM
Quote from: tonybeccar on October 03, 2012, 07:20:43 PM
Sorry to intervene, but WOW, does this mean that you can take advantage of BOTH processors of the 7D?? Will we be seeing awesome features because of their power??

I'm checking the forums every day.. and I never thanked you.. THANK YOU!!!!!!!!! YOU'RE MY HERO!!!!

i guess there will no awesome features, just more problems when it comes to special features that need to access the correct digic.
Title: Re: Canon 7D ML
Post by: bart on October 03, 2012, 09:40:26 PM
Well done G3gg0. Amazing work!
Title: Re: Canon 7D ML
Post by: Pelican on October 03, 2012, 10:14:02 PM
I am waiting for this moment for 3 years... 8) OMG!
Unfortunately I'm very busy with a special Nikon camera mod/remote right now, but after that I'll jump right into the 7D ML source...
Title: Re: Canon 7D ML
Post by: Pelican on October 05, 2012, 06:55:12 PM
I was playing with ML this afternoon and found an interesting bug.
When minute changes in the camera's clock  the Date/Time/Zone menu item displays the top of the ML stuff.
It happens only when the Date/Time/Zone menu item selected in My Menu settings.
The position of the Date/Time/Zone  item on the ML screen is the same as on the My Menu screen.
It shows on ML menu only less than a second but stays on the ML info screens (because these are drawn once?).
Title: Re: Canon 7D ML
Post by: g3gg0 on October 05, 2012, 07:16:23 PM
i didnt fix that specific bug yet, thanks.

in meantime you can apply this patch to current source tree:
http://upload.g3gg0.de/pub_files/d97c09226e2de63d370d0b59c8399934/7D.patch
there are a lot of other fixes.

also those features that dont work yet, are disabled.

Title: Re: Canon 7D ML
Post by: nanomad on October 05, 2012, 09:03:03 PM
Do you want access to the bitbucket repository?

(patch pushed, hope you don't mind)
Title: Re: Canon 7D ML
Post by: Pelican on October 05, 2012, 11:16:25 PM
Thank you! (Both of you)
It's working... :)
Title: Re: Canon 7D ML
Post by: g3gg0 on October 06, 2012, 12:57:55 AM
ah nice, thanks :)
Title: Re: Canon 7D ML
Post by: g3gg0 on October 06, 2012, 11:26:28 PM
Quote from: nanomad on October 05, 2012, 09:03:03 PM
Do you want access to the bitbucket repository?

sorry forgot to answer.
already talked to alex about that.
in theory "yes". but as i didnt work with mercurial yet, i would probably break something ;)
i am used to CVS/SVN, but not to this client.

no rush :)
Title: Re: Canon 7D ML
Post by: g3gg0 on October 07, 2012, 12:09:46 AM
and here the latest patch.
http://upload.g3gg0.de/pub_files/3747c82d249e973381434c45ba75a43d/7D.patch

fixed a lot of details.
Title: Re: Canon 7D ML
Post by: joespace on October 07, 2012, 01:00:24 AM
Thank you!  7d owner always wanted to have ML on it. What your are doing is great. Any chance ti have Fps overide on the 7d one day ?
Title: Re: Canon 7D ML
Post by: g3gg0 on October 07, 2012, 02:20:27 AM
Quote from: joespace on October 07, 2012, 01:00:24 AM
Thank you!  7d owner always wanted to have ML on it. What your are doing is great. Any chance ti have Fps overide on the 7d one day ?

thanks.
for what i know now, it seems to be a lot of work again, as the known timers are not used for fps timing.
so i think it will take its time to find that out. maybe next year ;)
Title: Re: Canon 7D ML
Post by: nanomad on October 07, 2012, 10:15:16 AM
Quote from: g3gg0 on October 07, 2012, 12:09:46 AM
and here the latest patch.
http://upload.g3gg0.de/pub_files/3747c82d249e973381434c45ba75a43d/7D.patch

fixed a lot of details.

Merged ;)
Title: Re: Canon 7D ML
Post by: phiber on October 07, 2012, 04:17:06 PM
Getting a working arm toolchain on centos 5 is a PITA. Hopefully I'll have a working arm toolchain tonight.
Title: Re: Canon 7D ML
Post by: Pelican on October 07, 2012, 04:28:30 PM
This latest doesn't work for me.

Without the splash bmp:
Freezing in sensor cleaning. If I skip sensor cleaning then the camera can work but no display.
With the splash:
Splash screen appears for half of the second (but the "alpha" text is plain purple) after that the display turns black but still on and remains on this stage forever (no menu, no info, no play) Camera works otherwise.
If I skip the sensor cleaning (and the splash) then the camera and ML works normally.


I want to be sure that my compiler makes the same code as others so could anyone of you send me an autoexec.bin for 7D?
Title: Re: Canon 7D ML
Post by: g3gg0 on October 07, 2012, 07:12:42 PM
@phiber:
you cannot run this on "normal" 7Ds as the bootflag is not enabled. (or is it?)

@Pelican:
true. didnt test it with sensor cleaning.
thanks for pointing out!
will provide an update
Title: Re: Canon 7D ML
Post by: joespace on October 07, 2012, 11:49:55 PM
Is it safe (and easy) to install it on my 7D right now ?

You guys are doing great job. As i don't know how to help, i made a small donation.
Title: Re: Canon 7D ML
Post by: g3gg0 on October 07, 2012, 11:57:08 PM
@joespace:
you cannot run this on "normal" 7Ds as the bootflag is not enabled. (or is it?)
Title: Re: Canon 7D ML
Post by: joespace on October 10, 2012, 06:14:29 PM
As a didn't understand what does bootflag stand for ... i better wait for an official ML release for the 7D. :D
Title: Re: Canon 7D ML
Post by: Toni on December 05, 2012, 06:03:07 PM
Quote from: g3gg0 on October 07, 2012, 11:57:08 PM
you cannot run this on "normal" 7Ds as the bootflag is not enabled. (or is it?)

I'm sorry, but what does "normal 7D" mean? As far as I know, there's only one type of 7D camera, am I wrong?

Also, what is the bootflag and how can it be enabled if needed?
Title: Re: Canon 7D ML
Post by: g3gg0 on December 05, 2012, 06:06:13 PM
Quote from: Toni on December 05, 2012, 06:03:07 PM
I'm sorry, but what does "normal 7D" mean? As far as I know, there's only one type of 7D camera, am I wrong?

Also, what is the bootflag and how can it be enabled if needed?

there are developer models that have the bootflag set.
also there are some cameras on that we enabled the boot flag.
boot flag = load autoexec.bin (ML) from CF card on startup
Title: Re: Canon 7D ML
Post by: Toni on December 05, 2012, 08:19:05 PM
Quote from: g3gg0 on December 05, 2012, 06:06:13 PM
there are developer models that have the bootflag set.
also there are some cameras on that we enabled the boot flag.
boot flag = load autoexec.bin (ML) from CF card on startup

OK. And can it be enabled on all "normal" cameras? How?

Also, what is a "developer model"? Do you mean some models used only by Canon developers?
Title: Re: Canon 7D ML
Post by: g3gg0 on December 05, 2012, 10:30:37 PM
Quote from: Toni on December 05, 2012, 08:19:05 PM
OK. And can it be enabled on all "normal" cameras? How?
Also, what is a "developer model"? Do you mean some models used only by Canon developers?

as soon ML for 7D is stable, we will have some sort of FIR that enables bootflag on every camera out there.
yes, "developer model" i call those used by canon devs.
Title: Re: Canon 7D ML
Post by: feureau on December 06, 2012, 01:05:49 AM
Wait, developer mode, as in used by Canon when they work on 7D?

What does it do?
Title: Re: Canon 7D ML
Post by: g3gg0 on December 06, 2012, 01:34:30 AM
its the boot flag....
Title: Re: Canon 7D ML
Post by: Pelican on December 06, 2012, 11:33:59 AM
My 7D* surely a developer model because I use ML from autoexec.bin.  :) 
*D=Developer
Title: Re: Canon 7D ML
Post by: Stedda on December 06, 2012, 01:52:46 PM
OMG I don't know how you guys do it... how do you hold back?  :o
Title: Re: Canon 7D ML
Post by: g3gg0 on December 06, 2012, 02:10:31 PM
Quote from: Stedda on December 06, 2012, 01:52:46 PM
OMG I don't know how you guys do it... how do you hold back?  :o

you will get it as soon its comes out of alpha state.
Title: Re: Canon 7D ML
Post by: Stedda on December 06, 2012, 02:25:16 PM
Oh I'm not asking about the firmware, I'm not one of those.

I'm asking about the stupid questions...
Title: Re: Canon 7D ML
Post by: Toni on December 09, 2012, 12:54:42 PM
Quote from: g3gg0 on December 05, 2012, 10:30:37 PM
as soon ML for 7D is stable, we will have some sort of FIR that enables bootflag on every camera out there.
yes, "developer model" i call those used by canon devs.

OK, thanks a lot  :)