Mkrootfs

From RCSWiki

Jump to: navigation, search

Ron's Notes For Making a GNU/Linux Distribution for RCC

WARNING: This page is not finished or tested! I'm just creating it as I figure it out.

(I.e., DO NOT RELY on this info yet!)

I am using Cross Linux From Scratch book as a rough guide.

To build root file system, I started with CLFS (Cross Linux From Scratch) and decided it is not going to work very well for me. (They want to compile most things on the target machine, I want to compile most things on the host.) So here's what I've done and it seems to be working:

Step 0 Open a new environment (so that we can back out of environment variable changes):

PS1="`hostname`-cross> " bash
export TARGET=powerpc-405-linux-gnu
export TOOLS=/opt/cross/gcc-4.2.2-glibc-2.7
export ROOTFS=/lbuild/ml410/mixed/mkrootfs/rootfs

Start Clean:

rm -rf $TOOLS
mkdir -p $TOOLS
mkdir -p $TOOLS/$TARGET
rm -rf $ROOTFS
mkdir -p $ROOTFS
mkdir mkrootfs ; cd mkrootfs

What this does is open a new bash shell with a different Prompt String (PS1) to make it clear that we have set some key env variables. Then we set up three variables we'll need in different circumstances. Finally we create a working directory that we'll use to build the root file system.

Step 1 Build Cross-Compiler Tools

This is not finished yet! I am still getting this figured out. In the mean time, I'm using crosstools as my basic cross-compiler.

Summary

  1. Build binutil cross-tools
  2. Get Kernel Headers
  3. Build glibc Headers
  4. Build a minimal gcc
  5. Build glibc
  6. Build full gcc cross-compiler
  7. Build native PPC compiler

Okay 1.1, Build binutil

# Build binutil cross-tools
wget -nv http://ftp.gnu.org/gnu/binutils/binutils-2.18.tar.bz2
wget -nv http://svn.cross-lfs.org/svn/repos/cross-lfs/trunk/patches/binutils-2.18-branch_update-3.patch
wget -nv http://svn.cross-lfs.org/svn/repos/cross-lfs/trunk/patches/binutils-2.18-posix-1.patch
tar xjf binutils-2.18.tar.bz2
cd binutils-2.18
patch -Np1 -i ../binutils-2.18-posix-1.patch
patch -Np1 -i ../binutils-2.18-branch_update-3.patch
mkdir build ; cd build
../configure --target=$TARGET --prefix=$TOOLS/$TARGET --with-sysroot=$TOOLS/$TARGET
make
make install

Now 1.2, Linux (unsantized) Kernel Headers

git clone git://git.secretlab.ca/git/linux-2.6-virtex.git
cd linux-2.6-virtex
make ARCH=ppc CROSS_COMPILER=powerpc-405-gnu-linux- ml403_defconfig 
mkdir -p $TOOLS/$TARGET/usr/include
cp -a include/linux include/asm-generic $TOOLS/$TARGET/usr/include
cp -a include/asm-ppc  $TOOLS/$TARGET/usr/include/asm

Install 1.3 glibc headers

wget -nv http://ftp.gnu.org/gnu/glibc/glibc-2.7.tar.bz2
wget -nv http://svn.cross-lfs.org/svn/repos/cross-lfs/trunk/patches/glibc-2.7-branch_update-1A.patch
wget -nv http://svn.cross-lfs.org/svn/repos/cross-lfs/trunk/patches/glibc-2.7-libgcc_eh-1.patch
wget -nv http://svn.cross-lfs.org/svn/repos/cross-lfs/trunk/patches/glibc-2.7-localedef_segfault-1.patch
tar xjf glibc-2.7.tar.bz2
cd glibc-2.7
patch -Np1 -i ../glibc-2.7-branch_update-1A.patch
patch -Np1 -i ../glibc-2.7-libgcc_eh-1.patch
patch -Np1 -i ../glibc-2.7-localedef_segfault-1.patch
mkdir build ; cd build
echo "libc_cv_forced_unwind=yes" > config.cache
echo "libc_cv_c_cleanup=yes" >> config.cache
echo "libc_cv_ppc_machine=yes" >> config.cache
../configure --host=$TARGET --prefix=$TOOLS/$TARGET \
             --with-headers=$TOOLS/$TARGET/usr/include \
             --disable-sanity-checks \
             --cache-file=config.cache
make install-headers install_root=$TOOLS/$TARGET
cp -v bits/stdio_lim.h $TOOLS/$TARGET/usr/include/bits
touch ${CLFS}/usr/include/gnu/stubs.h
mkdir -p $TOOLS/$TARGET/usr/include/gnu

There is something about recent glibc's that are bugging me. It should just work but I think various sub-architectures have been broken out?? Or maybe I'm missing something much more more fundamental.

Bottom line: I cannot configure glibc so that I can extract glibc headers to do a "best practices" cross-compiler build.

I will look at it again tomorrow... bedtime for bonzo.

Step 3 Build Root File System Image

We are going to start cross-compiling the minimal packages needed to get a boot-able system.

  • binutils and gcc (we can copy glibc from cross-compiler)
  • busybox
  • bootscripts


PATH=${PATH}:/opt/crosstool/gcc-4.2.1-glibc-2.3.6/powerpc-405-linux-gnu/bin

First, build a native PPC405 binutil:

tar xjf binutils-2.18.tar.bz2
cd binutils-2.18
patch -Np1 -i ../binutils-2.18-posix-1.patch
patch -Np1 -i ../binutils-2.18-branch_update-3.patch
mkdir build ; cd build
../configure --prefix=/usr --host=$TARGET --enable-shared
make
make DESTDIR=$ROOTFS install

Second, build a native PPC405 gcc:

wget -nv http://ftp.gnu.org/gnu/gcc/gcc-4.2.2/gcc-4.2.2.tar.bz2
wget -nv http://svn.cross-lfs.org/svn/repos/cross-lfs/trunk/patches/gcc-4.2.2-branch_update-2.patch
wget -nv http://svn.cross-lfs.org/svn/repos/cross-lfs/trunk/patches/gcc-4.2.2-posix-1.patch
tar xjf gcc-4.2.2.tar.bz2
cd gcc-4.2.2
patch -Np1 -i ../gcc-4.2.2-branch_update-2.patch
patch -Np1 -i ../gcc-4.2.2-posix-1.patch
mkdir build ; cd build
../configure --prefix=/usr --host=$TARGET --target=$TARGET --enable-long-long -enable-c99 --enable-shared --enable-threads=posix --enable-__cxa_atexit -disable-nls --enable-languages=c,c++ --disable-libstdcxx-pch --with-cpu=405 --enable-cxx-flags=-mcpu=405
make AS_FOR_TARGET=${TARGET}-as LD_FOR_TARGET=${TARGET}-ld






'''Step X'''


The web sites I've been using thus far
* [http://dev.gentoo.org/~vapier/eh/?part=1&chap=4 gentoo]
* [http://cross-lfs.org/view/1.0.0/ppc/cross-tools/glibc.html ppc clfs]
* [http://cross-lfs.org/view/clfs-sysroot/arm/cross-tools/glibc-headers.html (arm) glibc 2.6]

'''Step 3'''
Create a directory to work in:
<code><pre>
mkdir mkrootfs/{,downloads,scripts,rootfs}
cp *.src files mkrootfs/scripts # some scripts to download source
cd mkrootfs/downloads
source ../scripts/source.src
source ../scripts/patches.src
cd ..

Step 1 Create a directory to work in:


Personal tools