1、官方文档中提到需要安装以下:

lib32ncurses5
lib32z1
u-boot-tools
libstdc++6
libncurses5-dev
liblzo2-dev:i386,
mtd-utils

首先先检查系统是否已经安装支持运行以下脚本:

for pkg in lib32ncurses5 lib32z1 libstdc++6 libncurses5-dev liblzo2-dev mtd-utils u-boot-tools liblzo2-dev:i386; do
    if dpkg -s "$pkg" >/dev/null 2>&1; then
        echo "✅ $pkg 已安装"
    else
        echo "❌ $pkg 未安装"
    fi
done

输出如下:

❌ lib32ncurses5 未安装
❌ lib32z1 未安装
✅ libstdc++6 已安装
❌ libncurses5-dev 未安装
❌ liblzo2-dev 未安装
❌ mtd-utils 未安装
✅ u-boot-tools 已安装
❌ liblzo2-dev:i386 未安装

安装缺失的包:

# 更新包列表
sudo apt update

# 安装所有缺失的包
sudo apt install \
    lib32ncurses5 \
    lib32z1 \
    libstdc++6 \
    libncurses5-dev \
    liblzo2-dev \
    mtd-utils \
    u-boot-tools

安装32 位开发库(如liblzo2-dev:i386):

# 启用 i386 架构支持(首次需要)
sudo dpkg --add-architecture i386
sudo apt update

# 安装 i386 版本
sudo apt install liblzo2-dev:i386

2.安装工具链:

解压 tools/riscv64-anyka-linux-musl.tar.gz,到/opt目录

sudo tar zxvf riscv64-anyka-linux-musl.tar.gz
sudo mv riscv64-anyka-linux-musl /opt

3.进入SDK源码目录,使用./auto_build.sh应能正常编译通过

 ./auto_build.sh 

可是遇到发下报错:

./mkfs.jffs2: not found

检查发现明明已经安装

$which mkfs.jffs2
/usr/sbin/mkfs.jffs2

查找错误原因:在脚本 create_jffs2fs.sh 第 22 行写着:

./mkfs.jffs2 [参数...]

这表示:在当前目录执行 mkfs.jffs2

运行:

file mkfs.jffs2

输出:

mkfs.jffs2: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, BuildID[sha1]=fe1d475322a64cab2dbf0268ba1de74fb100fd4f, with debug_info, not stripped

安装 32 位运行时支持,才能运行这个 32 位的 mkfs.jffs2

# 启用 i386 架构
sudo dpkg --add-architecture i386

# 更新包列表
sudo apt-get update

# 安装 32 位运行时核心库
sudo apt-get install libc6:i386 libstdc++6:i386

然后测试:

./mkfs.jffs2 --help

输出:

./mkfs.jffs2: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

安装 32 位 zlib 库

sudo apt-get install zlib1g:i386

然后测试:

./mkfs.jffs2 --help

输出:

./mkfs.jffs2: error while loading shared libraries: liblzo2.so.2: cannot open shared object file: No such file or directory

安装 32 位 LZO2 运行时库

sudo apt-get install liblzo2-2:i386

验证:

./mkfs.jffs2 --help
mkfs.jffs2: error!: Usage: mkfs.jffs2 [OPTIONS]
Make a JFFS2 file system image from an existing directory tree

Options:
  -p, --pad[=SIZE]        Pad output to SIZE bytes with 0xFF. If SIZE is
                          not specified, the output is padded to the end of
                          the final erase block
  -r, -d, --root=DIR      Build file system from directory DIR (default: cwd)
  -s, --pagesize=SIZE     Use page size (max data node size) SIZE.
                          Set according to target system's memory management
                          page size (default: 4KiB)
  -e, --eraseblock=SIZE   Use erase block size SIZE (default: 64KiB)
  -c, --cleanmarker=SIZE  Size of cleanmarker (default 12)
  -m, --compr-mode=MODE   Select compression mode (default: priortiry)
  -x, --disable-compressor=COMPRESSOR_NAME
                          Disable a compressor
  -X, --enable-compressor=COMPRESSOR_NAME
                          Enable a compressor
  -y, --compressor-priority=PRIORITY:COMPRESSOR_NAME
                          Set the priority of a compressor
  -L, --list-compressors  Show the list of the avaiable compressors
  -t, --test-compression  Call decompress and compare with the original (for test)
  -n, --no-cleanmarkers   Don't add a cleanmarker to every eraseblock
  -o, --output=FILE       Output to FILE (default: stdout)
  -l, --little-endian     Create a little-endian filesystem
  -b, --big-endian        Create a big-endian filesystem
  -D, --devtable=FILE     Use the named FILE as a device table file
  -f, --faketime          Change all file times to '0' for regression testing
  -q, --squash            Squash permissions and owners making all files be owned by root
  -U, --squash-uids       Squash owners making all files be owned by root
  -P, --squash-perms      Squash permissions on all files
  -h, --help              Display this help text
  -v, --verbose           Verbose operation
  -V, --version           Display version information
  -i, --incremental=FILE  Parse FILE and generate appendage output for it

Logo

智能硬件社区聚焦AI智能硬件技术生态,汇聚嵌入式AI、物联网硬件开发者,打造交流分享平台,同步全国赛事资讯、开展 OPC 核心人才招募,助力技术落地与开发者成长。

更多推荐