OK, So I was able to get back to stock on my own.
The process to convert to OpenWRT was to sort of follow this guide
OpenWRT install
- Connect UART (for some reason I had to connect my USB interface board Rx and Tx pins to the published Rx and Tx pins on the Qhora straight-through... should be crossed but whatever).
- Statically set my PC to 192.168.1.111 and start a TFTP server with the initramfs (Kernel) image I got from the OpenWrt Firmware Selector
- Enter U-boot. It helped me to save the output of
env print
for going back later. - Connect the ethernet cable to port 2 and set these env variables:
setenv ipaddr 192.168.1.11
setenv serverip 192.168.1.111
setenv ethact mvpp2-1
- Test connectivity with a ping to the tftp server. This should be successful:
ping 192.168.1.111
- Pull the intrarmafs image and boot to it using the qHora database:
tftpboot 0x6500000 openwrt-22.03.3-mvebu-cortexa72-iei_puzzle-m902-initramfs-kernel.bin
ext4load mmc 0:2 0x6000000 cn9132-db-A.dtb
booti 0x6500000 - 0x6000000
- Copy the openWRT images to a usb drive. You need linux to prepare the images to be copied. Since intrarmafs has no internet access, this needs to be done offline and copied to a usb drive. This is where I diverged a bit from the guide. I don't know why they copied the snapshot image, that gave me dependency nightmares. I found it best to use the stable release of openWRT. This is how I did it, assuming I mounted the usb drive to
/mnt/pendrive
. Another note on that though, I had to format the pendrive ext4. Formatting it as fat32 caused complaints when trying to mount it on the qHora:
- In my raspberry pi:
wget https://downloads.openwrt.org/releases/22.03.3/targets/mvebu/cortexa72/openwrt-22.03.3-mvebu-cortexa72-iei_puzzle-m902-squashfs-sdcard.img.gz
gzip -d openwrt-22.03.3-mvebu-cortexa72-iei_puzzle-m902-squashfs-sdcard.img.gz
# the warning about extra data that was ignored is fine. This is the metadata used to install the image during sysupdate or LuCI
newloop=$(losetup -f)
sudo losetup -P $newloop openwrt-22.03.3-mvebu-cortexa72-iei_puzzle-m902-squashfs-sdcard.img
# The complaint about the discard of the 512 bytes at the end was fine too. I ignored it and I was fine.
sudo dd if=${newloop}p1 of=/mnt/pendrive/0.img
sudo dd if=${newloop}p2 of=/mnt/pendrive/1.img
sudo losetup -d $newloop
- Back in the qHora322, insert the usb drive in the port and mount it:
- Copy 0.img to partition 1 and 1.img to partition 3. Leave other partitions alone so you can go back if needed. Both results have to display same number of records in and out.
dd if=/mnt/pendrive/0.img of=/dev/mmcblk0p1
dd if=/mnt/pendrive/1.img of=/dev/mmcblk0p3
- Reboot and go back to U-boot interrupting the startup sequence. Then set the new
bootcmd
, change thecurrent_entry
and save:
setenv bootcmd 'ext4load mmc 0:1 0x6500000 Image; ext4load mmc 0:1 0x6000000 cn9132-puzzle-m902.dtb; setenv bootargs $console cpuidle.off=1 root=/dev/mmcblk0p3; booti 0x6500000 - 0x6000000'
setenv current_entry 0
saveenv
- Reboot once more and profit! you are in openWRT
Stock reinstall
Going back to stock is a bit of a reverse procedure of the above. It is useful if you stored the envs before installation. The important one is bootcmd.
This was helpful to decrypt the QNAP image. The passkey is indeed the first 9 characters of the filename:
- Back to the raspberry pi:
# Download the firmware from QNAP
wget https://download.qnap.com/Storage/Networking/QHora-322/FW/production/QHora-322_20230206-2.2.13.016.img
# Decrypt the file. It is a tar.gz
python3 qnap-qts-fw-cryptor.py d QHora-322 QHora-322_20230206-2.2.13.016.img QHora-322_20230206-2.2.13.016.img.tar.gz
# Extract the package
tar -xzvf QHora-322_20230206-2.2.13.016.img.tar.gz
# Copy Image and usr.squashfs to the usb drive
cp Image /mnt/pendrive/p1.img
cp usr.squashfs /mnt/pendrive/p3.img
- Interrupt boot sequence to get back to U-boot. You need to boot up initramfs but while you're here, set the boot variables back to the original values:
setenv bootcmd 'ext4load mmc 0:1 0x6500000 Image; ext4load mmc 0:1 0x6000000 cn9132-db-A.dtb; setenv bootargs $console cpuidle.off=1; booti 0x6500000 - 0x6000000'
setenv current_entry 0
saveenv
- Load back up initramfs
tftpboot 0x6500000 openwrt-22.03.3-mvebu-cortexa72-iei_puzzle-m902-initramfs-kernel.bin
ext4load mmc 0:2 0x6000000 cn9132-db-A.dtb
booti 0x6500000 - 0x6000000
- Re-mount the usb drive in the qHora and overwrite partition 1 and partition 3 with the QNAP firmware:
dd if=/mnt/pendrive/p1.img of=/dev/mmcblk0p1
dd if=/mnt/pendrive/p3.img of=/dev/mmcblk0p3
- Reboot and profit! you are back on the stock FW. I would do a full firmware upgrade using the stock GUI just to make sure everything gets re-created as expected.