u-boot transplantation (13)---Code modification---Cutting and environment variables 2

Publisher:HarmonySpiritLatest update time:2023-06-27 Source: elecfansKeywords:u-boot Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Error handling

  An error was encountered in the previous section:

  

  Print this:

  

  It was found that none of the network parameters we wrote statically in jz2440.h were written.

  dm9000 address not set. The address of dm9000 is not set.

  

  There are two functions corresponding to this:

  static int eth_pre_unbind(struct udevice *dev) 和 int eth_write_hwaddr(struct eth_device *dev, const char *base_name, int eth_number)

  The two functions here correspond to the macro CONFIG_DM_ETH. Search in the file to see what this macro defines:

  

  If there is no setting in config, the latter function should be run. The latter function is to set the hardware address.

  The code for printing the address is as follows:


1 #ifdef CONFIG_NET_RANDOM_ETHADDR

2         net_random_ethaddr(dev->enetaddr);

3         printf("nWarning: %s (eth%d) using random MAC address - %pMn",

4                dev->name, eth_number, dev->enetaddr);

5 #else

6         printf("nError: %s address not set1.n",

7                dev->name);

8         return -EINVAL;

9 #endif


env_enetaddr is obtained from the eth_getenv_enetaddr_by_index function.


1 eth_getenv_enetaddr_by_index(base_name, eth_number, env_enetaddr);

3 int eth_getenv_enetaddr_by_index(const char *base_name, int index,

4 flying *enetaddr)

5 {

6 char enetvar[32];

7     sprintf(enetvar, index ? "%s%daddr" : "%saddr", base_name, index);

8     return eth_getenv_enetaddr(enetvar, enetaddr);

9 }


From several functions, we can know that if our dev->enetaddr is 0, the error message will be printed.


  I tried several methods but failed to set it up successfully. I will put it here first and do other work.

2. Nand points

  Enter the mtdparts command in u-boot:

  

  

  Macros defined in jz2440.h:

  Define the macro CONFIG_CMD_MTDPARTS to open the mtdparts command

  Modify the run_main_loop function:

  

  The function of the mtdparts_init() function is to construct partitions, which are represented by arrays.

  Check the setting partitions in other places and write them as follows:

  

  Compile and run, the results are as follows:

   

  Here's a reminder: mtdparts variable not set, see 'help mtdparts' no partitions defined

  This is because there are no parameters and the partitions have been printed below.

  Execute two commands to create a partition, as follows:

  

  Wipe partition:

  

  Add code to automatically execute the two commands for the partition:


 1 static int run_main_loop(void)

 2 {

 3 #ifdef CONFIG_SANDBOX

 4     sandbox_main_loop_init();

 5 #endif

 6 // mtdparts_init(); /* Partition command initialization*/

 7 run_command("mtdparts default",0); /* Automatically execute partition commands*/

 8     /* main_loop() can return to retry autoboot, if so just run it again */

 9     for (;;)

10         main_loop();

11     return 0;

12 }


  Compile and run to see the effect.

3. Add the kernel startup command line

  Just two commands:

  

  Execute bootm to start the kernel


Keywords:u-boot Reference address:u-boot transplantation (13)---Code modification---Cutting and environment variables 2

Previous article:u-boot transplantation (13)---Code modification---Support file system and patch production
Next article:u-boot transplantation (13)---Code modification---Cutting and environment variables 1

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号