Xunlong Orange Pi R1 Boot from Flash

sysupgrade will not work!
There you need to completely rewrite the commands in the files for updating using Luci or the command line.

@jayanta525, Show the /openwrt-master-kernel-4.19.104/build_dir/target-arm_cortex-a7+neon-vfpv4_musl_eabi/linux-sunxi_cortexa7/linux-4.19.104/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts file to make the correct patch-spi-flash for your source.
opi-r1 includes this dts.
1. In
/target/linux/sunxi/image/Makefile you should also write the line PROFILES: = Default

Part of the Makefile
define Device/Default
  PROFILES := Default
  DEVICE_VARS := SUNXI_DTS SUNXI_DTS_DIR SUNXI_UBOOT
  KERNEL_NAME := zImage
  KERNEL := kernel-bin | uImage none
  IMAGES := sysupgrade.bin
  SUPPORTED_DEVICES := $(subst _,$(comma),$(1))
  SUNXI_DTS_DIR :=
  SUNXI_DTS = $$(SUNXI_DTS_DIR)$$(SOC)-$(lastword $(subst _, ,$(1)))
  BLOCKSIZE := 64k
  IMAGE_SIZE := 15808k
  IMAGE/sysupgrade.bin = append-kernel | append-rootfs | pad-rootfs | \
         append-metadata | check-size $$$$(IMAGE_SIZE)
endef

Without this, there will be all profiles! And not just the chosen one.

IMAGE_SIZE: = 15808k,
this is 16384k(full 16Mb) - 512k(uboot) - 64k(dtb) = 15808k (firmware)

2. Edit /target/linux/sunxi/config-4.19 as in the spoiler:

Part of the config-4.19
CONFIG_MTD_JEDECPROBE=y
CONFIG_MTD_M25P80=y
CONFIG_MTD_SPI_NOR=y
CONFIG_MTD_CMDLINE_PARTS=y
CONFIG_MTD_SPLIT_FIRMWARE=y
CONFIG_MTD_SPLIT_SUPPORT=y
CONFIG_MTD_SPLIT_FIT_FW=y
CONFIG_MTD_SPLIT_UIMAGE_FW=y
CONFIG_MTD_OF_PARTS=y
CONFIG_MUTEX_SPIN_ON_OWNER=y
CONFIG_NEED_DMA_MAP_STATE=y
CONFIG_NEON=y

3. Create the file 212-add-mtd-spi-flash-opi.patch inside /target/linux/sunxi/patches-4.19.
And paste the contents of the spoiler:

212-add-mtd-spi-flashopi-zero.patch
--- a/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts
+++ b/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts
@@ -60,6 +70,7 @@
 		/* ethernet0 is the H3 emac, defined in sun8i-h3.dtsi */
 		ethernet0 = &emac;
 		ethernet1 = &xr819;
+		spi0 = &spi0;
 	};
 
 	chosen {
@@ -172,7 +179,7 @@
 
 &spi0 {
 	/* Disable SPI NOR by default: it optional on Orange Pi Zero boards */
-	status = "disabled";
+	status = "okay";
 
 	flash@0 {
 		#address-cells = <1>;
@@ -179,6 +199,28 @@
 		compatible = "mxicy,mx25l1606e", "winbond,w25q128";
 		reg = <0>;
 		spi-max-frequency = <40000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <0x01>;
+			#size-cells = <0x01>;
+
+			partition@0 {
+				label = "uboot";
+				reg = <0x0 0x80000>;
+			};
+
+			partition@80000 {
+				label = "dtb";
+				reg = <0x80000 0x10000>;
+			};
+
+			partition@90000 {
+				compatible = "denx,uimage";
+				label = "firmware";
+				reg = <0x90000 0xf70000>;
+			};
+		};
 	};
 };
 

uboot use only this one: https://github.com/melsem/openwrt-19.07.2-spi/raw/master/uboot_opi-zero_opi-r1.bin

cd /tmp
mtd -e uboot write uboot_opi-zero_opi-r1.bin uboot
mtd -e dtb write sun8i-h2-plus-orangepi-r1.dtb dtb
mtd -e firmware write openwrt-sunxi-cortexa7-sun8i-h2-plus-orangepi-r1-squashfs-sysupgrade.bin firmware

This is all that needs to be done so that after writing to the sysupgrade.bin spi-flash drive, the firmware is downloaded.

Developer @tr4bl3 (showuser=1177645).
I took a minimal part.
Tested, wrote instructions and uploaded to git. And some additions.

2 Likes

Following these steps i was able to get it working.

Thank you.

Sorry for necroposting to this one but this was bang on what I'm looking for, building custom images for OrangePi R1 using the sdk. The link above is dead. Can someone either redirect me to where this topic may have carried on or help me with obtaining the file indicated above. TIA.

The link above has been renamed and updated from 07.19.2-spi to 07.19.7-spi.
There are files for firmware:
sun8i-h2-plus_orangepi-r1-boot.bin.
sun8i-h2-plus-orangepi-r1-dtb
sun8i-h2-plus-orangepi-r1-squashfs-sysupgrade.bin
But they are from 19.07.2-spi.

In "README.md" I wrote how to write in "spi-flash", but the commands for files are from "orangepi-zero".
For "orangepi-R1":

cd /tmp
mtd -e uboot write sun8i-h2-plus_orangepi-r1-boot.bin uboot
mtd -e dtb write sun8i-h2-plus-orangepi-r1-dtb dtb
mtd -e firmware write sun8i-h2-plus-orangepi-r1-squashfs-sysupgrade.bin firmware

Edit basic boot configuration: http://192.168.10.1/boot

You can build it yourself with the necessary packages by downloading these patched raw materials.

1 Like

Fantastic. Thanks for updating the links.

I'm trying to use this with my OrangePi Zero. I followed the steps on github with the appropriate files (the "zero" ones) and it works as expected until the very last step.
The command "mtd -e firmware write sun8i-h2-plus-orangepi-zero-squashfs-sysupgrade.bin firmware" results in the following:
Unlocking firmware ...
Erasing firmware ...

Writing from sun8i-h2-plus-orangepi-zero-squashfs-sysupgrade.bin to firmware ...
then a series of [e] and [w] follow as it's erasing and writing, and finally
[e]Failed to erase block

and it fails. I tried it several times, after powering off/on each time, but it fails each time.

I have two OPI zero boards, and both fail in the exact same way. They are both the 512MB version, if that matters.

Any ideas?

TBH, all I want to do is to access the boot configuration to turn on wifi.

Opangepi-zero has 2 MB of flash memory.
And it needs to be re-soldered for 16 MB.
Therefore, an error is displayed: [e] Failed to erase block.

1 Like

Ah OK thanks; I wasn't aware of that as I haven't seen mentions of the required flash anywhere. I can do that, I've upgraded the flash chip on other routers in the past. Perhaps it would be good to mention the amount of flash required for the devices in the readme somewhere.

update: it worked, after I unsoldered the flash chip and soldered in its place a W25Q128 (16MB)
original chip:

new chip:

Thanks for the help.
Now, if I could only get this board to connect to my wifi network as a client... doesn't see it in scan.

1 Like

To make the search for access points work (client):
It is necessary to disable "AP" or delete it before scanning.
This is such a disadvantage of xradio.

even with the AP deleted, the scan still returns nothing. This is with the board physically within 2m of the router I want it to connect to. :frowning:

The xradio client does not work with all encryptions.
Install WPA2-PSK (strong security) encryption on the primary access point.

And repeat the search with "opangepi-zero".

I have an orange, through the xradio client, they catch wifi at a distance of about 15 meters, through 2 walls.

WPA2-PSK is what I use. I did the scan many times, nothing.

Look, maybe what are you doing wrong?
I checked the files directly downloaded from "git".

Here I posted a video from the screen with full orangepi firmware. And more WIFI scan settings.

I also have a OrangePi Zero laying around.
I remove the spi flash (2MB) from board and programmed 16MB flash chip with bootloader, dtb and firmware. Then I tried to boot without sd card. nothing.

I wrote the openwrt version to sd card and it booted but from sdcard. I checked
cat /proc/mtd
And the output is empty. Do you know any reason why it could be empty?

it seems to me you flashed dtb with no spi support. Follow above the instructions.

Oh my god. I tried and tried everything. Did everything according to tutorial. For few hours.

Then I had an idea maybe it doesn't "see" the spi because soldering. And I reheated pads. Then booting from sdcard and checking /proc/mtd showed partitions.
Removed sdcard as I had already flashed spi with external programmer and it booted right up from spi.

Ugh fwe hours for bad soldering. :blush:

1 Like

@xTomax Thank you i have solved problem given below with your post

[    1.295380] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[    1.302904] Please append a correct "root=" boot option; here are the available partitions:
[    1.311291] 1f00             512 mtdblock0 
[    1.311294]  (driver?)
[    1.317845] 1f01              64 mtdblock1 
[    1.317847]  (driver?)
[    1.324392] 1f02           15808 mtdblock2 
[    1.324394]  (driver?)
[    1.330946] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[    1.339213] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 5.4.203 #0```

Would the same instructions apply to the R1+ for SPI? Is there a way to get SPI into OpenWrt mainline support going forward?