原文地址::http://linuxgazette.net/123/jesslyn.htmlIntel and Analog Devices Inc. (ADI) jointly developed the Micro Signal Architecture (MSA) core and introduced it in December of 2000. ADI's Blackfin processor functions as a DSP and a microcontroller. This device is currently
used for multimedia applications.This article provides an introduction to programming the BF533 STAMP board and is intended for readers with some experience in Linux as well as with embedded devices. It contains a basic description of using the board for embedded
programming as I have done without any problem.
BF533 STAMP
The STAMP board features:
ADSP-BF533 500 MHz Blackfin Processor
128 MB SDRAM
4 MB FLASH memory
10/100 Ethernet Controller
RS232 Serial Interface
JTAG interface for debugging and flash programming
I/O connectors for Blackfin Peripherals:
PPI
SPORT0 & SPORT1
SPI
TIMERS
IRDA
TWI
The BF533 STAMP runs uClinux - a Linux port for embedded devices. It has soft real-time capabilities, meaning that it cannot guarantee a specific interrupt or scheduler latency.The STAMP board has been specifically designed to support the development and porting of open source uClinux applications and includes the full complement of memoryalong
with serial and network interfaces.The STAMP uClinux Kernel Board Support Package (BSP) includes a CD with a recent copy of the open source development tools, the uClinux kernel, and the documentation. For more details visithttp://blackfin.uclinux.org.
uClinux
The uClinux kernel provides a hardware abstraction layer. The uClinux Application Programming Interface (API) is identical for all processors which support uClinux, allowing code to be easily ported to a different processor core.
When porting an application to a new platform, programmers only need to address the areas specific to a particular processor - normally, this means only the device drivers.
Getting Started
We have to note the following components of our development board:
an Ethernet controller ( with an RJ45 Ethernet jack )
a serial port ( DB9 serial connector - female )
a power jack
The development workstation is essentially a Linux box which should have
an available serial port
terminal emulator software
an Ethernet card
There are two potential interconnections between the workstation and the target:
the 10 Mbps Ethernet connection
the RS232 serial interface
Connecting the Hardware
Connect the serial port to your host computer from the STAMP board
Connect the Ethernet cable to your network card of your Linux box ( use a straight cable with no cross connections )
Start the terminal emulation program. Minicom is an example of such a program, and is included in most Linux distributions. At the bash prompt type the following command as root:bash# minicom -m -s /dev/ttyS0
From the configuration menu within Minicom, set the serial port connection to
57600 baud
8 data bits
Parity none
1 stop bit
H/W flow control off
Now Save the configuration and choose Exit.
Connect the DC power cord and power up the board
After the STAMP board powers up, you should see a U-boot start-up screen in your terminal window. At this stage, if you allow the boot timer to count down, the board will load the uClinux kernel from flash memory and boot it,
finally resulting in a command prompt.
GNU/Linux tool chain for the Blackfin devices
Install the binutils and the GCC tools on your machine:[ Note: 'rpm' is RedHat-specific. Use the appropriate package manager for your distribution to install the latest 'bfin-gcc' version; if your distribution does not have one, use the 'alien' utility to convert
this RPM to your required format. -- Ben ] bash# rpm -ivh bfin-gcc-3.4-4.1.i386.rpm
You may not find the same version of GCC tools on the CD. I had to download the latest version since the one provided with CD did not contain the required tools (e.g., the C compiler for building programs on uClinux.) You may
download the RPM from here. Or you can visit the Blackfinwebsite
to download the toolchain yourself.In user mode, export the path for the tools:bash# export PATH=/opt/uClinux/bfin-elf/bin:/opt/uClinux/bfin-uclinux/bin:$PATH
Installing the uClinux Kernel
Copy the kernel source from the CD to your work directory
Uncompress the Kernel source
bash# bunzip2 uClinux-dist.tar.bz2
tar -xvf uClinux-dist.tar
Now that the kernel is uncompressed in the work directory, you are ready to start building your own uClinux kernel for the Blackfin processor.
Simple 'Hello World' Application
Traditionally, development environments and programming languages have always begun with the 'Hello World' program; we'll follow the precedent.Copy the following into a file called 'hello.c':#include
int main() {
printf("Hello, Welcome to Blackfin uClinux!!
");
return 0;
}
The next step is to compile 'hello.c' on you host PC:bash# bfin-uclinux-gcc -Wl,elf2flt hello.c -o hello
The resulting executable is named hello.Note that the bfin-uclinux-gcc compiler is used; this compiler is used to compile programs that run on the uClinux operating system. It automatically links our program with the uClinux run time libraries, which
in turn call the uClinux operating system when required ( for example ) to print to the console. The compiler collection for the Blackfin processor also includes another compiler,bfin-elf-gcc, which is used to compile the actual uClinux operating
system and uses a different set of libraries. If you want to try porting other RTOSs to Blackfin, you will have to usebfin-elf-gcc.Now we need to set up the Ethernet port on the Linux box; we'll set its IP address to 192.168.0.2. After booting the uClinux kernel on the STAMP board, you will have to configure its Ethernet interface as well; at the bash prompt
of the STAMP, type the following:root:~># ifconfig eth0 192.168.0.15 up
At this point, the Ethernet link should be up. We can use FTP to upload the 'hello' program from the host to the board. At the bash shell prompt of the linux workstation type the following:bash# ftp 192.168.0.15
Give the username and password as root anduClinux. Send the 'hello' executable to the STAMP board.Now modify the permissions and run:root:~> chown 777 hello
root:~> ./hello
Hello, Welcome to Blackfin uClinux!!
Segmentation faults
The Blackfin processor does not have an MMU, and does not provide any memory protection for programs. This can be demonstrated with a simple program:// test.c
int main ()
{
int *p;
*p=5;
}
Compile 'test.c' using our native C compiler. Try to run the resulting executable, and you'll end up with a segmentation fault.Now, compile the program using 'bfin-uclinux-gcc' as I described above. Send the executable to the STAMP board using FTP, change the file permissions, and run it.This time, it should run without a segmentation fault. Due to this, an unprivileged process can cause an address error, can corrupt kernel code, and result is obvious. This is not a limitation of the Blackfin architecture, but
simply demonstrates that uClinux is designed to support devices without an MMU.
End of Part I
This is all I know well about uClinux on Blackfin. I have to look deeper into uClinux and I shall try to include more next time!