On Mon, 10 Oct 2005, Heath Holcomb wrote:

> Version 0.09
> Please add, delete, modify. Thanks!
> 
> - fixed the password problem
> - wrote about the problem with kernels 2.6.11 (and latter)
> - fixed typos
> - added more options for UCLIBC_CPU
> - added two people to contributors list
> 
> Also I need no workarounds this time through (minus the kernel problem).
> 
> Still looking for feedback on the Gentooized version of the this how-to on 
> readability and usefullness.
> http://www.bulah.com/embedded-guide.html
> 
> Update to my website will come shortly.
> http://www.bulah.com/embeddedgentoo.html
> 
> Enjoy, 
> 
> --------------------------------------------------------------------------------
> # Embedded Gentoo How-To for x86
> #
> # A how-to guide to setup a Gentoo embedded environment, you must be root.
> # These commands are to be run on your development system, 
> # any x86 Gentoo Linux computer will do.  The system should be fast,
> # to speed development.  The target can be any x86 based SBC.  I'm
> # using a Geode based SBC.  Latter I'll use a Via based SBC.
> #
> # version 0.09
> # 2005.10.10
> #
> # Heath Holcomb (heath at bulah.com)
> # Ned Ludd (original commands posted)
> # Lloyd Sargent (contributor)
> # Yuri Vasilevski (contributor)
> # Mike George (contributor)
> # Kammi Cazze (contributor)
> # Marius Schaefer (contributor)
> # Pierre Cassimans (contributor)
> # Marius Schafer (contributor)
> #
> # Definitions and Terms
> # system_rootfs = your regular rootfs, development computer
> # development_rootfs = what you use to build the embedded_rootfs
> # embedded_rootfs = rootfs you deploy to the target system
> # SBC = single board computer (here it's an x86 based)
> #
> # References
> # http://www.gentoo.org/doc/en/handbook/index.xml
> # http://www.epiawiki.org
> # http://epia.kalf.org
> # Gentoo embedded mailing list ([email protected])
> #
> #
> # Overview of process (steps)
> # 1 - Prepare the development_rootfs from your system_rootfs
> # 2 - Build the development_rootfs
> # 3 - Build the embedded_rootfs
> # 4 - Build and install non-system programs to the embedded_rootfs
> # 5 - Build and install a kernel to the embedded_rootfs
> # 6 - Deploy embedded_rootfs to target
> #
> #--------------------------------------------------------------------------------
> 
> #----- Step 1 - Prepare the development_rootfs from your system_rootfs -------
> 
> # You must be root.
> su -
> cd /opt
> 
> # Create the development_rootfs directory.
> # I use i586 because of target is a Geode processor.
> mkdir -p /opt/i586-gentoo-uclibc-linux/usr/portage
> 
> # Download the latest stage 1 tarball.
> wget \
> http://mirror.usu.edu/mirrors/gentoo/experimental/x86/embedded/stages/\
> stage1-x86-uclibc-2005.0.tar.bz2
> 
> # Untar the stage to the development_rootfs.
> tar -xvjpf stage1-x86-uclibc-2005.0.tar.bz2 -C /opt/i586-gentoo-uclibc-linux/
> 
> # Mount the proc and portage directories to your development_rootfs.
> # Makes your system_rootfs's proc and portage directory available from inside
> # of your development_rootfs (after chrooting).
> mount --bind /proc /opt/i586-gentoo-uclibc-linux/proc/
> mount --bind /usr/portage /opt/i586-gentoo-uclibc-linux/usr/portage
> 
> # Copy over DNS information to the development_rootfs.
> cp /etc/resolv.conf /opt/i586-gentoo-uclibc-linux/etc/resolv.conf
> 
> # Chroot into the development_rootfs.
> chroot /opt/i586-gentoo-uclibc-linux /bin/bash --login
> 
> 
> #----- Step 2 - Build the development_rootfs ---------------------------------
> 
> # Create new environment and load variables into memory.
> env-update
> source /etc/profile
> 
> # Set profile to use 2.6 kernel.
> # The current stage uses 2.4 by default, and for most cases you are going
> # to want a 2.6.x kernel.
> cd /etc/
> unlink make.profile
> ln -s ../usr/portage/profiles/uclibc/x86/2005.1 make.profile
> 
> # Modify make.conf file to your liking/needs.
> # This is for my target, Geode x86 processor.
> # Other values for UCLIBC_CPU :
> # 386, 486, ELAN, 586, 586MMX, 686, PENTIUMII, PENTIUMIII,PENTIUM4, K6, K7 
> # CRUSOE, WINCHIPC6, WINCHIP2, CYRIXIII, NEHEMIAH

point to read uclibc ebuild for UCLIBC_CPU on other archs
or some grep / sed magic to get them from the ebuild

> nano -w /etc/make.conf
> /*
> USE="bitmap-fonts minimal truetype-fonts mmx"
> CHOST="i586-gentoo-linux-uclibc"
> CFLAGS="-march=i586 -Os -pipe -fomit-frame-pointer -mmmx"
> CXXFLAGS="${CFLAGS}"
> 
> FEATURES="buildpkg"
> 
> VIDEO_CARDS="chips"
> UCLIBC_CPU="586MMX"
> */
> 
> # Start the bootstrap script.
> cd /usr/portage/scripts
> ./bootstrap.sh -p -v
> ./bootstrap.sh
> 
> # Workaround - bootstraping
> # Failure compiling uclibc (gcc-config error: Could not run/locate "gcc")?
> # If you get a failure while bootstrap is compileing uclibc here are the steps
> # to work around the problem.
> gcc-config 1
> source /etc/profile
> ./bootstrap.sh
> 
> # Emerge the system ebuild for the development_rootfs.
> emerge -e system
> 
> # Workaround - emerge system
> # During emerge -e system, python-fchksum failes complaing about
> # gcc-config error: Could not run/locate "i386-gentoo-linux-uclibc-gcc"

the problem occurs if you change CHOST's ARCH part (as you did from i386 
to i586)

> # The following commands work around this problem.
> emerge python
> emerge -e system
> 
> #----- Step 3 - Build the embedded_rootfs ------------------------------------
> 
> # Create the embedded_rootfs directory.
> mkdir /embedded_rootfs
> 
> # Emerge baselayout-lite into embedded_rootfs.
> # This gives your system a basic file structure.
> # 1.0_pre1 is the only one that is stable, right?
> cd /usr/portage/sys-apps/baselayout-lite/
> ROOT=/embedded_rootfs emerge baselayout-lite-1.0_pre1.ebuild
> 
> # Required Workaround - baselayout-lite
> # Baselayout-lite is still beta, so a few fixes are needed.
> # There needs to be a directory "log" in /var.
> # Inittab calls for /usr/bin/tail, but it needs to /usr/bin.
> mkdir /embedded_rootfs/var/log
> nano -w /embedded_rootfs/etc/inittab
> /*
> #tty3::respawn:/usr/bin/tail -f /var/log/messages
> tty3::respawn:/bin/tail -f /var/log/messages
> */
> 
> # Emerge uclibc into the embedded_rootfs.
> # Use the -K option because we don't get the extra files created by the
> # build/emerge process into our embedded rootfs which needs to be as 
> # small as possible.
> ROOT=/embedded_rootfs emerge -K uclibc
> 
> # Emerge busybox into the embedded_rootfs.
> # First you must emerge it into your development_rootfs.
> # This does not create the symlinks in our development embedded rootfs.
> emerge busybox
> ROOT=/embedded_rootfs emerge -K busybox
> 
> # Create the symlinks for busybox in the embedded_rootfs.
> mkdir /embedded_rootfs/proc
> mount -o bind /proc/ /embedded_rootfs/proc/
> chroot /embedded_rootfs /bin/busybox --install -s
> umount /embedded_rootfs/proc
> 
> # Set time zone in your embedded_rootfs.
> # See http://leaf.sourceforge.net/doc/guide/buci-tz.html for details.
> # For central standard time in the US, use "CST6CDT".
> nano -w /embedded_rootfs/etc/TZ
> /*
> CST6CDT
> */
> 
> # Install a boot loader (usually grub or lilo).
> # Once you copy/deploy your embedded_rootfs to your target SBC you will 
> # have to run grub on the command line to write to the master boot record
> # (MBR).
> # For some reason not all of /boot/grub is copied over to the 
> # embedded_rootfs, so a extra manual copy step is needed.
> # The --nodeps gets rip of the run time need of ncurses.
> emerge --nodeps grub
> ROOT=/embedded_rootfs emerge -K --nodeps grub
> cp -R /boot/grub /embedded_rootfs/boot/
> 
> # Modify your boot configure file.
> # The example below is for a grub, for a boot partition on /dev/hda1 and only
> # one partition on the target SBC system.
> nano -w /embedded_rootfs/boot/grub/grub.conf
> /*
> default 0
> timeout 10
> splashimage=(hd0,0)/boot/grub/splash.xpm.gz
> 
> title=Linux 2.6.x
> root (hd0,0)
> kernel /vmlinuz-2.6.x root=/dev/hda1 vga=792
> */
> 
> # Set root password for the embedded_rootfs
> chroot /embedded_rootfs /bin/sh
> passwd
> exit
> rm /embedded_rootfs/etc/passwd-
> 
> # Modify fstab.
> # Below is mine, yours may vary.
> nano -w /embedded_rootfs/etc/fstab
> /*
> /dev/hda1             /                       reiserfs        defaults        
> 0 0
> none                  /proc           proc            defaults        0 0
> none                  /sys            sysfs           defaults        0 0
> none                  /dev/shm        tmpfs           defaults        0 0
> */

propose the use of noatime to speed up (probably only reiserfs is an 
exception here)

> 
> # Clean up the embedded_rootfs.
> # Don't know why these files are there in the first place, so if anyone
> # can tell me why.....
> rm -R /embedded_rootfs/var/db/pkg/*
all packages' ebuild/build environment etc. are saved here (so `emerge -u 
world` would know what to update (but updates do not work as expected if 
used as ROOT=/embedded_rootfs emerge -u)

> rm -R /embedded_rootfs/var/lib/portage/

move both after any ROOT=/embedded_rootfs emerge -K foo*, else they will 
be populated again
> 
> 
> #---- Step 4 - Build and install non-system programs to the embedded_rootfs --
> 
> # Emerge other software you need for you embedded target.
> # This is very wildly depending on your needs.
> # Also your proprietary application will be done here.
> emerge foo*

you do not have to really emerge foo* to your dev system, you could only 
build the package without installing

> ROOT=/embedded_rootfs emerge -K foo*
> 
[snip]

Peter

-- 
Peter S. Mazinger <ps dot m at gmx dot net>           ID: 0xA5F059F2
Key fingerprint = 92A4 31E1 56BC 3D5A 2D08  BB6E C389 975E A5F0 59F2

-- 
[email protected] mailing list

Reply via email to