Gentoo Archives: gentoo-embedded

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

Replies

Subject Author
Re: [gentoo-embedded] x86 SBC Gentoo Embedded HotTo version 0.07 Natanael Copa <mlists@××××××.org>