Getting started with development

Started by a1ex, June 07, 2012, 12:55:48 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

a1ex

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:

hg clone https://bitbucket.org/hudson/magic-lantern
cd magic-lantern
hg up qemu -C
cd contrib/qemu
./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


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


Alia5

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

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


miyake

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

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

I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus | EOS 5D MLbeta5- 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, PS, LR, RawTherapee, LightZone -no video experience-

dpham23

How come I don't see a branch for the 5d Mark 3?

scrax

I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus | EOS 5D MLbeta5- 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, PS, LR, RawTherapee, LightZone -no video experience-

NerveGas

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

Is anyone using Eclipse for ML development? 

Thanks

R

nanomad

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

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

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 | EOS 5D MLbeta5- 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, PS, LR, RawTherapee, LightZone -no video experience-

nanomad

Quote from: dslrrookie 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

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

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

yes, try to put the full address with c: instead of the ~
I'm using ML2.3 for photography with:
EOS 600DML | EOS 400Dplus | EOS 5D MLbeta5- 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, PS, LR, RawTherapee, LightZone -no video experience-

deletedAcc.0021

tried both ways, no difference.

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


deletedAcc.0021

I also installed Yagarto Tools, so I would have "make" ... should that path be in the Makefile.user also? And if so where?

RenatoPhoto

Quote from: dslrrookie 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?

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

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

Quote from: dlrpgmsvc 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
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

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

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