Re: Various rockchip u-boot aarch64 improvements

2019-10-06 Thread Mark Kettenis
> Date: Sun, 6 Oct 2019 11:42:03 +1100
> From: Jonathan Gray 
> 
> On Sat, Oct 05, 2019 at 12:20:57PM -0400, k...@intricatesoftware.com wrote:
> > Various rockchip u-boot 2019.10rc4 aarch64 improvements:
> > * u-boot.itb is included in the all target for rockpro64 and
> >   firefly-rk3399 so remove duplicate make for it.
> > * Build rock64-rk3328, except exclude idbloader.img which is broken.
> > * Install u-boot-spl-dtb.bin and mkimage for rock64, rockpro64 and
> >   firefly-rk3399 so that idbloader.img can be created using rkbin TPL
> >   layer.
> > * Provide a script to make idbloader.img from rkbin's TPL layer.
> > * For rockpro64 backport PCIe support from 5.3 dtb.
> > * For rock64 backport most 4.20 dtb components and additional bug
> >   fixes.
> > 
> > For rockpro64, I no longer need to have an updated dtb installed
> > in the i partition for PCIe to work. Although I am using the
> > rkbin TPL layer because the u-boot one doesn't recognize half
> > of my memory (other versions of this board dont have this 
> > problem).
> > 
> > For rock64 the dtb updates corrects the clock bindings so an
> > updated dtb is not needed in the i partition as well. However,
> > u-boot's TPL layer isn't working yet so the following steps
> > are needed to create a usable idbloader.img on a uSD for
> > install with miniroot66.fs:
> > 
> > /usr/local/libexec/u-boot/mkidbloader-rkbin rock64-rk3328
> > dd if=miniroot66.fs of=/dev/ bs=1m
> > dd if=idbloader.img of=/dev/ bs=512 seek=64 conv=sync
> > dd if=/usr/local/share/u-boot/rock64-rk3328/u-boot.itb \
> >of=/dev/ bs=512 seek=16384 conv=sync
> > 
> > One of the downsides of installing mkimage is the removal of
> > PKG_ARCH=*, but we get better support for both rock64 and
> > rockpro64 for where rkbin is still needed. I'm not sure how
> > well firefly works with the the u-boot TPL layer so it may
> > benefit from the ability to build idbloader.img with the
> > rkbin TPL layer as well.
> > 
> > Thoughts?
> 
> Dropping PKG_ARCH=* isn't something we should do in my opinion.  For
> example arm package snapshots seem to be made every few months and with
> U-Boot 2019.10 final planned for Monday US time there wouldn't be a
> package available for arm in time for the final release build.
> 
> I think for now you should drop the rk3328/mkimage parts and keep the
> rockpro64 dtb change.

Simon South just posted two patches to the U-Boot mailing list that
apparently fixes ro rock64 issues.  That removes the need to use the
propriatary Rockchip loader in favour of U-Boot TPL.



Re: Various rockchip u-boot aarch64 improvements

2019-10-06 Thread Kurt Miller
On Sun, 2019-10-06 at 18:47 +0200, Mark Kettenis wrote:
> > 
> > Date: Sun, 6 Oct 2019 11:42:03 +1100
> > From: Jonathan Gray 
> > 
> > On Sat, Oct 05, 2019 at 12:20:57PM -0400, k...@intricatesoftware.com wrote:
> > > 
> > > Various rockchip u-boot 2019.10rc4 aarch64 improvements:
> > > * u-boot.itb is included in the all target for rockpro64 and
> > >   firefly-rk3399 so remove duplicate make for it.
> > > * Build rock64-rk3328, except exclude idbloader.img which is broken.
> > > * Install u-boot-spl-dtb.bin and mkimage for rock64, rockpro64 and
> > >   firefly-rk3399 so that idbloader.img can be created using rkbin TPL
> > >   layer.
> > > * Provide a script to make idbloader.img from rkbin's TPL layer.
> > > * For rockpro64 backport PCIe support from 5.3 dtb.
> > > * For rock64 backport most 4.20 dtb components and additional bug
> > >   fixes.
> > > 
> > > For rockpro64, I no longer need to have an updated dtb installed
> > > in the i partition for PCIe to work. Although I am using the
> > > rkbin TPL layer because the u-boot one doesn't recognize half
> > > of my memory (other versions of this board dont have this 
> > > problem).
> > > 
> > > For rock64 the dtb updates corrects the clock bindings so an
> > > updated dtb is not needed in the i partition as well. However,
> > > u-boot's TPL layer isn't working yet so the following steps
> > > are needed to create a usable idbloader.img on a uSD for
> > > install with miniroot66.fs:
> > > 
> > > /usr/local/libexec/u-boot/mkidbloader-rkbin rock64-rk3328
> > > dd if=miniroot66.fs of=/dev/ bs=1m
> > > dd if=idbloader.img of=/dev/ bs=512 seek=64 conv=sync
> > > dd if=/usr/local/share/u-boot/rock64-rk3328/u-boot.itb \
> > >    of=/dev/ bs=512 seek=16384 conv=sync
> > > 
> > > One of the downsides of installing mkimage is the removal of
> > > PKG_ARCH=*, but we get better support for both rock64 and
> > > rockpro64 for where rkbin is still needed. I'm not sure how
> > > well firefly works with the the u-boot TPL layer so it may
> > > benefit from the ability to build idbloader.img with the
> > > rkbin TPL layer as well.
> > > 
> > > Thoughts?
> > Dropping PKG_ARCH=* isn't something we should do in my opinion.  For
> > example arm package snapshots seem to be made every few months and with
> > U-Boot 2019.10 final planned for Monday US time there wouldn't be a
> > package available for arm in time for the final release build.
> > 
> > I think for now you should drop the rk3328/mkimage parts and keep the
> > rockpro64 dtb change.
> Simon South just posted two patches to the U-Boot mailing list that
> apparently fixes ro rock64 issues.  That removes the need to use the
> propriatary Rockchip loader in favour of U-Boot TPL.

I've adjusted the u-boot changes to address dropping PKG_ARCH=*
and incorporated Simon South's changes to see if the Rock64
will work with u-boot's TPL layer. Please see the attached diff
for review.

Rock64 users can test the firmware by jumping gpio pins
20 and 21 to disable the SPI firmware and booting off a
uSD prepared as follows:

dd if=miniroot66.fs of=/dev/ bs=1m
dd if=idbloader.img of=/dev/ bs=512 seek=64 conv=sync
dd if=rock64-rk3328/u-boot.itb of=/dev/ \
  bs=512 seek=16384 conv=sync

NOTE: Use 115200 baud rate on the serial console.

The /usr/local/share/u-boot/rockpro64-rk3399 directory
built from this diff can be downloaded here to save Rock64
users some time:

http://www.intricatesoftware.com/distfiles/rock64-rk3328.tar.gz

-Kurt




Index: Makefile
===
RCS file: /cvs/ports/sysutils/u-boot/Makefile,v
retrieving revision 1.59
diff -u -p -u -r1.59 Makefile
--- Makefile28 Sep 2019 01:40:24 -  1.59
+++ Makefile7 Oct 2019 00:39:40 -
@@ -7,6 +7,7 @@ FLAVOR?=arm
 
 COMMENT=   U-Boot firmware
 VERSION=   2019.10-rc4
+REVISION=  0
 DISTNAME=  u-boot-${VERSION}
 PKGNAME=   u-boot-${FLAVOR}-${VERSION:S/-//}
 FULLPKGNAME=   ${PKGNAME}
@@ -40,6 +41,7 @@ BUILD_DEPENDS+=   devel/arm-none-eabi/gcc-
devel/py-elftools \
sysutils/arm-trusted-firmware
 MAKE_ENV+= CROSS_COMPILE="aarch64-none-elf-"
+RK3328_BL31=   "${LOCALBASE}/share/arm-trusted-firmware/rk3328-bl31.elf"
 RK3399_BL31=   "${LOCALBASE}/share/arm-trusted-firmware/rk3399-bl31.elf"
 SUNXI_BL31="${LOCALBASE}/share/arm-trusted-firmware/sun50i_a64-bl31.bin"
 .elif "${FLAVOR}" == "arm"
@@ -68,6 +70,7 @@ BOARDS=\
mvebu_espressobin-88f3720 \
mvebu_mcbin-88f8040 \
qemu_arm64 \
+   rock64-rk3328 \
rockpro64-rk3399 \
rpi_3 \
rpi_4
@@ -151,23 +154,27 @@ do-build:
mkdir -p build/${BOARD} && \
${SETENV} ${MAKE_ENV} ${MAKE_PROGRAM} ${MAKE_FLAGS} \
O="build/${BOARD}" \
-   -f ${MAKE_FILE} "${BOARD}"_defconfig && \
+   -f ${MAKE_FILE} "${BOARD}"_defconfig
+.if "${BOARD}" == "firefly-rk3399" || "${BOARD}" == "rockpro64-rk3399"
+   c

Re: Various rockchip u-boot aarch64 improvements

2019-10-06 Thread Kurt Miller
On Sun, 2019-10-06 at 21:51 -0400, Kurt Miller wrote:
> The /usr/local/share/u-boot/rockpro64-rk3399 directory

Typo above. It should have said:

The /usr/local/share/u-boot/rock64-rk3328 directory
> built from this diff can be downloaded here to save Rock64
> users some time:
> 
> http://www.intricatesoftware.com/distfiles/rock64-rk3328.tar.gz
> 
> -Kurt
> 
> 
> 
> 



Re: Various rockchip u-boot aarch64 improvements

2019-10-06 Thread Jonathan Gray
On Sun, Oct 06, 2019 at 09:51:20PM -0400, Kurt Miller wrote:
> On Sun, 2019-10-06 at 18:47 +0200, Mark Kettenis wrote:
> > > 
> > > Date: Sun, 6 Oct 2019 11:42:03 +1100
> > > From: Jonathan Gray 
> > > 
> > > On Sat, Oct 05, 2019 at 12:20:57PM -0400, k...@intricatesoftware.com 
> > > wrote:
> > > > 
> > > > Various rockchip u-boot 2019.10rc4 aarch64 improvements:
> > > > * u-boot.itb is included in the all target for rockpro64 and
> > > >   firefly-rk3399 so remove duplicate make for it.
> > > > * Build rock64-rk3328, except exclude idbloader.img which is broken.
> > > > * Install u-boot-spl-dtb.bin and mkimage for rock64, rockpro64 and
> > > >   firefly-rk3399 so that idbloader.img can be created using rkbin TPL
> > > >   layer.
> > > > * Provide a script to make idbloader.img from rkbin's TPL layer.
> > > > * For rockpro64 backport PCIe support from 5.3 dtb.
> > > > * For rock64 backport most 4.20 dtb components and additional bug
> > > >   fixes.
> > > > 
> > > > For rockpro64, I no longer need to have an updated dtb installed
> > > > in the i partition for PCIe to work. Although I am using the
> > > > rkbin TPL layer because the u-boot one doesn't recognize half
> > > > of my memory (other versions of this board dont have this 
> > > > problem).
> > > > 
> > > > For rock64 the dtb updates corrects the clock bindings so an
> > > > updated dtb is not needed in the i partition as well. However,
> > > > u-boot's TPL layer isn't working yet so the following steps
> > > > are needed to create a usable idbloader.img on a uSD for
> > > > install with miniroot66.fs:
> > > > 
> > > > /usr/local/libexec/u-boot/mkidbloader-rkbin rock64-rk3328
> > > > dd if=miniroot66.fs of=/dev/ bs=1m
> > > > dd if=idbloader.img of=/dev/ bs=512 seek=64 conv=sync
> > > > dd if=/usr/local/share/u-boot/rock64-rk3328/u-boot.itb \
> > > >    of=/dev/ bs=512 seek=16384 conv=sync
> > > > 
> > > > One of the downsides of installing mkimage is the removal of
> > > > PKG_ARCH=*, but we get better support for both rock64 and
> > > > rockpro64 for where rkbin is still needed. I'm not sure how
> > > > well firefly works with the the u-boot TPL layer so it may
> > > > benefit from the ability to build idbloader.img with the
> > > > rkbin TPL layer as well.
> > > > 
> > > > Thoughts?
> > > Dropping PKG_ARCH=* isn't something we should do in my opinion.  For
> > > example arm package snapshots seem to be made every few months and with
> > > U-Boot 2019.10 final planned for Monday US time there wouldn't be a
> > > package available for arm in time for the final release build.
> > > 
> > > I think for now you should drop the rk3328/mkimage parts and keep the
> > > rockpro64 dtb change.
> > Simon South just posted two patches to the U-Boot mailing list that
> > apparently fixes ro rock64 issues.  That removes the need to use the
> > propriatary Rockchip loader in favour of U-Boot TPL.
> 
> I've adjusted the u-boot changes to address dropping PKG_ARCH=*
> and incorporated Simon South's changes to see if the Rock64
> will work with u-boot's TPL layer. Please see the attached diff
> for review.

This looks good but it isn't clear to me what the 3328 dts files
(rk3328.dtsi rk3328-rock64.dts) are synced against?

There is quite a difference in rk3328.dtsi rk3328-rock64.dts and
linux 5.3.  The other files have no or expected diffs to 5.3.



Re: Various rockchip u-boot aarch64 improvements

2019-10-06 Thread Klaus Küchemann
Rock64 users can test the firmware…. :
-
 sudo minicom  -D /dev/ttyAMA0 -b 115200 8N1


Willkommen zu minicom 2.7

Optionen: I18n 
Übersetzt am Apr 22 2017, 09:14:19.
Port /dev/ttyAMA0, 04:23:52

Drücken Sie CTRL-A  Z für Hilfe zu speziellen Tasten
@
U-Boot TPL 2019.10-rc4 (Oct 06 2019 - 17:11:49)
LPDDR3
Trying to boot from BOOTROM
Returning to boot ROM...

U-Boot SPL 2019.10-rc4 (Oct 06 2019 - 17:11:49 -0400)
Trying to boot from MMC1
dwmmc@ff52 - probe failed: -22
NOTICE:  BL31: v2.1(debug):2.1
NOTICE:  BL31: Built : 10:16:27, Sep 27 2019
ERROR:   over or zero region, nr=4187432, max=10
NOTICE:  BL31:Rockchip release version: v1.2
INFO:ARM GICv2 driver initialized
INFO:plat_rockchip_pmu_init: pd status 0xe
INFO:BL31: Initializing runtime services
WARNING: BL31: cortex_a53: CPU workaround for 819472 was missing!   
WARNING: BL31: cortex_a53: CPU workaround for 824069 was missing!   
WARNING: BL31: cortex_a53: CPU workaround for 827319 was missing!   
WARNING: BL31: cortex_a53: CPU workaround for 855873 was missing!   
INFO:BL31: Preparing for EL3 exit to normal world   
INFO:Entry point address = 0x20 
INFO:SPSR = 0x3c9   


U-Boot 2019.10-rc4 (Oct 06 2019 - 17:11:49 -0400)   

Model: Pine64 Rock64
DRAM:  4 GiB
MMC:   dwmmc@ff52 - probe failed: -22   
dwmmc@ff50: 1   
Loading Environment from MMC... *** Warning - bad CRC, using default environment

In:serial@ff13  
Out:   serial@ff13  
Err:   serial@ff13  
Model: Pine64 Rock64
Net:
Warning: ethernet@ff54 (eth0) using random MAC address - de:5a:74:12:d0:ce  
eth0: ethernet@ff54 
Hit any key to stop autoboot:  0
no mmc device at slot 0 
switch to partitions #0, OK 
mmc1 is current device  
Scanning mmc 1:1... 
Found EFI removable media binary efi/boot/bootaa64.efi  
libfdt fdt_check_header(): FDT_ERR_BADMAGIC 
Scanning disk dw...@ff50.blk... 
Scanning disk dw...@ff52.blk... 
Disk dw...@ff52.blk not ready   
Found 3 disks   
BootOrder not defined   
EFI boot manager: Cannot load any image 
161090 bytes read in 13 ms (11.8 MiB/s) 
libfdt fdt_check_header(): FDT_ERR_BADMAGIC 
disks: sd0* 
>> OpenBSD/arm64 BOOTAA64 0.19  
boot>   
cannot open sd0a:/etc/random.seed: No such file or directory
booting sd0a:/bsd: 2228316+623504+8769504+741040 [221760+109+519552+200640]=0xf0
type 0x2 pa 0x20 va 0x20 pages 0x4000 attr 0x8  
type 0x7 pa 0x420 va 0x420 pages 0x3ef2 attr 0x8
type 0x4 pa 0x80f2000 va 0x80f2000 pages 0x1c attr 0x8  
type 0x7 pa 0x810e000 va 0x810e000 pages 0xf30a8 attr 0x8   
type 0x2 pa 0xfb1b6000 va 0xfb1b6000 pages 0xc34 attr 0x8   
type 0x4 pa 0xfbdea000 va 0xfbdea000 pages 0x1 attr 0x8 
type 0x2 pa 0xfbdeb000 va 0xfbdeb000 pages 0x3 attr 0x8 
type 0x7 pa 0xfbdee000 va 0xfbdee000 pages 0x1 attr 0x