给大家分享一个N年前自己写的bootloader,启动kernel原理很重要
本帖最后由 jiangdou 于 2015-6-1 12:31 编辑给大家分享一个N年前自己写的bootloader,启动kernel原理很重要
地址:https://github.com/jiangdoudou/mys32440_bootloader_for_kernel
整体文件
boot kernel 代码
makefile文件
还带uboot命令哦
好比:sunxi#
main.cint main(void)
{
char c;
char cmd_buf;
uart0_init();
puts("\n\r========================================\n\r");
puts("The board:TQ2440\n\r");
puts("The NAND:K9F1216U0A 256MB\n\r");
puts("The NOR:EN29LV160AB 2MB\n\r");
puts("The SRAM:HY57V561620 x2 64MB\n\r");
puts("just bootloader linux date: 2009.8.19;by jiangdou\n\r");
puts("===========================================\n\r");
lcd_Init();
my_logo();
PutPixel(20,250,0x001F);
PutPixel(40,250,0x07E0);
PutPixel(40,250,0xF800);
//paint_Bmp(0,0,320,240,logo);
//lcd_ClearScr(0x001F);
//paint_Bmp((LCD_XSIZE_TFT -80) / 2, (LCD_YSIZE_TFT -80) / 2, 80, 80, logo);
puts("Booting Linux ...\n\r");
boot_zImage(0x00200000, 0x00300000);
while (1)
{
puts("the menu of the update programe:\n\r");
puts(" write the nand flash\n\r");
puts(" read the nand flash\n\r");
puts(" erase the nand flash\n\r");
puts(" get file, and write to nand flash 0 block\n\r");
puts(" get file to ddr(0x32000000), run it\n\r");
puts(" reset the programe\n\r");
puts(" reset the programe\n\r");
puts("Please enter the chose:\n\r");
do {
c = getc();
if (c == '\n' || c == '\r')
{
puts("\n\r");
}
else
{
putc(c);
}
} while (c == '\n' || c == '\r');
switch (c)
{
case 'w':
case 'W':
{
nand_write_test();
break;
}
case 'r':
case 'R':
{
nand_read_test();
break;
}
case 'e':
case 'E':
{
nand_erase_test();
break;
}
case 'g':
case 'G':
{
update_program();
break;
}
case 'x':
case 'X':
{
run_program();
break;
}
case 's':
case 'S':
{
void (*theProgram)(void);
theProgram = (void (*)(void))0x33f80000;
theProgram();
break;
}
}
}
return 0;
}
原来bootloader这么短
谢谢分享、!
页:
[1]