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