allwinner uboot boot0

文章详细描述了嵌入式设备上电后的启动过程,从BROM加载固定代码开始,初始化存储介质,如flash和emmc,接着执行boot0阶段。boot0主要功能包括初始化板级设置,设置串口,检测用户输入,并加载后续的启动映像。此外,提到了sunxi系列芯片的特定操作,如sunxi_board_init和dram初始化。

 机器从上电后先运行BROM中一段固定的代码,BROM会读取外部引脚来决定从何种介质来启动系统,BROM的作用是初始化储存启动系统的介质,如flash,emmc等。然后从启动介质中读取boot0代码到芯片内部的SRAM中,然后跳到boot0的boot0_entry.S(sunxi_spl/boot0/main/)

 

代码流程:

1. boot0阶段调用的函数(注册函数,编译在代码中)
	SPL_LOAD_IMAGE_METHOD("MMC1", 0, BOOT_DEVICE_MMC1, spl_mmc_load_image);
	SPL_LOAD_IMAGE_METHOD("MMC2", 0, BOOT_DEVICE_MMC2, spl_mmc_load_image);
	SPL_LOAD_IMAGE_METHOD("MMC2_2", 0, BOOT_DEVICE_MMC2_2, spl_mmc_load_image);

2.boot0阶段启动
void main(void)	//位置:spl-pub/nboot/main/boot0_main.c
	//SUNXI板子初始化,全志未提供源码
	sunxi_board_init_early()
	//初始化串口
	sunxi_serial_init(BT0_head.prvt_head.uart_port, (void *)BT0_head.prvt_head.uart_ctrl, 6);
	//打印boot0启动信息
	print_commit_log();
		printf("HELLO! BOOT0 is starting!\n");
		printf("BOOT0 commit : %s\n", BT0_head.hash);
		sunxi_set_printf_debug_mode(BT0_head.prvt_head.debug_mode, 0);
	//SUNXI板子初始化,全志未提供源码
	sunxi_board_init()
	//检测到串口输入为2,可以阻止当前运行
	char uart_input_value = get_uart_input(); /* Prevent DRAM jamming */
		if (uart_input_value == '2')
			printf("detected_f user input 2\n");
	dram_size = init_DRAM(0, (void *)BT0_head.prvt_head.dram_para)
		pr_emerg("dram size =%d\n", dram_size);
	uart_input_value = get_uart_input();
		if (uart_input_value == '2') {
			sunxi_set_printf_debug_mode(3, 0);
			printf("detected_r user input 2\n");
			goto _BOOT_ERROR;
		} else if (uart_input_value == 'd') {
			sunxi_set_printf_debug_mode(8, 1);
			printf("detected user input d\n");
		} else if (uart_input_value == 'q') {
			printf("detected user input q\n");
			sunxi_set_printf_debug_mode(0, 1);
		}		
		
	malloc_init(CONFIG_HEAP_BASE, CONFIG_HEAP_SIZE);
	status = sunxi_board_late_init();
	
	status = load_package();
		if (status == 0)
		load_image(&uboot_base, &optee_base, &monitor_base, &rtos_base, &opensbi_base, &cpus_rtos_base);
			
	//输出跳转信息		
	printf("Jump to second Boot.\n");

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值