⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simple_hello_world_application_example.html

📁 ADI 公司blackfin系列的用户使用文挡。
💻 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="#simple_hello_world_application_example" class="toc">Simple Hello World Application Example</a></span></div></li><li class="level2"><div class="li"><span class="li"><a href="#compiling_the_application" class="toc">Compiling the application</a></span></div><ul class="toc"><li class="level3"><div class="li"><span class="li"><a href="#compiling_as_a_flat_file" class="toc">Compiling as a FLAT file</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#compiling_as_a_elf_file" class="toc">Compiling as a ELF file</a></span></div></li></ul></li><li class="level2"><div class="li"><span class="li"><a href="#downloading_to_the_board" class="toc">Downloading to the board</a></span></div><ul class="toc"><li class="level3"><div class="li"><span class="li"><a href="#including_in_the_uclinux-dist_image" class="toc">Including in the uClinux-dist image</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#network_download" class="toc">Network download</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#using_the_serial_port" class="toc">Using the serial port</a></span></div></li></ul></li><li class="level2"><div class="li"><span class="li"><a href="#running_the_application_on_the_board" class="toc">Running the application on the board</a></span></div></li></ul></li></ul></div></div><h2><a name="simple_hello_world_application_example" id="simple_hello_world_application_example">Simple Hello World Application Example</a></h2><div class="level2"><p> This section shows how to compile, download and run a simple &ldquo;Hello, World&rdquo; uClinux application on a Blackfin STAMP board.  For information on more detailed application development, please see the <a href="application_development.html" class="wikilink1" title="application_development.html">Application Development</a> section.</p><p>Here is the program &lsquo;hello.c&rsquo;:</p><pre class="code c"><span class="co2">#include &lt;stdio.h&gt;</span>&nbsp;<span class="kw4">int</span> main<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>        <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span class="kw3">printf</span></a><span class="br0">&#40;</span><span class="st0">"Hello, World<span class="es0">\n</span>"</span><span class="br0">&#41;</span>;        <span class="kw1">return</span> <span class="nu0">0</span>;<span class="br0">&#125;</span></pre></div><!-- SECTION [1-449] --><h2><a name="compiling_the_application" id="compiling_the_application">Compiling the application</a></h2><div class="level2"><p> <strong>bfin-uclinux-gcc</strong><strong>bfin-elf-gcc</strong><strong>bfin-elf-gcc</strong> </p><p>The first step is to ensure that <code>bfin-uclinux-gcc</code> is in your current path. </p><pre class="code">host&gt; bfin-uclinux-gcc -v</pre><p> If this results in <code>command not found</code>, then you must modify your PATH to include it. If you installed the rpm package, then it is located in <code>/opt/uClinux/bfin-uclinux/bin/</code>. If you installed the binary tarball, or compiled from source, it will be some other place.</p><p>The second step is to compile <code>hello.c</code> on your host PC:</p></div><!-- SECTION [450-1469] --><h3><a name="compiling_as_a_flat_file" id="compiling_as_a_flat_file">Compiling as a FLAT file</a></h3><div class="level3"><pre class="code">host&gt; bfin-uclinux-gcc -Wl,-elf2flt hello.c -o hello</pre><p><code>-Wl,-elf2flt</code><code>W</code></p><p>The output executable is &lsquo;hello&rsquo;.  </p></div><!-- SECTION [1470-1781] --><h3><a name="compiling_as_a_elf_file" id="compiling_as_a_elf_file">Compiling as a ELF file</a></h3><div class="level3"><pre class="code">host&gt; bfin-uclinux-gcc -mfdpic hello.c -o hello</pre><p><code>-mfdpic</code></p><p>The output executable is &lsquo;hello&rsquo;.  </p></div><!-- SECTION [1782-2078] --><h2><a name="downloading_to_the_board" id="downloading_to_the_board">Downloading to the board</a></h2><div class="level2"><p> The next step is to download &lsquo;hello&rsquo; to your Blackfin STAMP board. There are many ways to do this, involving either the serial port or ethernet.</p></div><!-- SECTION [2079-2262] --><h3><a name="including_in_the_uclinux-dist_image" id="including_in_the_uclinux-dist_image">Including in the uClinux-dist image</a></h3><div class="level3"><p> On the host: </p><pre class="code">host:~/checkouts/uClinux-dist&gt; cp ~/test/hello ./romfs/bin/hellohost:~/checkouts/uClinux-dist&gt; make image</pre><p>This will re-build the files <code>./images/linux</code> and <code>./images/uImage</code> so that the &lsquo;hello&rsquo; program is included in the uClinux-dist. Once you&rsquo;ve booted the board with this new image, just run &lsquo;hello&rsquo; like any other program.</p></div><!-- SECTION [2263-2670] --><h3><a name="network_download" id="network_download">Network download</a></h3><div class="level3"><p> Before you can download over the network, the board&rsquo;s network settings must be configured. Use either:</p><pre class="code">root&gt; dhcpcd &amp;root&gt; ifconfig eth0</pre><p> or </p><pre class="code">root&gt; ifconfig eth0 192.168.0.1 up</pre><p>For more information on how to set up the network, check out the <a href="setting_up_the_network.html" class="wikilink1" title="setting_up_the_network.html">setting up the network</a> page.</p></div><h4><a name="using_a_web_server" id="using_a_web_server">Using a Web Server</a></h4><div class="level4"><p> You can also place the &lsquo;hello&rsquo; program on a web server and use &lsquo;wget&rsquo; on the STAMP board.</p><p>Login to your stamp board and download:</p><pre class="code">root:~&gt; cd /tmproot:/tmp&gt; wget http://yourwebserver/hello</pre><p>Now on the board, modify the permissions:</p><pre class="code">root:/tmp&gt; chmod 777 hello</pre></div><h4><a name="using_ftp" id="using_ftp">Using ftp</a></h4><div class="level4"><p> You can ftp into the board from the host, and upload the file to the board:</p><pre class="code">host&gt; ftp 192.168.0.1username : rootpassword : uClinuxftp&gt; binaryftp&gt; put ./helloftp&gt; quit</pre><p>Now on the board, modify the permissions:</p><pre class="code">root:/tmp&gt; chmod 777 hello</pre></div><h4><a name="using_tftp" id="using_tftp">Using tftp</a></h4><div class="level4"><p> On the board, you can fetch the file from the host using tftp. The first step in this process is to copy the hello to the host&rsquo;s tftp server directory.</p><pre class="code">host&gt; cp hello /tftpboot/hello</pre><p>Then on the board:</p><pre class="code">root&gt; tftp -g -r hello 192.168.0.1</pre><p>Now on the board, modify the permissions:</p><pre class="code">root:/tmp&gt; chmod 777 hello</pre></div><h4><a name="using_rcp" id="using_rcp">Using rcp</a></h4><div class="level4"><p> From the host, remote copy the file to the board:</p><pre class="code">host:&gt; rcp ./hello root@192.168.0.1:/hello</pre></div><!-- SECTION [2671-4126] --><h3><a name="using_the_serial_port" id="using_the_serial_port">Using the serial port</a></h3><div class="level3"><p> If <code>lrz</code> (receive z-modem) is built into uClinux-dist, you can use this to transfer files from the PC to the board.</p><p>After &lsquo;hello&rsquo; has been transferred, modify the permissions:</p><pre class="code">root:/tmp&gt; chmod 777 hello</pre></div><!-- SECTION [4127-4382] --><h2><a name="running_the_application_on_the_board" id="running_the_application_on_the_board">Running the application on the board</a></h2><div class="level2"><pre class="code">root:/tmp&gt; ./helloHello, World</pre></div><!-- SECTION [4383-] --></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -