1 |
Version 0.06 |
2 |
Please add, delete, modify. Thanks! |
3 |
This procedure produces a working embedded rootfs, that boots form a hard |
4 |
drive on a Geode based SBC (single board computer); at least on my |
5 |
development system. |
6 |
|
7 |
I've update my website with this version also. |
8 |
http://www.bulah.com/embeddedgentoo.html |
9 |
|
10 |
|
11 |
#-------------------------------------------------------------------------------- |
12 |
# Embedded Gentoo How-To for x86 |
13 |
# |
14 |
# A how-to guide to setup a Gentoo embedded environment, you must be root. |
15 |
# These commands are to be run on your development system, |
16 |
# any x86 Gentoo Linux computer will do. The system should be fast, |
17 |
# to speed development. The target can be any x86 based SBC. I'm |
18 |
# using a Geode based SBC. Latter I'll use a Via based SBC. |
19 |
# |
20 |
# version 0.06 |
21 |
# 2005.6.6 |
22 |
# |
23 |
# Heath Holcomb (heath at bulah.com) |
24 |
# Ned Ludd (embedded Gentoo project lead, original commands posted) |
25 |
# Lloyd Sargent (contributor) |
26 |
# Yuri Vasilevshi (contributor) |
27 |
# Mike George (contributor) |
28 |
# Kammi Cazze (contributor) |
29 |
# Marius Schaefer (contributor) |
30 |
# |
31 |
# Definitions and Terms |
32 |
# system_rootfs = your regular rootfs |
33 |
# development_rootfs = what you use to build the embedded_rootfs |
34 |
# embedded_rootfs = rootfs you deploy to the target system |
35 |
# SBC = single board computer (here it's an x86 based) |
36 |
# |
37 |
# References |
38 |
# http://www.gentoo.org/doc/en/handbook/index.xml |
39 |
# http://www.epiawiki.org |
40 |
# http://epia.kalf.org |
41 |
# Gentoo embedded mailing list (gentoo-embedded@l.g.o) |
42 |
# |
43 |
# |
44 |
# Overview of process (steps) |
45 |
# 1 - Prepare the development_rootfs from your system_rootfs |
46 |
# 2 - Build the development_rootfs |
47 |
# 3 - Build the embedded_rootfs |
48 |
# 4 - Build and install non-system programs to the embedded_rootfs |
49 |
# 5 - Build and install a kernel to the embedded_rootfs |
50 |
# 6 - Deploy embedded_rootfs to target |
51 |
# |
52 |
#-------------------------------------------------------------------------------- |
53 |
|
54 |
#----- Step 1 - Prepare the development_rootfs from your system_rootfs ------- |
55 |
|
56 |
# You must be root. |
57 |
su - |
58 |
|
59 |
# Create the development_rootfs. |
60 |
# I use i586 because of target is a Geode processor. |
61 |
mkdir -p /opt/i586-gentoo-uclibc-linux/usr/portage |
62 |
|
63 |
# Download the latest stage 1 tarball. |
64 |
wget \ |
65 |
http://gentoo.osuosl.org/experimental/x86/embedded/stages/stage1-x86-uclibc-2005.0.tar.bz2 |
66 |
|
67 |
# Untar the stage to the development_rootfs. |
68 |
tar -xvjf stage1-x86-uclibc-2005.0.tar.bz2 -C /opt/i586-gentoo-uclibc-linux/ |
69 |
|
70 |
# Mount the proc and portage directories to your development_rootfs. |
71 |
# Makes your system_rootfs's proc and portage directory available from inside |
72 |
# of your development_rootfs (after chrooting). |
73 |
mount --bind /proc /opt/i586-gentoo-uclibc-linux/proc/ |
74 |
mount --bind /usr/portage /opt/i586-gentoo-uclibc-linux/usr/portage |
75 |
|
76 |
# Copy over DNS information to the development_rootfs. |
77 |
cp /etc/resolv.conf /opt/i586-gentoo-uclibc-linux/etc/resolv.conf |
78 |
|
79 |
# Chroot into the development_rootfs. |
80 |
chroot /opt/i586-gentoo-uclibc-linux /bin/bash --login |
81 |
|
82 |
|
83 |
#----- Step 2 - Build the development_rootfs --------------------------------- |
84 |
|
85 |
# Create new environment and load variables into memory. |
86 |
env-update |
87 |
source /etc/profile |
88 |
|
89 |
# Modify make.conf file to your liking/needs. |
90 |
nano -w /etc/make.conf |
91 |
# This is for my target, Geode x86 processor. |
92 |
/* |
93 |
USE="bitmap-fonts minimal truetype-fonts uclibc mmx" |
94 |
CHOST="i586-gentoo-linux-uclibc" |
95 |
CFLAGS="-march=i586 -Os -pipe -fomit-frame-pointer -mmmx" |
96 |
CXXFLAGS="${CFLAGS}" |
97 |
FEATURES="buildpkg" |
98 |
|
99 |
VIDEO_CARDS="chips" |
100 |
UCLIBC_CPU="586MMX" |
101 |
*/ |
102 |
|
103 |
# Set profile to use 2.6 kernel. |
104 |
# The current stage uses 2.4 by default, and for most cases you are going |
105 |
# to want a 2.6.x kernel. |
106 |
rm /etc/make.profile |
107 |
ln -s /usr/portage/profiles/uclibc/x86 /etc/make.profile |
108 |
|
109 |
# Start the bootstrap script. |
110 |
cd /usr/portage/scripts |
111 |
./bootstrap.sh -p -v |
112 |
./bootstrap.sh |
113 |
|
114 |
# Workaround 1 |
115 |
# Failure compiling uclibc (gcc-config error: Could not run/locate "gcc")? |
116 |
# If you get a failure while bootstrap is compileing uclibc here are the steps |
117 |
# to work around the problem. |
118 |
gcc-config 1 |
119 |
source /etc/profile |
120 |
./bootstrap.sh |
121 |
|
122 |
# Emerge the system ebuild for the development_rootfs. |
123 |
emerge -e system |
124 |
|
125 |
# Workaround 2 |
126 |
# During emerge -e system, python-fchksum failes complaing about |
127 |
# gcc-config error: Could not run/locate "i386-gentoo-linux-uclibc-gcc" |
128 |
# The following commands work around this problem. |
129 |
emerge python |
130 |
emerge -e system |
131 |
|
132 |
|
133 |
#----- Step 3 - Build the embedded_rootfs ------------------------------------ |
134 |
|
135 |
# Create the embedded_rootfs directory. |
136 |
mkdir /embedded_rootfs |
137 |
|
138 |
# Emerge baselayout-lite into embedded_rootfs. |
139 |
# This gives your system a basic file structure. |
140 |
# 1.0_pre1 is the only one that is stable, right? |
141 |
cd /usr/portage/sys-apps/baselayout-lite/ |
142 |
ROOT=/embedded_rootfs emerge baselayout-lite-1.0_pre1.ebuild |
143 |
|
144 |
# Workaround 3 |
145 |
# Baselayout-lite is still beta, so a few fixes are needed. |
146 |
# There needs to be a directory "log" in /var. |
147 |
# Inittab calls for /usr/bin/tail, but it needs to /usr/bin. |
148 |
mkdir /embedded_rootfs/var/log |
149 |
nano -w /embedded_rootfs/etc/inittab |
150 |
/* |
151 |
#tty3::respawn:/usr/bin/tail -f /var/log/messages |
152 |
tty3::respawn:/bin/tail -f /var/log/messages |
153 |
*/ |
154 |
|
155 |
# Emerge uclibc into the embedded_rootfs. |
156 |
# Use the -K option because we don't get the extra files created by the |
157 |
# build/emerge process into our embedded rootfs which needs to be as |
158 |
# small as possible. |
159 |
ROOT=/embedded_rootfs emerge -K uclibc |
160 |
|
161 |
# Emerge busybox into the embedded_rootfs. |
162 |
# First you must emerge it into your development_rootfs. |
163 |
# This does not create the symlinks in our development embedded rootfs. |
164 |
emerge busybox |
165 |
ROOT=/embedded_rootfs emerge -K busybox |
166 |
|
167 |
# Create the symlinks for busybox in the embedded_rootfs. |
168 |
mkdir /embedded_rootfs/proc |
169 |
mount -o bind /proc/ /embedded_rootfs/proc/ |
170 |
chroot /embedded_rootfs /bin/busybox --install -s |
171 |
umount /embedded_rootfs/proc |
172 |
|
173 |
# Set time zone in your embedded_rootfs. |
174 |
# See http://leaf.sourceforge.net/doc/guide/buci-tz.html for details. |
175 |
# For central standard time in the US, use "CST6CDT". |
176 |
nano -w /embedded_rootfs/etc/TZ |
177 |
/* |
178 |
CST6CDT |
179 |
*/ |
180 |
|
181 |
# Install a boot loader (usually grug or lilo). |
182 |
# Once you copy/deploy your embedded_rootfs program to you target SBC you will |
183 |
# have to run the grub on the command line to write to the master boot record |
184 |
# (MBR). |
185 |
# Ncurses is needed by grub, if you are not using gurb then you don't need |
186 |
# ncurses. For some reason not all of /boot/grub is copied over to the |
187 |
# embedded_rootfs, so a extra manual copy step is needed. |
188 |
ROOT=/embedded_rootfs emerge -K ncurses |
189 |
emerge grub |
190 |
ROOT=/embedded_rootfs emerge -K grub |
191 |
cp -R /boot/grub /embedded_rootfs/boot/ |
192 |
|
193 |
# Modify your boot configure file. |
194 |
# The example below is for a gurb, for a boot partition on /dev/hda1 and only |
195 |
# one partition on the target SBC system. |
196 |
nano -w /embedded_rootfs/boot/grub/grub.conf |
197 |
/* |
198 |
default 0 |
199 |
timeout 10 |
200 |
splashimage=(hd0,0)/boot/grub/splash.xpm.gz |
201 |
|
202 |
title=Linux 2.6.x |
203 |
root (hd0,0) |
204 |
kernel /vmlinuz-2.6.x root=/dev/hda1 vga=792 |
205 |
*/ |
206 |
|
207 |
# Set root password |
208 |
ROOT=/embedded_rootfs passwd |
209 |
|
210 |
# Modify fstab. |
211 |
# Below is mine, yours may vary. |
212 |
nano -w /embedded_rootfs/etc/fstab |
213 |
/* |
214 |
/dev/hda1 / reiserfs defaults 0 0 |
215 |
none /proc proc defaults 0 0 |
216 |
none /sys sysfs defaults 0 0 |
217 |
none /dev/shm tmpfs defaults 0 0 |
218 |
*/ |
219 |
|
220 |
#---- Step 4 - Build and install non-system programs to the embedded_rootfs -- |
221 |
|
222 |
# Emerge other software you need for you embedded target. |
223 |
# This is very wildly depending on your needs. |
224 |
# Also your proprietary application will be done here. |
225 |
emerge foobar* |
226 |
ROOT=/embedded_rootfs emerge -K foobar* |
227 |
|
228 |
|
229 |
#---- Step 5 - Build and install a kernel to the embedded_rootfs ------------- |
230 |
|
231 |
# Install a kernel into embedded_rootfs. |
232 |
# First we will emerge it into our development_rootfs, then configure and |
233 |
# build it. |
234 |
emerge vanilla-sources |
235 |
cd /usr/src/ |
236 |
cd linux |
237 |
make menuconfig |
238 |
# configure your kernel for your TARGET SBC here |
239 |
make |
240 |
ROOT=/embedded_rootfs make modules_install |
241 |
cp /usr/src/linux/arch/i386/boot/bzImage /embedded_rootfs/boot/vmlinuz-2.6.x |
242 |
|
243 |
# A few notes on compiling your kernel. |
244 |
# If deploying to Compact Flash/DiskOnChip/SD us ext2, as the journaling |
245 |
# filing systems "write" to much for a flash device. |
246 |
# If deploying to a hard drive use a journaling filing system, such as |
247 |
# ext3 or reiserfs. |
248 |
|
249 |
|
250 |
#---- Step 6 - Deploy embedded_rootfs to target ------------------------------ |
251 |
|
252 |
# Prepare a Gentoo (or any Linux distro) system on the target SBC using a |
253 |
# harddrive. This is known as the target development rootfs. |
254 |
# We will create a partition (/embedded_rootfs) that will server as our |
255 |
# "test" partition to deploy our embedded_rootfs that we generate on our |
256 |
# development_system. |
257 |
# |
258 |
# I use the following partitions to speed development (yours may vary): |
259 |
# /dev/hda1 - /embedded_rootfs - 1 GB |
260 |
# /dev/hda2 - /boot - 100 MB |
261 |
# /dev/hda3 - swap - (size varies, 512 MB is a good number) |
262 |
# /dev/hda4 - / - (what is left, at least 1.5 GB per 2005.0 install guide |
263 |
specs) |
264 |
# |
265 |
# Copy over your embedded_rootfs from you development system to your target |
266 |
# system and the directory /embedded_rootfs. This needs to be done via NFS as |
267 |
# need to preserve the permissions. |
268 |
# |
269 |
#The following commands are done from the |
270 |
# target development rootfs. |
271 |
mount -t reiserfs /dev/hda1 /mnt/embedded_rootfs |
272 |
mount -t nfs |
273 |
192.168.0.10:/opt/i586-gentoo-uclibc-linux/embedded_rootfs /mnt/transfer |
274 |
cp -adpR /mnt/transfer/* /mnt/embedded_rootfs |
275 |
|
276 |
|
277 |
# Modify your target system's gurb.conf (or lilo.conf) for allow you to boot |
278 |
# to the embedded_rootfs partition. |
279 |
# |
280 |
# Reboot, and if all goes well you'll be greeted with a login prompt. |
281 |
# |
282 |
# Fin. |
283 |
|
284 |
|
285 |
|
286 |
-- |
287 |
Heath Holcomb |
288 |
liquidcable |
289 |
liquidcable at bulah.com |
290 |
-- |
291 |
gentoo-embedded@g.o mailing list |