Magic Lantern Forum

Developing Magic Lantern => General Development => Topic started by: trsaunders on July 03, 2012, 02:36:55 PM

Title: ARM Toolchain
Post by: trsaunders on July 03, 2012, 02:36:55 PM
I've built the toolchain, had to use -mlong-calls in Makefile.inc, but I got ML compiled.

In platforms/, there is a folder 50D.109. Does this mean I need firmware 1.0.9 on my 50D? I currently have 1.0.8 and the ML release from December.
Title: Re: ARM Toolchain
Post by: nanomad on July 03, 2012, 02:47:59 PM
If you had to use -mlong-calls chances are you're using a 64bit compiler.
In order to test and develop Magic Lanter properly, I suggest you use a 32bit arm compiler. If you're on linux there's no need to use a 32 bit distrubtion, you just need to install libc6-i386
Title: Re: ARM Toolchain
Post by: trsaunders on July 03, 2012, 03:10:51 PM
I thought I might be better off with a 32bit compiler. I'm running ubuntu 12.04, and I have libc-i386 installed. Is there a way to modify summon-arm to force it to build a 32bit toolchain, or should I just use the vmware image?
Title: Re: ARM Toolchain
Post by: a1ex on July 03, 2012, 03:35:19 PM
If you can force the arm-toolchain to build a 32-bit compiler, please post the patch so I can commit it.
Title: Re: ARM Toolchain
Post by: nanomad on July 03, 2012, 03:57:53 PM
I'm using the codesourcery toolchain for my 1100D work. It's pre-built and works fine.

http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/

Title: Re: ARM Toolchain
Post by: a1ex on July 03, 2012, 04:00:53 PM
Didn't work for me, but that was back in 2010... http://magiclantern.wikia.com/wiki/Build_instructions/550D#Compilers_which_do_not_work
Title: Re: ARM Toolchain
Post by: nanomad on July 03, 2012, 04:03:17 PM
Now it works fine. Both at my home and on ML server :)
Title: Re: ARM Toolchain
Post by: trsaunders on July 03, 2012, 04:16:23 PM
thanks for the tips, I will try out that toolchain  :D

I had a problem running make docs. On ubuntu, rst2latex is just installed as rst2latex not rst2latex.py. I created a symlink in /usr/bin and that sorted it out.
Title: Re: ARM Toolchain
Post by: trsaunders on July 03, 2012, 04:55:17 PM
I downloaded Codesourcery ARM EABI (http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/arm-eabi), choosing 'IA32 GNU/Linux TAR'. Extracted to my home directory and updated Makefile.inc:

ARM_ABI = none-eabi
ARM_PATH=~/arm-2012.03


and it all builds fine.
Title: Re: ARM Toolchain
Post by: a1ex on July 03, 2012, 04:59:13 PM
Great, so there is now an easy way of building ML!
Title: Re: ARM Toolchain
Post by: nanomad on July 03, 2012, 05:13:03 PM
Quote from: a1ex on July 03, 2012, 04:59:13 PM
Great, so there is now an easy way of building ML!

At least as long as Codesurcery keeps offering the ARM GCC compiler for free  ;)
Title: Re: ARM Toolchain
Post by: trsaunders on July 03, 2012, 07:16:31 PM
ARM also maintain a gcc toolchain (https://launchpad.net/gcc-arm-embedded), I use the same one for ARM CM4 development. I didn't realise I could use it to compile ML, but it works. Binary is a bit smaller than the one produced by the code sourcery toolchain (~365kb vs 328kb)
Title: Re: ARM Toolchain
Post by: nanomad on July 03, 2012, 08:59:53 PM
Well, well, well. A prebuilt stock GCC toolchain mantained by ARM. We should definitely move to this

Thanks  :)
Title: Re: ARM Toolchain
Post by: a1ex on July 03, 2012, 09:27:47 PM
Works for me too (just compiled, did not run). RAM usage for 5D2 binary: 341k (prebuilt GCC) vs 339k (32-bit arm toolchain).
Title: Re: ARM Toolchain
Post by: scrax on July 03, 2012, 09:29:34 PM
Quote from: trsaunders on July 03, 2012, 04:16:23 PM
thanks for the tips, I will try out that toolchain  :D

I had a problem running make docs. On ubuntu, rst2latex is just installed as rst2latex not rst2latex.py. I created a symlink in /usr/bin and that sorted it out.

It was renamed for Osx compatibility, if you know a better way to deal with it...(maybe adding the symlink to Osx with prepare.Lion.sh ?)
Title: Re: ARM Toolchain
Post by: nanomad on July 03, 2012, 09:34:14 PM
In the makefile, check if OS is darwin or not and set the executable name accordingly
Title: Re: ARM Toolchain
Post by: trsaunders on July 03, 2012, 11:56:52 PM
it could be that non OSX platforms also get named with .py. a simple way to check could be to look at the output of `which rst2latex.py`
Title: Re: ARM Toolchain
Post by: scrax on July 04, 2012, 01:09:30 AM
Quote from: trsaunders on July 03, 2012, 11:56:52 PM
it could be that non OSX platforms also get named with .py. a simple way to check could be to look at the output of `which rst2latex.py`
yep, that is good, i've used it for MLTools (https://bitbucket.org/600Dplus/magic-lantern-for-600d/raw/e8d392c584c5/toolchain/MLTools), can you take a look at it to see if could be made more "POSIX" than now, if you want?


EDIT:
in makefile there is already a check for osx but I can't figure how to add:

ifeq ($(UNAME), Darwin)
# Variable declaration for Mac OS X
UMOUNT=hdiutil unmount
CF_CARD=/Volumes/EOS_DIGITAL
else
# Default settings for remaining operating systems
CF_CARD=/media/EOS_DIGITAL
UMOUNT=umount
endif

I can't use this code for the check:

if [ ! $(which rst2latex) ] && [ $(which rst2latex.py) ]; then
    alias rst2latex=rst2latex.py
fi

nor this inserted in the already present check:
alias rst2latex=rst2latex.py


Quote from: trsaunders on July 03, 2012, 07:16:31 PM
ARM also maintain a gcc toolchain (https://launchpad.net/gcc-arm-embedded), I use the same one for ARM CM4 development. I didn't realise I could use it to compile ML, but it works. Binary is a bit smaller than the one produced by the code sourcery toolchain (~365kb vs 328kb)
from what I can understand no osx, true?
Title: Re: ARM Toolchain
Post by: trsaunders on July 12, 2012, 04:39:31 PM
Quote from: scrax on July 04, 2012, 01:09:30 AM
from what I can understand no osx, true?
Unfortunately, that is true. YAGARTO (http://www.yagarto.de/) could be an alternative, but I've not tested with ML.
Title: Re: ARM Toolchain
Post by: a1ex on July 13, 2012, 02:59:32 PM
I've ran Yagarto under Windows (also had to install msys) and worked fine.
Title: Re: ARM Toolchain
Post by: vtrandal on July 31, 2012, 02:03:45 AM
I just made a long post in General Development Discussion about my difficulty building ML using the ARM toolchain I built in my 64-bit Ubuntu 10.04 VM.

From reading this thread I gather that it's because my Ubuntu 10.04 is 64-bit and building a correctly functioning ARM toolchain for ML is just not yet working in 64-bit Linux distributions? I guess I failed to read the fine print somewhere :) My bad.

Oh well I'm installing Ubuntu 12.04 LTS 32-bit right now. I hope that's a good direction to go in. I would much rather have another Ubuntu VM to backup and maintain that develop ML in Windows 7.
Title: Re: ARM Toolchain
Post by: adijiwa on July 31, 2012, 03:30:19 AM
Quote from: vtrandal on July 31, 2012, 02:03:45 AM
I just made a long post in General Development Discussion about my difficulty building ML using the ARM toolchain I built in my 64-bit Ubuntu 10.04 VM.

Use -mlong-calls on 64-bit systems. It will produce slightly larger binaries. From my experience, I have no problems compiling and running ML on 64-bit systems. I use Ubuntu 12.04 64-bit native, not VM.
Title: Re: ARM Toolchain
Post by: vtrandal on July 31, 2012, 04:56:33 AM
Quote from: adijiwa on July 31, 2012, 03:30:19 AM
Use -mlong-calls on 64-bit systems. It will produce slightly larger binaries. From my experience, I have no problems compiling and running ML on 64-bit systems. I use Ubuntu 12.04 64-bit native, not VM.

Sounds good to me. But I have no clue what that is. Can you explain?
Title: Re: ARM Toolchain
Post by: adijiwa on July 31, 2012, 05:22:14 AM
Quote from: vtrandal on July 31, 2012, 04:56:33 AM
Sounds good to me. But I have no clue what that is. Can you explain?

In Makefile.inc, look for CFLAGS variable. Mine looks like this:
CFLAGS=\
        $(FLAGS) \
        -Os \
        -Wall \
        -W \
        -mstructure-size-boundary=32 \
        -Wno-unused-parameter \
        -Wno-implicit-function-declaration \
        -Wno-unused-function \
        -Wno-missing-field-initializers \
        -Wno-format \
        -std=gnu99 \
        -D__ARM__ \
        -I$(PLATFORM_INC) \
        -I$(SRC_DIR) \
        -mlong-calls \


Notice the -mlong-calls at the end of variable.
Title: Re: ARM Toolchain
Post by: vtrandal on July 31, 2012, 12:51:34 PM
Thank you.

With that change the build does seem to progress further.

But it now terminates with an error similar to that described here:
http://www.magiclantern.fm/forum/index.php?topic=1768.0

So, a little progress.