Gentoo Archives: gentoo-embedded

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

Replies

Subject Author
Re: [gentoo-embedded] x86 SBC Gentoo Embedded HotTo version 0.07 Joshua ChaitinPollak <jpollak@×××××××××××.com>
RE: [gentoo-embedded] x86 SBC Gentoo Embedded HotTo version 0.07 Pierre Cassimans <kammicazze@×××××××.com>