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