Unlike higher versions of u-boot, the mtdparts command does not have a separate file like cmd_mtdparts to implement.
However, if you search for uboot, you can see the following code in cmd_jffs2.c:
1 U_BOOT_CMD(
2 mtdparts, 6, 0, do_jffs2_mtdparts,
3 "mtdparts- define flash/nand partitionsn",
4 "n"
5 " - list partition tablen"
6 "mtdparts delalln"
7 " - delete all partitionsn"
8 "mtdparts del part-idn"
9 " - delete partition (e.g. part-id = nand0,1)n"
10 "mtdparts add
11
12
13 ...
It can be seen that the mtdpart command is implemented in the do_jffs2_mtdparts function.
Look at the do_jffs2_mtdparts function again:
int do_jffs2_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
if (argc == 2) { //Check the number of parameters here first. Note that we usually use the mtdpart command without parameters. We will make modifications here below.
if (strcmp(argv[1], "default") == 0) {
setenv("mtdids", (char *)mtdids_default); //mtdids使用mtdids_default
setenv("mtdparts", (char *)mtdparts_default); //mtdparts uses 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 may be the first run, initialize lists if needed */
mtdparts_init();
setenv("mtdparts", NULL);
/* devices_init() calls current_save() */
return devices_init();
}
}
...
In addition, at the beginning of the cmd_jffs2.c file, note that there are several macro definitions:
#include
#if (CONFIG_COMMANDS & CFG_CMD_JFFS2)
#include
#if (CONFIG_COMMANDS & CFG_CMD_NAND)
#ifdef CFG_NAND_LEGACY
#include
#else /* !CFG_NAND_LEGACY */
and
#ifdef CONFIG_JFFS2_CMDLINE
/* default values for mtdids and mtdparts variables */
#if defined(MTDIDS_DEFAULT)
static const char *const mtdids_default = MTDIDS_DEFAULT;
#else
#warning "MTDIDS_DEFAULT not defined!"
static const char *const mtdids_default = NULL;
#endif
besides
static int part_validate_nand(struct mtdids *id, struct part_info *part)
{
#if defined(CONFIG_JFFS2_NAND) && (CONFIG_COMMANDS & CFG_CMD_NAND)
/* info for NAND chips */
nand_info_t *nand;
Here you need to define three macros and default configuration:
#define CONFIG_JFFS2_CMDLINE 1
#define CONFIG_JFFS2_NAND 1
#define MTDIDS_DEFAULT "nand0=nandflash0"
#define MTDPARTS_DEFAULT "mtdparts=nandflash0:256k@0(bootloader),"
"128k(params),"
"2m(kernel),"
"-(root)"
1 #define CONFIG_COMMANDS
2 CFG_CMD_JFFS2 |
Above, after the compilation is passed, the kernel cannot be started immediately. Pay attention to the startup parameters at this time:
#define CONFIG_BOOTCOMMAND "nand read.jffs2 0x30007FC0 kernel; bootm 0x30007FC0" //Because the kernel has not been recognized yet
This should be changed to:
#define CONFIG_BOOTCOMMAND "nand read.jffs2 0x30007FC0 0x60000 0x200000; bootm 0x30007FC0"
//Here, the kernel has been programmed into the Nand, and then the nand read command is used to read the 30007fc0 address of the sdram. The address of the kernel in the nand is 0x60000, and the size is 2M.
The mtdpart command still cannot be used here because of the mtdpart parameter problem mentioned above.
Since we don't use parameters, then:
1 if (argc == 2) {
2 if (strcmp(argv[1], "default") == 0) {
3 setenv("mtdids", (char *)mtdids_default);
4 setenv("mtdparts", (char *)mtdparts_default);
5 setenv("partition", NULL);
6
7 mtdparts_init();
8 return 0;
9 } else if (strcmp(argv[1], "delall") == 0) {
10 /* this may be the first run, initialize lists if needed */
11 mtdparts_init();
12
13 setenv("mtdparts", NULL);
14
15 /* devices_init() calls current_save() */
16 return devices_init();
17 }
18 }
19
20 /* make sure we are in sync with env variables */
21 if (mtdparts_init() != 0)
22 return 1;
23
24 if (argc == 1) {
25 list_partitions();
26 return 0;
27 }
Then, the following four functions are not executed:
setenv("mtdids", (char *)mtdids_default);
setenv("mtdparts", (char *)mtdparts_default);
setenv("partition", NULL);
mtdparts_init(); //Among them, mainly this is not executed
Treatment measures: There are two types
The first one is to remove the parameter parsing and directly execute the mtdparts_init() function. The code is as follows:
1 int do_jffs2_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
2 {
3 //by Flinn
4 setenv("mtdids", (char *)mtdids_default);
5 setenv("mtdparts", (char *)mtdparts_default);
6 setenv("partition", NULL);
7
8 mtdparts_init();
9 if (argc == 2) {
10 if (strcmp(argv[1], "default") == 0) {
11 //setenv("mtdids", (char *)mtdids_default);
12 //setenv("mtdparts", (char *)mtdparts_default);
13 //setenv("partition", NULL);
14
15 //mtdparts_init();
16 return 0;
17 } else if (strcmp(argv[1], "delall") == 0) {
18 /* this may be the first run, initialize lists if needed */
19 mtdparts_init();
20
21 setenv("mtdparts", NULL);
22
23 /* devices_init() calls current_save() */
24 return devices_init();
25 }
26 }
The second kind, as Wei Dongshan did, add: in the main_loop function of main.c:
1 #ifdef CONFIG_JFFS2_CMDLINE
2 extern int mtdparts_init(void); //Execute the init function first
3 if (!getenv("mtdparts"))
4 {
5 run_command("mtdparts default", 0); //Call the default configuration again
6 }
7 else
8 {
9 mtdparts_init();
10 }
11 #endif
Both of the above methods are possible.
Previous article:Porting u-boot-1.1.6 NOR support
Next article:Develop and implement an application plan for elevator buffer reset time test system in EVC environment
Recommended posts
- Raspberry Pi Official Manual 2023
- ExplorethetruepotentialoftheRaspberryPiwiththenew,OfficialManual2023.Withover200pagesofamazingprojects,funtutorials,practicalguides,andclearreviews,ithaseverythingyouneedtomastertheRaspberryPi! TheOfficial
- dcexpert MicroPython Open Source section
- Android 5.0 BLE low-power Bluetooth slave device application
- Android'slow-powerBluetoothapplicationsareverycommon.Smartbraceletsandwatchesareeverywhere,andtheybasicallyuseBLEcommunicationtoexchangedata.BLEisbasicallywellsupportedonbothAndroidandIOSterminaldevices,soithasa
- fish001 Wireless Connectivity
- EEWORLD University----[High Precision Laboratory] Motor Drive: Brushless DC Motor Driver
- MotorDrive:BrushlessDCMotorDriver:https://training.eeworld.com.cn/course/5605Motordrive:BrushlessDCmotordriverMotordrive:BrushlessDCmotordriverBrushlessDCmotordriversofferhugesystem-leveladvantagesMotordrive:4brush
- hi5 Analog electronics
- Design a PCB diagram based on FPGA electronic piano
- 1.Basicrequirements: (1)Ithasgeneralplayingfunctionsandvariablevolume(atleasttwolevels) (2)Realizetheautomaticplaybackfunctionofasong (3)Functionofdigitallydisplayingmusicalnotationnotes (4)Makearegulatedpowe
- ma.hh PCB Design
- Circuit parameters of real op amp
- Thisisavoltagefollowercircuit.Thecircuitinputis0-10V(10Kohmvariableresistor),thepowersupplyis0-15V(singlepowersupply),andtheopampisLM358.Myfriendsaidthisistheworstopamponearth! ThequestionIwanttoaskt
- bigbat Analog electronics
- RK3568J "Hongmeng System" is officially released, making your product development faster and easier!
- ThisarticlemainlyintroducestheOpenHarmonysystemdemonstrationofRockchipRK3568J.Thedevelopmentenvironmentisasfollows: OpenHarmonySDKcompilationenvironment:Ubuntu18.04.464bit U-Boot:U-Boot-2017.09 Kernel:Linux-5.10.97
- 别打牛牛 ARM Technology
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Power amplifier circuit
- [NXP Rapid IoT Review] + Mobile Synchronizer 6
- Latest interpretation: What is Wi-Fi 7?
- 【GD32L233C-START Review】17. Completed work: Indoor environment monitoring equipment
- [Atria AT32WB415 Series Bluetooth BLE 5.0 MCU] Part 3: Lightble Control OLED Display
- Car sunlight sensor, urgent help
- Communication Principles_matlab.pdf
- Flyback power supply saber simulation
- Fundamentals of Spectrum Analysis
- Linux/UNIX System Programming Manual (Volumes 1 and 2)