Unlike the U-boot high version, the Mtdparts command is not implemented cmd_mtdparts such a separate file.
However, search Uboot can see the following code in CMD_JFFS2.C:
1 U_boot_cmd (2Mtdparts,6,0, Do_jffs2_mtdparts,3 "mtdparts-define Flash/nand partitions\n",4 "\ n"5 "-list partition table\n"6 "mtdparts delall\n"7 "-Delete all partitions\n"8 "mtdparts del part-id\n"9 "-delete partition (e.g. Part-id = nand0,1) \ n"Ten "mtdparts add <mtd-dev> <size>[@<offset>] [<name>] [ro]\n" One A -...
The Mtdpart command is implemented in the Do_jffs2_mtdparts function.
Look again at the Do_jffs2_mtdparts function:
intDo_jffs2_mtdparts (cmd_tbl_t *CMDTP,intFlagintargcChar*argv[]) { if(ARGC = =2{//This first detects the number of parameters, note that we usually use the Mtdpart command without parameters, the following will be modified hereif(strcmp (argv[1],"default") ==0) {setenv ("Mtdids", (Char*) mtdids_default); Mtdids using Mtdids_default setenv ("Mtdparts", (Char*) mtdparts_default); Mtdparts using Mtdparts, the above two default configurations are implemented in the configuration file, such as Smdk2410.h setenv ("Partition", NULL); Mtdparts_init (); return 0; } Else if(strcmp (argv[1],"Delall") ==0) { /*This could be the first run, initialize lists if needed*/Mtdparts_init (); Setenv ("Mtdparts", NULL); /*Devices_init () calls Current_save ()*/ returnDevices_init (); } } ...
Also, at the beginning of the cmd_jffs2.c file, note that there are several macro definitions:
#include <linux/ctype.h>#if (config_commands & CFG_CMD_JFFS2)<cramfs/cramfs_fs.h >#if (config_commands & Cfg_cmd_nand)<linux/mtd/nand_legacy.h>#else /*! Cfg_nand_legacy * *
And
#ifdef Config_jffs2_cmdline /* */#if defined (mtdids_default)staticconstChar *const Mtdids_default = mtdids_default; #else #warning "Mtdids_default not defined!" Static Const Char *const mtdids_default = NULL; #endif
And also
Static int part_validate_nand (structstruct part_info * part) {#if defined ( Config_jffs2_nand) && (Config_commands & Cfg_cmd_nand) /** * *nand;
Here you need to define three macros and a default configuration:
#define Config_jffs2_cmdline 1#define config_jffs2_nand 1#define mtdids_default "Nand0=nandflash0" #define Mtdparts_default "Mtdparts=nandflash0:[email protected" (bootloader), " 128k (params)," "2m (kernel)," "-(Root) "
1 #define 2 CFG_CMD_JFFS2 | \
Above, after compiling through, and can not immediately start the kernel, note the startup parameters at this time:
#define Config_bootcommand "NAND read.jffs2 0x30007fc0 kernel; Bootm 0x30007fc0 " //Because kernel has not been identified
This should be changed to:
#define Config_bootcommand "NAND read.jffs2 0x30007fc0 0x60000 0x200000; Bootm 0x30007fc0 "
Here is the kernel has been burned into the NAND inside, and then use the NAND Read command to read to the 30007FC0 address of the SDRAM, the address of the kernel in the NAND is 0x60000, size is 2M
The Mtdpart command is still not available here because of the problem with the Mtdpart parameter mentioned above
Because we don't use parameters, then:
1 if(ARGC = =2) {2 if(strcmp (argv[1],"default") ==0) {3Setenv"Mtdids", (Char*) mtdids_default);4Setenv"Mtdparts", (Char*) mtdparts_default);5Setenv"Partition", NULL);6 7 mtdparts_init ();8 return 0;9}Else if(strcmp (argv[1],"Delall") ==0) {Ten /*This could be the first run, initialize lists if needed*/ One mtdparts_init (); A -Setenv"Mtdparts", NULL); - the /*Devices_init () calls Current_save ()*/ - returndevices_init (); - } - } + - /*Make sure we is in sync with env variables*/ + if(Mtdparts_init ()! =0) A return 1; at - if(ARGC = =1) { - list_partitions (); - return 0; -}
Then, the following four functions are not executed:
Setenv ("Mtdids", (char *) mtdids_default);
Setenv ("Mtdparts", (char *) mtdparts_default);
Setenv ("Partition", NULL);
Mtdparts_init (); Which, mostly, was not executed by this
Treatment measures: There are two types of
The first one, the parameter parsing that minus, directly execute the Mtdparts_init () function, the code is as follows:
1 intDo_jffs2_mtdparts (cmd_tbl_t *CMDTP,intFlagintargcChar*argv[])2 {3 //by Flinn4Setenv"Mtdids", (Char*) mtdids_default);5Setenv"Mtdparts", (Char*) mtdparts_default);6Setenv"Partition", NULL);7 8 mtdparts_init ();9 if(ARGC = =2) {Ten if(strcmp (argv[1],"default") ==0) { One //setenv ("Mtdids", (char *) mtdids_default); A //setenv ("Mtdparts", (char *) mtdparts_default); - //setenv ("Partition", NULL); - the //mtdparts_init (); - return 0; -}Else if(strcmp (argv[1],"Delall") ==0) { - /*This could be the first run, initialize lists if needed*/ + mtdparts_init (); - +Setenv"Mtdparts", NULL); A at /*Devices_init () calls Current_save ()*/ - returndevices_init (); - } -}
The second, as Vedon does, is added to the MAIN.C main_loop function:
1 #ifdef Config_jffs2_cmdline2 extern intMtdparts_init (void);//Execute the INIT function first3 if(!getenv ("Mtdparts"))4 {5Run_command ("mtdparts Default",0);//Call the default configuration again6 }7 Else8 {9 mtdparts_init ();Ten } One #endif
Both of these options are possible.
Porting the Mtdparts partition of u-boot-1.1.6