changeset 0:9beb566ded04

starting with the toolchain for building our loadagent
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Sun, 28 Apr 2013 17:36:07 +0000
parents
children da98dc08f575
files .hgignore loadagent/romvars.h toolchain/build+install.sh
diffstat 3 files changed, 120 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Sun Apr 28 17:36:07 2013 +0000
@@ -0,0 +1,6 @@
+re:^toolchain/binutils-2.21.1/
+re:^toolchain/binutils-build/
+re:^toolchain/gcc-4.5.4/
+re:^toolchain/gcc-build/
+re:^toolchain/newlib-2.0.0/
+re:^toolchain/newlib-build/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/loadagent/romvars.h	Sun Apr 28 17:36:07 2013 +0000
@@ -0,0 +1,29 @@
+/*
+ * Our loadagent will always be loaded into Calypso targets by the on-chip
+ * boot ROM operating in the UART download mode.  The lowest IRAM address
+ * at which we can load our code is 0x800750; somewhat lower at 0x800518
+ * the boot ROM downloader has a few variables which may have been intended
+ * to be private to the boot ROM, but which are useful to us.  For example,
+ * by looking at these variables, we can see which of the two UARTs was
+ * used to feed our code to the boot ROM, and use the same UART for
+ * subsequent communication - without building multiple versions of our
+ * loadagent or resorting to other ugliness.
+ *
+ * This header file defines the layout of the IRAM structure in question,
+ * based on the disassembly of the boot ROM.
+ */
+
+struct boot_rom_vars {
+	u8	baud_rate_code;
+	u8	pad1[3];
+	u32	uart_timeout;
+	u8	uart_id;
+	u8	pll_config;
+	u16	cs_ws_config;
+	u8	clktcxo_13mhz;
+	u8	rhea_cntl;
+	u16	chksum_cmd;
+	u16	chksum_accum;
+	u16	pad2;
+	u32	branch_addr;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/toolchain/build+install.sh	Sun Apr 28 17:36:07 2013 +0000
@@ -0,0 +1,85 @@
+#!/bin/sh
+#
+# This script builds and installs binutils, gcc and newlib in the order
+# necessary for the whole thing to work.  The present version is based
+# on OsmocomBB's gnu-arm-build.2.sh script, which is in turn based on
+# yet another source.  The present version has been concocted by
+# Spacefalcon the Outlaw for use in the FreeCalypso project.
+#
+# This script needs to be invoked with two arguments:
+#
+# $1: the path to the directory containing the upstream binutils, gcc
+#     and newlib source tarballs;
+#
+# $2: the path to the directory where the built toolchain should be
+#     installed.
+#
+# Note that there isn't a single install step at the end, instead this
+# script will build and install one component, then proceed to build the
+# next component which depends on the previous one, etc.  For this reason
+# you should create a dedicated install directory that is writable by your
+# regular (non-root) uid, then run this script to populate that directory
+# with the toolchain.
+
+if [ $# != 2 ]
+then
+	echo "usage: $0 path-to-tarballs path-to-install"
+	exit 1
+fi
+
+set -ex
+
+target_args="--target=arm-elf"
+
+# binutils come first
+tar xjf $1/binutils-2.21.1a.tar.bz2
+mkdir -p binutils-build
+cd binutils-build
+../binutils-2.21.1/configure --prefix=$2 ${target_args} --disable-nls
+make all
+make install
+cd ..
+
+# unpack gcc and newlib sources at the same time: the gcc build
+# will be pointed to newlib headers
+gcc_version=4.5.4
+newlib_version=2.0.0
+tar xjf $1/gcc-core-${gcc_version}.tar.bz2
+tar xzf $1/newlib-${newlib_version}.tar.gz
+
+# gcc depends on binutils - add our install destination dir to the PATH
+# we prepend it to avoid surprises if some other arm-elf- toolchain
+# happens to be present already
+PATH=$2/bin:$PATH
+export PATH
+
+mkdir -p gcc-build
+cd gcc-build
+../gcc-${gcc_version}/configure --prefix=$2 ${target_args} \
+	--enable-interwork --enable-multilib \
+	--with-cpu=arm7tdmi --with-float=soft \
+	--enable-languages=c --with-newlib \
+	--with-headers=`pwd`/newlib-${newlib_version}/newlib/libc/include \
+	--with-system-zlib --disable-shared \
+	--disable-nls
+make all-gcc
+make install-gcc
+cd ..
+
+# now we can build newlib
+mkdir newlib-build
+cd newlib-build
+../newlib-${newlib_version}/configure --prefix=$2 ${target_args} \
+	--enable-interwork --enable-multilib \
+	--enable-target-optspace --enable-newlib-reent-small \
+	--disable-newlib-supplied-syscalls \
+	--disable-nls
+make all
+make install
+cd ..
+
+# and finally, libgcc
+cd gcc-build
+make all
+make install
+cd ..