I discovered an AMD Geode processor lurking in a slim client SBC (single board computer) originally for a printer kiosk. I wonder if I could fit a TinyGentoo onto its 128MB compact flash card???
[picture of slim client and screen]
>>>I'm writing this while my Gentoo system cross-compiles a i486-pc-linux-uclibc toolchain into /usr/i486-pc-linux-uclibc.
There are many resources that I had to pull together to get this working:
...and take a coffee break.
Add our C(XX)FLAGS and other customizations for the target system:
Let's use the emerge wrappers!
"We can use these tools for both installing into your development root (sysroot) and into your runtime root. For the latter, simply specify by using the --root option."
"By default these wrappers use the --root-deps=rdeps option to avoid the host dependencies from being pulled into the deptree. This can lead to incomplete deptrees. Therefore you may want to use --root-deps alone to see the full depgraph."
Create some missing directories:
With this setup, our toolchain is in /usr/i486-pc-linux-uclibc/, our temp build environment is in /usr/i486-pc-linux-uclibc/tmp/portage/, and the binaries and other files/folders (with the --root flag) will go in /mnt/tinygentoo.
Problems:
The workaround for it right now is to comment the entire function in stdlib.h and those packages will compile well. Also comment the _wur definition, just above the function rpmatch. This is a crude workaround, and it’ll be fixed when upstream decides what’s the solution."
>>>Another issue with coreutils:
Introduction and overview
- I will utilize crossdev, and avoid any chrooting problems and mismatching CHOST/CFLAGS...
- Customize the target systems make.conf generated by crossdev.
- Compile and install packages into runtime tree.
>>>I'm writing this while my Gentoo system cross-compiles a i486-pc-linux-uclibc toolchain into /usr/i486-pc-linux-uclibc.
There are many resources that I had to pull together to get this working:
- http://en.gentoo-wiki.com/wiki/Tiny_Gentoo HOWTO guide to install a 5MB system on a USB flashdrive or similar
- http://www.gentoo.org/proj/en/base/embedded/handbook/index.xml?full=1 Gentoo Embedded Handbook details cross-compiling for various dev boards
- http://judepereira.com/blog/going-embedded-with-mgentoo/ Example mGentoo
After having followed (1) to the t, I realized I made a big mistake in my toolchain and after emerge -auND world: I recompiled gcc with CFLAGS="-march=geode" and CHOST="i486-pc-linux-uclibc", and then resulted in a unusable gcc (compiler cannot create executables). Stupid me! I was sort of confused in all of those make.conf variables anyways...
First Steps - cross-toolchain setup and creation
Following (2) for a while, my setup I want is this:
I have an i686 desktop as my normal Gentoo machine and I have an i486 uclibc I want to develop for:
Variable | Value For Building Cross-Toolchain | Value For Building Cross-Binaries |
CBUILD | i686-pc-linux-gnu | i686-pc-linux-gnu |
CHOST* | i686-pc-linux-gnu | i486-unknown-linux-uclibc |
CTARGET* | i486-unknown-linux-uclibc | not set |
ROOT | not set -- defaults to / | /usr/i486-pc-linux-uclibc |
PORTAGE_CONFIGROOT | not set -- defaults to / | /mnt/i486-pc-linux-uclibc |
Explanation for above table:
The cross-toolchain will only be run on the normal Gentoo machine (i686 CPU), but it has to build binaries for the i486 Geode with uclibc, which will eventually be put into the initramfs that the slim client will boot into.
*I use i486 and not i586 according to http://en.gentoo-wiki.com/wiki/Safe_Cflags/AMD#Geode_LX for better performance on the Geode, even though the Geode is an i586.
Actually do something: (this automatically takes care of building the cross-toolchain with the correct variables)
jwilly / # crossdev --target i486-pc-linux-uclibc |
...and take a coffee break.
Next, we need to configure a bit in order to build our cross-binaries. We need to have two directory trees: one that is where all development files are (sysroot), and the other is the runtime tree. We emerge everything in the sysroot without trimming anything, and then install what we need using binary packages (-k option for emerge) into the runtime tree.
Note: Before beginning any cross-emerge, you'll need to run emerge-wrapper --init. Be sure to follow any instructions printed by emerge-wrapper before beginning your cross-emerge.
jwilly ~ # emerge-wrapper --init i486-pc-linux-uclibc: Setting up symlinks |
Add our C(XX)FLAGS and other customizations for the target system:
nano -w /usr/i486-pc-linux-uclibc/etc/portage/make.conf |
CHOST=i486-pc-linux-uclibc CBUILD=i686-pc-linux-gnu ARCH=x86 HOSTCC=i686-pc-linux-gnu-gcc E_MACHINE=EM_386 ROOT=/usr/${CHOST}/ ACCEPT_KEYWORDS="x86"# ~x86" USE="${ARCH} zlib bindist make-symlinks minimal" #MARCH_TUNE="-march=armv4t -mtune=arm9tdmi" #arm-softfloat-linux-uclibc #MARCH_TUNE="-march=armv5t -mtune=xscale" #armv5teb-softfloat-linux-gnueabi MARCH_TUNE="-march=geode" CFLAGS="-Os -pipe ${MARCH_TUNE} -mmmx -m3dnow -fno-align-jumps -fno-align-functions -fno-align-labels -fno-align-loops -fomit-frame-pointer" CXXFLAGS="${CFLAGS}" FEATURES="-collision-protect sandbox ccache buildpkg noman noinfo nodoc" UCLIBC_CPU="586MMX" # Be sure we don't overwrite pkgs from another repo.. PKGDIR=${ROOT}packages/ PORTAGE_TMPDIR=${ROOT}tmp/ ELIBC="uclibc" PKG_CONFIG_PATH="${ROOT}usr/lib/pkgconfig/" #PORTDIR_OVERLAY="/usr/portage/local/"
LIBDIR_x86="lib"
LIBDIR_amd64=lib64
PORTDIR="/usr/portage"
DISTDIR="/usr/portage/distfiles"
PORTDIR_OVERLAY="/usr/local/portage"
MAKEOPTS="-j2"
EMERGE_DEFAULT_OPTS="--verbose"
CCACHE_SIZE="2G"
CCACHE_DIR="/var/tmp/ccache"
GENTOO_MIRRORS="http://gentoo.osuosl.org/"
|
Let's use the emerge wrappers!
i486-pc-linux-uclibc-emerge pkg0 pkg1 pkg2 |
"We can use these tools for both installing into your development root (sysroot) and into your runtime root. For the latter, simply specify by using the --root option."
"By default these wrappers use the --root-deps=rdeps option to avoid the host dependencies from being pulled into the deptree. This can lead to incomplete deptrees. Therefore you may want to use --root-deps alone to see the full depgraph."
Create some missing directories:
mkdir /usr/i486-pc-linux-uclibc/tmp/ |
With this setup, our toolchain is in /usr/i486-pc-linux-uclibc/, our temp build environment is in /usr/i486-pc-linux-uclibc/tmp/portage/, and the binaries and other files/folders (with the --root flag) will go in /mnt/tinygentoo.
Compile and Install packages into /mnt/tinygentoo
i486-pc-linux-uclibc-emerge --root /mnt/tinygentoo -auND baselayout uclibc busybox
These are the packages that would be merged, in order: Calculating dependencies... done! [ebuild N ] sys-apps/busybox-1.20.2 to /mnt/tinygentoo/ USE="make-symlinks static -ipv6 -livecd -math -mdev -pam -savedconfig (-selinux) -sep-usr -systemd" 0 kB [ebuild N ] sys-libs/ncurses-5.9-r2:5 to /mnt/tinygentoo/ USE="cxx minimal -ada -debug -doc -gpm -profile -static-libs -trace -unicode" 0 kB [ebuild N ] sys-apps/sysvinit-2.88-r3 to /mnt/tinygentoo/ USE="-ibm (-selinux) -static" 0 kB [ebuild N ] sys-libs/uclibc-0.9.33.2 to /mnt/tinygentoo/ USE="-crosscompile_opts_headers-only -debug -hardened -iconv -ipv6 -nptl -rpc -savedconfig -ssp -uclibc-compat -wordexp" 3 kB [ebuild N ] sys-process/psmisc-22.16 to /mnt/tinygentoo/ USE="-X -ipv6 -nls (-selinux)" 0 kB [ebuild N ] virtual/init-0 to /mnt/tinygentoo/ 0 kB [ebuild N ] sys-apps/baselayout-2.1-r1 to /mnt/tinygentoo/ USE="-build" 0 kB [ebuild N ] sys-apps/openrc-0.11.8 to /mnt/tinygentoo/ USE="-debug -ncurses -newnet -pam (-prefix) (-selinux) -static-libs -unicode" 0 kB
...
>>> Emerging (1 of 8) sys-apps/busybox-1.20.2 for /mnt/tinygentoo/
...
|
Problems:
>>> Emerging (5 of 8) sys-process/psmisc-22.16 for /mnt/tinygentoo/
checking for tgetent in -ltinfo... no
checking for tgetent in -lncurses... no
checking for tgetent in -ltermcap... no
configure: error: Cannot find tinfo, ncurses or termcap libraries
|
First, install every supporting package and libs we need in sysroot (this included ncurses lib):
i486-pc-linux-uclibc-emerge --root-deps -auND baselayout uclibc busybox
|
>>> This failed when compiling perl (17 of 21), so restart with just close deps:
i486-pc-linux-uclibc-emerge -auND baselayout uclibc busybox
|
>>>Then install recommended apps:
i486-pc-linux-uclibc-emerge -auND bash dropbear pam udev iptables coreutils nano util-linux shadow kbd net-tools grep procps gzip sed findutils mawk htop
|
>>>Upon emerging of coreutils, we came across "bug #423491 sys-apps/findutils-4.4.2-r1 and sys-apps/coreutils-8.14 with sys-libs/uclibc – rpmatch.c:58:1: error: redefinition of ‘rpmatch’ /// /usr/include/stdlib.h:810:28: note: previous definition of ‘rpmatch’ was here
The workaround for it right now is to comment the entire function in stdlib.h and those packages will compile well. Also comment the _wur definition, just above the function rpmatch. This is a crude workaround, and it’ll be fixed when upstream decides what’s the solution."
>>>Another issue with coreutils:
checking whether it is possible to resort to fread on /etc/mnttab... no configure: error: could not determine how to read list of mounted file systems |
Then, only install the required binaries in runtime tree /mnt/tinygentoo
i486-pc-linux-uclibc-emerge --root /mnt/tinygentoo -auND baselayout uclibc busybox
|
*****
At my side, I generate stages1 manually :
My next step will be "Gentoo From Scratch" : start from the first step of LinuxFromScratch (build a vanilla toolchain), then build python, then portage, then generate stage 1
_________________
Code: |
USE="-* build" ROOT=/newroot emerge --nodeps --oneshot baselayout USE="-* build" ROOT=/newroot emerge --oneshot `grep -v "#" /usr/portage/profiles/default/linux/packages.build` |
My next step will be "Gentoo From Scratch" : start from the first step of LinuxFromScratch (build a vanilla toolchain), then build python, then portage, then generate stage 1
_________________
Comments
Post a Comment