world leader in high performance signal processing
Trace:

Differences

This shows you the differences between two versions of the page.

simple_hello_world_application_example [2008/02/05 21:52]
w.sang typo
simple_hello_world_application_example [2009/04/30 17:28] (current)
rgetz update, and change things to use xterm
Line 18: Line 18:
  
 <note classic> <note classic>
-Since 2007R1 release, blackfin GCC toolchain comes with three categories: bfin-elf-*, bfin-linux-uclibc-*bfin-uclinux-*.+The Blackfin GCC toolchain comes with three categories: 
 +  - bfin-elf-*,  
 +  - bfin-linux-uclibc-* 
 +  - bfin-uclinux-*
  
-**bfin-uclinux-gcc** and **bfin-linux-uclibc-gcc** are used to compile programs that run on the Linux operating system.  They automatically link our program with the the Linux run time libraries, which in turn call the Linux operating system when required (for example, to print a string to the console). +**bfin-uclinux-gcc** and **bfin-linux-uclibc-gcc** are used to compile programs that run on the Linux operating system.  They automatically link the application with the the Linux run time libraries, which in turn call the Linux operating system when required (for example, to print a string to the console).
  
-**bfin-uclinux-gcc** is used to build FLAT format application (if given "elf2flt" option) and the Linux kernel (in ELF format), while **bfin-linux-uclibc-gcc** is used to build FDPIC format binary. Confused? ;( +The **bfin-elf-gcc** compiler is used to compile the Linux kernel and standalone programs as it uses a different set of libraries.
- +
-The **bfin-elf-gcc** compiler is used to compile the Linux kernel and standalone programs (non-Linux programs in other words, for example u-boot) as it uses a different set of libraries.+
 </note> </note>
  
 The first step is to ensure that ''bfin-uclinux-gcc'' is in your current path. The first step is to ensure that ''bfin-uclinux-gcc'' is in your current path.
-<code+<xterm>rgetz@imhotep:~> **bfin-uclinux-gcc --version** 
-host> bfin-uclinux-gcc -v +bfin-uclinux-gcc (ADI-trunk/svn-3343) 4.3.3 
-</code+Copyright (C) 2008 Free Software Foundation, Inc. 
-If this results in ''command not found'', then you must modify your PATH to include it. If you installed the rpm package, then it is located in ''/opt/uClinux/bfin-uclinux/bin/''. If you installed the binary tarball, or compiled from source, it will be some other place.+This is free software; see the source for copying conditions.  There is NO 
 +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 +</xterm> 
 + 
 +OR 
 + 
 +<xterm>rgetz@imhotep:~> **bfin-uclinux-gcc --version** 
 +bash: bfin-uclinux-gcc: command not found 
 +</xterm> 
 + 
 +If this results in ''command not found'', then you must modify your PATH to include it. If you installed the rpm package, then it is located in ''/opt/uClinux/bfin-uclinux/bin/''. If you installed the binary tarball, or compiled from source, it will be some other place. See [[:toolchain:installing|Installing the Blackfin GNU Toolchain]] for more information.
  
 The second step is to compile ''hello.c'' on your host PC: The second step is to compile ''hello.c'' on your host PC:
Line 37: Line 48:
  
 ==== Compiling as a FLAT file ==== ==== Compiling as a FLAT file ====
-<code> +<xterm>rgetz@imhotep:~/src**bfin-uclinux-gcc -Wl,-elf2flt hello.c -o hello** 
-host> bfin-uclinux-gcc -Wl,-elf2flt hello.c -o hello +</xterm>
-</code>+
  
 <note tip>Please note that ''-Wl,-elf2flt'' has no space between the comma or the dash, and that the character after the ''W'' is a lower case L, not the number 1</note> <note tip>Please note that ''-Wl,-elf2flt'' has no space between the comma or the dash, and that the character after the ''W'' is a lower case L, not the number 1</note>
Line 45: Line 55:
 The output executable is 'hello', also it creates a file "hello.gdb" which is used for debugging.   The output executable is 'hello', also it creates a file "hello.gdb" which is used for debugging.  
  
 +<xterm>rgetz@imhotep:~/src> **ls -l hello%%*%%**
 +-rwxr--r-- 1 rgetz users  5160 2009-04-30 11:16 hello
 +-rw-r--r-- 1 rgetz users    87 2009-04-30 11:15 hello.c
 +-rwxr-xr-x 1 rgetz users 78494 2009-04-30 11:16 hello.gdb
 +rgetz@imhotep:~/src> **file hello**
 +hello: BFLT executable - version 4 ram
 +rgetz@imhotep:~/src> **file hello.gdb**
 +hello.gdb: ELF 32-bit LSB executable, Analog Devices Blackfin, version 1 (SYSV), statically linked, not stripped
 +</xterm>
  
 ==== Compiling as a FDPIC program  ==== ==== Compiling as a FDPIC program  ====
 Need to use "bfin-linux-uclibc-gcc". Need to use "bfin-linux-uclibc-gcc".
-<code> +<xterm>rgetz@imhotep:~/src**bfin-linux-uclibc-gcc hello.c -o hello** 
-host> bfin-linux-uclibc-gcc hello.c -o hello +</xterm>
-</code>+
  
-The "-mfdpic" option is optional. Bellow command also works. +The output executable is 'hello' 
-<code> +
-host> bfin-linux-uclibc-gcc -mfdpic hello.c -o hello +
-</code>+
  
-<note tip>&quot;bfin-uclinux-gcc&quotcannot recongnize ''-mfdpic'' option.</note>+<xterm> 
 +rgetz@imhotep:~/src&gt**ls -l hello%%*%%** 
 +-rwxr-xr-x 1 rgetz users 10688 2009-04-30 11:17 hello 
 +-rw-r--r-- 1 rgetz users    87 2009-04-30 11:15 hello.c 
 +rgetz@imhotep:~/src&gt**file hello** 
 +hello: ELF 32-bit LSB executable, Analog Devices Blackfin, version 1 (SYSV), dynamically linked (uses shared libs), not stripped 
 +</xterm>
  
-The output executable is 'hello' +Since the output of the compilation has not been stripped, and includes debugging information, which is not necessary for running the application, this can be removed before downloading things to the target. 
 + 
 +<xterm>rgetz@imhotep:~/src> **bfin-linux-uclibc-strip hello** 
 +rgetz@imhotep:~/src> **ls -l hello%%*%%** 
 +-rwxr-xr-x 1 rgetz users 3556 2009-04-30 11:22 hello 
 +-rw-r--r-- 1 rgetz users   87 2009-04-30 11:15 hello.
 +</xterm>
  
 ===== Downloading to the board ===== ===== Downloading to the board =====
  
-The next step is to download 'hello' to your Blackfin STAMP board. There are many ways to do this, involving either the serial port or ethernet.+The next step is to download the ''hello'' to your Blackfin board. There are many ways to do this, involving either the serial port or ethernet.
  
 ==== Including in the uClinux-dist image ==== ==== Including in the uClinux-dist image ====
  
 On the host: On the host:
-<code+<xterm
-host:~/checkouts/uClinux-dist> cp ~/test/hello ./romfs/bin/hello +host:~/checkouts/uClinux-dist> **cp ~/test/hello ./romfs/bin/hello** 
-host:~/checkouts/uClinux-dist> make image +host:~/checkouts/uClinux-dist> **make image** 
-</code>+</xterm>
  
 This will re-build the files ''./images/linux'' and ''./images/uImage'' so that the 'hello' program is included in the uClinux-dist. Once you've booted the board with this new image, just run 'hello' like any other program. This will re-build the files ''./images/linux'' and ''./images/uImage'' so that the 'hello' program is included in the uClinux-dist. Once you've booted the board with this new image, just run 'hello' like any other program.
Line 79: Line 106:
 Before you can download over the network, the board's network settings must be configured. Use either: Before you can download over the network, the board's network settings must be configured. Use either:
  
-<code+<xterm
-root> dhcpcd & +root> **dhcpcd &** 
-root> ifconfig eth0 +root> **ifconfig eth0** 
-</code>+</xterm>
 or or
-<code> +<xterm>root> **ifconfig eth0 192.168.0.1 up** 
-root> ifconfig eth0 192.168.0.1 up +</xterm>
-</code>+
  
 For more information on how to set up the network, check out the [[setting up the network]] page. For more information on how to set up the network, check out the [[setting up the network]] page.
Line 96: Line 122:
 Login to your stamp board and download: Login to your stamp board and download:
  
-<code> +<xterm>root:~> **cd /tmp** 
-root:~> cd /tmp +root:/tmp> **wget %%http://yourwebserver/hello%%** 
-root:/tmp> wget http://yourwebserver/hello +</xterm>
-</code>+
  
 Now on the board, modify the permissions: Now on the board, modify the permissions:
  
-<code> +<xterm>root:/tmp> **chmod 777 hello** 
-root:/tmp> chmod 777 hello +</xterm>
-</code>+
  
 === Using ftp === === Using ftp ===
Line 111: Line 135:
 You can ftp into the board from the host, and upload the file to the board: You can ftp into the board from the host, and upload the file to the board:
  
-<code> +<xterm>host> **ftp 192.168.0.1** 
-host> ftp 192.168.0.1 +username : **root** 
-username : root +password : **uClinux** 
-password : uClinux +ftp> **binary** 
-ftp> binary +ftp> **put ./hello** 
-ftp> put ./hello +ftp> **quit** 
-ftp> quit +</xterm>
-</code>+
  
 Now on the board, modify the permissions: Now on the board, modify the permissions:
  
-<code> +<xterm>root:/tmp> **chmod 777 hello** 
-root:/tmp> chmod 777 hello +</xterm>
-</code>+
  
 === Using tftp === === Using tftp ===
Line 130: Line 152:
 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's tftp server directory. 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's tftp server directory.
  
-<code+<xterm
-host> cp hello /tftpboot/hello +host> **cp hello /tftpboot/hello** 
-</code>+</xterm>
  
 Then on the board: Then on the board:
  
-<code> +<xterm>root> **tftp -g -r hello 192.168.0.1** 
-root> tftp -g -r hello 192.168.0.1 +</xterm>
-</code>+
  
 Now on the board, modify the permissions: Now on the board, modify the permissions:
  
-<code> +<xterm>root:/tmp> **chmod 777 hello** 
-root:/tmp> chmod 777 hello +</xterm>
-</code>+
  
 === Using rcp === === Using rcp ===
Line 150: Line 170:
 From the host, remote copy the file to the board: From the host, remote copy the file to the board:
  
-<code> +<xterm>host:> **rcp ./hello root@192.168.0.1:/hello** 
-host:> rcp ./hello root@192.168.0.1:/hello +</xterm>
-</code>+
  
 ==== Using the serial port ==== ==== Using the serial port ====
Line 160: Line 179:
 After 'hello' has been transferred, modify the permissions: After 'hello' has been transferred, modify the permissions:
  
-<code> +<xterm>root:/tmp> **chmod 777 hello** 
-root:/tmp> chmod 777 hello +</xterm>
-</code>+
  
 ===== Running the application on the board ===== ===== Running the application on the board =====
  
-<code> +<xterm>root:/tmp> **./hello**
-root:/tmp> ./hello+
 Hello, World Hello, World
-</code>+</xterm>