ath79: add support for Fortinet FAP-221-B
authorMichael Pratt <mcpratt@pm.me>
Mon, 12 Dec 2022 09:55:34 +0000 (04:55 -0500)
committerHauke Mehrtens <hauke@hauke-m.de>
Fri, 6 Jan 2023 14:34:07 +0000 (15:34 +0100)
commite085812a7d7022c4bec948280efbcba738101636
tree611e0d848cf00c7843e74fa058dd80e471758e8c
parentee87dbb3fef2c0771b20967ec4a8638fdab9c9bf
ath79: add support for Fortinet FAP-221-B

FCC ID: U2M-CAP4100AG

Fortinet FAP-221-B is an indoor access point with
1 Gb ethernet port, dual-band wireless,
internal antenna plates, and 802.3at PoE+

Hardware and board design from Senao

**Specification:**

 - AR9344 SOC 2G 2x2, 5G 2x2, 25 MHz CLK
 - AR9382 WLAN 2G 2x2 PCIe, 40 MHz CLK
 - AR8035-A PHY RGMII, PoE+ IN, 25 MHz CLK
 - 16 MB FLASH MX25L12845EMI-10G
 - 2x 32 MB RAM W9725G6JB-25
 - UART at J11 populated, 9600 baud
 - 6 LEDs, 1 button power, ethernet, wlan, reset

  Note: ethernet LEDs are not enabled
because a new netifd hotplug is required
in order to operate like OEM.
Board has 1 amber and 1 green
for each of the 3 case viewports.

**MAC addresses:**

1 MAC Address in flash at end of uboot
ASCII encoded, no delimiters
Labeled as "MAC Address" on case
OEM firmware sets offsets 1 and 8 for wlan

  eth0 *:1e uboot 0x3ff80
  phy0 *:1f uboot 0x3ff80 +1
  phy1 *:26 uboot 0x3ff80 +8

**Serial Access:**

Pinout: (arrow) VCC GND RX TX

Pins are populated with a header and traces not blocked.
Bootloader is set to 9600 baud, 8 data, 1 stop.

**Console Access:**

Bootloader:

Interrupt boot with Ctrl+C
Press "k" and enter password "1"
OR
Hold reset button for 5 sec during power on
Interrupt the TFTP transfer with Ctrl+C

to print commands available, enter "help"

OEM:

default username is "admin", password blank
telnet is available at default address 192.168.1.2
serial is available with baud 9600

to print commands available, enter "help"
or tab-tab (busybox list of commands)

**Installation:**

Use factory.bin with OEM upgrade procedures
OR
Use initramfs.bin with uboot TFTP commands.
Then perform a sysupgrade with sysupgrade.bin

**TFTP Recovery:**

Using serial console, load initramfs.bin using TFTP
to boot openwrt without touching the flash.
TFTP is not reliable due to bugged bootloader,
set MTU to 600 and try many times.
If your TFTP server supports setting block size,
higher block size is better.
Splitting the file into 1 MB parts may be necessary

example:

$ tftpboot 0x80100000 image1.bin
$ tftpboot 0x80200000 image2.bin
$ tftpboot 0x80300000 image3.bin
$ tftpboot 0x80400000 image4.bin
$ tftpboot 0x80500000 image5.bin
$ tftpboot 0x80600000 image6.bin
$ bootm 0x80100000

**Return to OEM:**

The best way to return to OEM firmware
is to have a copy of the MTD partitions
before flashing Openwrt.

Backup copies should be made of partitions
"fwconcat0", "loader", and "fwconcat1"
which together is the same flash range
as OEM's "rootfs" and "uimage"
by loading an initramfs.bin
and using LuCI to download the mtdblocks.

It is also possible to extract from the
OEM firmware upgrade image by splitting it up
in parts of lengths that correspond
to the partitions in openwrt
and write them to flash,
after gzip decompression.

After writing to the firmware partitions,
erase the "reserved" partition and reboot.

**OEM firmware image format:**

Images from Fortinet for this device
ending with the suffix .out
are actually a .gz file

The gzip metadata stores the original filename
before compression, which is a special string
used to verify the image during OEM upgrade.

After gzip decompression, the resulting file
is an exact copy of the MTD partitions
"rootfs" and "uimage" combined in the same order and size
that they appear in /proc/mtd and as they are on flash.

OEM upgrade is performed by a customized busybox
with the command "upgrade".
Another binary, "restore"
is a wrapper for busybox's "tftp" and "upgrade".

Signed-off-by: Michael Pratt <mcpratt@pm.me>
target/linux/ath79/dts/ar9344_fortinet_ap-dual.dtsi [new file with mode: 0644]
target/linux/ath79/dts/ar9344_fortinet_fap-221-b.dts [new file with mode: 0644]
target/linux/ath79/dts/ar934x_fortinet_loader.dtsi [new file with mode: 0644]
target/linux/ath79/generic/base-files/etc/board.d/02_network
target/linux/ath79/generic/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
target/linux/ath79/generic/base-files/lib/preinit/10_fix_eth_mac.sh
target/linux/ath79/generic/base-files/lib/upgrade/platform.sh
target/linux/ath79/image/generic.mk