NanoPi M1 Plus:Allwinner H3使用lichee源码编译Linux-3.4 BSP
文章目录
- 前言
- 一、使用Linux-3.4 BSP
- 二、编译出错
-
- 错误:make: * [scripts] Error 2 ERROR: build kernel Failed
- 三、编译成功之后的事
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 allINFO: 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: sun8iw7p1INFO: platform: linuxINFO: business: INFO: kernel: linux-3.4INFO: board: nanopi-h3INFO: output: out/sun8iw7p1/linux/nanopi-h3INFO: ----------------------------------------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-h3Using 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/confscripts/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 directoryscripts/Makefile.build:307: recipe for target 'scripts/mod/empty.o' failedmake[2]: * [scripts/mod/empty.o] Error 1scripts/Makefile.build:443: recipe for target 'scripts/mod' failedmake[1]: * [scripts/mod] Error 2make[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' failedmake[1]: * [kernel/bounds.s] Error 1Makefile:986: recipe for target 'prepare0' failedmake: * [prepare0] Error 2make: * 正在等待未完成的任务....Makefile:507: recipe for target 'scripts' failedmake: * [scripts] Error 2ERROR: build kernel FailedINFO: use a fake rootfs.ext4.记录了1+0 的读入记录了1+0 的写出1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.000656584 s, 1.6 GB/smke2fs 1.42.13 (17-May-2015)文件系统小得无法记录日志INFO: ----------------------------------------INFO: build sun8iw7p1 linux lichee OKINFO: ----------------------------------------INFO: packing firmware ...copying tools filecopying configs filecopying boot resourcecopying boot file'sys_config.bin' -> 'script.bin'packing for linuxnormalskip dragon image.cfg sys_partition.fexpack finishINFO: build and pack lichee for LINUX platform success
解决办法:
sudo apt-get install lib32z1 lib32ncurses5sudo apt-get install lib32stdc++6
OK正常编译出kernel了!
三、编译成功之后的事
linux kernel编译出来之后的二进制文件在:
lichee/linux-3.4/output
该文件下的所有文件
liefyuan@ubuntu:~/Allwinner/h3/lichee/linux-3.4/output$ lsarisc bImage boot.img lib rootfs.cpio.gz uImage vmlinux.tar.bz2 zImage
还是跑不起来啊
HELLO! BOOT0 is starting!boot0 version : 4.0.0boot0 commit : 1234567891234567891234567891234567891234fel_flag = 0x00000000rtc[0] value = 0x00000000rtc[1] value = 0x00000000rtc[2] value = 0x00000000rtc[3] value = 0x00000000rtc[4] value = 0x00000000rtc[5] value = 0x00000000rtc[6] value = 0x00000000rtc[7] value = 0x00000000DRAM DRIVE INFO: V1.3the chip id is 0x00000081the chip id is 0x00000081the chip id is 0x00000081the chip id is 0x00000081the chip id is 0x00000081READ DQS LCDL = 00202021DRAM Type = 3 (2:DDR2,3:DDR3,6:LPDDR2,7:LPDDR3)DRAM CLK = 576 MHzDRAM zq value: 003b3bfbDRAM dram para1: 10f40400DRAM dram para2: 00000000DRAM workmode1: 000009f4DRAM SIZE =1024 Modt delaydram size =1024card boot number = 0card no is 0sdcard 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 okThe size of uboot is 000e4000.sum=06151854src_sum=06151854Succeed in loading uboot from sdmmc flash.Ready to disable icache.Jump to secend Boot.SUNXI_NORMAL_MODE[ 0.391]e modeU-Boot 2011.09-rc1 (Oct 17 2021 - 16:04:16) Allwinner Technology[ 0.398]version: 1.1.0[ 0.401]uboot commit : 1234567891234567891234567891234567891234normal mode[ 0.412]pmbus: readynot set main pmu idaxp_probe errorgpio value=0x20000[ 0.450]PMU: pll1 1008 Mhz,PLL6=600 MhzAXI=336 Mhz,AHB=200 Mhz, APB1=100 Mhzsid read alreadyfel key new moderun key detectno key foundno key inputdram_para_set startdram_para_set endnormal mode[ 0.481]DRAM: 1 GiBrelocation Offset is: 35af2000[recovery] no use[box standby] read rtc = 0x0[box_start_os] mag be start_type no useuser_gpio configuser_gpio okgic: normal or no secure os modeworkmode = 0MMC: 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 okscript config pll_de to 864 MhzNot Found clk pll_video1 in scriptscript config pll_video to 297 Mhzscript config pll_periph0 to 600 Mhzunable to find regulator vcc-hdmi-18 from [pmu1_regu] or [pmu2_regu]enable power vcc-hdmi-18, ret=-1DRV_DISP_Init end[disk_read_fs] no the partitionerror: open tv_vdid.fex, maybe it is not exist[disk_read_fs] no the partitionerror: open disp_rsl.fex, maybe it is not exist[disk_read_fs] no the partitionerror: open disp_rsl.fex, maybe it is not existboot_disp.auto_hpd=1auto 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=0x0try to read logic blk 0 without env partition* Warning - bad CRC, using default environmentIn: serialOut: serialErr: serial--------fastboot partitions--------mbr not existbase bootcmd=run setargs_mmc boot_normalbootcmd set setargs_mmckey 0cant find rcvy valuecant find fstbt valueno misc partition is foundto 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 1854sunxi_secstorage_read failget secure storage map errcheck user data form privatethe private part isn't existWORK_MODE_BOOTadver not need showsunxi_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 37416Error reading cluster Unable to read "boot.img" from mmc 0:1 boota: bad boot image magic, maybe not a boot.img?sunxi#