Author Topic: Canon 40D  (Read 296860 times)

heder

  • New to the forum
  • *
  • Posts: 16
Re: [UNMAINTAINED] Canon 40D
« Reply #425 on: August 22, 2019, 10:35:13 PM »
I need to set the bootflag in the camera to true, but I can't seems to find any ".fir" files for that.

Suggestions ?

Ok .. I found the solution .. read page 1+2 of this thread really carefully  :D and create a fir file that will toggle the camera bootflag
Embedded SW engineer. Current Cameras: Canon 20d, Canon 40d

heder

  • New to the forum
  • *
  • Posts: 16
Re: [UNMAINTAINED] Canon 40D
« Reply #426 on: August 29, 2019, 10:42:50 AM »
Finally some success!

Got a bootloader constructed and loaded with ML. Images of vxwork branch running in my camera (upper images) and changeset 8159 from unified  (lower images). I will spend the next days by getting a status of the Canon 40D progress, create proper bootloader and hopefully commit and push needed files for continued development. Then I'll make a new post.


Vxwork branch + modified (fonts have been included as static fonts)

Unified - changeset 8159 (commit 091b9f8)
Embedded SW engineer. Current Cameras: Canon 20d, Canon 40d

ilex

  • New to the forum
  • *
  • Posts: 19
Re: [UNMAINTAINED] Canon 40D
« Reply #427 on: August 29, 2019, 11:03:53 AM »
Up with de great work!!....Congrats.

Theta Sigma

  • New to the forum
  • *
  • Posts: 12
  • It's about time
Re: [UNMAINTAINED] Canon 40D
« Reply #428 on: August 31, 2019, 04:42:51 AM »
Thank you heder!

heder

  • New to the forum
  • *
  • Posts: 16
Re: [UNMAINTAINED] Canon 40D
« Reply #429 on: September 03, 2019, 10:39:51 AM »
Hi all! .. Long post.

I have worked the last couple of days to get a overview of the Canon 40D port which is born with the DIGIC III processor. All models with this processor have more or less stalled so getting one model ported should make it much easier to complete the others.  It's the first processor in the DIGIC series to have 14 bits support and with the Canon 40D's LiveView support, we have all the possibilities for a great ML upgrade - it's just here around the corner.

I hope more people with a canon 40d (or 450d, 1100d = all DIGIC III) will come help me creating a experimental release of ML for Canon 40d before Christmas, that would be cool (if not - its gonna be a easter release). I know it and old camera, but it still a pretty cool camera no matter if you use it as your primary or backup camera. And in these days with mercurial "sunsetting" (what a shitty word) on bitbucket we need some development to move the focus away from this.

Here is a short status:


Rom dumper
Link: https://www.magiclantern.fm/forum/index.php?topic=16534.0
The rom dumper work fine, but is victim of a power save mode and thus after 1-2 seconds after executing the rom dumper the screen goes dark. The rom dumper works, and you will need to wait for a minute or two before removing the battery. The ROM files are in ML\LOGS folder. Only ROM1.BIN has code, you can decompile/analyse it in Ghidra, specs are here (click image to expand):



Useable source repositories:
1. https://bitbucket.org/jmheder/vxworks_canon40d/src/vxworks/ (vxworks branch)
2. https://bitbucket.org/hudson/magic-lantern/src/vxworks/ (vxworks branch)
3. https://bitbucket.org/hudson/magic-lantern/unified (unified changeset 8159)

1. My working branch, properbly the best starting point atm. This is based on 2. with a some modifications (stubs,debug, defines, temporary static rbf fonts )   
2. main "vxworks branch", rufustfirefly rework of 3. will load, but no font are loaded (so no text)
3. The branch vnd used, old menu, but with static font, so text is shown, missing cache_lock() call.


Compilers
Compilers from launchpad, which I have been lightly tested are listed below. If you are on a Linux you will need multiverse for executing the old compilers (they are x86 compiled).

(4.6.2) ok, gcc-arm-none-eabi-4_6-2012q4-20121016.tar.bz2
(4.7.3) ok, gcc-arm-none-eabi-4_7-2012q4-20121208-linux.tar.bz2
(4.7.4) ok, gcc-arm-none-eabi-4_7-2014q2-20140408-linux.tar.bz2
(4.9.3) ok, gcc-arm-none-eabi-4_9-2015q3-20150921-linux.tar.bz2
(5.4.1) ok, gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2
(6.3.1) ok, arm-none-eabi-gcc (15:6.3.1+svn253039-1build1) 6.3.1 20170620 - Ubnutu standard
(8.3.1) bad, ML crashes at boot. gcc-arm-none-eabi-8-2019-q3-update-linux.tar.bz2


Bootloader / Flipper:
It works, but the code is not ready for releasing yet. It's based on the 5DC, but it does not work consistenly everytime, but so far it has'nt kill my 40D, so the errors are not fatal. This is my priority no.1 to get done.


Status, what works
* Basic bootloader works
* Booting magic lantern works
* GUI menu system works
* Totals Clicks (in debug menu)
* Temperature partial works (only shows raw temperature, but changeset 8159 (unified) shows celcius)
* Showing edmac channels (we have 16 channels)
* Showing vxworks threads
* Dumping log via call("dumpf") works see end of post for example (unified changeset 8159)


What does'nt work
* FIO_* system does not work and will result in somekind of file system lock
* Camera will not save images after capture (FIO issue), busy spinning icon appears, when powering off.
* Fonts are not loaded (FIO_ issue)
* Modules are not found/loaded (FIO_ issue)
* Dumping rom and does not work (?)
* Small fonts is incorrect scaled, totally unreadable
* Power off will sometimes result in crash
* Menu/GUI system LiveView button (set) not recognised, after liveview press PLAY before going into ML


QEMU emulation (QEMU branch)
I'm building on vxworks, but using QEMU branch to run it. On my mini server (intel atom) QEMU is rather unstable, only using vnc or no display will get it running
properly with a properbility of 50%. The emulator plays more nice that the real camera. I don't have the same problems with file system (FIO). I can dump
rom and call("dumpf") without problems my working branch.


Digic III
The Digic III processor uses same address space like all others, yet since this is a older Digic processor it might miss out on some features. CF address space is same. EDMAC address space is same (but only have 16 channels) FPS_REGISTER_A and FPS_REGISTER_B are same as all others. DMA0 the same .. ect. Mainboard comparison 40D/50D/5DMKII can be seen here - they are quite similar (click to expand image)



Medium/Larger tasks (random listed)
* Create a proper bootloader ("You may now remove the battery") (my priority 1)
* Fix FIO_* vxworks issue, file system lock (my priority 2)
* Get modules / Digic Poke working (FIO fix needed)
* Find free eDMAc channels and enable edmac_memcpy (channel 7,14,15 is reported as "unused?" in debug menu)
* Investigate how many dma channels we have, I have seen DMA0 is ghidra, but not DMA1.
* Investigate liveView
* Iso register investigation
* Bulb mode investigation
* ect ..


Small (random listed)
* Verify that we have 16 edmac channels
* Find Base Clock Mhz and compute default fps in liveView
* Compute FPS_REGISTER_B default (computed, see code at 0xFFFFA050) FPS_REGISTER_A = 0A070A07h (defined at 0xFFFFA130)
* Implement take_screenshot (FIO fix needed)
* Perform benchmark with slow and fast CF cards (bench.mo - FIO fix needed)
* Use Digit Poke to check for CF UDMA 3/4 support
  -> CFA3.0 is supported (string is present in FW)
  -> cfSetTiming does not touch UDMA registers
  -> 1Ds Mk III (DIGIC III) supports UDMA mode 3 - 45 MB/S
  -> new 2019 CF disks just uses CFA3.0 80 ns access (pio mode I guess) - see dumpf log below
* Test arkanoid for a couple of hours (long term test - FIO fixed needed)
* Investigate dump log (startup + enabling liveview), maybe the experts can find some interessing stuff in there ?

Canon 40d "dumpf" log from camera (Properly from source 3.). I started the camera and went into LiveView and then disabled LiveView again.
https://drive.google.com/file/d/10SMuQdFO1qWTv7p5qGRpd0wwj211At_6/view?usp=sharing

/heder
Embedded SW engineer. Current Cameras: Canon 20d, Canon 40d

Ant123

  • Contributor
  • Member
  • *****
  • Posts: 121
Re: [UNMAINTAINED] Canon 40D
« Reply #430 on: September 03, 2019, 12:07:09 PM »
heder

Do you have the same problem with ML menu in LV mode?

heder

  • New to the forum
  • *
  • Posts: 16
Re: [UNMAINTAINED] Canon 40D
« Reply #431 on: September 03, 2019, 02:39:20 PM »
heder

Do you have the same problem with ML menu in LV mode?

I cannot said yet, LiveView is'nt enabled and supported on my build yet, but I will keep that in mind.

I don't known about 450D, but in Canon 40D LiveView has no special button, and must be enabled in Canon menu system. Once enabled LiveView can be enabled in some mode when pressing "set" button.
Embedded SW engineer. Current Cameras: Canon 20d, Canon 40d

Ant123

  • Contributor
  • Member
  • *****
  • Posts: 121
Re: [UNMAINTAINED] Canon 40D
« Reply #432 on: September 03, 2019, 04:51:27 PM »
I don't known about 450D, but in Canon 40D LiveView has no special button, and must be enabled in Canon menu system. Once enabled LiveView can be enabled in some mode when pressing "set" button.

EOS 450D also uses "Set" button to turn on LiveView.

for your camera see page 161

heder

  • New to the forum
  • *
  • Posts: 16
Re: [UNMAINTAINED] Canon 40D
« Reply #433 on: September 03, 2019, 09:32:39 PM »
I realized driving home from work that CF card system was really slow, so I did a really quick test.  It turns out that ML uses the CF card system before it was initialized which leads to wrong behaviour and lock of the file system. Inserting a long delay after inside ml_init_task before executing anything else solved the FIO issue.  :)

* Fonts can be loaded
* Camera can shoot images
* Camera can dump logs and ROMs
Embedded SW engineer. Current Cameras: Canon 20d, Canon 40d

aprofiti

  • Contributor
  • Member
  • *****
  • Posts: 177
Re: [UNMAINTAINED] Canon 40D
« Reply #434 on: September 06, 2019, 06:12:54 PM »
@heder Can you load modules?
Make sure module_task is launched from ml_big_init_task() inside custom init.c

I get wrong behaviour with 5DC, they are listed with wrong filename (it show only last 4 characters of the module's name) so can't be found on card.
Would like to know if it’s the same with 40D.

heder

  • New to the forum
  • *
  • Posts: 16
Re: [UNMAINTAINED] Canon 40D
« Reply #435 on: September 07, 2019, 03:57:24 PM »
@heder Can you load modules?
Make sure module_task is launched from ml_big_init_task() inside custom init.c

I get wrong behaviour with 5DC, they are listed with wrong filename (it show only last 4 characters of the module's name) so can't be found on card.
Would like to know if it’s the same with 40D.

Hi. No I don't have the issue you have. I can now load modules in the camera - Arkanoid and File_mgr works just fine.


Embedded SW engineer. Current Cameras: Canon 20d, Canon 40d

aprofiti

  • Contributor
  • Member
  • *****
  • Posts: 177
Re: [UNMAINTAINED] Canon 40D
« Reply #436 on: September 07, 2019, 04:51:00 PM »
Thanks for checking. Need to figure out somehow to solve the issue, I'll try to have a look again

heder

  • New to the forum
  • *
  • Posts: 16
Re: [UNMAINTAINED] Canon 40D
« Reply #437 on: September 10, 2019, 10:44:01 AM »
More stubs found
  • _EngDrvOut,_engio_write,shamen_read
  • Cancel(Stop)DateTimer,StartTimerAfter
  • dm_Set_store_level
  • and others ..
   
* Interface to dm_det_store_level on Canon 40D is different than other camera, but input data is the same, so I'm creating a wrapper function. 40D interface is
Code: [Select]
foo(uint32_t *) Newer camera uses
Code: [Select]
foo(uint32_t,uint32_t)
 
* Bulb mode does'nt work, PROP SW1 and SW2 is not defined exactly as in newer camera, but call("dumpf") revealed the SW1 and SW2   
  is defined. The old property values are 0x80002001{5/6} but Canon 40D checks on 0x1000002B (SW1) and 0x1000002D (SW2)
 
  ...    
  562:  4627.423 [GUI] IDLEHandler PRESS_SW1_BUTTON
  ...
  571:  4672.101 [GUI] IDLEHandler PRESS_SW2_BUTTON
  ...
  609:  7982.061 [GUI] IDLEHandler UNPRESS_SW2_BUTTON
  ...
  614:  7999.412 [GUI] IDLEHandler UNPRESS_SW1_BUTTON

 
* take_screenshot() saves incorrectly (but does'nt crash either)
Embedded SW engineer. Current Cameras: Canon 20d, Canon 40d

heder

  • New to the forum
  • *
  • Posts: 16
Re: [UNMAINTAINED] Canon 40D
« Reply #438 on: Yesterday at 03:57:44 PM »
Quick update  :)

I'm still working being the scenes, stubs, reading decompiled code to get the 40D running better. The good thing it that the boot up process work better and better. ML is becomming more
stable and with less crashes.

Boot
  • prop_init() need to be called early on to get all PROP messages. (shutter PROP comes early)
  • CF card is really slow and after prop_init() I sleep 1600 ms before CF card system is ready for use :o

Debug Stuff
  • dm_set_store_level is working fine, dumpf log is being spammed.
  • dm-spy (my_DebugMsg) works in QEMU but not camera - so I'm using internal dumpf

Shooting menu
  • I located a nice function, named is usbShutterActivation, I guess it used via usb to activate shutter release in normal mode, liveview mode and bulb
  • Bulb with intervalometer is now working using usbShutterActivation
  • Bulb in standalone mode is not working (I think half pressed shutter is not detected, but i'm not sure)
  • PROP_SW1 and PROP_SW2 is not present is firmware

Expo menu
  • Started to populate Expo menu and it's better than I expected
  • Shutter works - only minor issue BULB/32". Moving dial to BULB is seen as BULB, but when changing it from within ML from 30" into BULB .. ML says 32"
  • Aperture works - only minor issue is the aperture is not always 100% correct, sometimes only 90% or so
  • ISO works fine
  • White Balance not enabled (PROP modes need to be verified) - now verified and working


Embedded SW engineer. Current Cameras: Canon 20d, Canon 40d

ilex

  • New to the forum
  • *
  • Posts: 19
Re: Canon 40D
« Reply #439 on: Yesterday at 05:36:17 PM »
@heder
Thanks for your great effort to run ML in 40D. Regards