Orangepi PC2 uboot编译

开发环境 ubuntu18.04LTS

官方源码下载地址:https://github.com/orangepi-xunlong/OrangePi_Build

上述链接下载下来是脚本,需要运行脚本下载源码

以下是具体的源码下载地址:

OrangePi PC2/Prima/Zero plus2

OrangePi PC2/Prima/Zero plus build on Allwinner H5 Soc, the offical maintain repository as follow:

kernel:

  git clone https://github.com/orangepi-xunlong/OrangePiH5_kernel.git

u-boot:

  git clone https://github.com/orangepi-xunlong/OrangePiH5_uboot.git

build scripts

 git clone https://github.com/orangepi-xunlong/OrangePiH5_scripts.git

external binary file

  git clone https://github.com/orangepi-xunlong/OrangePiH5_external.git

toolchain

  git clone https://github.com/orangepi-xunlong/OrangePiH5_toolchain.git

 注:以下的命令都是参考官方脚本。如果想方便可以直接使用官方脚本即可。

其实本人不建议购买orangepi,因为这货的电源插槽很松,触动的话,导致死机重启。


#解压交叉编译工具
$cd /root/Oriangepi/OrangePiH5
$ls
build.sh  external  kernel  scripts  toolchain  uboot


#将分卷还原成一个压缩包
$cat toolchain/toolchain_tar/toolchain* > toolchain/toolchain.tar.gz

$pwd
/root/Oriangepi/OrangePiH5
#解压kernel用的64位交叉编译工具
tar -zxvf toolchain/toolchain.tar.gz

#删除H3用的交叉编译工具
rm toolchain/gcc-linaro-aarch/gcc-linaro -rf

#解压H5 uboot用的交叉编译工具
cat toolchain/toolchain_tar/u-boot-compile-tools0* > toolchain/u-boot-compile-tools.tar.gz
#解压到H5 kernel交叉编译工具目录
tar -zxvf toolchain/u-boot-compile-tools.tar.gz -C toolchain/gcc-linaro-aarch/

#以下为可选操作
#删除烦人的压缩分卷,节省磁盘空间
rm /root/Oriangepi/OrangePiH5/toolchain -rf

将uboot和kernel的交叉编译工具添加至环境变量

#For H5
export PATH=/root/Oriangepi/OrangePiH5/toolchain/gcc-linaro-aarch/bin:$PATH
export PATH=/root/Oriangepi/OrangePiH5/toolchain/gcc-linaro-aarch/gcc-linaro/bin:$PATH

让环境变量生效需要注销用户、重启或者

source ~/.bashrc

开始编译

#创建输出目录
$mkdir /root/Oriangepi/OrangePiH5/output

#进入UBOOT目录
$cd /root/Oriangepi/OrangePiH5/uboot

查看可用配置文件

grep -r "sunxi" ./boards.cfg
Active  aarch64    armv7          sun50iw1p1    sunxi          sun50iw1p1          sun50iw1p1                            sun50iw1p1:SUN50IW1P1                                                                                                                   wangwei<[email protected]>
Active  aarch64    armv7          sun50iw2p1    sunxi          sun50iw2p1          sun50iw2p1                            sun50iw2p1:SUN50IW2P1                                                                                                                   wangwei <[email protected]>
Active  aarch64    armv7          sun50iw3p1    sunxi          sun50iw3p1          sun50iw3p1                            sun50iw3p1:SUN50IW3P1                                                                                                                   Jerry Wang <[email protected]>
#Active  aarch64     armv8          wine        sunxi           perf                wine                                  wine:ARM64,FPGA                                                                                                                   Jerry Wang <[email protected]>
Active  arm       armv7          sun8iw10p1    sunxi          sun8iw10p1          sun8iw10p1                            sun8iw10p1:SUN8IW10P1                                                                                                                    Young<[email protected]>
Active  arm       armv7          sun8iw11p1    sunxi          sun8iw11p1          sun8iw11p1                            sun8iw11p1:SUN8IW11P1                                                                                                                    wangwei<[email protected]>
Active  arm       armv7          sun8iw11p1    sunxi          sun8iw11p1          sun8iw11p1_nor                            sun8iw11p1:SUN8IW11P1_NOR                                                                                                                    wangwei<[email protected]>
Active  arm         armv7          sunxi       -               sunxi               Cubietruck                            sun7i:CUBIETRUCK,SPL,SUNXI_GMAC,RGMII                                                                                             -
Active  arm         armv7          sunxi       -               sunxi               Cubietruck_FEL                        sun7i:CUBIETRUCK,SPL_FEL,SUNXI_GMAC,RGMII 

可用看到可用配置名为sun50iw2p1,具体可参考/root/Oriangepi/OrangePiH5/scripts/uboot_compile.sh

make CROSS_COMPILE=arm-linux-gnueabi- sun50iw2p1_config
make CROSS_COMPILE=arm-linux-gnueabi-

make CROSS_COMPILE=arm-linux-gnueabi- spl

等待编译完成后,需要做几步工作,最坑的那几步

cd /root/Oriangepi/OrangePiH5/external

cp sys_config/OrangePiH5_PC2_sys_config.fex sys_config.fex

#将原内核的设备树改名,当然你改pack脚本文件也是可以的
mv /root/Oriangepi/OrangePiH5/kernel/arch/arm64/boot/dts /root/Oriangepi/OrangePiH5/kernel/arch/arm64/boot/dts.bak

#将PC2的设备树拷贝到内核
cp /root/Oriangepi/OrangePiH5/external/BUFFER/OrangePiH5_PC2_dts /root/Oriangepi/OrangePiH5/kernel/arch/arm64/boot/dts

#开始打包,转格式
$cd /root/Oriangepi/OrangePiH5/scripts/pack
$./pack

#打包完成后,进入输出目录
$cd /root/Oriangepi/OrangePiH5/output/pack/out

#复制
$cp boot0_sdcard.fex ../boot0.bin
$cp boot_package.fex ../uboot.bin

插入sd卡

#确认插入设备的设备号,防止将系统弄崩溃
$dmesg
[  983.624390] usb 1-1: new high-speed USB device number 2 using ehci-pci
[  983.895585] usb 1-1: New USB device found, idVendor=05e3, idProduct=0751
[  983.895589] usb 1-1: New USB device strings: Mfr=3, Product=4, SerialNumber=0
[  983.895591] usb 1-1: Product: USB Storage
[  983.895593] usb 1-1: Manufacturer: USB Storage
[  983.973901] usb-storage 1-1:1.0: USB Mass Storage device detected
[  983.973996] scsi host3: usb-storage 1-1:1.0
[  983.974547] usbcore: registered new interface driver usb-storage
[  983.996241] usbcore: registered new interface driver uas
[  985.004332] scsi 3:0:0:0: Direct-Access     Generic  STORAGE DEVICE   1404 PQ: 0 ANSI: 6
[  985.004717] sd 3:0:0:0: Attached scsi generic sg2 type 0
[  985.110954] sd 3:0:0:0: [sdb] 62333952 512-byte logical blocks: (31.9 GB/29.7 GiB)
[  985.130468] sd 3:0:0:0: [sdb] Write Protect is off
[  985.130472] sd 3:0:0:0: [sdb] Mode Sense: 21 00 00 00
[  985.150058] sd 3:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[  985.257734]  sdb: sdb1
[  985.340854] sd 3:0:0:0: [sdb] Attached SCSI removable disk
[  986.960067] EXT4-fs (sdb1): mounted filesystem with ordered data mode. Opts: (null)

#可用看到插入的设备设备号是/dev/sdb
#或者列出所有块设备
lsblk

#清空sd卡分区及数据,注意设备号
$dd bs=1k seek=8 count=1015 if=/dev/zero of=/dev/sdb

#将uboot写入到特定扇区
cd /root/Oriangepi/OrangePiH5/output/pack/
$dd bs=1k seek=8 if=boot0.bin of=/dev/sdb
$dd bs=1k seek=16400 if=uboot.bin of=/dev/sdb

$sync 
$umount /dev/sdb1

将卡插入开发板,可以看到uboot启动信息

▒HELLO! BOOT0 is starting!
boot0 commit : 661df598b3672fc3bc3e0c2425a77170a26d7a0d

boot0 version : 4.0
set pll start
set pll end
rtc[0] value = 0x00000000
rtc[1] value = 0x00000000
rtc[2] value = 0x00000000
rtc[3] value = 0x00000000
rtc[4] value = 0x00000000
rtc[5] value = 0x00000000
DRAM BOOT DRIVE INFO: V0.6
the chip id is 0x00000001
the chip id is 0x00000001
the chip id is 0x00000001
the chip id is 0x00000001
the chip id is 0x00000001
axp not exist
DRAM CLK =672 MHZ
DRAM Type =3 (2:DDR2,3:DDR3,6:LPDDR2,7:LPDDR3)
DRAM zq value: 0x003b3bf9
DRAM SIZE =1024 M
DRAM simple test OK.
dram size =1024
card no is 0
sdcard 0 line count 4
[mmc]: mmc driver ver 2016-03-15 20:40
[mmc]: sdc0 spd mode error, 2
[mmc]: Wrong media type 0x00000000
[mmc]: ***[2]Try SD card 0***
[mmc]: HSSDR52/SDR25 4 bit
[mmc]: 50000000 Hz
[mmc]: 30436 MB
[mmc]: ***SD/MMC 0 init OK!!!***
sum=aae18245
src_sum=aae18245
read boot-pkg from emmc 32800 sector
Succeed in loading uboot from sdmmc flash.
Entry_name        = u-boot
Entry_name        = monitor
Entry_name        = scp
set arisc reset to de-assert state
Ready to disable icache.
▒▒▒ɽc▒▒▒5)▒NOTICE:  BL3-1: v1.0(debug):3ffd944
NOTICE:  BL3-1: Built : 11:09:10, Aug 30 2016
NOTICE:  BL3-1 commit: 3ffd9442d4769d7fc0002770e3b69b55150a288e

INFO:    BL3-1: Initializing runtime services
ERROR:   Error initializing runtime service tspd_fast
INFO:    BL3-1: Preparing for EL3 exit to normal world
INFO:    BL3-1: Next image address = 0x4a000000
INFO:    BL3-1: Next image spsr = 0x1d3


U-Boot 2014.07-g661df59-dirty (Apr 28 2019 - 21:05:01) Allwinner Technology

uboot commit : 661df598b3672fc3bc3e0c2425a77170a26d7a0d

secure enable bit: 0
i2c: secure monitor exist
[      0.738]pmbus:   ready
u0:48105000
[      0.742][ARISC] :arisc initialize
[      0.772][ARISC] :arisc para ok
[SCP] :sunxi-arisc driver begin startup 2
[SCP] :arisc version: [sun8iw5_v0.03.00-244-gb750b8e]
[SCP] :sunxi-arisc driver v1.20 is starting
[      0.788][ARISC] :sunxi-arisc driver startup succeeded
axp: get node[charger0] error
[SCP ERROR] :message process error
[SCP ERROR] :message addr   : 48105080
[SCP ERROR] :message state  : 5
[SCP ERROR] :message attr   : 2
[SCP ERROR] :message type   : 80
[SCP ERROR] :message result : f3
[SCP WARING] :callback not install
[SCP ERROR] :arisc twi read pmu reg 0x3 err
probe axp806 failed
axp_probe error
[      0.822]PMU: cpux 1008 Mhz,AXI=336 Mhz
PLL6=600 Mhz,AHB1=200 Mhz, APB1=100Mhz MBus=400Mhz
run key detect
no key found
no uart input
DRAM:  1 GiB
fdt addr: 0x76e9f080
Relocation Offset is: 35ef2000
axp: get node[charger0] error
In:    serial
Out:   serial
Err:   serial
gic: sec monitor mode
[box standby] read rtc = 0x0
[box standby] start_type = 0x1
[box standby] to kernel
boot_init_gpio used
ir boot recovery not used
workmode = 0,storage type = 1
[      1.027]MMC:        0
[mmc]: mmc driver ver 2016-05-20 17:18:00-test0
[mmc]: get card2_boot_para:sdc_ex_dly_used 0
[mmc]: no mmc-hs400-1_8v!
[mmc]: no mmc-hs200-1_8v!
[mmc]: no mmc-ddr-1_8v!
[mmc]: delete max-frequency from dtb
SUNXI SD/MMC: 0
[mmc]: 50 MHz...
[mmc]: sample: 62 - 161(ps)
[mmc]: 100 MHz...
[mmc]: sample: 31 - 161(ps)
[mmc]: 200 MHz...
[mmc]: sample: 16 - 156(ps)
[mmc]: media type 0x0
[mmc]: Wrong media type 0x0
[mmc]: ************Try SD card 0************
[mmc]: host caps: 0x27
[mmc]: MID 03 PSN 4a541998
[mmc]: PNM SC32G -- 0x53-43-33-32-47
[mmc]: PRV 8.0
[mmc]: MDT m-12 y-2018
[mmc]: speed mode     : HSSDR52/SDR25
[mmc]: clock          : 50000000 Hz
[mmc]: bus_width      : 4 bit
[mmc]: user capacity  : 30436 MB
[mmc]: ************SD/MMC 0 init OK!!!************
[mmc]: erase_grp_size      : 0x1WrBlk*0x200=0x200 Byte
[mmc]: secure_feature      : 0x0
[mmc]: secure_removal_type : 0x0
[      1.235]sunxi flash init ok
[      1.251]start
drv_disp_init
tv_init:
tv_probe:000
no report hpd work,you need support the switch class!
screen 0 don't support TV!
tv_init:
fetch tv1 err.
drv_disp_init finish
hdcp is closed by sys config.
no the part:Reserve0
hpd_dev_num=2, id of def_output_dev is 0
hdmi hpd out, force open?
fdt_setprop_u32 disp.init_disp(0x20b0404) code:<no error>
fb_id=0, size=3686400, gd->ram_size=1073741824, SUNXI_DISPLAY_FRAME_BUFFER_SIZE=                                                                                                                                                             16777216
[      1.824]end
PowerBus = 0( 2:vBus 3:acBus other: not exist)
no battery, limit to dc
no battery exist
sunxi_bmp_logo_display
[boot disp] can not find the partition Reserve0
bmp_name=bootlogo.bmp
** Bad device size - sunxi_flash 0 **
sunxi bmp info error : unable to open logo file bootlogo.bmp
fail to find part named env
Using default environment

--------fastboot partitions--------
mbr not exist
base bootcmd=run mmcbootcmd
bootcmd set setargs_mmc
no misc partition is found
to be run cmd=run mmcbootcmd
cann't get the boot_base from the env
read item0 copy0
[mmc]: first and second bak compare failed fun sdmmc_secure_storage_read line 48                                                                                                                                                             3
read item0 copy1
[mmc]: first and second bak compare failed fun sdmmc_secure_storage_read line 48                                                                                                                                                             3
unknown error happen in item 0 read
get secure storage map err
check user data form private
the private part isn't exist
update dtb dram start
update dtb dram  end
serial is: 24005035c120582a084c
[      1.997]inter uboot shell
Hit any key to stop autoboot:  0
Loading orangepi uEnv.txt from 40000000 ...
** Unrecognized filesystem type **
** Unrecognized filesystem type **
Booting with defaults ...
Loading orangepi orangepi/OrangePiH5.dtb from 44000000 ...
** Unrecognized filesystem type **
Loading orangepi orangepi/uImage from 4007ffc0 ...
** Unrecognized filesystem type **
sunxi#

好了,uboot的搞定。

PS:编译时缺少软件请自行百度

猜你喜欢

转载自blog.csdn.net/kbitosy/article/details/89643894
今日推荐