当前位置:   article > 正文

uboot引导应用程序_uboot standalone

uboot standalone

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.bin
ethernet@fe300000 Waiting for PHY auto negotiation to complete.. done
Speed: 1000, full duplex
Using ethernet@fe300000 device
TFTP from server 192.168.137.1; our IP address is 192.168.137.110
Filename 'hello_world.bin'.
Load address: 0x280000
Loading: #
         0 Bytes/s
done
Bytes transferred = 794 (31a hex)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

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

=> go 0x280000
## Starting application at 0x00280000 ...
Example expects ABI version 9
Actual U-Boot ABI version 9
Hello World
argc = 1
argv[0] = "0x280000"
argv[1] = "<NULL>"
Hit any key to exit ... 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

成功打印出Hello World。

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

https://blog.csdn.net/weixin_45861321/article/details/122459099

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/346623
推荐阅读
相关标签
  

闽ICP备14008679号