Skip to main content

AD100快启进阶

此方案不做技术支持,只针对高定制客户的流程说明.

一 概述

​ AD100 的快速启动流程是spl -> rtos -> kernel -> rootfs, 其中kernel使用zip压缩分包压缩, rootfs使用squashfs的zstd压缩, rtos负责初始化的lcd和加载解压kernel, 大部分lcd初始化都需要300ms左右, 目前kernel加载和解压比lcd初始化还快.

​ 优化思路->把rootfs压缩进kernel, 用内存空间换启动速度.

​ 大致收益:

  • 4-5m的内存换取200ms启动速度.
  • 可以实现squashfs文件系统动态挂载, 把升级程序放到rootfs.cpio实现升级squashfs文件系统,而不用多个rootfs分区.

二 linux配置及编译

以配置文件ad100_cpio_nor_defconfig为例(未配置任何外设及驱动,请根据实际硬件自己添加)

2.1 spl配置

修改uboot配置, 目录bootloader/uboot-x2000/include/configs/ad100_base.h

-#define CONFIG_ROOTFS_SQUASHFS
-#define CONFIG_ROOTFS2_SQUASHFS
+#define CONFIG_ROOTFS_RAMDISK
+#define CONFIG_ROOTFS2_RAMDISK

2.2 编译

bhu@bhu-PC:~/ad100$ cd build
bhu@bhu-PC:~/ad100/build$ make clean
bhu@bhu-PC:~/ad100/build$ make ad100_cpio_nor_defconfig
bhu@bhu-PC:~/ad100/build$ make

编译后生成固件如下:

bhu@bhu-PC:~/ad100/build$ ls -lh output/
总用量 7.0M
-rw-r--r-- 1 bhu bhu 4.3M 7月 11 11:01 rootfs.cpio
-rw-r--r-- 1 bhu bhu 24K 7月 11 11:01 u-boot-spl-pad.bin
-rw-r--r-- 1 bhu bhu 2.8M 7月 11 11:05 uImage_split

复制rootfs.cpio文件到kernel目录下

bhu@bhu-PC:~/ad100/build$ cp output/rootfs.cpio ../kernel/kernel

vmlinux.bin + rootfs.cpio 内核加文件系统未压缩前的大小控制在12M以内才有收益, 不能超过16M, 目前rtos跑在16M的位置

需要具备kernel深度裁剪能力,rootfs深度裁剪能力. (没有技术支持)

bhu@bhu-PC:~/ad100/build$ cd ../kernel/kernel
bhu@bhu-PC:~/ad100/kernel/kernel$ ls -lh arch/mips/boot/vmlinux.bin
-rwxr-xr-x 1 bhu bhu 4.9M 711 14:23 arch/mips/boot/vmlinux.bin
bhu@bhu-PC:~/ad100/kernel/kernel$ ls -lh rootfs.cpio
-rw-r--r-- 1 bhu bhu 4.0M 711 14:24 rootfs.cpio

2.3 kernel修改

bhu@bhu-PC:~/ad100/kernel/kernel$ make menuconfig

1

保存后, 重新编译kernel

bhu@bhu-PC:~/ad100/kernel/kernel$ cd -
/home/bhu/ad100/build
bhu@bhu-PC:~/ad100/build$ make kernel

三 rtos配置及编译

以配置文件ad100_evb_v10_quick_start_lcd_nor_defconfig为例, 配置了lcd,背光以及fb用于显示logo

修改rtos压缩方式

bhu@bhu-PC:~/rtos$ cd freertos/
bhu@bhu-PC:~/rtos/freertos$ make menuconfig

5

保存并退出, 在/rtos工程目录/freertos/vendor/vendor.c内, 修改代码如下:

#include <stdio.h>
#include "../example/driver/quick_boot_logo_and_load_split_uimage_example.c"
void vendor_init(void *arg)
{
printf("vendor init...\n");
quick_boot_logo_and_load_kernel(arg);
}

编译rtos系统:

bhu@bhu-PC:~/rtos/freertos$ source build/envsetup.sh
bhu@bhu-PC:~/rtos/freertos$ make ad100_evb_v10_quick_start_lcd_nor_defconfig
bhu@bhu-PC:~/rtos/freertos$ make

四 烧录

2

3

rtos分区烧录/rtos工程目录/freertos/zero.bin文件, kernel分区烧录/linux工程目录/build/output/uImage_split文件, 不用烧录文件系统

4