{"id":54,"date":"2008-11-26T09:55:35","date_gmt":"2008-11-25T22:55:35","guid":{"rendered":"http:\/\/www.madox.net\/blog\/?p=54"},"modified":"2009-03-25T18:20:34","modified_gmt":"2009-03-25T07:20:34","slug":"compiling-a-toolchain-for-arm7-under-ubuntu","status":"publish","type":"post","link":"http:\/\/www.madox.net\/blog\/2008\/11\/26\/compiling-a-toolchain-for-arm7-under-ubuntu\/","title":{"rendered":"Compiling a toolchain for ARM7 under Ubuntu"},"content":{"rendered":"<p>Well this chronicles my first attempt at compiling a toolchain for programming ARM&#8217;s in ELF code.<\/p>\n<p>Why do I need a toolchain for programming ARMs?<\/p>\n<ol>\n<li>I found a <a href=\"http:\/\/www.google.com.au\/url?sa=t&amp;source=web&amp;ct=res&amp;cd=1&amp;url=http%3A%2F%2Fwww.olimex.com%2Fdev%2Flpc-2378stk.html&amp;ei=2XYsSdLNB5S48ATzw_26BA&amp;usg=AFQjCNEMrqCur9EzTwEAWo7Xr2y93wepgw&amp;sig2=484jqe6-NCOgdYedM5Yd7Q\" target=\"_blank\">LPC2378-STK development board<\/a> in my room<\/li>\n<li>I want to give ARM programming a try (PS WinAVR is great for programming AVRs)<\/li>\n<li>I found I have some spare ARM7 LPC2378&#8217;s lying around (WTF?) and thought I&#8217;ll actually complete my Chumby Speedometer on my car project!<\/li>\n<\/ol>\n<p><!--more-->The compile process should be pretty straight forward, but I made a few stuffup&#8217;s along the way.<\/p>\n<ul>\n<li>I had originally wanted to keep it neat and install to a new directory, then the PATH annoyance thing hit me.\u00a0 Setting the path under my user shell didn&#8217;t carry over when using sudo which is required to make install.\u00a0 Solved using <em>sudo -s<\/em>, but then in the end i just redid it all and installed to <em>\/usr\/local\/<\/em>.<\/li>\n<li>Realised (should have known) that you need &#8216;GMP&#8217; and &#8216;MPFR&#8217; to compile GCC.\u00a0 Available as packages <em>libgmp3-dev<\/em> and<em> libmpfr-dev<\/em> in Ubuntu.<\/li>\n<li>Did my usual of forgetting to set up the prefix install location when configuring&#8230;minor boo boo<\/li>\n<\/ul>\n<h2>Setting it all up<\/h2>\n<p>Install any packages you need&#8230; <em>build-essential<\/em> is probably essential&#8230; GMP and MPFR could be got by using<\/p>\n<blockquote><p>sudo apt-get install libgmp3-dev libmpfr-dev<\/p><\/blockquote>\n<p>Set-up some directories&#8230;I opted to use create an &#8216;arm-elf&#8217; directory in my home to hold both the source and build directories&#8230;<\/p>\n<blockquote><p>cd ~<br \/>\nmkdir arm-elf arm-elf\/src<br \/>\ncd ~\/arm-elf\/src<\/p><\/blockquote>\n<h3>Get the latest sources&#8230;<\/h3>\n<p>Get the latest sources for <a href=\"http:\/\/www.gnu.org\/software\/binutils\/\" target=\"_blank\">binutils<\/a>, <a href=\"http:\/\/gcc.gnu.org\/\" target=\"_blank\">gcc<\/a>, <a href=\"http:\/\/sourceware.org\/newlib\/\" target=\"_blank\">newlib<\/a>, <a href=\"http:\/\/sources.redhat.com\/insight\/\" target=\"_blank\">insight<\/a> (click the links if you need).\u00a0 The versions I used should be obvious from the filenames below.\u00a0 Just be wary that the insight front page is not kept up to date but you&#8217;ll find the latest if you follow any of the release links anyway.<\/p>\n<blockquote><p>wget http:\/\/ftp.gnu.org\/gnu\/binutils\/binutils-2.19.tar.bz2<br \/>\nwget http:\/\/gcc.releasenotes.org\/releases\/gcc-4.3.2\/gcc-4.3.2.tar.bz2<br \/>\nwget ftp:\/\/sources.redhat.com\/pub\/newlib\/newlib-1.16.0.tar.gz<br \/>\nwget ftp:\/\/sourceware.org\/pub\/insight\/releases\/insight-6.8.tar.bz2<\/p><\/blockquote>\n<h3>Unpack the sources&#8230;<\/h3>\n<blockquote><p>tar -xvjf binutils-2.19.tar.bz2<br \/>\ntar -xvjf gcc-4.3.2.tar.bz2<br \/>\ntar -xvzf newlib-1.16.0.tar.gz<br \/>\ntar -xvjf insight-6.8.tar.bz2<\/p><\/blockquote>\n<h3>Tweak the gcc source config&#8230;<\/h3>\n<p>Make a minor config tweak to the gcc source.\u00a0 Edit gcc-4.3.2\/gcc\/config\/arm\/t-arm-elf and append <em>mno-thumb-interwork\/mthumb-interwork<\/em> after MULTILIB_OPTIONS and <em>normal interwork<\/em> after MULTILIB_DIRNAMES.\u00a0 I used nano, see the screenshot below if I haven&#8217;t been too clear \ud83d\ude42<\/p>\n<p><a href=\"http:\/\/www.madox.net\/blog\/wp-content\/uploads\/2008\/11\/screenshot-madoxmadox-laptop-armelf-src-gcc-432-gcc-config-arm.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-55\" title=\"src-gcc-432-gcc-config-arm\" src=\"http:\/\/www.madox.net\/blog\/wp-content\/uploads\/2008\/11\/screenshot-madoxmadox-laptop-armelf-src-gcc-432-gcc-config-arm.png\" alt=\"\" width=\"500\" height=\"331\" srcset=\"http:\/\/www.madox.net\/blog\/wp-content\/uploads\/2008\/11\/screenshot-madoxmadox-laptop-armelf-src-gcc-432-gcc-config-arm.png 657w, http:\/\/www.madox.net\/blog\/wp-content\/uploads\/2008\/11\/screenshot-madoxmadox-laptop-armelf-src-gcc-432-gcc-config-arm-300x198.png 300w\" sizes=\"auto, (max-width: 500px) 85vw, 500px\" \/><\/a><\/p>\n<blockquote><p>nano ~\/arm-elf\/src\/gcc-4.3.2\/gcc\/config\/arm\/t-arm-elf<\/p><\/blockquote>\n<h3>Start building with fingers crossed&#8230;<\/h3>\n<p>Now we can start building the toolchain.\u00a0 Note my prefix is <em>\/usr\/local<\/em>.\u00a0 First off binutils!<\/p>\n<blockquote><p>cd ~\/arm-elf\/<br \/>\nmkdir build build\/binutils-2.19 build\/insight-6.8 build\/gcc-4.3.2 build\/newlib-1.16.0<\/p>\n<p>cd ~\/arm-elf\/build\/binutils-2.19<br \/>\n~\/arm-elf\/src\/binutils-2.19\/configure &#8211;target=arm-elf &#8211;prefix=\/usr\/local &#8211;enable-interwork &#8211;enable-multilib &#8211;with-float=soft &#8211;disable-werror<br \/>\nsudo make all install<\/p><\/blockquote>\n<p>Next just the gcc part of gcc&#8230;note we configure the newlib src headers here&#8230;<\/p>\n<blockquote><p>cd ~\/arm-elf\/build\/gcc-4.3.2<br \/>\n~\/arm-elf\/src\/gcc-4.3.2\/configure &#8211;target=arm-elf &#8211;prefix=\/usr\/local &#8211;enable-interwork &#8211;enable-multilib &#8211;with-float=soft &#8211;disable-werror &#8211;enable-languages=&#8221;c,c++&#8221; &#8211;with-newlib\u00a0 &#8211;with-headers=~\/arm-elf\/src\/newlib-1.16.0\/newlib\/libc\/include<br \/>\nsudo make all-gcc install-gcc<\/p><\/blockquote>\n<p>Now newlib&#8230;<\/p>\n<blockquote><p>cd ~\/arm-elf\/build\/newlib-1.16.0<br \/>\n~\/arm-elf\/src\/newlib-1.16.0\/configure &#8211;target=arm-elf &#8211;prefix=\/usr\/local &#8211;enable-interwork &#8211;enable-multilib &#8211;with-float=soft &#8211;disable-werror<br \/>\nsudo make all install<\/p><\/blockquote>\n<p>Coming back for the rest off gcc (needed newlib)<\/p>\n<blockquote><p>cd ~\/arm-elf\/build\/gcc-4.3.2<br \/>\nsudo make all install<\/p><\/blockquote>\n<p>&#8230;and finally insight gdb<\/p>\n<blockquote><p>cd ~\/arm-elf\/build\/insight-6.8<br \/>\n~\/arm-elf\/src\/insight-6.8\/configure &#8211;target=arm-elf &#8211;prefix=\/usr\/local &#8211;enable-interwork &#8211;enable-multilib &#8211;with-float=soft &#8211;disable-werror<br \/>\nsudo make all install<\/p><\/blockquote>\n<p>Voila done!\u00a0 I should now have all my arm-elf tools!\u00a0 Just a check&#8230;<\/p>\n<blockquote>\n<pre>madox@madox-laptop:\/usr\/local\/bin$ ls arm*\r\narm-elf-addr2line  arm-elf-gcc        arm-elf-insight  arm-elf-run\r\narm-elf-ar         arm-elf-gcc-4.3.2  arm-elf-ld       arm-elf-size\r\narm-elf-as         arm-elf-gccbug     arm-elf-nm       arm-elf-strings\r\narm-elf-c++        arm-elf-gcov       arm-elf-objcopy  arm-elf-strip\r\narm-elf-c++filt    arm-elf-gdb        arm-elf-objdump\r\narm-elf-cpp        arm-elf-gdbtui     arm-elf-ranlib\r\narm-elf-g++        arm-elf-gprof      arm-elf-readelf<\/pre>\n<\/blockquote>\n<p>Yup all there and runs \ud83d\ude42\u00a0 Now the search for the LPC header files&#8230; argh<\/p>\n<p>PS : If you copy and paste my commands, be wary of line breaks&#8230; I didn&#8217;t put \\&#8217;s anywhere&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Well this chronicles my first attempt at compiling a toolchain for programming ARM&#8217;s in ELF code. Why do I need a toolchain for programming ARMs? I found a LPC2378-STK development board in my room I want to give ARM programming a try (PS WinAVR is great for programming AVRs) I found I have some spare &hellip; <a href=\"http:\/\/www.madox.net\/blog\/2008\/11\/26\/compiling-a-toolchain-for-arm7-under-ubuntu\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Compiling a toolchain for ARM7 under Ubuntu&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,17,16],"tags":[24,23,55,14],"class_list":["post-54","post","type-post","status-publish","format-standard","hentry","category-microcontrollers","category-software","category-software-tips-tricks","tag-arm","tag-crosscompiling","tag-microcontrollers","tag-ubuntu"],"_links":{"self":[{"href":"http:\/\/www.madox.net\/blog\/wp-json\/wp\/v2\/posts\/54","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.madox.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.madox.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.madox.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.madox.net\/blog\/wp-json\/wp\/v2\/comments?post=54"}],"version-history":[{"count":6,"href":"http:\/\/www.madox.net\/blog\/wp-json\/wp\/v2\/posts\/54\/revisions"}],"predecessor-version":[{"id":57,"href":"http:\/\/www.madox.net\/blog\/wp-json\/wp\/v2\/posts\/54\/revisions\/57"}],"wp:attachment":[{"href":"http:\/\/www.madox.net\/blog\/wp-json\/wp\/v2\/media?parent=54"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.madox.net\/blog\/wp-json\/wp\/v2\/categories?post=54"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.madox.net\/blog\/wp-json\/wp\/v2\/tags?post=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}