Skip to content

B860AV2.1刷linux(未完成)

Updated: at 02:46

通过本篇文章的教程一步步刷成linux.

我的机顶盒CPU和原文中一样是S905L-B。

通过安装两款专业精准检测机顶盒/手机_硬件信息软件(含CPU芯片)中提到的软件,Aida64就可以查看机顶盒的CPU了,原来的系统似乎无法安装外来软件,我的已经刷成了全功能系统了。原系统的可以试试用ADB查看。

我使用的是WSL,kali linux,之前下载的,懒得换了。

前置准备

首先找个目录放文件,我直接放在默认目录下了 cd ~

然后运行文中的代码把仓库爬取下来:

git clone https://github.com/u-boot/u-boot.git
git clone https://github.com/repk/gxlimg.git
git clone https://github.com/LibreELEC/amlogic-boot-fip --depth=1

然后更新一下软件源: sudo apt update 查看自己有没有下载对应的编译工具,先安装工具和依赖:

sudo apt install build-essential bison flex libncurses-dev \
                 libssl-dev libgnutls28-dev device-tree-compiler \
                 libfdt-dev

编译u-boot

进入u-boot的文件夹,之前git爬取下来的。 cd u-boot

然后执行以下命令 make khadas-vim_defconfig 你需要查找适合自己CPU的开发板,并使用相对应的uboot配置

然后执行

export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-

再通过 make menuconfig 设置u-boot配置。 根据原文描述,需要设置三个地方: Environment -> [ * ] Environment is in a FAT filesystem Boot options -> Boot media -> [ * ]Support for booting from SD/EMMC Command line interface -> Boot commands -> [ * ]bootz

执行下方的save和多次exit退出。

然后执行命令 make -j$(nproc) 原文使用的是j32,代表使用32个内核进行编译,可以替换为自己CPU所有的内核数或直接用$(nproc)来匹配自己CPU所有的内核数

编译没有错误就可以进行下一步了,最后应该出现以下结果:

  LD      u-boot
  OBJCOPY u-boot.srec
  OBJCOPY u-boot-nodtb.bin
  SYM     u-boot.sym
  RELOC   u-boot-nodtb.bin
  DTC     dts/upstream/src/arm64/amlogic/meson-gxl-s905x-khadas-vim.dtb
  SHIPPED dts/dt.dtb
  CAT     u-boot-dtb.bin
  COPY    u-boot.dtb
  COPY    u-boot.bin
  LD      u-boot.elf
  OFCHK   .config

如果报错,先问AI哪里有问题,解决完问题再进行下一步,否则无法保证后面不出错

使用ls命令查看当前u-boot/目录下的文件,应该有一个u-boot.bin

接下来到之前git爬取的amlogic-boot-fip文件夹中,使用其中的工具打包u-boot生成bootloader

# khadas-vim换成对应型号的开发板名字
# /path/to/u-boot/u-boot.bin换成上一步生成的u-boot.bin文件路径
# my-output-dir 换成输出文件的路径
./build-fip.sh khadas-vim /path/to/u-boot/u-boot.bin my-output-dir

像我的就是 ./build-fip.sh khadas-vim ../u-boot/u-boot.bin ../ 之后到主文件夹就能看到生成的一堆u-boot文件

由于我的系统uboot启动延迟设置为0,暂时不进行抓取原uboot的操作。

编译linux

根据这篇教程,先下载linux源码 git clone https://github.com/torvalds/linux.git

接着将gcc工具链下载下来,对应机顶盒的CPU架构,可以问AI自己的CPU应该下载哪个工具链。 sudo apt install gcc-aarch64-linux-gnu 然后安装一下device-tree-compiler sudo apt install device-tree-compiler

进入git爬取下来的linux文件夹 输入以下命令

export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-

然后输入 make defconfig 使用defconfig作为默认配置文件 然后用以下命令配置编译项 make menuconfig 根据原文描述,分别需要选中以下配置: Platform selection -> [ * ] Amlogic Platforms Device Drivers -> Network device support -> Ethernet driver support -> [ * ] STMicroelectronics devices - < * > STMicroelectronics Multi-Gigabit Ethernet driver - < * > STMMAC Platform bus support - < * > Amlogic Meson dwmac support Device Drivers -> Network device support -> < * > Amlogic GXL based MDIO bus multiplexer
Device Drivers -> Network device support -> PHY Device support and infrastructure -> < * > PHY Device support and infrastructure

然后保存并退出

先安装bc工具 sudo apt-get install bc

然后进行编译 make -j$(nproc) 编译到最后如果不报错最后几行应该是这样

  LD [M]  net/can/can-gw.ko
  LD [M]  net/bluetooth/bluetooth.ko
  LD [M]  net/bluetooth/hidp/hidp.ko
  LD [M]  net/mac80211/mac80211.ko
  LD [M]  net/rfkill/rfkill.ko
  LD [M]  net/rfkill/rfkill-gpio.ko
  LD [M]  net/nfc/nfc.ko
  LD [M]  net/nfc/nci/nci.ko
  LD [M]  net/hsr/hsr.ko
  LD [M]  net/qrtr/qrtr.ko
  LD [M]  net/qrtr/qrtr-smd.ko
  LD [M]  net/qrtr/qrtr-tun.ko
  LD [M]  net/qrtr/qrtr-mhi.ko

由于无法进入shell,所以只能进行到底再烧录了。

根文件目录

根文件是arm64的,而我的电脑是x86,显然wsl是不支持跨平台编译的,于是我只好下了个Ubuntu系统,在外接硬盘上运行将根文件做好了。

还可以使用Docker进行编译,但是不知道具体的步骤是什么。

结局

后面的镜像虽然成功烧成了,也能写到SD卡中,但是无论如何都无法启动,看来是失败了,转投armbian去了。


Previous Post
hax&woiden机器测试
Next Post
解决插入u盘或其他USB设备无法启动armbian的问题