diff options
author | Scott Rifenbark <scott.m.rifenbark@intel.com> | 2013-03-19 14:41:41 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-03-22 17:08:42 +0000 |
commit | 70583639c462fb4d303cf392927498daacc904f7 (patch) | |
tree | 146f1dd3c422413f26360658c1b50b916dccf484 /documentation/dev-manual | |
parent | ac15c28151a89b2dc60b037e8e99214349952c8b (diff) | |
download | poky-70583639c462fb4d303cf392927498daacc904f7.tar.gz |
dev-manual: second pass of poky-tiny section.
(From yocto-docs rev: 44be6fdc992809846fcaade8986c1a1323c14f0c)
Signed-off-by: Scott Rifenbark <scott.m.rifenbark@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'documentation/dev-manual')
-rw-r--r-- | documentation/dev-manual/dev-manual-common-tasks.xml | 243 |
1 files changed, 209 insertions, 34 deletions
diff --git a/documentation/dev-manual/dev-manual-common-tasks.xml b/documentation/dev-manual/dev-manual-common-tasks.xml index 39da63436f..a6aa8fafbe 100644 --- a/documentation/dev-manual/dev-manual-common-tasks.xml +++ b/documentation/dev-manual/dev-manual-common-tasks.xml | |||
@@ -2086,7 +2086,7 @@ | |||
2086 | You can include nearly any variable from the | 2086 | You can include nearly any variable from the |
2087 | <filename>local.conf</filename> file. | 2087 | <filename>local.conf</filename> file. |
2088 | The variables you use are not limited to the list in the | 2088 | The variables you use are not limited to the list in the |
2089 | previous bulletted item.</para></listitem> | 2089 | previous bulleted item.</para></listitem> |
2090 | <listitem><para><emphasis>Point to Your Distribution Configuration File:</emphasis> | 2090 | <listitem><para><emphasis>Point to Your Distribution Configuration File:</emphasis> |
2091 | In your <filename>local.conf</filename> file in the | 2091 | In your <filename>local.conf</filename> file in the |
2092 | <link linkend='build-directory'>Build Directory</link>, | 2092 | <link linkend='build-directory'>Build Directory</link>, |
@@ -2130,22 +2130,14 @@ | |||
2130 | <section id='building-a-tiny-system'> | 2130 | <section id='building-a-tiny-system'> |
2131 | <title>Building a Tiny System</title> | 2131 | <title>Building a Tiny System</title> |
2132 | 2132 | ||
2133 | <literallayout class='monospaced'> | ||
2134 | * Introduction that tells what, why, and benefits | ||
2135 | * Overview of the process | ||
2136 | * Cutting back on the kernel size | ||
2137 | * Cutting back on the filesystem (libc and busybox) | ||
2138 | </literallayout> | ||
2139 | |||
2140 | <para> | 2133 | <para> |
2141 | Very small distributions have some significant advantages such | 2134 | Very small distributions have some significant advantages such |
2142 | requiring less on-die memory (cheaper), better performance through | 2135 | as requiring less on-die memory (cheaper), better performance |
2143 | efficient cache usage, lower power requirements due to less | 2136 | through efficient cache usage, lower power requirements due to less |
2144 | memory, faster boot times, and reduced development overhead. | 2137 | memory, faster boot times, and reduced development overhead. |
2145 | Some real-world examples where a very small distribution gives | 2138 | Some real-world examples where a very small distribution gives |
2146 | you distinct advantages are digital cameras, medical devices, | 2139 | you distinct advantages are digital cameras, medical devices, |
2147 | small headless systems, and partitioned flash. | 2140 | small headless systems, and partitioned flash. |
2148 | You can use the Yocto Project to create very small distribution. | ||
2149 | </para> | 2141 | </para> |
2150 | 2142 | ||
2151 | <para> | 2143 | <para> |
@@ -2167,11 +2159,13 @@ | |||
2167 | <itemizedlist> | 2159 | <itemizedlist> |
2168 | <listitem><para>Determine your goals and guiding | 2160 | <listitem><para>Determine your goals and guiding |
2169 | principles.</para></listitem> | 2161 | principles.</para></listitem> |
2170 | <listitem><para>Know what you are starting with. | 2162 | <listitem><para>Understand what gives your image size. |
2171 | </para></listitem> | 2163 | </para></listitem> |
2172 | <listitem><para>Trim the root filesystem. | 2164 | <listitem><para>Reduce the size of the root filesystem. |
2173 | </para></listitem> | 2165 | </para></listitem> |
2174 | <listitem><para>Trim the kernel</para></listitem> | 2166 | <listitem><para>Reduce the size of the kernel. |
2167 | </para></listitem> | ||
2168 | <listitem><para>Iterate on the process.</para></listitem> | ||
2175 | </itemizedlist> | 2169 | </itemizedlist> |
2176 | </para> | 2170 | </para> |
2177 | </section> | 2171 | </section> |
@@ -2190,15 +2184,15 @@ | |||
2190 | a root filesystem that is 3 Mbytes or less). | 2184 | a root filesystem that is 3 Mbytes or less). |
2191 | </para></listitem> | 2185 | </para></listitem> |
2192 | <listitem><para>Find the areas that are currently | 2186 | <listitem><para>Find the areas that are currently |
2193 | taking 90% of the space and concentrate on that | 2187 | taking 90% of the space and concentrate on reducing |
2194 | for trimming. | 2188 | those areas. |
2195 | </para></listitem> | 2189 | </para></listitem> |
2196 | <listitem><para>Do not create any difficult "hacks" | 2190 | <listitem><para>Do not create any difficult "hacks" |
2197 | to achieve your goals.</para></listitem> | 2191 | to achieve your goals.</para></listitem> |
2198 | <listitem><para>Leverage of the device-specific | 2192 | <listitem><para>Leverage off the device-specific |
2199 | options.</para></listitem> | 2193 | options.</para></listitem> |
2200 | <listitem><para>Do your work in a separate layer | 2194 | <listitem><para>Work in a separate layer so that you |
2201 | to keep changes isolated. | 2195 | keep changes isolated. |
2202 | For information on how to create layers, see | 2196 | For information on how to create layers, see |
2203 | the "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>" section. | 2197 | the "<link linkend='understanding-and-creating-layers'>Understanding and Creating Layers</link>" section. |
2204 | </para></listitem> | 2198 | </para></listitem> |
@@ -2206,8 +2200,8 @@ | |||
2206 | </para> | 2200 | </para> |
2207 | </section> | 2201 | </section> |
2208 | 2202 | ||
2209 | <section id='know-what-you-are-starting-with'> | 2203 | <section id='understand-what-gives-your-image-size'> |
2210 | <title>Know What You Are Starting With</title> | 2204 | <title>Understand What Gives Your Image Size</title> |
2211 | 2205 | ||
2212 | <para> | 2206 | <para> |
2213 | You will need to have an image from which you can | 2207 | You will need to have an image from which you can |
@@ -2218,27 +2212,30 @@ | |||
2218 | that works with two shipped Board Support Packages (BSPs): | 2212 | that works with two shipped Board Support Packages (BSPs): |
2219 | Fish River Island 2 and QEMU. | 2213 | Fish River Island 2 and QEMU. |
2220 | You can use this distribution as a starting point and trim | 2214 | You can use this distribution as a starting point and trim |
2221 | down from there. | 2215 | the size down from there. |
2222 | If you need to build out the <filename>poky-tiny</filename> | 2216 | If you need to build out the <filename>poky-tiny</filename> |
2223 | distribution, see the | 2217 | distribution, see the |
2224 | "<link linkend='creating-your-own-distribution'>Creating Your Own Distribution</link>" | 2218 | "<link linkend='creating-your-own-distribution'>Creating Your Own Distribution</link>" |
2225 | section. | 2219 | section for information. |
2226 | </para> | 2220 | </para> |
2227 | 2221 | ||
2228 | <para> | 2222 | <para> |
2229 | Understanding some memory concepts will help you reduce the | 2223 | Understanding some memory concepts will help you reduce the |
2230 | system size. | 2224 | system size. |
2231 | Memory consists of static, dynamic, and temporary memory. | 2225 | Memory consists of static, dynamic, and temporary memory. |
2232 | Static memory is the TEXT, DATA, and BSS sections. | 2226 | Static memory is the TEXT (the code), DATA (initialized data |
2227 | in the code), and BSS (uninitialized data) sections. | ||
2233 | Dynamic memory contains memory that is allocate at runtime, | 2228 | Dynamic memory contains memory that is allocate at runtime, |
2234 | stacks, hashtables, and so forth. | 2229 | stacks, hash tables, and so forth. |
2235 | Temporary memory is decompression and | 2230 | Temporary memory is decompressed from the expanded kernel |
2236 | <filename>__init__</filename> | 2231 | after boot. |
2232 | Temporary memory also includes the <filename>__init__</filename> | ||
2233 | functions. | ||
2237 | </para> | 2234 | </para> |
2238 | 2235 | ||
2239 | <para> | 2236 | <para> |
2240 | To help you see where you currently are with kernel and root | 2237 | To help you see where you currently are with kernel and root |
2241 | filesystem sizes, you can use some tools found in the | 2238 | filesystem sizes, you can use two tools found in the |
2242 | <link linkend='source-directory'>Source Directory</link> in | 2239 | <link linkend='source-directory'>Source Directory</link> in |
2243 | the <filename>scripts</filename> directory: | 2240 | the <filename>scripts</filename> directory: |
2244 | <itemizedlist> | 2241 | <itemizedlist> |
@@ -2247,17 +2244,29 @@ | |||
2247 | <listitem><para><filename>dirsize.py</filename>: Reports | 2244 | <listitem><para><filename>dirsize.py</filename>: Reports |
2248 | the size of the root filesystem.</para></listitem> | 2245 | the size of the root filesystem.</para></listitem> |
2249 | </itemizedlist> | 2246 | </itemizedlist> |
2250 | This next tool and command helps you organized configuration | 2247 | This next tool and command helps you organize configuration |
2251 | fragments and view file dependencies in a human-readable form: | 2248 | fragments and view file dependencies in a human-readable form: |
2252 | <itemizedlist> | 2249 | <itemizedlist> |
2253 | <listitem><para><filename>merge_config.sh</filename>: | 2250 | <listitem><para><filename>merge_config.sh</filename>: |
2254 | Merges individual configuration fragments. | 2251 | Helps you manage configuration files and fragments |
2255 | For more information on configuration fragments, see | 2252 | within the kernel. |
2256 | the | 2253 | With this tool you can merge individual configuration |
2254 | fragments together. | ||
2255 | The tool allows you to make overrides and warns you | ||
2256 | of any missing configuration options. | ||
2257 | The tool is ideal for allowing you to iterate on | ||
2258 | configurations, create minimal configurations, and | ||
2259 | create a configuration files for different machines | ||
2260 | without having to duplicate your process.</para> | ||
2261 | <para>The <filename>merge_config.sh</filename> script is | ||
2262 | part of the Linux Yocto kernel Git repository in the | ||
2263 | <filename>scripts/kconfig</filename> directory.</para> | ||
2264 | <para>For more information on configuration fragments, | ||
2265 | see the | ||
2257 | "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#generating-configuration-files'>Generating Configuration Files</ulink>" | 2266 | "<ulink url='&YOCTO_DOCS_KERNEL_DEV_URL;#generating-configuration-files'>Generating Configuration Files</ulink>" |
2258 | section of the Yocto Project Linux Kernel Development | 2267 | section of the Yocto Project Linux Kernel Development |
2259 | Manual and the "<link linkend='creating-config-fragments'>Creating Configuration Fragments</link>" | 2268 | Manual and the "<link linkend='creating-config-fragments'>Creating Configuration Fragments</link>" |
2260 | section in this manual.</para></listitem> | 2269 | section, which is in this manual.</para></listitem> |
2261 | <listitem><para><filename>bitbake -u depexp -g core-image-*</filename>: | 2270 | <listitem><para><filename>bitbake -u depexp -g core-image-*</filename>: |
2262 | Using the BitBake command with these options brings up | 2271 | Using the BitBake command with these options brings up |
2263 | a Dependency Explorer from which you can view file | 2272 | a Dependency Explorer from which you can view file |
@@ -2272,6 +2281,172 @@ | |||
2272 | <section id='trim-the-root-filesystem'> | 2281 | <section id='trim-the-root-filesystem'> |
2273 | <title>Trim the Root Filesystem</title> | 2282 | <title>Trim the Root Filesystem</title> |
2274 | 2283 | ||
2284 | <para> | ||
2285 | Root filesystem is made up of packages for booting, libraries, | ||
2286 | and applications. | ||
2287 | To change things you can configure how the packaging happens, | ||
2288 | which changes the way you build them. | ||
2289 | You can also tweak the filesystem itself or select a different | ||
2290 | file system. | ||
2291 | </para> | ||
2292 | |||
2293 | <para> | ||
2294 | First, check out what is hogging your file system running the | ||
2295 | <filename>dirsize.sh</filename> script from your root directory: | ||
2296 | <literallayout class='monospaced'> | ||
2297 | $ cd <root-directory-of-image> | ||
2298 | $ dirsize.py 100000 > dirsize-100k.log | ||
2299 | $ cat dirsize-100k.log | ||
2300 | </literallayout> | ||
2301 | You can apply a filter to the script to ignore files under | ||
2302 | a certain size. | ||
2303 | This example filters out anything below 100 Kbytes. | ||
2304 | When you examine your log file, you can focus on areas of the | ||
2305 | root filesystem that take up large amounts of memory. | ||
2306 | </para> | ||
2307 | |||
2308 | <para> | ||
2309 | You need to be sure that what you eliminate does not cripple | ||
2310 | the functionality you need. | ||
2311 | One way to see how packages relate to each other is by using | ||
2312 | the Dependency Explorer UI with the BitBake command: | ||
2313 | <literallayout class='monospaced'> | ||
2314 | $ cd <image-directory> | ||
2315 | $ bitbake -u depexp -g <image> | ||
2316 | </literallayout> | ||
2317 | Use the interface to select potential packages you wish to | ||
2318 | eliminate and see their dependency relationships. | ||
2319 | </para> | ||
2320 | |||
2321 | <para> | ||
2322 | When deciding how to reduce the size, get rid of packages that | ||
2323 | result in minimal impact on the feature set. | ||
2324 | For example, you might not need a VGA display. | ||
2325 | Or, you might be able to get by with <filename>devtmpfs</filename> | ||
2326 | and <filename>mdev</filename>. | ||
2327 | </para> | ||
2328 | |||
2329 | <para> | ||
2330 | Use the <filename>local.conf</filename> file to make changes. | ||
2331 | For example, to eliminate <filename>udev</filename> and | ||
2332 | <filename>glib</filename>, set the following in the | ||
2333 | local configuration file: | ||
2334 | <literallayout class='monospaced'> | ||
2335 | VIRTUAL-RUNTIME_dev_manager = "" | ||
2336 | </literallayout> | ||
2337 | </para> | ||
2338 | |||
2339 | <para> | ||
2340 | Some other examples of where you can look to eliminate size | ||
2341 | from the root filesystem are using <filename>ext2</filename> | ||
2342 | rather than <filename>ext3</filename>, which requires a | ||
2343 | 1 Mbyte journal. | ||
2344 | If you are okay with running read-only you don't need this | ||
2345 | journal. | ||
2346 | </para> | ||
2347 | |||
2348 | <note> | ||
2349 | After each round of elimination, you need to rebuild your | ||
2350 | system and then use the tools to see the effects of your | ||
2351 | reductions. | ||
2352 | </note> | ||
2353 | |||
2354 | |||
2355 | </section> | ||
2356 | |||
2357 | <section id='trim-the-kernel'> | ||
2358 | <title>Trim the Kernel</title> | ||
2359 | |||
2360 | <para> | ||
2361 | Kernel is built by including policies for hardware-independent | ||
2362 | aspects. | ||
2363 | What subsystems do you enable? | ||
2364 | What architecture are you building for? | ||
2365 | Which drivers do you build by default. | ||
2366 | <note>You can modify the kernel source if you want to help | ||
2367 | with boot time. | ||
2368 | </note> | ||
2369 | </para> | ||
2370 | |||
2371 | <para> | ||
2372 | Run the <filename>ksize.py</filename> script from the top-level | ||
2373 | Linux build directory to get an idea of what is making up | ||
2374 | the kernel: | ||
2375 | <literallayout class='monospaced'> | ||
2376 | $ cd <top-level-linux-build-directory> | ||
2377 | $ ksize.py > ksize.log | ||
2378 | $ cat ksize.log | ||
2379 | </literallayout> | ||
2380 | When you examine the log, you will see how much space is | ||
2381 | taken up with the built-in <filename>.o</filename> files for | ||
2382 | drivers, networking, core kernel files, filesystem, sound, | ||
2383 | and so forth. | ||
2384 | Look to reduce the areas that are large and taking up around | ||
2385 | the "90% rule". | ||
2386 | </para> | ||
2387 | |||
2388 | <para> | ||
2389 | To examine, or drill down, into any particular area, use the | ||
2390 | <filename>-d</filename> option with the script: | ||
2391 | <literallayout class='monospaced'> | ||
2392 | $ ksize.py -d > ksize.log | ||
2393 | </literallayout> | ||
2394 | Using this option breaks out the individual file information | ||
2395 | for each area of the kernel (e.g. drivers, networking, and | ||
2396 | so forth). | ||
2397 | </para> | ||
2398 | |||
2399 | <para> | ||
2400 | Use your log file to see what you can eliminate from the kernel | ||
2401 | based on features you can let go. | ||
2402 | For example, if you are not going to need sound, you do not | ||
2403 | need any drivers that support sound. | ||
2404 | </para> | ||
2405 | |||
2406 | <para> | ||
2407 | After figuring out what to eliminate, you need to reconfigure | ||
2408 | kernel to reflect those changes during the next build. | ||
2409 | You could run <filename>menuconfig</filename> and make all your | ||
2410 | changes at once. | ||
2411 | However, that makes it difficult to see the effects of your | ||
2412 | individual eliminations and also makes it difficult to replicate | ||
2413 | the changes for perhaps another target device. | ||
2414 | A better method is to start with no configurations using | ||
2415 | <filename>allnoconfig</filename>, create configuration | ||
2416 | fragments for individual changes, and then manage the | ||
2417 | fragments into a single configuration file using | ||
2418 | <filename>merge_config.sh</filename>. | ||
2419 | The tool makes it easy for you to iterate using the | ||
2420 | configuration change/build cycle. | ||
2421 | </para> | ||
2422 | |||
2423 | <para> | ||
2424 | Each time you make configuration changes, you need to rebuild | ||
2425 | the kernel and check to see what impact your changes had on | ||
2426 | the overall size. | ||
2427 | </para> | ||
2428 | </section> | ||
2429 | |||
2430 | <section id='iterate-on-the-process'> | ||
2431 | <title>Iterate on the Process</title> | ||
2432 | |||
2433 | <para> | ||
2434 | If you have not reached your goals on system size, you need | ||
2435 | to iterate on the process. | ||
2436 | The process is the same. | ||
2437 | Use the tools and see just what is taking up 90% of the root | ||
2438 | filesystem and the kernel. | ||
2439 | Decide what you can eliminate without limiting your device | ||
2440 | beyond what you need. | ||
2441 | </para> | ||
2442 | |||
2443 | <para> | ||
2444 | Depending on your system, a good place to look might be | ||
2445 | Busybox, which provides a stripped down | ||
2446 | version of Unix tools in a single, executable file. | ||
2447 | You might be able to drop virtual terminal services or perhaps | ||
2448 | ipv6. | ||
2449 | </para> | ||
2275 | </section> | 2450 | </section> |
2276 | </section> | 2451 | </section> |
2277 | 2452 | ||
@@ -3005,7 +3180,7 @@ | |||
3005 | </literallayout> | 3180 | </literallayout> |
3006 | Once the binary is built, you can find it here: | 3181 | Once the binary is built, you can find it here: |
3007 | <literallayout class='monospaced'> | 3182 | <literallayout class='monospaced'> |
3008 | tmp/sysroots/<host-arch>/usr/bin/<target-abi>-gdb | 3183 | tmp/sysroots/<host-arch>/usr/bin/<target-platform>/<target-abi>-gdb |
3009 | </literallayout> | 3184 | </literallayout> |
3010 | </para> | 3185 | </para> |
3011 | </section> | 3186 | </section> |