NanoPi M1 Plus:Allwinner H3使用lichee源码编译Linux-3.4 BSP

乐正秦斩
2023-12-01

NanoPi M1 Plus:Allwinner H3 搭建编译环境、编译Uboot、编译Linux Kernel–失败Kernel跑不起来
 经过上一篇的尝试,我放弃了编译主线uboot和Kernel。

前言

 这里使用

一、使用Linux-3.4 BSP

 Linux3.4 BSP是由H3芯片厂商全志科技提供,在此基础上友善官方进行了自家硬件的适配。

准备工作

克隆lichee源码:

$ git clone https://github.com/friendlyarm/h3_lichee.git lichee --depth 1

注:lichee是全志为其CPU的板级支持包所起的项目名称,里面包含了U-boot,Linux等源码和众多的编译脚本。

安装交叉编译器

 访问此处下载地址的toolchain目录,下载交叉编译器gcc-linaro-arm.tar.xz,将该压缩包放置在lichee/brandy/toochain/目录下即可,无需解压。

编译lichee源码

 编译全志 H3 的BSP源码包必须使用64bit的Linux PC系统,并安装下列软件包,下列操作均基于Ubuntu-14.04 LTS-64bit:

$ sudo apt-get install gawk git gnupg flex bison gperf build-essential \
zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \
libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \
libgl1-mesa-dev g++-multilib mingw32 tofrodos \
python-markdown libxml2-utils xsltproc zlib1g-dev:i386

编译lichee源码包,执行命令:

$ cd lichee/fa_tools
$ ./build.sh -b nanopi-m1-plus -p linux -t all
  • 该命令会一次性编译好U-boot、Linux内核和模块。
  • lichee目录里内置了交叉编译器,当进行源码编译时,会自动使用该内置的编译器,所以无需手动安装编译器。

下列命令可以更新TF卡上的U-boot:

$ cd lichee/fa_tools/
$ ./fuse.sh -d /dev/sdX -p linux -t u-boot
  • /dev/sdX请替换为实际的TF卡设备文件名。
  • 内核boot.img和驱动模块均位于linux-3.4/output目录下,将boot.img拷贝到TF卡的boot分区的根目录即可更新内核。

单独编译U-boot

注意: 必须先完整地编译整个lichee目录后,才能进行单独编译U-boot的操作。
如果你想单独编译U-boot,可以执行命令:

$ cd lichee/fa_tools/
$ ./build.sh -b nanopi-m1-plus -p linux -t u-boot

下列命令可以更新TF卡上的U-boot:

$ cd lichee/fa_tools/
$ ./fuse.sh -d /dev/sdX -p linux -t u-boot

/dev/sdX请替换为实际的TF卡设备文件名。

单独编译Linux内核

注意: 必须先完整地编译整个lichee目录后,才能进行单独编译Linux内核的操作。
如果你想单独编译Linux内核,可以执行命令:

$ cd lichee/fa_tools/
$ ./build.sh -b nanopi-m1-plus -p linux -t kernel

编译完成后内核boot.img和驱动模块均位于linux-3.4/output目录下,将boot.img拷贝到TF卡的boot分区的根目录即可。

清理lichee源码

$ cd lichee/fa_tools/
$ ./build.sh -b nanopi-m1-plus -p linux -t clean

二、编译出错

错误:make: *** [scripts] Error 2 ERROR: build kernel Failed

错误提示:error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

liefyuan@ubuntu:~/Allwinner/h3/lichee/fa_tools$ ./build.sh -b nanopi-m1-plus -p linux -t all
INFO: preparing sys_config.fex
'/home/liefyuan/Allwinner/h3/lichee/tools/pack/chips/sun8iw7p1/configs/nanopi-h3/board/sys_config_nanopi-m1-plus.fex' -> '/home/liefyuan/Allwinner/h3/lichee/tools/pack/chips/sun8iw7p1/configs/nanopi-h3/sys_config.fex'
INFO: ----------------------------------------
INFO: build lichee ...
INFO: chip: sun8iw7p1
INFO: platform: linux
INFO: business: 
INFO: kernel: linux-3.4
INFO: board: nanopi-h3
INFO: output: out/sun8iw7p1/linux/nanopi-h3
INFO: ----------------------------------------
INFO: build kernel ...
INFO: prepare toolchain ...
INFO: skip kernel clean for nanopi-h3 Linux system.
Building kernel
/home/liefyuan/Allwinner/h3/lichee/linux-3.4/output/lib/modules/3.4.39-h3

Using default config sun8iw7p1smp_defconfig ...

  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/zconf.lex.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf --silentoldconfig Kconfig
  WRAP    arch/arm/include/generated/asm/auxvec.h
  WRAP    arch/arm/include/generated/asm/bitsperlong.h
  WRAP    arch/arm/include/generated/asm/cputime.h
  WRAP    arch/arm/include/generated/asm/emergency-restart.h
  WRAP    arch/arm/include/generated/asm/errno.h
  WRAP    arch/arm/include/generated/asm/ioctl.h
  WRAP    arch/arm/include/generated/asm/irq_regs.h
  WRAP    arch/arm/include/generated/asm/kdebug.h
  CHK     include/linux/version.h
  WRAP    arch/arm/include/generated/asm/local.h
  WRAP    arch/arm/include/generated/asm/local64.h
  WRAP    arch/arm/include/generated/asm/percpu.h
  WRAP    arch/arm/include/generated/asm/poll.h
  UPD     include/linux/version.h
  WRAP    arch/arm/include/generated/asm/resource.h
  WRAP    arch/arm/include/generated/asm/sections.h
  WRAP    arch/arm/include/generated/asm/siginfo.h
  WRAP    arch/arm/include/generated/asm/sizes.h
  CHK     include/generated/utsrelease.h
  UPD     include/generated/utsrelease.h
  HOSTCC  scripts/kallsyms
  CC      scripts/mod/empty.o
/home/liefyuan/Allwinner/h3/lichee/brandy/toolchain/gcc-arm/bin/../libexec/gcc/arm-linux-gnueabi/4.6.3/cc1: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
scripts/Makefile.build:307: recipe for target 'scripts/mod/empty.o' failed
make[2]: *** [scripts/mod/empty.o] Error 1
scripts/Makefile.build:443: recipe for target 'scripts/mod' failed
make[1]: *** [scripts/mod] Error 2
make[1]: *** 正在等待未完成的任务....
  Generating include/generated/mach-types.h
  CC      kernel/bounds.s
/home/liefyuan/Allwinner/h3/lichee/brandy/toolchain/gcc-arm/bin/../libexec/gcc/arm-linux-gnueabi/4.6.3/cc1: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
/home/liefyuan/Allwinner/h3/lichee/linux-3.4/./Kbuild:35: recipe for target 'kernel/bounds.s' failed
make[1]: *** [kernel/bounds.s] Error 1
Makefile:986: recipe for target 'prepare0' failed
make: *** [prepare0] Error 2
make: *** 正在等待未完成的任务....
Makefile:507: recipe for target 'scripts' failed
make: *** [scripts] Error 2
ERROR: build kernel Failed
INFO: use a fake rootfs.ext4.
记录了1+0 的读入
记录了1+0 的写出
1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.000656584 s, 1.6 GB/s
mke2fs 1.42.13 (17-May-2015)

文件系统小得无法记录日志
INFO: ----------------------------------------

INFO: build sun8iw7p1 linux  lichee OK

INFO: ----------------------------------------

INFO: packing firmware ...
copying tools file
copying configs file
copying boot resource
copying boot file
'sys_config.bin' -> 'script.bin'
packing for linux
normal
skip dragon image.cfg sys_partition.fex
pack finish
INFO: build and pack lichee for LINUX platform success

解决办法:

sudo apt-get install lib32z1 lib32ncurses5
sudo apt-get install lib32stdc++6

OK正常编译出kernel了!

三、编译成功之后的事

linux kernel编译出来之后的二进制文件在:

lichee/linux-3.4/output

该文件下的所有文件

liefyuan@ubuntu:~/Allwinner/h3/lichee/linux-3.4/output$ ls
arisc  bImage  boot.img  lib  rootfs.cpio.gz  uImage  vmlinux.tar.bz2  zImage

还是跑不起来啊

HELLO! BOOT0 is starting!
boot0 version : 4.0.0
boot0 commit : 1234567891234567891234567891234567891234

fel_flag = 0x00000000
rtc[0] value = 0x00000000
rtc[1] value = 0x00000000
rtc[2] value = 0x00000000
rtc[3] value = 0x00000000
rtc[4] value = 0x00000000
rtc[5] value = 0x00000000
rtc[6] value = 0x00000000
rtc[7] value = 0x00000000
DRAM DRIVE INFO: V1.3
the chip id is 0x00000081
the chip id is 0x00000081
the chip id is 0x00000081
the chip id is 0x00000081
the chip id is 0x00000081
READ DQS LCDL = 00202021
DRAM Type = 3 (2:DDR2,3:DDR3,6:LPDDR2,7:LPDDR3)
DRAM CLK = 576 MHz
DRAM zq value: 003b3bfb
DRAM dram para1: 10f40400
DRAM dram para2: 00000000
DRAM workmode1: 000009f4
DRAM SIZE =1024 M
odt delay
dram size =1024
card boot number = 0
card no is 0
sdcard 0 line count 4
[mmc]: mmc driver ver 2015-04-13 16:07:39
[mmc]: ***Try SD card 0***
[mmc]: SD/MMC Card: 4bit, capacity: 30436MB
[mmc]: vendor: Man 00035344 Snr db0809e8
[mmc]: product: SD32G
[mmc]: revision: 8.5
[mmc]: ***SD/MMC 0 init OK!!!***
sdcard 0 init ok
The size of uboot is 000e4000.
sum=06151854
src_sum=06151854
Succeed in loading uboot from sdmmc flash.
Ready to disable icache.
Jump to secend Boot.
SUNXI_NORMAL_MODE
[      0.391]e mode

U-Boot 2011.09-rc1 (Oct 17 2021 - 16:04:16) Allwinner Technology

[      0.398]version: 1.1.0
[      0.401]uboot commit : 1234567891234567891234567891234567891234

normal mode
[      0.412]pmbus:   ready
not set main pmu id
axp_probe error
gpio value=0x20000
[      0.450]PMU: pll1 1008 Mhz,PLL6=600 Mhz
AXI=336 Mhz,AHB=200 Mhz, APB1=100 Mhz
sid read already
fel key new mode
run key detect
no key found
no key input
dram_para_set start
dram_para_set end
normal mode
[      0.481]DRAM:  1 GiB
relocation Offset is: 35af2000
[recovery] no use
[box standby] read rtc = 0x0
[box_start_os] mag be start_type no use
user_gpio config
user_gpio ok
gic: normal or no secure os mode
workmode = 0
MMC:     0
[      0.539][mmc]: mmc driver ver 2015-04-13 14:50:00
[      0.544][mmc]: get sdc_phy_wipe fail.
[      0.547][mmc]: get sdc0 sdc_erase fail.
[      0.551][mmc]: get sdc_f_max fail,use default 50000000Hz
[      0.557][mmc]: get sdc_ex_dly_used fail,use default dly
[      0.562][mmc]: SUNXI SD/MMC: 0
[      0.576][mmc]: *Try SD card 0*
[      0.618][mmc]: CID 0x3534453 0x44333247 0x85db0809 0xe801547f
[      0.623][mmc]: mmc clk 50000000
[      0.627][mmc]: SD/MMC Card: 4bit, capacity: 30436MB
[      0.632][mmc]: boot0 capacity: 0KB,boot1 capacity: 0KB
[      0.637][mmc]: ***SD/MMC 0 init OK!!!***
[      0.641][mmc]: erase_grp_size:0x1WrBlk * 0x200 = 0x200 Byte
[      0.647][mmc]: secure_feature 0x0
[      0.650][mmc]: secure_removal_type  0x0
[      0.654]sunxi flash init ok
script config pll_de to 864 Mhz
Not Found clk pll_video1 in script
script config pll_video to 297 Mhz
script config pll_periph0 to 600 Mhz
unable to find regulator vcc-hdmi-18 from [pmu1_regu] or [pmu2_regu]
enable power vcc-hdmi-18, ret=-1
DRV_DISP_Init end
[disk_read_fs] no the partition
error: open tv_vdid.fex, maybe it is not exist
[disk_read_fs] no the partition
error: open disp_rsl.fex, maybe it is not exist
[disk_read_fs] no the partition
error: open disp_rsl.fex, maybe it is not exist
boot_disp.auto_hpd=1
auto hpd check has 100 times!
auto check no any connected, the output_type is 4
[      2.029]finally, output_type=0x4, output_mode=0x4, screen_id=0x0, disp_para=0x0
try to read logic blk 0 without env partition
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
--------fastboot partitions--------
mbr not exist
base bootcmd=run setargs_mmc boot_normal
bootcmd set setargs_mmc
key 0
cant find rcvy value
cant find fstbt value
no misc partition is found
to be run cmd=run setargs_mmc boot_normal
[      2.077][mmc]: MMC Device 2 not found
[      2.081][mmc]: Can not find mmc dev
[      2.084][mmc]: read first backup failed in fun sdmmc_secure_storage_read line 1854
sunxi_secstorage_read fail
get secure storage map err
check user data form private
the private part isn't exist
WORK_MODE_BOOT
adver not need show
sunxi_bmp_logo_display

** Unable to read "bootlogo.bmp" from mmc 0:1 **
sunxi bmp info error : unable to open logo file bootlogo.bmp
[      2.118]Hit any key to stop autoboot:  0
[      3.210][mmc]: Should not w/r secure area in fun mmc_bread_secure,line,1701 in start 10405,end 37416
Error reading cluster

** Unable to read "boot.img" from mmc 0:1 **
boota: bad boot image magic, maybe not a boot.img?
sunxi#

 类似资料: