Hi all, this is mostly in response to steev’s query in my last post… been meaning to post this up for a while now.
CodeSourcery have done some excellent work maintaining the GNU toolchain for the ARM EABI target, among others. They make their money selling and supporting precompiled versions for Win32/i386 and Linux/i386, and do publish their sources for others to download.
That said, it is not easy to reproduce the toolchain using the supplied build script. I think the idea is one is meant to purchase a prebuilt toolchain, which certainly has its advantages… and one should consider doing so anyway even if they get a homebrew one to work — just as a thank-you for providing the patched sources (I would if I could)… but there are numerous reasons why the prebuilt toolchains may not be ideal. In my case, it happens to be that my host platform is Gentoo/MIPS running on my Yeeloong … I can run i386 code thanks to Bochs… very slowly. (I also plan to do bare-iron i386 coding on the same machine… and yes, I’ve installed a hand-built toolchain for that too.) Native code however is far more favourable.
Disclaimer: The methods and code presented here are in no way supported by myself, CodeSourcery, or Gentoo. Some assistance may be sought on the CodeSourcery GNU-ARM mailing list, but in essence there’s no warranty given whatsoever.
Okay, with that over with… the first thing to do is download CodeSourcery’s sources. Head over to the G++ Lite download page and select the latest release… then look for the source tarball. It’ll be big, in the order of 120MB.
Unpack this in a directory of your choice that’s got plenty of space. The sources are packaged Russian-doll style, that is compressed tarballs within an arm-RELEASE-arm-none-eabi directory. In my case, I used release 2009q3-68.
Now, in there is a build script… Have a squiz at that, as there may be changes needed. I’ve tried to distill these into a Makefile which I have attached here. Decompress it then drop it in the source build directory created when you unpacked the CodeSourcery source tarball.
Give it a quick check over, comparing it against the build script to ensure things haven’t changed too drastically… if parameters have changed in the build script, you’ll need to change them in the Makefile. In addition, the TARGET will need to match your desired toolchain target (I used arm-stellaris-eabi) and CS_VER, the version of CodeSourcery downloaded. Some of the embedded packages may have changed version numbers too — these may need tweaking.
When happy, run make. It should go ahead and build you a toolchain. It’ll get installed to whereever your PREFIX was set to.
Other tools of the trade:
The above gives you a working toolchain for compiling, and a command line debugger (gdb). Two additional tools that I find useful:
- OpenOCD which is available in Gentoo as dev-util/openocd… will let you program and debug your application via JTAG.
- Insight debugger… a frontend to gdb. The Gentoo ebuild is out of date, and it’s a pain to write an ebuild for, as evidently the Insight team have never heard of DESTDIR. (How do they write their RPM specs?)
The latter is pretty straightforward to do by hand… just remember to use the same target as your toolchain. Versions prior to 6.8-1 will fail to run on modern X.