📄 loading_a_compressed_kernel_image.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head> <title></title> <link rel="stylesheet" media="screen" type="text/css" href="./style.css" /> <link rel="stylesheet" media="screen" type="text/css" href="./design.css" /> <link rel="stylesheet" media="print" type="text/css" href="./print.css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><a href=start.html>start</a></br><div class="toc"><div class="tocheader toctoggle" id="toc__header">Table of Contents</div><div id="toc__inside"><ul class="toc"><li class="clear"><ul class="toc"><li class="level2"><div class="li"><span class="li"><a href="#loading_a_compressed_kernel_image" class="toc">Loading a Compressed Kernel Image</a></span></div></li><li class="level2"><div class="li"><span class="li"><a href="#testing_the_compressed_kernel_image" class="toc">Testing the Compressed Kernel Image</a></span></div></li><li class="level2"><div class="li"><span class="li"><a href="#saving_the_compressed_kernel_image_in_flash" class="toc">Saving the Compressed Kernel Image in Flash</a></span></div><ul class="toc"><li class="level3"><div class="li"><span class="li"><a href="#creating_compressed_kernel_image_by_hand" class="toc">Creating Compressed Kernel Image by Hand</a></span></div></li></ul></li></ul></li></ul></div></div><h2><a name="loading_a_compressed_kernel_image" id="loading_a_compressed_kernel_image">Loading a Compressed Kernel Image</a></h2><div class="level2"><p>U鈥態oot is capable of loading a kernel image that was compressed with <em><strong>gzip</strong></em>. This feature makes for faster transfers of the kernel image to the target system, especially useful when using slower transfer methods such as a serial connection. Before proceeding with the instructions in this section you should be familiar with the different methods used to to transfer a uClinux memory image to the target (i.e. TFTP, DHCP, and Serial). See <a href="setting_up_a_tftp_server.html" class="wikilink1" title="setting_up_a_tftp_server.html">Setting up a TFTP Server</a>, <a href="setting_up_a_dhcp_server.html" class="wikilink1" title="setting_up_a_dhcp_server.html">Setting up a DHCP Server</a>, and <a href="loading_dxes_via_the_serial_port.html" class="wikilink1" title="loading_dxes_via_the_serial_port.html">Loading Files via the Serial Port</a> for more information.</p><p><code>linux</code><a href="compiling_the_kernel.html" class="wikilink1" title="compiling_the_kernel.html">compiling the kernel</a></p></div><!-- SECTION [1-875] --><h2><a name="testing_the_compressed_kernel_image" id="testing_the_compressed_kernel_image">Testing the Compressed Kernel Image</a></h2><div class="level2"><p> When making the kernel, a compressed file will have been made for you, and is at <code>./uClinux-dist/images/uImage</code>. After copying things to your tftp server, the following U鈥態oot command may be used to transfer the <code>uImage</code> file to the target via TFTP, though any transfer command (i.e. <strong>tftp</strong>, <strong>dhcp</strong>, or <strong>loadb</strong>) may be used:</p><pre class="code">BOOT> tftp 0x1000000 uImage</pre><p> or </p><pre class="code">BOOT> loadb 0x1000000</pre><p>After the compressed file has been downloaded to the target, information on the memory image can be viewed by entering the following command:</p><pre class="code">BOOT> iminfo 0x1000000</pre><p>Finally to decompress and load the memory image enter the following command:</p><pre class="code">BOOT> bootm 0x1000000</pre></div><!-- SECTION [876-1639] --><h2><a name="saving_the_compressed_kernel_image_in_flash" id="saving_the_compressed_kernel_image_in_flash">Saving the Compressed Kernel Image in Flash</a></h2><div class="level2"><p> The following U鈥態oot command may be used to transfer the <code>uImage</code> file to the target via TFTP, though any transfer command (i.e. <strong>tftp</strong>, <strong>dhcp</strong>, or <strong>loadb</strong>) may be used:</p><pre class="code">BOOT> tftp 0x1000000 uImage</pre><p> or </p><pre class="code">BOOT> loadb 0x1000000</pre><p>After the compressed file has been downloaded to the target, you can erase the flash, and copy the uImage from SDRAM to FLASH. Before doing this, you must understand the flash address that you want to put things in. To understand how your flash is organized, use the <code>flinfo</code> command.</p><pre class="code">stamp>flinfoBank # 1: CFI conformant FLASH (16 x 16) Size: 4 MB in 67 SectorsErase timeout 16384 ms, write timeout 0 ms, buffer write timeout 1 ms, buffer size 1 Sector Start Addresses: 20000000 (RO) 20004000 (RO) 20006000 (RO) 20008000 (RO) 20010000 (RO) 20020000 20030000 20040000 20050000 20060000 20070000 20080000 20090000 200A0000 200B0000 200C0000 200D0000 200E0000 200F0000 20100000 20110000 20120000 20130000 20140000 20150000 20160000 20170000 20180000 20190000 201A0000 201B0000 201C0000 201D0000 201E0000 201F0000 20200000 20210000 20220000 20230000 20240000 20250000 20260000 20270000 20280000 20290000 202A0000 202B0000 202C0000 202D0000 202E0000 202F0000 20300000 20310000 20320000 20330000 20340000 20350000 20360000 20370000 20380000 20390000 203A0000 203B0000 203C0000 203D0000 203E0000 203F0000stamp> </pre><p>This tells you the sectors that are readonly (marked with <code>(RO)</code>), and where the start and end sector addresses are. The <code>erase</code> command must start on a sector begin address, and end on a sector end address. If your <code>flinfo</code> is different, you will need to adjust the addresses.</p><pre class="code">BOOT> erase 0x20040000 0x203FFFFFBOOT> cp.b 0x1000000 0x20040000 $(filesize)BOOT> bootm 0x20040000</pre><p><code>$(filesize)</code><code>$(filesize)</code><code>0x33DB82</code><code>$(filesize)</code>’</p><p><code>$(filesize)</code></p><p>The remaining step would be to tell U-Boot to boot the image on it’s bootup, by changing the <code>bootcmd</code>: </p><pre class="code">BOOT> set bootcmd bootm 0x20040000BOOT> save</pre><p>Then when you reset the board - the kernel will automatically boot.</p></div><!-- SECTION [1640-4464] --><h3><a name="creating_compressed_kernel_image_by_hand" id="creating_compressed_kernel_image_by_hand">Creating Compressed Kernel Image by Hand</a></h3><div class="level3"><p> <code>make</code><code>make image</code><code>./uClinux-dist/images/</code><code>uImage</code></p><p>The first step is to generate a binary file from the ELF file. To do this enter a command similar to the following:</p><pre class="code">bash$ bfin-uclinux-objcopy -O binary -S linux linux.bin</pre><p> (Assuming <code>linux</code> is the name of the uClinux memory image)</p><p>Next this binary file should be compressed with gzip. To do this enter a command similar to the following:</p><pre class="code">bash$ gzip -9 linux.bin</pre><p>This command generates a compressed file called <code>linux.bin.gz</code>. Next a utility called <em><strong>mkimage</strong></em> must be used to make a file that can be read by U鈥態oot. This utility is found in the subdirectory <code>tools</code> within the root of the U鈥態oot source tree. To make the image enter a command similar to the following:</p><pre class="code">bash$ <U-Boot Directory>/tools/mkimage -A blackfin -O linux -T kernel -C gzip -a 0x1000 -e 0x1000 -n "uClinux Kernel Image" -d linux.bin.gz uImage</pre><p> </p><p>This command creates a file called <code>uImage</code> from the file <code>linux.bin.gz</code>. <code>uImage</code> is the file that will be loaded onto the target and uncompressed by U鈥態oot. This file may be transferred to the target by any of the methods described in the above sections (i.e. TFTP, DHCP, or Serial). If you are using the TFTP or DHCP method you must copy the file <code>uImage</code> to the TFTP directory. </p></div><!-- SECTION [4465-] --></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -