You need various components for a full build.
- Bootloader
- Logic: FPGA or CPLD
- kernel
- initrd (ram filesystem)
- Rootfs
There are also ancilliary tools such as bbl to help install this stuff. Here we cover how to build all these parts.
Menuconfig2
The page SoftwareBuilding/Menuconfig2 currently contains Chris's notes on how to get menuconfig2 to build.
The quickstart version
Checkout balloonboard svn, make sure you have subversion installed and the emdebian repository in your sources list, and do make:
svn checkout svn://balloonboard.org/balloon/trunk cd trunk make
Note that the file structure checked out of svn relies on a certain number of symbolic links. For that reason, we recommend checking it out using svn on Linux. Using a tool like TortoiseSVN on Windows can lead to the symbolic links becoming short nonsense files, which breaks things.
This process builds things in a build directory at the same level as trunk.
Once built do make dist to install all the generated binaries into a distro directory at the same level as trunk. This copies the relevant sources into place too, and utilies and config files for uploading use the paths in this layout to find files.
This mechanism does not build the vhdl code as that needs the Xilinx Webpack tools (and GUI).
The patches are managed with quilt. See QuiltHowto for details on how that works so you can use it to easily make changes, update patches and check changes back in.
To check code back in you will need svn access on balloonboard.org. email wookey@wookware.org with an ssh key to get access.
Configuration
The build system use makefiles. If you need to make changes from the defaults create a Makefile.local to override variables in Makefile.inc. This makes it easy to tell your copy to use a different kernel, local apt cache, YAFFS version, BUILDROOT version, build-variant etc from the defaults. e.g:
#Makefile for local changes to configuration variables #Included after Makefile.inc default settings #Set things here to override those REPOSITORY:=http://ftp.uk.debian.org/debian/ YAFFSCHECKOUT:=2009-03-07 KERNVER:=2.6.29.1 VARIANT:=-tcl-sl40
Don't check your version into svn!
Tools and libraries you might need
The build procedure needs various tools and libraries to be present on your system. The makefiles will warn you about some things, and on a Debian system, automatically install the needed packages if you have sudo rights. You need make, glibc headers, bzip2, wget, quilt, module-init-tools, fakeroot, texinfo, bison and flex in addition to the ARM toolchain, see below.
You shouldn't need to manually install anything - it should just be taken care of. But here we detail the steps needed so you can sort out problems.
Manual installation of tools and libraries
apt-get install build-essential bzip2 quilt module-init-tools fakeroot texinfo bison flex wget apt-get install libncurses5-dev debhelper debootstrap subversion
The symptoms of module-init-tools not being installed are non-intuitive: if building the modules results in a lot of messages complaining about ELF files not being for this architecture, then module-init-tools probably isn't installed.
From rel v0.8 onwards the Balloon software build procedure also needs multistrap, the Emdebian multiple repository boostrap tool. This is not present in the Debian 'lenny' release, so if you're running a 'lenny' machine you'll have to install it manually.
For squeeze or later:
sudo aptitude update sudo aptitude install multistrap
For lenny: Get the dpkg file from http://packages.debian.org/testing/main/multistrap and do
apt-get install libparse-debian-packages-perl dpkg -i multistrap_2.0.3_all.deb
ARM GCC toolchain
The ARM GCC 4.1 or later toolchain is also required, which is also available from http://www.emdebian.org/crosstools.html. Makefile.tools (which is run automatically by make) will check to see if this is presnet and whinge (or on a debian machine try to install it for you). If this fails you might need to install it manually. In principle any cross-toolchain (for arm OABI or EABI, as desired) will work, but we've only ever tried using the emdebian ones. Currently you need and OABI ('arm'/'arm-linux-gnu') toolchain to buid bootloader even if everything else is EABI ('armel'/'arm-linux-gnueabi')
sudo aptitude update sudo aptitude install g++-4.2-arm-linux-gnueabi sudo aptitude install gcc-4.1-arm-linux-gnu
The 'arm' architecture is needed for bootldr, and 'armel' is needed for the kernel. The quickstart build will call these as required during the make.
In March 2009 on Debian 'lenny', this installed gcc-4.3-arm-linux-gnu and gcc-4.3-arm-linux-gnueabi.
Bootloader
The current bootloader used is bootldr from handhelds.org. It has been quite heavily modified to include YAFFS2 support and FPGA support.
There are currently two branches, the trunk version which works with a modern gcc, and the branch version which only works with gcc2.95. The branch version is the one that has all the latest stuff in it.
Get it from svn with: svn checkout svn://balloonboard.org/balloon/branches/bootldr36-pxa-sa1100
Make sure you have an arm cross-compiler installed (currently v2.95 is needed).
Build an initial loader with: make
By default it builds the minimalist version for initial JTAG download. To make a full-featured loader edit the config.local.mk file and comment out CONFIG_BALLOON_SMALL=y To make one for balloon2 set CONFIG_ARCH=SA1100 in config.local.mk, then make again
Resulting binaries:
<release>/bootldr/bootldr.fast
<release>/bootldr/bootldr.small
kernel
You should not need to do this manually - the build is integrated into the svn makefiles. But here is a description of what goes on, should you wish to play with it.
Check out the kernel patches from svn checkout svn://balloonboard.org/balloon/trunk/kernel/2.6.21
Apply them to a fresh kernel source: from either http://balloonboard.org/files/balloon3/distro/test-v0.2/sources/kernel/linux-2.6.21.1.tar.bz2 or http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.21.1.tar.bz2 You can do this with just patch, but it is set up to use quilt.
- Set the config for balloon3 and build the kernel
The easiest way to do this:
svn checkout svn://balloonboard.org/balloon/trunk cd trunk make
To do it manually:
svn checkout svn://balloonboard.org/balloon/trunk mkdir -p build/kernel cd build/kernel wget http://balloonboard.org/files/balloon3/distro/test-v0.3/sources/kernel/linux-2.6.22.2.tar.bz2 tar -xvjf linux-2.6.22.2.tar.bz2 svn checkout svn://balloonboard.org/balloon/trunk/kernel patches quilt push -a
Assuming that went OK you should be ready to build:
make balloon3_defconfig ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- make zImage
Resulting binaries:
<release>/kernel/zImage
Note that, as checked out of svn, the build procedure will make a kernel with an initrd built in. To get rid of it, uncheck the option "Initial RAM filesystem and RAM disk (initramfs/initrd) support" under "General setup" in make menuconfig.
initrd
You should not need to do this manually - the build is integrated into the svn makefiles. But here is a description of what goes on, should you wish to play with it.
This is currently built with buildroot. To do it manually:
svn checkout svn://balloonboard.org/balloon/trunk mkdir -p build/buildroot cd build/buildroot wget http://balloonboard.org/files/balloon3/distro/test-v0.3/sources/initrd/buildroot18662.tar.bz2 tar -xvjf buildroot18662.tar.bz2 svn checkout svn://balloonboard.org/balloon/trunk/initrd patches quilt push -a
Assuming that went OK you should be ready to build:
make oldconfig make
The result is a rootfs in build_arm/root
To get the initrd combined into the kernel you need to either set CONFIG_INITRAMFS_SOURCE to the dir containing your unpacked initrd, or copy a cpio archive of the initrd into usr/initramfs_data.cpio, then remake zImage. (see http://www.timesys.com/timesource/initramfs.htm for more details on how this all works)
Resulting binaries:
<release>/kernel/zImageInitrd
debian rootfs
This is made with debootstrap.
debootstrap --verbose --arch arm --foreign etch --include=udev,pcmciautils,balloon3-config,ntpdate,avahi-daemon,libdaemon0,lib avahi-common3,libavahi-core4,avahi-autoipd,libnss-mdns,libdbus-1-3,dbus etch-arm-chroot http://ftp.uk.debian.org/debian/
Then we apply a script rootfs-config to set various things up properly. These are the things which need to be configured in the rootfs in order to boot it on a target. These things are:
- It sets up devices (mtd, sd, fb, ttyS0-2)
- /etc/apt/sources.list points to ftp.uk.debian.org, and balloonboard.org for updates - (the default ftp.debian.org does not have arm packages)
- /etc/network/interfaces created for eth0 etc using dhcp
- /etc/securetty added ttyS1 and ttyS2 - allows root logon
- /etc/hostname set to balloon
The package balloon3-config takes care of 2nd-stage config.
- /etc/fstab set to sensible defaults
- /etc/passwd or /etc/shadow root password set to rootme
- shell set to bash for boot speed
- password change date set so it doesn;t ask you to change it every login
- /etc/hosts set up
- apt cache cleared out
- /dev/random pointed at /dev/urandom so ssh keys can be generated
- chmod 755 /
A prototype version is downloadable here: http://husaberg.toby-churchill.com/balloon/releases/development/balloon3/distro/debian/debootstrap-etch-arm-patched.yaffs2.gz
Resulting Binaries:
<release>/rootfs/debian/debianstage1root.tgz
Normally this is processed into a full debian rootfs by mounting it over usb and running debootstrap --second stage to produce a fully-functional rootfs:
<release>/rootfs/debian/debianroot.tgz
logic files
These are checked out of svn: svn checkout svn://balloonboard.org/balloon/trunk/vhdl
You need the xilinx web pack to build the binaries.
Resulting binaries:
<release>/vhdl/cpld/l3cpld.xsvf (for CPLD)
<release>/vhdl/fpga/l3fpga.bin (for FPGA)
Programming utilities
These are curently built in-tree, unlike the kernel, initrd and rootfs - the makefiles will be fully integrated soon. Check them out of svn and build everything:
svn checkout svn://balloonboard.org/balloon/trunk/utils make
This builds bflash, (and jflash), audio-off, and playxvsf - which are the various utils needed to program up a Balloon. make install will install them into your system (in /usr/local/bin) if you have sudo access, so that you can use them straight away.