Commit Graph

133 Commits

Author SHA1 Message Date
Bjørn Mork 5fb51d4516 ipq806x: sysupgrade: drop unnecessary UBI to UBI logic
The purpose of this code seems to be to avoid issues caused
by partially overwriting an existing UBI partition, where some
of the erase counters would be reset but not the unmodified
ones.  This problem has been solved in a more generic way by
the UBI EOF marker. This ensures that any old PEBs after the
marker are properly initialized.  It is therefore unnecessary
to erase the whole partition before flashing a new OpenWrt
factory image.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
2021-12-03 12:23:02 +01:00
Matthew Hagan 67f5201276 ipq806x: add support for Cisco Meraki MR42/MR52
The MR42 and MR52 are two similar IPQ806x based devices from the Cisco
Meraki "Cryptid" series.

  MR42 main features:
  -  IPQ8068 1.4GHz
  -  512MB RAM
  -  128MB NAND
  -  2x QCA9992 (2.4 & 5GHz)
  -  1x QCA9889 (2.4 & 5GHz)
  -  1x AR8033 PHY
  -  PoE/AC power

  MR52 main features:
  -  IPQ8068 1.4GHz
  -  512MB RAM
  -  128MB NAND
  -  2x QCA9994 (2.4 & 5GHz)
  -  1x QCA9889 (2.4 & 5GHz)
  -  2x AR8033 PHYs
  -  PoE/AC power

(MR42 Only) Installation via diagnostic mode:

If you can successfully complete step 1 then you can continue to install
via this method without having to open the device. Otherwise please use
the standard UART method. Please note that when booting via TFTP, some
Ethernet devices, in particular those on laptops, will not connect in
time, resulting in TFTP boot not succeeding. In this instance it is
advised to connect via a switch.

  1. Hold down reset at power on and keep holding, after around 10 seconds
     if the orange LED changes behaviour to begin flashing, proceed to
     release reset, then press reset two times. Ensure that the LED has
     turned blue. Note that flashing will occur on some devices, but it
     will not be possible to change the LED colour using the reset button.
     In this case it will still be possible to continue with this install
     method.

  2. Set your IP to 192.168.1.250. Set up a TFTP server serving
     mr42_u-boot.mbn and
     openwrt-ipq806x-generic-meraki_mr42-initramfs-fit-uImage.itb, obtained
     from [1].

  3. Use telnet and connect to 192.168.1.1. Run the following commands to
     install u-boot. Note that all these commands are critical, an error
     will likely render the device unusable.

     Option 3.1:
       If you are sure you have set up the TFTP server correctly you can
       run this script on the device. This will download and flash the
       u-boot image immediately:

       `/etc/update_uboot.sh 192.168.1.250 mr42_u-boot.mbn`

       Once completed successfully, power off the device.

     Option 3.2:
       If you are unsure the TFTP server is correctly set up you can
       obtain the image and flash manually:

       3.2.1. `cd /tmp`
       3.2.2. `tftp-hpa 192.168.1.250 -m binary -c get mr42_u-boot.mbn`
       3.2.3. Confirm file has downloaded correctly by comparing the
              md5sum:

            `md5sum mr42_u-boot.mbn`

       3.2.4. The following are the required commands to write the image.

            `echo 1 > /sys/devices/platform/msm_nand/boot_layout
             mtd erase /dev/mtd1
             nandwrite -pam /dev/mtd1 mr42_u-boot.mbn
             echo 0 > /sys/devices/platform/msm_nand/boot_layout`

          Important: You must observe the output of the `nandwrite`
          command. Look for the following to verify writing is occurring:

            `Writing data to block 0 at offset 0x0
             Writing data to block 1 at offset 0x20000
             Writing data to block 2 at offset 0x40000`

          If you do not see this then do not power off the device. Check
          your previous commands and that mr42_u-boot.mbn was downloaded
          correctly. Once you are sure the image has been written you
          can proceed to power off the device.

  4. Hold the reset button and power on the device. This will immediately
     begin downloading the appropriate initramfs image and boot into it.

     Note: If the device does not download the initramfs, this is likely
     due to the interface not being brought up in time. Changing Ethernet
     source to a router or switch will likely resolve this. You can also
     try manually setting the link speed to 10Mb/s Half-Duplex.

  5. Once a solid white LED is displayed on the device, continue to the
     UART installation method, step 6.

Standard installation via UART - MR42 & MR52

  1. Disassemble the device and connect a UART header. The header pinout
     is as follows:

       1 - 3.3v
       2 - TXD
       3 - RXD
       4 - GND

     Important: You should only connect TXD, RXD and GND. Connecting
     3.3v may damage the device.

  2. Set your IP to 192.168.1.250. Set up a TFTP server serving
     openwrt-ipq806x-generic-meraki_(mr42|mr52)-initramfs-fit-uImage.itb.
     Separately obtain the respective sysupgrade image.

  3. Run the following commands, preferably from a Linux host. The
     mentioned files, including ubootwrite.py and u-boot images, can be
     obtained from [1].

       `python ubootwrite.py --write=(mr42|mr52)_u-boot.bin`

     The default for "--serial" option is /dev/ttyUSB0.

  4. Power on the device. The ubootwrite script will upload the image to
     the device and launch it. The second stage u-boot will in turn load
     the initramfs image by TFTP, provided the TFTP server is running
     correctly. This process will take about 13 minutes. Once a solid
     white LED is displayed, the image has successfully finished
     loading. Note: If the image does not load via TFTP, try again with
     the Ethernet link to 10Mb/s Half-Duplex.

  5. (MR42 only) Do not connect over the network. Instead connect over
     the UART using minicom or similar tool. To replace u-boot with
     the network enabled version, please run the following commands.
     Note that in the provided initramfs images, the u-boot.mbn file
     is located in /root:

     If you have not used the provided initramfs, you must ensure you
     are using an image with "boot_layout" ECC configuration enabled in
     the Kernel. This will be version 5.10 or higher. If you do not do
     this correctly the device will be bricked.

       `insmod mtd-rw i_want_a_brick=1
        mtd erase /dev/mtd8
        nandwrite -pam /dev/mtd8 /root/mr42_u-boot.mbn`

     After running nandwrite, ensure you observe the following output:

       `Writing data to block 0 at offset 0x0
        Writing data to block 1 at offset 0x20000
        Writing data to block 2 at offset 0x40000`

  6. (Optional) If you have no further use for the Meraki OS, you can
     remove all other UBI volumes on ubi0 (mtd11), including diagnostic1,
     part.old, storage and part.safe. You must not remove the ubi1 ART
     partition (mtd12).

       `for i in diagnostic1 part.old storage part.safe ; do
        ubirmvol /dev/ubi0 -N $i
        done`

  7. Proceed to flash the sysupgrade image via luci, or else download or
     scp the image to /tmp and use the sysupgrade command.

[1] The mentioned images and ubootwrite.py script can be found in this repo:
    https://github.com/clayface/openwrt-cryptid

[2] The modified u-boot sources for the MR42 and MR52 are available:
    https://github.com/clayface/U-boot-MR52-20200629

Signed-off-by: Matthew Hagan <mnhagan88@gmail.com>
2021-11-28 17:51:52 +01:00
Robert Marko 76fff69180 ipq806x: ecw5410: use bootloader provided MAC-s
Currently, we are overriding the bootloader provided MAC-s as the ethernet
aliases are reversed so MAC-s were fixed up in userspace.
There is no need to do that as we can just fix the aliases instead and get
rid of MAC setting via userspace helper.

Fixes: 59f0a0f ("ipq806x: add Edgecore ECW5410 support")

Signed-off-by: Robert Marko <robert.marko@sartura.hr>
2021-10-31 21:24:47 +01:00
Robert Marko 2e3c79ef83 ipq806x: ecw5410: fix PCI1 radio caldata
ECW5410 has 2 QCA9984 cards, one per PCI controller.
They are located at PCI adresses 0001:01:00.0 and 0002:01:00.0.

Currently, pre-cal is not provided for 0001:01:00.0 at all,but for
0000:01:00.0 which is incorrect and causes the ath10k driver to not
be able to fetch the BMI ID and use that to fetch the proper BDF but
rather fail with:
[   12.029708] ath10k 5.10 driver, optimized for CT firmware, probing pci device: 0x46.
[   12.031816] ath10k_pci 0001:01:00.0: enabling device (0140 -> 0142)
[   12.037660] ath10k_pci 0001:01:00.0: pci irq msi oper_irq_mode 2 irq_mode 0 reset_mode 0
[   13.173898] ath10k_pci 0001:01:00.0: qca9984/qca9994 hw1.0 target 0x01000000 chip_id 0x00000000 sub 168c:cafe
[   13.174015] ath10k_pci 0001:01:00.0: kconfig debug 0 debugfs 1 tracing 0 dfs 1 testmode 0
[   13.189304] ath10k_pci 0001:01:00.0: firmware ver 10.4b-ct-9984-fW-13-5ae337bb1 api 5 features mfp,peer-flow-ctrl,txstatus-noack,wmi-10.x-CT,ratemask-CT,regdump-CT,txrate-CT,flush-all-CT,pingpong-CT,ch-regs-CT,nop-CT,set-special-CT,tx-rc-CT,cust-stats-CT,txrate2-CT,beacon-cb-CT,wmi-block-ack-CT,wmi-bcn-rc-CT crc35
[   15.492322] ath10k_pci 0001:01:00.0: failed to fetch board data for bus=pci,vendor=168c,device=0046,subsystem-vendor=168c,subsystem-device=cafe,variant=Edgecore-ECW541 from ath10k/QCA9984/hw1.0/board-2.bin
[   15.543883] ath10k_pci 0001:01:00.0: failed to fetch board-2.bin or board.bin from ath10k/QCA9984/hw1.0
[   15.543920] ath10k_pci 0001:01:00.0: failed to fetch board file: -12
[   15.552281] ath10k_pci 0001:01:00.0: could not probe fw (-12)

So, provide the pre-cal for the actual PCI card and not the non-existent
one.

Fixes: 59f0a0f ("ipq806x: add Edgecore ECW5410 support")

Signed-off-by: Robert Marko <robert.marko@sartura.hr>
2021-10-31 21:24:47 +01:00
Adrian Schmutzler fbddb38442 ipq806x: consolidate 11-ath10k-caldata
After the ath10k_patch_mac lines have been removed, a lot of blocks
can be consolidated.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-10-30 22:11:23 +02:00
Adrian Schmutzler 6a27e8036e ipq806x: remove transition workarounds for qcom-smem partitions
The out-of-tree qcom-smem patches traditionally displayed mtd partition names
in upper case, starting with the new mainline qcom-smem support in kernel v5.10,
it switched to normalizing the partition names to lower case.

While both 5.4 and 5.10 were supported in the target, we carried a workaround
to support both of them. Since the target has dropped 5.4 recently, those
can be removed now.

Ref:

2db9dded0a ("ipq806x: nbg6817: case-insensitive qcom-smem partitions")
435dc2e77e ("ipq806x: ecw5410: case-insensitive qcom-smem partitions")
f70e11cd97 ("ipq806x: g10: case-insensitive qcom-smem partitions")

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-10-30 22:11:23 +02:00
Ansuel Smith f44e933458 ipq806x: provide WiFI mac-addresses from dts
Use nvmem framework for supported mac-address stored
in nvmem cells and drop mac patch function for hotplug
script for supported devices.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
[rebase, move to correct node for d7800, include xr500]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-10-30 22:11:13 +02:00
Peter Geis 70c12d26ca ipq806x: add support for Netgear Nighthawk Pro Gaming XR500
This adds support for the Netgear Nighthawk Pro Gaming XR500.
It is the successor to the Netgear Nighthawk R7800 and shares almost
identical hardware to that device.
The stock firmware is a heavily modified version of OpenWRT.

Specifications:
  SoC: Qualcomm Atheros IPQ8065
  RAM: 512 MB
  Storage: 256 MiB NAND Flash
  Wireless: 2x Qualcomm Atheros QCA9984
  Ethernet: 2x 1000/100/10 dedicated interfaces
  Switch: 5x 1000/100/10 external ports
  USB: 2x 3.0 ports

More information:
Manufacturer page: https://www.netgear.com/gaming/xr500/
Almost identical to Netgear R7800
Differences (r7800 > xr500):
  Flash: 128MiB > 256MiB
  Removed esata
  swapped leds:
    usb1 (gpio 7 > 8)
    usb2 (gpio 8 > 26)
    guest/esata (gpio 26 > 7)

MAC addresses:

On the OEM firmware, the mac addresses are:

  WAN: *:50  art 0x6
  LAN: *:4f  art 0x0 (label)
  2G:  *:4f  art 0x0
  5G:  *:51  art 0xc

Installation:
Install via Web Interface (preferred):
Utilize openwrt-ipq806x-netgear_xr500-squashfs-factory.img

Install via TFTP recovery:
1.Turn off the power, push and hold the reset button (in a hole on
  backside) with a pin
2.Turn on the power and wait till power led starts flashing white
  (after it first flashes orange for a while)
3.Release the reset button and tftp the factory img in binary mode.
  The power led will stop flashing if you succeeded in transferring
  the image, and the router reboots rather quickly with the new
  firmware.
4.Try to ping the router (ping 192.168.1.1). If does not respond,
  then tftp will not work either.

Uploading the firmware image with a TFTP client
$ tftp 192.168.1.1
bin
put openwrt-ipq806x-netgear_xr500-squashfs-factory.img

Note:

The end of the last partition is at 0xee00000. This was chosen
by the initial author, but nobody was able to tell why this
particular arbitrary size was chosen. Since it's not leaving
too much empty space and it's the only issue left, let's just
keep it for now.

Based on work by Adam Hnat <adamhnat@gmail.com>
ref: https://github.com/openwrt/openwrt/pull/3215

Signed-off-by: Peter Geis <pgwipeout@gmail.com>
[squash commits, move common LEDs to DTSI, remove SPDX on old
 files, minor whitespace cleanup, commit message facelift,
 add MAC address overview, add Notes, fix MAC addresses,
 use generic name for partition nodes in DTS]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-10-26 22:30:18 +02:00
Chukun Pan fcc075e12f ipq806x: Askey RT4230W REV6: fix caldata script
The partition name in the device dts is '0:ART'.
Be independent to prevent this part from becoming
incorrect once the kernel v5.4 gone.

Fixes: da8428d277 ("ipq806x: add support for Askey RT4230W REV6")

Signed-off-by: Chukun Pan <amadeus@jmu.edu.cn>
2021-08-24 20:26:00 +02:00
Alex Henrie 6fb27e8e6d ipq806x: fix LAN and WAN port assignments on TP-Link AD7200
LAN port 4 was swapped with the WAN port and the remaining three LAN
ports were numbered in reverse order from their labels on the case.

Fixes: 1a775a4fd0 ("ipq806x: add support for TP-Link Talon AD7200")
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
2021-06-06 00:26:13 +02:00
Adrian Schmutzler 6f648ed7e6 treewide: remove "+" sign for increment with macaddr_add
Many people appear to use an unneeded "+" prefix for the increment
when calculating a MAC address with macaddr_add. Since this is not
required and used inconsistently [*], just remove it.

[*] As a funny side-fact, copy-pasting has led to almost all
    hotplug.d files using the "+", while nearly all of the
    02_network files are not using it.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-06-05 23:54:37 +02:00
Lauro Moreno da8428d277 ipq806x: add support for Askey RT4230W REV6
This adds support for the Askey RT4230W REV6
(Branded by Spectrum/Charter as RAC2V1K)

At this time, there's no way to reinstall the stock firmware so don't install
this on a router that's being rented.

Specifications:

    Qualcomm IPQ8065
    1 GB of RAM (DDR3)
    512 MB Flash (NAND)
    2x Wave 2 WiFi cards (QCA9984)
    5x 10/100/1000 Mbps Ethernet (Switch: QCA8337)
    1x LED (Controlled by a microcontroller that switches it between red and
        blue with different patterns)
    1x USB 3.0 Type-A
    12V DC Power Input
    UART header on PCB - pinout from top to bottom is RX, TX, GND, 5V
    Port settings are 115200n8

More information: https://forum.openwrt.org/t/askey-rac2v1k-support/15830
https://deviwiki.com/wiki/Askey_RAC2V1K

To check what revision your router is, restore one of these config backups
through the stock firmware to get ssh access then run
"cat /proc/device-tree/model".
https://forum.openwrt.org/t/askey-rac2v1k-support/15830/17
The revision number on the board doesn't seem to be very consistent so that's
why this is needed. You can also run printenv in the uboot console and if
machid is set to 177d, that means your router is rev6.

Note: Don't install this if the router is being rented from an ISP. The defined
partition layout is different from the OEM one and even if you changed the
layout to match, backing up and restoring the OEM firmware breaks /overlay so
nothing will save and the router will likely enter a bootloop.

How to install:

Method 1: Install without opening the case using SSH and tftp

    You'll need:
    RAC2V1K-SSH.zip:
https://github.com/lmore377/openwrt-rt4230w/blob/master/RAC2V1K-SSH.zip
    initramfs and sysupgrade images

    Connect to one of the router's LAN ports

    Download the RAC2V1K-SSH.zip file and restore the config file that
corresponds to your router's firmware (If you're firmware is newer than what's
in the zip file, just restore the 1.1.16 file)

    After a reboot, you should be able to ssh into the router with username:
"4230w" and password: "linuxbox" or "admin". Run the following commannds
     fw_setenv ipaddr 10.42.0.10 #IP of router, can be anything as long as
it's in the same subnet as the server
     fw_setenv serverip 10.42.0.1# #IP of tftp server that's set up in next
steps
     fw_setenv bootdelay 8
     fw_setenv bootcmd "tftpboot initramfs.bin; bootm; bootipq"

    Don't reboot the router yet.

    Install and set up a tftp server on your computer

    Set a static ip on the ethernet interface of your computer (use this for
serverip in the above commands)

    Rename the initramfs image to initramfs.bin, and host it with the tftp
server

    Reboot the router. If you set up everything right, the router led should
switch over to a slow blue glow which means openwrt is booted. If for some
reason the file doesn't get loaded into ram properly, it should still boot to
the OEM firmware.
    After openwrt boots, ssh into it and run these commands:
    fw_setenv bootcmd "setenv mtdids nand0=nand0 && setenv mtdparts
 mtdparts=nand0:0x1A000000@0x2400000(firmware) && ubi part firmware && ubi
read 0x44000000 kernel 0x6e0000 && bootm"
    fw_setenv bootdelay 2

    After openwrt boots up, figure out a way to get the sysupgrade file onto it
(scp, custom build with usb kernel module included, wget, etc.) then flash it
with sysupgrade. After it finishes flashing, it should reboot, the light should
start flashing blue, then when the light starts "breathing" blue that means
openwrt is booted.

Method 2: Install with serial access (Do this if something fails and you can't
boot after using method 1)

    You'll need:
    initramfs and sysupgrade images
    Serial access:
https://openwrt.org/inbox/toh/askey/askey_rt4230w_rev6#opening_the_case

    Install and set up a tftp server

    Set a static ip on the ethernet interface of your computer

    Download the initramfs image, rename it to initramfs.bin, and host it with
the tftp server

    Connect the wan port of the router to your computer

    Interrupt U-Boot and run these commands:
    setenv serverip 10.42.0.1 (You can use whatever ip you set for the computer)
    setenv ipaddr 10.42.0.10 (Can be any ip as long as it's in the same subnet)
    setenv bootcmd "setenv mtdids nand0=nand0 &&
set mtdparts mtdparts=nand0:0x1A000000@0x2400000(firmware) && ubi part firmware
&& ubi read 0x44000000 kernel 0x6e0000 && bootm"

    saveenv
    tftpboot initramfs.bin
    bootm

    After openwrt boots up, figure out a way to get the sysupgrade file onto it
(scp, custom build with usb kernel module included, wget, etc.) then flash it
with sysupgrade. After it finishes flashing, it should reboot, the light should
start flashing blue, then when the light starts "breathing" blue that means
openwrt is booted.

Signed-off-by: Lauro Moreno <lmore377@gmail.com>
[add entry in 5.10 patch, fix whitespace issues]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-06-05 23:39:14 +02:00
Petr Štetiar ce8af0ace0 ipq806x: base-files: asrock: fix bootcount include
Fixes following error while executing the init script on the buildhost:

 Enabling boot
 ./etc/init.d/bootcount: line 5: /lib/upgrade/asrock.sh: No such file or directory
 Enabling bootcount

While at it fix following shellcheck issue:

 base-files/etc/init.d/bootcount line 11:
    if [ $? -eq 0 ]; then
         ^-- SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?.

Cc: Ansuel Smith <ansuelsmth@gmail.com>
Cc: Pawel Dembicki <paweldembicki@gmail.com>
Cc: Christian Lamparter <chunkeey@gmail.com>
Fixes: 98b86296e6 ("ipq806x: add support for ASRock G10")
References: https://gitlab.com/ynezz/openwrt/-/jobs/1243290743#L1444
Signed-off-by: Petr Štetiar <ynezz@true.cz>
2021-05-13 15:13:15 +02:00
Stefan Lippers-Hollmann 435dc2e77e ipq806x: ecw5410: case-insensitive qcom-smem partitions
The out-of-tree qcom-smem patches traditionally displayed mtd partition names
in upper case, starting with the new mainline qcom-smem support in kernel v5.10,
it switches to normalizing the partition names to lower case.

Signed-off-by: Stefan Lippers-Hollmann <s.l-h@gmx.de>
2021-05-08 18:45:42 +02:00
Stefan Lippers-Hollmann f70e11cd97 ipq806x: g10: case-insensitive qcom-smem partitions
The out-of-tree qcom-smem patches traditionally displayed mtd partition names
in upper case, starting with the new mainline qcom-smem support in kernel v5.10,
it switches to normalizing the partition names to lower case.

Signed-off-by: Stefan Lippers-Hollmann <s.l-h@gmx.de>
2021-05-08 18:45:42 +02:00
Stefan Lippers-Hollmann 2db9dded0a ipq806x: nbg6817: case-insensitive qcom-smem partitions
The out-of-tree qcom-smem patches traditionally displayed mtd partition names
in upper case, starting with the new mainline qcom-smem support in kernel v5.10,
it switches to normalizing the partition names to lower case.

Signed-off-by: Stefan Lippers-Hollmann <s.l-h@gmx.de>
2021-05-08 18:45:42 +02:00
Ansuel Smith 861b82d36a ipq806x: improve system latency
Various report and data show that the freq 384000 is too low and cause some
extra latency to the entire system. OEM qsdk code also set the min frequency
for this target to 800 mhz.
Also some user notice some instability with this idle frequency, solved by
setting the min frequency to 600mhz. Fix all these kind of problem by
introducing a boot init.d script that set the min frequency to 600mhz and set
the ondemand governor to be more aggressive. The script set these value only if
the ondemand governor is detected. 384 mhz freq is still available and user can
decide to restore the old behavior by disabling this script.

Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
2021-05-07 07:05:16 +02:00
Mark Mentovai 565814a5ee ipq806x: ubnt,unifi-ac-hd: reorder eth0 and eth1
The Ubiquiti UniFi AC HD (UAP-AC-HD, UAP301) has two Ethernet ports,
labeled MAIN and SECONDARY, connected to gmac2 and gmac1, respectively.
The standard probe order results in gmac1/SECONDARY being eth0 and
gmac2/MAIN being eth1. This does not match the stock firmware, is
contrary to user expectation, causes the wrong (high) MAC address to be
used in a bridged configuration (the default for this device), and makes
the gmac2/MAIN port unusable in the preinit environment (such as for
failsafe). Until a recent patch, gmac1/SECONDARY (eth0) was not even
usable.

This reorders the ports so that gmac2/MAIN is eth0, and the now-working
gmac1/SECONDARY is eth1. eth0 has the low MAC address and eth1 has the
high; when bridged, the bridge takes on the correct low MAC address.
This matches the stock firmware. The MAIN port is usable for failsafe
during preinit.

This device does not have a switch on board, so there's no possibility
to remap ports via switch configuration. "ip link set $interface name"
is used instead, during preinit before networking is configured.

Signed-off-by: Mark Mentovai <mark@moxienet.com>
Build-tested: ipq806x/ubnt,unifi-ac-hd
Run-tested: ipq806x/ubnt,unifi-ac-hd
2021-05-07 07:05:16 +02:00
Adrian Schmutzler 85b1f4d8ca treewide: remove execute bit and shebang from board.d files
So far, board.d files were having execute bit set and contained a
shebang. However, they are just sourced in board_detect, with an
apparantly unnecessary check for execute permission beforehand.

Replace this check by one for existance and make the board.d files
"normal" files, as would be expected in /etc anyway.

Note:

This removes an apparantly unused '#!/bin/sh /etc/rc.common' in
target/linux/bcm47xx/base-files/etc/board.d/01_network

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-03-06 11:30:06 +01:00
Jan Alexander 4e46beb313 ipq806x: add support for Ubiquiti UniFi AC HD
Hardware
--------

SoC:   Qualcomm IPQ8064
RAM:   512MB DDR3
Flash: 256MB NAND (Micron MT29F2G08ABBEAH4)
       32MB SPI-NOR (Macronix MX25U25635F)
WLAN:  Qualcomm Atheros QCA9994 4T4R b/g/n
       Qualcomm Atheros QCA9994 4T4R a/n/ac
ETH:   eth0 - SECONDARY (Atheros AR8033)
       eth1 - MAIN (Atheros AR8033)
USB:   USB-C
LED:   Dome (white / blue)
BTN:   Reset

Installation
------------

Copy the OpenWrt sysupgrade image to the /tmp directory of the device
using scp. Default IP address is 192.168.1.20 and default username and
password are "ubnt".

SSH to the device and write the bootselect flag to ensure it is booting
from the mtd partition the OpenWrt image will be written to. Verify the
output device below matches mtd partition "bootselect" using /proc/mtd.

> dd if=/dev/zero bs=1 count=1 seek=7 conv=notrunc of=/dev/mtd11

Write the OpenWrt sysupgrade image to the mtd partition labeled
"kernel0". Also verify the used partition device using /proc/mtd.

> dd if=/tmp/sysupgrade.bin of=/dev/mtdblock12

Reboot the device.

Back to stock
-------------

Use the TFTP recovery procedure with the Ubiquiti firmware image to
restore the vendor firmware.

Signed-off-by: Jan Alexander <jan@nalx.net>
2021-01-14 01:03:54 +01:00
Daniel Golle f4c64937cf ipq806x: fix LED names of TP-Link Talon AD2700
While the underscore in the name of the USB LEDs was removed from DTS,
/etc/board.d/01_leds also has to reflect that change.

Fixes: 28fd279e5d ("ipq806x: some corrections for TP-Link Talon AD7200")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2021-01-05 16:26:44 +00:00
Gary Cooper 1a775a4fd0 ipq806x: add support for TP-Link Talon AD7200
Device hardware: https://deviwiki.com/wiki/TP-LINK_AD7200_(Talon)

The Talon AD7200 is basically an Archer C2600 with a third PCIe lane
and an 802.11ad radio. It looks like the Archers C2600/5400 but the
housing is slightly larger.

Specifications
--------------

  - IPQ8064 dual-core 1400MHz
  - QCA9988 2.4GHz WiFi
  - QCA9990 5GHz WiFi
  - QCA9500 60GHz WiFi
  - 32MB SPI Flash
  - 512MiB RAM
  - 5 GBit Ports (QCA8337)

Installation
------------

Installation is possible from the OEM web interface.
Sysupgrade is possible.
TFTP recovery is possible.
  - Image: AD7200_1.0_tp_recovery.bin

Notes
  - This will be the first 802.11ad device supported by mainline.

Signed-off-by: Gary Cooper <gaco@bitmessage.de>
2021-01-05 02:16:24 +00:00
Yanase Yuki 3bb1618573 ipq806x: add support for NEC Platforms Aterm WG2600HP3
NEC Platforms Aterm WG2600HP3 is a dual-band router based on Qualcomm IPQ8062.

Specification
-------------
- SoC: Qualcomm IPQ8062
- RAM: 512MiB
- Flash memory: SPI-NOR 32MiB (Cypress S25FL256S)
- Wi-Fi: Qualcomm QCA9984 (2.4GHz, 1ch - 13ch)
- Wi-Fi: Qualcomm QCA9984 (5GHz, 36ch - 64ch, 100ch - 140ch)
- Ethernet: 4x 100/1000 Mbps (1x WAN, 4x LAN)
- LED: 6x green LED, 6x red LED
- Input: 2x tactile switch, 1x SP3T slide switch
- Serial console: 115200bps, through-hole J3
  - [  ] [GND] [  ] [TX] [RX] ----> DC jack
- Power: DC 12V 1.5A

This device does not support VHT160 and VHT80+80.
Custom BDFs are required to limit VHT capabilities.

Flash instructions
------------------
1. Setup TFTP server (IP address: 192.168.1.2)
2. Put initramfs image into TFTP server directory
3. Connect WG2600HP3 lan port and computer that runs TFTP server
4. Connect to the serial console
5. Interrupt booting by Esc key (password: chiron)
6. Execute the following commands
    # setenv bootcmd "nboot 0x44000000 1 0x860000"
    # saveenv
    # setenv ipaddr 192.168.1.1
    # setenv serverip 192.168.1.2
    # tftpboot 0x44000000 openwrt-ipq806x-generic-nec_wg2600hp3-initramfs-uImage
7. After booting OpenWrt initramfs image, backup SPI-NOR flash memory
8. Erase firmware partition
    # mtd erase firmware
9. Run sysupgrade

Signed-off-by: Yanase Yuki <dev@zpc.sakura.ne.jp>
2020-12-25 10:38:13 +01:00
Adrian Schmutzler 212ad91630 ipq806x: remove unneeded empty lines
This removes two unneeded empty lines in base-files.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-12-22 21:44:57 +01:00
Christian Lamparter 98b86296e6 ipq806x: add support for ASRock G10
The ASRock G10 is a 2.4/5 GHz band 11ac "Gaming" router,
based on Qualcomm IPQ8064.

Specifications:

SoC:	Qualcomm IPQ8064
CPU:	Dual-Core A15 @ (384 - 1,400 MHz, 2C2T)
DRAM:	512 MiB (~467 MiB available)
NAND:	128 MB (Micron MT29F1G08ABBEAH4)
WLAN0:	4T4R 5 GHz Wlan (QCA9980)
WLAN1:	4T4R 2.4 GHz Wlan (QCA9980)
ETH:    5x 10/100/1000 Mbps Ethernet (QCA8337)
INPUT:  Reset Button, WPS 2.4G and WPS 5G Button
LEDS:   1 multicolor status LED
USB:    2x USB 3.0 Type-A
POWER:  12VDC/3A AC Adapter + dedicated Power Switch
UART:   Setting is 115200-8-N-1. 1x4 .1" unpopulated header
	on the PCB (J6 - very tiny silkscreen next to TX).
        Pinout: 1. 3v3 (Square - best skipped!), 2. RX, 3. GND, 4. TX

WARNING: The serial port needs a TTL/RS-232 3.3v level converter!
	 (Depending on the serial adapter RX and TX might need to
	  be swapped).

Note about the IR-Remote:
There's a 8-Bit MCU (SONIX SN8F25E21SG) which is controlling the
IR-Remote and is fed by the IR-Photodiode. The SoC can talk to
the device via I2C. The vendor's GPL archive comes with the source
of the interface driver for this as a (character driver), the main
control software is however a blob.

Installation Instructions:
 1. Download factory image to disk
 2. Apply factory image via stock web-gui

Back to stock:
 1. Login to router via ssh
 2. run "asrock_g10_back_to_factory" script from /sbin

Notes:
 - If something goes wrong durring sysupgrade, router will go back to
   factory image.
 - Asrock G10 uses partition layout from smem. So partition layout can
   be normal or alternate.
 - 900-arm-add-cmdline-override.patch was copied from 102-powerpc-add-cmdline-override.patch
   from powerpc target.

Knowledge about BOOTCONFIG partition was based on user "jmomo" post from old
OpenWrt forum (Post #50):
https://forum.archive.openwrt.org/viewtopic.php?id=65956&p=2

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
[bump to 5.4, add factory image, fix sysupgrade, convert partition
layout to smem, remove ipq-wifi-asrock-g10 and use ART, minor fixes]
Co-Authored-by: Pawel Dembicki <paweldembicki@gmail.com>
Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
Tested-by: Lukasz Ostapiuk <palibrzuch@gmail.com>
2020-12-22 19:11:50 +01:00
Adrian Schmutzler d181b2cefa ipq806x: remove model name from LED labels
Like in the previous patches for ath79 and ramips, this will remove
the "devicename" from LED labels in ipq806x.

The devicename is removed in DTS files and 01_leds, and a migration
script is added.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-10-07 01:31:45 +02:00
Adrian Schmutzler 95c9df7971 ipq806x: fix support of Edgecore ECW5410 support
This fixes several stylistic and functional errors of the recently
added Edgecore ECW5410:

  - fix call in 11-ath10k-caldata
  - use hex notation in 11-ath10k-caldata
  - remove redundant definitions from DTS that are already in DTSI
  - use proper sorting in image/Makefile
  - use DEVICE_VENDOR/DEVICE_MODEL instead of DEVICE_TITLE
  - use SOC instead of DEVICE_DTS

Fixes: 59f0a0fd83 ("ipq806x: add Edgecore ECW5410 support")

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-09-19 13:32:11 +02:00
Adrian Schmutzler 6e170ffb96 ipq806x: sort entries in lib/upgrade/platform.sh
Apply alphabetic sorting like in the other files.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-09-17 13:03:18 +02:00
Adrian Schmutzler 0b1cdb7eea treewide: remove empty default cases
There is no apparent reason to have an empty default case.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-09-17 12:46:19 +02:00
Adrian Schmutzler a744c14dfa ipq806x: sort entries in 02_network
Apply alphabetic sorting like in the other files.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-09-17 12:33:45 +02:00
Robert Marko 59f0a0fd83 ipq806x: add Edgecore ECW5410 support
This patch adds support for the Edgecore ECW5410 indoor AP.

Specification:
- SoC: Qualcomm Atheros IPQ8068 ARMv7 2x Cortex A-15
- RAM: 256MB(225 usable) DDR3
- NOR Flash: 16MB SPI NOR
- NAND Flash: 128MB S34MS01G2 Parallel NAND
- Ethernet: 2 x 1G via 2x AR8033 PHY-s connected directly to GMAC2 and GMAC3 via SGMII (802.3af POE IN on eth0)
- USB: 1 x USB 3.0 SuperSpeed
- WLAN: 2x QCA9994 AC Wawe 2 (1x 2GHz bgn, 1x 5GHz acn)
- CC2540 BLE
- UART console on RJ45 next to ethernet ports exposed.
Its Cisco pin compatible, 115200 8n1 baud.

Installation instructions:
Through stock firmware or initramfs.

1.Connect to console
2. Login with root account, if password is unknown then interrupt the boot with f and reset it in failsafe.
3. Transfer factory image
4. Flash the image with ubiformat /dev/mtd1 -y -f <your factory image path>

This will replace the rootfs2 with OpenWrt, if you are currently running from rootfs2 then simply change /dev/mtd1 to /dev/mtd0

Note

Initramfs:
1.  Connect to console
2.  Transfer the image from TFTP server with tftpboot,
or by using DHCP advertised image with dhcp command.
3. bootm
4. Run ubiformat /dev/mtd1

You need to interrupt the bootloader after rebooting and run:
run altbootcmd

This will switch your active rootfs partition to one you wrote to and boot from it.

So if rootfs1 is active, then it will change it to rootfs2.

This will format the rootfs2 partition, if your active partition is 2 then simply change /dev/mtd1 with /dev/mtd0
If you dont format the partition you will be writing too, then sysupgrade will find existing UBI rootfs and kernel volumes and update those.
This will result in wrong ordering and OpenWrt will panic on boot.

5. Transfer sysupgrade image
6. Flash with sysupgrade -n.

Note that sysupgrade will write the image to rootfs partition that is not currently in use.

Signed-off-by: Robert Marko <robert.marko@sartura.hr>
2020-09-17 08:42:17 +02:00
Pawel Dembicki f93267bccf ipq806x: enable Linksys EA8500 eth1 interface
At this moment Linksys EA8500 uses only eth0.

This patch change switch registers, which allow to use eth1 as lan
and eth0 as wan. The method work with similar Linksys EA7500V1
and it work with EA8500.

Suggested-by: Sungbo Eo <mans0n@gorani.run>
Tested-by: Brian Onn <brian.a.onn@gmail.com>
Tested-by: Adrian Panella <ianchi74@outlook.com>
Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
2020-07-11 13:33:28 +02:00
Pawel Dembicki 20c7abd4b7 ipq806x: add support for Linksys EA7500 V1
This patch adds support for the Linksys EA7500 V1 router.

Specification:
 - CPU: Qualcomm IPQ8064
 - RAM: 256MB
 - Flash: NAND 128MB
 - WiFi: QCA9982 an+ac + QCA9983 bgn
 - Ethernet: 5 GBE Ports (WAN+ 4xLAN) (QCA8337)
 - USB: 1x USB 3.0 1x USB2.0
 - Serial console: RJ-45 115200 8n1 (1V8 Voltage level)
 - 2 Buttons
 - 1 LED

Known issues:
 - Some devices won't flash via web gui

Installation:
- Newer stock images doesn't allow to install custom firmware.
- Please downgrade software to 1.1.2 version. Official firmware:
https://downloads.linksys.com/downloads/firmware/FW_EA7500_1.1.2.172843_prod.gpg.img
- Do it two times to downgrade all stored images.
- Apply factory image via web-gui.

Serial + TFTP method:
 - downgrade to 1.1.2 two times
 - connect ehternet and serial cable
 - set ip address of tftp server to 192.168.1.254
 - put openwrt factory image to tftp folder and rename it to macan.bin
 - stop device while booting in u-boot
 - run command: "run flashimg"
 - run command: "setenv boot_part 1"
 - run command "saveenv"
 - reset

Back to stock:
- Please use old non-gpg image like this 1.1.2:
https://downloads.linksys.com/downloads/firmware/FW_EA7500_1.1.2.172843_prod.img
- ssh to router and copy image to tmp
- use sysupgrade -n -F

Tested by github users: @jack338c and @grzesiczek1

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
[removed i2c4_pins, mdio0_pins, nand_pins, rgmii2_pins from DTSI]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-07-08 16:07:05 +02:00
Adrian Schmutzler 48c1fdd046 treewide: drop shebang from non-executable target files
This drops the shebang from all target files for /lib and
/etc/uci-defaults folders, as these are sourced and the shebang
is useless.

While at it, fix the executable flag on a few of these files.

This does not touch ar71xx, as this target is just used for
backporting now and applying cosmetic changes would just complicate
things.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-06-16 14:26:33 +02:00
Samantha Collard 0f910a8c4c ipq806x: EA8500 fix boot partition detection
Remove extraneous code that disabled boot partition detection.

Fixes: b3770eaca3 ("mtd: base-files: Unify dual-firmware devices (Linksys)")
Signed-off-by: Samantha Collard <sammyrc34@gmail.com>
2020-05-31 15:44:05 +02:00
Yanase Yuki d97c9bae81 ipq806x: read both WG2600HP MAC addresses from flash
WG2600HP has its WLAN MAC addresses at PRODUCTDATA 0xc and 0x12, so
use them both directly.

Signed-off-by: Yanase Yuki <dev@zpc.sakura.ne.jp>
[commit title/message clarification]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-03-16 16:53:47 +01:00
Adrian Schmutzler c2ddc3a0c4 ipq806x: remove useless case within default case for upgrade
The default case will catch anything left, there is no need to
explicitly add any device to it.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2020-03-16 16:53:47 +01:00
David Bauer 70d5989c9c ipq806x: use switch trigger for WAN LED on NETGEAR boards
With this commit, the WAN LED is triggered by the switch port state
instead of the eth0 netdev.
Otherwise, the LED is always illuminated, regardless of the WAN port
link state.

Signed-off-by: David Bauer <mail@david-bauer.net>
2019-11-04 18:50:53 +01:00
Adrian Schmutzler 48b5d08a48 treewide: use a single ath10k MAC patching function with checksum
While all ath10k eeproms have a checksum field, so far two
functions for patching ath10k MAC address have been present (and
been used).

This merges code to provide a single function ath10k_patch_mac
in caldata.sh, having its name in accordance with ath9k functions.
By doing so, correct MAC patching for current and future ath10k
devices should be ensured.

This patch adds checksum adjustments for several targets on
ath79 and lantiq.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-10-15 18:13:54 +02:00
Adrian Schmutzler 2c60de0e3f treewide: move MAC address patch functions to common library
This unifies MAC address patch functions and moves them to a
common script. While those were implemented differently for
different targets, they all seem to do the same. The number of
different variants is significantly reduced by this patch.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-10-14 12:36:02 +02:00
Adrian Schmutzler 5b6a809092 treewide: move calibration data extraction function to library
This moves the almost identical calibration data extraction
functions present multiple times in several targets to a single
library file /lib/functions/caldata.sh.

Functions are renamed with more generic names to merge different
variants that only differ in their names.

Most of the targets used find_mtd_chardev, while some used
find_mtd_part inside the extraction code. To merge them, the more
abundant version with find_mtd_chardev is used in the common code.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
[rebase on latest master; add mpc85xx]
Signed-off-by: David Bauer <mail@david-bauer.net>
2019-10-13 21:48:58 +02:00
Adrian Schmutzler c1388a2deb base-files: move xor() from caldata extraction to functions.sh
The xor() function is defined in each of the caldata extraction
scripts for several targets. Move it to functions.sh to reduce
duplicate code.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-10-13 19:03:57 +02:00
Rafał Miłecki 641f6b6c26 treewide: use new procd sysupgrade $UPGRADE_BACKUP variable
It's a variable set by procd that should replace hardcoded
/tmp/sysupgrade.tgz.

This change requires the most recent procd with the commit 0f3c136
("sysupgrade: set UPGRADE_BACKUP env variable").

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
2019-09-05 23:33:19 +02:00
Rafał Miłecki 62dbe361a1 treewide: when copying a backup file always specify dest name
$CONF_TAR shouldn't be assumed to always point to the sysupgrade.tgz.
This change makes code more generic and allows refactoring $CONF_TAR.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
2019-09-05 14:33:20 +02:00
Rafał Miłecki bf39047872 treewide: don't hardcode "sysupgrade.tgz" file name
1) Add BACKUP_FILE and use it when copying an archive to be restored
   after sysupgrade (on the next preinit).
2) Use CONF_TAR for copying backup prepared by the /sbin/sysupgrade

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
2019-09-05 14:33:19 +02:00
Adrian Schmutzler d94a3f328f ipq806x: Replace backticks by $(...)
This replaces deprecated backticks by more versatile $(...) syntax.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-08-31 12:08:23 +02:00
Chuanhong Guo 92e60260d5 treewide: sync bootcount scripts across targets
This commit made the following changes to sync all bootcount scripts:

1. use boot() instead of start()
    This script only needs to be executed once when boot is complete.
    use boot() to make this explicit.

2. drop sourcing of /lib/functions.sh
    This is aready done in /etc/rc.common.

3. ramips: replace board name checking with a case

Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
2019-08-17 23:52:34 +08:00
Adrian Schmutzler b133e466b0
treewide: convert WiFi caldata size and offset to hexadecimal
This changes size and offset set for WiFi caldata extraction and
MAC address adjustment to hexadecimal notation.

This will be much clearer for the reader when numbers are big, and
will also match the style used for mtd-cal-data in DTS files.

Since dd cannot deal with hexadecimal notation, one has to convert
back to decimal by simple $(($hexnum)).

Acked-by: Alexander Couzens <lynxis@fe80.eu>
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-08-14 12:36:37 +02:00
Adrian Schmutzler 75bfc393ba treewide: convert MAC address location offsets to hexadecimal
This changes the offsets for the MAC address location in
mtd_get_mac_binary* and mtd_get_mac_text to hexadecimal notation.

This will be much clearer for the reader when numbers are big, and
will also match the style used for mtd-mac-address in DTS files.

(e.g. 0x1006 and 0x5006 are much more useful than 4102 and 20486)

Acked-by: Alexander Couzens <lynxis@fe80.eu>
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2019-08-14 12:10:12 +02:00
Rafał Miłecki 1cbe0d659c treewide: sysupgrade: get rid of platform_nand_pre_upgrade()
1) nand_do_upgrade() is always called by a target code
2) nand_do_upgrade() starts with calling platform_nand_pre_upgrade()

It means there is no need for the platform_nand_pre_upgrade() callback
at all. All code that was present there could bo moved & simplly called
by a target right before the nand_do_upgrade().

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
2019-07-22 14:27:37 +02:00