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