autoboot
autoboot.cautoboot_command 自动启动命令1234567891011121314151617181920212223242526272829void autoboot_command(const char *s){ debug("### main_loop: bootcmd=\"%s\"\n", s ? s : "<UNDEFINED>"); if (s //有bootcmd && (stored_bootdelay == -2 || //有延迟时间,且没有按键中断 (stored_bootdelay != -1 && !abortboot(stored_bootdelay)))) { bool lock; int prev; lock = autoboot_keyed() && !IS_ENABLED(CO...
cli
CTL_CH 转换为控制字符1#define CTL_CH(c) ((c) - 'a' + 1) 控制字符通常用于表示特定的控制操作,例如回车、换行、退格等。在 ASCII 码表中,控制字符的值通常在 1 到 31 之间。 cli.ccli_init u_boot_hush_start(); 123456789101112int u_boot_hush_start(void){ if (top_vars == NULL) { top_vars = malloc(sizeof(struct variables)); top_vars->name = "HUSH_VERSION"; top_vars->value = "0.01"; top_vars->next = NULL; top_vars->flg_export = 0; top_vars->flg_read_only = 1; } return 0;} cli_process...
command
command.cU_BOOT_CMD12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273#ifdef CONFIG_AUTO_COMPLETE# define _CMD_COMPLETE(x) x,#else# define _CMD_COMPLETE(x)#endif#ifdef CONFIG_SYS_LONGHELP# define _CMD_HELP(x) x,#else# define _CMD_HELP(x)#endif//cmd名称,最大参数个数,是否可重复,cmd调用函数,使用说明,帮助信息#define U_BOOT_CMD(_name, _maxargs, _rep, _cmd, _usage, _help) \ U_BOOT_CMD_COMPLETE(_name, _maxargs, _rep, _cmd, _usage, ...
console
common/console.cputs 输出字符串 暂不分析***
export
exports.cjumptable_init malloc分配jt_funcs结构体,并将函数指针赋值给jt_funcs结构体 jt_funcs结构体中的函数指针是在_exports.h中定义的 这些函数在u-boot中是代码段中的函数,在u-boot中是通过函数指针调用的 jt跳转表包含指向导出函数的指针。指向跳转表将传递给独立应用程序。 123456789101112131415161718192021EXPORT_FUNC(get_version, unsigned long, get_version, void)EXPORT_FUNC(getchar, int, getc, void)EXPORT_FUNC(tstc, int, tstc, void)EXPORT_FUNC(putc, void, putc, const char)EXPORT_FUNC(puts, void, puts, const char *)struct jt_funcs {#define EXPORT_FUNC(impl, res, func, ...) res(*func)(__...
log
## common/log.c 暂不分析***
main
main.c123456789101112131415161718192021/* We come here after U-Boot is initialised and ready to process commands */void main_loop(void){ const char *s; bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop"); cli_init(); s = bootdelay_process(); //获取启动延迟时间 //从FDT中获取命令行参数 if (cli_process_fdt(&s)) //设置了bootsecure执行; //不使用命令行,避免被攻击 cli_secure_boot_cmd(s); //自动启动命令 autoboot_command(s); //命令行循环 cli_loop(); panic("No CLI available");}
env
envU_BOOT_ENV_LOCATION 通过该宏定义环境变量的位置 1234567891011121314151617181920/* * Define a callback that can be associated with variables. * when associated through the ".callbacks" environment variable, the callback * will be executed any time the variable is inserted, overwritten, or deleted. * * For SPL these are silently dropped to reduce code size, since environment * callbacks are not supported with SPL. */#ifdef CONFIG_XPL_BUILD#define U_BOOT_ENV_CALLBACK(name, callback) \ static ...
adc
[TOC] stm32-adc-core.c驱动信息12345678910111213static const struct udevice_id stm32_adc_core_ids[] = { { .compatible = "st,stm32h7-adc-core" }, { .compatible = "st,stm32mp1-adc-core" }, {}};U_BOOT_DRIVER(stm32_adc_core) = { .name = "stm32-adc-core", .id = UCLASS_SIMPLE_BUS, .of_match = stm32_adc_core_ids, .probe = stm32_adc_core_probe, .priv_auto = sizeof(struct stm32_adc_common),}; stm32_adc_core_probe 获取 base 地址 ...
button
[TOC] common/button_cmd.c 在执行到这里的时候,按键必须已经按下;代码没有循环与延时 且只能处理一个按键,不支持多个按键同时按下 使用时,需要在env中设置button_cmd_N_name= 和button_cmd_N=fastboot usb 0(执行的CMD命令) 参考test/dm/button.c中的button_cmd测试的用法 123456789101112131415void process_button_cmds(void){ struct button_cmd cmd = {0}; int i = 0; while (get_button_cmd(i++, &cmd) && i < MAX_BTN_CMDS) { if (!cmd.pressed) continue; log_info("BTN '%s'> %s\n", cmd.btn_name, cmd.cmd); run_co...







