- 0 Talk
-
Magic Lantern Development on Mac
Contents |
General Notes - By: Coutts
Edit
I installed this on my 2009 unibody Macbook Pro, running Snow Leopard 10.6.7. This page will help anybody set everything up from scratch. I will first cover how to install the ARM toolchain (to compile magic lantern), and then explain how to setup the arm console for firmware analysis.
Related Links:
My setup:
- Macbook Pro 5,5
- Mac OS X Lion 10.7.1
- Core 2 Duo 2.26GHz processor
- 8gb memory
- Yagarto 4.6.0 (Binutils-2.2.1, Newlib-1.19.0, GCC-4.6.0, GDB-7.2)
- Xcode 3
- yappi 0.53
- Cheetah 2.4.4
- EasyGui 0.96
- profilestats 1.0.2
- ahocorasick 0.9
- pyprof2calltree 1.1.0
- pyparsing 1.5.5
All ports that I have installed, note I have only setup the compiler/toolchain, so everything here is related to that (dependencies, etc)l. These are all going to be installed during the build process:
coutt1aj:ARM-console coutt1aj$ port installed The following ports are currently installed: atk @1.32.0_0 (active) atlas @3.9.37_0+gcc44 (active) autoconf @2.68_2 (active) automake @1.11.1_0 (active) bison @2.5_0 (active) bzip2 @1.0.6_0 (active) cairo @1.10.2_3+x11 (active) curl @7.21.6_0+ssl (active) curl-ca-bundle @7.21.6_0 (active) db46 @4.6.21_6 (active) docbook-xml @5.0_0 (active) docbook-xml-4.1.2 @4.1.2_1 (active) docbook-xml-4.2 @4.2_0 (active) docbook-xml-4.3 @4.3_0 (active) docbook-xml-4.4 @4.4_0 (active) docbook-xml-4.5 @4.5_0 (active) docbook-xml-5.0 @5.0_0 (active) docbook-xsl @1.76.1_0 (active) expat @2.0.1_1 (active) fftw-3 @3.2.2_0 (active) fontconfig @2.8.0_0 (active) freetype @2.4.4_0 (active) gcc44 @4.4.6_0 (active) gcc_select @0.1_5 (active) gd2 @2.0.35_10 (active) gdbm @1.8.3_3 (active) gdk-pixbuf2 @2.22.1_1 (active) getopt @1.1.4_1 (active) gettext @0.18.1.1_2 (active) ghostscript @9.02_0 (active) glib2 @2.28.8_0 (active) gmp @5.0.1_1 (active) gnome-common @2.28.0_0 (active) gnome-doc-utils @0.20.6_0+python27 (active) gperf @3.0.4_0 (active) graphviz @2.28.0_0 (active) groff @1.21_1 (active) gsed @4.2.1_1 (active) gtk-doc @1.17_0+python27 (active) gtk2 @2.24.4_0+x11 (active) gts @0.7.6_1 (active) gzip @1.4_0 (active) hdf5-18 @1.8.7_1 (active) help2man @1.39.3_0 (active) intltool @0.40.6_0 (active) ipython_select @0.1_0 (active) iso-codes @3.25.1_0 (active) jasper @1.900.1_7 (active) jpeg @8c_0 (active) libiconv @1.13.1_0 (active) libidn @1.22_0 (active) libpaper @1.1.24_0 (active) libpixman @0.22.0_0 (active) libpng @1.4.7_0 (active) libtool @2.4_0 (active) libxml2 @2.7.8_0 (active) libxslt @1.1.26_0 (active) m4 @1.4.16_0 (active) makedepend @1.0.3_0 (active) mesa @7.10.2_2+python27 (active) metis @4.0.3_1 (active) mpfr @3.0.1-p3_0 (active) ncurses @5.9_0 (active) ncursesw @5.8_0 (active) netcdf @4.1.1_5+dap+netcdf4 (active) netpbm @10.47.26_0 (active) openssl @1.0.0d_0 (active) p5-getopt-long @2.38_1 (active) p5-locale-gettext @1.05_5 (active) p5-pathtools @3.33_1 (active) p5-scalar-list-utils @1.23_1 (active) p5-xml-parser @2.40_1 (active) pango @1.28.4_0+x11 (active) pcre @8.12_0 (active) perl5 @5.12.3_1+perl5_12 (active) perl5.12 @5.12.3_1 (active) pkgconfig @0.25_2 (active) psutils @p17_1 (active) py26-altgraph @0.9_0 (active) py26-bdist_mpkg @0.4.4_0 (active) py26-configobj @4.6.0_0 (active) py26-dateutil @1.5_0 (active) py26-distribute @0.6.19_0 (active) py26-ipython @0.10.1_3+scientific (active) py26-macholib @1.4.1_0 (active) py26-matplotlib @1.0.1_3+tkinter (active) py26-modulegraph @0.9_0 (active) py26-nose @1.0.0_0 (active) py26-numpy @1.6.0_0+atlas+gcc44 (active) py26-parsing @1.5.5_0 (active) py26-py2app @0.6.3_0 (active) py26-pydot @1.0.25_0 (active) py26-pygraphviz @1.0_0 (active) py26-pyobjc @2.3_0 (active) py26-pyobjc-cocoa @2.3_0 (active) py26-scientific @2.8_2 (active) py26-scipy @0.9.0_0+gcc44 (active) py26-setuptools @0.6c11_1 py26-sympy @0.6.7_0 (active) py26-tkinter @2.6.6_0 (active) py26-tz @2011g_0 (active) py26-wxpython @2.8.10.1_0+gtk (active) py27-libxml2 @2.6.21_0 (active) python26 @2.6.6_3 (active) python27 @2.7.1_3 (active) python_select @0.3_1 (active) rarian @0.8.1_0 (active) readline @6.2.000_0 (active) shared-mime-info @0.90_0 (active) sqlite3 @3.7.6_0 (active) SuiteSparse @3.4.0_0 (active) swig @2.0.4_0 (active) swig-python @2.0.4_0 (active) szip @2.1_2 (active) tcl @8.5.9_0 (active) texinfo @4.13_2 (active) tiff @3.9.5_0 (active) tk @8.5.9_0 (active) urw-fonts @1.0.7pre44_0 (active) wxWidgets-python @2.8.10.1_2+gtk (active) Xft2 @2.2.0_0 (active) xmlcatmgr @2.2_1 (active) xorg-bigreqsproto @1.1.1_0 (active) xorg-compositeproto @0.4.2_0 (active) xorg-damageproto @1.2.1_0 (active) xorg-dri2proto @2.3_0 (active) xorg-fixesproto @5.0_0 (active) xorg-glproto @1.4.12_0 (active) xorg-inputproto @2.0.1_0 (active) xorg-kbproto @1.0.5_0 (active) xorg-libice @1.0.7_0 (active) xorg-libpthread-stubs @0.3_0 (active) xorg-libsm @1.2.0_0 (active) xorg-libX11 @1.4.3_0 (active) xorg-libXau @1.0.6_0 (active) xorg-libXaw @1.0.9_0 (active) xorg-libxcb @1.7_0+python27 (active) xorg-libXcomposite @0.4.3_0 (active) xorg-libXcursor @1.1.11_0 (active) xorg-libXdamage @1.1.3_0 (active) xorg-libXdmcp @1.1.0_0 (active) xorg-libXext @1.3.0_0 (active) xorg-libXfixes @5.0_0 (active) xorg-libXi @1.4.1_0 (active) xorg-libXinerama @1.1.1_0 (active) xorg-libXmu @1.1.0_0 (active) xorg-libXrandr @1.3.1_0 (active) xorg-libXScrnSaver @1.2.1_0 (active) xorg-libXt @1.1.1_0 (active) xorg-randrproto @1.3.2_0 (active) xorg-renderproto @0.11.1_0 (active) xorg-scrnsaverproto @1.2.1_0 (active) xorg-util-macros @1.14.0_0 (active) xorg-xcb-proto @1.6_0+python27 (active) xorg-xcb-util @0.3.8_0 (active) xorg-xcmiscproto @1.2.1_0 (active) xorg-xextproto @7.2.0_0 (active) xorg-xf86bigfontproto @1.2.0_0 (active) xorg-xineramaproto @1.2.1_0 (active) xorg-xproto @7.0.21_0 (active) xorg-xtrans @1.2.6_0 (active) xpm @3.5.9_0 (active) xrender @0.9.6_0 (active) xz @5.0.2_0 (active) zlib @1.2.5_0 (active)
Installing Developer Tools
Edit
You need to install Xcode so that you will have a compiler, it is not installed by default. It is easy to install though. If you have a snow leopard disk, there will be an installer for Xcode under the Optional Installs folder.
If you do not have a snow leopard cd, you can still download Xcode from Apple's website for free. Just follow this link here to download Xcode 3. Once this is all done, you are ready to install the arm-toolchain.
ARM Toolchain Setup
Edit
The easiest route to go by far is Yagarto. It's an easy installer that takes 10 seconds to do. There's no waiting for things to download and compile, it's already done. First, download yagarto from that link above. Then, open readme and follow it word for word. it's fool proof, they explain everything there as far as setting up the toolchain in your .bash_profile and making sure things are working.
EDIT: I've found that putting this addition in .bash_profile will allow the programs to be used:
export PATH=$HOME/yagarto/yagarto-4.6.2/bin:$HOME/yagarto/yagarto-4.6.2/tools:$PATH
Obviously replace this path with the path to your yagarto /bin and /tools folders.
Test that the path variable is working by running:
arm-none-eabi-gcc --version
You should see this as the result:

Added by CouttsPhotogSetting up MacHg
Edit
Now that the compiler and arm-toolchain are all setup and working, it's time to download the magic lantern code and try to compile it. I like to use a program called MacHg, which you can download for free here. After the download is complete and you've installed it (move it to Applications), open it so we can setup the magic lantern repository.

Added by CouttsPhotog
To pull from my repository with experimental daily builds, use this url:
https://bitbucket.org/coutts/magic-lantern-500d
The code will be cloned to your computer at a spot you choose.
Editing the Makefile
Edit
Before we can compile we must edit the make file to point at our binaries in the correct locations. The make file on my repository currently is setup from me compiling on my macbook, so all you will need to change is a couple words. You can find a copy of my Makefile here.
Edit this part of the make file to match your paths and you will be all set to compile.
ARM_PATH=~/yagarto/yagarto-4.6.0 ARM_BINPATH=$(ARM_PATH)/bin GCC_VERSION=4.6.0 CC=$(ARM_BINPATH)/arm-none-eabi-gcc-4.6.0 OBJCOPY=$(ARM_BINPATH)/arm-none-eabi-objcopy AR=$(ARM_BINPATH)/arm-none-eabi-ar RANLIB=$(ARM_BINPATH)/arm-none-eabi-ranlib LD=$(CC) HOST_CC=gcc HOST_CFLAGS=-O3 -W -Wall
Compiling Magic Lantern
Edit
Now that everything is all setup, it's time to see if it compiles. Open up a terminal and cd to the directory you have the repository at on your computer. Then, run:
make clean
followed by
make
It should go through and compile everything (it will take a minute or two depending on your computer). There will be lots of warnings, don't worry, it's fine. If you get an error, look back and see where the first error occured at, it will tell you the file to check and the line number the problem is at. It should compile fine, but if you have any odd issues just email me and I'll help to resolve them.
This will be the output if everything went well (along with a new Autoexec.bin file!!):

Added by CouttsPhotog
So that covers setting up the compiler and arm-toolchain, and compiling magic lantern. Now, if you choose to, you can setup the arm-console for firmware analysis (lots of cool scripts thanks to A1ex).
Setting up the ARM-console
Edit
Ah.. now the fun part, and the part that will take the longest. Set aside a good 3-4 hours for this to finish. Follow these steps and you'll be using the console in no time.
Setting up MacPorts
Edit
******* NOTE: If on OS X 10.7 (Lion) or later, please see the note at the bottom of this page for the required fix. ******* This is what we will use to install the many components we need. Think of it as an equivilant of apt-get for mac. You can download MacPorts here. Setup is easy, just follow the installer. After the installation is complete, be sure to update MacPorts with the following commands (before installing anything always run this):
sudo port selfupdate sudo port upgrade installed
Once this is done, it's time to start installing what we need.
Prerequisites
Edit
Run the following commands in this order, they will take a while dependning on how many dependencies are being installed too. Just wait it out and be patient, it could take several hours.
sudo port install python26 sudo port select python python26 <--this tells os x to use our python 2.6 we just installed sudo port install py26-wxpython py26-numpy py26-matplotlib sudo port install py26-scipypy26-ipython<-- ***see note about ipython below***sudo port select ipython ipython26 <--tells os x to use ipython 2.6sudo port install py26-pygraphviz sudo port install py26-sympy sudo port install py26-pydot
Note: As of now (2012), the default install of ipython from macports is version 0.12, which is NOT compatible with the arm-console. The work around is to install v0.10, and everything will work fine. Instead of using macports, download the ipython 0.10 source from here: http://pypi.python.org/pypi/ipython/0.10
Then simply unzip the tar and run this in the ipython directory:
sudo python setup.py install
and ipython 0.10 will be all installed and working.
Now we'll test matplotlib to make sure ipython and everything is setup correctly. But first we need to do one quick fix for matplotlib.
Create a new text file named matplotlibrc (no extension, make sure it's plain text too) and put this in it:
backend : WXAgg # Use wxpython as the plotting backend.
Save it here, make the .matplotlib directory if needed.
~/.matplotlib/matplotlibrc
Now we are ready to test things out. Open up a new terminal and run:
ipython -pylab
If everything is well, you should see this:

Added by CouttsPhotog
Now run these commands to do a test plot.
import matplotlib.pyplot as plt plt.plot([1,2,3]) plt.show() <-- only if the plot doesn't automatically show after the previous command
If everything is working, you should see this:

Added by CouttsPhotog
Now, we need to finish installing the prerequisits for the ARM-console. Here's what needs to be installed. I've provided links to the ones that will need to be manually installed. The install is easy for those, just download the module, and run this on each of them:
sudo python setup.py install
Here is what you will need to install manually:
Obtaining the ARM-console
Edit
You can obtain the console from A1ex's github repository here. After you download the files, put them all in a folder (I named mine ARM-console). We have to make a couple small changes to the disassembler script since our toolchain is none-eabi and not elf.
Open scripts/disassm.py and go to line 24:
23: gui_enabled = False 24: armelf = "arm-elf-" 25: objcopy = armelf + "objcopy" 26: objdump = armelf + "objdump"
Change to:
23: gui_enabled = False 24: armelf = "arm-none-eabi-" 25: objcopy = armelf + "objcopy" 26: objdump = armelf + "objdump"
And at line 1067:
1067: os.system("arm-elf-as test.asm -o test.elf")
1068: os.system("arm-elf-objcopy -O binary test.elf test-0xff000000.bin")
Change to:
1067: os.system("arm-none-eabi-as test.asm -o test.elf")
1068: os.system("arm-none-eabi-objcopy -O binary test.elf test-0xff000000.bin")
That should take care of all of the required setup. To use the console, open a new terminal and cd to the console directory and run:
python main.py
You should see this if everything is installed and working:

Added by CouttsPhotog
Now you can follow A1ex's guide here to learn what you can do with the console.
In the words of AJ, happy hacking :)
*****************************************************************************************************************************
*****************************************************************************************************************************
Mac OS X 10.7 Lion Compatibility
Edit
In OS X Lion, a new version of xcode has been released, and a couple extra steps must be taken to make things work.
First, instead of downloading Xcode 3, download Xcode 4 from here (must sign in with your apple id): https://developer.apple.com/xcode/
After it is installed, you must download the development tools (gcc compiler, etc). To do this, go to the Downloads tab of the Xcode preferences, and click the install button next to Command Line Tools.
Now you will be all set to install macports and continue with the install normlly. Hope this helps!
- Coutts