根文件系统制作除了使用 busybox来制作外,还有很多成熟化的根文件系统构建方式,例如 buildroot,yocto。
BusyBox 是一个集成了大量的 Linux 命令和工具的软件,像 ls、mv、ifconfig 等命令 BusyBox 都会提供。BusyBox 就是一 个大的工具箱,这个工具箱里面集成了 Linux 的许多工具和命令。一般下载 BusyBox 的源码, 然后配置 BusyBox,选择自己想要的功能,最后编译即可。
这里我们使用 busybox 打包制作根文件系统。构建的根文件系统调试,我们通过 nfs 网络挂载,也就是将根文件系统存放到 ubuntu系统下,开发板启动以后,通过 nfs服务使用 ubuntu下的根文件系统。
BusyBox 可以在其官网下载到,官网地址为:
https://busybox.net/
打开官网后,如下打开 "Download Source" 选项,如下:
将正点原子提供的 busybox源码包拷贝到 ubuntu系统下,并加压源码包。之后通过 vscode打开 busybox源码。
更改分两个部分:printable_string.c 与 unicode.c 更改。
const char* FAST_FUNC printable_string(uni_stat_t *stats, const char *str)
{
char *dst;
const char *s;
s = str;
while (1) {
...................................
/* 注释掉下面这个两行代码 */
/* if (c >= 0x7f)
break; */
s++;
}
#if ENABLE_UNICODE_SUPPORT
dst = unicode_conv_to_printable(stats, str);
#else
{
...................................
/* 修改下面代码 */
/* if (c < ' ' || c >= 0x7f) */
if(c < ' ')
*d = '?';
d++;
}
if (stats) {
stats->byte_count = (d - dst);
stats->unicode_count = (d - dst);
stats->unicode_width = (d - dst);
}
}
#endif
return auto_string(dst);
}
可以看出,屏蔽了 第10~11行的代码:即当字符大于 0X7F 以后就跳出去了。
去掉了第 21行关于当字符大于 0X7F 的判断。
static char* FAST_FUNC unicode_conv_to_printable2(uni_stat_t *stats, const char *src, unsigned width, int flags)
{
char *dst;
unsigned dst_len;
unsigned uni_count;
unsigned uni_width;
if (unicode_status != UNICODE_ON) {
char *d;
if (flags & UNI_FLAG_PAD) {
d = dst = xmalloc(width + 1);
while ((int)--width >= 0) {
............................................
/* 修改下面一行代码 */
/* *d++ = (c >= ' ' && c < 0x7f) ? c : '?'; */
*d++ = (c >= ' ') ? c : '?';
src++;
}
*d = '\0';
} else {
d = dst = xstrndup(src, width);
while (*d) {
unsigned char c = *d;
/* 修改下面一行代码 */
/*if (c < ' ' || c >= 0x7f) */
if(c < ' ')
*d = '?';
d++;
}
.............................................
}
可以看出,第 15行,当字符大于 0X7F 以后,*d++就为‘?’。将这一行进行更改。
第 25 行,,当字符大于 0X7F 以后,*d 也为‘?’。 也更改这一行判断。