How to get very basic offline compiling on OS X

14 Sep 2010

Hi Guys,

After spending some hours trying to get this working from info on the informationSuperDirtTrack I have come up with a simple solution that works, here you go:

 

First install MacPorts if you have not done so. See: http://www.macports.org/

 

Then install arm-elf-gcc:

 

sudo port install arm-elf-gcc

 

Then check it is installed correctly:

 

arm-elf-gcc-4.5 --version

 

should produce:

 

arm-elf-gcc-4.5 (GCC) 4.5.0

Copyright (C) 2010 Free Software Foundation, Inc.

This is free software; see the source for copying conditions.  There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 

Next we need to make some symbolic links, most code you see seems to use arm-none-eabi so we need to map this to arm-elf:

 

cd /opt/local/bin/

sudo ln -s arm-elf-gcc-4.5 arm-none-eabi-gcc

sudo ln -s arm-elf-as arm-none-eabi-as

sudo ln -s arm-elf-ld arm-none-eabi-ld

sudo ln -s arm-elf-objcopy arm-none-eabi-objcopy

sudo ln -s arm-elf-size arm-none-eabi-size

 

 

Get basic CMIS stuff here (section 5 zip file): http://dev.frozeneskimo.com/notes/compiling_your_own_cmsis_code_for_the_mbed

 

in the unzipped folder:

 

make

cp mbed_test.bin /Volumes/MBED

 

Reset your mBed and you should see the blinking light. It is going at the wrong speed, some issue with the timer stuff.

 

 

 

 

Cheers Andy

14 Sep 2010 . Edited: 14 Sep 2010

I've been working on a more finely tuned, custom-built toolchain for mbed and other ARM devices that works on OS X. (I develop on OS X so it's not a second class cititzen). You can find it here:

http://github.com/hugovincent/arm-eabi-toolchain

Being arm-eabi-* instead of plain old arm-elf-* means you should be able to link against the mbed libraries (although I've never tried). There is a bit of FreeRTOS-specific stuff in there (see the file: patches/freertos-newlib.patch) that you might want to remove too (it does things like thread-local memory and thread safety/reentrancy for FreeRTOS).

 

I also did a port of FreeRTOS to mbed. Some bits of it are slightly broken at the moment but you should be able to directly use the Makefiles and linker scripts from that in your own project:

http://github.com/hugovincent/mbed-freertos

 

Cheers,

Hugo

14 Sep 2010

Hi Hugo,

Thanks for the info, if only I had had found it before I spent hours trying to get it all to work :)

What exactly is the difference between arm-eabi and arm-elf, I must admin the whole thing confused the hell out of me!

Thanks

Andy

15 Sep 2010

Hi Hugo,

 

I have tried your makefile and when making the install_cross it fails, here are the last few lines:

 

ewlib\ 1.17.0\" -DPACKAGE_BUGREPORT=\"\"  -I. -I../../../../../../../newlib-2010q1/newlib/libc/argz -Os -D__NO_SYSCALLS__ -DHAVE_RENAME -DHAVE_SYSTEM -fno-builtin      -ffunction-sections -fdata-sections -g -Os -fno-unroll-loops -fomit-frame-pointer -D__BUFSIZ__=128 -DSMALL_MEMORY -DREENTRANT_SYSCALLS_PROVIDED -D_REENT_ONLY -DSIGNAL_PROVIDED -DHAVE_NANOSLEEP -DHAVE_FCNTL -DHAVE_RENAME -D_NO_GETLOGIN -D_NO_GETPWENT -D_NO_GETUT -D_NO_GETPASS -D_NO_SIGSET    -mthumb -c -o lib_a-envz_remove.o `test -f 'envz_remove.c' || echo '../../../../../../../newlib-2010q1/newlib/libc/argz/'`envz_remove.c

arm-none-eabi-gcc -B/Development/mBed/hugovincent-arm-eabi-toolchain-418b254/build/newlib/arm-none-eabi/thumb/newlib/ -isystem /Development/mBed/hugovincent-arm-eabi-toolchain-418b254/build/newlib/arm-none-eabi/thumb/newlib/targ-include -isystem /Development/mBed/hugovincent-arm-eabi-toolchain-418b254/newlib-2010q1/newlib/libc/include  -mthumb -DPACKAGE_NAME=\"newlib\" -DPACKAGE_TARNAME=\"newlib\" -DPACKAGE_VERSION=\"1.17.0\" -DPACKAGE_STRING=\"newlib\ 1.17.0\" -DPACKAGE_BUGREPORT=\"\"  -I. -I../../../../../../../newlib-2010q1/newlib/libc/argz -Os -D__NO_SYSCALLS__ -DHAVE_RENAME -DHAVE_SYSTEM -fno-builtin      -ffunction-sections -fdata-sections -g -Os -fno-unroll-loops -fomit-frame-pointer -D__BUFSIZ__=128 -DSMALL_MEMORY -DREENTRANT_SYSCALLS_PROVIDED -D_REENT_ONLY -DSIGNAL_PROVIDED -DHAVE_NANOSLEEP -DHAVE_FCNTL -DHAVE_RENAME -D_NO_GETLOGIN -D_NO_GETPWENT -D_NO_GETUT -D_NO_GETPASS -D_NO_SIGSET    -mthumb -c -o lib_a-envz_merge.o `test -f 'envz_merge.c' || echo '../../../../../../../newlib-2010q1/newlib/libc/argz/'`envz_merge.c

arm-none-eabi-gcc -B/Development/mBed/hugovincent-arm-eabi-toolchain-418b254/build/newlib/arm-none-eabi/thumb/newlib/ -isystem /Development/mBed/hugovincent-arm-eabi-toolchain-418b254/build/newlib/arm-none-eabi/thumb/newlib/targ-include -isystem /Development/mBed/hugovincent-arm-eabi-toolchain-418b254/newlib-2010q1/newlib/libc/include  -mthumb -DPACKAGE_NAME=\"newlib\" -DPACKAGE_TARNAME=\"newlib\" -DPACKAGE_VERSION=\"1.17.0\" -DPACKAGE_STRING=\"newlib\ 1.17.0\" -DPACKAGE_BUGREPORT=\"\"  -I. -I../../../../../../../newlib-2010q1/newlib/libc/argz -Os -D__NO_SYSCALLS__ -DHAVE_RENAME -DHAVE_SYSTEM -fno-builtin      -ffunction-sections -fdata-sections -g -Os -fno-unroll-loops -fomit-frame-pointer -D__BUFSIZ__=128 -DSMALL_MEMORY -DREENTRANT_SYSCALLS_PROVIDED -D_REENT_ONLY -DSIGNAL_PROVIDED -DHAVE_NANOSLEEP -DHAVE_FCNTL -DHAVE_RENAME -D_NO_GETLOGIN -D_NO_GETPWENT -D_NO_GETUT -D_NO_GETPASS -D_NO_SIGSET    -mthumb -c -o lib_a-envz_strip.o `test -f 'envz_strip.c' || echo '../../../../../../../newlib-2010q1/newlib/libc/argz/'`envz_strip.c

rm -f lib.a

arm-none-eabi-ar cru lib.a lib_a-dummy.o lib_a-argz_add.o lib_a-argz_add_sep.o lib_a-argz_append.o lib_a-argz_count.o lib_a-argz_create.o lib_a-argz_create_sep.o lib_a-argz_delete.o lib_a-argz_extract.o lib_a-argz_insert.o lib_a-argz_next.o lib_a-argz_replace.o lib_a-argz_stringify.o lib_a-buf_findstr.o lib_a-envz_entry.o lib_a-envz_get.o lib_a-envz_add.o lib_a-envz_remove.o lib_a-envz_merge.o lib_a-envz_strip.o

make[9]: arm-none-eabi-ar: No such file or directory

make[9]: *** [lib.a] Error 1

make[8]: *** [all-recursive] Error 1

make[7]: *** [all-recursive] Error 1

make[6]: *** [all] Error 2

make[5]: *** [multi-do] Error 1

make[4]: *** [all-multi] Error 2

make[3]: *** [all] Error 2

make[2]: *** [all-target-newlib] Error 2

make[1]: *** [all] Error 2

make: *** [cross-newlib] Error 2

Cheers
Andy

15 Sep 2010

I think the important part is this:

make[9]: arm-none-eabi-ar: No such file or directory
which means that the binary utils (first thing to be installed) aren't installed properly (probably the directory you're trying to install to isn't on your PATH).

You can probably fix it by adding a line like:

PATH=/path/to/where/you/installed/it:$PATH
into your ~/.profile or ~/.bashrc (hidden files in your home directory - you can edit them with:
open -a /Applications/TextEdit.app .bashrc 

15 Sep 2010

Hi Hugo,

Thanks for the info.

from your web page "You will need to have GCC, make, binutils and latex installed on your machine to compile all of this. You can get all of these on Mac OS X, by just installing the Apple Developer Tools which are free here."

I have XCode installed.

Also I have made the install-deps.

I cannot see arm-none-eabi-ar anywhere on the system.


Cheers

Andy

 

15 Sep 2010

No, arm-none-eabi-* are installed by the makefile. Building a toolchain is like this:

1) build the binary utilities (linker, assembler and what not)

2) build the compiler(s) (using the previously built binary utilities)

3) build the C(/C++) library(s) (using the previously built compiler and binary utilities).

 

So the first step installs binary utilities to your system. The error you were seeing means the rest of the Makefile can't find them after it installed them. This is because of PATH (an old UNIX notion... the directories on your system to look in when you request a program like arm-non-eabi-ar) doesn't contain the directory where you installed to. In my Makefile, things are installed to the path set by PREFIX:

PREFIX=$(HOME)/Projects/arm-eabi-tools/
You can either change that to somewhere already on the PATH (possibly /usr/local/ - check your path with "echo $PATH") or add this directory to your path (as mentioned in my previous post).

 

Hope that helps,

Hugo

15 Sep 2010

Hi Hugo,

Great thanks for the info, thats the folder I couldn't find. I will give it another go later.

Thanks for the help it is very good of you.

Andy

15 Sep 2010

Hi Hugo,

Worked a dream:

Andrew-Capons-MacBook-Pro:~ andrewcapon$ arm-none-eabi-cpp --version
arm-none-eabi-cpp (GCC) 4.4.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Fantastic, thanks very much for your help and effort on this.

Cheers


Andy

16 Sep 2010

Congrats. The next thing you need to figure out (... are you beginning to understand why the online compiler is such a great idea yet? ...) is the C library. You may not need it, in which case everything is fine, but if you want to use it, you need to provide stub functions that interact with the operating system, boot monitor or hardware directly to suit your application.  In my freertos port project (http://github.com/hugovincent/mbed-freertos) there are a number of stubs for system calls and what not (so fopen can open a file or printf can write to the serial port for example). Some of them aren't complete mind you. If you're not using an operating system, you may or may not still need to provide stubs. The eLua project (amoung many others) provide good examples for the sorts of stub functions you need.

Good luck!

Hugo

16 Sep 2010

Hi Hugo,

Thanks for the useful info, not in much need of the std libs for what I am doing, I will try to get some debug printf stuff going over the serial port and thats about it.

I have already managed to get a 25% performance increase over the mBed compiler/libs for writing to the digital ports, that's a nice improvement.

Next I want to get projects building from XCode....

All the best

Andy

 

 

 

03 Oct 2010

Hi! Any progress on getting this toolchain working from XCode? Thanks.

-Pete

20 Oct 2010

user Hugo Vincent wrote:

Being arm-eabi-* instead of plain old arm-elf-* means you should be able to link against the mbed libraries (although I've never tried).

Hugo, I'm very interested in building mbed code using their libraries, but using offline compilation on Mac OS X. I don't even know where to get the libraries. Can you point me at the right location? Thanks!

 

21 Oct 2010

user Roderick Mann wrote:
Hugo, I'm very interested in building mbed code using their libraries, but using offline compilation on Mac OS X. I don't even know where to get the libraries. Can you point me at the right location? Thanks!
You can get the header files and binary libraries by checking out with Subversion (svn) from here: http://mbed.org/projects/libraries/svn/mbed/trunk

Beyond that, like I said, I've never tried and don't know, sorry. I have heard of others who tried and failed so I presume it's not completely trivial. But you can verify that the GNU tools can read the libraries in that format; for example:

arm-none-eabi-nm --print-armap LPC1768/mbed.ar
prints a full list of symbols in the library.

27 Jun 2013

Any new development?

Did you manage to have offline compilation in OS X?

I tried to use Xcode as my IDE but their were many conflicts with system library when compiling, and had no Idea how to correct the target settings anyway if someone manages to get offline compilation with CLANG->LLVM give me a shout!

27 Jun 2013

Nope not in Xcode.

What you can use on OSX is this: http://lpcxpresso.code-red-tech.com/LPCXpresso/

Register for an account, then they will let you download it, then they will let you register it.

From the mBed website then using a test project export it to Red Code. Make sure you have updated the mbed lib before doing this. Right click on the mbed folder in the project and select update from the menu

Import into Code Red and you can build for the mBed.

I have not got debugging working though, Red Code doesn't seem to support CMSIS-DAP

27 Jun 2013

Now that mbed officially support GCC export, you can just install GCC for ARM from here: https://launchpad.net/gcc-arm-embedded then download/export a project from the online compiler, unzip it, and run "make".

27 Jun 2013

Ok thank you both for the feedback!

27 Jun 2013

Hugo Vincent wrote:

Now that mbed officially support GCC export, you can just install GCC for ARM from here: https://launchpad.net/gcc-arm-embedded then download/export a project from the online compiler, unzip it, and run "make".

Have you got that to work, I had problems?

27 Jun 2013

Andrew Capon wrote:

Hugo Vincent wrote:

Now that mbed officially support GCC export, you can just install GCC for ARM from here: https://launchpad.net/gcc-arm-embedded then download/export a project from the online compiler, unzip it, and run "make".

Have you got that to work, I had problems?

It does work! Maybe I forgot to update the mbed lib last time i tried !