Support for NEC WG2600HP (ipq806x)

I'm trying to add support for NEC Aterm WG2600HP. Most of the work is completed, and most functions can be used without problems.
However, there is only one problem with the behavior of sysupgrade on it, the work has stopped.

Specifications

  • SoC: IPQ8064
    • 2-Core, 384 - 1,400 MHz
  • RAM: 512 MB
  • Flash: SPI 32 MB
  • WLAN: QCA9980
    • ac wave2, n, a, b, g
  • WAN: 1000 Mbps x1
  • LAN: 1000 Mbps x4
  • USB: 3.0 (Type-A) x1

Inside

Repository

Issue

  • Cannot keep the settings at sysupgrade
    • When executing sysupgrade, the settings on the router is not kept even if it is executed without -n option, and it starts as the initial state after rebooting.

    • sysupgrade log (see below)

root@OpenWrt:/tmp# sysupgrade openwrt-ipq806x-nec_wg2600hp-squashfs-sysupgrade.b
in 
Saving config files...
Commencing upgrade. All shell sessions will be closed now.
Watchdog handover: fd=3
- watchdog -
killall: telnetd: no process killed
Sending TERM to remaining processes ... udhcpc odhcp6c dnsmasq ntpd ubusd logd rpcd netifd odhcpd uhttpd 
Sending KILL to remaining processes ... 
Switching to ramdisk...
Performing system upgrade...
Unlocking kernel ...
Unlocking rootfs ...

Writing from <stdin> to kernel ...     

Writing from <stdin> to rootfs ...     
Appending jffs2 data from /tmp/sysupgrade.tgz to rootfs..
.                                                                                                                             
Upgrade completed
Rebooting system...
umount: can't unmount /dev: Resource busy
[  790.560395] reboot: Restarting system

Does anyone have idea...?

Without the hardware it's hard to say. Can you please upload a bootlog after the upgraded system restarts? Because you should be seeing a "- config restore -" message generated by:

As for ideas:

Incorrect BLOCKSIZE and PAGESIZE values in image/Makefile for your target can cause these issues. This is because the location of the /sysupgrade.tgz file that gets appended to the rootfs is crucial.

as for other ideas:

What you could (and should) do however is to make a combined "firmware" partition in the device's dts by adding the area of the kernel and rootfs partition. The small "2 MiB" kernel partition might not be enough if all the kmods are built (which is the default for the image builders).

				firmware@860000 {
					label = "firmware";
					reg = <0x860000 0x17a00000>;
				};

and then also update the image/Makefile's sysupgrade.bin rule to something like this:

 IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs | append-metadata
 (remove the KERNEL_SIZE variable)

and call just the default_do_upgrade "$ARGV" in upgrade/platform.sh

(Note: other devices use the "firmware" partition method as well, if you are unsure you can look at the db149, d7800, r7500, ...)

(Please verify that suggestions from above. I'm doing some of this from memory . some stuff might need some adjustment or other fixes. But I think you should be able to your repo looks good otherwise. )

chunkeey, thank you for your advices!

see below:

The log - config restore - was not found...

I thought about that possibility, but I can not change it because I can not determine the exact value of the flash memory (S25FL256S) installed on WG2600HP.

nand info on u-boot shows this:

boot> nand info

Device 1: 1609736408x nand1, sector size 64 KiB
  Page size       256 b
  OOB size          0 b
  Erase size    65536 b

According to the above, should I set PAGESIZE to 256 and BLOCKSIZE to 64k?

OK, I'll try it!

the values can be also taken from /sys/class/spi_master/spi0/spi0.X/mtd/mtdX/erasesize (= BLOCKSIZE) and the subpagesize (= PAGESIZE) or look into the vendor's datasheet for the S25FL256S. (I think these will match the values the # nand info command).

That said, most SPI-NOR chips usually support multiple blocksizes and I did run into a issue with the Fritz!Box 4040's SPI-NOR flash mx25l25635f that specifies and supports 4K sectors. So also please also test "sysupgrade -n" because it can be broken by a bad BLOCKSIZE / PAGESIZE value as well. (The failure mode here is, that the configuration was kept, even though sysupgrade was instructed to delete it)

K, just test it, if it works you will never ever have to bother with making updates in case the kernel size outgrew the partition. So it's definitely worth it.

1 Like

I tried the following three:

  • do sysupgrade -n

    • settings for flash:

      • BLOCKSIZE: 128k
      • PAGESIZE: 2048
    • result: sysupgrade succeeded and booted normally.

    • log:

  • set BLOCKSIZE := 64k, PAGESIZE := 512

    • settings for flash:

      • BLOCKSIZE: 64k
      • PAGESIZE: 512
    • result: sysupgrade succeeded with configurations.

    • note:
      cat /sys/class/.../mtdX/erasesize shows 65536 and cat /sys/class/.../mtdX/subpagesize shows 1.
      I set PAGESIZE to 512 with reference to spi-nor.c in Linux Kernel.

    • log:

  • unify kernel and rootfs to "firmware" partition

    • settings for flash:

      • BLOCKSIZE: 64k
      • PAGESIZE: 512
    • result: rootfs cannot be recognized and boot failed.

    • log:


BLOCKSIZE is necessary, but PAGESIZE seems to be unnecessary.

1 Like

Oh right, you have a SPI-NOR. "NOR-type flash allows a single machine word (byte) to be written – to an erased location – or read independently.". That's why the subpagesize is 1.
As for the 512B vs 256B Pagesize. You should definitely look up the vendor's datasheet on this.

I believe "S25FL128S/S25FL256S, 128 Mbit (16 Mbyte)/256 Mbit (32 Mbyte) 3.0V SPI Flash Memory". Is this right one?

If it is, then you'll need the complete part number. This is because for this series of chips, The chip manufacturer states (on page 7) that "the size assigned for a page depends on the Ordering Part Number."

You can look at Page 146 "12. Ordering Information" to decipher which pagesize is the right one. From what I can see, the second last digit is the important one.

If it's 0 "= Uniform 64-kB sectors = A hybrid of 32 x 4-kB sectors with all remaining sectors being 64 kB, with a 256B programming buffer." => PageSize 256B

if it's 1 "= Uniform 256-kB sectors = All sectors are uniform 256-kB with a 512B programming buffer." => PageSize 512B.

Sadly, this sort of specification conflict between slightly different flash chips does happen more often than you would think.

Luckily, the PAGESIZE setting does not really come into play in your case. The PAGESIZE is important for targets that utilize ubi. so you can get away with removing it.

     [    1.276240] no rootfs found after FIT image in "firmware"

This message is generated by the mtdsplit/mtdsplit_fit.c

So the mtdsplit_fit wasn't able to locate the rootfs image. Do you still have the generated image (and maybe upload it somewhere?). I think I know what's going on.

(Did you try to sysupgrade the image from a existing installation that had a separate kernel and rootfs partition? If yes, then that the problem.
You would need to do a "full first install" via initramfs or u-boot, since sysupgrade can't change the layout/size of the fixed mtd partitions. ).

1 Like

I see...
I do not have much knowledge about flash devices, so I learn a lot.

i think that it is probably correct.
On the surface of flash installed on WG2600HP, "FL256SAVFR0" was printed. But I am confused because this part number does not match the format in the datasheet...
photo:

OK, I'll drop the PAGESIZE setting.

here:
https://taiha.net/jenkins/job/OpenWrt-master-NEC-WG2600HP/49/

I tried to sysupgrade with following:

  1. Boot using initramfs image
  2. execute mtd erase kernel and mtd erase rootfs to erase separated kernel and rootfs partition
  3. execute sysupgrade openwrt-ipq806x-nec_wg2600hp-squashfs-sysupgrade.bin

By the way, I got a hint from your advice, I added CONFIG_MTD_SPLIT_UIMAGE_FW into config-4.9 of ipq806x and included mtdsplit_uimage in the image. I succeeded in booting WG2600HP with "firmware" partition.

log:

1 Like

That "FL256SAVFR0" is what the datasheet calls the "Package Marking". You can decode it with the help of the Table 83. on page 147 (Title: "S25FL128S/S25FL256S Valid Comindations - Standard") of the PDF. It also tells you that the "S25" prefix is omitted on the package marking: See Note(1): "1. Example, S25FL256SAGMFI000 package marking would be FL256SAIF00".

If I decoded the "FL256SAVFR0" correctly, you should have a S25FL256SAGMFVR0. Which would make it a variant of the "Uniform 64-kB sectors = A hybrid of 32 x 4-kB sectors with all remaining sectors being 64 kB, with a 256B programming buffer" and hence the PAGESIZE would be 256B.
So the value from u-boot is right \o/.... (But yes, this is academical by now since you don't need the PAGESIZE.)

you are right. The NEC WG2600HP doesn't use fit, so the mtdsplit_fit is useless (and mtdsplit_uimage is the right one). So if it works go with it.

In fact, currently the TP-Link C2600 image is having a problem with the 2MiB kernel partition and there's an effort under way to increase it to 4 MiB:

https://www.mail-archive.com/lede-dev@lists.infradead.org/msg12165.html

With the "firmware" partition approach, you'll never need to deal with these problems. And as a bonus, the flash space will be used more efficiently and less space is wasted. (For example on the TP-Link C2600 the kernel is just barely over the 2 MiB limit, however because the "proposed" kernel partition is 4 MiB, the remaining ~1.9-1.8 MiB will lie idle.)

1 Like

After sysupgrade from devadd/wg2600hp to devadd/wg2600hp_firmware router restart loop. I can't pause boot to change env use tftp recovery. Can you back up env block help for me,thanks.Screenshot%20from%202018-05-15%2002-33-44

I see, I finally feel like I could understand the whole thing...
Thank you very much for your detailed explanations!

Indeed. I also felt anxiety because the kernel area was small. Even so, it seems to be a very "good timing" as a topic on C2600's proposal.
I will sorting the commits and try submitting the PR, thanks!

Could you tell me how you installed it the first time? Also, do you have any websites you referred to in that case?

setenv enable tftp and flash openwrt.bin via tftp. Then delete env ipaddr and serverip because if plug in ethernet cable it well start tftp recovery can't boot OpenWrt Kernel
I want flash env block use programmer to change env value and enable tftp recovery.

U-Boot have a password

U-Boot 2012.07 [Standard IPQ806X.LN,local] (Mar 26 2015 - 13:53:09)

smem ram ptable found: ver: 0 len: 5
DRAM:  491 MiB
NAND:  ipq_nand: unknown NAND device manufacturer: 0 device: 0
ipq_nand: failed to identify device
SF: Detected S25FL256S with page size 64 KiB, total 32 MiB
ipq_spi: page_size: 0x100, sector_size: 0x10000, size: 0x2000000
32 MiB
MMC:   
PCI0 Link Intialized
PCI1 Link Intialized
In:    serial
Out:   serial
Err:   serial
PRODUCTDATA CRC Verify OK.
Net:   MAC1 addr:
athrs17_reg_init: complete
athrs17_vlan_config ...done
S17c init  done
MAC2 addr:
eth0, eth1

welcome to boot console
Password:

I see...
However, I could not read and write with my programmer, so I can not give advice on recovery using it. Sorry.

Yes, u-boot on WG2600HP has a password, so I cannot login to the console in the usual way.
For this reason, I kept tftpboot in bootcmd even after installing OpenWrt.
My environment variables for u-boot:

bootdelay=5
baudrate=115200
ramboot=rootfstype=ramfs; tftpboot 0x44000000 wg2600hp-initramfs.bin
serverip=192.168.10.2
ipaddr=192.168.10.1
autostart=yes
bootargs=console=ttyHSL1,115200n8 root=mtd:rootfs rootfstype=squashfs reboot=0
bootcmd=run ramboot || bootipq

If WG2600HP fails to tftpboot, it will boot from flash memory.

If it is possible to identify the u-boot password, it will be easy to recover...

Maybe you can read and backup env block use "dd" or "mtd" command.

Oh, I had a misunderstanding.

I put a binary in here that dumped from my WG2600HP:
https://taiha.net/contents/mtd9_APPSBLENV.bin

The contents are as listed above.

Ok. Please keep in mind that OpenWrt is gunning for a 18.06 release. So new targets/device PRs might take a while to process.

As for your devadd/wg2600hp. Can you please look again into the dts gpio-key
node? Because both the "bridge" and "converter" switches? use the same BTN_0 keycode. If this is really correct then you should add a short note that this is supposed to be this way (otherwise it just confuse the heck out of Mathias).

1 Like

Well, to be honest, I do not understand exactly how to assign the keycode identical or another in this case.

WG2600HP has a slide switch for switching operation mode (router / bridge / converter, "router" position is not connected to gpio), so I assigned the same keycode with reference to WSR-1166 with similar switch.

1 Like

Oh ok. So it's a three position switch. got it. Well, so this will likely depend on what the committer will think is right :frowning: .The OpenWrt's specific gpio-button-hotplug driver is not setup to handle such cases. You could set one of the two to BTN_1 (and leave the other at BTN_0). This would make it possible to distinguish between the converter and bridge case.... But it's far from ideal, since the button hotplug handler scripts would to have extra logic in order to retain the state. But yeah, this is sort of tricky.

hmm, I see...
I will send PR in the current repository for the time being and I will follow it if there is a committer pointed out.

In the current OpenWrt, I feel that it is somewhat unsatisfactory that keys other than some (e.g.: wps, reset, rfkill) are hard to use...