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