Gentoo Archives: gentoo-embedded

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

Replies

Subject Author
Re: [gentoo-embedded] x86 SBC Gentoo Embedded HotTo version 0.07 Robert Wohleb <rob@×××××××××××××.com>