修改Makefile,添加交叉编译器

CROSS_COMPILE必须使用绝对路径

ARCH ?= arm
CROSS_COMPILE ?= /root/tool/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-

添加中文支持

libbb/printable_string.c文件

//printable_string 方法

//注释掉
if (c >= 0x7f)
	break;
	
//即
if (c < ' ')
	break;
/* if (c >= 0x7f)
	break; */
//ENABLE_UNICODE_SUPPORT 判断项

//注释掉
if (c < ' ' || c >= 0x7f)

//添加
if( c < ' ')
//即
while (1) {
	unsigned char c = *d;
	if (c == '\0')
		break;
	if (c < ' ' || c >= 0x7f)
		*d = '?';
	d++;
}

libbb/unicode.c文件

*d++ = (c >= ' ' && c < 0x7f) ? c : '?';
//改成
*d++ = (c >= ' ') ? c : '?';
//即
while ((int)--width >= 0) {
	unsigned char c = *src;
	if (c == '\0') {
		do
			*d++ = ' ';
		while ((int)--width >= 0);
		break;
	}
	// *d++ = (c >= ' ' && c < 0x7f) ? c : '?';
	*d++ = (c >= ' ') ? c : '?';
	src++;
}
/* if (c < ' ' || c >= 0x7f) */
//改成
if(c < ' ')
//即
while (*d) {
	unsigned char c = *d;
	// if (c < ' ' || c >= 0x7f)
	if(c < ' ')
		*d = '?';
	d++;
}

配置busybox

①、defconfig,缺省配置,也就是默认配置选项。

②、allyesconfig,全选配置,也就是选中 busybox 的所有功能

③、allnoconfig,最小配置。

默认使用defconfig

make defconfig
make menuconfig

在图形配置界面做以下配置

静态编译 busybox 还是动态编译

选中为静态编译,我们不选中

Location: 
 -> Settings 
	-> Build static binary (no shared libs)

选中

Location: 
  -> Settings 
	-> vi-style line editing commands

使能 busybox 的 unicode 编码以支持中文

Location: 
 -> Settings
   -> Support Unicode //选中
	 -> Check $LC_ALL, $LC_CTYPE and $LANG environment variables //选中

不选中

Location: 
  -> Linux Module Utilities
	-> Simplified modutils

选中

Location: 
  -> Linux System Utilities 
 	-> mdev (16 kb) //确保下面的全部选中,默认都是选中

编译报错问题

系统时间问题解决在.config文件中注释掉这两个

#CONFIG_RDATE=y
#CONFIG_DATE=y

编译

make
//清除配置 make distclean

make后---命令行会问要不要打开CONFIG_DATE,输入n后回车,再次询问要不要打开CONFIG_RDATE,输入n后回车

make install CONFIG_PREFIX=/root/tool/rootfs/maked-zdyz

编译完成,在/root/tool/rootfs/maked-zdyz有相应文件

添lib加库文件

  • 移动/root/tool/rootfs/maked-zdyz所有文件到/srv/nfs文件夹下
cp -rf /root/tool/rootfs/maked-zdyz/* /srv/nfs
  • 在/root/tool/rootfs/maked-zdyz新建lib文件夹

  • 复制交叉编译器里面的库文件

cd /root/tool/arm-linux-gnueabihf/arm-linux-gnueabihf/libc/lib
cp *so* *.a /srv/nfs/lib/ -d   “-d”表示拷贝符号链接

rm /srv/nfs/lib/ld-linux-armhf.so.3  软链接删除
cp /root/tool/arm-linux-gnueabihf/arm-linux-gnueabihf/libc/lib/ld-linux-armhf.so.3 /srv/nfs/lib/ 

cd /root/tool/arm-linux-gnueabihf/arm-linux-gnueabihf/lib
cp *so* *.a /srv/nfs/lib/ -d

mkdir /srv/nfs/usr/lib
cd /root/tool/arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/lib
cp *so* *.a /srv/nfs/usr/lib -d
  • 查看文件系统大小
cd /srv/nfs
du ./lib ./usr/lib/ -sh

//
root@wyl:/srv/nfs# du ./lib ./usr/lib/ -sh
57M     ./lib
67M     ./usr/lib/
  • 创建其他文件夹
mkdir dev proc mnt sys tmp root

挂载测试

nfs配置命令

root=/dev/nfs nfsroot=[<server-ip>:]<root-dir>[,<nfs-options>] ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>:<dns0-ip>:<dns1-ip

服务器 IP 地址,也就是存放根文件系统主机的 IP 地址,那就是 Ubuntu 的 IP 地址。

根文件系统的存放路径,/srv/nfs

NFS 的其他可选选项,一般不设置

客户端 IP 地址,也就是我们开发板的 IP 地址,Linux 内核启动以后就会使用 此 IP 地址来配置开发板。

服务器 IP 地址

网关地址192.168.0.1

子网掩码,255.255.255.0。

客户机的名字,一般不设置,此值可以空着。

设备名,也就是网卡名,一般是 eth0,eth1

自动配置,一般不使用,所以设置为 off。

DNS0 服务器 IP 地址,不使用

DNS1 服务器 IP 地址,不使用

在uboot命令行输入

setenv bootargs 'console=ttymxc0,115200 root=/dev/nfs nfsroot=192.168.0.254:/srv/nfs,proto=tcp rw ip=192.168.0.155:192.168.0.254:192.168.0.1:255.255.255.0::eth1:off'//设置 bootargs
saveenv //保存环境变量

或者

setenv bootargs 'console=ttymxc0,115200 root=/dev/nfs nfsroot=192.168.0.254:/srv/nfs,v3,tcp ip=dhcp'

启动linux

tftp 80800000 zImage-alientek
tftp 83000000 imx6ull-alientek-emmc.dtb
bootz 80800000 - 83000000