Setup of at91rm9200 Pilot Program (iii) --- transplantation of U-Boot1.1.4 on at91rm9200

Source: Internet
Author: User

Bootloader OverviewBoot Loader is a small program that runs before the operating system kernel runs. Through this bootloader, We initialize the hardware device, prepare the address space and interrupt number for the hardware device, and establish a memory space ing to bring the system's hardware and software environment to a suitable state. The at91rm9200 processor can be started from external sources, such as flash, EEPROM, and dataflash. The other is guided by the internal bootrom curing code. Our arm board is directly started by downloading from the host to the flash of the Target Board through the JTAG interface. After the system powers on, our CPU gets its first command from 0x00000000, and our flash is mapped to this address. The CPU first executes the bootloader program we burn on flash and uses it to guide the Linux system. U-boot is a general bootloader that can be easily transplanted to other hardware platforms. Now it has become the de facto standard for the ARM platform. You can download the U-boot source code package from the SourceForge website. We use U-Boot1.1.4 as the bootloader we port. U-Boot1.1.4 PortU-boot modification. Because our board is different from the DK board of ATMEL, we need to modify the U-boot code for our hardware, especially the Flash Driver. 1) Modify board/at91rm9200dk/config. mktext_base = 0x21f00000 to load U-boot into the high-end part of 32msdram, that is, leave the space of the highest-end 1 MB to the U-boot code. 2) Modify include/configs/at91rm9200dk. h to modify the flash and SDRAM sizes:

# Define phys_sdram_size 0x2000000/* 32 megs */# define phys_flash_size 0x200000/* 2 megs main flash */

The following environment variables are also defined:

# Define config_default_environment
# Define config_boardname "at91rm9200dk" # define config_ethaddr "00: 11: 22: 33: 44: 55 "# define config_ipaddr" 192.168.1.100 "# define config_serverip" 192.168.1.1 "// # define config_gatewayip" 192.168.18.1 "# define config_bootcommand" TFTP 0x20008000 zimage; TFTP 0x20410000 ramdisk; go 0x20008000 "# define config_default_kernel" 2.6.17"

We can see from the above that our board's IP address is 192.168.1.100, while our host's IP address is 192.168.1.1, and our Nic Mac is: 00: 11: 22: 33: 44: 55. 3) modify the flash drive borad/at91rm9200dk/flash. C. This file has many modifications. 1. The first is the definition of orgdef, and the current flash is added.

Orgdef orgsstvf6401b [] ={{ 2048,4*1024},/* 2048*64 Kbytes sectors */};

Modify the function flash_identification (flash_info_t * info) to display the correct information.

Void flash_identification (token * info) {volatile 2010manuf_code, device_code, add_device_code; identifier = flash_code1; identifier = flash_code2; identifier = identifier; manuf_code = * (volatile 2010*) pai_flash_base; device_code = * (volatile 2010*) (pai_flash_base + 2); add_device_code = * (volatile 2010*) (pai_flash_base + (3 <1); mem_flash_addr1 = flash_code1; mem_flash_addr2 = flash_code2; mem_flash_addr1 = id_out_code;/* vendor type * // * If (Info-> flash_id = atm_manufact & flash_vendmask) {printf ("Atmel :");} */If (Info-> flash_id = sst_manufact & flash_vendmask) // zzl061206 {printf ("SST:") ;}/ * Atmel identify */If (device_code & flash_typemask) ==( atm_id_bv1614 & flash_typemask) {If (add_device_code & flash_typemask) == (callback & flash_typemask) {Info-> flash_id | = atm_id_bv1614a & flash_typemask; printf ("at49bv1614a (16 Mbit)/n");} else {/* at49bv1614 flash */info-> flash_id | = atm_id_bv1614 & flash_typemask; printf ("at49bv1614 (16 Mbit) /n ") ;}} else if (device_code & flash_typemask) ==( atm_id_bv6416 & flash_typemask) {Info-> flash_id | = atm_id_bv6416 & flash_typemask; printf ("at49bv6416 (64 Mbit)/n");}/* SST identify */ Else if (device_code & flash_typemask) = (sst_id_xf6401b & flash_typemask) // zzl061206 { Info-> flash_id | = sst_id_xf6401b & flash_typemask; Printf ("vf6401b (64 Mbit)/n "); }}

2. Modify the initialization flash function ulong flash_init.

(Void) ulong flash_init (void) {int I, j, k; unsigned int flash_nb_blocks, sector; unsigned int start_address; orgdef * porgdef; ulong size = 0; for (I = 0; I <cfg_max_flash_banks; I ++) {ulong flashbase = 0; flash_identification (& flash_info [I]); If (flash_info [I]. flash_id & flash_typemask) = (Export & flash_typemask) {porgdef = orgat49bv16x4; flash_nb_blocks = sizeof (outputs)/sizeof (orgdef);} else if (flash_info [I]. flash_id & flash_typemask) = (Photo & flash_typemask) {/* at49bv1614a flash */porgdef = photo; flash_nb_blocks = sizeof (orgat49bv16x4a)/sizeof (orgdef );} else if (flash_info [I]. flash_id & flash_typemask) = (Bytes & flash_typemask) {/* at49bv6416 flash */porgdef = bytes; flash_nb_blocks = sizeof (orgat49bv6416)/sizeof (orgdef );} /* Zzl */ Else if (flash_info [I]. flash_id & flash_typemask) = (Sst_id_xf6401b & flash_typemask )) { Porgdef = orgsstvf6401b; Flash_nb_blocks = sizeof (orgsstvf6401b)/sizeof (orgdef ); }Else {flash_nb_blocks = 0; porgdef = orgat49bv16x4;} flash_info [I]. sector_count = flash_number_sector (porgdef, flash_nb_blocks); memset (flash_info [I]. protect, 0, flash_info [I]. sector_count); if (I = 0) flashbase = phys_flash_1; else panic ("configured too prepare Flash banks! /N "); sector = 0; start_address = flashbase; flash_info [I]. size = 0; For (j = 0; j <flash_nb_blocks; j ++) {for (k = 0; k <porgdef [J]. sector_number; k ++) {flash_info [I]. start [sector ++] = start_address; start_address + = porgdef [J]. sector_size; flash_info [I]. size + = porgdef [J]. sector_size ;}} size + = flash_info [I]. size; If (flash_info [I]. flash_id & flash_typemask) = (atm_id_bv6416 & flash_typemask) {/* at49bv6416 flash * // * zzl * // * unlock all sectors at reset */For (j = 0; j <flash_info [I]. sector_count; j ++) {flash_unlock_sector (& flash_info [I], j) ;}}/* protect binary Boot Image */flash_protect (flag_protect_set, pai_flash_base, pai_flash_base + pai_boot_size-1, & flash_info [0]);/* protect environment variables */flash_protect (values, values, 1__env_addr + 1__env_size-1, & flash_info [0]); /* protect u-boot gzipped image */flash_protect (flag_protect_set, pai_u_boot_base, pai_u_boot_base + pai_u_boot_size-1, & flash_info [0]); Return size;

3. Modify the flash_erase () function and comment out the flash detection type because it has previously been detected.

/* First look for protection bits * // * zzl 20061206 if (Info-> flash_id = flash_unknown) return err_unknown_flash_type; If (s_first <0) | (s_first> s_last) {return err_inval;} If (Info-> flash_id & flash_vendmask )! = (Atm_manufact & flash_vendmask) {return err_unknown_flash_vendor ;}*/

However, a problem occurs here. After compilation, the IP address is 0.192.168.1 and the serverip address is 0.192.168.1. Modifies the function used to obtain the IP address in net/net. C.

Ipaddr_t getenv_ipaddr (char * var) {/* zzl */Char tmp_str [64]; strcpy (tmp_str, getenv (VAR); If (isxdigit (* tmp_str )) /* test whether the environment variable character is in hexadecimal format. If yes, it starts with the first character and 4 bytes. If not, it starts with the second character. */Return (string_to_ip (tmp_str); else return (string_to_ip (tmp_str + 1);/* Old Code return (string_to_ip (getenv (VAR ))); */} re-compile # Make distclean # Make at91rm9200dk_config # Make all

After the compilation is successful, the binary file of the u-boot.bin is obtained, that is, the executable image file, which is burned into flash by using the simulator through JTAG. The Board is powered on again, and U-boot is started successfully. (Note: u-boot1.1.4has been compressed into u-boot.gz. Directly burn the 0 address of flash, you can start it and enter U-boot .)

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.