Gentoo Archives: gentoo-embedded

From: Heath H Holcomb <heath@×××××.com>
To: gentoo-embedded@l.g.o
Subject: [gentoo-embedded] x86 SBC Gentoo Embedded HowTo version 0.05 (unfinished)
Date: Mon, 30 May 2005 03:42:10
Message-Id: 200505292242.27858.heath@bulah.com
1 Version 0.05
2 Please add, delete, modify. Thanks!
3
4 I've update my website with this version also.
5 http://www.bulah.com/embeddedgentoo.html
6
7 #--------------------------------------------------------------------------------------------------
8 # Embedded Gentoo How-To for x86
9 #
10 # Commands to setup a Gentoo embedded environment, you must be root.
11 # These commands are to be run on your development system,
12 # any x86 Gentoo Linux computer will do. The system should be fast,
13 # to speed development. The target can be any x86 based SBC. I'm
14 # using a Geode based SBC. Latter I'll use a Via based SBC.
15 #
16 # version 0.05
17 # 2005.29.5
18 #
19 # Heath Holcomb (heath at bulah.com)
20 # Ned Ludd (embedded Gentoo project lead, original commands posted)
21 # Lloyd Sargent (contributor)
22 # Yuri Vasilevshi (contributor)
23 # Mike George (contributor)
24 # Kammi Cazze (contributor)
25 # Marius Schaefer (contributor)
26 #
27 # Definitions and Terms
28 # system_rootfs = your regular rootfs
29 # development_rootfs = what you use to build the embedded_rootfs
30 # embedded_rootfs = rootfs you deploy to the target system
31 # SBC = single board computer (here it's an x86 based)
32 #
33 # References
34 # http://www.gentoo.org/doc/en/handbook/index.xml
35 # http://www.epiawiki.org
36 # http://epia.kalf.org
37 # Gentoo embedded mailing list (gentoo-embedded@l.g.o)
38 #
39 #
40 # Overview of process (steps)
41 # 1 - Prepare the development_rootfs from your system_rootfs
42 # 2 - Build the development_rootfs
43 # 3 - Build the embedded_rootfs
44 # 4 - Build and install non-system programs to the embedded_rootfs
45 # 5 - Build and install a kernel to the embedded_rootfs
46 # 6 - Deploy embedded_rootfs to target
47 #--------------------------------------------------------------------------------------------------
48
49 #---------- Step 1 - Prepare the development_rootfs from your system_rootfs
50 ----------
51
52 # You must be root.
53 su
54
55 # Create the development_rootfs.
56 # I use i586 because of target is a Geode processor.
57 mkdir -p /opt/i586-gentoo-uclibc-linux/usr/portage
58
59 # Download the latest stage 1 tarball.
60 wget \
61 http://gentoo.osuosl.org/experimental/x86/embedded/stages/stage1-x86-uclibc-2005.0.tar.bz2
62
63 # Untar the stage to the development_rootfs.
64 tar -xvjf stage1-x86-uclibc-2005.0.tar.bz2 -C /opt/i586-gentoo-uclibc-linux/
65
66 # Mount the proc and portage directories to your development_rootfs.
67 # Makes your system_rootfs's proc and portage directory available from inside
68 # of your development_rootfs (after chrooting).
69 mount --bind /proc /opt/i586-gentoo-uclibc-linux/proc/
70 mount --bind /usr/portage /opt/i586-gentoo-uclibc-linux/usr/portage
71
72 # Copy over DNS information to the development_rootfs.
73 cp /etc/resolv.conf /opt/i586-gentoo-uclibc-linux/etc/resolv.conf
74
75 # Chroot into the development_rootfs.
76 chroot /opt/i586-gentoo-uclibc-linux /bin/bash --login
77
78
79 #---------- Step 2 - Build the development_rootfs
80 -------------------------------------------
81
82 # Create new environment and load variables into memory.
83 env-update
84 source /etc/profile
85
86 # Modify make.conf file to your liking/needs.
87 nano -w /etc/make.conf
88 # this is for my target, Geode x86 processor
89 USE="uclibc"
90 CHOST="i586-gentoo-linux-uclibc"
91 CFLAGS="-march=i586 -Os -pipe -fomit-frame-pointer -mmmx"
92 CXXFLAGS="${CFLAGS}"
93 FEATURES="buildpkg"
94
95 # Start the bootstrip script.
96 cd /usr/portage/scripts
97 ./bootstrap.sh -p -v
98 ./bootstrap.sh
99
100 # Emerge the system ebuild for the development_rootfs.
101 emerge -e system
102
103
104 #---------- Step 3 - Build the embedded_rootfs
105 --------------------------------------------
106
107 # Create the embedded_rootfs directory.
108 mkdir /embedded_rootfs
109
110 # Emerge baselayout-lite into embedded_rootfs.
111 # This gives your system a basic file structure.
112 # 1.0_pre1 is the only one that is stable, right?
113 cd /usr/portage/sys-apps/baselayout-lite/
114 ROOT=/embedded_rootfs emerge baselayout-lite-1.0_pre1.ebuild
115
116 # Emerge uclibc into the embedded_rootfs.
117 # Use the -K option because we don't get the extra files created by the
118 build/emerge
119 # process into our embedded rootfs which needs to be as small as possible.
120 ROOT=/embedded_rootfs emerge -K uclibc
121
122 # Emerge busybox into the embedded_rootfs.
123 # First you must emerge it into your development_rootfs.
124 # This does not create the symlinks in our development embedded rootfs.
125 emerge busybox
126 ROOT=/embedded_rootfs emerge -K busybox
127
128 # Create the symlinks for busybox in the embedded_rootfs.
129 mkdir /embedded_rootfs/proc
130 mount -o bind /proc/ /embedded_rootfs/proc/
131 chroot /embedded_rootfs /bin/busybox --install -s
132 umount /embedded_rootfs/proc
133
134 # Set time zone in your embedded_rootfs.
135 # See http://leaf.sourceforge.net/doc/guide/buci-tz.html for details.
136 # For central standard time in the US, use "CST6CDT".
137 nano -w /embedded_rootfs/etc/TZ
138 /*
139 CST6CDT
140 */
141
142 # Install a boot loader (usually grug or lilo).
143 # Once you copy/deploy your embedded_rootfs program to you target SBC you will
144 # have to run the grub on the command line to write to the master boot record
145 (MBR).
146 # Ncurses is needed by grug, it not useing gurb then you don't need ncurses.
147 # For some reason not all of /boot/grub is copied over to the embedded_rootfs,
148 so
149 # a extra manual copy step is needed.
150 ROOT=/embedded_rootfs emerge -K ncurses
151 emerge grub
152 ROOT=/embedded_rootfs emerge -K grub
153 cp -R /boot/grub /embedded_rootfs/boot/
154
155 # Modify your boot configure file.
156 # The example below is for a gurb, for a boot partition on /dev/hda1 and only
157 one
158 # partition on the target SBC system.
159 nano -w /embedded_rootfs/boot/grub/grub.conf
160 /*
161 default 0
162 timeout 10
163 splashimage=(hd0,0)/boot/grub/splash.xpm.gz
164
165 title=Linux 2.6.x
166 root (hd0,0)
167 kernel /vmlinuz-2.6.x root=/dev/hda1 vga=792
168 */
169
170
171 #---------- Step 4 - Build and install non-system programs to the
172 embedded_rootfs ----
173
174 # Emerge other software you need for you embedded target.
175 # This is very wildly depending on your needs.
176 # Also your proprietary application will be done here.
177 emerge foobar*
178 ROOT=/embedded_rootfs emerge -K foobar*
179
180
181 #---------- Step 5 - Build and install a kernel to the embedded_rootfs
182 --------------------
183
184 # Install a kernel into embedded_rootfs.
185 # First we will emerge it into our development_rootfs, then configure and
186 build it.
187 emerge vanilla-sources
188 cd /usr/src/
189 cd linux
190 make menuconfig
191 # configure your kernel for your TARGET SBC here
192 make
193 ROOT=/embedded_rootfs make modules_install
194 cp /usr/src/linux/arch/i386/boot/bzImage /embedded_rootfs/boot/vmlinuz-2.6.x
195
196
197 #---------- Step 6 - Deploy embedded_rootfs to target
198 -------------------------------------
199
200 # Prepare a Gentoo (or any Linux distro) system on the target SBC using a
201 harddrive.
202 # We will create a partition (/embedded_rootfs) that will server as our "test"
203 partition
204 # to deploy our embedded_rootfs that we generate on our development_system.
205 #
206 # Use the following partitions to speed development (yours may vary):
207 # /dev/hda1 - /embedded_rootfs - 1 GB
208 # /dev/hda2 - /boot - 100 MB
209 # /dev/hda3 - swap - (size varies, 512 MB is a good number)
210 # /dev/hda4 - / - (what ever is left, at least 1.5 GB per 2005.0 install guide
211 specs)
212 #
213 # Copy over your embedded_rootfs from you development system to your target
214 # system and the directory /embedded_rootfs. Usually this can be done via a
215 NFS
216 # or SMB share.
217 #
218 # Modify your target system's gurb.conf (or lilo.conf) for allow you to boot
219 to the
220 # /embedded_rootfs partition.
221 #
222 # Reboot, and if all goes well you'll be greeted with a login prompt.
223 #
224 # Fin.
225
226
227
228 --
229 Heath Holcomb
230 heath at bulah.com
231 www.bulah.com
232 --
233 gentoo-embedded@g.o mailing list

Replies