[Banana Pi BPI-R64] Mainline OpenWRT image

Having SATA enabled by default is not an option for OpenWrt as the mPCIe port shared with SATA is the only of the two which has enough space around for oversized modules. The other mPCIe is too close to the Ethernet ports and blocks the modules from fitting. OpenWrt is primarily an operating system for networking tasks, having mPCIe available enjoys higher priority than SATA in this context.

The proper way to have still have to option to have SATA enabled would be to append a device-tree overlay blob to the uImage.FIT making the appropriate changes. OpenWrt at this point doesn’t have an easy way to facilitate that, but you can edit the its file generated during build and add the dt-overlay blob (use dtc to generate that) there, then assemble the image using mkimage.

Maybe you can make two sysupgrade images with sata and with pci-e?

That’s the plan, but for that that dt-overlay blob needs to be generated, some changes are needed in OpenWrt to support that (duplicating the whole DTS just for that is not an option, because that will then need to be maintained as well).

What’s needed for that:

  • extend scripts/mkits.sh to support adding dt-overlay blobs (yes, plural)
  • introduce new variable DEVICE_DT_OVERLAYS:= to list overlay source files in eg. target/linux/mediatek/image/mt7622.mk
  • make use of all that in include/image-commands.mk

Doesn’t look too crazy now that I wrote it down, actually…

Please try building from my staging tree where I added the necessary functionality to let you decide whether SATA or PCIE1 functionality is selected. I’ve tried and by setting the bootconf environment variable in U-Boot (can be done from within Linux using fw_setenv in case you don’t have serial access) you can now select either which device tree overlay blobs to add. It successfully detects my Samsung SATA SSD I hooked up to it for testing (and PCIe1 works when selecting the other config in U-Boot).

https://git.openwrt.org/?p=openwrt/staging/dangole.git;a=summary

I must say that the way device-tree overlay blobs are applied in U-Boot is more limited than I thought it would be. /delete-node/ and /delete-property/ don’t work and trying to replace complex nodes results in broken trees. Hence I use a hack by changing the GPIO_ACTIVE_HIGH to GPIO_ACTIVE_LOW instead of doing it the proper way which would be deleting the output-high property and adding an output-low property (because that doesn’t work).

See this added unit test in U-Boot which fails:

diff --git a/test/overlay/cmd_ut_overlay.c b/test/overlay/cmd_ut_overlay.c
index c001fb183f..b73daaedec 100644
--- a/test/overlay/cmd_ut_overlay.c
+++ b/test/overlay/cmd_ut_overlay.c
@@ -145,6 +145,20 @@ static int fdt_overlay_add_subnode_property(struct unit_test_state *uts)
 }
 OVERLAY_TEST(fdt_overlay_add_subnode_property, 0);
 
+static int fdt_overlay_remove_subnode_property(struct unit_test_state *uts)
+{
+	int off;
+
+	off = fdt_path_offset(fdt, "/test-node/sub-test-node");
+	ut_assert(off >= 0);
+
+	ut_assertnonnull(fdt_getprop(fdt, off, "sub-test-property", NULL));
+	ut_asserteq(NULL, fdt_getprop(fdt, off, "property-to-remove", NULL));
+
+	return CMD_RET_SUCCESS;
+}
+OVERLAY_TEST(fdt_overlay_remove_subnode_property, 0);
+
 static int fdt_overlay_local_phandle(struct unit_test_state *uts)
 {
 	uint32_t local_phandle;
diff --git a/test/overlay/test-fdt-base.dts b/test/overlay/test-fdt-base.dts
index 38278334e4..248e6dbd14 100644
--- a/test/overlay/test-fdt-base.dts
+++ b/test/overlay/test-fdt-base.dts
@@ -13,6 +13,7 @@
 
 		subtest: sub-test-node {
 			sub-test-property;
+			property-to-remove;
 		};
 	};
 };
diff --git a/test/overlay/test-fdt-overlay.dts b/test/overlay/test-fdt-overlay.dts
index 5a21b346d0..ee108858b6 100644
--- a/test/overlay/test-fdt-overlay.dts
+++ b/test/overlay/test-fdt-overlay.dts
@@ -92,4 +92,15 @@
 			};
 		};
 	};
+
+	fragment@9 {
+		target = <&test>;
+
+		__overlay__ {
+			sub-test-node {
+				/delete-property/ property-to-remove;
+			};
+		};
+	};
+
 };

Do you use overlay for linux or uboot too? I guess changing uboots fdt is not possible (to boot kernel from sata) as fdt is loaded on uboot start and environment is loaded after this point. But i guess most users do not need sata in uboot itself,only want to use it in linux as additional storage

Right now I’m only letting U-Boot patch the DTS for Linux. Patching the live DT in U-Boot is also possible somehow, but I didn’t play with that yet.

Update: I tested things a lot and pushed to the main repository:

Hi I try compile compile your staging tree and have got error during compiling:

aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/kernel/head.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/kernel/smccc-call.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/clear_page.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/clear_user.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/copy_from_user.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/copy_in_user.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/copy_page.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/copy_to_user.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/memchr.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/memcmp.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/memcpy.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/memmove.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/memset.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/strchr.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/strcmp.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/strlen.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/strncmp.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/strnlen.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/strrchr.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/tishift.o' being placed in section `__ksymtab_strings'
  KSYMS   .tmp_vmlinux.kallsyms2.S
  AS      .tmp_vmlinux.kallsyms2.S
  LD      vmlinux
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/kernel/head.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/kernel/smccc-call.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/clear_page.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/clear_user.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/copy_from_user.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/copy_in_user.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/copy_page.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/copy_to_user.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/memchr.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/memcmp.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/memcpy.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/memmove.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/memset.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/strchr.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/strcmp.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/strlen.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/strncmp.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/strnlen.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/strrchr.o' being placed in section `__ksymtab_strings'
aarch64-openwrt-linux-musl-ld: warning: orphan section `__ksymtab_strings' from `arch/arm64/lib/tishift.o' being placed in section `__ksymtab_strings'
  SORTTAB vmlinux
  SYSMAP  System.map
  OBJCOPY arch/arm64/boot/Image
make[5]: Leaving directory '/home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23'
cmp -s /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/vmlinux /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/vmlinux-initramfs.debug || { aarch64-openwrt-linux-musl-objcopy -O binary -R .reginfo -R .notes -R .note -R .comment -R .mdebug -R .note.gnu.build-id -S /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/vmlinux /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/vmlinux-initramfs; aarch64-openwrt-linux-musl-objcopy -R .reginfo -R .notes -R .note -R .comment -R .mdebug -R .note.gnu.build-id -S /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/vmlinux /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/vmlinux-initramfs.elf; cp -fpR /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/vmlinux /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/vmlinux-initramfs.debug;  cp -fpR /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/arch/arm64/boot//Image /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/Image-initramfs;  }
touch /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/.image
make -C image compile install TARGET_BUILD=
make[5]: Entering directory '/home/dmitry/DTS_Test/target/linux/mediatek/image'
make[5]: Nothing to be done for 'compile'.
aarch64-openwrt-linux-musl-cpp -nostdinc -x assembler-with-cpp -I/home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/arch/arm64/boot/dts/mediatek -I/home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/arch/arm64/boot/dts/mediatek/include -I/home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/include/ -undef -D__DTS__  -o /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/image-mt7622-bananapi-bpi-r64.dtb.tmp /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts
/home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/scripts/dtc/dtc -O dtb -i/home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/arch/arm64/boot/dts/mediatek/ -Wno-unit_address_vs_reg -Wno-simple_bus_reg -Wno-unit_address_format -Wno-pci_bridge -Wno-pci_device_bus_num -Wno-pci_device_reg -Wno-avoid_unnecessary_addr_size -Wno-alias_paths -Wno-graph_child_address -Wno-graph_port -Wno-unique_unit_address  -@ -o /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/image-mt7622-bananapi-bpi-r64.dtb /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/image-mt7622-bananapi-bpi-r64.dtb.tmp
/home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/arch/arm64/boot/dts/mediatek/mt7622.dtsi:257.40-264.4: Warning (interrupt_provider): /interrupt-controller@10200620: Missing #address-cells in interrupt provider
/home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/arch/arm64/boot/dts/mediatek/mt7622.dtsi:300.24-312.4: Warning (interrupt_provider): /pinctrl@10211000: Missing #address-cells in interrupt provider
  also defined at /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64.dts:285.6-545.3
/home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/arch/arm64/boot/dts/mediatek/mt7622.dtsi:329.37-338.4: Warning (interrupt_provider): /interrupt-controller@10300000: Missing #address-cells in interrupt provider
rm -f /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/image-mt7622-bananapi-bpi-r64.dtb.tmp
aarch64-openwrt-linux-musl-cpp -nostdinc -x assembler-with-cpp -I/home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/arch/arm64/boot/dts/mediatek -I/home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/arch/arm64/boot/dts/mediatek/include -I/home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/include/ -undef -D__DTS__  -o /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/image-mt7622-bananapi-bpi-r64-pcie1.dtb.tmp /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64-pcie1.dts
aarch64-openwrt-linux-musl-cpp: error: /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.23/arch/arm64/boot/dts/mediatek/mt7622-bananapi-bpi-r64-pcie1.dts: No such file or directory
aarch64-openwrt-linux-musl-cpp: warning: '-x assembler-with-cpp' after last input file has no effect
aarch64-openwrt-linux-musl-cpp: fatal error: no input files
compilation terminated.
make[5]: *** [Makefile:40: /home/dmitry/DTS_Test/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/image-mt7622-bananapi-bpi-r64-pcie1.dtb] Error 1
make[5]: Leaving directory '/home/dmitry/DTS_Test/target/linux/mediatek/image'
make[4]: *** [Makefile:18: install] Error 2
make[4]: Leaving directory '/home/dmitry/DTS_Test/target/linux/mediatek'
make[3]: *** [Makefile:11: install] Error 2
make[3]: Leaving directory '/home/dmitry/DTS_Test/target/linux'
time: target/linux/install#22.36#5.97#28.08
    ERROR: target/linux failed to build.
make[2]: *** [target/Makefile:25: target/linux/install] Error 1
make[2]: Leaving directory '/home/dmitry/DTS_Test'
make[1]: *** [target/Makefile:19: /home/dmitry/DTS_Test/staging_dir/target-aarch64_cortex-a53_musl/stamp/.target_install] Error 2
make[1]: Leaving directory '/home/dmitry/DTS_Test'
make: *** [/home/dmitry/DTS_Test/include/toplevel.mk:230: world] Ошибка 2

@deema sorry, this was caused by an omission in the commits I had pushed. I forced-pushed an update and also pushed to openwrt.git, the buildbot is munging on it in this moment:

https://buildbot.openwrt.org/master/images/#/builders/44/builds/6

(so in an hour or two we will have images on downloads.openwrt.org)

Update: yet another small bug (caused by uncareful copy&paste on my end), caused the generated U-Boot for eMMC to contain the environment for SDMMC. Fixed now:

Hi, I want make clear. U-boot and bl2 flashing in eMMC only when I pick “Install bootloader and recovery to eMMC.” from SD u-boot menu?

You can do that manually in the U-Boot shell as well. From within Linux you can write to the eMMC, but I haven’t tried writing to the boot0 hardware partition in that way (may require some extra locks to be broken).

Using the option to install to eMMC in the bootloader menu is the easiest way. If you don’t have serial access, you can trigger the installation on the next boot from within OpenWrt running from the SD Card like this:

fw_setenv bootcmd run emmc_init

Buildbot for mt7622 running again:

https://buildbot.openwrt.org/master/images/#/builders/44/builds/8

Once this has completed, there will be images on downloads.openwrt.org containing both, the changes needed to select either SATA or PCIE1 at boot as well as fixed environment for eMMC installation.

I have install new build, but how activate sata support.

I found IT:

fw_setenv bootconf config-mt7622-bananapi-bpi-r64-sata

and reboot.

I had try new build. It work fine. Sata port have work.

Should work as on other images (maybe need to prepare hw-partitions with mmc utils).

root@bpi-r64:~# echo 0 > /sys/block/mmcblk1boot0/force_ro
root@bpi-r64:~# dd if=bl2_emmc.bin of=/dev/mmcblk1boot0

If it does not boot from emmc check/set partition config with mmcutils (needs to be 0x48)

root@bpi-r64:~# ./mmc extcsd read /dev/mmcblk1 | grep 'PARTITION_CONFIG'                                                                                       
Boot configuration bytes [PARTITION_CONFIG: 0x00]
root@bpi-r64:~# ./mmc bootpart enable 1 1 /dev/mmcblk1                                                                                                         
root@bpi-r64:~# ./mmc extcsd read /dev/mmcblk1 | grep 'PARTITION_CONFIG'                                                                                       
Boot configuration bytes [PARTITION_CONFIG: 0x48]

Hello, i have a bpi-r64 (mt7622) with lede 17 snapshot instaled, i want to move to openwrt last stable 19. But i don’t understand how to install from scratch. Thanks for your reply.

Flash openwrt-mediatek-mt7622-bananapi_bpi-r64-sdcard.img to SD card (by Win32Diskimager for example). Boot from SD and flash loader by command “Install bootloader and recovery to eMMC.”. Reboot from eMMC and load sysupgrade image by tftp server (tftpd64 for example) . More information you can see there

1 Like

in U-boot how i can change the ip of tftp server ? sr9UxowSPK

By default env var serverip is used.

you can do

printenv serverip
setenv serverip 192.168.0.10

And try again

1 Like