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: Add support for HiWiFi HC5962 #865

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
6 participants
@gigibox
Contributor

gigibox commented Feb 22, 2017

This patch adds supports for the HiWiFi HC5962(gee4) http://www.hiwifi.com

Short specification:

  • MT7621AT + MT7612EN + 7603EN
  • 256MB DDR3 RAM
  • 128MB NAND flash
  • 1+3 x 1000M Ethernet
  • 1x USB 2.0 port. 1x USB 3.0 port
  • UART pad on PCB (JP3: TX, RX, GND, 3.3V)

Flash instruction:

  1. Download lede-ramips-mt7621-hc5962-squashfs-factory.bin
  2. Login as root via SSH on 192.168.199.1 and then copy factory.bin(using wget or nc or...) to /tmp/
  3. use the following commands:
    $ mtd write /tmp/lede-ramips-mt7621-hc5962-squashfs-factory.bin firmware
    $ mtd erase firmware_backup && reboot
    After reboot you should be able to login as root via SSH on 192.168.1.1

Signed-off-by: ZengFei Zhang zhangzengfei@kunteng.org

@liudf0716

This comment has been minimized.

liudf0716 commented Feb 22, 2017

good job

@pepe2k

Hello @gigibox,

Thank you for your contribution, please find my comments below.

Please, include also some short description about the device you are adding support for and how to flash LEDE image on it, inside the commit message. You can find many different examples in commit history.

Cheers,
Piotr

@@ -199,6 +199,10 @@ hc5861)
ucidef_set_led_netdev "wifi5g" "wifi5g" "$board:blue:wlan5g" "rai0"
ucidef_set_led_default "turbo" "turbo" "$board:blue:turbo" "0"
;;
hc5962)
ucidef_set_led_default "system" "system" "$board:red:system" "1"
ucidef_set_led_timer "status" "status" "$board:white:status" "1000" "1000"

This comment has been minimized.

@pepe2k

pepe2k Feb 22, 2017

Member

This will be misleading for the user as this LED is already set for status in diag.sh. Please, drop this line.

@@ -102,6 +102,7 @@ ramips_setup_interfaces()
wt1520|\
y1|\
youku-yk1|\
hc5962|\

This comment has been minimized.

@pepe2k

pepe2k Feb 22, 2017

Member

Please, keep boards in alphabetical order here.

@@ -248,6 +248,9 @@ get_status_led() {
zbt-cpe102)
status_led="$board:green:4g-0"
;;
hc5962)

This comment has been minimized.

@pepe2k

pepe2k Feb 22, 2017

Member

Please, keep boards in alphabetical order here.

@@ -343,6 +344,7 @@ ramips_setup_macs()
e1700)
wan_mac=$(mtd_get_mac_ascii config WAN_MAC_ADDR)
;;
hc5962|\

This comment has been minimized.

@pepe2k

pepe2k Feb 22, 2017

Member

Please, keep boards in alphabetical order here (hc5*61 should be first).

gpio-leds {
compatible = "gpio-leds";
status-white {

This comment has been minimized.

@pepe2k

pepe2k Feb 22, 2017

Member

Please, use only status here.

label = "opt";
reg = <0x54c0000 0x2ac0000>;
};

This comment has been minimized.

@pepe2k

pepe2k Feb 22, 2017

Member

Remove this new line, please.

@@ -221,6 +221,20 @@ define Device/zbt-wg3526
endef
TARGET_DEVICES += zbt-wg3526
define Device/hc5962

This comment has been minimized.

@pepe2k

pepe2k Feb 22, 2017

Member

Please, keep all boards in alphabetical order here.

define Device/hc5962
DTS := HC5962
BLOCKSIZE := 128KiB
# IMAGES := sysupgrade.bin

This comment has been minimized.

@pepe2k

pepe2k Feb 22, 2017

Member

Drop this line, please.

# IMAGES := sysupgrade.bin
PAGESIZE := 2048
KERNEL_SIZE := 2097152
# FILESYSTEMS := squashfs

This comment has been minimized.

@pepe2k

pepe2k Feb 22, 2017

Member

Drop this line, please.

@@ -221,6 +221,20 @@ define Device/zbt-wg3526
endef
TARGET_DEVICES += zbt-wg3526
define Device/hc5962
DTS := HC5962
BLOCKSIZE := 128KiB

This comment has been minimized.

@pepe2k

pepe2k Feb 22, 2017

Member

KiB is a wrong unit here.

@mkresin

Please use git commit --amend to add changes to your commit. Use git push --force to overwrite your github repository/branch. The PR will afterwards update automatically.

@@ -199,6 +199,10 @@ hc5861)
ucidef_set_led_netdev "wifi5g" "wifi5g" "$board:blue:wlan5g" "rai0"
ucidef_set_led_default "turbo" "turbo" "$board:blue:turbo" "0"
;;
hc5962)
ucidef_set_led_default "system" "system" "$board:red:system" "1"

This comment has been minimized.

@mkresin

mkresin Feb 22, 2017

Contributor

Any specific reason why you switch the LED to on here? If not, drop it.

#include "mt7621.dtsi"
#include <dt-bindings/input/input.h>

This comment has been minimized.

@mkresin

mkresin Feb 22, 2017

Contributor

Please include <dt-bindings/gpio/gpio.h> here as well and keep alphabetical order..

Use the GPIO_ACTIVE_LOW and GPIO_ACTIVE_HIGH macros afterwards in stead of 1 and 0 in the gpio parameters.

Check the recent ramips board additions for examples.

reg = <0x0 0x10000000>;
};
palmbus@1E000000 {

This comment has been minimized.

@mkresin

mkresin Feb 22, 2017

Contributor

Drop this node. the spi node is disabled by default in mt7621.dtsi.

read-only;
};
firmware {

This comment has been minimized.

@mkresin

mkresin Feb 22, 2017

Contributor

Something is wrong here. The firmware and the kernel partition are having the same start address. Drop the firmware partition, you are having already the ubi partition.

KERNEL_SIZE := 2097152
# FILESYSTEMS := squashfs
UBINIZE_OPTS := -E 5
IMAGE/sysupgrade.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | check-size $$$$(ralink_default_fw_size_32M)

This comment has been minimized.

@mkresin

mkresin Feb 22, 2017

Contributor

Drop this line and add the following instead:

IMAGE_SIZE := $(ralink_default_fw_size_32M)
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata

That should create the correct image format for sysupgrade.

If the sysupgrade.bin you created is intended for the first installation of LEDE (maybe via bootloader) use the following:

IMAGE_SIZE := $(ralink_default_fw_size_32M)
IMAGES += factory.bin
IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | check-size $$$$(IMAGE_SIZE)

Edit:

You need to add your board to the platform_pre_upgrade() function in target/linux/ramips/base-files/lib/upgrade/platform.sh to actually do the nand specific update.

This comment has been minimized.

@gigibox

gigibox Feb 23, 2017

Contributor

all corrected.Thanks for you help!

UBINIZE_OPTS := -E 5
IMAGE/sysupgrade.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | check-size $$$$(ralink_default_fw_size_32M)
DEVICE_TITLE := HiWiFi HC5962
DEVICE_PACKAGES := kmod-usb3 kmod-usb-ledtrig-usbport kmod-mt76

This comment has been minimized.

@heinzek

heinzek Feb 22, 2017

Contributor

You add "kmod-usb-ledtrig-usbport" module, but you not defined any led as usbport.

chosen {
bootargs = "console=ttyS0,115200";
};

This comment has been minimized.

@heinzek

heinzek Feb 22, 2017

Contributor

Here is unnecessary tab.

label = "hc5962:white:status";
gpios = <&gpio0 6 0>;
};

This comment has been minimized.

@heinzek

heinzek Feb 22, 2017

Contributor

Here is unnecessary tab.

};
};
};

This comment has been minimized.

@heinzek

heinzek Feb 22, 2017

Contributor

Unnecessary tab.

label = "ubi";
reg = <0x340000 0x1E00000>;
};

This comment has been minimized.

@heinzek

heinzek Feb 22, 2017

Contributor

Unnecessary tab.

label = "hw_panic";
reg = <0x2140000 0x80000>;
};

This comment has been minimized.

@heinzek

heinzek Feb 22, 2017

Contributor

Unnecessary tab.

label = "backup";
reg = <0x2240000 0x80000>;
};

This comment has been minimized.

@heinzek

heinzek Feb 22, 2017

Contributor

Unnecessary tab.

label = "overly";
reg = <0x22c0000 0x1000000>;
};

This comment has been minimized.

@heinzek

heinzek Feb 22, 2017

Contributor

Unnecessary tab.

label = "oem";
reg = <0x52c0000 0x200000>;
};

This comment has been minimized.

@heinzek

heinzek Feb 22, 2017

Contributor

Unnecessary tab.

This comment has been minimized.

@gigibox

gigibox Feb 23, 2017

Contributor

thanks!

@liudf0716

This comment has been minimized.

liudf0716 commented Feb 23, 2017

good advice

@gigibox

This comment has been minimized.

Contributor

gigibox commented Feb 23, 2017

Thanks a lot for the review and comments. ^^

@mkresin

Please add a comment with a serial log which shows:

  • the boot of the OEM firmware
  • the switch to LEDE from the OEM software
  • the LEDE boot
  • sysupgrade lede-ramips-mt7621-hc5962-sysupgrade.bin

This way we can ensure that at least the basic stuff is tested.

@@ -259,7 +260,8 @@ platform_pre_upgrade() {
local board=$(ramips_board_name)
case "$board" in
ubnt-erx)

This comment has been minimized.

@mkresin

mkresin Feb 23, 2017

Contributor

Please restore the former indentation!

@@ -62,6 +62,7 @@ platform_check_image() {
gl-mt300n|\
gl-mt750|\
hc5*61|\
hc5962|\

This comment has been minimized.

@mkresin

mkresin Feb 23, 2017

Contributor

I'm quite sure the sysupgrade will fail at this point since your sysupgrade image doesn't start with the uImage magic 0x27051956.

The whole image header validation isn't required for the hc5962 since a validation based on the metadata will be done. Please add a new block for the hc5962 containing:

hc5962)
	# these boards use metadata images
	return 0
	;;
@@ -199,6 +199,9 @@ hc5861)
ucidef_set_led_netdev "wifi5g" "wifi5g" "$board:blue:wlan5g" "rai0"
ucidef_set_led_default "turbo" "turbo" "$board:blue:turbo" "0"
;;
hc5962)
ucidef_set_led_timer "status" "status" "$board:white:status" "1000" "1000"

This comment has been minimized.

@mkresin

mkresin Feb 23, 2017

Contributor

What is the purpose of this blinking LED? I guess this can be removed, right?

This comment has been minimized.

@gigibox

gigibox Feb 24, 2017

Contributor

Hi.
This device has only one indicator light, So, After the system starts, I hope the Indicator blink white to show system normal operation.
Image of Yaktocat

This comment has been minimized.

@pepe2k

pepe2k Feb 24, 2017

Member

But you are already using status_led in /etc/diag.sh for this. Default behavior of status_led is to blink during system boot up process and stay on when system is booted.

This comment has been minimized.

@gigibox

gigibox Feb 24, 2017

Contributor

It works like this:
hc5962-led-status2

This comment has been minimized.

@liudf0716

liudf0716 Feb 24, 2017

when system boot, its red light blink, after booted, become white light blink.

This comment has been minimized.

@pepe2k

pepe2k Feb 24, 2017

Member

Please, use then only the white LED for status_led in /etc/diag.sh instead of the red one and don't add anything else in /etc/board.d/01_leds. Using red LED could be misleading as this color is usually used to indicate some error and/or problem.

We have a common/general approach over whole code, for all targets, for status LED and there is no need to reproduce vendor firmware approach here.

Thanks!

This comment has been minimized.

@gigibox

gigibox Feb 24, 2017

Contributor

Nice. Thanks! That explains a lot! I'll do that.

reg = <0x54c0000 0x2ac0000>;
};
partition@140000 {

This comment has been minimized.

@mkresin

mkresin Feb 23, 2017

Contributor

drop this partition. it has still the same start address on flash (0x140000) as the kernel partition. For NAND board you don't need a firmware partition.

This comment has been minimized.

@gigibox

gigibox Feb 26, 2017

Contributor

Sorry, I just found it submission failed, is now complete.

reg = <0x340000 0x1E00000>;
};
partition@2140000 {

This comment has been minimized.

@mkresin

mkresin Feb 23, 2017

Contributor

If this partition is required to revert to the OEM firmware, mark the partition as read-only. If this partition is not required, drop the node and use the extra space for the ubi partition.

@gigibox

This comment has been minimized.

@mkresin

This comment has been minimized.

Contributor

mkresin commented Feb 26, 2017

With your latest changes you broke the sysupgrade again. Have you tested the sysupgrade with your latest changes?

You dropped the following requested changes with your last push:

It is not necessary to do the nand_do_platform_check for the hc5962, since the validation is done via metadata.

It was fine the way it was before your last change. You have just added to much in indentation.

@gigibox

This comment has been minimized.

Contributor

gigibox commented Feb 27, 2017

@mkresin Please forgive my ignorance. I have changed it as you suggested and has been tested. Thank you again for you time on this matter.

hc5962-lede-test-sysupgrade.txt

@pepe2k

pepe2k approved these changes Feb 27, 2017

@mkresin

This comment has been minimized.

Contributor

mkresin commented Feb 27, 2017

Look really good to me. One last remark.

In the ethernet node of the DTS you read the mac address as hex values from the factory partition. But later in the boot process you replace this mac address with the ASCII values read from the bdinfo partition (target/linux/ramips/base-files/etc/board.d/02_network). Either of them seam to be wrong to me. Any explanation for this?

In your bootlog the following can be seen:

[   10.100000] mt76x2e 0000:02:00.0: ASIC revision: 76120044
[   10.100000] mt76x2e 0000:02:00.0: EEPROM data check failed: 7603
[   10.110000] mt76x2e 0000:02:00.0: Invalid MAC address, using random address 7e:dd:3f:8b:49:e8
[   10.130000] mt76x2e 0000:02:00.0: ROM patch already applied
[   10.130000] mt76x2e 0000:02:00.0: Firmware Version: 0.0.00
[   10.140000] mt76x2e 0000:02:00.0: Build: 1
[   10.140000] mt76x2e 0000:02:00.0: Build Time: 201507311614____
[   10.170000] mt76x2e 0000:02:00.0: Firmware running!
[   10.180000] mt7603e 0000:01:00.0: ASIC revision: 76030010
[   12.260000] mt7603e 0000:01:00.0: Firmware Version: _mt7603mp
[   12.270000] mt7603e 0000:01:00.0: Build Time: 20151020155902

Not sure about this, but could it be that something is wrong with the EEPROM of the mt76@1,0 (0000:02:00.0) wireless? Maybe you have defined the wrong position on flash?

ramips: Add support for HiWiFi HC5962
This patch adds supports for the HiWiFi HC5962(gee4) http://www.hiwifi.com

Short specification:

 - MT7621AT + MT7612EN + 7603EN
 - 256MB DDR3 RAM
 - 128MB NAND flash
 - 1+3 x 1000M Ethernet
 - 1x USB 2.0 port. 1x USB 3.0 port.
 - reset button
 - UART pad on PCB (JP3: TX, RX, GND, 3.3V)

Flash instruction:

1, Download lede-ramips-mt7621-hc5962-squashfs-factory.bin
2, Login as root via SSH on 192.168.199.1 and then copy factory.bin(using wget or nc or...) to /tmp/
3, use the following commands:
   $ mtd write /tmp/lede-ramips-mt7621-hc5962-squashfs-factory.bin firmware
   $ mtd erase firmware_backup && reboot
After reboot you should be able to login as root via SSH on 192.168.1.1

Signed-off-by: ZengFei Zhang <zhangzengfei@kunteng.org>
@gigibox

This comment has been minimized.

Contributor

gigibox commented Feb 28, 2017

Yes, mkresin, you are right, I adjusted the reading position of the eeprom, Now it works very well, Signal is stable and reliable.

In addition, HiWiFi use bdinfo parition to save MAC address, The ethernet node of the DTS have since been deleted.

Thanks!

[    9.990000] mt7603e 0000:01:00.0: ASIC revision: 76030010
[   12.040000] mt7603e 0000:01:00.0: Firmware Version: _mt7603mp
[   12.040000] mt7603e 0000:01:00.0: Build Time: 20151020155902
[   12.090000] firmware init done
[   12.260000] mt76x2e 0000:02:00.0: ASIC revision: 76120044
[   12.280000] mt76x2e 0000:02:00.0: ROM patch already applied
[   12.340000] mt76x2e 0000:02:00.0: Firmware Version: 0.0.00
[   12.350000] mt76x2e 0000:02:00.0: Build: 1
[   12.350000] mt76x2e 0000:02:00.0: Build Time: 201507311614____
[   12.380000] mt76x2e 0000:02:00.0: Firmware running!

wireless

Full log:
hc5962-lede-upgrade-bootlog.txt

@liudf0716

This comment has been minimized.

liudf0716 commented Feb 28, 2017

@mkresin I have submitted a pull request for update libevent days ago, but why no member reviewed my PR, either no member gave me advise or suggestion. here is my PR
#848

@mkresin mkresin self-assigned this Feb 28, 2017

@mkresin

This comment has been minimized.

Contributor

mkresin commented Feb 28, 2017

Merged! Thanks for the PR and thanks a lot to all reviewers.

@mkresin mkresin closed this Feb 28, 2017

@gigibox gigibox deleted the gigibox:patch-hc5962 branch Mar 1, 2017

@SouHong

This comment has been minimized.

SouHong commented Aug 26, 2017

HC5962.dts-ok.tar.gz

#for usr 2.0:

gpio_export {
	compatible = "gpio-export";
	#size-cells = <0>;

	usbpower {
		gpio-export,name = "usbpower";
		gpio-export,output = <0>;
		gpios = <&gpio0 12 0>;
	};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment