summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--temporary-bootstrap-builder-setup-cortexa8.txt381
1 files changed, 381 insertions, 0 deletions
diff --git a/temporary-bootstrap-builder-setup-cortexa8.txt b/temporary-bootstrap-builder-setup-cortexa8.txt
new file mode 100644
index 0000000..6e88467
--- /dev/null
+++ b/temporary-bootstrap-builder-setup-cortexa8.txt
@@ -0,0 +1,381 @@
+ABOUT THIS GUIDE
+================
+
+This is a guide to building a custom BusyBox/Linux-libre system with the GNU
+toolchain. It mostly follows Cross Linux From Scratch Sysroot version
+SVN-0.0.1-20090726-x86, except that it uses more recent versions of software
+packages and uses a BusyBox-based userspace rather than a GNU-based one. This
+guide assumes the use of a GNU/Linux host system with all the necessary
+development software (GCC, GNU Binutils, Subversion, etc.) already installed.
+
+This version of the procedure is designed to build a bootstrap builder system
+capable of cross-compiling software for an ARM Cortex-A8 core.
+
+It is recommended that you read Cross Linux From Scratch Sysroot version
+SVN-0.0.1-20090726-x86 to understand the full build process and the rationale
+behind various elements of the setup.
+
+
+LEGAL NOTICE
+============
+
+THIS GUIDE:
+
+ Copyright (C) 2012 Patrick "P. J." McDermott
+
+ This guide may be reproduced, distributed, modified, and otherwise dealt in
+ under the terms of the Expat/MIT License:
+ http://www.jclark.com/xml/copying.txt
+
+CERTAIN COMMAND LINES AND FILE CONTENTS:
+
+ Cross-Compiled Linux From Scratch - Sysroot
+ Version SVN-0.0.1-20090726-x86
+
+ Copyright © 2005-2009, Jim Gifford, & Ryan Oliver
+
+ This material may be distributed only subject to the terms and conditions set
+ forth in the Open Publication License v1.0 or later (the latest version is
+ presently available at http://www.opencontent.org/openpub/).
+
+ The latest version of the original book may be downloaded from:
+ http://trac.cross-lfs.org/wiki/download#CLFSSysroot1.xUnderDevelopment
+ It may also be read online at:
+ http://cross-lfs.org/view/clfs-sysroot/x86/
+
+TRADEMARKS:
+
+ Linux is a Registered Trademark of Linus Torvalds.
+
+
+PROCEDURE
+=========
+
+Make a directory in which all work will be done. Under this directory, make
+directories 'src' and sys.cortexa8':
+ $ mkdir src sys.cortexa8
+
+Download all of the necessary source archives and branches.
+ $ cd src
+ $ wget http://www.busybox.net/downloads/busybox-1.19.3.tar.bz2
+ $ wget http://www.fsfla.org/svnwiki/selibre/linux-libre/download/releases/\
+ > 3.2.10-libre/linux-3.2.10-libre.tar.bz2
+ $ svn co svn://svn.eglibc.org/branches/eglibc-2_15 eglibc-2.15
+ $ wget http://ftp.gnu.org/gnu/gcc/gcc-4.6.2/gcc-4.6.2.tar.bz2
+ $ wget http://ftp.gnu.org/gnu/binutils/binutils-2.22.tar.bz2
+ $ wget http://ftp.gnu.org/gnu/make/make-3.82.tar.bz2
+ $ wget ftp://ftp.gmplib.org/pub/gmp-5.0.2/gmp-5.0.2.tar.bz2
+ $ wget http://www.mpfr.org/mpfr-current/mpfr-3.1.0.tar.bz2
+ $ wget http://www.multiprecision.org/mpc/download/mpc-0.9.tar.gz
+ $ for file in *.tar.bz2; do tar -xjf ${file}; done
+ $ for file in *.tar.gz; do tar -xzf ${file}; done
+ $ cd ..
+
+Make and mount the filesystem. mkfs and mount must be run as the superuser, but
+dd shouldn't need to be.
+ $ cd sys.cortexa8
+ $ dd if=/dev/zero of=fs bs=1024 count=$((3*1024*1024))
+ # mkfs -t ext4 fs
+ $ mkdir fsmnt
+ # mount -o loop fs fsmnt
+
+Set up a new user.
+ # groupadd tbb-cortexa8
+ # useradd -s /bin/bash -g tbb-cortexa8 -d /home/tbb-cortexa8 tbb-cortexa8
+ # mkdir -pv /home/tbb-cortexa8
+ # chown -v tbb-cortexa8:tbb-cortexa8 /home/tbb-cortexa8
+ # passwd tbb-cortexa8
+ # chown -Rv tbb-cortexa8:tbb-cortexa8 fsmnt
+
+Set up the toolchain work environment. Be sure to change '<BASE_DIR>' to the
+absolute path to the base work directory you made earlier, and adjust the
+configuration name in BBL_TARGET if you're building for a different
+architecture. We're using GNU Bash as the new user's default shell for
+convenience; this has no effect on the target system.
+ $ su - tbb-cortexa8
+ $ cat > ~/.bash_profile <<EOF
+ > exec env -i HOME="${HOME}" TERM="${TERM}" /bin/bash
+ > EOF
+ $ cat > ~/.bashrc <<EOF
+ > set +h
+ > umask 022
+ > BBL=<BASE_DIR>/sys.cortexa8/fsmnt
+ > LC_ALL=C
+ > PATH=<BASE_DIR>/sys.cortexa8/fsmnt/cross-tools/bin:/bin:/usr/bin
+ > export BBL LC_ALL PATH
+ > PS1='$ '
+ > unset CFLAGS
+ > unset CXXFLAGS
+ > export BBL_HOST=$(echo ${MACHTYPE} | \
+ > sed "s/$(echo ${MACHTYPE} | cut -d - -f 2)/cross/")
+ > export BBL_TARGET=arm-none-linux-gnu
+ > EOF
+ $ source ~/.bash_profile
+
+Make system directories. These commands should give you a system that is
+compliant with Filesystem Hierarchy Standard version 2.3. Note that the range
+syntax in many of these command lines is a non-standard feature of GNU Bash;
+this may not work on other shells.
+ $ mkdir -pv ${BBL}/{bin,boot,dev,etc/opt,home,lib,media,mnt,opt,proc}
+ $ install -dv -m 0750 ${BBL}/root
+ $ mkdir -pv ${BBL}/{sbin,srv,sys}
+ $ install -dv -m 1777 ${BBL}{,/var}/tmp
+ $ mkdir -pv ${BBL}/usr/{,local/}{bin,include,lib,sbin,share/{man,misc},src}
+ $ mkdir -pv ${BBL}/usr/local/{etc,games}
+ $ mkdir -pv ${BBL}/usr/{,local/}share/{doc,info,locale,terminfo,zoneinfo}
+ $ mkdir -pv ${BBL}/usr/{,local/}share/man/man{1,2,3,4,5,6,7,8}
+ $ ln -sv share/man ${BBL}/usr/local/man
+ $ mkdir -pv ${BBL}/var/{cache,lib/misc,local,lock,log,mail,opt,run,spool}
+
+Write the passwd and group files.
+ $ cat > ${BBL}/etc/passwd <<EOF
+ > root::0:0:root:/root:/bin/bash
+ > EOF
+ $ cat > ${BBL}/etc/group <<EOF
+ > root:x:0:
+ > bin:x:1:
+ > sys:x:2:
+ > kmem:x:3:
+ > tty:x:4:
+ > tape:x:5:
+ > daemon:x:6:
+ > floppy:x:7:
+ > disk:x:8:
+ > lp:x:9:
+ > dialout:x:10:
+ > audio:x:11:
+ > video:x:12:
+ > utmp:x:13:
+ > usb:x:14:
+ > cdrom:x:15:
+ > EOF
+
+If CONFIG_FEATURE_UTMP and/or CONFIG_FEATURE_WTMP are enabled in BusyBox,
+certain BusyBox applets (getty, login, init, etc.) will log user logins to
+/var/run/utmp and/or /var/run/wtmp. However, BusyBox's supporting library won't
+create /var/run/wtmp if it doesn't exist. So create these files now and set
+proper modes for them.
+ $ touch ${BBL}/var/run/{u,w}tmp
+ $ chmod -v 664 ${BBL}/var/run/{u,w}tmp
+/var/run/utmp is used to track logged-in users. /var/run/wtmp is used to record
+when users log into and out of the system. NB: This is an odd location for
+wtmp, but that's where an unpatched BusyBox will expect it.
+
+Make and change to a directory for package source code.
+ $ mkdir -v ${BBL}/src
+ $ cd ${BBL}/src
+
+At this point and after every milestone (maybe after each package installation),
+I recommend you create a snapshot of the filesystem. To do so, first exit the
+shell environment of user 'tbb-cortexa8'.
+ $ exit
+As the superuser, unmount the filesystem.
+ # umount fs
+Make a copy of the filesystem. Replace '<UNIQUE_NAME>' with something to
+identify the milestone (for example, at this point I named my snapshot image
+'fs.01-fs-hier' to note that it was the first snapshot and that I just finished
+making the filesystem hierarchy).
+ $ cp -p fs fs.<UNIQUE_NAME>
+As the superuser, mount the filesystem again.
+ # mount -o loop fs fsmnt
+Log in as user 'tbb-cortexa8' and return to the src directory in the filesystem.
+ $ su - tbb-cortexa8
+ $ cd ${BBL}/src
+Now, if something goes wrong, you can revert to a previous filesystem image by
+going through this section and swapping the arguments to 'cp'.
+
+Install Linux's headers for use by EGLIBC.
+ $ cp -pR ${BBL}/../../src/linux-3.2.10 .
+ $ cd linux-3.2.10
+ $ make mrproper
+ $ make ARCH=arm headers_check
+ $ make ARCH=arm INSTALL_HDR_PATH=${BBL}/usr headers_install
+ $ find ${BBL}/usr/include/ -name .install -o -name ..install.cmd | \
+ > xargs rm -fv
+ $ cd ..
+ $ rm -Rf linux-3.2.10
+
+Install GMP for use by the cross-compiling GCC build.
+ $ cp -pR ${BBL}/../../src/gmp-5.0.2 .
+ $ cd gmp-5.0.2
+ $ CPPFLAGS=-fexceptions ./configure --prefix=${BBL}/cross-tools --enable-cxx
+ $ make
+ $ make install
+ $ make check
+ $ cd ..
+ $ rm -Rf gmp-5.0.2
+
+Install MPFR for use by the cross-compiling GCC build.
+ $ cp -pR ${BBL}/../../src/mpfr-3.1.0 .
+ $ cd mpfr-3.1.0
+ $ LDFLAGS="-Wl,-rpath,${BBL}/cross-tools/lib" ./configure \
+ > --prefix=${BBL}/cross-tools --enable-shared --with-gmp=${BBL}/cross-tools
+ $ make
+ $ make install
+ $ cd ..
+ $ rm -Rf mpfr-3.1.0
+
+Install MPC for use by the cross-compiling GCC build.
+ $ cp -pR ${BBL}/../../src/mpc-0.9 .
+ $ cd mpc-0.9
+ $ LDFLAGS="-Wl,-rpath,${BBL}/cross-tools/lib" ./configure \
+ > --prefix=${BBL}/cross-tools --with-mpfr=${BBL}/cross-tools \
+ > --with-gmp=${BBL}/cross-tools
+ $ make
+ $ make install
+ $ cd ..
+ $ rm -Rf mpc-0.9
+
+Configure and build a cross-compiling GNU Binutils.
+ $ cp -pR ${BBL}/../../src/binutils-2.22 .
+ $ mkdir -v binutils-build
+ $ cd binutils-build
+ $ AR=ar AS=as ../binutils-2.22/configure --prefix=${BBL}/cross-tools \
+ > --host=${BBL_HOST} --target=${BBL_TARGET} --with-sysroot=${BBL} \
+ > --disable-nls --enable-shared --disable-multilib
+ $ make configure-host
+ $ make
+ $ make install
+ $ cp -v ../binutils-2.22/include/libiberty.h ${BBL}/usr/include
+ $ cd ..
+ $ rm -Rf binutils-2.22 binutils-build
+
+Configure and build a cross-compiling GCC with a static libgcc and no threads.
+ $ cp -pR ${BBL}/../../src/gcc-4.6.2 .
+ $ mkdir -v gcc-build
+ $ cd gcc-build
+ $ AR=ar LDFLAGS="-Wl,-rpath,${BBL}/cross-tools/lib" ../gcc-4.6.2/configure \
+ > --prefix=${BBL}/cross-tools --build=${BBL_HOST} --host=${BBL_HOST} \
+ > --target=${BBL_TARGET} --disable-multilib --with-sysroot=${BBL} \
+ > --disable-nls --without-headers --with-newlib --disable-decimal-float \
+ > --disable-libgomp --disable-libmudflap --disable-libssp \
+ > --with-mpfr=${BBL}/cross-tools --with-gmp=${BBL}/cross-tools \
+ > --with-mpc=${BBL}/cross-tools --without-ppl --without-cloog \
+ > --disable-shared --disable-threads --enable-languages=c
+ $ make all-gcc all-target-libgcc
+ $ make install-gcc install-target-libgcc
+ $ cd ..
+ $ rm -Rf gcc-4.6.2 gcc-build
+
+Configure and build a cross-compiling EGLIBC. Change '<LINUX_VER>' to the lower
+of either version 3.1.6 or the version of Linux running on your host system.
+ $ cp -pR ${BBL}/../../src/eglibc-2.15 .
+ $ cd eglibc-2.15
+ $ find . -depth -name .svn -exec rm -Rf {} \;
+ $ rm ports/Makefile
+ $ cp -R ports/* libc
+ $ cd libc
+ $ cp -v Makeconfig{,.orig}
+ $ sed -e 's/-lgcc_eh//g' Makeconfig.orig > Makeconfig
+ $ cd ../..
+ $ mkdir -v eglibc-build
+ $ cd eglibc-build
+ $ cat > config.cache <<EOF
+ > libc_cv_forced_unwind=yes
+ > libc_cv_c_cleanup=yes
+ > libc_cv_gnu89_inline=yes
+ > libc_cv_ssp=no
+ > EOF
+ $ cat > configparams <<EOF
+ > install_root=${BBL}
+ > EOF
+ $ BUILD_CC=gcc CC=${BBL_TARGET}-gcc AR=${BBL_TARGET}-ar \
+ > RANLIB=${BBL_TARGET}-ranlib \
+ > ../eglibc-2.15/libc/configure --prefix=/usr --libexecdir=/usr/lib/eglibc \
+ > --host=${BBL_TARGET} --build=${BBL_HOST} --without-fp \
+ > --disable-profile --enable-add-ons --with-tls --enable-kernel=<LINUX_VER> \
+ > --with-__thread --with-binutils=${BBL}/cross-tools/bin \
+ > --with-headers=${BBL}/usr/include --cache-file=config.cache
+ $ make
+ $ make install_root=${BBL} install
+ $ rm -Rf *
+
+Build EGLIBC's localedef and install locales.
+ $ CPPFLAGS=-DNOT_IN_libc ../eglibc-2.15/localedef/configure
+ > --prefix=${BBL}/usr --with-glibc=../eglibc-2.15/libc
+ $ make
+ $ make SUPPORTED-LOCALES='\
+ > de_DE.UTF-8/UTF-8 de_DE/ISO-8859-1 de_DE@euro/ISO-8859-15 \
+ > en_HK.UTF-8/UTF-8 en_HK/ISO-8859-1 \
+ > en_PH.UTF-8/UTF-8 en_PH/ISO-8859-1 \
+ > en_US.UTF-8/UTF-8 en_US/ISO-8859-1 \
+ > es_MX.UTF-8/UTF-8 es_MX/ISO-8859-1 \
+ > fa_IR/UTF-8 \
+ > fr_FR.UTF-8/UTF-8 fr_FR/ISO-8859-1 fr_FR@euro/ISO-8859-15 \
+ > it_IT.UTF-8/UTF-8 it_IT/ISO-8859-1 \
+ > ja_JP.EUC-JP/EUC-JP ja_JP.UTF-8/UTF-8' install-locales
+ $ cd ..
+ $ rm -Rf eglibc-2.15 eglibc-build
+
+Write the Name Service Switch configuration file.
+ $ cat > ${BBL}/etc/nsswitch.conf <<EOF
+ > # /etc/nsswitch.conf
+ >
+ > passwd: files
+ > group: files
+ > shadow: files
+ >
+ > hosts: files dns
+ > networks: files
+ >
+ > protocols: files
+ > services: files
+ > ethers: files
+ > rpc: files
+ > EOF
+
+Set the system's timezone.
+ $ TZDIR=${BBL}/usr/share/zoneinfo ${BBL}/usr/bin/tzselect
+Answer the prompts and the tzselect script will output the name of a time zone.
+Substitute '<TZ>' below with this name.
+ $ ln -sfv ../usr/share/zoneinfo/<TZ> ${BBL}/etc/localtime
+
+Configure the dynamic loader to search for libraries in /usr/local/lib and
+/opt/lib in addition to its default locations /lib and /usr/lib.
+ $ cat > ${BBL}/etc/ld.so.conf <<EOF
+ > # /etc/ld.so.conf
+ >
+ > /usr/local/lib
+ > /opt/lib
+ > EOF
+
+Configure and build a final cross-compiling GCC.
+ $ cp -pR ${BBL}/../../src/gcc-4.6.2 .
+ $ mkdir -v gcc-build
+ $ cd gcc-build
+ $ AR=ar LDFLAGS="-Wl,-rpath,${BBL}/cross-tools/lib" ../gcc-4.6.2/configure \
+ > --prefix=${BBL}/cross-tools --build=${BBL_HOST} --host=${BBL_HOST} \
+ > --target=${BBL_TARGET} --disable-multilib --with-sysroot=${BBL} \
+ > --disable-nls --enable-shared --enable-languages=c,c++ \
+ > --enable-__cxa_atexit --with-mpfr=${BBL}/cross-tools \
+ > --with-gmp=${BBL}/cross-tools --with-mpc=${BBL}/cross-tools --without-ppl \
+ > --without-cloog --enable-c99 --enable-long-long --enable-threads=posix
+ $ make AS_FOR_TARGET="${BBL_TARGET}-as" LD_FOR_TARGET="${BBL_TARGET}-ld"
+ $ make install
+ $ cd ..
+ $ rm -Rf gcc-4.6.2 gcc-build
+
+
+
+Set up environment variables to have all further packages built using the cross-
+compiling toolchain.
+ $ cat >> ~/.bashrc <<EOF
+ > export CC=${BBL_TARGET}-gcc
+ > export CXX=${BBL_TARGET}-g++
+ > export AR=${BBL_TARGET}-ar
+ > export AS=${BBL_TARGET}-as
+ > export RANLIB=${BBL_TARGET}-ranlib
+ > export LD=${BBL_TARGET}-ld
+ > export STRIP=${BBL_TARGET}-strip
+ > export READELF=${BBL_TARGET}-readelf
+ > EOF
+ $ source ~/.bashrc
+
+
+
+Install opkg to /opkgbootstrap with an etc dir under /opkgbootstrap/etc.
+Install opkhelper to /opkgbootstrap.
+Install fakeroot to /opkgbootstrap.
+Write an opkg.conf under /opkgbootstrap/etc.
+opkbuild and opkg-install packages.
+