BusyBox-root file system construction

One: Modify Makefile

164 CROSS_COMPILE ?= /home/jun/work/tool/arm-linux-gcc/gcc-linaro-4.9.4-2017.01-x86_64_arm- 
    linux-gnueabihf/bin/arm-linux-gnueabihf-

192 ARCH ?= arm

2: Modify busybox to support Chinese characters

Modify busybox-1.29.0/libbb/printable_string.c: modify (1) (2)

const char* FAST_FUNC printable_string(uni_stat_t *stats, const char *str)
{
	while (1) {
... ...
		if (c < ' ')
			break;
		// if (c >= 0x7f)                                 /* (1) */
		// 	break;
		s++;
	}

#if ENABLE_UNICODE_SUPPORT
	dst = unicode_conv_to_printable(stats, str);
#else
	{
		char *d = dst = xstrdup(str);
		while (1) {
			unsigned char c = *d;
			if (c == '\0')
				break;
			// if (c < ' ' || c >= 0x7f)                  /* (2) */  
			if(c < ' ')
				*d = '?';
			d++;
		}
	}
#endif
	return auto_string(dst);
}

Modify busybox-1.29.0/libbb/unicode.c: modify (1) (2)

static char* FAST_FUNC unicode_conv_to_printable2(uni_stat_t *stats, const char *src, unsigned width, int flags)
{
	if (unicode_status != UNICODE_ON) {
		char *d;
		if (flags & UNI_FLAG_PAD) {
			d = dst = xmalloc(width + 1);
			while ((int)--width >= 0) {
				unsigned char c = *src;
				if (c == '\0') {
					do
						*d++ = ' ';
					while ((int)--width >= 0);
					break;
				}
				// *d++ = (c >= ' ' && c < 0x7f) ? c : '?';        /* (1) */
				*d++ = (c >= ' ') ? c : '?';
				src++;
			}
			*d = '\0';
		} else {
			d = dst = xstrndup(src, width);
			while (*d) {
				unsigned char c = *d;
				// if (c < ' ' || c >= 0x7f)                       /* (2) */
				if (c < ' ')
					*d = '?';
				d++;
			}
		}
	}
}

Three: Configure busybox

Configure busybox by default and then perform graphical detailed configuration

make defconfig
make menuconfig

1. Dynamic compilation settings

Location: -> Settings -> Build static binary (no shared libs) cannot be checked.

2. Vi command line editing

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

3. Unsimplify

Location: -> Linux Module Utilities -> Simplified modutils uncheck

4. Enable unicode

Location: -> Settings -> Support Unicode check

Four: compile busybox

Create a rootfs file and set the nfs environment value:

sudo vi /etc/exports

/home/jun/work/nfs/rootfs *(rw,sync,no_root_squash)

sudo /etc/init.d/nfs-kernel-server restart

Specify the compilation result in the rootfs file created in advance:

make install CONFIG_PREFIX=/home/jun/work/nfs/rootfs

Five: add lib library

1. Create a lib folder under the rootfs directory

2. Copy the libc/lib file in the installed cross compilation tool to the lib directory of rootfs.

jun@zero:~/work/tool/arm-linux-gcc/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/lib$ 

cp *so* *.a /home/jun/work/nfs/rootfs/lib/ -d

The file "ld-linux-armhf.so.3" cannot be used as a symbolic link and needs to be changed from "link mode" to "source file".

Delete the symbolic link file copied to the rootfs/lib directory and copy it again

cp ld-linux-armhf.so.3 /home/jun/work/nfs/rootfs/lib

3. Copy the files in the libc/usr/lib directory to the rootfs/usr/lib directory.

jun@zero:~/work/tool/arm-linux-gcc/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/libc/usr/lib$ 

cp *so* *.a ~/work/nfs/rootfs/usr/lib/ -d

Six: Create other folders

jun@zero:~/work/nfs/rootfs$ mkdir dev proc mnt sys tmp root
jun@zero:~/work/nfs/rootfs$ ls
bin  dev  lib  linuxrc  mnt  proc  root  sbin  sys  tmp  usr

Seven: Improve the root file system

1. Create /etc/init.d/rcS and give permission "chmod 777 rcS"

#!/bin/sh

PATH=/sbin:/bin:/usr/sbin:/usr/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib:/usr/lib
export PATH LD_LIBRARY_PATH runlevel

mount -a
mkdir /dev/pts
mount -t devpts devpts /dev/pts

echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s

2. Create /etc/fstab

#<file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
tmpfs /tmp tmpfs defaults 0 0
sysfs /sys sysfs defaults 0 0

 

Guess you like

Origin blog.csdn.net/qq_34968572/article/details/103084347