Gentoo Archives: gentoo-embedded

From: "Peter S. Mazinger" <ps.m@×××.net>
To: "'gentoo-embedded@l.g.o'" <gentoo-embedded@l.g.o>
Subject: Re: [gentoo-embedded] x86 SBC Gentoo Embedded HotTo version 0.09
Date: Mon, 17 Oct 2005 06:32:24
Message-Id: Pine.LNX.4.44.0510170819160.30331-100000@lnx.bridge.intra
In Reply to: [gentoo-embedded] x86 SBC Gentoo Embedded HotTo version 0.09 by Heath Holcomb
1 On Mon, 10 Oct 2005, Heath Holcomb wrote:
2
3 > Version 0.09
4 > Please add, delete, modify. Thanks!
5 >
6 > - fixed the password problem
7 > - wrote about the problem with kernels 2.6.11 (and latter)
8 > - fixed typos
9 > - added more options for UCLIBC_CPU
10 > - added two people to contributors list
11 >
12 > Also I need no workarounds this time through (minus the kernel problem).
13 >
14 > Still looking for feedback on the Gentooized version of the this how-to on
15 > readability and usefullness.
16 > http://www.bulah.com/embedded-guide.html
17 >
18 > Update to my website will come shortly.
19 > http://www.bulah.com/embeddedgentoo.html
20 >
21 > Enjoy,
22 >
23 > --------------------------------------------------------------------------------
24 > # Embedded Gentoo How-To for x86
25 > #
26 > # A how-to guide to setup a Gentoo embedded environment, you must be root.
27 > # These commands are to be run on your development system,
28 > # any x86 Gentoo Linux computer will do. The system should be fast,
29 > # to speed development. The target can be any x86 based SBC. I'm
30 > # using a Geode based SBC. Latter I'll use a Via based SBC.
31 > #
32 > # version 0.09
33 > # 2005.10.10
34 > #
35 > # Heath Holcomb (heath at bulah.com)
36 > # Ned Ludd (original commands posted)
37 > # Lloyd Sargent (contributor)
38 > # Yuri Vasilevski (contributor)
39 > # Mike George (contributor)
40 > # Kammi Cazze (contributor)
41 > # Marius Schaefer (contributor)
42 > # Pierre Cassimans (contributor)
43 > # Marius Schafer (contributor)
44 > #
45 > # Definitions and Terms
46 > # system_rootfs = your regular rootfs, development computer
47 > # development_rootfs = what you use to build the embedded_rootfs
48 > # embedded_rootfs = rootfs you deploy to the target system
49 > # SBC = single board computer (here it's an x86 based)
50 > #
51 > # References
52 > # http://www.gentoo.org/doc/en/handbook/index.xml
53 > # http://www.epiawiki.org
54 > # http://epia.kalf.org
55 > # Gentoo embedded mailing list (gentoo-embedded@l.g.o)
56 > #
57 > #
58 > # Overview of process (steps)
59 > # 1 - Prepare the development_rootfs from your system_rootfs
60 > # 2 - Build the development_rootfs
61 > # 3 - Build the embedded_rootfs
62 > # 4 - Build and install non-system programs to the embedded_rootfs
63 > # 5 - Build and install a kernel to the embedded_rootfs
64 > # 6 - Deploy embedded_rootfs to target
65 > #
66 > #--------------------------------------------------------------------------------
67 >
68 > #----- Step 1 - Prepare the development_rootfs from your system_rootfs -------
69 >
70 > # You must be root.
71 > su -
72 > cd /opt
73 >
74 > # Create the development_rootfs directory.
75 > # I use i586 because of target is a Geode processor.
76 > mkdir -p /opt/i586-gentoo-uclibc-linux/usr/portage
77 >
78 > # Download the latest stage 1 tarball.
79 > wget \
80 > http://mirror.usu.edu/mirrors/gentoo/experimental/x86/embedded/stages/\
81 > stage1-x86-uclibc-2005.0.tar.bz2
82 >
83 > # Untar the stage to the development_rootfs.
84 > tar -xvjpf stage1-x86-uclibc-2005.0.tar.bz2 -C /opt/i586-gentoo-uclibc-linux/
85 >
86 > # Mount the proc and portage directories to your development_rootfs.
87 > # Makes your system_rootfs's proc and portage directory available from inside
88 > # of your development_rootfs (after chrooting).
89 > mount --bind /proc /opt/i586-gentoo-uclibc-linux/proc/
90 > mount --bind /usr/portage /opt/i586-gentoo-uclibc-linux/usr/portage
91 >
92 > # Copy over DNS information to the development_rootfs.
93 > cp /etc/resolv.conf /opt/i586-gentoo-uclibc-linux/etc/resolv.conf
94 >
95 > # Chroot into the development_rootfs.
96 > chroot /opt/i586-gentoo-uclibc-linux /bin/bash --login
97 >
98 >
99 > #----- Step 2 - Build the development_rootfs ---------------------------------
100 >
101 > # Create new environment and load variables into memory.
102 > env-update
103 > source /etc/profile
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/2005.1 make.profile
111 >
112 > # Modify make.conf file to your liking/needs.
113 > # This is for my target, Geode x86 processor.
114 > # Other values for UCLIBC_CPU :
115 > # 386, 486, ELAN, 586, 586MMX, 686, PENTIUMII, PENTIUMIII,PENTIUM4, K6, K7
116 > # CRUSOE, WINCHIPC6, WINCHIP2, CYRIXIII, NEHEMIAH
117
118 point to read uclibc ebuild for UCLIBC_CPU on other archs
119 or some grep / sed magic to get them from the ebuild
120
121 > nano -w /etc/make.conf
122 > /*
123 > USE="bitmap-fonts minimal truetype-fonts mmx"
124 > CHOST="i586-gentoo-linux-uclibc"
125 > CFLAGS="-march=i586 -Os -pipe -fomit-frame-pointer -mmmx"
126 > CXXFLAGS="${CFLAGS}"
127 >
128 > FEATURES="buildpkg"
129 >
130 > VIDEO_CARDS="chips"
131 > UCLIBC_CPU="586MMX"
132 > */
133 >
134 > # Start the bootstrap script.
135 > cd /usr/portage/scripts
136 > ./bootstrap.sh -p -v
137 > ./bootstrap.sh
138 >
139 > # Workaround - bootstraping
140 > # Failure compiling uclibc (gcc-config error: Could not run/locate "gcc")?
141 > # If you get a failure while bootstrap is compileing uclibc here are the steps
142 > # to work around the problem.
143 > gcc-config 1
144 > source /etc/profile
145 > ./bootstrap.sh
146 >
147 > # Emerge the system ebuild for the development_rootfs.
148 > emerge -e system
149 >
150 > # Workaround - emerge system
151 > # During emerge -e system, python-fchksum failes complaing about
152 > # gcc-config error: Could not run/locate "i386-gentoo-linux-uclibc-gcc"
153
154 the problem occurs if you change CHOST's ARCH part (as you did from i386
155 to i586)
156
157 > # The following commands work around this problem.
158 > emerge python
159 > emerge -e system
160 >
161 > #----- Step 3 - Build the embedded_rootfs ------------------------------------
162 >
163 > # Create the embedded_rootfs directory.
164 > mkdir /embedded_rootfs
165 >
166 > # Emerge baselayout-lite into embedded_rootfs.
167 > # This gives your system a basic file structure.
168 > # 1.0_pre1 is the only one that is stable, right?
169 > cd /usr/portage/sys-apps/baselayout-lite/
170 > ROOT=/embedded_rootfs emerge baselayout-lite-1.0_pre1.ebuild
171 >
172 > # Required Workaround - baselayout-lite
173 > # Baselayout-lite is still beta, so a few fixes are needed.
174 > # There needs to be a directory "log" in /var.
175 > # Inittab calls for /usr/bin/tail, but it needs to /usr/bin.
176 > mkdir /embedded_rootfs/var/log
177 > nano -w /embedded_rootfs/etc/inittab
178 > /*
179 > #tty3::respawn:/usr/bin/tail -f /var/log/messages
180 > tty3::respawn:/bin/tail -f /var/log/messages
181 > */
182 >
183 > # Emerge uclibc into the embedded_rootfs.
184 > # Use the -K option because we don't get the extra files created by the
185 > # build/emerge process into our embedded rootfs which needs to be as
186 > # small as possible.
187 > ROOT=/embedded_rootfs emerge -K uclibc
188 >
189 > # Emerge busybox into the embedded_rootfs.
190 > # First you must emerge it into your development_rootfs.
191 > # This does not create the symlinks in our development embedded rootfs.
192 > emerge busybox
193 > ROOT=/embedded_rootfs emerge -K busybox
194 >
195 > # Create the symlinks for busybox in the embedded_rootfs.
196 > mkdir /embedded_rootfs/proc
197 > mount -o bind /proc/ /embedded_rootfs/proc/
198 > chroot /embedded_rootfs /bin/busybox --install -s
199 > umount /embedded_rootfs/proc
200 >
201 > # Set time zone in your embedded_rootfs.
202 > # See http://leaf.sourceforge.net/doc/guide/buci-tz.html for details.
203 > # For central standard time in the US, use "CST6CDT".
204 > nano -w /embedded_rootfs/etc/TZ
205 > /*
206 > CST6CDT
207 > */
208 >
209 > # Install a boot loader (usually grub or lilo).
210 > # Once you copy/deploy your embedded_rootfs to your target SBC you will
211 > # have to run grub on the command line to write to the master boot record
212 > # (MBR).
213 > # For some reason not all of /boot/grub is copied over to the
214 > # embedded_rootfs, so a extra manual copy step is needed.
215 > # The --nodeps gets rip of the run time need of ncurses.
216 > emerge --nodeps grub
217 > ROOT=/embedded_rootfs emerge -K --nodeps grub
218 > cp -R /boot/grub /embedded_rootfs/boot/
219 >
220 > # Modify your boot configure file.
221 > # The example below is for a grub, for a boot partition on /dev/hda1 and only
222 > # one partition on the target SBC system.
223 > nano -w /embedded_rootfs/boot/grub/grub.conf
224 > /*
225 > default 0
226 > timeout 10
227 > splashimage=(hd0,0)/boot/grub/splash.xpm.gz
228 >
229 > title=Linux 2.6.x
230 > root (hd0,0)
231 > kernel /vmlinuz-2.6.x root=/dev/hda1 vga=792
232 > */
233 >
234 > # Set root password for the embedded_rootfs
235 > chroot /embedded_rootfs /bin/sh
236 > passwd
237 > exit
238 > rm /embedded_rootfs/etc/passwd-
239 >
240 > # Modify fstab.
241 > # Below is mine, yours may vary.
242 > nano -w /embedded_rootfs/etc/fstab
243 > /*
244 > /dev/hda1 / reiserfs defaults 0 0
245 > none /proc proc defaults 0 0
246 > none /sys sysfs defaults 0 0
247 > none /dev/shm tmpfs defaults 0 0
248 > */
249
250 propose the use of noatime to speed up (probably only reiserfs is an
251 exception here)
252
253 >
254 > # Clean up the embedded_rootfs.
255 > # Don't know why these files are there in the first place, so if anyone
256 > # can tell me why.....
257 > rm -R /embedded_rootfs/var/db/pkg/*
258 all packages' ebuild/build environment etc. are saved here (so `emerge -u
259 world` would know what to update (but updates do not work as expected if
260 used as ROOT=/embedded_rootfs emerge -u)
261
262 > rm -R /embedded_rootfs/var/lib/portage/
263
264 move both after any ROOT=/embedded_rootfs emerge -K foo*, else they will
265 be populated again
266 >
267 >
268 > #---- Step 4 - Build and install non-system programs to the embedded_rootfs --
269 >
270 > # Emerge other software you need for you embedded target.
271 > # This is very wildly depending on your needs.
272 > # Also your proprietary application will be done here.
273 > emerge foo*
274
275 you do not have to really emerge foo* to your dev system, you could only
276 build the package without installing
277
278 > ROOT=/embedded_rootfs emerge -K foo*
279 >
280 [snip]
281
282 Peter
283
284 --
285 Peter S. Mazinger <ps dot m at gmx dot net> ID: 0xA5F059F2
286 Key fingerprint = 92A4 31E1 56BC 3D5A 2D08 BB6E C389 975E A5F0 59F2
287
288 --
289 gentoo-embedded@g.o mailing list