20180119_jeffrey - silenceuncrio/diary GitHub Wiki
0855
review
0915
研究一下目前 m360 上的 UBoot
...
============================================
Ralink UBoot Version: 5.0.0.0
--------------------------------------------
ASIC MT7621A DualCore (MAC to MT7530 Mode)
DRAM_CONF_FROM: Auto-Detection
DRAM_TYPE: DDR2
DRAM bus: 16 bit
Xtal Mode=3 OCP Ratio=1/4
Flash component: NAND Flash
Date:Jan 18 2018 Time:06:30:35
============================================
icache: sets:256, ways:4, linesz:32 ,total:32768
dcache: sets:256, ways:4, linesz:32 ,total:32768
##### The CPU freq = 880 MHZ ####
estimate memory size =128 Mbytes
#Reset_MT7530
Please choose the operation:
1: Load system code to SDRAM via TFTP.
2: Load system code then write to Flash via TFTP.
3: Boot system code via Flash (default).
4: Entr boot command line interface.
7: Load Boot Loader code then write to Flash via Serial.
9: Load Boot Loader code then write to Flash via TFTP.
仔細地從支援的 operation 來研究
就照順序看吧 - 1: Load system code to SDRAM via TFTP.
Uboot\lib_mips\board.c
void board_init_r (gd_t *id, ulong dest_addr)
{
OperationSelect();
while (timer1 > 0) {
--timer1;
/* delay 100 * 10ms */
for (i=0; i<100; ++i) {
if ((my_tmp = tstc()) != 0) { /* we got a key press */
timer1 = 0; /* no more delay */
BootType = getc();
if ((BootType < '0' || BootType > '5') && (BootType != '7') && (BootType != '8') && (BootType != '9'))
BootType = '3';
printf("\n\rYou choosed %c\n\n", BootType);
break;
}
udelay (10000);
}
printf ("\b\b\b%2d ", timer1);
}
putc ('\n');
if(BootType == '3') {
printf(" \n3: System Boot system code via Flash.\n");
do_bootm(cmdtp, 0, 2, argv);
}
else {
switch(BootType) {
case '1':
printf(" \n%d: System Load Linux to SDRAM via TFTP. \n", SEL_LOAD_LINUX_SDRAM);
tftp_config(SEL_LOAD_LINUX_SDRAM, argv);
argc= 3;
setenv("autostart", "yes");
do_tftpb(cmdtp, 0, argc, argv);
break;
} /* end of switch */
do_reset(cmdtp, 0, argc, argv);
} /* end of else */
/* NOTREACHED - no way out of command loop except booting */
}
此時 tftp_config(SEL_LOAD_LINUX_SDRAM, argv)
的行為如下
int tftp_config(int type, char *argv[])
{
printf("\tInput device IP ");
input_value(devip);
setenv("ipaddr", devip);
printf("\tInput server IP ");
input_value(srvip);
setenv("serverip", srvip);
argv[1] = "0x80A00000";
strncpy(argv[2], "uImage", ARGV_LEN);
printf("\tInput Linux Kernel filename ");
input_value(file);
setenv("bootfile", file);
return 0;
}
1300
繼續看 - 1: Load system code to SDRAM via TFTP.
do_tftpb()
的行為如下
int do_tftpb (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
return netboot_common (TFTP, cmdtp, argc, argv);
}
netboot_common()
的行為
static int
netboot_common (int proto, cmd_tbl_t *cmdtp, int argc, char *argv[])
{
switch (argc) {
case 3: load_addr = simple_strtoul(argv[1], NULL, 16);
copy_filename (BootFile, argv[2], sizeof(BootFile));
break;
}
printf("LoadAddr=%x NetBootFileXferSize= %08x\n", load_addr, size);
/* Loading ok, check if we should attempt an auto-start */
if (((s = getenv("autostart")) != NULL) && (strcmp(s,"yes") == 0)) {
char *local_args[2];
local_args[0] = argv[0];
local_args[1] = NULL;
printf ("Automatic boot of image at addr 0x%08lX ...\n", load_addr);
rcode = do_bootm (cmdtp, 0, 1, local_args);
}
return rcode;
}
do_bootm()
的內容有點多 先 pass
1310
研究第二個 operation - 2: Load system code then write to Flash via TFTP.
只顯示 switch case 的相關部分
printf(" \n%d: System Load Linux Kernel then write to Flash via TFTP. \n", SEL_LOAD_LINUX_WRITE_FLASH);
printf(" Warning!! Erase Linux in Flash then burn new one. Are you sure?(Y/N)\n");
tftp_config(SEL_LOAD_LINUX_WRITE_FLASH, argv);
argc= 3;
setenv("autostart", "no");
do_tftpb(cmdtp, 0, argc, argv);
unsigned int load_address = simple_strtoul(argv[1], NULL, 16);
ranand_erase_write((u8 *)load_address, CFG_KERN_ADDR-CFG_FLASH_BASE, NetBootFileXferSize);
argc= 2;
sprintf(addr_str, "0x%X", CFG_KERN_ADDR);
argv[1] = &addr_str[0];
do_bootm(cmdtp, 0, argc, argv);
tftp_config()
行為如下
int tftp_config(int type, char *argv[])
{
printf("\tInput device IP ");
input_value(devip);
setenv("ipaddr", devip);
printf("\tInput server IP ");
input_value(srvip);
setenv("serverip", srvip);
argv[1] = "0x80100000";
strncpy(argv[2], "uImage", ARGV_LEN);
printf("\tInput Linux Kernel filename ");
input_value(file);
setenv("bootfile", file);
return 0;
}
tftp_config()
在 operation 1 和 2 的差別
-
1: Load system code to SDRAM via TFTP.
- argv[1] = "0x80A00000";
-
2: Load system code then write to Flash via TFTP.
- argv[1] = "0x80100000";
ranand_erase_write()
用眼睛 trace 沒有感覺
應該直接操作在放幾個 debug message 來了解流程的細節
1510
新增一個 GitLab project 來 keep 我對於 m360 uboot 的進展 - https://192.168.0.124/RD/uboot-m360