Gentoo Archives: gentoo-embedded

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