[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.