Gentoo Archives: gentoo-embedded

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

Replies

Subject Author
Re: [gentoo-embedded] x86 SBC Gentoo Embedded HotTo version 0.08 Pierre Cassimans <kammicazze@×××××××.com>