When burning with ok6410, you need to type a lot of commands every time, which is time-consuming and laborious. I remember that when I used TQ2440 before, there would be a menu when u-boot started. Just press a number key to burn the kernel, which was very convenient.
Now this SD card has comprehensive functions. It can not only boot directly from the SD card, but also burn the u-boot zImage rootfs in the nand flash. Hehe.
Now add this function to the u-boot of ok6410.
1. Modify the u-boot1.1.6 of the SD card
1. common/main.c
void main_loop (void)
{.......
if (bootdelay >= 0 && s && !abortboot (bootdelay)) {
}
//If a key is pressed during the startup process, the execution process is interruptedrun_command("menu",0);
//If the menu returns, enter the u-boot shell
#ifdef CFG_HUSH_PARSER
parse_file_outer();......
}
2. The process of executing menu,
run_command("menu", 0), will eventually execute do_menu.
do_menu prints out the command menu at the beginning, and then executes different commands according to different selections.
So the added file common/cmd_menu.c is as follows:
#include
#include
#include
#include
void print_menu_usage(void)
{
printf("rn##### SD boot Menu #####rn");
printf("[1] Download u-boot bootloader to Nand Flashrn");
printf("[2] Download Linux Kernel to Nand Flashrn");
printf("[3] Download CRAMFS image to Nand Flashrn");
printf("[4] Download YAFFS image to Nand Flashrn");
printf("[5] Boot the systemrn");
printf("[6] Format the Nand Flashrn");
printf("[0] Set the boot parametersrn");
printf("[a] Download User Program (eg: uCOS-II or TQ2440_Test)rn");
printf("[b] Download LOGO Picture (.bin) to Nand Flash rn");
printf("[q] quit from menurn");
printf("Enter your selection: ");
}
int do_menu(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
int c;
char cmd_buf[200];
while(1)
{
print_menu_usage();
c = getc();
printf("%cn", c);
switch (c)
{
case '1':
{
strcpy(cmd_buf, "fatload mmc 0:1 50008000 u-boot.bin_nand; nand erase 0 100000; nand write.uboot 50008000 0 10000");
run_command(cmd_buf, 0);
break;
}
case '2':
{
strcpy(cmd_buf, "fatload mmc 0:1 50008000 zImage_nand; nand erase 100000 500000; nand write.e 50008000 100000 500000");
run_command(cmd_buf, 0);
break;
}
case '3':
{
//strcpy(cmd_buf, "fatload mmc 0:1 50008000 u-boot.bin; nand erase 0 100000; nand write.uboot 50008000 0 10000");
//run_command(cmd_buf, 0);
break;
}
case '4':
{
//strcpy(cmd_buf, "fatload mmc 0:1 50008000 rootfs.yaffs; nand erase 600000 4A4000; nand write.yaffs2 50008000 600000 4A4000");
//strcpy(cmd_buf, "fatload mmc 0:1 50008000 rootfs.yaffs; nand erase 600000 $(filesize); nand write.yaffs2 50008000 600000 $(filesize)");
//Note: nand erase 600000 $(filesize), if there is a bad block, data cannot be written, so this place can be fixed to a larger value, such as
// 0x1400000=20M, so the size of rootfs.yaffs cannot exceed 20M,
//Consider whether to add a nand flash partition here: nand erase root, erase the entire root partition, so you don't have to worry about whether there are bad blocks
strcpy(cmd_buf, "fatload mmc 0:1 50008000 rootfs.yaffs; nand erase 600000 1400000; nand write.yaffs2 50008000 600000 $(filesize)");
run_command(cmd_buf, 0);
break;
}
case '5':
{
strcpy(cmd_buf, "bootm 50008000");
run_command(cmd_buf, 0);
break;
}
case 'q':
return;
default:
printf("command not found\n");
break;
}
}
}
U_BOOT_CMD(
menu, 5, 1, do_menu,
"menu - manipulate BMP image datan",
"menu long help: TNND mu you"
);
3. Add to Makefile
Finally, add a line to common/Makefile
COBJS+= cmd_menu.o
Note: When combining commands, what if you don't know the size of the file to be burned in nand write? It doesn't matter, there is a variable $(filesize). As long as you add this, any problem will no longer be difficult.
The above 50008000 is the memory address to be read when booting from the SD card; if booting from Nand flash, change the above 50008000 to C0008000
2. Test
2.1 sd card
a. Because data is read from the SD card and the first partition, the first partition format must be FAT32 when partitioning the SD card.
b. Compile u-boot.bin:
The code should use the u-boot included in the CD, which supports booting from nand flash.
Make forlinx_nand_ram256_config, then generate u-boot.bin
and copy it to the first partition of the SD card, and rename it to u-boot.bin_nand (to be consistent with the name in the u-boot code)
c. Compile zImage
code with linux-3.0.1 included in the CD, make and generate zImage
and copy it to the first partition of the SD card, and rename it to zImage_nand (to be consistent with the name in the u-boot code)
d. Generate rootfs.yaffs
with FileSystem-Yaffs2.tar.gz included in the CD, After decompression, it is too big, so delete the unnecessary ones.
The busybox in it seems to be dynamically linked, so compile a static busybox yourself, and finally generate rootfs.yaffs
sudo /opt/6410/4.3.2/bin/mkyaffs2image-nand2g FileSystem-Yaffs2 rootfs.yaffs
nand flash is 2G, so use the command mkyaffs2image-nand2g
to copy rootfs.yaffs to the first partition of the SD card (to be consistent with the name in the u-boot code)
Note: If you are not sure whether there is a problem with the rootfs itself, you can start from nfs first to see if it is normal.
If it is normal, use mkyaffs2image-nand2g to make a yaffs image and burn it into the nand flash.
3. NAND Flash added to menu
3.1 The files of NAND flash are obtained through USB, of course, it can also be obtained through TFTP (TFTP has not been tried, but the principle is the same)
Will strcpy(cmd_buf, "fatload mmc 0:1 50008000 u-boot.bin_nand; nand erase 0 100000; nand write.uboot 50008000 0 10000");
Change to -->:
strcpy(cmd_buf, "dnw c0008000; nand erase 0 100000; nand write.uboot c0008000 0 10000");
Or --> (haven't tried this)
strcpy(cmd_buf, "tftp c0008000 u-boot.bin; nand erase 0 100000; nand write.uboot c0008000 0 10000");
3.2 Solve a small problem of USB transmission.
The following is the printed log:
the downloaded file size is 0x420000, the nand flash erase size is 0x1400000, but it becomes 0x7fa00000 when nand write.yaffs2.
Enter your selection: 3
OTG cable
Now, Waiting for DNW to transmit data
Download Download Address: 0xc0008000, Download Filesize:0x420000
Checksum is being calculated....calc checksum=0xba1c, read checksum=0xba1c, start:
Checksum OK
NAND erase: device 0 offset 0x600000, size 0x1400000
Skipping bad block at 0x00780000
Erasing at 0x1980000 -- 100% complete.
OK
NAND write: device 0 offset 0x600000, size 0x7fa00000
Input block length is not page aligned
Data did not fit into device, due to bad blocks
2141192192 bytes written: ERROR
##### NAND boot Menu #####
This is because after the USB transfer is completed, the size of the received file is not saved.
The solution is as follows:
in cpu/s3c64xx/usbd-otg-hs.c
void s3c_usb_verify_checksum(void)
{
u8 *cs_start, *cs_end;
u16 dnCS;
u16 checkSum;
int i;
printf("Checksum is being calculated.");
char buf[12];
long size;
/* checksum calculation */
cs_start = (u8*)otg.dn_addr;
cs_end = (u8*)(otg.dn_addr+otg.dn_filesize-10);
checkSum = 0;
while(cs_start < cs_end) {
checkSum += *cs_start++;
if(((u32)cs_start&0xfffff)==0) printf(".");
}
dnCS = *(u16 *)cs_end;
printf("calc checksum=0x%x, read checksum=0x%x, start:n", checkSum, dnCS);
if (checkSum == dnCS)
{
//Add the following paragraph to record the size of the received file
size = otg.dn_filesize-10;
sprintf(buf, "%lX", size);
printf("nChecksum OK down filesize=%ldn", size);
setenv("filesize", buf);
}
else
{
printf("nChecksum Value => MEM:%x DNW:%xn",checkSum,dnCS);
printf("Checksum failed.nn");
}
}
Previous article:Analysis of the process of writing yaffs2 file system using ---11uboot on S3C6410
Next article:S3C6410 usage --- SD initialization and reading and writing analysis in 7uboot
- 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
- The diameter of the four holes on the EK140 base plate
- This circuit is called a "lawn mower"
- CC3200-LAUNCHXL
- How to monitor battery voltage with Arduino
- Image Algorithm Transplantation to DSP and Its Optimization Steps
- Prize-winning live broadcast: Keysight’s Metaverse Test Series Seminar: Challenges in VR/AR Digital Interface Testing in Progress!
- 51 STM32 reference study manuals, one-click download without points!
- Microwave and RF Applications
- [ESP32-S2-Kaluga-1 Review] 3. Physical buttons?
- Unable to search for Bluetooth signal after adding characteristic value