[Black Gold power community] [bf531 experience board tutorial] guide to porting uClinux Based on bf531 DSP (IV)

Source: Internet
Author: User
Tags syslog

Heijin powerCommunity: Http://www.heijin.org

I. Preparations

1. U-BOOT official offers: u-boot-1.1.6-2008R1.tar.bz2

2. uClinux official: uClinux-dist-2008R1-RC8.tar.bz2

3. Cross-compilation tool: blackfin-toolchain-elf-gcc-4.1-08r1.5-14.i386.tar.bz2

Blackfin-toolchain-uclibc-full-08r1.5-14.i386.tar.bz2

Blackfin-toolchain-08r1.5-14.i386.tar.bz2

4. compiling environment: fedora 9.0

II, U-BOOT Of Port

The transplantation of U-boot is divided into two parts: First, create a new directory under the directory/board/and copy the source code of the similar development board to this directory, modify the corresponding configuration for our new development board and compile it. Then, modify the source code file based on the features of our new Development Board so that it can run on our development board.

The two parts are described as follows:

1. Create a file

Our development board uses bf531, similar to the official BF533-stamp Development Board provided in U-boot, can also be started by serial flash. Therefore, we can use this Development Board as a template to get the porting of our new Development Board through modification.Code. All operations are logged on as root users. Other problems are not described here. Next, we will elaborate on the first part of U-Boot porting, which mainly includes the following steps:

(1) enter the Board directory of U-boot and create a file directory for our development board named ms531.
(2) copy the files in the entire directory of the bf533-stamp to ms531 and change all the bf533-stamp inside to ms531. For this reason, the file directories and files of our new Development Board are available, but we cannot run them on our development board.
(3) Modify makefile and u-boot.lds under the ms531 directory, modify all the bf533-stamp to ms531. Note that you need to modify the serial flash in the spi-flash.c, in the old version, you need to set the flash size in this file. The new version has all supported flash descriptions and does not need to be modified manually. For specific supported flash types, refer to the official documentation or view the file by yourself.

(4) enter the./include/configs directory, copy a bf533-stamp.h and name it ms531.h. This header file contains a lot of content to be modified. We will describe it in the second part.
(5) modify the makefile in the top-level directory and add "ms531" in "bfin_boards = ". Note that makefiles of different versions are slightly different and must be added according to the actual situation.
(6) Finally compile U-boot:

# Make clean
# Makems531_config (the config added in makefile)
# Make
(7) The compilation is correct, generate u-boot.ldr file, other compilation file first don't worry, this part is completed. Next we will try to modify the correspondingSource code. To fit our ms531 board.

2. Modify the file

 

This part mainly involves modifying the development board configuration file and the Flash Driver. Modify the configuration file of the Development Board so that U-boot can run. The main changes include startup mode, serial port settings, clock settings, flash settings, and SDRAM settings. Note that the settings for different versions may vary, especially the Startup Mode settings. Please refer to the official documentation. The following sections describe:

(1) first set the Startup Mode

# Definebfin_cpu bf531

# Definebfin_boot_mode bfin_boot_spi_master

(2) configure the serial port to set the baud rate to 115200.

# Defineconfig_baudrate 115200

(3) Clock settings

According to the crystal oscillator frequency of the Development Board and the operating frequency required by the system, the crystal oscillator of our development board is 20 MHz, the kernel clock is the 20 multiplier of the input clock, and the system clock is the 5-division of the kernel clock, so the following settings. Make changes based on the specific configuration and requirements on the Development Board.

# Defineconfig_clkin_hz20000000

/* Config_clkin_half controls what is passed to PLL 0 = clkin */

/* 1 = clkin/2 */

# Define config_clkin_half 0

/* Config_pll_bypass controls if the PLL is used 0 = Don't bypass */

/* 1 = bypass PLL */

# Defineconfig_pll_bypass 0

/* Config_vco_mult controls what the multiplier of the PLL is .*/

/* Values canrange from 1-64 */

# Defineconfig_vco_mult 20

/* Config_cclk_div controls what the core clock divider is */

/* Values can be1, 2, 4, or 8 only */

# Defineconfig_cclk_div 5

/* Config_spi_baud controls the SPI peripheral clock divider */

/* Values canrange from 2-65535 */

/* Sck frequency = sclk/(2 * config_spi_baud )*/

# Defineconfig_spi_baud 2

/* Config_sclk_div controls what the peripheral clock divider is */

/* Values canrange from 1-15 */

# Defineconfig_sclk_div 4

(4) SDRAM settings

Customized according to the sdramcapacity and start address of your development board, the sdramcapacity of our development board is 32 MB, the column address width is 9, and the start address is 0x00000000. In this version, the maximum amount of SDRAM has been calculated according to the following design. You do not need to make any changes. In other versions, you need to note the changes in the corresponding areas.

# Definecfg_large_image_len 0x1000000/* largeimage length */

# Defineconfig_mem_size 32/* 128, 64, 32, 16 */

# Define config_mem_add_wdth 9/* 8, 9, 10, 11 */

(5) disable unnecessary parts such as network, real-time clock, and I2C, as long as the corresponding value is set to 0. No error will occur if you do not close it.

(6) finally re-configure the u-boot.ldr generated by the compilation, and download to the Development Board that can run, should be able to see the serial port returned U-boot successfully run information. Then you can run the U-boot command to test whether the transplantation is successful.

III, UClinux Transplantation

Also use the official BF533-stamp as a module for porting. You can use U-boot to download the CPU clock, SDRAM, baud rate, and other settings to run uClinux in the SDRAM. However, the generated uimage file occupies 3 MB space, while ms531 only has 2 MB of Flash space. Because the official support for sound and image drives is completely unnecessary, it is necessary to cut. Specific operations include the following steps:

(1) enter the uClinux-Dist directory and enter the following command: # Make menuconfig; you can also use make xconfig to enter the graphical settings. Note that if you have compiled it before, makeclean should be used first.

The first compilation will show several options that support usb otg. You don't need to worry about it. The following page is displayed to start cutting uClinux.

In the vendor/product selection, select the manufacturer and template, you can also create a template in the vendor folder, here directly use the BF531-stamp template with Adi. You can also create an ms531 folder in the vendor folder, and the settings will be saved in the folder.

In kernel/library/defaults selection, select customize kernelsetting and customizevendor/user setting. Because this is the two parts we need to trim, if not selected, use the default configuration of the BF533-stamp.

Then exit and choose Save. The compilation will automatically proceed. The next step will go to the Customize kernelsetting interface, as shown in.

(2) blackfinprocessor options must be modified. The CPU is changed to bf531, the clock is 20 m, and port is changed to 115200 by default, the SRAM size is 32, and the address width is 9. Other options can be changed by default. Note that if re-programclocks while kernel boots? If this option is selected, the PLL settings will be changed again after uClinux is started. If this option is not selected, the PLL settings will be set based on the U-boot principle.

Go back to the original interface and cut unnecessary items. You can judge based on your actual situation. Now, we mainly need to cut the number in the kernel. If you don't know what it means, don't cancel it. Now we have removed all the options in busoptions and removed networking. In addition, the device drivers does not need to cancel the drive, and the file system does not need to support the yaff2 file system. Security performance does not need to be supported and all is canceled, and then save.

(3) The next step is to cut customervendor/user, which is easy to understand. Almost all applicationsProgram, You do not need to cancel it directly. If you need it, add it. Do not cancel the init option in coreapplication. In addition, if the network is canceled, remove the syslog support in busybox and cancel the following syslog application options. Otherwise, the compiled kernel will always have a SYSLOG error. We recommend that you select zmodenutils in miscellaneousapplication. This option is not selected by default. Because the default Development Board has a network port, you can use TFTP to transfer files, here, we can only use the Classic serial transmission protocol zmodem. You can directly transfer compiled files to the system for debugging in the Super Terminal. In addition, Blackfin also provides many testing programs and applications, which can be selected based on the actual situation or size.

(4) Note that if an error occurs in the user folder during system compilation, the corresponding library does not exist, or the corresponding support is canceled in the kernel options, or the corresponding patch is not applied, you can install a package patch on your own. If you cannot fix the package, you can compile it without adding this application. If you still do not know which option is used, open the makefile in the user folder to block the application with the corresponding error.

(5) After saving and exiting, enter the make command to compile the entire system. In the image folder, The uimage file we need is obtained. You will get other types of files like U-boot.

(6) other commonly used compilation commands are as follows:

# Make Linux; Compile the Kernel File

# Make romfs; Compile the root file system

# Make image; generate a uimage Image File

IV, Hello, China !

Write the most classic program "Hello, China! ", This will not ask Baidu to go. Then compile with the following command:

# Bfin-uClinux-gcc-wl,-elf2flt hello. C-O hello;

Generate FLT executable files in uClinux. Note that you cannot directly compile bfin-uClinux-GCC. In this case, the prompt "elf: Not Found" is displayed when generating the executable file ".

Other available compilation tools include bfin-Linux-uclibc-GCC and bfin-Linux-uclibc-strip. For details, refer to the official documentation.

Generate an executable file and download it to the system through the terminal. This time, we will use the zmodem protocol added above. As shown in:

Select the file to be sent, select "zmodem and crash recovery" for the protocol, and then click send directly. The lsz command is automatically called to send the file, which is not required here. The file is directly sent to the directory you are currently in. Then run the following command:

# Chmod777 hello;

After changing the file properties, you can directly run the program. Note that the system has been copied to the SDRAM, so the program will not be saved after the power is down. Well, a system is built up here.

V, UClinux Add Application

The compiled system will generate the root file system in the current directory. Make directly runs the make romf command, so the Compilation Program is directly added to the file system, you can change the/etc/rc file and the user program runs automatically after it is powered on.

Compile and write the LED. c file program as shown in the appendix. Of course, do not remove the gpio driver from the kernel cut. You can check whether there is a pf0-pf15 in the/dev file of the system. Compile the bfin-uClinux-GCC command to generate an executable file. Copy to the/home folder in the romf folder. Then, modify the RC file in/etc and add the following code:

Sleep3; if there is a network in front and the following program is based on the network, a certain amount of waiting time is required. If not, you can skip this step.

/Hom/led &

Then return to the main directory and run the make image command again to generate the uimage file, and then run the command in flash.

This is only a personal method that has been successfully run. It only applies to a small amount of code and is easy to implement. Other methods are also available on the official website or on the Internet. As shown in the following figure.

Appendix 1

Ms531 Preview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.