Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ramips: RAVPower RP-WD03 updates, using OKLI loader, and other image improvements #3386

Closed
wants to merge 1 commit into from

Conversation

arrmo
Copy link
Contributor

@arrmo arrmo commented Sep 5, 2020

The RAVPower RP-WD03 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).
The implementation is based heavily off the HooToo HT-TM05, as the hardware
is almost identical (except for RAM size), and is from the same vendor (SunValley).
Given the hardware commonalities, the RAVPower RP-WD03 and HooToo HT-TM05 common
elements in the dts files are also combined in a shared dtsi file.

Specifications:

SOC: MediaTek MT7620N
BATTERY: 6700mAh
WLAN: 802.11bgn
LAN: 1x 10/100 Mbps Ethernet
USB: 1x USB 2.0 (Type-A)
RAM: 32 MB
FLASH: GigaDevice GD25Q64, Serial 8 MB Flash, clocked at 50 MHz
Flash itself specified to 80 MHz, but speed limited by mt7620 SPI
fast-read enabled (m25p)
LED: Status LED (blue after boot, green with WiFi traffic
4 leds to indicate power level of the battery (unable to control)
INPUT: Power, reset button

MAC assignment based on vendor firmware:

2.4 GHz *:b4 (factory 0x04)
LAN/label *:b4 (factory 0x28)
WAN *:b5 (factory 0x2e)

Tested and working:

  • Ethernet
  • 2.4 GHz WiFi (Correct MAC-address)
  • Installation from TFTP (recovery)
  • OpenWRT sysupgrade (Preserving and non-preserving), through the usual
    ways: command line and LuCI
  • LEDs (except as noted above)
  • Button (reset)
  • I2C, which is needed for reading battery charge status and level
  • U-Boot environment / variables (from U-Boot, and OpenWrt)

Installation:

  • Download the needed OpenWrt install files, place them in the root
    of a clean TFTP server running on your computer. Rename the files as,
    • openwrt-ramips-mt7620-ravpower_rp-wd03-squashfs-kernel.bin => kernel
    • openwrt-ramips-mt7620-ravpower_rp-wd03-squashfs-rootfs.bin => rootfs
  • Plug the router into your computer via Ethernet
  • Set your computer to use 10.10.10.254 as its IP address
  • With your router shut down, hold down the power button until the first
    white LED lights up.
  • Push and hold the reset button and release the power button. Continue
    holding the reset button for 30 seconds or until it begins searching
    for files on your TFTP server, whichever comes first.
  • The router (10.10.10.128) will look for your computer at 10.10.10.254
    and install the two files. Once it has finished installation, it will
    automatically reboot and start up OpenWrt.
  • Set your computer to use DHCP for its IP address

Notes:

  • U-Boot environment can be modified, u-boot-env is preserved on initial
    install or sysupgrade
  • mtd-concat functionality is included, to leave a "hole" for u-boot-env,
    combining the OEM kernel and rootfs partitions

I would like to thank @mpratt14 and @xabolcs for their help getting the
lzma loader to work!

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

@arrmo
Copy link
Contributor Author

arrmo commented Sep 5, 2020

@mpratt14 raised a question on this - is a single commit OK, or rather 2 ... correcting / aligning the device name first, then updating the device support.

FYI, to hopefully make this one easier to review, it's very closely aligned to the recently added HooToo HT-TM05.

Thanks!

@mpratt14
Copy link
Contributor

mpratt14 commented Sep 5, 2020

I guess the main reason for splitting into 2 commits is so that the DTSI is seen as a new file instead of a rename

Also maybe rename the commit / PR to "add lzma loader to..." since the device was already in the makefile?

SOC := mt7620n
IMAGE_SIZE := 6144k
DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-i2c-ralink
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this right after "DEVICE_MODEL" so that it's not seen as a line change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, done - thanks!

@@ -1,30 +1,16 @@
/dts-v1/;

// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an empty line between license comment and #include

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, done.

DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-i2c-ralink
DEVICE_VENDOR := RAVPower
DEVICE_MODEL := RP-WD03
LZMA_TEXT_START := 0x81800000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if LZMA_TEXT_START applies to both devices it should be in the common section

However I thought this was set recently as the default in master...so maybe just delete the line?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was linked in forum by @xabolcs

a40ddc2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ummm ... so leave this then? Thanks!

Copy link
Contributor

@mpratt14 mpratt14 Sep 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nah, its definitely the same value now as the default, so remove line
read the commit I relinked it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NP, done!

@xabolcs
Copy link
Contributor

xabolcs commented Sep 5, 2020

Commit (and PR) title is confusing, as this device is supported already by OpenWrt.

@@ -924,14 +915,16 @@ define Device/ralink_mt7620a-v22sg-evb
endef
TARGET_DEVICES += ralink_mt7620a-v22sg-evb

define Device/ravpower_wd03
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should touch this original recipe only when you touch the original .dts!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, not quite understanding this one 😞. It seemed like folks wanted it changed / corrected, to match the vendor name better?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xabolcs can you rephrase what you mean? This commit changes both recipe and DTS at same time, unless you mean something else...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mpratt14 I meant exactly that.

Somehow I saw that the HooToo dts was renamed to dtsi.

Copy link
Contributor

@mpratt14 mpratt14 Sep 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is a feature of git where if you have a deleted file and a new file but they are more than 50% similar it counts it as a renamed file instead

I mentioned earlier and in forum that this makes it hard to review and understand what this commit does in the future. Solution would be to do all the renaming in a separate commit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's OK to me to see one of the dts as a rename, but I missed the other here.
I was looking this PR through app.

@@ -953,6 +946,19 @@ define Device/sercomm_na930
endef
TARGET_DEVICES += sercomm_na930

define Device/sunvalley_loader_okli
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer sunvalley_filehub as recipe name, and would include SOC, IMAGE_SIZE and DEVICE_PACKAGES recipe variables too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL - I changed this because @mpratt14 preferred this name. Easy for me to change it back, just need folks to agree 🤣. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just let Adrian decide, I was following the pattern that he and I decided for my most recent PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, no issue at all - and agreed. Easy change, if needed. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And my points are to save as many lines as possible, because they differ only in memory size.

@xabolcs
Copy link
Contributor

xabolcs commented Sep 5, 2020

@adschm the context for this PR is the following.

This PR is for renewing support for the already supported "Ravpower WD03".

As you can see in the description ("The implementation is based heavily off the HooToo HT-TM05, as the hardware
is almost identical (except for RAM size), and is from the same vendor (SunValley).
") this RAVPower device shares the very same hardware as the recently added HooToo device.

The files for HooToo can be crossflashed to this RAVPower and it works as intended.

And while it shares the same hardware, it shares the same issues too:

  • 1.5M kernel size limit: it's unbootable since 2019 february (commit a7370b5). See forum for the details!
  • u-boot-env (mtd5, "params" in OEM firmware) partition in the middle of kernel and rootfs

(And there is a HT-TM02 too which also shares these issues)

Sure, this renewing could be done with DEVICE_ALT?_... like in commit 08f5cac, but I don't know how would it's bootlog look.

In this PR @arrmo tries to create shared recipes and dtsi like in PR #3235 or like in EnGenius 202 commits (6decbf3 and 22caf30).

@xabolcs
Copy link
Contributor

xabolcs commented Sep 5, 2020

Renaming the device (and it's compatible) from "Ravpower WD03" to "RAVPower RP-WD03" has the following purposes

  • to be in line with RAVPower RP-WD009 and HooToo HT-TM05
  • prevent upgrading from old image, as the partition change is a breaking change - the new u-boot-env is in the middle of the old firmware partition
  • initial flashing steps are a little bit different

@arrmo
Copy link
Contributor Author

arrmo commented Sep 5, 2020

Commit (and PR) title is confusing, as this device is supported already by OpenWrt.

Good point. Perhaps rename to something like update or improve (vs. add)?

@xabolcs
Copy link
Contributor

xabolcs commented Sep 7, 2020

Good point. Perhaps rename to something like update or improve (vs. add)?

The RP-WD03 images (both sysupgrade and factory) are broken by the 1.5 MByte kernel size limit.
I think this is the most important issue. I would start with this information. But one has to include in the title that there are more than OKLI loader in this commit!

If you have no clue about commit message, then try to get inspiration from below!

ramips: usage of OKLI loader and other improvements for RAVPower WD-03

One paragraph about the kernel size limitation.

The second important thing is the misplaced u-boot-env partition:
another paragraph about how u-boot is able to break OpenWrt with saveenv. It would be nice to inclue here: Fixes: 5ef79af4f80f ("ramips: add support for Ravpower WD03")

You could write a half paragraph about it's content, why does it have 0x4000 offset.
And of course one paragraph about saving the ~1.5 MB flash space between loader and the correctly placed u-boot-env.

Another paragraph about renaming the device: what does it buy us? Why does it worth it?

After those you could write a few paragraph about the similarity between TM05 and WD03: common recipe, dtsi and the modified installation steps.

@@ -0,0 +1,26 @@
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (and/or the dtsi) is a re-license, IMHO.

You have to ask all the contributors do they agree with the change!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no issue removing this, to keep it as it was before - but I was told that this was missed in some cases before (an error, it happens), and now it has to be included. So added it based on that.

But I get your point, no issue. Let me add the folks who it seems contributed to this file before (if I have it right!). Any concerns with this addition ... @adschm, @mans0n, @mwarning, @981213?

Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mwarning aye (although, I do not remember contributing here..)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought all files in the folder need license identifier, but DTSI does not have DTS tag, so DTS has both, DTSI only has license

Copy link
Contributor

@xabolcs xabolcs Sep 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grep for Signed-off-by: in the commit history!

Here is how GitHub sees them:

And here is git cli:

  • mt7620n_ravpower_wd03.dts
git log -- target/linux/ramips/dts/mt7620n_ravpower_wd03.dts | grep "Signed-off-by:" | sort | uniq
    Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
    Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
    Signed-off-by: Moritz Warning <moritzwarning@web.de>
    Signed-off-by: Sungbo Eo <mans0n@gorani.run>
  • WD03.dts
git log -- target/linux/ramips/dts/WD03.dts | grep "Signed-off-by:" | sort | uniq
    Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
    Signed-off-by: Alex Maclean <monkeh@monkeh.net>
    Signed-off-by: Christian Lamparter <chunkeey@gmail.com> [split up]
    Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
    Signed-off-by: Mathias Kresin <dev@kresin.me>
    Signed-off-by: Matthias Badaire <mbadaire@gmail.com>
    Signed-off-by: Petr Štetiar <ynezz@true.cz>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arrmo , yup, please keep the header and do the re-license work!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I get your point, no issue. Let me add the folks who it seems contributed to this file before (if I have it right!). Any concerns with this addition ... @adschm, @mans0n, @mwarning, @981213?

Acked-by: Adrian Schmutzler freifunk@adrianschmutzler.de

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, to understand - "re-license" work. Do you mean to get everyone on the lists above to approve this? Easier would be to remove it, go back the way it was 🤣.

@adschm
Copy link
Member

adschm commented Sep 8, 2020

I don't get the point here. Is this really adding a device or just altering an existing one?

@xabolcs
Copy link
Contributor

xabolcs commented Sep 8, 2020

@adschm see my comments above, two days ago!

This PR is for renewing support for the already supported "Ravpower WD03".

And yes, both the commit message and PR title is confusing, but @arrmo didn't update it yet.

@arrmo
Copy link
Contributor Author

arrmo commented Sep 8, 2020

Sorry! That's on me - have been tied up at work lately, haven't gotten back to this. I was thinking folks would want the full outline in the commit, like the HooToo (as this is aligning the two somewhat, given very similar HW). But this is an update, not new HW. Let me try to clarify.

Thanks!

@adschm
Copy link
Member

adschm commented Sep 8, 2020

well, if this is not adding a device, but changing it, you should group the changes into commits based on what they change (i.e. partitioning, introduction of a DTSI, ...)

@arrmo
Copy link
Contributor Author

arrmo commented Sep 8, 2020

OK, updated - sorry for the delay. I tried to add in the information that @xabolcs mentioned above, and overall clean up the commit message. Please do comment if you still see issues.

Thanks!

@mpratt14
Copy link
Contributor

mpratt14 commented Sep 9, 2020

@adschm There is 3 basic changes for this PR

  • rename to ravpower,rp-wd03
  • use okli-loader for ravpower
  • common DTSI for this and Hootoo tm05 (which was just merged before this PR)

so how many commits should there be? 1 or 2 or 3 or....

@arrmo btw rename the PR itself at the top right of the page (pencil button)

@xabolcs
Copy link
Contributor

xabolcs commented Sep 9, 2020

rename the PR itself at the top right of the page (pencil button)

👍

There is 3 basic changes for this PR ...

How about the following?

  • (re-license)
  • rename to ravpower,rp-wd03
  • everything else
    • copy all from hootoo,ht-tm05 to ravpower,rp-wd03: recipe, dts, everything we learned in commit 45a81f7
    • realize that hootoo,ht-tm05 and ravpower,rp-wd03 are 99% similar now: extract common stuff into generic recipe and dtsi

Last step can be split into two, if it helps.

@mpratt14
Copy link
Contributor

mpratt14 commented Sep 9, 2020

I don't see anything wrong with the license tag...

@adschm adschm added needs changes target/ramips pull request/issue for ramips target labels Sep 9, 2020
@adschm
Copy link
Member

adschm commented Sep 9, 2020

What's the reason for the introduction of the new loader here? I doesn't seem to be broken?

If you actually introduce the new loader, it makes sense to do the rename in the same commit or immediately afterwards, as that will prevent (probably broken) sysupgrade; however, the fact that this would break sysupgrade is actually a reason against introducing this change

@xabolcs
Copy link
Contributor

xabolcs commented Sep 9, 2020

What's the reason for the introduction of the new loader here?

Current kernel exceeds 1.5 MB, vendor u-boot is unable to boot, as it reads only 1.5 MB:

Bootlogs from forum:

## Booting image at 80500000 ...

   Image Name:   MIPS OpenWrt Linux-4.14.98
   Image Type:   MIPS Linux Kernel Image (lzma compressed)
   Data Size:    1577517 Bytes =  1.5 MB
   Load Address: 80000000
   Entry Point:  80000000
   Verifying Checksum
 ... Bad Data CRC
## Booting image at 80500000 ...

   Image Name:   MIPS OpenWrt Linux-4.14.98
   Image Type:   MIPS Linux Kernel Image (lzma compressed)
   Data Size:    1572417 Bytes =  1.5 MB
   Load Address: 80000000
   Entry Point:  80000000
   Verifying Checksum ... OK
   Uncompressing Kernel Image ... OK

No initrd

## Transferring control to Linux (at address 80000000) ...
## Giving linux memsize in MB, 32

Starting kernel ...

[    0.000000] Linux version 4.14.98 (user@686cf3994001) (gcc version 7.4.0 (OpenWrt GCC 7.4.0 r9310-ebcd5226cc)) #0 Mon Feb 11 20:18:48 2019
[    0.000000] Board has DDR1
[    0.000000] Analog PMU set to hw control
[    0.000000] Digital PMU set to hw control
[    0.000000] SoC Type: MediaTek MT7620N ver:2 eco:6
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019650 (MIPS 24KEc)
[    0.000000] MIPS: machine is Ravpower WD03

See my comment above!

@arrmo arrmo changed the title ramips: add support for RAVPower RP-WD03 ramips: RAVPower RP-WD03 updates, using OKLI loader, and other image improvements Sep 9, 2020
@arrmo
Copy link
Contributor Author

arrmo commented Sep 9, 2020

@arrmo btw rename the PR itself at the top right of the page (pencil button)

I had missed that - thanks!

@arrmo
Copy link
Contributor Author

arrmo commented Sep 9, 2020

FYI, to the comments above - I had reported in the forum (and others had as well) => the current build (from master, in OpenWrt downloads) doesn't work. It soft-bricks the device. This PR addresses that problem, and aligns with the HooToo as well (very similar HW). Thanks!

@adschm
Copy link
Member

adschm commented Sep 9, 2020

I've just disabled the device for buildbots. So, the remaining job seems to wrap this up properly into separate commits with adequate descriptions.

@arrmo
Copy link
Contributor Author

arrmo commented Sep 9, 2020

remaining job seems to wrap this up properly into separate commits with adequate descriptions.

That make sense - of course hits the area where I struggle the most, git-idiot (me!). 🤣

Thanks!

@adschm
Copy link
Member

adschm commented Sep 9, 2020

Well, you will need to learn it at some point if you want to continue contributing.

@mpratt14
Copy link
Contributor

mpratt14 commented Sep 9, 2020

@arrmo dont be afraid to mess it up because you can always delete your commit and pull it from this github branch to start over, or you can copy your branch the way it is now to a new branch with git checkout -b and checkout back to this one, and pull from the copy if you mess it up

@arrmo
Copy link
Contributor Author

arrmo commented Sep 9, 2020

Well, you will need to learn it at some point if you want to continue contributing.

Agreed! My challenge is when I split to multiple commits, then someone wants a change to a middle one - that's where I get messed up.

But that aside ... what split is desired here? Just trying to understand before starting over 😄.

Thanks!

@adschm
Copy link
Member

adschm commented Sep 9, 2020

Agreed! My challenge is when I split to multiple commits, then someone wants a change to a middle one - that's where I get messed up.

The key is "git rebase --interactive ..."

But that aside ... what split is desired here? Just trying to understand before starting over .

Sometimes I have the feeling that you don't actually read what we are posting here. There are at least two comments above that quite explicitly state what to do. That BTW was also the reason of the enormous number of comments on the Hootoo commit. If you just had read the stuff carefully, we would have finished much quicker and without the pain of explaining everything three times.
So, please read the existing comments another time before just posting a question about something already answered beforehand. And please read them carefully ...

@arrmo
Copy link
Contributor Author

arrmo commented Sep 9, 2020

So, please read the existing comments another time before just posting a question about something already answered beforehand. And please read them carefully ...

I actually do read them very carefully, it's unfortunate that you think I don't. I admit, a lot of my confusion comes from different answers from different folks - and I admit, then I'm not sure what the right answer is (and what to do). Sorry if I'm not following the internal discussion fully, but I really am reading it (and trying to digest). I even had some above where I made a change to address specific comments from one person, only to have another want it done differently.

Even above I see different thoughts on the split, so now I'm stuck - different opinions, no idea which one is right 😞.

Thanks.

@adschm
Copy link
Member

adschm commented Sep 9, 2020

So, please read the existing comments another time before just posting a question about something already answered beforehand. And please read them carefully ...

I actually do read them very carefully, it's unfortunate that you think I don't. I admit, a lot of my confusion comes from different answers from different folks - and I admit, then I'm not sure what the right answer is (and what to do). Sorry if I'm not following the internal discussion fully, but I really am reading it (and trying to digest). I even had some above where I made a change to address specific comments from one person, only to have another want it done differently.

Even above I see different thoughts on the split, so now I'm stuck - different opinions, no idea which one is right .

So, you have to decide for one of the following options:

  1. Choose who you believe "more".
  2. Think for yourself what would be an appropriate concept and presentation of the changes you want to propose.

Apart from that, I don't really see a difference between the comments on the commit splitting conceptually.

@arrmo
Copy link
Contributor Author

arrmo commented Sep 9, 2020

LOL - yes, agreed ... I have struggled with 1, I admit. I'll roll with 2, take my best guess. Won't keep everyone happy, which will mean a few comments I'm guessing. But will deal with it - trying to do the right thing here (my device is blown as part of the assembly / disassembly / debug, so this is to help others out, not me).

Thanks.

…improvements

The RAVPower RP-WD03 is a battery powered router, with an Ethernet and USB port.
Due due a limitation in the vendor supplied U-Boot bootloader, we cannot exceed
a 1.5 MB kernel size, as is the case with recent releases (i.e. post v19.07). This
breaks both factory and sysupgrade images. To address this, the updates here include
usage of the lzma loader (loader-okli) - to work around this limitation.

The improvements here also address the "misplaced" U-Boot environment partition,
which is located between the kernel and rootfs in the stock image / implementation.
This is addressed by making use of mtd-concat, to "piece together" sections of flash,
maximizing space available in the booted image.

Hardware support here is based heavily off the HooToo HT-TM05, as the hardware
is almost identical (except for RAM size), and is from the same vendor (SunValley).
Given the hardware commonalities, the RAVPower RP-WD03 and HooToo HT-TM05 common
elements in the dts files are also combined in a shared dtsi file.

Specifications:

  SOC:     MediaTek MT7620N
  BATTERY: 6700mAh
  WLAN:    802.11bgn
  LAN:     1x 10/100 Mbps Ethernet
  USB:     1x USB 2.0 (Type-A)
  RAM:     32 MB
  FLASH:   GigaDevice GD25Q64, Serial 8 MB Flash, clocked at 50 MHz
           Flash itself specified to 80 MHz, but speed limited by mt7620 SPI
           fast-read enabled (m25p)
  LED:     Status LED (blue after boot, green with WiFi traffic
           4 leds to indicate power level of the battery (unable to control)
  INPUT:   Power, reset button

MAC assignment based on vendor firmware:

  2.4 GHz    *:b4   (factory 0x04)
  LAN/label  *:b4   (factory 0x28)
  WAN        *:b5   (factory 0x2e)

Tested and working:

 - Ethernet
 - 2.4 GHz WiFi (Correct MAC-address)
 - Installation from TFTP (recovery)
 - OpenWRT sysupgrade (Preserving and non-preserving), through the usual
   ways: command line and LuCI
 - LEDs (except as noted above)
 - Button (reset)
 - I2C, which is needed for reading battery charge status and level
 - U-Boot environment / variables (from U-Boot, and OpenWrt)

Installation:

 - Download the needed OpenWrt install files, place them in the root
   of a clean TFTP server running on your computer. Rename the files as,
   - openwrt-ramips-mt7620-ravpower_rp-wd03-squashfs-kernel.bin => kernel
   - openwrt-ramips-mt7620-ravpower_rp-wd03-squashfs-rootfs.bin => rootfs
 - Plug the router into your computer via Ethernet
 - Set your computer to use 10.10.10.254 as its IP address
 - With your router shut down, hold down the power button until the first
   white LED lights up.
 - Push and hold the reset button and release the power button. Continue
   holding the reset button for 30 seconds or until it begins searching
   for files on your TFTP server, whichever comes first.
 - The router (10.10.10.128) will look for your computer at 10.10.10.254
   and install the two files. Once it has finished installation, it will
   automatically reboot and start up OpenWrt.
 - Set your computer to use DHCP for its IP address

Notes:

 - U-Boot environment can be modified, u-boot-env is preserved on initial
   install or sysupgrade
 - mtd-concat functionality is included, to leave a "hole" for u-boot-env,
   combining the OEM kernel and rootfs partitions

I would like to thank @mpratt14 and @xabolcs for their help getting the
lzma loader to work!

Signed-off-by: Russell Morris <rmorris@rkmorris.us>
@adschm
Copy link
Member

adschm commented Sep 11, 2020

Since I think it will be more efficient after all I have separated the changes and wrapped them up properly myself. The result can be found here: https://git.openwrt.org/?p=openwrt/staging/adrian.git;a=shortlog;h=refs/heads/ravpower

Please critically and thoroughly review and finally test.

A few questions that popped up:

  • Is the old ethernet MAC address really just a copy-paste mistake (factory 0x4000)? What's found in that location?
  • As I understand it, all existing OpenWrt installations will have overwritten ubootenv. Is that a problem?

@xabolcs
Copy link
Contributor

xabolcs commented Sep 11, 2020

Please critically and thoroughly review and finally test.

It looks good at first sight! Thank you for wrapping up!

For the second commit it would be nice to add Fixes: 5ef79af4f80f ("ramips: add support for Ravpower WD03") as the partition is wrong since the beginning.

  • As I understand it, all existing OpenWrt installations will have overwritten ubootenv. Is that a problem?

I don't know how OpenWrt could initialize it or it is a problem at all. I hope @arrmo could test it.

But the u-boot is with saveenv is able to create a correct content from nowhere. See discussion in the HooToo PR for the details!

@adschm
Copy link
Member

adschm commented Sep 11, 2020

For the second commit it would be nice to add Fixes: 5ef79af ("ramips: add support for Ravpower WD03") as the partition is wrong since the beginning.

You are specifically referring to overwritten uboot-env and mislabelled config here?

@adschm adschm self-assigned this Sep 11, 2020
@xabolcs
Copy link
Contributor

xabolcs commented Sep 11, 2020

You are specifically referring to overwritten uboot-env and mislabelled config here?

Exactly.

From Device page:

dev:    size   ​erasesize ​ name
mtd0: 00800000 00010000 "​ALL"​
mtd1: 00030000 00010000 "​Bootloader"​
mtd2: 00010000 00010000 "​Config"​ <--- some ralink specific stuff, that was orignially tought as "u-boot-env"
mtd3: 00010000 00010000 "​Factory"​
mtd4: 00180000 00010000 "​Kernel_RootFS"​
mtd5: 00010000 00010000 "​params"​ <--- u-boot environment, that was in the middle of the old "firmware" partition
mtd6: 00010000 00010000 "​user_backup"​
mtd7: 00010000 00010000 "​user"​
mtd8: 00600000 00010000 "​Rootfs"​

More details in the discussion!

@arrmo
Copy link
Contributor Author

arrmo commented Sep 11, 2020

Since I think it will be more efficient after all I have separated the changes and wrapped them up properly myself.

Thanks very much! I was working on this in parallel, but obviously much slower at it. And this does help me understand how you like to see these, learning for the future.

Please critically and thoroughly review and finally test.

Absolutely! FYI, I pulled down your ravpower branch, built it (all fine) ... but 1 issue noted so far => serial port speed is not right (which I can sort of work around). I did check, and it's correct in mt7620n.dtsi ... huh?!?! Will dig here, seems very odd. But re-confirmed, part way through boot it changes from 57600 (u-boot, startup), to 115200.

Thanks again!

@arrmo
Copy link
Contributor Author

arrmo commented Sep 11, 2020

BTW, if I can get the serial port working, I can capture serial port logs, just so folks have something to check over as well.

OK, from dmesg,
[ 0.000000] Kernel command line: console=ttyS0,115200 rootfstype=squashfs,jffs2

Not making sense to me yet. Hmmm.

@arrmo
Copy link
Contributor Author

arrmo commented Sep 11, 2020

Found it! It's also in target/linux/ramips/dts/mt7620n_ravpower_rp-wd03.dts => need to remove it there, agreed.

Thanks!

@arrmo
Copy link
Contributor Author

arrmo commented Sep 11, 2020

That minor update (remove console from ravpower dts), and then it all looks good to me ... boots, okli-loader found, mtd-concat in place. Other things you can think of to check?

And the serial log,
https://paste.ubuntu.com/p/95MCXWJfd9/

Thanks!

@adschm
Copy link
Member

adschm commented Sep 11, 2020

So, the console value added for rp-wd03 initially (here: 5ef79af) is wrong and needs to be changed to the default 57600 ...?

@arrmo
Copy link
Contributor Author

arrmo commented Sep 11, 2020

Correct! Just like HooToo, it just needs to be removed in the device level dts (i.e. WD03 file), and let it default to the top level mt7620n.dtsi. I tried it here, and it's correct (that's how I got the serial log above ... if not I start to get garbled data part way through the boot).

Make sense?

If it helps, here is what I changed locally (from your branch),

diff --git a/target/linux/ramips/dts/mt7620n_ravpower_rp-wd03.dts b/target/linux/ramips/dts/mt7620n_ravpower_rp-wd03.dts
index 4f19b8e6ea..305ac0bf20 100644
--- a/target/linux/ramips/dts/mt7620n_ravpower_rp-wd03.dts
+++ b/target/linux/ramips/dts/mt7620n_ravpower_rp-wd03.dts
@@ -13,10 +13,6 @@
                led-upgrade = &led_wifi_blue;
        };

-       chosen {
-               bootargs = "console=ttyS0,115200";
-       };
-
        leds {
                compatible = "gpio-leds";

@adschm
Copy link
Member

adschm commented Sep 11, 2020

And factory 0x4000 indeed does not contain a valid MAC address?

@arrmo
Copy link
Contributor Author

arrmo commented Sep 11, 2020

Correct - at least best I can tell 😆. The same as the HooToo, and here is a dump of the factory partition (rp-wd03),

root@travelRouter:/# hexdump -C /dev/mtd2ro
00000000  20 76 00 01 00 1c c2 30  c9 56 ff ff ff ff ff ff  | v.....0.V......|
00000010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00000020  ff ff ff ff ff ff ff ff  00 1c c2 30 c9 56 00 1c  |...........0.V..|
00000030  c2 30 c9 57 22 0c 20 00  ff ff b9 01 55 77 a8 aa  |.0.W". .....Uw..|
00000040  8c 88 ff ff 0a 00 00 00  00 00 00 00 00 00 ff ff  |................|
00000050  ff ff 0d 0c 0c 0b 0b 0a  0a 09 09 09 08 08 08 07  |................|
00000060  11 11 11 11 11 11 11 11  11 11 11 11 11 11 ff ff  |................|
00000070  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
*
000000d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff 00 00  |................|
000000e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
*
00010000

To make sure, I did a MAC lookup, and 00 1c c2 is in fact SunValley (Part II Research, Inc.). Nothing up at 0x4000, agreed?

@adschm
Copy link
Member

adschm commented Sep 11, 2020

Thanks, pushed to master. Specific thanks also to @mpratt14 @xabolcs for technical help and pre-review in this and many similar PRs, making my life much easier.

@adschm adschm closed this Sep 11, 2020
@arrmo
Copy link
Contributor Author

arrmo commented Sep 11, 2020

I couldn't agree more - thanks to all 3 of you, very much appreciated. And apologies for any grief I caused, a bit new to this, learning as I go.

@arrmo arrmo deleted the ravpower-rp-wd03 branch September 12, 2020 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs changes target/ramips pull request/issue for ramips target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants