Uboot port records

Source: Internet
Author: User
Tags network function srec
The entire uboot porting process can be divided into three phases: 1. Porting A uboot that can be started from Nor flash is the simplest uboot, which can be run in Nor flash. 2. Port the uboot file that supports the Nand flash Driver to the Nand flash Driver. You can operate the Nand flash file on the uboot command line. however, it cannot be started from Nand flash and can only be run in Nor flash. 3. Port the uboot that can be started from Nor flash and store it in Nand flash, and set to start uboot from Nand flash. transplantation can be performed in three phases to clarify the porting process and principle of uboot, and reduce the difficulty and scope of solving the problem. first, we will introduce how to port the uboot that can be started from Nor flash. this stage is relatively simple. It is the simplest uboot to run in Nor flash. there is no need to modify too many things. The procedure is as follows: test whether the default smdk2410_config configuration can run properly on your board. 1. Compile uboot1.1.4.

#make smdk2410_config #make ARCH=arm

Note: When compiling a platform for arm, uboot uses arm-linux-gcc by default. if the name of the cross compiler is different, you must modify it in Makefile. Two errors will occur. error Message 1: Maid: Invalid option 'Abi = apcs-gnu 'make [1]: *** [hello_world.o] Error 1 make [1]: leaving directory '/root/u-boot-1.1.4/examples' make: *** [examples] Error 2 solution: the Error file is/cpu/arm920t/config. mk: Change PLATform_CPPFLAGS + = $ (call cc-option,-mapcs-32,-mabi = apcs-gnu) to: PLATform_CPPFLAGS + = $ (call cc-option,-mapcs-32, $ (call cc-option,-mabi = apcs-gnu,) error message 2: make [1]: *** No rule to make target 'Hello _ world. srec ', needed by 'all '. stop. make [1]: Leaving directory '/work/src/u-boot-1.1.4/examples' solution: Open examples/Makefile
Change %. srec: % in Makefile in the example folder to %. srec: %. o 126th
%. Bin: % changed to %. bin: %. o 2. If compilation is successful, a u-boot.bin file will be generated under uboot source code. Burn this file to nor flash. Note: by default, the smdk2410_config of u-boot does not support nandflash and can only be run in nor flash. Therefore, it can only be burned to nor flash for running. If it is burned to nandflash, it cannot be run. 3. Refer to the Development Board materials and set the jumper to start from nor flash. The startup information is as follows:

U-Boot 1.1.4 (Dec 30 2007 - 23:25:02) U-Boot code: 33F80000 -> 33F9696C BSS: -> 33F9AC58 RAM Configuration: Bank #0: 30000000 64 MB *** Warning - bad CRC, using default environment Flash: 512 kB In: serial Out: serial Err: serial

Three problems are found: 1) The Development Board buzzer keeps ringing at startup. It is suspected that the GPIO port corresponding to the buzzer of my Development Board does not match the IP address of the GPIO port of smdk2410, which leads to a false value during startup and keeps ringing. 2) The problem of Warning-bad CRC and using default environment is that the variables are not set when uboot is used for the first time. If you save the settings, they will not appear. 3) Flash: 512 kB my board Nor flash is 1 MB, and here it shows kB 4. next we will modify the uboot source code. Here we will modify the source code based on the hardware of the Development Board based on the source code of smdk2410 (mainly the configuration file include/configs/smdk2410.h ), and solve problems 1 and 3. If you are not familiar with the hardware board, refer to datasheet 2410 and the hardware information provided by the Development Board supplier. From the first startup of uboot on the Development Board, the problem is not too big. First, modify include/configs/smdk2410.h. It contains many macros set for the target board. The content of smdk2410.h and the location to be modified are as follows:

# Define CONFIG_BOOTDELAY 3/* # define CONFIG_BOOTARGS "root = ramfs devfs = mount console = ttySA0, 9600" */# define CONFIG_ETHADDR 08: 00: 3e: 26: 0a: 5b # define CONFIG_NETMASK 255.255.255.0 # define 255.192.168.1.103 # define CONFIG_SERVERIP 192.168.1.102 # define CONFIG_BOOTFILE "uImage" # define CONFIG_BOOTCOMMAND "tftp 30000000 uImage \; bootm 30000000" // This command runs after bootdelay
// These macros correspond to the uboot variables, that is, the variables printed by printenv in the uboot command line. You can set it here (defined as the default value) or use the setenv command after uboot is started.

#define CFG_PROMPT "ARMSYS2410 # " /* Monitor Command Prompt */ #define CFG_LOAD_ADDR 0x33000000 /* default load address */ #define CONFIG_NR_DRAM_BANKS 1 /* we have 1 bank of DRAM */ #define PHYS_SDRAM_1 0x30000000 /* SDRAM Bank #1 */ #define PHYS_SDRAM_1_SIZE 0x04000000 /* 64 MB */

 

Solution 3: change # define CONFIG_AMD_LV400 1/* uncomment this if you have a LV400 flash */# if 0 # define CONFIG_AMD_LV800 1/* uncomment this if you have a LV800 flash */# endif: # define CONFIG_AMD_LV800 1/* uncomment this if you have a LV800 flash */# if 0 # define CONFIG_AMD_LV400 1/* uncomment this if you have a LV400 flash */# endif pay attention to the following two location: # ifdef CONFIG_AMD_LV800 # define PHYS_FLASH_SIZE 0x001000 00/* 1 MB */solve the problem during u-boot startup. 3. The Nor Flash size is 512 kB, because the correct Nor flash model is not selected. # Define pai_max_flash_sect (19)/* max number of sectors on one chip */# define pai_env_addr (pai_flash_base + 0x0F0000) /* addr of environment */macro _ env_addr defines the address for storing the uboot variable, which is converted to 1 mb-64kb = 960KB, and the actual uboot compiled size is only about KB, even if the newly compiled uboot file is installed in Nor flash, the uboot variable previously set will not be affected. # Endif Note: You can check the functions of these macros in README of u-boot. 5. solve the Problem of BUZZER sound always view ARMSYS2410-B baseboard circuit diagram, In the Reset Singal module can see the BUZZER (BUZZER) control port connected to the TOUT1 pin, and low level sound. The GPB1 port is reused by the s3c2410 Datasheet. Therefore, you only need to assign values to the GPBDAT register at uboot startup and disable the BUZZER. Modify smdk2410.c # vi board/smdk2410/smdk2410.c find the board_init () function in gpio-> GPBUP = 0x000007FF; Add the following content:

/*******stop beep******/ gpio->GPBDAT &= ~0x00000002; //Open BUZZER delay (5000000); //BUZZER Delay Time gpio->GPBDAT |= 0x00000002;

6. recompile # make clean # make ARCH = arm 7. burn u-boot.bin to nor flash Boot information: U-Boot 1.1.4 (Jan 3 2008-23:11:07) U-Boot code: 33F80000-> 33F96DC4 BSS:-> 33F9B0E8 RAM Configuration: Bank #0: 30000000 64 MB Flash: 1 MB In: serial Out: serial Err: serial Hit any key to stop autoboot: 0 ARMSYS2410 # uboot transplantation record 2 transplantation can be started from the Nor flash uboot please refer to the uboot transplantation series of "One Of The uboot transplantation record" http://blog.chinaunix.net/u2/60011/showart.php? Id = 1005057 the following section describes how to port uboot that supports the Nand flash Driver. with support for the Nand flash Driver, you can operate the Nand flash on the uboot command line. however, it cannot be started from Nand flash and can only be run in Nor flash. the following section describes how to enable Nandflash. The following describes the detailed steps: 1. Enable Nandflash driver to enable uboot to support the nand driver. In smdk2410.h, you must uncomment the comment of ipv_0000_nand to enable the nandflash function. Modify as follows: /* include/configs/smdk2410.h */# define CONFIG_COMMANDS \ | */\ pai_1__reginfo | \ pai_1__date | \ pai_1__elf) 2. add the nand_init () function Uboot to initialize the NAND Flash part of the SMDK2410 board. the start_armboot function in c has the following sentence: # if (CONFIG_COMMANDS & CFG_CMD_NAND) puts ("NAND:"); nand_init ();/* go Init the NAND */# endif. Because the macro "cmd_init_nand" is opened earlier, uboot will query the nand_init () function during compilation. The nand_init function is not defined in any source file in the board/smdk2410 directory. Therefore, we need to add this function and the underlying operations involved in this function. Here we can refer to the nand_init function of the VCMA9 Board. The VCMA9 Board is a Board with the S3C2410, so this part of the operation is very similar to the SMDK2410 Demo Board. Most code can be copied. Analyze the nand_init () function of the VCM9 board and find that you need to copy the following content: first, copy the following code in board/mpl/vcma9/vcma9.h to the front of do_nand function in common/cmd_nand.c. /* Dongas-support nand driver */# if (CONFIG_COMMANDS & cfg_assist_nand) typedef enum {NFCE_LOW, NFCE_HIGH} NFCE_STATE; static inline void NF_Conf (2010conf) {S3C2410_NAND * const nand = S3C2410_GetBase_NAND (); nand-> NFCONF = conf;} static inline void NF_Cmd (u8 cmd) {S3C2410_NAND * const nand = S3C2410_GetBase_NAND (); nand-> NFCMD = cmd;} static inline void nf_0000w (u8 cmd) {NF_Cmd (cmd); udelay (1);} static inline void NF_Addr (u8 addr) {S3C2410_NAND * const nand = S3C2410_GetBase_NAND (); nand-> NFADDR = addr;} static inline void NF_SetCE (NFCE_STATE s) {S3C2410_NAND * const nand = S3C2410_GetBase_NAND (); switch (s) {case NFCE_LOW: nand-> NFCONF & = ~ (111); break; case NFCE_HIGH: nand-> NFCONF |=( 111); break ;}} static inline void NF_WaitRB (void) {S3C2410_NAND * const nand = S3C2410_GetBase_NAND (); while (! (Nand-> NFSTAT & (10);} static inline void NF_Write (u8 data) {S3C2410_NAND * const nand = S3C2410_GetBase_NAND (); nand-> NFDATA = data ;} static inline u8 NF_Read (void) {S3C2410_NAND * const nand = S3C2410_GetBase_NAND (); return (nand-> NFDATA);} static inline void NF_Init_ECC (void) {S3C2410_NAND * const nand = S3C2410_GetBase_NAND (); nand-> NFCONF |=( 112);} static inline u32 NF_Read_ECC (void) {S3C2410_NAND * const nand = S3C2410_GetBase_NAND (); return (nand-> NFECC );} # endif/* dongas-support nand driver-end */then copy the following code from board/mpl/vcma9/vcma9.c to common/cmd_nand.c. /* Dongas-support nand driver * // ** NAND flash initialization. */# if (CONFIG_COMMANDS & CFG_CMD_NAND) extern ulong nand_probe (ulong physadr); static inline void NF_Reset (void) {int I; NF_SetCE (NFCE_LOW); NF_Cmd (0xFF ); /* reset command */for (I = 0; I 10; I ++);/* tWB = 100ns. */NF_WaitRB ();/* wait 200 ~ 500us; */NF_SetCE (NFCE_HIGH);} static inline void NF_Init (void) {# if 0/* a little bit too optimistic */# define TACLS 0 # define TWRPH0 3 # define TWRPH1 0 # else # define TACLS 0 # define TWRPH0 4 # define TWRPH1 2 # endif NF_Conf (115) | (014) | (013) | (112) | (111) | (TACLS8) | (TWRPH04) | (TWRPH10 )); /* nand-> NFCONF = (1/* 1 1 1, 1 xxx, r xxx, r xxx * // * En 512B 4 step ECCR nFCE = H tACLS tWRPH0 tWRPH1 */NF_R Eset ();} void nand_init (void) {S3C2410_NAND * const nand = S3C2410_GetBase_NAND (); NF_Init (); # ifdef DEBUG printf ("NAND flash probing at 0x %. 8lX \ n ", (ulong) nand); # endif printf (" % 4lu MB \ n ", nand_probe (ulong) nand)> 20 );} # endif/* dongas-support nand driver-end */In addition, add # include in front of pai_nand.c. Otherwise, the ERROR "S3C2410_NAND" Undeclared will occur during compilation! Finally, copy the following code from include/configs/VCMA.9 TO include/configs/smdk2410.h. /* Dongas-support nand driver * // * ------------------------------------------------------------------------- * NAND flash settings */# if (CONFIG_COMMANDS & CFG_CMD_NAND) # define limit 1/* Max number of NAND devices */# define SECTORSIZE 512 # define ADDR_COLUMN 1 # define ADDR_PAGE 2 # define ADDR_COLUMN_PAGE 3 # define limit 0x00 # define NAND_MAX_FLOORS 1 # define NAND_MA X_CHIPS 1 # define sequence (nand) NF_WaitRB () # define sequence (nand) NF_SetCE (NFCE_HIGH) # define sequence (nand) NF_SetCE (NFCE_LOW) # define WRITE_NAND_COMMAND (d, adr) NF_Cmd (d) # define WRITE_NAND_COMMANDW (d, adr) nf_0000w (d) # define WRITE_NAND_ADDRESS (d, adr) NF_Addr (d) # define WRITE_NAND (d, adr) NF_Write (d) # define READ_NAND (adr) NF_Read ()/* the following functions are NOP's bec Ause S3C24X0 handles this in hardware */# define NAND_CTL_CLRALE (nandptr) # define NAND_CTL_SETALE (nandptr) # define aggregate (nandptr) # define NAND_CTL_SETCLE (nandptr) # define CONFIG_MTD_NAND_VERIFY_WRITE 1 # define CONFIG_MTD_NAND_ECC_JFFS2 1 # endif/* CONFIG_COMMANDS & cfg_assist_nand * // * dongas-support nand driver-end */3. re-compile uboot # make ARCH = arm 4. to test the uboot supported by the Nand driver, let's test the newly compiled uboot with the Nand driver. Whether the uboot supported by the driver is useful. Since we have compiled the NOR version of uboot and installed it in nor flash, we do not need to re-install the newly compiled uboot to Nor Flash. You can directly use the serial port transmission function provided by uboot in Nor to transmit the compiled uboot (with nand driver support) to the sdram through the serial port for testing, this method is much more efficient and fast. There are two transmission methods: 1) Use the loadb command to load the uboot. bin loadb command to download the binary file from the serial port to the memory of the Development Board using the kermit protocol. The default download is 0x33000000. Of course, you can change it to another address. For example, loadb 30000000 is downloaded to 0x30000000. First, execute the loadb command # loadb # Ready for binary (kermit) download to 0x33000000 at 115200 bps in uboot command line mode... then select the Super Terminal menu: Transfer> send file, the file name select compiled U-Boot.bin, protocol select Kermit send, you can see the sending progress. Note: The secure CRT cannot be used here. It is not found that it supports the kermit protocol. You can only use the Super Terminal or mini-com that comes with windows to end sending. The following message is displayed: # Total Size = 0x00019a14 = 104980 Bytes # Start Addr = 0x33000000 after transmission, you can test whether the newly compiled uboot is useful: ARMSYS2410 # go 30000000 note: the go command can directly execute the program on the specified memory address, for example, the uboot that just downloaded to 0x30000000 that supports the NAND driver. 2) You can also use the tftp protocol to download uboot to the specified address, for example, 0x30000000, and then run the go command. The effect is the same. It is faster than the previous method, provided that the network function is available. Of course, because my board uses CS8900 Nic, smdk2410 by default is supported, so you can use it directly. (For the usage of tftp, please refer to the relevant information) # tftpboot 30000000 u-boot.bin # go 30000000 execute the go command to start the uboot in the sdram, if the "NAND: 64MB" line appears, then congratulations, basically, you can determine that your Nand driver has been successfully transplanted. My startup information is as follows: ARMSYS2410 # go 30000000 # Starting application at 0x30000000... u-Boot 1.1.4 (Jan 9 2008-00:08:10) U-Boot code: 33F80000-> 33F9A04C BSS:-> 33F9E3E8 RAM Configuration: Bank #0: 30000000 64 MB Flash: 1 mb nand: 64 MB ------------- this line is added! Happying! In: serial Out: serial Err: serial Hit any key to stop autoboot: 0 ARMSYS2410 nand # confirm, enter help, we found that there is a set of nand commands more than the previous NOR version of U-Boot! # Help mw-memory write (fill) nand-NAND sub-system --------- the newly added Nand command nboot-boot from NAND device ...... Help nand: ARMSYS2410 nand # help nand info-show available nand devices NAND device [dev]-show or set current device nand read [. jffs2 [s] addr off size nand write [. jffs2] addr off size-read/write 'SIZE' bytes starting at offset 'off' to/from memory address 'addr 'nand erase [clean] [off size]-erase 'size 'bytes from offset' off these commands can be used to read and write Nandflash! Enter nand info to view the NandFlash chip information: ARMSYS2410 # nand info Device 0: Samsung unknown 64 Mb at 0x4e000000 (64 MB, 16 kB sector) it indicates that our Nand driver has been transplanted successfully. (The Nand model is displayed as unknown, which can be used by default.) The reason is that the uboot nand list does not contain K9S1208 64 MB. You can add it by yourself, add the nand flash memory chip model and modify the following struct value assignment in/include/linux/mtd/nand_ids.h: static struct nand_flash_dev nand_flash_ids [] = {...... {"Samsung K9F1208U0B", NAND_MFR_SAMSUNG, 0x76, 26, 0, 3, 0x4000, 0 },.......} in this way, operations on the nand flash memory chip can be correctly performed. Of course, it does not matter if you do not add it. You can also use the default parameter to operate the NAND. After the test is successful, we will burn the new uboot with Nand driver support to Nor. You do not need to use the tool to install the program. You can use the cp Command provided by uboot to copy the program to Nor flash. Powerful, huh, huh ~ It is much faster than sjflash. Since uboot provides so many good functions, it would be a pity if you don't need them! :) 1) first look at the NOR Flash situation: ARMSYS2410 nand # flinfo Bank #1: AMD: 1x Amd29LV800BB (8 Mbit) Size: 1 MB in 19 Sectors Sector Start Addresses: 00000000 (RO) 00004000 (RO) 00006000 (RO) 00008000 (RO) 00010000 00020000 00030000 00040000 00050000 00060000 00070000 00080000 000A0000 000B0000 000C0000 000D0000 000E0000 000F0000 (RO) there are a total of 19 sector, of which the first five sector totaling kb have U-Boot programs, which are write-protected (RO ). To enable write, you must first remove write protection. Note: The flinfo command is used to display the current flash (nor) information. 2) Remove the write protection of the first five sector. The size is kb, enough for our uboot. ARMSYS2410 # protect off 0 1 ffff Un-Protected 5 sectors 3) Check again: ARMSYS2410 nand # flinfo Bank #1: AMD: 1x Amd29LV800BB (8 Mbit) Size %

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.