Skip to main content

Geode LX800 cash-in

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???

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.

[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:

  1. http://en.gentoo-wiki.com/wiki/Tiny_Gentoo HOWTO guide to install a 5MB system on a USB flashdrive or similar
  2. http://www.gentoo.org/proj/en/base/embedded/handbook/index.xml?full=1 Gentoo Embedded Handbook details cross-compiling for various dev boards
  3. 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


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 : 
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 8)
_________________






Comments

Popular posts from this blog

Atmega328PB Dev on Linux x64

The Atmega328PB is the greatest thing to come to the Arduino platform since the UNO.  Who wouldn't want more 16-bit PWMs and double all 3 serial protocols? The new unofficial Arduino Mini PB Pro! To get the IDE to support it, follow this guide: https://github.com/watterott/ATmega328PB-Testing Since the JSON file is incomplete for Linux, do the manual toolchain replacement.  This was a little tricky, and there isn't much on the internet on where the toolchain resides inside the Arduino base folder.  Here's what I did to make it work. I downloaded the latest Arduino build, and I will refer to the extracted base directory as "arduino-1.6.9".  Also download the "hardware.zip" and the "Arduino Toolchain (4.9.2)" Linux x64 version from the github links. 1. Replace the toolchain The builtin toolchain resides in "arduino-1.6.9/hardware/tools/avr/".  Rename the avr folder to "avr.old".  Extract the "Arduino Toolc...

PB Pro Mini

No, it isn't Lead, nor is it Peanut Butter.  It is the 'B' version of the prolific ATmega328P microcontroller which started all this maker craziness off! Top view of PB Pro Mini Description This is a minimal microcontroller board with only a voltage reg, crystal, I2C pull-ups, LEDs and the chip itself.  The goal here is to reduce costs while hosting the beefy 328PB! This is based on, and pin compatible with, the Arduino Pro Mini 5v/16MHz from  Sparkfun . Notable, not-so-minor improvements for the 'B' version: 2 UARTs 2 I2Cs (TWI) 2 SPI Qtouch 5 Timers (with OC, IC, and PWM) Everything else is about the same.  You should be aware the clock driver on the chip is a low-power version, but this board and crystal operate at 16MHz just fine at 5V.  The Arduino library I've been using for the PB has been working without a problem! Getting Started You'll need a FTDI Friend  or FTDI Cable  to program this as there is no seconda...

Update to USBmicroISP: 6pin and 10pin headers

Actually using my USBmicroISP with microcontrollers other than Arduino Uno's led me to fix a udev rule issue with my Gentoo Linux laptop.  I was getting Permission Denied when I was trying to use avrdude as a normal user.  Yes, my user is part of the 'uucp' group... Background Some background on the Arduino ISP connector.  It is much different than the 10-pin AVR connector... 6-pin ICSP cable pinout.  NOTE: Numbers refer to ATtiny45/85 pins, not ICSP! Arduino ISP pinout. Notice the vertical line next to pin 1, which appears in silkscreen on the PCBs. Redboard ISP pinout.  Obviously the same as UNO.  Notice pin 1 location on upper-left, with horizontal white silk. My USBmicroISP has the cables coming off the IDC differently, but the key is in the correct orientation to the pinout in the top picture! (Please disregard numbering on first picture for ICSP purposes)  Usually the key and wires are facing inward (left side on 2nd and 3rd ...