RAVPower WD-03, Add LZMA Loader

OK, missed it before somehow, but the latest and greatest serial log shows,

[   47.843030] jffs2: notice: (449) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
[   47.875320] mount_root: overlay filesystem has not been fully initialized yet
[   47.894991] mount_root: switching to jffs2 overlay
[   47.934849] overlayfs: upper fs does not support tmpfile.
- config restore -

Life is good :laughing:

1 Like

Well, except for git that is :rofl:. Figured I'll rebased my ravpower branch to hootoo now, thought that made sense. Now I have a bunch of commits. Arrgh, git kills me!

$ git branch -v
* hootoo-tm05 f0bfa630c8 ramips: Add support for HooToo TM05
  master      0453c3866f vxlan: fix udp checksum control
$ git fetch arrmo
remote: Enumerating objects: 27, done.
remote: Counting objects: 100% (27/27), done.
remote: Total 31 (delta 26), reused 27 (delta 26), pack-reused 4
Unpacking objects: 100% (31/31), done.
From https://github.com/arrmo/openwrt
 + f0bfa630c8...8f23744452 hootoo-tm05   -> arrmo/hootoo-tm05  (forced update)
 * [new branch]            master        -> arrmo/master
 * [new branch]            openwrt-19.07 -> arrmo/openwrt-19.07
 * [new branch]            ravpower-wd03 -> arrmo/ravpower-wd03
$ git reset --hard arrmo/hootoo-tm05
HEAD is now at 8f23744452 ramips: Add support for HooToo TM05
$ git checkout ravpower-wd03
Previous HEAD position was 8f23744452 ramips: Add support for HooToo TM05
Switched to branch 'ravpower-wd03'
Your branch is up to date with 'arrmo/ravpower-wd03'.
$ git rebase hootoo-tm05
First, rewinding head to replay your work on top of it...
Applying: ramips: Add support for HooToo TM05
Using index info to reconstruct a base tree...
M       package/boot/uboot-envtools/files/ramips
M       target/linux/ramips/image/Makefile
M       target/linux/ramips/image/mt7620.mk
M       target/linux/ramips/mt7620/base-files/etc/board.d/02_network
M       target/linux/ramips/mt7620/config-4.14
M       target/linux/ramips/mt7620/config-5.4
Falling back to patching base and 3-way merge...
Auto-merging target/linux/ramips/image/mt7620.mk
CONFLICT (content): Merge conflict in target/linux/ramips/image/mt7620.mk
Auto-merging package/boot/uboot-envtools/files/ramips
error: Failed to merge in the changes.
Patch failed at 0001 ramips: Add support for HooToo TM05
hint: Use 'git am --show-current-patch' to see the failed patch

Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".

Here would happen the magic: you had to skip the old, superseded HooToo commit! :wink:

$ git rebase --skip
Applying: ramips: Add support for RAVPower WD03
$ git log
commit 45566406e0aebbbfec99bd492e12867f1ca45f89 (HEAD)
Author: Russell Morris <rmorris@rkmorris.us>
Date:   Tue Jul 14 21:23:53 2020 -0500

    ramips: Add support for RAVPower WD03

    Signed-off-by: Russell Morris <rmorris@rkmorris.us>

commit 8f237444520a795dba410c830ec42d315f39811e (arrmo/hootoo-tm05, hootoo-tm05)
Author: Russell Morris <rmorris@rkmorris.us>
Date:   Tue Dec 24 18:38:36 2019 -0600

    ramips: Add support for HooToo TM05

    The HooToo TM05 is a battery powered router, with an Ethernet and USB port.
    Vendor U-Boot limited to 1.5 MB kernel size, so use lzma loader (loader-okli).
    MAC assignment based on vendor firmware,
    2.4 GHz, *:b4 (factory 0x04)
    LAN/label, *:b4 (factory 0x28)
    WAN, *:b5 (factory 0x2e)

    Specifications:
    SOC:     MediaTek MT7620N
    .
    .
    .
1 Like

Thanks! Will dig into this. Right now, fighting to get the RAVPower flashed. Seems I don't have a flash file from the vendor ... only HooToo, and that doesn't seem to be happy for some reason? I have the fw file from the vendor => not sure how to extract the flash from it :frowning_face:.

Try this: https://github.com/theodric/HooToo_HT-TM05-hacking-doubleplusgood/blob/master/bin/Download-and-split.sh

I think it should work for RavPower too. Just examine the second part of the script!

1 Like

Will do, thanks! I can see the elements (bootloader, kernel, rootfs) inside the archive file, just need to turn those into a flash image somehow ... LOL.

Flash Layout is:

dev:    size   ​erasesize ​ name
mtd0: 00800000 00010000 "​ALL"​
mtd1: 00030000 00010000 "​Bootloader"​
mtd2: 00010000 00010000 "​Config"​
mtd3: 00010000 00010000 "​Factory"​
mtd4: 00180000 00010000 "​Kernel_RootFS"​
mtd5: 00010000 00010000 "​params"​
mtd6: 00010000 00010000 "​user_backup"​
mtd7: 00010000 00010000 "​user"​
mtd8: 00600000 00010000 "​Rootfs"​

Config and Factory is lost, so your calibration data and MAC address is gone.
You had to find the device's MAC address on it's box or on itself.

man dd will help you! :slight_smile:

The easiest way is to replace the bootloader in the HooToo's ALL.bin and program it to RavPower, IMHO.

Funny, again we're thinking alike! Did that ... but no joy. Wondering now, do I need to "zero out" (0xFF) the unused portion of that 192kB. Hmmm. Will try that, as dd built me the file, flashed it, but still won't boot (i.e. no serial output at all).

Bootloader can be flashed by itself...and at the very least you would get serial output telling you why boot has stopped

It's possible that even though the two boards are almost the same that the bootloaders don't match

Agreed! Struggling to get the layout file working (with flashrom), so I can do just what you say - program only the bootloader.

Thanks!

Pulling my hair out again ... :rofl:. OK, flashrom is a bit of a PITA - even to program a section, you have to have a full sized file. NP, here is what I did - yell if you see anything wrong!

dd if=/dev/zero bs=8M count=1 | tr "\000" "\377" > u-boot.full.bin
hexdump -C u-boot.full.bin
   => yep, file is 8M, all 0xFF
dd if=u-boot.bin of=u-boot.full.bin conv=notrunc
   => bootloader at the start of the file
flashrom -l rom.layout -i u-boot -w u-boot.full.bin -p linux_spi:dev=/dev/spidev0.0,spispeed=2000

So this has only the bootloader, but won't boot ... no serial, no LED's (normal sequence I mean), no ethernet. Wondering if it needs the u-boot-env or config perhaps?

So tried replacing u-boot (only) in the HooToo image => still no joy (and no serial, no LED's like expected, no ethernet). Dang it! And no luck finding a flash image for the RAVPower (like I have for the HooToo).

Thanks!

@badzz, could you help out @arrmo with a full backup of WD-03?

1 Like

Yes, would appreciate if someone has the flash / backup file. Thanks!!!

FYI, I did email the vendor, but I know how that goes :rofl:

@arrmo I don't want to be "that guy" but I am anyway

do a full backup of flash for every device you work on. It can be done through LuCI on an initramfs.bin. I've done it over serial and TFTP on OEM image too.

BTW if you hate flashrom yet, feel free to install Adafruit Blinka and try my scripts. It should be an easy edit to get it working on RPi

2 Likes

LMAO! Too funny. And no worries, I take it the right way - 100% agree with you, very valid comments ... and lesson learned :stuck_out_tongue_winking_eye: . Thanks!

Sorry, I was thinking this was for Arduino - I misunderstood your earlier comment. Will check it out!

OK, the RAVPower is back up and running ... sort of :wink:. I stumbled on to it, but it seems that during that "large" erase, something got broken. If I leave the flash programmer connected, then it will boot. It seems to me like the power supply went, and that gets provided by the flash programmer. So a bit of a fragile setup, but I will try to continue now. And FYI, the bootloader does seem to have a (subtle?) difference ... the address in the rows below is different in the two cases,

Board: Ralink APSoC DRAM:  32 MB
relocate_code Pointer at: 81fac000

Thanks!

Well, I can sort of get back up ... booting from initramfs, it comes up - but no mtd partitions. Is there a way to restore them? Or DOA?

Thanks!

If you have some backup then you could flash it! Bootloader is there. How about Config and Factory OEM partitions? In case you don't have a WD-03 backup, then you could try from your HooToo TM-05 backup!

Did you try flashing kernel.bin and rootfs.bin through TFTP recovery from your PR?

Yep, exactly what I did! HooToo flash (from the vendor), and then replaced the bootloader. No joy, lots of errors (trying to boot OEM), like the following,

[   19.576000] SQUASHFS error: Unable to read data cache entry [1c6b18]
[   19.588000] SQUASHFS error: Unable to read page, block 1c6b18, size 9ae8
[   19.604000] SQUASHFS error: Unable to read data cache entry [1c6b18]
[   19.616000] SQUASHFS error: Unable to read page, block 1c6b18, size 9ae8

Yep, that was my next step - we're on the same page! LOL. But getting,

[    0.736420] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[    0.751398] Please append a correct "root=" boot option; here are the available partitions:
[    0.768050] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[    0.785388] Rebooting in 1 seconds..

And if I boot from initramfs, /proc/mtd is completely empty :frowning_face:

Crazy!

OK, I was wrong - it's the WP pin that I have to pull high, then the unit will boot. Huh?!?! Still messed up flash overall though.