{"id":315,"date":"2013-03-23T23:50:14","date_gmt":"2013-03-23T23:50:14","guid":{"rendered":"http:\/\/retroramblings.net\/?p=315"},"modified":"2023-01-27T20:36:20","modified_gmt":"2023-01-27T20:36:20","slug":"trials-tribulations-and-toolchains","status":"publish","type":"post","link":"https:\/\/retroramblings.net\/?p=315","title":{"rendered":"Trials, Tribulations and Toolchains"},"content":{"rendered":"<p><em><strong>Edit:<\/strong> Future me, nearly 10 years later, says don&#8217;t bother attempting these steps unless you really have no alternative. My comment below about guides found on the net quickly becoming obsolete now applies to this post!<\/em><\/p>\n<p><em>If you&#8217;re using Ubuntu or a derivative, then the arm-none-eabi-&#8230; toolchain is now in the repos, so can easily be installed with apt, and there&#8217;s even an m68k gcc cross compiler too.<\/em><\/p>\n<p><em>&lt;Historical content resumes&#8230;&gt;<\/em><\/p>\n<p>To build the OSD firmware for the Minimig projects, a cross-compilation environment is needed. Configuring GCC for this task can be an arcane process, and aspects tend to change from time to time, so guides found on the net quickly become obsolete. For instance, guides recommending the target &#8220;arm-elf&#8221; will fail with the latest GCC. Instead we need to use the target &#8220;arm-none-eabi&#8221;.<\/p>\n<p>Here&#8217;s how I built a toolchain for building both M68K (Chameleon Minimig port) and ARM (Original Minimig and <a href=\"http:\/\/www.harbaum.org\/till\/mist\/index.shtml\">MiST<\/a>) versions of the firmware:<br \/>\n<!--more--><br \/>\nFirstly I downloaded the latest versions of Binutils, GCC and Newlib. At the time of writing these were: Binutils 2.23.1, GCC 4.8.0 and Newlib 2.0.0.<\/p>\n<p>Unpack all three tarballs into the same toplevel directory, then proceed as follows.<br \/>\nGCC is a bit of a special case when it comes to compiling. Rather than simply issuing the usual .\/configure \/ make \/ make install commands from the toplevel directory, we have to create a target-specific build directory, and issue the configure command from within. (This is compulsory for GCC. It&#8217;s not compulsory for binutils, but a good idea nonetheless, since we&#8217;re going to be building for two different targets.)<\/p>\n<p><code>cd binutils-2.23.1<br \/>\nmkdir arm-none-eabi<br \/>\ncd arm-none-eabi<br \/>\n..\/configure --target=arm-none-eabi --prefix=\/opt\/arm-none-eabi<br \/>\nmake<br \/>\nsudo make install<br \/>\ncd ..\/..\/<\/code><\/p>\n<p>Now we need to add the newly-compiled binutils to the PATH so they can be used when building GCC:<\/p>\n<p><code>export PATH=\/opt\/arm-none-eabi\/bin:$PATH<\/code><\/p>\n<p>Before building GCC we need to link newlib into it, like so:<\/p>\n<p><code>cd gcc-4.8.0<br \/>\nln -s ..\/newlib-2.0.0\/newlib .<\/code><\/p>\n<p>Now we can make a directory to hold build files, and build GCC.<\/p>\n<p><code>mkdir arm-none-eabi<br \/>\ncd arm-none-eabi<br \/>\n..\/configure --target=arm-none-eabi --prefix=\/opt\/arm-none-eabi --enable-languages=c --with-newlib<br \/>\nmake<br \/>\nsudo make install<br \/>\ncd ..\/..\/<br \/>\n<\/code><\/p>\n<p>That&#8217;s all there is to it. The toolchain is now complete enough to build <a href=\"http:\/\/www.harbaum.org\/till\/mist\/files.html\">the firmware<\/a> for the <a href=\"http:\/\/www.harbaum.org\/till\/mist\/index.shtml\">MiST project.<\/a> At the time of writing the makefile needs one small adjustment; it assumes that the toolchain has been built with the target &#8220;arm-elf&#8221; &#8211; but as mentioned earlier that target is no longer available, so just change the first line of the Makefile to read:<br \/>\n<code>BASE = arm-none-eabi<\/code><\/p>\n<p>If we want an m68k toolchain the steps are almost identical:<\/p>\n<p><code>cd binutils-2.23.1<br \/>\nmkdir m68k-elf<br \/>\ncd m68k-elf<br \/>\n..\/configure --target=m68k-elf --prefix=\/opt\/m68k-elf<br \/>\nmake<br \/>\nsudo make install<\/code><\/p>\n<p><code><code><\/code><\/code><\/p>\n<p>export PATH=\/opt\/m68k-elf\/bin:$PATH<\/p>\n<p><code><br \/>\n<\/code><\/p>\n<p><code>cd ..\/..\/gcc-4.8.0<br \/>\n# I assume you've already linked newlib in by this point, but if not:<br \/>\n# ln -s ..\/newlib-2.0.0\/newlib .<br \/>\nmkdir m68k-elf<br \/>\ncd m68k-elf<br \/>\n..\/configure --target=m68k-elf --prefix=\/opt\/m68k-elf --enable-languages=c --with-newlib<br \/>\nmake<br \/>\nsudo make install<\/code><\/p>\n<p>The only other thing needed for the m68k is <a href=\"http:\/\/sun.hasenbraten.de\/vasm\/\">VASM, which you can find here.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Edit: Future me, nearly 10 years later, says don&#8217;t bother attempting these steps unless you really have no alternative. My comment below about guides found on the net quickly becoming obsolete now applies to this post! If you&#8217;re using Ubuntu &hellip; <a href=\"https:\/\/retroramblings.net\/?p=315\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[],"class_list":["post-315","post","type-post","status-publish","format-standard","hentry","category-amiga","category-fpga"],"_links":{"self":[{"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts\/315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=315"}],"version-history":[{"count":13,"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts\/315\/revisions"}],"predecessor-version":[{"id":1961,"href":"https:\/\/retroramblings.net\/index.php?rest_route=\/wp\/v2\/posts\/315\/revisions\/1961"}],"wp:attachment":[{"href":"https:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/retroramblings.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}