Xunlong Orange Pi R1 Boot from Flash

Hello there,

I have a Xunlong Orange Pi R1 with 16MB flash (https://openwrt.org/toh/hwdata/xunlong/xunlong_orange_pi_r1).

I've already loaded the latest version to the SD Card and boot from there. Beside Wi-Fi (witch I don't need) everything works very smooth and nicely! But apparently there is only a version to use with the SD Card, and I would like to use the SPI flash to avoid uising an SD Card (testing for industrial environment)

I've been search for some time now for a way to transfer the SD Card installation to the SPI flash.
I found [hyphop] version, miZy - https://github.com/hyphop/miZy, witch is derived from openwrt and allow for flash installation. But there is no usable GUI and no real good explanation of how to work with it (eg. enable DHCP on one port). Things seemed a bit hardcoded (at least to the best o my low knowledge on the matter).

Is there anyone who can help me find a way to build or copy the running version on the SD Card to the SPI flash and boot from it?

from miZy instalation I got: root@miZy:/# cat /proc/mtd
dev: size erasesize name
mtd0: 00080000 00010000 "uboot"
mtd1: 00010000 00010000 "script"
mtd2: 00010000 00010000 "dtb"
mtd3: 003a0000 00010000 "kernel"
mtd4: 004b0000 00010000 "initrd"
mtd5: 00710000 00010000 "user"
mtd6: 01000000 00010000 "full"

So I'm hopping the necessary uboot is already written witch can simplify things for me a bit?
(It seams to me I'm missing something incredibly simple or easy but I just can't reach it).

1 Like

[NOTE: This guide is incomplete, still trying to understand is different form the steps I take.]

If by any chance anyone is looking to solve this, I partially solve the issue.

First of all:

I've used as reference the miZy project: https://github.com/hyphop/miZy So, many thanks for the work done there!

Since I didn't needed WIFI (not natively supported with openwrt for this board) and wanted a not modified version of openwrt, I end up using the miZy project as a kick starter for this. In the end I'm only using the uboot (mtd0) but the whole project help a lot making this possible.

Since I was a complete noob regarding uboot, spi flash, and that kinda of stuff, I had help from PaulFertser on IRC freenode #openwrt, whom I do really appreciate the help.

TL:DR - Jump to installing system on flash.

I did it in 3 major steps:

  • Compile the correct openwrt version with changes to make file in order to get as output the sysupgrade image (for the flash - 16286KB).
  • Flash the compiled image to SPI NOR flash.
  • Change the starting script in order to boot correctly.
  • Bonus enable the 3 uarts available on the GPIO pins (by changing the DTB file)

Compile the correct openwrt version with changes to make file in order to get as output the sysupgrade image (for the flash - 16286KB)

First thing I noticed when search for this device was there is a lack of an openwrt image for the SPI flash, the compiled one available (https://openwrt.org/toh/hwdata/xunlong/xunlong_orange_pi_r1) is for the SD Card, witch came handy regarding the flash access.

To get the appropriate sysupgrade image I've
selected the appropriated board on make menuconfig:

  • Target System (Allwinner A1x/A20/A3x/R40)

  • Subtarget (Allwinner A20/A3x/R40)

  • Target Profile (Xunlong Orange Pi R1)

  • Target image > remove ext4 to avoid compilation errors.

Changed the makefile inside: openwrt/target/linux/sunxi/image with the file (mega link below) Makefile_sysupgrade (remove the _sysupgrade and replace the Makefile).

After compiling a sysupgrade image is created like the file in Mega: openwrt-sunxi-cortexa7-xunlong_orangepi-r1-squashfs-sysupgrade.bin

Installing system on flash

We now have a sysupgrade with our rootfs.
With this we can simply flash the mtdparts and upgrade to latest version.

The easiest way we came up with, was to extract and "burn" the SDCard build with MTD Support to an SDCard: openwrt-r1-squashfs-sdcard_MTDSupport.img.gz, the first partitions has a few files, backup the boot.src and replace it with the one on MEGA repo boot.scr_ReplaceOnSDCard (remove the _ReplaceOnSDCard from the file name).

This file only changes the bootargs section to include the SPI flash partitions as we want to use them adding: mtdparts=spi0.0:512k(uboot),64k(script),64k(dtb),-(firmware) . Now boot the Orange pi R1 with this file modded on the sdcard. The system shall boot and you have an openwrt router on the R1.
run command: cat /proc/mtd and shall see this:

root@OpenWrt:/# cat /proc/mtd
dev: size erasesize name
mtd0: 00080000 00010000 "uboot"
mtd1: 00010000 00010000 "script"
mtd2: 00010000 00010000 "dtb"
mtd3: 00f60000 00010000 "firmware"

If everything is OK so far, lets proceed. If not the mtd partitions are not ok. There was probably some error replacing the boot.src, check that again.

Extract the MTDParts.7z it shall have 7 img files. We will use the first 4. (mtd0_uboot.img, mtd1_script.img, mtd2_DTB.img, mtd3_Firmware.img), copy them to the /tmp of the booted orangepi R1 (using scp for instance). And don't forget to move to /tmp folder.

Now simply use MTD command to write the correct image to the correct place:
mtd write /dev/mtd0 mtd0_uboot.img
mtd write /dev/mtd1 mtd1_script.img
mtd write /dev/mtd2 mtd2_DTB.img
mtd write /dev/mtd3 mtd3_Firmware.img

And thats all, you now shall be able to poweroff remove the sdcard and boot the system witch will use the spi flash.

TODO: Build an Uboot image with support for SPI flash (read and write) in order to use a more recent uboot verison.

Repo with all the needed files (and more):

https://mega.nz/folder/xmA3WI6L#riaNTSHXrKyjst1fKRYmfQ

If by any change someone thinks this shall be posted on a wiki page, please tell me how to do it.

4 Likes

Thanks for the work you've done.

Having written your files to the flash, orange pi works.
But I have collected openwrt-sunxi-cortexa7-xunlong_orangepi-r1-squashfs-sysupgrade.bin not works.

boot log

[ 2.662934] mmc1: new high speed SDIO card at address 0001
[ 2.666003] ALSA device list:
[ 2.674467] No soundcards found.
[ 2.678964] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[ 2.686488] Please append a correct "root=" boot option; here are the available partitions:
[ 2.694883] 1f00 512 mtdblock0
[ 2.694890] (driver?)
[ 2.701440] 1f01 64 mtdblock1
[ 2.701446] (driver?)
[ 2.708017] 1f02 64 mtdblock2
[ 2.708024] (driver?)
[ 2.714594] 1f03 15744 mtdblock3
[ 2.714600] (driver?)
[ 2.721146] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[ 2.729415] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 4.14.171 #0
[ 2.735505] Hardware name: Allwinner sun8i Family
[ 2.740258] [] (unwind_backtrace) from [] (show_stack+0x10/0x14)
[ 2.748018] [] (show_stack) from [] (dump_stack+0x94/0xa8)
[ 2.755257] [] (dump_stack) from [] (panic+0xec/0x278)

What else needs to be edited? Or add in .config?
Makefile edited.

You are trying to compile openwrt after editing Makefile and use the resulting sysupgrade to upgrade the already working system on flash? Or are you trying to do another thing? This is important so I can try and recreate your issue.

Yes, I compiled openwrt after editing the Makefile and used the resulting sysupgrade to update an already running system in spi-flash memory.

Target image > removed ext4.
There were no errors during compilation.

I'm not recalling any other change besides that and the Makefile inside openwrt/target/linux/sunxi/image .
I just compiled, try to sysupgrade, selected force the upgrade and then, the upgrade was successful.

What are the version you are using?

Is there any command I can use to give you all my configuration for compiling?

My actions:

  1. Downloaded openwrt-19.07.2

  2. Added a patch for mtd flash drives, /openwrt-19.07.2/target/linux/sunxi/patches-4.14/212-add-spi-flash-opi-zero.patch

212-add-spi-flash-opi-zero.patch
--- a/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts
+++ b/arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts
@@ -389,6 +400,32 @@
 		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 = "script";
+				reg = <0x80000 0x10000>;
+			};
+
+			partition@90000 {
+				label = "dtb";
+				reg = <0x90000 0x10000>;
+			};
+
+			partition@a0000 {
+				label = "firmware";
+				reg = <0xa0000 0xf60000>;
+			};
+		};
 	};
 };
 
  1. Edited the Makefile inside /target/linux/sunxi/image

  2. ./scripts/feeds update -a && ./scripts/feeds install -a

  3. make menuconfig
    I selected the opi-R1 profile and the Target Image> deleted ext4.
    marked "y" mmc-spi.
    Exit & save.
    make -j1 V=s

Openwrt-sunxi-cortexa7-sun8i-h2-plus-orangepi-r1-squashfs-sysupgrade.bin assembly.
And I used it to update an already running system in spi-flash.

Your files were already written to the spi-flash drive, and Orange Pi worked.
And my sysupgrade - in the log is this:

log

[ 2.678964] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[ 2.686488] Please append a correct "root=" boot option; here are the available partitions:
[ 2.694883] 1f00 512 mtdblock0
[ 2.694890] (driver?)
[ 2.701440] 1f01 64 mtdblock1
[ 2.701446] (driver?)
[ 2.708017] 1f02 64 mtdblock2
[ 2.708024] (driver?)
[ 2.714594] 1f03 15744 mtdblock3
[ 2.714600] (driver?)
[ 2.721146] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[ 2.729415] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 4.14.171 #0
[ 2.735505] Hardware name: Allwinner sun8i Family[/details]

1 Like

Humm. I did not run the patch on your point 2. What is the intended purpose of it?

Show me your Makefile please.

It seams that kernel cannot load the rootfs for some reason. It appears not to be in the correct location.

I started the assembly from the beginning.
Maybe with openwrt-19.07.2 something else is also noted in make kernel_menuconfig?

  1. Download openwrt-master.

  2. I put your Makefile_sysupgrade in /openwrt-master/target/linux/sunxi/image/ and renamed it to Makefile.

Makefile_sysupgrade

#
# Copyright (C) 2013-2016 OpenWrt.org
# Copyright (C) 2016 Yousong Zhou
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/image.mk

FAT32_BLOCK_SIZE=1024
FAT32_BLOCKS=$(shell echo $$(($(CONFIG_SUNXI_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))

DEVICE_VARS := SUNXI_DTS SUNXI_DTS_DIR
KERNEL_LOADADDR:=0x40008000

define Build/sunxi-sdcard
	rm -f $@.boot
	mkfs.fat $@.boot -C $(FAT32_BLOCKS)

	mcopy -i $@.boot $(STAGING_DIR_IMAGE)/$(DEVICE_NAME)-boot.scr ::boot.scr
	mcopy -i $@.boot $(DTS_DIR)/$(SUNXI_DTS).dtb ::dtb
	mcopy -i $@.boot $(IMAGE_KERNEL) ::uImage
	./gen_sunxi_sdcard_img.sh $@ \
		$@.boot \
		$(IMAGE_ROOTFS) \
		$(CONFIG_SUNXI_SD_BOOT_PARTSIZE) \
		$(CONFIG_TARGET_ROOTFS_PARTSIZE) \
		$(STAGING_DIR_IMAGE)/$(DEVICE_NAME)-u-boot-with-spl.bin
	rm -f $@.boot
endef

# why \x00\x00\x00\x00 for zImage-initramfs
define Device/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 := 16286k
  IMAGE/sysupgrade.bin = append-kernel | append-rootfs | pad-rootfs | \
         append-metadata | check-size $$$$(IMAGE_SIZE)
endef

ifeq ($(SUBTARGET),cortexa7)
include cortex-a7.mk
endif

ifeq ($(SUBTARGET),cortexa8)
include cortex-a8.mk
endif

ifeq ($(SUBTARGET),cortexa53)
include cortex-a53.mk
endif

$(eval $(call BuildImage))
  1. ./scripts/feeds update -a && ./scripts/feeds install -a

    make menuconfig
    I selected the opi-R1 profile and the Target Image > deleted ext4.
    marked "y" mmc-spi.
    Exit & save.
    make -j1 V=s

  2. File in /openwrt-master/bin/targets/sunxi/cortexa7/openwrt-sunxi-cortexa7-xunlong_orangepi-r1-squashfs-sysupgrade.bin is assembled.
    I load it into /tmp.

  3. cd /tmp
    mtd write openwrt-sunxi-cortexa7-xunlong_orangepi-r1-squashfs-sysupgrade.bin firmware

The process of loading a file in spi-flesh has been going on for some time.
Download completed successfully.
I give the reboot command.

The process runs fine until: root is not created ..
And then the error log that I posted in the first message.

Through luci is not updated ..
After a reboot, your firmware remains ..

Maybe something else should be noted in make kernel_menuconfig?

If not difficult, repeat this from the original sources.
I have repeated more than once, and nothing comes out ..

Why 'marked "y" mmc-spi'?

Why are you writing the sysupgrade using MTD to the firmware section of the flash? No wonder that section get corrupted. You would have to write, if I'm not mistaken, the uImage to the correct location. Altho the sysupgrade shall do that for you.

You can also try my image if you want: https://mega.nz/file/M3JWWQLZ#v5x8OgDAfDE2xEnwf_4jiiSQ7XQq6jt-FLmRDx5tJAE

Using CLI try this: sysupgrade -F openwrt-sunxi-cortexa7-xunlong_orangepi-r1-squashfs-sysupgrade.bin

This shall proceed with the sysupgrade correctly.

Please try this first and tell me what happen.

Loaded inside /tmp my openwrt-sunxi-cortexa7-xunlong_orangepi-r1-squashfs-sysupgrade.bin
In putty:
cd /tmp
sysupgrade -F openwrt-sunxi-cortexa7-xunlong_orangepi-r1-squashfs-sysupgrade.bin

The firmware has not been updated..

log-sysupgrade
root@OpenWrt:/#
root@OpenWrt:/# cd /tmp
root@OpenWrt:/tmp# sysupgrade -F openwrt-sunxi-cortexa7-xunlong_orangepi-r1-squashfs-sysupgrade.bin
Unable to determine upgrade device
Image check failed but --force given - will update anyway!
Saving config files...
Commencing upgrade. Closing all shell sessions.
Watchdog handover: fd=3
- watchdog -
killall: telnetd: no process killed
Sending TERM to remaining processes ... ubusd askfirst urngd logd rpcd netifd odhcpd uhttpd ntpd dnsmasq
Sending KILL to remaining processes ...
Switching to ramdisk...
Performing system upgrade...
Unable to determine upgrade device
sh: 7: unknown operand
sh: 7: unknown operand
sh: 7: unknown operand
sh: 7: unknown operand
sh: 7: unknown operand
sh: 7: unknown operand
sh: 7: unknown operand
sh: 7: unknown operand
sh: 31: unknown operand
sh: 31: unknown operand
sh: 31: unknown operand
sh: 31: unknown operand
sh: 31: unknown operand
sh: 31: unknown operand
sh: 31: unknown operand
Upgrade completed
Rebooting system...
umount: can't unmount /dev: Resource busy
umount: can't unmount /tmp: Resource busy
[  487.195070] kvm: exiting hardware virtualization
[  487.202831] reboot: Restarting system

U-Boot SPL 2017.01-hyphop miZy (May 26 2018 - 14:48:37)
DRAM: 512 MiB
Trying to boot from sunxi SPI

U-Boot 2017.01-hyphop miZy (May 26 2018 - 14:48:37 +0700) Allwinner Technology

CPU:   Allwinner H3 (SUN8I 1680)
Model: Xunlong Orange Pi R1
I2C:   ready
DRAM:  512 MiB
MMC:   SUNXI SD/MMC: 0, SUNXI SD/MMC: 1
MMC: no card present
*** Warning - MMC init failed, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   phy interface0
eth0: ethernet@1c30000
Setting bus to 0
Valid chip addresses:
Hit any key to stop autoboot:  0
SPI readed 8192 bytes from 524288 offset, time 0.004
## Executing script at 43100000
SPI readed 65536 bytes from 589824 offset, time 0.035
SPI readed 3751621 bytes from 655360 offset, time 2.005
## Booting kernel from Legacy Image at 42000000 ...
   Image Name:   ARM OpenWrt Linux-4.19.108
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    2922048 Bytes = 2.8 MiB
   Load Address: 40008000
   Entry Point:  40008000
## Flattened Device Tree blob at 43000000
   Booting using the fdt blob at 0x43000000
   Loading Kernel Image ... OK
   Loading Device Tree to 40ff7000, end 40fffbd3 ... OK

Starting kernel....

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.19.108 (tomax@debian) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r12689-9e5a25846f)) #0 SMP PREEMPT Sun Mar 22 13:37:37 2020
[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=30c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: Xunlong Orange Pi R1
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: Using PSCI v0.1 Function IDs from DT
[    0.000000] random: get_random_bytes called from start_kernel+0x7c/0x428 with crng_init=0
[    0.000000] percpu: Embedded 15 pages/cpu s31244 r8192 d22004 u61440
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 129920
[    0.000000] Kernel command line: console=ttyS0,115200 earlyprintk rootfstype=squashfs mtdparts=spi0.0:512k(uboot),64k(script),64k(dtb),-(firmware) btime=2.354
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 508036K/524288K available (5928K kernel code, 393K rwdata, 1644K rodata, 2048K init, 243K bss, 16252K reserved, 0K cma-reserved, 0K highmem)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xe0800000 - 0xff800000   ( 496 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xe0000000   ( 512 MB)
[    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
[    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)
[    0.000000]       .text : 0x(ptrval) - 0x(ptrval)   (7945 kB)
[    0.000000]       .init : 0x(ptrval) - 0x(ptrval)   (2048 kB)
[    0.000000]       .data : 0x(ptrval) - 0x(ptrval)   ( 394 kB)
[    0.000000]        .bss : 0x(ptrval) - 0x(ptrval)   ( 244 kB)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[    0.000000] rcu: Preemptible hierarchical RCU implementation.
[    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
[    0.000000]  Tasks RCU enabled.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] GIC: Using split EOI/Deactivate mode
[    0.000000] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.000000] arch_timer: cp15 timer(s) running at 24.00MHz (phys).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
[    0.000012] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
[    0.000034] Switching to timer-based delay loop, resolution 41ns
[    0.000265] Console: colour dummy device 80x30
[    0.000337] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)
[    0.000365] pid_max: default: 32768 minimum: 301
[    0.000658] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.000682] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.001971] CPU: Testing write buffer coherency: ok
[    0.002625] /cpus/cpu@0 missing clock-frequency property
[    0.002676] /cpus/cpu@1 missing clock-frequency property
[    0.002719] /cpus/cpu@2 missing clock-frequency property
[    0.002764] /cpus/cpu@3 missing clock-frequency property
[    0.002787] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[    0.060091] Setting up static identity map for 0x40200000 - 0x40200060
[    0.080089] rcu: Hierarchical SRCU implementation.
[    0.120206] smp: Bringing up secondary CPUs ...
[    0.210883] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[    0.301162] CPU2: thread -1, cpu 2, socket 0, mpidr [    0.509955] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.510257] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.525776] io scheduler noop registered
[    0.525806] io scheduler deadline registered
[    0.526071] io scheduler cfq registered (default)
[    0.527365] sun4i-usb-phy 1c19400.phy: Couldn't request ID GPIO
[    0.535632] sun8i-h3-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[    0.538741] sun8i-h3-r-pinctrl 1f02c00.pinctrl: initialized sunXi PIO driver
[    0.551997] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled
[    0.555393] console [ttyS0] disabled
[    0.575851] 1c28000.serial: ttyS0 at MMIO 0x1c28000 (irq = 39, base_baud = 1500000) is a U6_16550A
[    1.188001] console [ttyS0] enabled
[    1.201363] loop: module loaded
[    1.208267] m25p80 spi0.0: found w25q128, expected mx25l1606e
[    1.225054] m25p80 spi0.0: w25q128 (16384 Kbytes)
[    1.229801] 4 cmdlinepart partitions found on MTD device spi0.0
[    1.235762] Creating 4 MTD partitions on "spi0.0":
[    1.240570] 0x000000000000-0x000000080000 : "uboot"
[    1.247015] 0x000000080000-0x000000090000 : "script"
[    1.253315] 0x000000090000-0x0000000a0000 : "dtb"
[    1.259268] 0x0000000a0000-0x000001000000 : "firmware"
[    1.267832] random: fast init done
[    1.325157] no rootfs found after FIT image in "firmware"
[    1.457681] 2 uimage-fw partitions found on MTD device firmware
[    1.463659] 0x0000000a0000-0x000000369680 : "kernel"
[    1.469975] 0x00000036968n8i 1c30000.ethernet: Current syscon value is not the default 148000 (expect 58000)
[    1.523127] dwmac-sun8i 1c30000.ethernet: No HW DMA feature register supported
[    1.530352] dwmac-sun8i 1c30000.ethernet: RX Checksum Offload Engine supported
[    1.537602] dwmac-sun8i 1c30000.ethernet: COE Type 2
[    1.542603] dwmac-sun8i 1c30000.ethernet: TX Checksum insertion supported
[    1.549393] dwmac-sun8i 1c30000.ethernet: Normal descriptors
[    1.555076] dwmac-sun8i 1c30000.ethernet: Chain mode enabled
[    1.561073] libphy: stmmac: probed
[    1.565556] dwmac-sun8i 1c30000.ethernet: Found internal PHY node
[    1.571916] libphy: mdio_mux: probed
[    1.575531] dwmac-sun8i 1c30000.ethernet: Switch mux to internal PHY
[    1.581936] dwmac-sun8i 1c30000.ethernet: Powering internal PHY
[    1.589029] libphy: mdio_mux: probed
[    1.594171] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.600706] ehci-platform: EHCI generic platform driver
[    1.606323] ehci-platform 1c1a000.usb: EHCI Host Controller
[    1.612006] ehci-platform 1c1a000.usb: new USB bus registered, assigned bus number 1
[    1.619990] ehci-platform 1c1a000.usb: irq 28, io mem 0x01c1a000
[    1.650986] ehci-platform 1c1a000.usb: USB 2.0 started, EHCI 1.00
[    1.657442] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 4.19
[    1.665761] usb usb1: N[    2.020986] ehci-platform 1c1b000.usb: USB 2.0 started, EHCI 1.00
[    2.027451] usb usb3: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 4.19
[    2.035770] usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    2.043022] usb usb3: Product: EHCI Host Controller
[    2.047906] usb usb3: Manufacturer: Linux 4.19.108 ehci_hcd
[    2.053510] usb usb3: SerialNumber: 1c1b000.usb
[    2.058835] hub 3-0:1.0: USB hub found
[    2.062703] hub 3-0:1.0: 1 port detected
[    2.068032] ohci-platform 1c1b400.usb: Generic Platform OHCI controller
[    2.074748] ohci-platform 1c1b400.usb: new USB bus registered, assigned bus number 4
[    2.082779] ohci-platform 1c1b400.usb: irq 31, io mem 0x01c1b400
[    2.155308] usb usb4: New USB device found, idVendor=1d6b, idProduct=0001, bcdDevice= 4.19
[    2.163633] usb usb4: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    2.170858] usb usb4: Product: Generic Platform OHCI controller
[    2.176815] usb usb4: Manufacturer: Linux 4.19.108 ohci_hcd
[    2.182419] usb usb4: SerialNumber: 1c1b400.usb
[    2.187706] hub 4-0:1.0: USB hub found
[    2.191575] hub 4-0:1.0: 1 port detected
[    2.196555] cpu cpu0: Linked as a consumer to regulator.5
[    2.202105] cpu cpu0: Dropping the link to regulator.5
[    2.207537] cpu cpu0: Linked as a consumer to regulator.5
[    2.223895] sunxi-mmc 1c10000.mmc: Linked as a consumer to regulator.4
[    2.230891] sunxi-mmc 1c10000.mmc: allocated mmc-pwrseq
[    2.473526] sunxi-mmc 1c10000.mmc: initialized, max. request size: 16384 KB
[    2.480611] hctosys: unable to open rtc device (rtc0)
[    2.486277] ALSA device list:
[    2.489244]   No soundcards found.
[    2.496110] mmc1: new high speed SDIO card at address 0001
[    2.498188] VFS: Mounted root (squashfs filesystem) readonly on device 31:5.
[    2.511406] Freeing unused kernel memory: 2048K
[    2.516081] Run /sbin/init as init process
[    2.599645] random: crng init done
[    2.921273] init: Console is alive
[    2.924904] init: - watchdog -
[    3.125368] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    3.207163] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    3.221550] init: - preinit -
[    3.841834] Generic PHY 0.1:01: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0.1:01, irq=POLL)
[    3.852773] dwmac-sun8i 1c30000.ethernet eth0: No Safety Features support found
[    3.860086] dwmac-sun8i 1c30000.ethernet eth0: No MAC Management Counters available
[    3.867810] dwmac-sun8i 1c30000.ethernet eth0: PTP not supported by HW
[    3.875990] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[    8.001484] dwmac-sun8i 1c30000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
[    8.010079] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[    8.050795] jffs2: notice: (866) jffs2_build_xattr_subsystem: complete building xattr subsystem, 5 of xdatum (0 unchecked, 3 orphan) and 9 of xref (3 dead, 0 orphan) found.
[    8.069959] mount_root: switching to jffs2 overlay
[    8.094225] overlayfs: upper fs does not support tmpfile.
[    8.141177] urandom-seed: Seeding with /etc/urandom.seed
[    8.217989] procd: - early -
[    8.221101] procd: - watchdog -
[    8.921421] procd: - watchdog -
[    8.924826] procd: - ubus -
[    8.978912] procd: - init -
Please press Enter to activate this console.
[    9.257270] kmodloader: loading kernel modules from /etc/modules.d/*
[    9.282095] usbcore: registered new interface driver r8152
[    9.295634] xt_time: kernel timezone is -0000
[    9.309291] urngd: v1.0.2 started.
[    9.312199] PPP generic driver version 2.4.2
[    9.318024] NET: Registered protocol family 24
[    9.329346] kmodloader: done loading kernel modules from /etc/modules.d/*
[   12.668512] Generic PHY 0.1:01: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0.1:01, irq=POLL)
[   12.679884] dwmac-sun8i 1c30000.ethernet eth0: No Safety Features support found
[   12.687382] dwmac-sun8i 1c30000.ethernet eth0: No MAC Management Counters available
[   12.695552] dwmac-sun8i 1c30000.ethernet eth0: PTP not supported by HW
[   12.703130] br-lan: port 1(eth0) entered blocking state
[   12.708389] br-lan: port 1(eth0) entered disabled state
[   12.714254] device eth0 entered promiscuous mode
[   12.720534] IPv6: ADDRCONF(NETDEV_UP): br-lan: link is not ready
[   16.881435] dwmac-sun8i 1c30000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
[   16.890024] br-lan: port 1(eth0) entered blocking state
[   16.895283] br-lan: port 1(eth0) entered forwarding state
[   16.901767] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready
[   33.120965] vcc3v0: disabling
[   33.123959] vcc3v3: disabling
[   33.126924] vcc5v0: disabling

In my firmware should be:

Linux version 4.19.108 (sem@RV508) (gcc version 8.3.0 (OpenWrt GCC 8.3.0 r12644-50a59b3a39))

Your firmware also does not update

root@OpenWrt:/# cd /tmp
root@OpenWrt:/tmp# sysupgrade -F openwrt-sunxi-cortexa7-xunlong_orangepi-r1-squa
shfs-sysupgrade.bin
Unable to determine upgrade device
Image check failed but --force given - will update anyway!
Saving config files...
Commencing upgrade. Closing all shell sessions.
Watchdog handover: fd=3

  • watchdog -
    killall: telnetd: no process killed
    Sending TERM to remaining processes ... urngd logd rpcd netifd odhcpd uhttpd ntpd dnsmasq ubusd askfirst
    Sending KILL to remaining processes ...
    Switching to ramdisk...
    Performing system upgrade...
    Unable to determine upgrade device
    sh: 7: unknown operand
    sh: 7: unknown operand
    sh: 7: unknown operand
    sh: 7: unknown operand
    sh: 7: unknown operand
    sh: 7: unknown operand
    sh: 7: unknown operand
    sh: 7: unknown operand
    sh: 31: unknown operand
    sh: 31: unknown operand
    sh: 31: unknown operand
    sh: 31: unknown operand
    sh: 31: unknown operand
    sh: 31: unknown operand
    sh: 31: unknown operand
    Upgrade completed
    Rebooting system...
    umount: can't unmount /dev: Resource busy
    umount: can't unmount /tmp: Resource busy
    [ 174.405613] kvm: exiting hardware virtualization
    [ 174.413305] reboot: Restarting system

That is indeed weird! Because on my side the firmware I gave you updates without any issue what so ever.

I'm thinking its device related. Or something is missing indeed.

It is indeed a Orange Pi R1 we are talking here, right?

I'm expecting to receive some factory devices from china, they were shipped using DHL but due to the virus, not really sure how long it will take.
After I receive them I have to program them and I think it would be the best test I can make either it works or not.

Yes, orange pi R1.
Spi-flash drive 16 MB (w25q128).
I recorded your files from the MTDParts.7z archive, orange pi R1 works.

But I can’t update it and install kmod packages..
If forced, then: Kernel of panic and constant reboot.

Your firmware is not updated via sysupgrade -F, it is not updated via luci (sysupgrade-compatible).

But if you erase / dev / mtd3 (firmware), and then flash it, then orangepi works.
mtd -e firmware -r write openwrt-sunxi-cortexa7-xunlong_orangepi-r1-squashfs-sysupgrade.bin firmware

That can actually make sense! The erase the spi part. Since it was the only thing I had to do differently from the guide I wrote, because I did it by trying stuff out. And as much as I repeated the hole process I did never encounter a difference, because I did not erase the flash.

Maybe probably because of the way the flash is written and the rootfs is created after?
I'm not too of an expert on this area.

@xTomax
The builds you provided works perfectly. linux 4.19.108 openwrt master.

I am using an customized build with linux 4.19.104 and openwrt master. After many modification, i'm still unable to boot openwrt from my image.

I'm collecting a bit more info, but if you have to build you need to enable this configs:

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

And try the makefile I have above. I think with this you can build correctly.
The Wifi won't work. I'll have to check a few more things when I get the time. @skreydaIs is helping a lot with this =)

2 Likes

I'll try with these config enabled on kernel_menuconfig.

So, the finalized steps would be,

  1. Follow your first post for installation. Get it all working and verified.
  2. Prepare build system and Modify Makefile inside target/linux/sunxi
  3. Apply configs in kernel_menuconfig.
  4. Compile and copy the compiled squashfs file to /tmp.
  5. sysupgrade or mtd write the squashfs.bin file in firmware.
  6. reboot.

Is this correct or am i missing something?

@skreyda has made an github repo, and that image too works great. Following his commits on github, and applying it to my build system, i'm unable to get a working build.

I am waiting for an more documented guide.

Thanks to both of you for your efforts.

If you use the mtd write like this (-e option) the flash section (firmware) is erased 1st and your build shall work with no problem.

mtd -e firmware write openwrt-sunxi-cortexa7-xunlong_orangepi-r1-squashfs-sysupgrade.bin firmware

If you build the version with this correct configs, you shall be able to sysupgrade.

Try it!

1 Like