Porting u-boot-2015.10 to JZ2440 Development Board (v)--set NAND partition, environment variable save address and other default parameters

Source: Internet
Author: User

In the download kernel or file system, we can directly in the command to state the specific address burned to nandflash, but the more troublesome, we can give Nandflash partition, so you can directly write burn to that partition on the line, more convenient. How to set it up? First we enter the Mtdparts command in Uboot, see the default partition, the result is mtdids not defined, no default present. Search "Mtdids not Defined", navigate to Common/cmd_mtdparts.c's Mtdparts_init function, the analysis found is Mtdids_default is empty, Mtdids and another important variable, mtdparts, are defined as follows:

1 #ifDefined (Mtdids_default)2 Static Const Char*ConstMtdids_default =Mtdids_default;3 #else $ Static Const Char*ConstMtdids_default =NULL;5 #endif6 7 #ifDefined (Mtdparts_default)8 Static Const Char*ConstMtdparts_default =Mtdparts_default;9 #elseTen Static Const Char*ConstMtdparts_default =NULL; One #endif

Therefore, we need to define the Mtdids_default,mtdparts_default two macros in Smdk2410.h. How to define these two macros, there are examples in the comments in CMD_MTDPARTS.C:

/**/

In conjunction with examples and other development Board configuration files, we define the following:

1 #define Mtdids_default "          nand0=s3c2440-nand.0"2#define mtdparts_default        "mtdparts= s3c2440-nand.0:256k (bootloader), "\       3                                 "128k (params), 2m (kernel),"  \                        4                                  "-(ROOTFS)"

Save, compile, burn write. Execute mtdparts command After starting U-boot, prompt

Mtdparts variable not set, see ' Help Mtdparts '
No partitions defined

Execute the Help mtdparts command and discover

Mtdparts default-reset partition table to defaults

You may want to execute mtdparts default and no longer prompt for errors after execution. So, we execute such a command in the code. In Board_r.c's Run_main_loop, modify the following:

 static  int  Run_main_loop (void       #endif  /*   Main_loop () can return to retry autoboot, if so just run it again  */  Run_command ( "  mtdparts default  , 0   for   (;;)     Main_loop ();  return  0 ; 

After compiling the burn write, start u-boot execute mtdparts command, no longer prompt the error, directly list the partition, we try to kernel partition to burn write Uimage, and to start the kernel, you must set the default parameters Bootargs and Bootcmd, According to the environment.h file, we want to set up Config_bootargs and Config_bootcommand two macros in Smdk2410.h, as follows

#define Config_bootargs        "noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttysac0"#define Config_ Bootcommand    "NAND read.jffs2 0x30007fc0 kernel; BOOTM 0x30007fc0"

Compile burn write, start u-boot, use tftp to download uimage to 30000000, use command NAND erase.chip;nand write 30000000 kernel 1c08e8, download kernel to kernel partition successfully, And it's ready to start the kernel.

Before we set the environment variables, we did not execute the Save command because we have not set the environment variable to save the address. Search the Saveenv function and discover that both ENV_FLASH.C and ENV_NAND.C have this function, by viewing common/makefile discovery to include Config_env_is_in_nand by defining ENV_NAND.C, The environment variables are then saved on the Nandflash. Also set the Cmd_saveenv,config_env_range,config_env_offset, such as macro, modify the configuration file as follows: Not to be continued ...

Porting u-boot-2015.10 to JZ2440 Development Board (v)--set NAND partition, environment variable save address and other default parameters

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.