Gentoo Archives: gentoo-embedded

From: Yuri Vasilevski <yuri@×××××××××××××.mx>
To: gentoo-embedded@l.g.o
Subject: Re: [gentoo-embedded] x86 SBC Gentoo Embedded HowTo version 0.06 (almost finished)
Date: Mon, 06 Jun 2005 16:16:11
Message-Id: 20050606111622.79f2a6ec@edune.lan
In Reply to: [gentoo-embedded] x86 SBC Gentoo Embedded HowTo version 0.06 (almost finished) by Heath H Holcomb
1 Hi,
2
3 On Mon, 6 Jun 2005 10:03:26 -0500
4 Heath H Holcomb <liquidcable@×××××.com> wrote:
5
6 > Version 0.06
7 > Please add, delete, modify. Thanks!
8
9 Just some things that came to my mind with respect to this
10 version.
11
12 > This procedure produces a working embedded rootfs, that boots form a hard
13 > drive on a Geode based SBC (single board computer); at least on my
14 > development system.
15 >
16 > I've update my website with this version also.
17 > http://www.bulah.com/embeddedgentoo.html
18 >
19 >
20 > #--------------------------------------------------------------------------------
21 > # Embedded Gentoo How-To for x86
22 > #
23 > # A how-to guide to setup a Gentoo embedded environment, you must be root.
24 > # These commands are to be run on your development system,
25 > # any x86 Gentoo Linux computer will do. The system should be fast,
26 > # to speed development. The target can be any x86 based SBC. I'm
27 > # using a Geode based SBC. Latter I'll use a Via based SBC.
28 > #
29 > # version 0.06
30 > # 2005.6.6
31 > #
32 > # Heath Holcomb (heath at bulah.com)
33 > # Ned Ludd (embedded Gentoo project lead, original commands posted)
34 > # Lloyd Sargent (contributor)
35 > # Yuri Vasilevshi (contributor)
36
37 It's Vasilevski :-)
38
39 > # Mike George (contributor)
40 > # Kammi Cazze (contributor)
41 > # Marius Schaefer (contributor)
42 > #
43 > # Definitions and Terms
44 > # system_rootfs = your regular rootfs
45 > # development_rootfs = what you use to build the embedded_rootfs
46 > # embedded_rootfs = rootfs you deploy to the target system
47 > # SBC = single board computer (here it's an x86 based)
48 > #
49 > # References
50 > # http://www.gentoo.org/doc/en/handbook/index.xml
51 > # http://www.epiawiki.org
52 > # http://epia.kalf.org
53 > # Gentoo embedded mailing list (gentoo-embedded@l.g.o)
54 > #
55 > #
56 > # Overview of process (steps)
57 > # 1 - Prepare the development_rootfs from your system_rootfs
58 > # 2 - Build the development_rootfs
59 > # 3 - Build the embedded_rootfs
60 > # 4 - Build and install non-system programs to the embedded_rootfs
61 > # 5 - Build and install a kernel to the embedded_rootfs
62 > # 6 - Deploy embedded_rootfs to target
63 > #
64 > #--------------------------------------------------------------------------------
65 >
66 > #----- Step 1 - Prepare the development_rootfs from your system_rootfs -------
67 >
68 > # You must be root.
69 > su -
70 >
71 > # Create the development_rootfs.
72 > # I use i586 because of target is a Geode processor.
73 > mkdir -p /opt/i586-gentoo-uclibc-linux/usr/portage
74 >
75 > # Download the latest stage 1 tarball.
76 > wget \
77 > http://gentoo.osuosl.org/experimental/x86/embedded/stages/stage1-x86-uclibc-2005.0.tar.bz2
78 >
79 > # Untar the stage to the development_rootfs.
80 > tar -xvjf stage1-x86-uclibc-2005.0.tar.bz2 -C /opt/i586-gentoo-uclibc-linux/
81
82 it should be tar -xvjpf ...
83 where -p stands for --preserve-permissions
84
85 >
86 > # Mount the proc and portage directories to your development_rootfs.
87 > # Makes your system_rootfs's proc and portage directory available from inside
88 > # of your development_rootfs (after chrooting).
89 > mount --bind /proc /opt/i586-gentoo-uclibc-linux/proc/
90 > mount --bind /usr/portage /opt/i586-gentoo-uclibc-linux/usr/portage
91 >
92 > # Copy over DNS information to the development_rootfs.
93 > cp /etc/resolv.conf /opt/i586-gentoo-uclibc-linux/etc/resolv.conf
94 >
95 > # Chroot into the development_rootfs.
96 > chroot /opt/i586-gentoo-uclibc-linux /bin/bash --login
97 >
98 >
99 > #----- Step 2 - Build the development_rootfs ---------------------------------
100 >
101 > # Create new environment and load variables into memory.
102 > env-update
103 > source /etc/profile
104 >
105 > # Modify make.conf file to your liking/needs.
106 > nano -w /etc/make.conf
107 > # This is for my target, Geode x86 processor.
108 > /*
109 > USE="bitmap-fonts minimal truetype-fonts uclibc mmx"
110
111 The uclibc USE flag was obsoleted, see:
112 http://www.mail-archive.com/gentoo-embedded@l.g.o/msg00140.html
113
114 > CHOST="i586-gentoo-linux-uclibc"
115 > CFLAGS="-march=i586 -Os -pipe -fomit-frame-pointer -mmmx"
116 > CXXFLAGS="${CFLAGS}"
117 > FEATURES="buildpkg"
118 >
119 > VIDEO_CARDS="chips"
120 > UCLIBC_CPU="586MMX"
121 > */
122 >
123 > # Set profile to use 2.6 kernel.
124 > # The current stage uses 2.4 by default, and for most cases you are going
125 > # to want a 2.6.x kernel.
126 > rm /etc/make.profile
127
128 This are equivalent but I would use:
129 unlink /etc/make.profile
130 for clarity's sake.
131
132 > ln -s /usr/portage/profiles/uclibc/x86 /etc/make.profile
133 >
134 > # Start the bootstrap script.
135 > cd /usr/portage/scripts
136 > ./bootstrap.sh -p -v
137 > ./bootstrap.sh
138 >
139 > # Workaround 1
140 > # Failure compiling uclibc (gcc-config error: Could not run/locate "gcc")?
141 > # If you get a failure while bootstrap is compileing uclibc here are the steps
142 > # to work around the problem.
143 > gcc-config 1
144 > source /etc/profile
145 > ./bootstrap.sh
146 >
147 > # Emerge the system ebuild for the development_rootfs.
148 > emerge -e system
149 >
150 > # Workaround 2
151 > # During emerge -e system, python-fchksum failes complaing about
152 > # gcc-config error: Could not run/locate "i386-gentoo-linux-uclibc-gcc"
153 > # The following commands work around this problem.
154 > emerge python
155 > emerge -e system
156 >
157 >
158 > #----- Step 3 - Build the embedded_rootfs ------------------------------------
159 >
160 > # Create the embedded_rootfs directory.
161 > mkdir /embedded_rootfs
162 >
163 > # Emerge baselayout-lite into embedded_rootfs.
164 > # This gives your system a basic file structure.
165 > # 1.0_pre1 is the only one that is stable, right?
166 > cd /usr/portage/sys-apps/baselayout-lite/
167 > ROOT=/embedded_rootfs emerge baselayout-lite-1.0_pre1.ebuild
168 >
169 > # Workaround 3
170 > # Baselayout-lite is still beta, so a few fixes are needed.
171 > # There needs to be a directory "log" in /var.
172 > # Inittab calls for /usr/bin/tail, but it needs to /usr/bin.
173 > mkdir /embedded_rootfs/var/log
174 > nano -w /embedded_rootfs/etc/inittab
175 > /*
176 > #tty3::respawn:/usr/bin/tail -f /var/log/messages
177 > tty3::respawn:/bin/tail -f /var/log/messages
178 > */
179 >
180 > # Emerge uclibc into the embedded_rootfs.
181 > # Use the -K option because we don't get the extra files created by the
182 > # build/emerge process into our embedded rootfs which needs to be as
183 > # small as possible.
184 > ROOT=/embedded_rootfs emerge -K uclibc
185 >
186 > # Emerge busybox into the embedded_rootfs.
187 > # First you must emerge it into your development_rootfs.
188 > # This does not create the symlinks in our development embedded rootfs.
189 > emerge busybox
190 > ROOT=/embedded_rootfs emerge -K busybox
191 >
192 > # Create the symlinks for busybox in the embedded_rootfs.
193
194 I have not used it, but form the ebuild it looks like
195 if you emerge busybox with make-symlinks in USE flags
196 it'll just make them for you. I think the proper way
197 may be (gain, this is just by looking at the ebuild):
198 VERY_BRAVE_OR_VERY_DUMB=yes USE=make-symlinks emerge -B busybox
199 (this will just make the package without installing it
200 to the system and consequently without braking it with
201 the symlinks)
202 ROOT=/embedded_rootfs emerge -K busybox
203 (at this point the busybox binary package should have
204 the symlinks in it)
205
206 > mkdir /embedded_rootfs/proc
207 > mount -o bind /proc/ /embedded_rootfs/proc/
208 > chroot /embedded_rootfs /bin/busybox --install -s
209 > umount /embedded_rootfs/proc
210 >
211 > # Set time zone in your embedded_rootfs.
212 > # See http://leaf.sourceforge.net/doc/guide/buci-tz.html for details.
213 > # For central standard time in the US, use "CST6CDT".
214 > nano -w /embedded_rootfs/etc/TZ
215 > /*
216 > CST6CDT
217 > */
218 >
219 > # Install a boot loader (usually grug or lilo).
220 > # Once you copy/deploy your embedded_rootfs program to you target SBC you will
221 > # have to run the grub on the command line to write to the master boot record
222 > # (MBR).
223 > # Ncurses is needed by grub, if you are not using gurb then you don't need
224 > # ncurses. For some reason not all of /boot/grub is copied over to the
225 > # embedded_rootfs, so a extra manual copy step is needed.
226 > ROOT=/embedded_rootfs emerge -K ncurses
227 > emerge grub
228 > ROOT=/embedded_rootfs emerge -K grub
229 > cp -R /boot/grub /embedded_rootfs/boot/
230
231 Why not installing grub with static USE flag?
232 I think ncurses is to expensive (big) to have if it is used
233 just by grub.
234 Another option will be to install install grub with:
235 ROOT=/embedded_rootfs emerge -K --nodeps grub
236 rm -f /embedded_rootfs/sbin/grub
237 As we can still use grub-install that doesn't need ncurses.
238
239 >
240 > # Modify your boot configure file.
241 > # The example below is for a gurb, for a boot partition on /dev/hda1 and only
242 > # one partition on the target SBC system.
243 > nano -w /embedded_rootfs/boot/grub/grub.conf
244 > /*
245 > default 0
246 > timeout 10
247 > splashimage=(hd0,0)/boot/grub/splash.xpm.gz
248 >
249 > title=Linux 2.6.x
250 > root (hd0,0)
251 > kernel /vmlinuz-2.6.x root=/dev/hda1 vga=792
252 > */
253 >
254 > # Set root password
255 > ROOT=/embedded_rootfs passwd
256 >
257 > # Modify fstab.
258 > # Below is mine, yours may vary.
259 > nano -w /embedded_rootfs/etc/fstab
260 > /*
261 > /dev/hda1 / reiserfs defaults 0 0
262 > none /proc proc defaults 0 0
263 > none /sys sysfs defaults 0 0
264 > none /dev/shm tmpfs defaults 0 0
265 > */
266 >
267 > #---- Step 4 - Build and install non-system programs to the embedded_rootfs --
268 >
269 > # Emerge other software you need for you embedded target.
270 > # This is very wildly depending on your needs.
271 > # Also your proprietary application will be done here.
272 > emerge foobar*
273 > ROOT=/embedded_rootfs emerge -K foobar*
274 >
275 >
276 > #---- Step 5 - Build and install a kernel to the embedded_rootfs -------------
277 >
278 > # Install a kernel into embedded_rootfs.
279 > # First we will emerge it into our development_rootfs, then configure and
280 > # build it.
281 > emerge vanilla-sources
282 > cd /usr/src/
283 > cd linux
284 > make menuconfig
285 > # configure your kernel for your TARGET SBC here
286 > make
287 > ROOT=/embedded_rootfs make modules_install
288 > cp /usr/src/linux/arch/i386/boot/bzImage /embedded_rootfs/boot/vmlinuz-2.6.x
289 >
290 > # A few notes on compiling your kernel.
291 > # If deploying to Compact Flash/DiskOnChip/SD us ext2, as the journaling
292 > # filing systems "write" to much for a flash device.
293 > # If deploying to a hard drive use a journaling filing system, such as
294 > # ext3 or reiserfs.
295 >
296 >
297 > #---- Step 6 - Deploy embedded_rootfs to target ------------------------------
298 >
299 > # Prepare a Gentoo (or any Linux distro) system on the target SBC using a
300 > # harddrive. This is known as the target development rootfs.
301 > # We will create a partition (/embedded_rootfs) that will server as our
302 > # "test" partition to deploy our embedded_rootfs that we generate on our
303 > # development_system.
304 > #
305 > # I use the following partitions to speed development (yours may vary):
306 > # /dev/hda1 - /embedded_rootfs - 1 GB
307 > # /dev/hda2 - /boot - 100 MB
308 > # /dev/hda3 - swap - (size varies, 512 MB is a good number)
309 > # /dev/hda4 - / - (what is left, at least 1.5 GB per 2005.0 install guide
310 > specs)
311 > #
312 > # Copy over your embedded_rootfs from you development system to your target
313 > # system and the directory /embedded_rootfs. This needs to be done via NFS as
314 > # need to preserve the permissions.
315 > #
316 > #The following commands are done from the
317 > # target development rootfs.
318 > mount -t reiserfs /dev/hda1 /mnt/embedded_rootfs
319 > mount -t nfs
320 > 192.168.0.10:/opt/i586-gentoo-uclibc-linux/embedded_rootfs /mnt/transfer
321 > cp -adpR /mnt/transfer/* /mnt/embedded_rootfs
322 >
323 >
324 > # Modify your target system's gurb.conf (or lilo.conf) for allow you to boot
325 > # to the embedded_rootfs partition.
326 > #
327 > # Reboot, and if all goes well you'll be greeted with a login prompt.
328 > #
329 > # Fin.
330
331 Yuri.
332 --
333 gentoo-embedded@g.o mailing list

Replies