Gentoo Archives: gentoo-embedded

From: Heath Holcomb <liquidcable@×××××.com>
To: gentoo-embedded@l.g.o
Subject: Re: [gentoo-embedded] x86 SBC Gentoo Embedded HotTo version 0.07
Date: Sat, 13 Aug 2005 22:54:28
Message-Id: 200508131752.40677.liquidcable@bulah.com
In Reply to: RE: [gentoo-embedded] x86 SBC Gentoo Embedded HotTo version 0.07 by Marcel Romijn
1 On Friday 12 August 2005 01:39 am, Marcel Romijn wrote:
2 > Hello Heath,
3 >
4 > Nice writedown! I haven't made it to the end yet (lack of time), but I'm
5 > getting there...
6 >
7 > I noticed some issues along the way (not counting grub begin spelled as
8 > "grug" or "gurb" ;-) )
9 >
10 > In step 3 you write:
11 >
12 > <snip>
13 > # Set root password for the embedded_rootfs
14 > chromm /embedded_rootfs
15 > passwd
16 > rm /embedded_rootfs/etc/passwd-
17 > Exit
18 > </snip>
19 >
20 > I presume 'chromm' should have been 'chroot' ?
21 > If it is indeed 'chroot' then you should either do "rm /etc/passwd-"
22 > before the "exit" or the "exit" before the "rm
23 > /embedded_rootfs/etc/passwd-".
24
25 Yes, "chromm" should be "chroot". The order is correct, as far as I can tell.
26 chroot /embedded_rootfs
27 passwd
28 rm /embedded_rootfs/etc/passwd-
29 exit
30
31
32 > A few lines down, you write:
33 >
34 > <snip>
35 > rm -R /embedded_rootfs/var/db/pkg/ *
36 > </snip>
37 >
38 > As a reletive newbie, doing a quick copy/paste of this command late in
39 > the evening as root in '/', this wiped out all files, except the ones
40 > that were firmly locked.
41 > Fortunately, I'm going through you HowTo in VMWare, so I could restore a
42 > previous snapshot ;-)
43 >
44 > I presume the space before the '*' should have been omitted?
45 >
46 > <snip>
47 > rm -R /embedded_rootfs/var/db/pkg/*
48 > </snip>
49
50 Major typo on my part. Fixed in version 0.08.
51
52 >
53 > My aim is to create an embedded Gentoo for a Via Epia ME6000, which
54 > reads the kernel and a ramdisk image from CF and then runs completely
55 > from RAM.
56 > If I'm not mistaken, you were heading for a Via Epia as well?
57
58 My target will be a Via based SBC. From what I have read using a ramdisk on a
59 x86 based platform really does not buy you much. But you sure don't want to
60 write to the CF all that often (limited write cycles, usallay 100,000 to
61 300,000). So I plan on mounting the / partition of the CF as read only and
62 creating a separate partition that is mounted read/write and have my embedded
63 application and only my application write to that partition.
64
65 > Regards,
66 >
67 > Marcel Romijn
68 >
69 >
70 > -----Original Message-----
71 > From: Heath Holcomb [mailto:liquidcable@×××××.com]
72 > Sent: Monday, 08 August, 2005 4:17
73 > To: gentoo-embedded@l.g.o
74 > Subject: [gentoo-embedded] x86 SBC Gentoo Embedded HotTo version 0.07
75 >
76 > Version 0.07
77 > Please add, delete, modify. Thanks!
78 >
79 > Several fixes. Root password now works. Several work arounds are no
80 > longer
81 > need, as the embedded Gentoo team has fixed them (I'm guess because I no
82 >
83 > longer get those errors). There is still one problem when "emerge -e
84 > system"
85 > for groff. Bug 98187 (http://bugs.gentoo.org/show_bug.cgi?id=98187).
86 > Check
87 > out the bug report for the temp fix/work around (USE="-sandbox" emerge
88 > -e
89 > system).
90 >
91 > I've update my website with this version also.
92 > http://www.bulah.com/embeddedgentoo.html
93 >
94 >
95 > #-----------------------------------------------------------------------
96 > ---------
97 > # Embedded Gentoo How-To for x86
98 > #
99 > # A how-to guide to setup a Gentoo embedded environment, you must be
100 > root.
101 > # These commands are to be run on your development system,
102 > # any x86 Gentoo Linux computer will do. The system should be fast,
103 > # to speed development. The target can be any x86 based SBC. I'm
104 > # using a Geode based SBC. Latter I'll use a Via based SBC.
105 > #
106 > # version 0.07
107 > # 2005.8.7
108 > #
109 > # Heath Holcomb (heath at bulah.com)
110 > # Ned Ludd (original commands posted)
111 > # Lloyd Sargent (contributor)
112 > # Yuri Vasilevski (contributor)
113 > # Mike George (contributor)
114 > # Kammi Cazze (contributor)
115 > # Marius Schaefer (contributor)
116 > #
117 > # Definitions and Terms
118 > # system_rootfs = your regular rootfs, development computer
119 > # development_rootfs = what you use to build the embedded_rootfs
120 > # embedded_rootfs = rootfs you deploy to the target system
121 > # SBC = single board computer (here it's an x86 based)
122 > #
123 > # References
124 > # http://www.gentoo.org/doc/en/handbook/index.xml
125 > # http://www.epiawiki.org
126 > # http://epia.kalf.org
127 > # Gentoo embedded mailing list (gentoo-embedded@l.g.o)
128 > #
129 > #
130 > # Overview of process (steps)
131 > # 1 - Prepare the development_rootfs from your system_rootfs
132 > # 2 - Build the development_rootfs
133 > # 3 - Build the embedded_rootfs
134 > # 4 - Build and install non-system programs to the embedded_rootfs
135 > # 5 - Build and install a kernel to the embedded_rootfs
136 > # 6 - Deploy embedded_rootfs to target
137 > #
138 > #-----------------------------------------------------------------------
139 > ---------
140 >
141 > #----- Step 1 - Prepare the development_rootfs from your system_rootfs
142 > -------
143 >
144 > # You must be root.
145 > su -
146 >
147 > # Create the development_rootfs.
148 > # I use i586 because of target is a Geode processor.
149 > mkdir -p /opt/i586-gentoo-uclibc-linux/usr/portage
150 >
151 > # Download the latest stage 1 tarball.
152 > wget \
153 > http://gentoo.osuosl.org/experimental/x86/embedded/stages/stage1-x86-ucl
154 > ibc-2005.0.tar.bz2
155 >
156 > # Untar the stage to the development_rootfs.
157 > tar -xvjpf stage1-x86-uclibc-2005.0.tar.bz2 -C
158 > /opt/i586-gentoo-uclibc-linux/
159 >
160 > # Mount the proc and portage directories to your development_rootfs.
161 > # Makes your system_rootfs's proc and portage directory available from
162 > inside
163 > # of your development_rootfs (after chrooting).
164 > mount --bind /proc /opt/i586-gentoo-uclibc-linux/proc/
165 > mount --bind /usr/portage /opt/i586-gentoo-uclibc-linux/usr/portage
166 >
167 > # Copy over DNS information to the development_rootfs.
168 > cp /etc/resolv.conf /opt/i586-gentoo-uclibc-linux/etc/resolv.conf
169 >
170 > # Chroot into the development_rootfs.
171 > chroot /opt/i586-gentoo-uclibc-linux /bin/bash --login
172 >
173 >
174 > #----- Step 2 - Build the development_rootfs
175 > ---------------------------------
176 >
177 > # Create new environment and load variables into memory.
178 > env-update
179 > source /etc/profile
180 >
181 > # Modify make.conf file to your liking/needs.
182 > nano -w /etc/make.conf
183 > # This is for my target, Geode x86 processor.
184 > /*
185 > USE="bitmap-fonts minimal truetype-fonts mmx"
186 > CHOST="i586-gentoo-linux-uclibc"
187 > CFLAGS="-march=i586 -Os -pipe -fomit-frame-pointer -mmmx"
188 > CXXFLAGS="${CFLAGS}"
189 > FEATURES="buildpkg"
190 >
191 > VIDEO_CARDS="chips"
192 > UCLIBC_CPU="586MMX"
193 > */
194 >
195 > # Set profile to use 2.6 kernel.
196 > # The current stage uses 2.4 by default, and for most cases you are
197 > going
198 > # to want a 2.6.x kernel.
199 > cd /etc/
200 > unlink make.profile
201 > ln -s ../usr/portage/profiles/uclibc/x86 make.profile
202 >
203 > # Start the bootstrap script.
204 > cd /usr/portage/scripts
205 > ./bootstrap.sh -p -v
206 > ./bootstrap.sh
207 >
208 > # Emerge the system ebuild for the development_rootfs.
209 > emerge -e system
210 >
211 > #----- Step 3 - Build the embedded_rootfs
212 > ------------------------------------
213 >
214 > # Create the embedded_rootfs directory.
215 > mkdir /embedded_rootfs
216 >
217 > # Emerge baselayout-lite into embedded_rootfs.
218 > # This gives your system a basic file structure.
219 > # 1.0_pre1 is the only one that is stable, right?
220 > cd /usr/portage/sys-apps/baselayout-lite/
221 > ROOT=/embedded_rootfs emerge baselayout-lite-1.0_pre1.ebuild
222 >
223 > # Workaround 1
224 > # Baselayout-lite is still beta, so a few fixes are needed.
225 > # There needs to be a directory "log" in /var.
226 > # Inittab calls for /usr/bin/tail, but it needs to /usr/bin.
227 > mkdir /embedded_rootfs/var/log
228 > nano -w /embedded_rootfs/etc/inittab
229 > /*
230 > #tty3::respawn:/usr/bin/tail -f /var/log/messages
231 > tty3::respawn:/bin/tail -f /var/log/messages
232 > */
233 >
234 > # Emerge uclibc into the embedded_rootfs.
235 > # Use the -K option because we don't get the extra files created by the
236 > # build/emerge process into our embedded rootfs which needs to be as
237 > # small as possible.
238 > ROOT=/embedded_rootfs emerge -K uclibc
239 >
240 > # Emerge busybox into the embedded_rootfs.
241 > # First you must emerge it into your development_rootfs.
242 > # This does not create the symlinks in our development embedded rootfs.
243 > emerge busybox
244 > ROOT=/embedded_rootfs emerge -K busybox
245 >
246 > # Create the symlinks for busybox in the embedded_rootfs.
247 > mkdir /embedded_rootfs/proc
248 > mount -o bind /proc/ /embedded_rootfs/proc/
249 > chroot /embedded_rootfs /bin/busybox --install -s
250 > umount /embedded_rootfs/proc
251 >
252 > # Set time zone in your embedded_rootfs.
253 > # See http://leaf.sourceforge.net/doc/guide/buci-tz.html for details.
254 > # For central standard time in the US, use "CST6CDT".
255 > nano -w /embedded_rootfs/etc/TZ
256 > /*
257 > CST6CDT
258 > */
259 >
260 > # Install a boot loader (usually grug or lilo).
261 > # Once you copy/deploy your embedded_rootfs to your target SBC you will
262 > # have to run grub on the command line to write to the master boot
263 > record
264 > # (MBR).
265 > # For some reason not all of /boot/grub is copied over to the
266 > # embedded_rootfs, so a extra manual copy step is needed.
267 > # The --nodeps gets rip of the run time need of ncurses.
268 > emerge --nodeps grub
269 > ROOT=/embedded_rootfs emerge -K --nodeps grub
270 > cp -R /boot/grub /embedded_rootfs/boot/
271 >
272 > # Modify your boot configure file.
273 > # The example below is for a gurb, for a boot partition on /dev/hda1 and
274 > only
275 > # one partition on the target SBC system.
276 > nano -w /embedded_rootfs/boot/grub/grub.conf
277 > /*
278 > default 0
279 > timeout 10
280 > splashimage=(hd0,0)/boot/grub/splash.xpm.gz
281 >
282 > title=Linux 2.6.x
283 > root (hd0,0)
284 > kernel /vmlinuz-2.6.x root=/dev/hda1 vga=792
285 > */
286 >
287 > # Set root password for the embedded_rootfs
288 > chromm /embedded_rootfs
289 > passwd
290 > rm /embedded_rootfs/etc/passwd-
291 > exit
292 >
293 > # Modify fstab.
294 > # Below is mine, yours may vary.
295 > nano -w /embedded_rootfs/etc/fstab
296 > /*
297 > /dev/hda1 / reiserfs defaults
298 > 0 0
299 > none /proc proc defaults
300 > 0 0
301 > none /sys sysfs defaults
302 > 0 0
303 > none /dev/shm tmpfs defaults 0 0
304 > */
305 >
306 > # Clean up the embedded_rootfs.
307 > # Don't know why these files are there in the first place, so if anyone
308 > # can tell me why.....
309 > rm -R /embedded_rootfs/var/db/pkg/ *
310 > rm -R /embedded_rootfs/var/lib/portage/
311 >
312 > #---- Step 4 - Build and install non-system programs to the
313 > embedded_rootfs --
314 >
315 > # Emerge other software you need for you embedded target.
316 > # This is very wildly depending on your needs.
317 > # Also your proprietary application will be done here.
318 > emerge foo*
319 > ROOT=/embedded_rootfs emerge -K foo*
320 >
321 >
322 > #---- Step 5 - Build and install a kernel to the embedded_rootfs
323 > -------------
324 >
325 > # Install a kernel into embedded_rootfs.
326 > # First we will emerge it into our development_rootfs, then configure
327 > and
328 > # build it.
329 > emerge vanilla-sources
330 > cd /usr/src/
331 > cd linux
332 > make menuconfig
333 > # Configure your kernel for your TARGET SBC here. I HIGHLY suggest you
334 > # configure the kernel to compile everything into the kernel, and
335 > nothing
336 > # as a module.
337 > make
338 > ROOT=/embedded_rootfs make modules_install
339 > cp /usr/src/linux/arch/i386/boot/bzImage
340 > /embedded_rootfs/boot/vmlinuz-2.6.x
341 >
342 > # A few notes on compiling your kernel.
343 > # If deploying to Compact Flash/DiskOnChip/SD use ext2, as the
344 > journaling
345 > # filing systems "write" to much for a flash device.
346 > # If deploying to a hard drive use a journaling filing system, such as
347 > # ext3 or reiserfs.
348 >
349 >
350 > #---- Step 6 - Deploy embedded_rootfs to target
351 > ------------------------------
352 >
353 > # Prepare a Gentoo (or any Linux distro) system on the target SBC using
354 > a
355 > # harddrive. This is known as the target development rootfs.
356 > # We will create a partition (/embedded_rootfs) that will server as our
357 > # "test" partition to deploy our embedded_rootfs that we generate on our
358 > # development_system.
359 > #
360 > # I use the following partitions to speed development (yours may vary):
361 > # /dev/hda1 - /embedded_rootfs - 1 GB
362 > # /dev/hda2 - /boot - 100 MB
363 > # /dev/hda3 - swap - (size varies, 512 MB is a good number)
364 > # /dev/hda4 - / - (what is left, at least 1.5 GB per 2005.0 install
365 > guide
366 > specs)
367 > #
368 > # Copy over your embedded_rootfs from you development system to your
369 > target
370 > # system and the directory /embedded_rootfs. This needs to be done via
371 > NFS as
372 > # need to preserve the permissions.
373 > #
374 > #The following commands are done from the
375 > # target development rootfs.
376 > mount -t reiserfs /dev/hda1 /mnt/embedded_rootfs
377 > mount -t nfs\
378 > 192.168.0.10:/opt/i586-gentoo-uclibc-linux/embedded_rootfs\
379 > /mnt/nfs_embedded_rootfs
380 > cp -adpR /mnt/nfs_embedded_rootfs/* /mnt/embedded_rootfs
381 >
382 >
383 > # Modify your target system's gurb.conf (or lilo.conf) for allow you to
384 > boot
385 > # to the embedded_rootfs partition.
386 > #
387 > # Reboot, and if all goes well you'll be greeted with a login prompt.
388 > #
389 > # Fin.
390 >
391 >
392 >
393 > --
394 > heath holcomb
395 > liquidcable at bulah.com
396 > www.bulah.com
397 > --
398 > gentoo-embedded@g.o mailing list
399
400 --
401 heath holcomb
402 liquidcable at bulah.com
403 www.bulah.com
404 --
405 gentoo-embedded@g.o mailing list

Replies

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