这里选用ubuntu 64bit 16.04的系统
参考到:
https://blog.csdn.net/qq_39436605/article/details/9008136
https://blog.csdn.net/weixin_30363817/article/details/9526648
目录
1./bin/sh: 1: pushd: not found错误
9.internal compiler error: Killed
1./bin/sh: 1: pushd: not found错误
不能压栈入栈,因为pushd命令需要在bash的环境中执行,所以需要修改系统默认shell为bash
- 步骤1.which sh,结果是/bin/sh
- 步骤2.ls -l /bin/sh,结果sh指向dash
- 步骤3.sudo rm /bin/sh
- 步骤4.sudo ln -s /bin/bash /bin/sh
- 步骤5.ls -l /bin/sh,结果sh指向bash
2.交叉编译配置错误
make[2]: arm-hisiv300-linux-gcc: Command not found
原因
-
交叉编译工具链未安装。
-
由于嵌入式单板的资源有限,不能在单板上运行开发和调试工具,通常需要交叉编译调试的方式进行开发和调试,即“宿主机+目标机(评估板)”的形式。
-
宿主机和目标机的处理器一般不相同。宿主机需要建立合适于目标机的交叉编译环境。程序在宿主机上经过“编译-链接-定位”得到可执行文件。通过一定的方法将可执行文件烧写到目标机中,然后再目标机上运行。所谓的交叉编译也就是A机编译,B机运行。
-
发布包提供两种编译工具链arm-hisiv300-linux 和 arm-hisiv400-linux,其中 arm-hisiv300-linux 为基于 uclibc 的工具链, arm-hisiv400-linux 为基于 glibc 的工具链。 uclibc比 glibc要小很多,因此我们选用arm-hisiv300-linux。
解决方法
- 步骤1,进入工具链及其安装程序的目录位置:Hi3518E_SDK_V1.0.3.0/osdrv/opensource/toolchain/arm-hisiv300-linux
- 步骤2,解压工具链:tar -xvf arm-hisiv300-linux.tar.bz2
- 步骤3,安装工具链:sudo ./cross.install.v300
- 步骤4,进入交叉编译工具链的挂载目录:cd /opt/hisi-linux/x86-arm/arm-hisiv300-linux/bin
- 步骤5,ls 【发现里面有很多arm-hisiv300-linux-uclibcgnueabi-xxx编译工具链】
- 步骤6,file file arm-hisiv300-linux-uclibcgnueabi-gcc 【ELF 32-bit LSB executable,也就是说这个交叉编译工具链是32位的,但是我是用的虚拟机上Ubuntu16.04是64位的,因此必须安装32位的兼容包】
- 步骤7,cd ../target/bin
- 步骤8,ls 【发现里面有很多arm-hisiv300-linux-xxx编译工具链,这些是arm-hisiv300-linux-uclibcgnueabi-xxx的符号链接,就是我们要找的arm-hisiv300-linux工具链,可以用ls -l查看】
- 步骤9,pwd 【/opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/bin,记住这个路径,需要将这个路径导入到环境变量中:见步骤9,10】
- 步骤10,vi ~/.bashrc,在文件末尾追加export PATH=/opt/hisi-linux/x86-arm/arm-hisiv300-linux/target/bin:$PATH
- 步骤11,source ~/.bashrc 【确保环境变量设置生效.,可以用echo $PATH查看是否成功导入】
- 步骤12,ping www.baidu.com 【确保虚拟机能上网】
- 步骤13,sudo aptitude install lib32z1 【注意:要安装任何软件之前,一定要确保虚拟机能上网】
- 步骤14,sudo aptitude install lib32stdc++6-4.8-dbg 【注意:要安装任何软件之前,一定要确保虚拟机能上网】
3.32位库问题
Ubuntu16.04 error while loading shared libraries: libstdc++.so.6解决方法
https://blog.csdn.net/chxw098/article/details/79470508
解决方法:apt install lib32stdc++6-4.8-dbg
4.uboot编译出错了,未能找到mkimage
解决方法:
将编译生成的mkimage工具放到我们全局的文件夹下,能访问的到。
5.缺少zlib库错误
问题定位:系统中没有安装zlib的库
解决方法有两个:
1)在我们使用的SDK中Hi3518E_SDK_V1.0.4.0是有这个工具的
zlib.h在osdrv/tools/pc/zlib/tmp/include目录中有,只需要复制到osdrv/tools/pc/jffs2_tool/tmp/include目录中即可。注意同时要将zconf.h也复制过去的。还有,要将tools/pc/jffs2_tool/tmp/lib目录下的libz.a libz.so libz.so.1 libz.so.1.2.7等4个文件复制到tools/pc/jffs2_tool/tmp/lib目录下。
[root@Mrtan pc]# ls
cramfs_tool jffs2_tool mkimage_tool nand_production ubifs_config zlib
ext4_utils lzma_tool mkyaffs2image squashfs4.2 uboot_tools
[root@Mrtan pc]# cd jffs2_tool/
[root@Mrtan jffs2_tool]# ls
lzo-2.09.tar.gz Makefile mtd-utils-1.5.0.tar.bz2 tmp
[root@Mrtan jffs2_tool]# cd tmp/
[root@Mrtan tmp]# ls
include lib lzo-2.09 mtd-utils-1.5.0 share
[root@Mrtan tmp]# cp ./../../zlib/tmp/include/zlib.h ./include/
[root@Mrtan tmp]# cp ./../../zlib/tmp/include/zconf.h ./include/
[root@Mrtan tmp]# cp ./../../zlib/tmp/lib/
libz.a libz.so libz.so.1 libz.so.1.2.7 pkgconfig/
[root@Mrtan tmp]# cp ./../../zlib/tmp/lib/* ./lib/
cp: omitting directory ‘./../../zlib/tmp/lib/pkgconfig’
[root@Mrtan tmp]# pwd
/work/hi3518e/Hi3518E_SDK_V1.0.4.0/osdrv/tools/pc/jffs2_tool/tmp
[root@Mrtan tmp]#
5.serve_image.c:32:18: error: storage size of ‘hints’ isn’t known
原因
在于ubuntu操作系统版本太高,而SDK使用的mtd-utils版本太低导致
解决方法
修改操作系统头文件/usr/include/netdb.h,将此宏__USE_XOPEN2K注释,如下图(注意#ifdef与#endif是一一对应的)
- 步骤1,sudo vi /usr/include/netdb.h
- 步骤2,:set nu 【显示行号】
- 步骤3,/__USE_XOPEN2K 【搜索】
- 步骤4,将第79行的#if defined __USE_XOPEN2K || defined __USE_XOPEN_EXTENDED和相应的第82行的#endif用//注释掉
- 步骤5,/__USE_XOPEN2K 【搜索】
- 步骤6,第565行的#ifdef __USE_XOPEN2K和第681行的的#endif用//注释掉 【用:681命令跳转到681行】
进入osdrv,继续编译
make OSDRV_CROSS=arm-hisiv300-linux CHIP=hi3518ev200 all
6.
关于这个问题,在这个链接中有详细的描述:
https://blog.csdn.net/weixin_30363817/article/details/95266483
mkfs.ubifs/hashtable/hashtable_itr.c:42:1: error: redefinition of ‘hashtable_iterator_key’
-----------
Makefile:204: recipe for target 'hipctools' failed
原因:
mtd-utils_1.5.0.tar.bz2 库的问题,大家可以更新到 mtd-utils_1.5.2.tar.bz2 重新编译就可以了;
mtd-utils_1.5.2.tar.bz2的下载地址:http://nl.archive.ubuntu.com/ubuntu/pool/universe/m/mtd-utils/mtd-utils_1.5.2.orig.tar.bz2
分析以及解决方案
总结:经过百度搜索以及各种探索,发现我不能解决这个问题,因此决定把这个问题跳过去
分析
根据打印的错误信息分析,因为:
mkfs.ubifs/hashtable/hashtable_itr.c:42:1: error: redefinition of ‘hashtable_iterator_key’
-----------
Makefile:204: recipe for target 'hipctools' failed
所以要研究总Makefile里面的'hipctools'部分:
hipctools: prepare
@echo "---------task [5] build tools which run on pc"
make -C $(OSDRV_DIR)/tools/pc/mkyaffs2image/
cp $(OSDRV_DIR)/tools/pc/mkyaffs2image/bin/$(YAFFS_TOOL) $(OSDRV_DIR)/pub/bin/pc
make -C $(OSDRV_DIR)/tools/pc/jffs2_tool/
cp $(OSDRV_DIR)/tools/pc/jffs2_tool/mkfs.jffs2 $(OSDRV_DIR)/pub/bin/pc
cp $(OSDRV_DIR)/tools/pc/jffs2_tool/mkfs.ubifs $(OSDRV_DIR)/pub/bin/pc
cp $(OSDRV_DIR)/tools/pc/jffs2_tool/ubinize $(OSDRV_DIR)/pub/bin/pc
7.ncurses or ncursesw error
configure: error: ncurses or ncursesw selected, but library not found (--without-ncurses to disable)
步骤1,sudo apt-get install libncurses5-dev libncursesw5-dev
8.cramfs错误
然后到了这里,就是之前centos系统遇到到问题,这里单独看是没办法解决的。其实我们这里并没有用到cramfs,所以我们要去修改Makefile
9.internal compiler error: Killed
这个问题,主要我实在阿里云服务器上实验的,配置不怎么高,所以导致这个问题,经过查找,发现可能是内存不够
参考到:https://blog.csdn.net/little_stupid_child/article/details/79188015
内存不足引起“gcc: internal compiler error: Killed (program cc1plus)”以及解决办法
解决方法:
主要问题是内存不足导致的,可以通过增加swap交换分区来解决
操作:
sudo mkdir -p /var/cache/swap/
sudo dd if=/dev/zero of=/var/cache/swap/swap0 bs=1M count=512
sudo chmod 0600 /var/cache/swap/swap0
sudo mkswap /var/cache/swap/swap0
sudo swapon /var/cache/swap/swap0
然后还有一个可能是译错误:/usr/bin/ld: i386:x86-64 architecture of input file `mkyaffs2image.o' is incompatible with i386 output
这个是因为sdk中本来就有在64位系统下编译的.o文件,而我们用的是32位的ubuntu,解决办法是进入tools/pc/mkyaffs2image/mkyaffs2image目录下,rm *.o(或者make clean)删除所有之前编译的痕迹即可。
10 结果
出现---------finish osdrv work,表示整个osdrv编译成功
- 总结:此时只有mkfs.ubifs/hashtable/hashtable_itr.c:42:1: error: redefinition of ‘hashtable_iterator_key’被跳过了。拍摄快照。
11 查看成果
查看:
- cd /work/hi3518e/Hi3518E_SDK_V1.0.4.0/osdrv/pub/image_uclibc
4.8M rootfs_hi3518ev200_128k.jffs2
4.8M rootfs_hi3518ev200_256k.jffs2
12M rootfs_hi3518ev200_2k_4bit.yaffs2
4.8M rootfs_hi3518ev200_64k.jffs2
273K u-boot-hi3518ev200.bin
2.6M uImage_hi3518ev200
因为我们是在/work/hi3518e/Hi3518E_SDK_V1.0.4.0/osdrv/pub/bin/pc下,放置了mkfs.jffs2工具,所以在最后生成的文件系统中是有一个yaffs的文件,若需要其他类型的文件系统,也需要将相应的可执行程序放入该目录下
如果我们在编译时,前面的uboot,kernel编译都没问题,只是后面的rootfs出现问题,我们在执行编译命令时,是会全部重新编译。其实我们也有方法做到只编译后面的部分的,那就是去更改Makefile.
比如在Makefile中的:
hiboot:prepare 的内容就只留下一段echo
hikernel:prepare下也是如此
其实对应的hibusybox 部分也是可以干掉的
然后hipctools:prepare下也只剩一条echo
hiboardtools是将来会编译用到板子中去的,所以主要是busybox和boardtools我们都是需要的