User Tools

Site Tools


blackfin:uclinux_bf537setup

This document should greatly aid you in getting ucLinux for the Blackfin BF537-EZLITE evaluation board up and running. This document proposes using the latest versions of the developed sources for both booting and running the board which usually means that the most recent drivers and other enhancements will be available. It also means that this wiki is likely to lapse in and out of verbatim accuracy as the latest versions of the software change. This wiki was last updated on March 5, 2007. Below are the steps which I needed to perform to get ucLinux running on my desktop Debian system. Results for you will vary, especially in terms of programs that you may have currently installed. So without further discussion, let's begin. — arwillis 2007/03/05 05:39

Hardware you need

  1. The BF537-EZLITE or BF537-STAMP evaluation board.
  2. An RJ-45 ethernet cable connected between your host (or some other network connection to the board, e.g., both the host and the board connect to a network hub/switch) and the development board.
  3. A serial cable or a USB⇒serial connector (see details below)

That's it, only three things to run uclinux. It is also a victory that we don't require a JTAG connector which is typically the case in programming embedded systems. I'm not a huge fan of the old and nearly defunct 9-pin serial cable. There is another way, I suggest looking into the purchase of a USB⇒serial converter. This is a nifty way to connect to the target using a contemporary usb port rather than a 9-pin serial port which may / may not exist on PCs in the future (or even today). Connectors are available all over the web. One such place is here : http://www.pfranc.com/usb/usb.shtml.

Other things you will need

  1. The IP address of your host computer on the connected ethernet interface.
  2. Patience installed in your mental firmware. Remember, this software, system, etc. is completely free and requires no JTAG connector. Getting things going will take some time and you must be willing (and able) to understand, learn, and cope with that;

Good luck.

Register to the Blackfin uClinux Site

Go to blackfin.uclinux.org and register to the uclinux blackfin community.

Install some initial needed programs

I needed to install minicom, setserial and ckermit to talk to the BF537 through the serial port.

| Installing Serial Communication Programs
rootbash$> apt-get install minicom setserial ckermit

I prefer minicom to ckermit so I set it up to communicate over the Blackfin serial port. This is done by running minicom and configuring the connection.

  1. Run minicom
  2. Press Ctrl-A, lift your hands off the keyboard, then press O.
  3. Select Modem and Dialing using the arrow keys and enter.
  4. Press A to change the initialization and delete all the contents and press enter. Hit enter again to return to the configuration menu.
  5. Select Serial Port Setup using the arrow keys and enter.
  6. Press A and change the device name to the serial port you have connected to the Blackfin. This is typically /dev/ttyS0 or /dev/ttyS1.
  7. Press E to change the connection speed and protocol settings.
  8. Press H to select 57600 bps
  9. Press Q to select 8-N-1
  10. Press enter to return to the previous menu.
  11. Press F and G (if necessary) to make sure hardware and software flow control are off.
  12. Press enter to return to the previous menu.
  13. Select Save setup a dfl to preserve your changes as the default minicom setup.
  14. Select exit

If you have trouble running minicom. In debian the user accessing the serial port will need to be a member of the dialout group. You can make sure this is the case as follows (make sure you are root to do this) :

| Add user drew to group dialout
rootbash$>  adduser drew dialout

UPDATE

You may want to use gtkterm for accessing the board. It seems to be more updated and, in particular, will work with USB→serial connectors as mentioned above. I had difficulties getting minicom and kermit working with a USB→serial cable.

| Add user drew to group dialout
rootbash$>  apt-get install gtkterm

My username is drew. Your username will likely be something different. Substitute appropriately through the entirety of this wiki.

Getting the SubVersioN (SVN) Source

After getting mostly through an initial configuration of this board, I found that I need the program bfin-uclinux-ldr to load u-boot, the bootloader, onto the BF537-EZLITE board. Yet, this program as of March 2, 2007 is only available in the latest versions of the toolchain which are only served from the source upon which the development team is currently working. To get it, I needed to install subversion.

| Installing subversion
rootbash$> apt-get install subversion

Once you have obtained subversion, you can download the latest and greatest versions of all things relating to the Blackfin. This can be done using the following commands: The following commands get

  1. Toolchain source
  2. uClinux distribution source
  3. linux kernel source
  4. u-boot source

UPDATE

Checking out the code from blackin.uclinux.org can take a very long time (3+hours). Hence, the projects are being mirrored locally on the visionlab server.

| Checking out the latest Blackfin source
bash$> svn checkout http://www.visionlab.uncc.edu/svn/toolchain/trunk toolchain
bash$> svn checkout http://www.visionlab.uncc.edu/svn/uclinux-dist/trunk uclinux-dist
bash$> svn checkout http://www.visionlab.uncc.edu/svn/linux-kernel/trunk linux-kernel
bash$> svn checkout http://www.visionlab.uncc.edu/svn/u-boot/trunk u-boot

If for some reason you can't get the sources locally from visionlab.uncc.edu, try the following commands :

| Checking out the latest Blackfin source
bash$> svn checkout svn://sources.blackfin.uclinux.org/toolchain/trunk toolchain
bash$> svn checkout svn://sources.blackfin.uclinux.org/uclinux-dist/trunk uclinux-dist
bash$> svn checkout svn://sources.blackfin.uclinux.org/linux-kernel/trunk linux-kernel
bash$> svn checkout svn://sources.blackfin.uclinux.org/u-boot/trunk u-boot

At the time I did this I got the following versions :

“toolchain version 1488”

“uclinux-dist version 4995”

“linux kernel version 2793”

“u-boot version 614”

Getting the source this way takes ages (hours and hours), I will be setting up a mirror to help serve these files.

Directions on setting up mirrors are provided here : http://docs.blackfin.uclinux.org/doku.php?id=version_control_systems&s=rsync#mirroring_svn

Note that u-boot seems to have both u-boot-1.1.3 and u-boot-1.1.6 as part of the trunk. I believe version 1.1.6 will be the one we will use for our system.

Build the Blackfin toolchain

We now will compile the source to the toolchain which will be the workhorse of our system. The toolchain takes C code we write and generates binaries executable on the target system. To compile the toolchain we will need to install all of the programs which the toolchain build script requires. The following command tests for the presence of these programs.

| Building toolchain
$bash:toolchain/buildscript$>./BuildToolChain -p
Can not find autoconf
Can not find automake
bison (GNU Bison) 2.3
flex 2.5.33
gcc (GCC) 4.1.2 20060901 (prerelease) (Debian 4.1.1-13)
gettext (GNU gettext-runtime) 0.14.6
grep (GNU grep) 2.5.1
ln (GNU coreutils) 5.97
GNU M4 1.4.4
GNU Make 3.81
makeinfo (GNU texinfo) 4.8
msgfmt (GNU gettext-tools) 0.14.6
/usr/bin/which: illegal option -- -
Usage: /usr/bin/which [-a] args
mv (GNU coreutils) 5.97
cp (GNU coreutils) 5.97
rm (GNU coreutils) 5.97
This is free software.  You may redistribute copies of it under the terms of
There is NO WARRANTY, to the extent permitted by law.
grep (GNU grep) 2.5.1
mkdir (GNU coreutils) 5.97
tail (GNU coreutils) 5.97
GNU bash, version 3.1.17(1)-release (i486-pc-linux-gnu)
Can not find runtest
/bin/bash

Looks like I am missing a couple of needed tools for compile. I install them the debian way below.

| Install needed programs
bashroot$> apt-get install autoconf automake

You also need dejagnu for the runtest program used for cross-compilation.

| Install needed programs
bashroot$> apt-get install dejagnu

The command below will build the toolchain needed to cross-compile programs so they can run on the Blackfin architecture and are required to get linux up and running on a Blackfin board. This command will take about one hour (and 10 mins) to complete if successful.

| Build the toolchain
bash$> mkdir build
bash$> ~/archive/bf537/toolchain/buildscript/BuildToolChain -s ~/archive/bf537/toolchain -k ~/archive/bf537/linux-kernel -u ~/archive/bf537/u-boot/u-boot-1.1.6 -b ~/archive/bf537/build -o ~/archive/bf537/cvsoutput
 
Building gcc versions 4.1
Utilizing make: make -j2
Found multiple versions of autoconf, using the one at /usr/bin/autoconf
Found multiple versions of automake, using the one at /usr/bin/automake
Found multiple versions of bison, using the one at /usr/bin/bison
Found multiple versions of flex, using the one at /usr/bin/flex
Found multiple versions of gcc, using the one at /usr/bin/gcc
Found multiple versions of gettext, using the one at /usr/bin/gettext
Found multiple versions of m4, using the one at /usr/bin/m4
Found multiple versions of make, using the one at /usr/bin/make
Found multiple versions of makeinfo, using the one at /usr/bin/makeinfo
Found multiple versions of msgfmt, using the one at /usr/bin/msgfmt
Found multiple versions of which, using the one at /usr/bin/which
Found multiple versions of tail, using the one at /usr/bin/tail
Found multiple versions of make, using the one at /usr/bin/make
Removing /opt/uClinux/bfin-uclinux/bin from the PATH
Toolchain source is at      /home/drew/archive/bf537/toolchain
Kernel source is at         /home/drew/archive/bf537/linux-kernel
Build will be done in       /home/drew/archive/bf537/build
Path to elf output dir  /home/drew/archive/bf537/cvsoutput-elf
/home/drew/archive/bf537/cvsoutput-elf already exists - cleaning
Path to binutils dir        /home/drew/archive/bf537/toolchain/binutils-2.17
Path to elf2flt dir         /home/drew/archive/bf537/toolchain/elf2flt
Path to uClibc dir          /home/drew/archive/bf537/toolchain/uClibc
Path to genext2fs           /home/drew/archive/bf537/toolchain/genext2fs
Path to cramfs-tools        /home/drew/archive/bf537/toolchain/cramfs-1.1
Path to ldr-utils           /home/drew/archive/bf537/toolchain/ldr-utils
Path to uClinux output dir  /home/drew/archive/bf537/cvsoutput-uclinux
/home/drew/archive/bf537/cvsoutput-uclinux already exists - cleaning
Path to linux-uClibc output dir  /home/drew/archive/bf537/cvsoutput-linux-uclibc
/home/drew/archive/bf537/cvsoutput-linux-uclibc already exists - cleaning
Path to kernel output dir  /home/drew/archive/bf537/build/kernel_build
/home/drew/archive/bf537/build/kernel_build already exists - cleaning
Path to U-Boot Source       /home/drew/archive/bf537/u-boot/u-boot-1.1.6
Path to uClibc Config files /home/drew/archive/bf537/toolchain/uClibc/extra/Configs/
Creating log file           /home/drew/archive/bf537/build/logs/log
Removing old build dir
*** Configuring Elf Binutils & GDB Sat Mar  3 21:10:15 EST 2007
*** Building Elf Binutils & GDB    Sat Mar  3 21:10:18 EST 2007
*** Installing Elf Binutils & GDB  Sat Mar  3 21:15:56 EST 2007
Path to gcc dir             /home/drew/archive/bf537/toolchain/gcc-4.1
*** Linking files from /home/drew/archive/bf537/toolchain/binutils-2.17/newlib to /home/drew/archive/bf537/toolchain/gcc-4.1
*** Configuring GCC                Sat Mar  3 21:16:01 EST 2007
*** Building GCC                   Sat Mar  3 21:16:05 EST 2007
*** Installing GCC                 Sat Mar  3 21:32:59 EST 2007
*** Building Elf elf2flt           Sat Mar  3 21:33:24 EST 2007
*** Make Elf elf2flt               Sat Mar  3 21:33:27 EST 2007
*** Installing Elf elf2flt         Sat Mar  3 21:33:28 EST 2007
*** Building libdsp                Sat Mar  3 21:33:28 EST 2007
*** Installing libdsp              Sat Mar  3 21:33:29 EST 2007
*** Installing libdsp              Sat Mar  3 21:33:29 EST 2007
*** Configuring Linux Kernel       Sat Mar  3 21:33:29 EST 2007
*** Configuring uClibc             Sat Mar  3 21:33:48 EST 2007
*** Cleaning uClibc                Sat Mar  3 21:33:50 EST 2007
*** Building uClibc                Sat Mar  3 21:33:56 EST 2007
*** Installing uClibc              Sat Mar  3 21:35:03 EST 2007
*** Configuring sep-data uClibc    Sat Mar  3 21:35:04 EST 2007
*** Cleaning uClibc                Sat Mar  3 21:35:04 EST 2007
*** Building uClibc                Sat Mar  3 21:35:10 EST 2007
*** Installing uClibc              Sat Mar  3 21:36:21 EST 2007
*** Configuring shared flat uClibc Sat Mar  3 21:36:22 EST 2007
*** Cleaning uClibc                Sat Mar  3 21:36:22 EST 2007
*** Building uClibc                Sat Mar  3 21:36:28 EST 2007
*** Installing uClibc              Sat Mar  3 21:37:37 EST 2007
*** Configuring uClibc for FD-PIC  Sat Mar  3 21:37:38 EST 2007
*** Cleaning uClibc                Sat Mar  3 21:37:38 EST 2007
*** Building uClibc                Sat Mar  3 21:37:44 EST 2007
*** Installing uClibc              Sat Mar  3 21:38:58 EST 2007
*** Cleaning uClibc                Sat Mar  3 21:38:59 EST 2007
*** Building uClibc                Sat Mar  3 21:39:05 EST 2007
*** Installing uClibc              Sat Mar  3 21:40:19 EST 2007
*** Cleaning kernel                Sat Mar  3 21:40:19 EST 2007
*** Cleaning uClibc                Sat Mar  3 21:40:19 EST 2007
*** Configuring uClinux Binutils & GDBSat Mar  3 21:40:25 EST 2007
*** Building uClinux Binutils & GDB   Sat Mar  3 21:40:29 EST 2007
*** Installing uClinux Binutils & GDB Sat Mar  3 21:46:17 EST 2007
Path to gcc dir             /home/drew/archive/bf537/toolchain/gcc-4.1
*** Configuring GCC                Sat Mar  3 21:46:22 EST 2007
*** Building GCC                   Sat Mar  3 21:46:26 EST 2007
*** Installing GCC                 Sat Mar  3 21:59:11 EST 2007
*** Building uClinux elf2flt       Sat Mar  3 21:59:27 EST 2007
*** Cleaning uClinux elf2flt       Sat Mar  3 21:59:27 EST 2007
*** Building uClinux elf2flt       Sat Mar  3 21:59:30 EST 2007
*** Installing uClinux elf2flt     Sat Mar  3 21:59:31 EST 2007
*** Configuring linux-uclibc Binutils & GDBSat Mar  3 21:59:31 EST 2007
*** Building linux-uclibc binutils    Sat Mar  3 21:59:35 EST 2007
*** Installing linux-uclibc binutils  Sat Mar  3 22:05:32 EST 2007
Path to gcc dir             /home/drew/archive/bf537/toolchain/gcc-4.1
*** Configuring GCC                Sat Mar  3 22:05:39 EST 2007
*** Building GCC                   Sat Mar  3 22:05:43 EST 2007
*** Installing GCC                 Sat Mar  3 22:16:19 EST 2007
Installing /home/drew/archive/bf537/cvsoutput-linux-uclibc/lib/gcc/bfin-linux-uclibc/4.1.2/libstdc++.so.6.0.8
Installing /home/drew/archive/bf537/cvsoutput-linux-uclibc/lib/gcc/bfin-linux-uclibc/4.1.2/libgcc_s.so.1
*** Installing uClinux libdsp      Sat Mar  3 22:16:25 EST 2007
*** Building uClinux genext2fs     Sat Mar  3 22:16:25 EST 2007
*** Cleaning uClinux genext2fs     Sat Mar  3 22:16:25 EST 2007
*** Make uClinux genext2fs         Sat Mar  3 22:16:31 EST 2007
*** Installing uClinux genext2fs   Sat Mar  3 22:16:33 EST 2007
*** Building uClinux cramfs-tools  Sat Mar  3 22:16:33 EST 2007
*** Cleaning uClinux cramfs-tools  Sat Mar  3 22:16:33 EST 2007
*** Make uClinux cramfs-tools      Sat Mar  3 22:16:33 EST 2007
*** Installing uClinux cramfs-tools Sat Mar  3 22:16:34 EST 2007
*** Building uClinux ldr-utils      Sat Mar  3 22:16:34 EST 2007
*** Cleaning uClinux ldr-utils      Sat Mar  3 22:16:34 EST 2007
*** Make uClinux ldr-utils          Sat Mar  3 22:16:34 EST 2007
*** Installing uClinux ldr-utils    Sat Mar  3 22:16:35 EST 2007
*** Building U-Boot to get Tools   Sat Mar  3 22:16:35 EST 2007
*** Cleaning U-Boot                Sat Mar  3 22:16:35 EST 2007
*** Make U-Boot                    Sat Mar  3 22:16:35 EST 2007
*** Copying U-Boot Tools           Sat Mar  3 22:16:36 EST 2007
*** Cleaning U-Boot                Sat Mar  3 22:16:36 EST 2007
*** Building target libbfd (flat)  Sat Mar  3 22:16:37 EST 2007
*** Installing target libbfd       Sat Mar  3 22:18:10 EST 2007
*** Building target libbfd (fdpic) Sat Mar  3 22:18:11 EST 2007
*** Installing target libbfd       Sat Mar  3 22:19:44 EST 2007
*** Done                           Sat Mar  3 22:19:45 EST 2007

Ahhh… the pleasant feel of a clean compile. Thanks blackfin.uclinux.org developers!

If things didn't work for you look here for help : http://docs.blackfin.uclinux.org/doku.php?id=toolchain_build_script

Making a BF537 UART version of u-boot

Now to boot the board from UART0 using a UART compatible version of u-boot. To accomplish this we go into the u-boot source root directory and modify a file underneath this directory. Specifically, in the include/configs directory modify the file bf537.h or bf537-stamp.h in the following way :

to C files
//#define BFIN_BOOT_MODE          BF537_BYPASS_BOOT
#define BFIN_BOOT_MODE          BF537_UART_BOOT

Then execute the following commands from a shell

| Making u-boot UART loader
bash$>make mrproper
bash$>make bf537-stamp_config
bash$>make

If you run into trouble see the information here : http://docs.blackfin.uclinux.org/doku.php?id=compiling_u-boot

Once u-boot has compiled, a boot file u-boot.ldr will be created in the root of the u-boot source directory.

Booting your BF537 from UART (Finally)

  1. Set switch 16 on the BF537-EZLITE board to position 7.
  2. Turn the board ON (don't laugh… you see everything as a teacher).
  3. Issue the following command
| Loading u-boot from UART
~/bf537/u-boot/u-boot-1.1.6$ bfin-uclinux-ldr -l u-boot.ldr /dev/ttyS0 && minicom
Loading LDR u-boot.ldr ... OK!
Opening /dev/ttyS0 ... OK!
Configuring terminal I/O ... OK!
Trying to send autobaud ... OK!
Trying to read autobaud ... OK!
Checking autobaud ... OK!
Autobaud result: 115200bps 49.766mhz (header:0xBF DLL:0x1B DLH:0x00 fin:0x00)
Sending blocks of DXE 1 ... [1/2] [2/2] OK!
Sending blocks of DXE 2 ... [1/5] [2/5] [3/5] [4/5] [5/5] OK!
You may want to run minicom or kermit now
Quick tip: run 'ldrviewer <ldr> <tty> && minicom'
Connecting to /dev/ttyS0, speed 57600
 Escape character: Ctrl-\ (ASCII 28, FS): enabled
Type the escape character followed by C to get back,
or followed by ? to see other options.
----------------------------------------------------
 0
## Error: "ramboot" not defined
bf537>version
 
U-Boot 1.1.6-svn614 (ADI-2007R1-pre) (Mar  3 2007 - 22:41:36)
 
bf537>

If you run into trouble look here : http://docs.blackfin.uclinux.org/doku.php?id=loading_u-boot

Otherwise things must have worked. Great! Now we are running something on the board. But what are we doing? Now that we can boot the BF537-EZLITE board we really should run something useful on it. How about linux?

Setting up Trival FTP (TFTP) Server on the host

Ok, now we want to run linux. To start, we will boot using u-boot and load the linux kernel from the host computer (your desktop). Some directions on this are here : http://docs.blackfin.uclinux.org/doku.php?id=setting_up_a_tftp_server. I had to deviate from these directions significantly to get this working in debian please find my deviations below.

Note that you want to start with this command to install your programs :

| Installing TFTP Programs
rootbash$> apt-get install tftpd-hpa tftp-hpa

Getting tftpd to run right in debian can be a bit tricky. For me, I had to modify the /etc/defaults/tftpd file to contain :

| /etc/defaults/tftpd
#Defaults for tftpd-hpa
#RUN_DAEMON="no"
RUN_DAEMON="yes"
#OPTIONS="-l -s /var/lib/tftpboot"
OPTIONS="-l -s /home/drew/bf537/tftpboot"

Where /home/drew/bf537/tftpboot is the location I plan on putting my kernel image file. This need special access privelidges which may be set as follows :

| tftpd directory setup
rootbash$> mkdir /home/drew/bf537/tftpboot
rootbash$> chmod 777 /home/drew/bf537/tftpboot
rootbash$> chown nobody /home/drew/bf537/tftpboot

Then check it's runnning and working as specified here : http://docs.blackfin.uclinux.org/doku.php?id=setting_up_a_tftp_server See the parts that run commands similar to those below.

| Checking stuff out
~/bf537$ netstat -l -u
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
udp        0      0 *:32768                 *:*
udp        0      0 *:32769                 *:*
udp        0      0 *:bootpc                *:*
udp        0      0 *:tftp                  *:*
udp        0      0 *:sunrpc                *:*
udp        0      0 *:ipp                   *:*
udp        0      0 *:1016                  *:*
~/bf537$ cat 'adkkfjasdlf' > tftpboot/foo
~/bf537$ tftp localhost
tftp> get foo
tftp> quit
:~/bf537$ ls -al foo
-rw-r--r-- 1 drew drew 11 2007-03-04 00:05 foo

Ok, everything looks good for the TFTP server now this will be used more later.

Setting up the ucLinux Distribution for your Target

We need to tell uclinux what type of board you have so that the system can be changed appropriately to your target. In this regard there are 5 files within the uclinux-dist source that need to be copied to strategic locations.

  • ./uClinux-dist/vendors/AnalogDevices/BF537-STAMP/config.arch ⇔ ./uClinux-dist/config.arch
  • ./uClinux-dist/vendors/AnalogDevices/BF537-STAMP/config.device ⇔ ./uClinux-dist/.config
  • ./uClinux-dist/vendors/AnalogDevices/BF537-STAMP/config.linux-2.6.x ⇔ ./uClinux-dist/linux-2.6.x/.config
  • ./uClinux-dist/vendors/AnalogDevices/BF537-STAMP/config.uClibc ⇔ ./uClinux-dist/uClibc/.config
  • ./uClinux-dist/vendors/AnalogDevices/BF537-STAMP/config.vendor-2.6.x ⇔ ./uClinux-dist/config/.config

Move these files into these locations to make your uclinux-dist customized for the BF537 target. More details on this are available here : http://docs.blackfin.uclinux.org/doku.php?id=managing_kernel_upgrades

Once these files have been moved make a backup copy of the directory.

  1. go to the uclinux-dist directory
  2. generate a symbolic link (similar to a shortcut) to the linux kernel source using the command ln -s ../linux-kernel linux-2.6.x
  3. go to the subdirectory vendors/AnalogDevices
  4. make a copy of the BF537-STAMP directory to BF537-STAMP-JFFS2 using the cp -R BF537-STAMP BF537-STAMP-JFFS2 command.
  5. cd BF537-STAMP-JFFS2
  6. cp config.arch ../../../config.arch
  7. cp config.device ../../../.config
  8. cp config.linux-2.6.x ../../../linux-2.6.x/.config
  9. cp config.vendor ../../../config/.config

I could not find a config.uClibc file initially in this directory. It may be automatically generated.

  • go to the uclinux-dist root directory
  • make menuconfig
  • Vendor Product Selection ⇒ Analog Devices Products ⇒ BF537-STAMP-JFFS2
  • Kernel/Library/Defaults Selection ⇒ Libc Version ⇒uClibc
  • Exit and save your changes
  • Make the system.

I have received the following error : bfin-uclinux-genext2fs: couldn't allocate a block (no free space) this occurs when you have run out of free space on your system. This means your kernel is too big. However, you can circumvent this problem for compilation, say if you want to boot from trivial ftp, by changing the BLOCKS variable in the file Makefile located in the vendors/AnalogDevices/BF537-STAMP-JFFS2 directory. For more information see : http://docs.blackfin.uclinux.org/doku.php?id=FAQ#i_get_errors_about_no_free_space

The built files are placed in the images subdirectory. These need to be moved into the TFTP directory to be downloaded to the host.

| copying linux images to the tftp directory
bash$> cp images/linux ../tftpboot/linux-bf537-1.00
bash$> cp images/uImage ../tftpboot/uImage-bf537-1.00
bash$> cd ../tftpboot; ln -s uImage-bf537-1.00 uImage

Setting up Trival FTP (TFTP) Boot

Connect to the Blackfin board again through the serial cable. Now set some environment variables by executing the following commands on the board :

| BF537 Environment setup commands
bf537> setenv bootcmd run tftp_boot
bf537> setenv ethaddr 192.168.0.15
bf537> setenv tftp_boot 'tftp ftp 0x1000000 uImage;bootm 0x1000000; echo'
bf537> setenv stdin serial
bf537> setenv stdout serial
bf537> setenv stderr serial

Where 192.168.0.15 is the address of my host or desktop machine on the local network and I have plugged the ethernet cable into a router.

I then take a compiled linux kernel and place it in the TFTP server file directory (where I had created foo). I then attempt to boot. However, I believe I have not set a filename environment variable to boot from. Hence, the default file name is assumed to be “C0A8000F.img”. Hence, I create a symbolic link (for now) from my file to this filename.

| Make the link
~/bf537/tftpboot$ ls
foo                uImage-bf537-stamp           uImage-bf537-stamp-netscope
linux-bf537-stamp  uImage-bf537-stamp-awg       uImage-bf537-stamp-usb
uImage             uImage-bf537-stamp-netaudio  uImage-bf561-ezkit
drew@hendrix:~/bf537/tftpboot$ ln uImage-bf537-stamp C0A8000F.img

Now the image may be downloaded.

| Download the image to the Blackfin
bf537> setenv ethaddr 192.168.0.15
bf537> tftp 0x1000000 uImage
Using BF537 ETHERNET device
TFTP from server 192.168.0.2; our IP address is 192.168.0.15
Filename 'uImage'.
Load address: 0x1000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###############
done
Bytes transferred = 3403458 (33eec2 hex)
bf537> bootm 0x1000000
## Booting image at 01000000 ...
   Image Name:   uClinux Kernel and ext2
   Image Type:   Blackfin Linux Kernel Image (gzip compressed)
   Data Size:    3403394 Bytes =  3.2 MB
   Load Address: 00001000
   Entry Point:  00001000
   Verifying Checksum ... OK
   Uncompressing Kernel Image ...

Great. Now we have a boot loader and have a host⇒client transfer of the linux kernel image from the desktop to the board configured. Now lets try a delicate part. Flashing the boot loader to the board memory.

Flashing u-boot to the Board

Ok… now we go back to the u-boot files. Go to the u-boot/u-boot-1.1.6 directory. Now edit the file include/configs/bf537-stamp.h to be similar to this :

| bf537-stamp.h
#define BFIN_BOOT_MODE                BF537_BYPASS_BOOT
//#define BFIN_BOOT_MODE          BF537_PARA_BOOT
//#define BFIN_BOOT_MODE                BF537_UART_BOOT
//#define BFIN_BOOT_MODE                BF537_SPI_MASTER_BOOT

Also, save your previously built version of u-boot.ldr so you can use it to boot from serial whenever you need to.

| backup u-boot.ldr
bash$ cp u-boot.ldr u-boot-uart.ldr

Now rebuild a version of u-boot that will boot from a parallel (8-bit or 16-bit) flash as follows :

| build flash u-boot
bash$ make mrproper
bash$ make bf537-stamp_config
bash$ make

This time you want to use the u-boot.bin file. Take this file and place it in your tftp download directory.

| Copy the binary to the tftp directory
bash$ cp u-boot.bin /home/drew/bf537/tftpboot/u-boot.bypass.bin

Another path is to just download the u-boot compiled version u-boot_stamp537.bin available here http://blackfin.uclinux.org/gf/project/u-boot/frs

| Flashing with a precompiled uboot
bf537> version
 
U-Boot-1.1.3-ADI-R06R2 (Sep 21 2006 - 15:10:36)
 
bf537> setenv ethaddr 192.168.0.15
bf537> tftp 0x1000000 u-boot.bypass.bin
Using MAC Address 92:68:00:15:00:00
TFTP from server 192.168.0.2; our IP address is 192.168.0.15
Filename 'u-boot.bypass.bin'.
Load address: 0x1000000
Loading: ########################
done
Bytes transferred = 118912 (1d080 hex)
bf537> go 0x1000000
## Starting application at 0x01000000 ...
U-Boot 1.1.6-svn614 (ADI-2007R1-pre) (Mar  4 2007 - 16:57:11)
 
CPU:   ADSP BF537 Rev.: 0.2
Board: ADI BF537 stamp board
       Support: http://blackfin.uclinux.org/
Clock: VCO: 500 MHz, Core: 500 MHz, System: 100 MHz
SDRAM: 64 MB
FLASH:   4 MB
In:    serial
Out:   serial
Err:   serial
Net:    BF537 ETHERNET
I2C:   ready
Hit any key to stop autoboot:  0
bf537> version
 
U-Boot 1.1.6-svn614 (ADI-2007R1-pre) (Mar  4 2007 - 16:57:11)
 
bf537> protect off all
Un-Protect Flash Bank # 1
bf537> erase all
Erase Flash Bank # 1
Erasing Flash locations, Please Wait
.......................................................................
bf537> cp.b 0x1000000 0x20000000 0x1d080
Copy to Flash... .done
bf537> cmp.b 0x1000000 0x20000000 0x1d080
Total of 118912 bytes were the same

A victory! U-boot is now written to the flash! VERY IMPORTANT You no longer need to use the UART to boot. Put switch 16 (SW16) into position 0 to boot from your new u-boot based flash.

Now press the board reset button or cycle power to the board. You should see the board boot on its own with output from the serial port now. If so, congratulations, you now are booting from u-boot resident on the board flash memory, i.e., you have flashed your board.

Running Linux on your board

We will start by running linux through tftp. In this case we need to download the kernel image using tftp to the board memory and then execute the image. Here's an example :

Running Linux
bf537> setenv ethaddr 192.168.0.15
bf537> tftp 0x1000000 linux-bf537-stamp
Using MAC Address 92:68:00:15:00:00
TFTP from server 192.168.0.2; our IP address is 192.168.0.15
Filename 'linux-bf537-stamp'.
Load address: 0x1000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #########################################
done
Bytes transferred = 10190745 (9b7f99 hex)
bf537> bootelf
Loading .text @ 0x00001000 (1114456 bytes)
Loading .init @ 0x00111158 (60980 bytes)
Loading .text_l1 @ 0xffa00000 (1572 bytes)
sh_addr: FFA00000, p_paddr: 0011FF8C
Loading from: 01120000 to 0011FF8C, size: 1572
Loading .data @ 0x001205b0 (201552 bytes)
Clearing .bss @ 0x00151900 (58952 bytes)
Loading .romfs @ 0x0015ff48 (8388608 bytes)
## Starting application at 0x00001000 ...
Linux version 2.6.16.27-ADI-2006R2 (root@sevens) (gcc version 4.1.1 (ADI 06R2)) #1 Tue Oct 31 11:03:40 6Blackfin support (C) 2004-2006 Analog Devices, Inc.
Compiled for ADSP-BF537 Rev. 0.2
Blackfin uClinux support by http://blackfin.uclinux.org/
Processor Speed: 500 MHz core clock and 100 Mhz System Clock
Board Memory: 64MB
Kernel Managed Memory: 64MB
Memory map:
  text      = 0x00001000-0x00111158
  init      = 0x00112000-0x0011ff8c
  data      = 0x001205b0-0x00151900
  stack     = 0x00122000-0x00124000
  bss       = 0x00151900-0x0015ff48
  available = 0x0015ff48-0x03700000
  rootfs    = 0x03700000-0x03f00000
  DMA Zone  = 0x03f00000-0x04000000
Instruction Cache Enabled
Data Cache Enabled (write-through)
Hardware Trace Enabled
Built 1 zonelists
Kernel command line: root=/dev/mtdblock0 rw ip=192.168.0.15:192.168.0.2:192.168.0.1:255.255.255.0:BF537fConfiguring Blackfin Priority Driven Interrupts
PID hash table entries: 256 (order: 8, 4096 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Physical pages: 3700
Memory available: 54400k/64382k RAM, (55k init code, 1088k kernel code, 57k data, 1024k dma)
Blackfin Scratchpad data SRAM: 4 KB
Blackfin DATA_A SRAM: 16 KB
Blackfin DATA_B SRAM: 16 KB
Blackfin Instruction SRAM: 48 KB
Security Framework v1.0.0 initialized
Capability LSM initialized
Mount-cache hash table entries: 512
NET: Registered protocol family 16
Blackfin DMA Controller
stamp_init(): registering device resources
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler cfq registered
Real Time Clock Driver v1.10e
Dynamic Power Management Controller Driver v0.1: major=10, minor = 254
Blackfin BF5xx serial driver version 2.00 (DMA mode)
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
Blackfin mac net device registered
uclinux[mtd]: RAM probe address=0x3700000 size=0x800000
Creating 1 MTD partitions on "RAM":
0x00000000-0x00800000 : "ROMfs"
uclinux[mtd]: set ROMfs:EXT2  to be root filesystem
NET: Registered protocol family 2
IP route cache hash table entries: 512 (order: -1, 2048 bytes)
TCP established hash table entries: 2048 (order: 1, 8192 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
TCP bic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
IP-Config: Complete:
      device=eth0, addr=192.168.0.15, mask=255.255.255.0, gw=192.168.0.1,
     host=BF537, domain=, nis-domain=(none),
     bootserver=192.168.0.2, rootserver=192.168.0.2, rootpath=
VFS: Mounted root (ext2 filesystem).
Freeing unused kernel memory: 52k freed (0x112000 - 0x11e000)
dma_alloc_init: dma_page @ 0x0011b000 - 256 pages at 0x03f00000
 
Welcome to:
       ____ _  _
      /  __| ||_|             _  _
 _   _| |  | | _ ____  _   _ \ \/ /
| | | | |  | || |  _ \| | | | \  /
| |_| | |__| || | | | | |_| | /  \
|  ___\____|_||_|_| |_|\____|/_/\_\
|_|
 
For further information see:
http://www.uclinux.org/
http://blackfin.uclinux.org/
 
 
 
BusyBox v1.00 (2006.10.30-05:34+0000) Built-in shell (msh)
Enter 'help' for a list of built-in commands.
 
root:~>

Ahhh… finally a linux prompt!

Modifying boot startup parameters

Now let's configure our boot environment to be compatible with our setup rather than typing things into u-boot constantly in order to get things loading. My first step is to set the ethernet ip address of the board.

| Setting the board IP address
bf537> setenv ethaddr 192.168.0.15
bf537> saveenv
Saving Environment to Flash...
Un-Protected 1 sectors
Erasing Flash...
Erasing Flash locations, Please Wait
.
Erased 1 sectors
Writing to Flash... done
Protected 1 sectors
bf537>

Now setup u-boot to boot from the uncompressed tftp image on the host.

| Setting up automatic tftp boot
bf537> setenv boot-linux-stamp 'tftp 0x1000000 linux-bf537-stamp;bootelf'
bf537> setenv bootcmd run boot-linux-stamp
bf537> saveenv
Saving Environment to Flash...
Un-Protected 1 sectors
Erasing Flash...
Erasing Flash locations, Please Wait
.
Erased 1 sectors
Writing to Flash... done
Protected 1 sectors
bf537> reset
U-Boot-1.1.3-ADI-R06R2 (Sep 21 2006 - 15:10:36)
 
CPU:   ADSP BF537 Rev.: 0.2
Board: ADI BF537 stamp board
       Support: http://blackfin.uclinux.org/
Clock: VCO: 500 MHz, Core: 500 MHz, System: 100 MHz
SDRAM: 64 MB
FLASH:   4 MB
In:    serial
Out:   serial
Err:   serial
Using MAC Address 92:68:00:15:00:00
Net:    ADI BF537 EMAC
I2C:   ready
Hit any key to stop autoboot:  0
Using MAC Address 92:68:00:15:00:00
TFTP from server 192.168.0.2; our IP address is 192.168.0.15
Filename 'linux-bf537-stamp'.
Load address: 0x1000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #########################################
done
Bytes transferred = 10190745 (9b7f99 hex)
Loading .text @ 0x00001000 (1114456 bytes)
Loading .init @ 0x00111158 (60980 bytes)
Loading .text_l1 @ 0xffa00000 (1572 bytes)
sh_addr: FFA00000, p_paddr: 0011FF8C
Loading from: 01120000 to 0011FF8C, size: 1572
Loading .data @ 0x001205b0 (201552 bytes)
Clearing .bss @ 0x00151900 (58952 bytes)
Loading .romfs @ 0x0015ff48 (8388608 bytes)
## Starting application at 0x00001000 ...
Linux version 2.6.16.27-ADI-2006R2 (root@sevens) (gcc version 4.1.1 (ADI 06R2)) #1 Tue Oct 31 11:03:40 6Blackfin support (C) 2004-2006 Analog Devices, Inc.
Compiled for ADSP-BF537 Rev. 0.2
Blackfin uClinux support by http://blackfin.uclinux.org/
Processor Speed: 500 MHz core clock and 100 Mhz System Clock
Board Memory: 64MB
Kernel Managed Memory: 64MB
Memory map:
  text      = 0x00001000-0x00111158
  init      = 0x00112000-0x0011ff8c
  data      = 0x001205b0-0x00151900
  stack     = 0x00122000-0x00124000
  bss       = 0x00151900-0x0015ff48
  available = 0x0015ff48-0x03700000
  rootfs    = 0x03700000-0x03f00000
  DMA Zone  = 0x03f00000-0x04000000
Instruction Cache Enabled
Data Cache Enabled (write-through)
Hardware Trace Enabled
Built 1 zonelists
Kernel command line: root=/dev/mtdblock0 rw
Configuring Blackfin Priority Driven Interrupts
PID hash table entries: 256 (order: 8, 4096 bytes)
Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
Physical pages: 3700
Memory available: 54400k/64382k RAM, (55k init code, 1088k kernel code, 57k data, 1024k dma)
Blackfin Scratchpad data SRAM: 4 KB
Blackfin DATA_A SRAM: 16 KB
Blackfin DATA_B SRAM: 16 KB
Blackfin Instruction SRAM: 48 KB
Security Framework v1.0.0 initialized
Capability LSM initialized
Mount-cache hash table entries: 512
NET: Registered protocol family 16
Blackfin DMA Controller
stamp_init(): registering device resources
io scheduler noop registered
io scheduler anticipatory registered (default)
io scheduler cfq registered
Real Time Clock Driver v1.10e
Dynamic Power Management Controller Driver v0.1: major=10, minor = 254
Blackfin BF5xx serial driver version 2.00 (DMA mode)
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
Blackfin mac net device registered
uclinux[mtd]: RAM probe address=0x3700000 size=0x800000
Creating 1 MTD partitions on "RAM":
0x00000000-0x00800000 : "ROMfs"
uclinux[mtd]: set ROMfs:EXT2  to be root filesystem
NET: Registered protocol family 2
IP route cache hash table entries: 512 (order: -1, 2048 bytes)
TCP established hash table entries: 2048 (order: 1, 8192 bytes)
TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
TCP: Hash tables configured (established 2048 bind 2048)
TCP reno registered
TCP bic registered
NET: Registered protocol family 1
NET: Registered protocol family 17
VFS: Mounted root (ext2 filesystem).
Freeing unused kernel memory: 52k freed (0x112000 - 0x11e000)
dma_alloc_init: dma_page @ 0x0011b000 - 256 pages at 0x03f00000
 
Welcome to:
       ____ _  _
      /  __| ||_|             _  _
 _   _| |  | | _ ____  _   _ \ \/ /
| | | | |  | || |  _ \| | | | \  /
| |_| | |__| || | | | | |_| | /  \
|  ___\____|_||_|_| |_|\____|/_/\_\
|_|
 
For further information see:
http://www.uclinux.org/
http://blackfin.uclinux.org/
 
 
 
BusyBox v1.00 (2006.10.30-05:34+0000) Built-in shell (msh)
Enter 'help' for a list of built-in commands.
 
root:~>

Success. We now have a board which will boot to linux automagically! Now lets use tftp to boot from a compressed image.

| tftp boot linux from compressed image
bf537> setenv boot-linux-uImage 'tftp 0x1000000 uImage;bootm 0x1000000'
bf537> setenv bootcmd 'run boot-linux-uImage'
bf537> saveenv
Saving Environment to Flash...
Un-Protected 1 sectors
Erasing Flash...
Erasing Flash locations, Please Wait
.
Erased 1 sectors
Writing to Flash... done
Protected 1 sectors

Now our board will boot from a compressed image which is much smaller (3.2MB) than the uncompressed kernel image (~9MB). The boot process takes longer since the kernel image must be uncompressed into computer memory before being executed. If we are able to compress the kernel image to be small enough, we can also put the compressed kernel image in the flash. If this is accomplished, the board can boot ucLinux without any attached host, i.e., no tftp transfer to boot!

Some docs on this are here : http://docs.blackfin.uclinux.org/doku.php?id=loading_a_compressed_kernel_image

Some things I plan to work on in the future:

Frame Capture Device Notes

Running java on the blackfin

Blackfin Add-on Cards and JTAG systems

uCLinux Blackfin Projects

Advanced Topics on the Linux Kernel

This commentary is sort of old and at the time I didn't understand exactly how the system was built. However this is still here so that I can expand on this topic at a later time. One may test compilation of the kernel alone in this context apart from compiling the whole uclinux distribution so there is merit to having a separate kernel-related section.

My downloaded version of the linux kernel did not immediately compile. Instead, I needed to configure the kernel options that are appropriate for the BF537. The .config file in the linux-kernel directory determines the configuration options for the kernel. As I am not familiar with which options need to be set, I got the large majority of these settings from a previous configuration file provided as part of the uclinux-dist package. To get these settings go to the linux-kernel directory and issue the following command.

| Copy linux kernel configuration for the BF537
bash$ cp ../uclinux-dist/vendors/AnalogDevices/BF537-STAMP/config.linux-2.6.x .config

Note that this command was issued when I was in the root of the kernel source directory and a relative path to uclinux-dist directory was provided. Your paths may be different.

Go to the linux-kernel directory and configure your kernel to your desires.

| Configure the linux kernel
bash$> make clean
bash$> make 

When you provide the make command some additional prompts may come up. These are kernel options not specified within the configuration file. It is safest initially to just press Enter to adopt the default decision on these options.

The kernel will take some time to compile. Once it finishes compiling your output images are in the arch/blackfin/boot subdirectory. Below is commands to move these files to a trivial ftp directory to be placed on the target system.

| Copying the images to TFTP
bash$> cp arch/blackfin/boot/vmlinux.bin ../tftpboot/linux-bf537-1.00
bash$> cp arch/blackfin/boot/vmImage ../tftpboot/uImage-bf537-1.00

You will need this information for later : The default username for the Blackfin login is root and the password is uClinux.

If you want to change the config you can do this in several possible ways :

  • make config (most basic)
  • make menuconfig (better you need ncurses for this I think)
  • make xconfig (best – must have libqt2 I think)

Within these menus one may completely customize the kernel to add or remove functionality as is appropriate to their task at hand. The most important thing here is to ensure the target system is correctly set in the kernel configuration as is discussed here : http://docs.blackfin.uclinux.org/doku.php?id=basic_compilation.

Go to Blackfin Processor OptionsCPUBF537. This will make sure the kernel is compiled for the correct target. The default at the time of this build was the BF533. This being now done, you can make a simple kernel with no fancy customizations. You will probably re-do this step when you want to customize your application.

An Introduction to uClinux commands and memory structure for the Blackfin

Nano-X : An X-Windows-like Environment for embedded systems

blackfin/uclinux_bf537setup.txt · Last modified: 2010/09/02 16:46 by arwillis