Magic Lantern Forum

Developing Magic Lantern => General Development => Topic started by: mark.farnell on March 15, 2013, 09:36:44 PM

Title: Software architectural relationship between firmware, DryOS, ML and "canon stuff
Post by: mark.farnell on March 15, 2013, 09:36:44 PM
Quote from: 1% on March 15, 2013, 01:00:19 AM
6D has a few more (ie timecode) but 600D had the same stuff. Its not DryOS, its canon stuff on top of it.

Ptool directly modifies fw (AFAIK) and they have a software encoder.

I am a total newbie to ML development and I am just starting to learn...
Where can I find a diagram explaining the architectural relationship between:

- Canon camera hardware
- DryOS
- ML
- other "canon stuff" above the DryOS that 1% mentioned

When people say firmware and software, I am a bit confused about where do they sit on the above list.  Does firmware cover DryOS or does it only cover things below the DryOS?  What does "firmware" cover for our purpose?

Also does ML work by replacing part of the "other canon stuff" above the DryOS, or the DryOS, or both?

Thanks!

Mark
Title: Re: Software architectural relationship between firmware, DryOS, ML and "canon stuff
Post by: g3gg0 on March 16, 2013, 12:52:30 AM
i have no picture for you, but some words.

DryOS is the operating system, the canon firmware uses and is widely used on cameras in field.
Operating system = basic I/O, tasks, semaphores, memory management, etc.

canon firmware is the DryOS plus a lot of application code like menu, state machines for every camera function.

Boot loader is the first code executed after processor reset. it checks flash and jumps to canon firmware.
it also checks for boot flag and autoexec.bin on card and executes it (ML loading)

Title: Re: Software architectural relationship between firmware, DryOS, ML and "canon stuff
Post by: mark.farnell on March 16, 2013, 08:08:44 AM
Quote from: g3gg0 on March 16, 2013, 12:52:30 AM
i have no picture for you, but some words.

DryOS is the operating system, the canon firmware uses and is widely used on cameras in field.
Operating system = basic I/O, tasks, semaphores, memory management, etc.

canon firmware is the DryOS plus a lot of application code like menu, state machines for every camera function.

Boot loader is the first code executed after processor reset. it checks flash and jumps to canon firmware.
it also checks for boot flag and autoexec.bin on card and executes it (ML loading)

Thanks!  So where does ML sit?  Is ML augmenting/patching the  "application code" that you talked about, or the DryOS code, or both?  I am confused........

Also are camera functions such as recording movies, and limiting movie time length to 1799 seconds belong to the user space application code rather than the DryOS code?
Title: Re: Software architectural relationship between firmware, DryOS, ML and "canon stuff
Post by: 1% on March 16, 2013, 08:45:40 AM
Its all compiled together into a rom.... you can patch code in memory throughout or execute new code. The different functions i.e. movie recorder, color calc are kind of like apps or modules. ML is somewhat like that, it runs with all the other stuff.



Title: Re: Software architectural relationship between firmware, DryOS, ML and "canon stuff
Post by: a1ex on March 16, 2013, 10:01:26 AM
Most of ML code is running as a couple of user tasks on DryOS (look for TASK_CREATE lines in the source code). It calls Canon functions - see platform/stubs.S - to do its job (e.g. to take a picture, to change shutter speed etc).

Some code is called back from DryOS when some events happen (e.g. you change some setting, or you start recording, etc). These are the property handlers (PROP_HANDLER), see http://magiclantern.wikia.com/wiki/Properties .

The GUI event handlers run in Canon's GUI task (so when a button is pressed, ML code looks at it, and decides whether it's for its own use - e.g. ML menu or shortcut keys - or just passes it to Canon code).

And finally, you can patch small bits of Canon code, usually with cache hacks, or by relocating some code into RAM. This is used, for example, for modifying Canon's startup code in order to load ML. The patching is temporary, the ROM is not altered, just the RAM or CPU cache.

If you want diagrams, you can look here: http://a1ex.bitbucket.io/ML/states/index.html (these are Canon tasks implemented as state objects).
Title: Re: Software architectural relationship between firmware, DryOS, ML and "canon stuff
Post by: g3gg0 on March 16, 2013, 11:33:59 AM
as explained the bootloader loads autoexec.bin [into RAM and executes it] expecting some canon debug/development code but it is Magic Lantern.

then ML has control over the system before the OS is booting.
ML patches some stuff in the OS init code, putting its own init task into DryOS startup.
(patching is tricky, as we cannot and do not want to modify flash content -> advanced topic)
after this patching is done, ML jumps to the original DryOS entry point as the bootloader would do it.

DryOS boots, but with some things changed (call it "infected with ML code").
now we have our own tasks running and can modify variables in RAM etc while the camera operates normally.
Title: Re: Software architectural relationship between firmware, DryOS, ML and "canon stuff
Post by: g3gg0 on March 16, 2013, 11:50:51 AM
(http://upload.g3gg0.de/pub_files/a60f0996c37a5d17acd929ab743ec2c0/ml_boot.png)
Title: Re: Software architectural relationship between firmware, DryOS, ML and "canon stuff
Post by: g3gg0 on March 16, 2013, 12:19:45 PM
(http://upload.g3gg0.de/pub_files/0227a2e622aa1187b58a2b42e6b1d089/main_firmware.png)
Title: Re: Software architectural relationship between firmware, DryOS, ML and "canon stuff
Post by: Indy on March 16, 2013, 11:12:43 PM
nice picture!
see also http://www.canon.com/technology/canon_tech/explanation/cp_tech.html#dryos

Title: Re: Software architectural relationship between firmware, DryOS, ML and "canon stuff
Post by: g3gg0 on March 17, 2013, 11:10:23 AM
well, its not perfect and for sure not 100% correct.
its just a visualization of basic things.
https://bitbucket.org/hudson/magic-lantern/commits/55da5b5d4cd41d30df888462b6232025af3ffd11

feel free to edit the drawing using yEd (you can start that tool from its web page, needs no extra installation. java webstart)
http://www.yworks.com/de/products_yed_about.html (click start)
Title: Re: Software architectural relationship between firmware, DryOS, ML and "canon stuff
Post by: mark.farnell on March 29, 2013, 09:54:30 PM
Thanks g3gg0 for these very illustrative diagrams...... Should they go to the developer's documentation on the ML website?  Newbie developers do need to understand the big picture first before they can progress further......
Title: Re: Software architectural relationship between firmware, DryOS, ML and "canon stuff
Post by: a1ex on March 29, 2013, 09:59:55 PM
Yes, feel free to add them.
Title: Re: Software architectural relationship between firmware, DryOS, ML and "canon stuff
Post by: kitor on May 25, 2023, 01:07:33 PM
Images are dead. @g3gg0 do you still have them?
Title: Re: Software architectural relationship between firmware, DryOS, ML and "canon stuff
Post by: names_are_hard on May 25, 2023, 01:19:06 PM
They're in the repo at doc/Architecture_Drawings.graphml - or at least that's the file from the ref'd commit.
Title: Re: Software architectural relationship between firmware, DryOS, ML and "canon stuff
Post by: g3gg0 on December 28, 2023, 06:23:45 PM
Quote from: kitor on May 25, 2023, 01:07:33 PM
Images are dead. @g3gg0 do you still have them?

fixed