龙空技术网

uboot引导应用程序

嵌入式与Linux那些事 229

前言:

此刻小伙伴们对“uboot tftpput”可能比较珍视,你们都需要剖析一些“uboot tftpput”的相关内容。那么小编同时在网络上汇集了一些关于“uboot tftpput””的相关资讯,希望我们能喜欢,咱们快快来学习一下吧!

uboot默认是支持执行应用程序的,就像引导内核一样,我们也可以自己写一个应用程序,让uboot启动时引导。

在uboot examples/standalone 目录下,有hello_world.c文件,编译uboot的时候,会自动编译hello_world.bin文件。

裸机程序未加链接地址时,只能使用text代码段,如果裸机程序中使用出现了跨端操作(使用text端段以外的段:rodata,data,bss段),必须在链接时手工指定连接链接地址为实际的运行地址。

默认的链接地址由 Makefile中通过CONFIG_STANDALONE_LOAD_ADDR 指定。

这个地址不一定适合我们的板子,为了不影响uboot的正常运行,我们修改该地址为内核的链接地址0x280000

重新编译的uboot后,将hello_world.bin通过tftp加载到内存中。

uboot设置好参数。

=> setenv ipaddr 192.168.137.110=> setenv serverip 192.168.137.1=> setenv gatewayip 192.168.137.1=> tftp 0x00280000 hello_world.binethernet@fe300000 Waiting for PHY auto negotiation to complete.. doneSpeed: 1000, full duplexUsing ethernet@fe300000 deviceTFTP from server 192.168.137.1; our IP address is 192.168.137.110Filename 'hello_world.bin'.Load address: 0x280000Loading: #         0 Bytes/sdoneBytes transferred = 794 (31a hex)

执行go指令去引导我们的程序。

=> go 0x280000## Starting application at 0x00280000 ...Example expects ABI version 9Actual U-Boot ABI version 9Hello Worldargc = 1argv[0] = "0x280000"argv[1] = "<NULL>"Hit any key to exit ... 

成功打印出Hello World。

也可以将 go 0x280000 添加到bootcmd 中,每次启动内核前,先去引导应用程序,再引导内核。

标签: #uboot tftpput