关闭

MINI6410 uboot中USB下载

标签: linux移植下载菜单FriendlyARM
983人阅读 评论(0) 收藏 举报
分类:

我使用的Friendly ARM已经配置好的U-boot,然后利用他自带的USB下载功能往ARM板上烧制内核和文件系统,不需要输入地址参数,搞得挺简单,但是不清楚内核到底下载到什么位置了,能否和内核中设置的MTD分区匹配起来?


疑惑了好几天,网上百度了一些,还是没有找到下载菜单的位置,最终还是grep帮了大忙,直接拿下载菜单中的选项做关键词,在common文件中search,

      find . -name "*.c" | xargs grep -i  "uboot.bin" 

相关代码原来在main.c中:

	while(1) {
		int c;
		printf("##### FriendlyARM U-Boot(" RELEASE_MARK ", " BOOT_MEDIA ") for 6410 #####\n");
		printf("[f] Format the nand flash\n");
		printf("[v] Download u-boot.bin\n");
		printf("[k] Download Linux/Android kernel\n");
		printf("[y] Download root yaffs2 image\n");
		printf("[u] Download root ubifs image\n");
		printf("[a] Download Absolute User Application\n");
		printf("[n] Download Nboot.nb0 for WinCE\n");
		printf("[w] Download WinCE NK.nb0\n");
		printf("[s] Set the boot parameter of Linux\n");
		printf("[b] Boot Linux\n");
		printf("[q] Quit to shell\n");
		printf("NAND(%s): %u MiB, RAM: %u MiB\n", NandIsMlc2() ? "MLC2" : (NandIsMlc1()? "MLC1" : "SLC"), FriendlyARMGetNandSizeInMB(), PHYS_SDRAM_1_SIZE >> 20);
		if (Lcd != 0) {
			printf("LCD type, firmware version: %u %u\n", Lcd, FirmwareVer);
		}
		printf("Enter your Selection:");

		c = getc();
		printf("%c\n", c >= ' ' && c <= 127 ? c : ' ');

		switch(c) {
			unsigned max_size, pos, len;
		case 'F': case 'f':
			FriendlyARMFormatFrom(0, 1);
			break;

		case 'V': case 'v':
			pos = 0;
			max_size = 256 K;
			len = 256 K;
			FriendlyARMGetDataFromUsbAndWriteNand(max_size, pos, len, "U-Boot.bin");
			SetLinuxCommandLine(NULL);
			break;

		case 'K': case 'k':
			if (NandIsMlc()) {
				pos =  4 M;
				max_size = 5 M - 128 K;
				len = 8 M;
				NAND_EraseBlock(1 M / NandBlockSizeInByte);
			} else {
				pos = 4 * 128 K;
				max_size = 5 M - 128 K;
				len = 5 M;
			}
			FriendlyARMGetDataFromUsbAndWriteNand(max_size, pos, len, "Linux/Android Kernel");
			break;

		case 'Y': case 'y':
			if (NandIsMlc()) {
				printf("Yaffs is not support yet for MLC2 NAND\n");
			} else {
				FriendlyARMGetDataFromUsbAndWriteNand(126 M, 5 M + 4 * 128 K, (unsigned)-1, "yaffs2-image");
				SetLinuxCommandLine("root=/dev/mtdblock2 console=ttySAC0,115200");
			}
			break;

		case 'U': case 'u':
			max_size = 126 M;
			len = (unsigned) -2;
			if (NandIsMlc()) {
				pos = 12 M;
			} else {
				pos = 5 M + 4 * 128 K;
			}
			FriendlyARMGetDataFromUsbAndWriteNand(max_size, pos, len, "ubifs-image");
			SetLinuxCommandLine("init=/linuxrc rootfstype=ubifs root=ubi0:FriendlyARM-root ubi.mtd=2 console=ttySAC0,115200");
			break;

		case 'A': case 'a':
			FriendlyARMGetDataFromUsbAndWriteNand(64 M, 0, 128 M, "User-Bin");
			break;

		case 'N': case 'n':
			FriendlyARMGetDataFromUsbAndWriteNand(128 K, 0, 128 K, "nboot.nb0");
			break;

		case 'W': case 'w':
			if (NandIsMlc()) {
				max_size = 63 M;
				pos =  8 M;
				len = 72 M;
				FriendlyARMFormatFrom( pos / NandBlockSizeInByte, 0);
			} else {
				max_size = 63 M;
				pos = 2 M + 4 * 128 K;
				len = 64 M;
				ExecuteCmd("nand erase 4280000");
			}
			FriendlyARMGetDataFromUsbAndWriteNand(max_size, pos, len, "NK.nb0");
			// Mark the indicators of NK Magic Number and Image Size
			{
				unsigned char *p = (unsigned char *)0xC0000000;
				memset(p, 0, 128 K);
				((unsigned *)p)[0] = 0xCEFA4146U;
				((unsigned *)p)[1] = 63 M;
				
				if (NandIsMlc()) {
					pos = 1 M;
					len = 2 M;
				} else {
					pos = 2 * NandBlockSizeInByte;
					len = 1 * NandBlockSizeInByte;
				}

				FriendlyARMWriteNand(p, 128 K, pos, len);
			}
			break;

		case 'S': case 's':
			{
				int r;
				r = readline("Linux cmd line: ");
				if (r > 0 && r < 1000) {
					SetLinuxCommandLine(console_buffer);
				} else {
					printf("Linux command line not changed\n");
				}
			}
			break;
		case 'B': case 'b': 
			if (NandIsMlc()) {
				ExecuteCmd("nand read.i c0008000 400000 500000;bootm c0008000");
			} else {
				ExecuteCmd(CONFIG_BOOTCOMMAND);
			}
			while(1);
		case 'Q': case 'q':
			if (NandIsMlc()) {
				//printf("Caution: any nand write command may damage your data. DON'T use them\n");
			}
			return;
		default:
			;
		}
	}


我只想知道其中关于MTD的分区,看到源代码一看就明白了,就不去看他调用的其他函数;我用的yaffs2格式的根文件系统,在arch/arm/mach-s3c64xx/mach-mini6410文件中,关于MTD分区的定义:

static struct mtd_partition mini6410_nand_part[] = {
	{
		.name		= "Bootloader",
		.offset		= 0,
		.size		= (4 * 128 *SZ_1K),
		.mask_flags	= MTD_CAP_NANDFLASH,
	},
	{
		.name		= "Kernel",
		.offset		= (4 * 128 *SZ_1K),
		.size		= (5*SZ_1M) ,
		.mask_flags	= MTD_CAP_NANDFLASH,
	},
	{
		.name		= "File System",
		.offset		= MTDPART_OFS_APPEND,
		.size		= MTDPART_SIZ_FULL,
	}
};

MTD分区完全匹配,恍然大悟的感觉真好,哈哈

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:39123次
    • 积分:738
    • 等级:
    • 排名:千里之外
    • 原创:33篇
    • 转载:9篇
    • 译文:0篇
    • 评论:4条
    最新评论