Author Topic: Getting started with development  (Read 110248 times)

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 11519
  • 5D Mark Free
Getting started with development
« on: June 07, 2012, 12:55:48 PM »
Step 1. Get the source code
hg clone -u unified https://bitbucket.org/hudson/magic-lantern


Step 2. Get a compiler


2a -> pre-built toolchain from gcc-arm-embedded (preferred 5_4-2016q3, but any other version should work)

Manual toolchain setup should be straightforward on Linux, Mac and Windows Subsystem for Linux.

General instructions:

Either unzip the downloaded toolchain in your HOME directory (for example, you may get ~/gcc-arm-none-eabi-5_4-2016q3/bin/arm-none-eabi-gcc), or install a package that provides arm-none-eabi-gcc and make sure it's in your executable PATH. That way, the compiler will be picked up by our Makefiles without additional tweaking.

Ubuntu: package gcc-arm-none-eabi (older) or gcc-arm-embedded from ppa:team-gcc-arm-embedded/ppa (latest). Or just unzip the downloaded toolchain into your HOME directory if you prefer to avoid a system-wide installation.

Mac: the easiest way is probably this tutorial from Daniel Fort, but manual setup should work just as well.

Windows 10 WSL is known to require some tweaking (such as installing an X server for QEMU), but generally works well.

Windows (native, without WSL): you may install Cygwin (but make sure there are no spaces in your username). For Windows XP you will have to use an older version of Cygwin, but other than that, it should work without much trouble.




2b -> QEMU installation script will download the recommended toolchain and install it for you.

This method is recommended for Ubuntu, Mac and Win10 WSL; other Linux distros may require additional tweaking.

Besides setting up and compiling QEMU, this script also installs the ARM compiler and debugger, and will provide an environment to run your camera firmware and Magic Lantern in the emulator (very useful for debugging and reverse engineering - check out the guide).

Videos: for Ubuntu and Mac (todo: WSL and native Windows).



To run QEMU install script:
Code: [Select]
hg clone https://bitbucket.org/hudson/magic-lantern
cd magic-lantern
hg up qemu -C
./install.sh



2c -> Linaro bare-metal toolchain should also work (use ARM_ABI=eabi in Makefile.user).



2d -> pre-built VM if you feel lazy (Kudos to Anton2707) (User/Root password is 123456)

Also, nikfreak has a VM available here (with ARM-console preinstalled).

Note: these VMs are old and do not have the latest bells and whistles (QEMU etc), but these should be easy to install.



2e -> Docker (experimental, feedback welcome if you decide to try it)



2f -> Build the compiler yourself.



Step 3. Start hacking

Code: [Select]
hg up unified -C
cd platform/550D.109
make clean && make zip
make install
make install_qemu

Useful branches

- unified (mainline)
- Experiments section on the download page (WIP stuff)
- Pull requests on Bitbucket (same)
- All branches (lots of unfinished work and experiments)
- crop_rec_4k (4K recording and lossless compression, very bleeding edge)
- dm-spy-experiments (logging tools for reverse engineering)
- iso-research (CMOS/ADTG ISO experiments, adtg_gui, raw_diag)
- qemu (camera firmware emulation)
- new-sound-system (experimental audio controls for DIGIC 5)
- 1200D, 1300D, 100D_merge_fw101, 70D_merge_fw112, 5Ds_experiments etc (ports in progress)
- vxworks (450D, 40D, other oldies are welcome); vxworks-dm-spy (logging)
- digic6-dumper (80D, 750D, 7D2 etc)
- recovery (experiments running from bootloader context, mostly diagnostics or ROM dumping)

Useful stuff

- Writing modules tutorial #1: Hello, World!
- How can I run Magic Lantern in QEMU? (aka QEMU guide)
- EOS firmware in QEMU - development and reverse engineering guide (must read for understanding how the firmware works)
- Notes on old wiki: http://www.magiclantern.wikia.com/wiki/For_Developers
- Using WiFi SD (FlashAir and Transcend) to avoid swapping the card back and forth
- Speed up compilation:
   export MAKEFLAGS="-j8"  # parallel build
   make install ML_MODULES="lua ettr"  # only compile the modules you are interested in
- Examine ASM code: tag a function with DUMP_ASM, then run: make dump_asm
- Stack trace in crash logs
- Submitting a pull request

miyake

  • Developer
  • Senior
  • *****
  • Posts: 396
Re: Getting started with development
« Reply #1 on: July 23, 2012, 05:29:36 PM »
deleted

Alia5

  • Freshman
  • **
  • Posts: 99
  • 600D
Re: Getting started with development
« Reply #2 on: July 23, 2012, 11:10:39 PM »
I'm a litte bit scared of this line of the wiki
Run make and keep your fingers crossed!
make

This will compile a new autoexec.bin, which contains unencrypted ARM code, ready to brick your camera (God forbid...) See Build_instructions for next steps.

But on the Link wich leads me further I cant read anything that would help...

so it wont brick my camera? or what?

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 11519
  • 5D Mark Free
Re: Getting started with development
« Reply #3 on: July 23, 2012, 11:17:28 PM »
When you alter the source code you need to be much more careful that with things already tested for hundreds or thousands of hours.

See also http://magiclantern.wikia.com/wiki/Unbricking - it contains my mistakes and how I've fixed them.

Alia5

  • Freshman
  • **
  • Posts: 99
  • 600D
Re: Getting started with development
« Reply #4 on: July 23, 2012, 11:25:49 PM »
Alright, thanks a lot!

miyake

  • Developer
  • Senior
  • *****
  • Posts: 396
Re: Getting started with development
« Reply #5 on: July 24, 2012, 04:39:38 AM »
I'm understanding that is ML advantage is not changing boot sequence constantly.
Most cell phones hack is every time build boot sequence , So the brick risk is very high.
But ML change a boot sequence only one time which is installing.

So my understanding:
It's nothing to brick which is broken boot sequence installing with  changing only autoexec.bin .
BTW Cannon firmware does not solve invalid NVRAM config. So If we write a invalid config value from custom autoexec.bin , Canon firmware will not boot.(but recovery method available)

Anyway, anybody not guaranteed . At your own risk when you built your own built.
So you do not take a this risk. Use release version of ML

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 11519
  • 5D Mark Free
Re: Getting started with development
« Reply #6 on: July 24, 2012, 07:43:42 AM »
That's right. Except that ML does never overwrite executable bootloader code, it just sets a flag in the bootloader data area by calling a Canon function. This is a feature probably used by them for troubleshooting (hint: EOS_DEVELOP).

scrax

  • Developer
  • Hero Member
  • *****
  • Posts: 1417
  • Code monkey
Re: Getting started with development
« Reply #7 on: November 09, 2012, 07:06:50 AM »
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus - EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX Lion, Photoshop & Lightroom -no video experience- MLTools

dpham23

  • New to the forum
  • *
  • Posts: 1
Re: Getting started with development
« Reply #8 on: December 05, 2012, 09:20:56 PM »
How come I don't see a branch for the 5d Mark 3?

scrax

  • Developer
  • Hero Member
  • *****
  • Posts: 1417
  • Code monkey
Re: Getting started with development
« Reply #9 on: December 05, 2012, 10:57:55 PM »
it's all in the unified
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus - EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX Lion, Photoshop & Lightroom -no video experience- MLTools

NerveGas

  • New to the forum
  • *
  • Posts: 20
Re: Getting started with development
« Reply #10 on: March 03, 2013, 04:16:13 AM »
I have my own build compiled, before I turn on the boot flat with this file: how do i turn it off later on?

littlefooch

  • New to the forum
  • *
  • Posts: 1
Re: Getting started with development
« Reply #11 on: April 15, 2013, 02:44:42 PM »
Is anyone using Eclipse for ML development? 

Thanks

R

nanomad

  • Administrator
  • Hero Member
  • *****
  • Posts: 2918
  • All your websites are belong to us
Re: Getting started with development
« Reply #12 on: April 15, 2013, 03:32:24 PM »
I tried but there are so many platform-specific defines it's almost impossible. You need to use a custom makefile builder and specify the correct target
EOS 1100D | EOS 650 (No, I didn't forget the D) | Ye Olde Canon EF Lenses ('87): 50 f/1.8 - 28 f/2.8 - 70-210 f/4 | EF-S 18-55 f/3.5-5.6 | Metz 36 AF-5

deletedAcc.0021

  • Member
  • ***
  • Posts: 238
  • 600d x 4
Re: Getting started with development
« Reply #13 on: May 03, 2013, 02:31:19 PM »
any idea what is wrong here?  this is what I get when I run "make 600d"

C:\MLnew\magic-lantern>make 600d
process_begin: CreateProcess(NULL, date +%Y-%m-%d, ...) failed.
/usr/bin/sh: date: command not found
process_begin: CreateProcess(NULL, pwd, ...) failed.
make -C /platform/600D.102
make: *** /platform/600D.102: No such file or directory.  Stop.
make: *** [600d] Error 2

scrax

  • Developer
  • Hero Member
  • *****
  • Posts: 1417
  • Code monkey
Re: Getting started with development
« Reply #14 on: May 03, 2013, 02:33:51 PM »
try:
make 600D

with the uppercase D

and are you in the source folder when launcing this command? I've no experience on win so not sure if that's the problem
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus - EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX Lion, Photoshop & Lightroom -no video experience- MLTools

nanomad

  • Administrator
  • Hero Member
  • *****
  • Posts: 2918
  • All your websites are belong to us
Re: Getting started with development
« Reply #15 on: May 03, 2013, 02:46:19 PM »
any idea what is wrong here?  this is what I get when I run "make 600d"

C:\MLnew\magic-lantern>make 600d
process_begin: CreateProcess(NULL, date +%Y-%m-%d, ...) failed.
/usr/bin/sh: date: command not found
process_begin: CreateProcess(NULL, pwd, ...) failed.
make -C /platform/600D.102
make: *** /platform/600D.102: No such file or directory.  Stop.
make: *** [600d] Error 2

Windows, good luck :P
EOS 1100D | EOS 650 (No, I didn't forget the D) | Ye Olde Canon EF Lenses ('87): 50 f/1.8 - 28 f/2.8 - 70-210 f/4 | EF-S 18-55 f/3.5-5.6 | Metz 36 AF-5

deletedAcc.0021

  • Member
  • ***
  • Posts: 238
  • 600d x 4
Re: Getting started with development
« Reply #16 on: May 03, 2013, 03:33:41 PM »
tried the upper case D .. same error.  I think it might be an error in Makefile.user

my windows path to yagarto is: c:/yagarto, so would it be the same in makefile.user or with the ~


# Path-related stuff
# for yagarto or the official ARM toolchain use ARM_ABI=none-eabi otherwise use ARM_ABI=elf
CCACHE=ccache
ARM_ABI=none-eabi
ARM_PATH=~/yagarto
ARM_BINPATH=$(ARM_PATH)/bin/arm-none-eabi-gcc-4.7.2
#GCC_VERSION=4.7.2
#OBJCOPY=$(ARM_BINPATH)/arm-$(ARM_ABI)-objcopy
#AR=$(ARM_BINPATH)/arm-$(ARM_ABI)-ar
#RANLIB=$(ARM_BINPATH)/arm-$(ARM_ABI)-ranlib
#READELF=$(ARM_BINPATH)/arm-$(ARM_ABI)-readelf

scrax

  • Developer
  • Hero Member
  • *****
  • Posts: 1417
  • Code monkey
Re: Getting started with development
« Reply #17 on: May 03, 2013, 03:38:33 PM »
yes, try to put the full address with c: instead of the ~
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus - EF 100mm f/2.8 USM Macro  - EF-S 17-85mm f4-5.6 IS USM - EF 70-200mm f/4 L USM - 580EXII - OsX Lion, Photoshop & Lightroom -no video experience- MLTools

deletedAcc.0021

  • Member
  • ***
  • Posts: 238
  • 600d x 4
Re: Getting started with development
« Reply #18 on: May 03, 2013, 03:42:36 PM »
tried both ways, no difference.

double checked the ARM path, BINPath and version ... all correct.


deletedAcc.0021

  • Member
  • ***
  • Posts: 238
  • 600d x 4
Re: Getting started with development
« Reply #19 on: May 03, 2013, 03:45:19 PM »
I also installed Yagarto Tools, so I would have "make" ... should that path be in the Makefile.user also? And if so where?

RenatoPhoto

  • Moderators
  • Hero Member
  • *****
  • Posts: 1509
  • 5DM3 / 7D
Re: Getting started with development
« Reply #20 on: May 03, 2013, 04:20:19 PM »
I also installed Yagarto Tools, so I would have "make" ... should that path be in the Makefile.user also? And if so where?

Here is the link to the windows installation guide by Pel

http://www.magiclantern.fm/forum/index.php?topic=2899.msg14021#msg14021

Also note my Makefile.user user for windows here

http://www.magiclantern.fm/forum/index.php?topic=2899.msg31741#msg31741
http://www.pululahuahostal.com  |  EF 300 f/4, EF 100-400 L, EF 180 L, EF-S 10-22, Samyang 14mm, Sigma 28mm EX DG, Sigma 8mm 1:3.5 EX DG, EF 50mm 1:1.8 II, EF 1.4X II, Kenko C-AF 2X

dlrpgmsvc

  • Senior
  • ****
  • Posts: 398
  • The 7D and 50D Robin Hood
Re: Getting started with development
« Reply #21 on: May 17, 2013, 05:44:59 PM »
Now i can compile ! But what is the procedure to put my modifications online as a "pull request" ? Many thanks !  :P
If you think it's impossible, you have lost beforehand

nanomad

  • Administrator
  • Hero Member
  • *****
  • Posts: 2918
  • All your websites are belong to us
Re: Getting started with development
« Reply #22 on: May 18, 2013, 02:03:08 AM »
Now i can compile ! But what is the procedure to put my modifications online as a "pull request" ? Many thanks !  :P
After you fork the repo on bitbucket.org you can push your changes to it and then click on the pull request button
EOS 1100D | EOS 650 (No, I didn't forget the D) | Ye Olde Canon EF Lenses ('87): 50 f/1.8 - 28 f/2.8 - 70-210 f/4 | EF-S 18-55 f/3.5-5.6 | Metz 36 AF-5

dlrpgmsvc

  • Senior
  • ****
  • Posts: 398
  • The 7D and 50D Robin Hood
Re: Getting started with development
« Reply #23 on: May 18, 2013, 02:02:51 PM »
Many thanks, Nanomad ! But now I cannot find how to sync my pc local sources with BitBucket sources on my fork repository. I have found "download" but it's for only one file at-a-time. I found "Import/Export" but it's only for "issues". How can I proceed ? Many thanks again !
If you think it's impossible, you have lost beforehand

nanomad

  • Administrator
  • Hero Member
  • *****
  • Posts: 2918
  • All your websites are belong to us
EOS 1100D | EOS 650 (No, I didn't forget the D) | Ye Olde Canon EF Lenses ('87): 50 f/1.8 - 28 f/2.8 - 70-210 f/4 | EF-S 18-55 f/3.5-5.6 | Metz 36 AF-5