f1c200s---编译uboot

2023-11-11 02:40
文章标签 编译 uboot f1c200s

本文主要是介绍f1c200s---编译uboot,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

目录

  • 前言
  • 安装必要工具
    • 安装交叉编译链工具
  • 下载Uboot
    • 切换分支
    • 查看配置文件
  • 配置Uboot
    • 修改Makefile
    • 配置文件
  • 编译uboot
    • 出现/bin/sh: 1: python: not found错误
    • 出现multiple definition of `yylloc'错误
    • 出现FATAL ERROR: Unable to parse input tree错误
    • 出现/usr/bin/env: 'python2': No such file or directory错误
    • 出现ImportError: No module named _libfdt的错误
    • 出现scripts/dtc/pylibfdt/libfdt_wrap.c:154:11: fatal error: Python.h: No such file or directory错误
  • 烧录
  • 快速搭建
    • 修改后的Uboot
    • 快速部署环境的Docker镜像

前言

本章所解决问题后的Uboot仓库、docker镜像可在文章末尾找到,如果不想一步步配置编译环境可到文章末尾下载docker镜像直接运行

安装必要工具

sudo apt update
sudo apt upgrade
sudo apt-get install git vim wget 
sudo apt-get install xz-utils nano unzip build-essential bc swig libncurses5-dev libpython3-dev libssl-dev pkg-config zlib1g-dev libusb-dev libusb-1.0-0-dev python3-pip gawk bison flex 

安装交叉编译链工具

下载交叉编译链:

wget http://releases.linaro.org/components/toolchain/binaries/7.2-2017.11/arm-linux-gnueabi/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi.tar.xz

解压交叉编译链:

mkdir /usr/local/arm 
tar -vxf gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi.tar.xz -C /usr/local/arm 

配置环境变量:

vim ~/.bashrc

打开后在文件最后一行添加以下变量:

export PATH=$PATH:/usr/local/arm/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabi/bin

生效环境变量:

source ~/.bashrc 

查询版本确保安装无误:

arm-linux-gnueabi-gcc -v

在这里插入图片描述

下载Uboot

由于官方Uboot并没有对f1c200s有支持,所以我们使用基于licheepi的Uboot进行编译和后续的开发工作

git clone https://github.com/Lichee-Pi/u-boot.git
cd u-boot

切换分支

git checkout nano-v2018.01

在这里插入图片描述

查看配置文件

进入configs目录查看配置文件,可以看到有两个配置文件,一个是带spiflash的一个是不带的,根据自己需求选择

cd configs && find -name "*lichee*" && cd ..

在这里插入图片描述

配置Uboot

修改Makefile

vim Makefile

输入/CROSS_COMPILE定位到修改的位置,如果用别的编辑器修改,大概在246行,修改为如下内容:

ARCH?=arm
CROSS_COMPILE?=arm-linux-gnueabi-

修改前:
在这里插入图片描述
修改后:在这里插入图片描述

配置文件

make licheepi_nano_spiflash_defconfig
make menuconfig

需要在menuconfig里面配置成如图这样就可以,当然如果你是高手也可以自己配置

在这里插入图片描述
boot arguments参数:

console=ttyS0,115200 panic=5 rootwait root=/dev/mmcblk0p2 earlyprintk rw

boot cmd参数:

load mmc 0:1 0x80008000 zImage;load mmc 0:1 0x80c08000 suniv-f1c100s-licheepi-nano.dtb;bootz 0x80008000 - 0x80c08000;

保存并退出写入到.config中

编译uboot

make -j8

出现/bin/sh: 1: python: not found错误

具体出错细节如下:

/bin/sh: 1: python: not found
make[3]: *** [scripts/dtc/pylibfdt/Makefile:26: scripts/dtc/pylibfdt/_libfdt.so] Error 127HOSTCC  scripts/dtc/checks.o
make[2]: *** [scripts/Makefile.build:425: scripts/dtc/pylibfdt] Error 2
make[2]: *** Waiting for unfinished jobs....HOSTCC  scripts/dtc/util.oCHK     include/config.hCFG     u-boot.cfgCHK     include/generated/version_autogenerated.hCC      lib/asm-offsets.sCC      arch/arm/lib/asm-offsets.sCHK     include/generated/generic-asm-offsets.hCHK     include/generated/asm-offsets.h
make[1]: *** [scripts/Makefile.build:425: scripts/dtc] Error 2
make: *** [Makefile:493: scripts] Error 2

经过测试我们只有python3,没有python,并且找到了python3相对应的目录
在这里插入图片描述
执行下列命令后进行python测试:

cp /usr/bin/python3 /usr/bin/python

在这里插入图片描述
重新编译:

make -j8

出现multiple definition of `yylloc’错误

错误具体详细如下:

/usr/bin/ld: scripts/dtc/dtc-parser.tab.o:(.bss+0x10): multiple definition of `yylloc'; scripts/dtc/dtc-lexer.lex.o:(.bss+0x0): first defined here
/workspace/u-boot/scripts/dtc/pylibfdt/setup.py:21: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternativesfrom distutils.core import setup, Extension
collect2: error: ld returned 1 exit status
make[2]: *** [scripts/Makefile.host:108: scripts/dtc/dtc] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [scripts/Makefile.build:425: scripts/dtc] Error 2
make: *** [Makefile:493: scripts] Error 2
make: *** Waiting for unfinished jobs....

看起来是yylloc这个变量重复定义了,具体目录看起来应该是在scripts/dtc/文件夹下的dtc-lexer.lex.c下第一次定义了yylloc变量然后又在别的c文件定义了yylloc变量,输入以下命令进行查找

cd scripts/dtc/ && grep -nR yylloc

果然,在dtc-parser.tab.c的1205行和dtc-lexer.lex.c的634行出现了多重定义,由于编译器提示dtc-lexer.lex.c是第一次定义,所以我们去注释dtc-parser.tab.c的定义
在这里插入图片描述
注释dtc-parser.tab.c的定义后如下图:
在这里插入图片描述
重新编译:

make -j8

出现FATAL ERROR: Unable to parse input tree错误

具体错误详情如下:

DTC     arch/arm/dts/suniv-f1c100s-licheepi-nano.dtb
Error: arch/arm/dts/.suniv-f1c100s-licheepi-nano.dtb.pre.tmp:59.1-10 syntax error
FATAL ERROR: Unable to parse input tree
make[2]: *** [scripts/Makefile.lib:329: arch/arm/dts/suniv-f1c100s-licheepi-nano.dtb] Error 1
make[1]: *** [dts/Makefile:51: arch/arm/dts/suniv-f1c100s-licheepi-nano.dtb] Error 2
make: *** [Makefile:878: dts/dt.dtb] Error 2

看起来是设备树的问题,这里也是困扰我最久的地方
进入scrpit文件夹,修改Makefile.lib的第321行,多了个斜杠,紫色选中为多的那个斜杠

cd scripts
vim Makefile.lib

在这里插入图片描述
删除斜杠后:
在这里插入图片描述
重新编译:

make -j8

出现/usr/bin/env: ‘python2’: No such file or directory错误

具体出错信息:

BINMAN  u-boot-sunxi-with-spl.bin
/usr/bin/env: 'python2': No such file or directory
make: *** [Makefile:1150: u-boot-sunxi-with-spl.bin] Error 127

看起来没安装python2,安装一下

sudo apt-get install python2

重新编译

make -j8

出现ImportError: No module named _libfdt的错误

具体报错信息如下:

Traceback (most recent call last):File "./tools/binman/binman", line 32, in <module>import controlFile "/workspace/u-boot/tools/binman/control.py", line 16, in <module>import fdtFile "/workspace/u-boot/tools/binman/../dtoc/fdt.py", line 13, in <module>import libfdtFile "scripts/dtc/pylibfdt/libfdt.py", line 15, in <module>import _libfdt
ImportError: No module named _libfdt

看起来我们之前无脑的把python3拷贝为python的方法是错误的,他的脚本用python2写的,与python3兼容性并不好,一些库已经不再支持,我们切换回python2

cp /usr/bin/python2 /usr/bin/python

重新编译:

make -j8

出现scripts/dtc/pylibfdt/libfdt_wrap.c:154:11: fatal error: Python.h: No such file or directory错误

具体出错信息如下:

  CHK     include/generated/asm-offsets.h
scripts/dtc/pylibfdt/libfdt_wrap.c:154:11: fatal error: Python.h: No such file or directory154 | # include <Python.h>|           ^~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
make[3]: *** [scripts/dtc/pylibfdt/Makefile:26: scripts/dtc/pylibfdt/_libfdt.so] Error 1
make[2]: *** [scripts/Makefile.build:425: scripts/dtc/pylibfdt] Error 2
make[1]: *** [scripts/Makefile.build:425: scripts/dtc] Error 2
make: *** [Makefile:493: scripts] Error 2

应该是python2的dev没有安装,安装试一下

sudo apt-get install python2-dev

重新编译:

make -j8

编译成功,出现u-boot-sunxi-with-spl.bin文件
在这里插入图片描述

烧录

在芯片进入fel模式后,通过sunxi-tools进行烧录(单次,仅验证)
具体安装与使用参考:传送门

sudo sunxi-fel uboot u-boot-sunxi-with-spl.bin

可以看到连接了芯片串口的设备有以下Uboot输出:
![在这里插入图片描述](https://img-blog.csdnimg.cn/e8e38bb908bd414983c902f9c4283450.png

快速搭建

修改后的Uboot

Github: https://github.com/JiangLin998/licheepi-nano-u-boot
Gitee:https://gitee.com/jianglin998/licheepi-nano-u-boot

快速部署环境的Docker镜像

Docker镜像:https://github.com/JiangLin998/dockerImages

这篇关于f1c200s---编译uboot的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/386987

相关文章

maven 编译构建可以执行的jar包

💝💝💝欢迎莅临我的博客,很高兴能够在这里和您见面!希望您在这里可以感受到一份轻松愉快的氛围,不仅可以获得有趣的内容和知识,也可以畅所欲言、分享您的想法和见解。 推荐:「stormsha的主页」👈,「stormsha的知识库」👈持续学习,不断总结,共同进步,为了踏实,做好当下事儿~ 专栏导航 Python系列: Python面试题合集,剑指大厂Git系列: Git操作技巧GO

Windows环境利用VS2022编译 libvpx 源码教程

libvpx libvpx 是一个开源的视频编码库,由 WebM 项目开发和维护,专门用于 VP8 和 VP9 视频编码格式的编解码处理。它支持高质量的视频压缩,广泛应用于视频会议、在线教育、视频直播服务等多种场景中。libvpx 的特点包括跨平台兼容性、硬件加速支持以及灵活的接口设计,使其可以轻松集成到各种应用程序中。 libvpx 的安装和配置过程相对简单,用户可以从官方网站下载源代码

Golang test编译使用

创建文件my_test.go package testsimport "testing"func TestMy(t *testing.T) {t.Log("TestMy")} 通常用法: $ go test -v -run TestMy my_test.go=== RUN TestMyTestMy: my_test.go:6: TestMy--- PASS: TestMy (0.

C++/《C/C++程序编译流程》

程序的基本流程如图:   1.预处理        预处理相当于根据预处理指令组装新的C/C++程序。经过预处理,会产生一个没有宏定义,没有条件编译指令,没有特殊符号的输出文件,这个文件的含义同原本的文件无异,只是内容上有所不同。 读取C/C++源程序,对其中的伪指令(以#开头的指令)进行处理将所有的“#define”删除,并且展开所有的宏定义处理所有的条件编译指令,如:“#if”、“

编译linux内核出现 arm-eabi-gcc: error: : No such file or directory

external/e2fsprogs/lib/ext2fs/tdb.c:673:29: warning: comparison between : In function 'max2165_set_params': -。。。。。。。。。。。。。。。。。。 。。。。。。。。。。。。。 。。。。。。。。 host asm: libdvm <= dalvik/vm/mterp/out/Inte

QT 编译报错:C3861: ‘tr‘ identifier not found

问题: QT 编译报错:C3861: ‘tr’ identifier not found 原因 使用tr的地方所在的类没有继承自 QObject 类 或者在不在某一类中, 解决方案 就直接用类名引用 :QObject::tr( )

hector_quadrotor编译总结 | ubuntu 16.04 ros-kinetic版本

hector_quadrotor编译总结 | ubuntu 16.04 ros-kinetic版本 基于Ubuntu 16.04 LTS系统所用ROS版本为 Kinetic hector_quadrotor ROS包主要用于四旋翼无人机的建模、控制和仿真。 1.安装依赖库 所需系统及依赖库 Ubuntu 16.04|ros-kinetic|Gazebo|gazebo_ros_pkgs|ge

hector_quadrotor编译总结 | ubuntu 14.04 ros-indigo版本

hector_quadrotor编译总结 | ubuntu 14.04 ros-indigo版本 基于Ubuntu 14.04 LTS系统所用ROS版本为 Indigo hector_quadrotor ROS包主要用于四旋翼无人机的建模、控制和仿真。 备注:两种安装方式可选:install the binary packages | install the source files

编译和链接那点事下

http://www.0xffffff.org/?p=357 上回书我们说到了链接以前,今天我们来研究最后的链接问题。         链接这个话题延伸之后完全可以跑到九霄云外去,为了避免本文牵扯到过多的话题导致言之泛泛,我们先设定本文涉及的范围。我们今天讨论只链接进行的大致步骤及其规则、静态链接库与动态链接库的创建和使用这两大块的问题。至于可执行文件的加载、可执行文件的运行时

编译和链接那点事上

http://www.0xffffff.org/?p=323  有位学弟想让我说说编译和链接的简单过程,我觉得几句话简单说的话也没什么意思,索性写篇博文稍微详细的解释一下吧。其实详细的流程在经典的《Linkers and Loaders》和《深入理解计算机系统》中均有描述,也有国产的诸如《程序员的自我修养——链接、装载与库》等大牛著作。不过,我想大家恐怕很难有足够的时间去研读这些厚如