嵌入式Linux开发常见问题记录

1. 已经包含string.h,还是缺少memset

原因:链接的时候没有连接标准库

解决办法:在arm-linux-ld命令加上libc.a库

arm-linux-ld /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/lib/libc.a

2. 交叉编译后在开发板上运行,出现-sh: ./hello: not found

hello是程序名字

原因:开发板缺少动态库

解决办法:arm-linux-readelf hello 查看依赖库,发现缺少ld-linux-so.3,将该文件拷贝至开发板lib目录

3. 交叉编译后在开发板上运行,出现Illegal instruction

紧接问题3出现的问题

原因:arm-linux-gcc版本与编译内核版本不一致,arm-linux-gcc版本为4.3.2,开发板linux内核为2.6,应该用arm-linux-gcc 3.4.5

解决办法:删除arm-linux-gcc 4.3.2,解压arm-linux-gcc 3.4.5,修改/etc/profile,使用

sudo /etc/profile

使用source /etc/profile使修改的变量立即生效,成功更改版本,重新编译程序,在开发板上运行,成功。

4. 开发板挂载网络系统后,使用cp命令复制文件出现nfs server not responding

解决办法:用如下命令重新挂载

 mount -t nfs -o intr,nolock,rsize=1024,wsize=1024 169.254.48.98:/work/nfs_root /mnt

5.编译内核出错:Can‘t use ‘defined(@array)‘ (Maybe you should just omit the defined()?)

高版本Ubuntu下进行交叉编译内核,出现如下错误。

1

make CROSS_COMPILE=arm-arago-linux-gnueabi- ARCH=arm uImage

1
2
3
4

Can't use 'defined(@array)' (Maybe you should just omit the defined()?) at kernel/timeconst.pl line 373.
make[1]: *** [/*/kernel-3.2/kernel/Makefile:141: kernel/timeconst.h] Error 255
make: *** [Makefile:945: kernel] Error 2
mv: cannot stat 'arch/arm/boot/uImage': No such file or directory

问题分析:版本升级中存在的bug。

解决方案:根据提示信息,对kernel/timeconst.pl文件做如下修改。再进行编译,问题解决。

修改前:

1
2
3
4
5

    @val = @{$canned_values{$hz}};
    if (!defined(@val)) {
        @val = compute_values($hz);
    }
    output($hz, @val);

修改后:

1
2
3
4
5

    @val = @{$canned_values{$hz}};
    if (!(@val)) {
        @val = compute_values($hz);
    }
    output($hz, @val);

6.编译内核时"mkimage" command not found - U-Boot images will not be built

第一步:编译uboot,这时将会在uboot/tools下生成mkimage工具;

第二步:声明环境变量,在/etc/bash.bashrc中添加如下语句:

export PATH=/opt/program/mx53_android/uboot/tools:$PATH

这里要和自己的uboot的路径对应。

然后更新bashrc脚本:

source /etc/bash.bashrc

注意一定要在和编译内核同一个终端执行该语句,否则同样会出现

"mkimage" command not found - U-Boot images will not be built

的错误。

由于我们随时可能清空掉uboot中的编译文件,这意味着mkimage文件随时会被清除,我们

可以将它复制到/usr/bin下,然后在bashrc中声明,以确保内核正常编译。

7.编译内核,配置时make s3c2410_defconfig出现问题usr/include/x86_64-linux-gnu/sys/types.h:25:22: fatal error: features.h: No such file or directory

make s3c2410_defconfig
  HOSTCC  scripts/basic/fixdep
In file included from scripts/basic/fixdep.c:107:0:
/usr/include/x86_64-linux-gnu/sys/types.h:25:22: fatal error: features.h: No such file or directory
compilation terminated.
scripts/Makefile.host:118: recipe for target 'scripts/basic/fixdep' failed
make[1]: *** [scripts/basic/fixdep] Error 1
Makefile:349: recipe for target 'scripts_basic' failed
make: *** [scripts_basic] Error 2

原因:编译环境被不明原因破坏

解决办法:

sudo apt-get install build-essential

持续更新
 

猜你喜欢

转载自blog.csdn.net/freestep96/article/details/126640926