Gentoo Archives: gentoo-embedded

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

Replies

Subject Author
Re: [gentoo-embedded] x86 SBC Gentoo Embedded HotTo version 0.07 "S. ancelot" <sancelot@××××.fr>
Re: [gentoo-embedded] x86 SBC Gentoo Embedded HotTo version 0.07 "S. ancelot" <sancelot@××××.fr>