Gentoo Archives: gentoo-embedded

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

Replies

Subject Author
Re: [gentoo-embedded] x86 SBC Gentoo Embedded HotTo version 0.09 "Xabier Yeregi (BIC BERRILAN)" <xyeregi@×××××××××××.com>
Re: [gentoo-embedded] x86 SBC Gentoo Embedded HotTo version 0.09 Mike Frysinger <vapier@g.o>
Re: [gentoo-embedded] x86 SBC Gentoo Embedded HotTo version 0.09 "Peter S. Mazinger" <ps.m@×××.net>
Re: [gentoo-embedded] x86 SBC Gentoo Embedded HotTo version 0.09 "Philippe Clérié" <philippe@××××.net>