jeffsf
May 15, 2019, 12:09am
1
Edit: Drivers for GigaDevice and Paragon SPI-NAND accepted upstream. Since this thread started, I broke down and bought myself an AR300M. As a result, both devices are supported by the PR shown below.
Having an AR750S running GL.iNet v3 firmware through two weeks of travel made the mess of hotel wireless and VPN so much easier to deal with. If you’ve got the latest GL.iNet firmware running, unless you’re a developer, I’d stick with that for daily use.
Initial support for the AR750S (“Slate”) on the ath79 platform, Linux kernel 4.19, with the upstream SPI NAND framework has been submitted to OpenWrt. Current patch series is available at OpenWrt development - Patchwork
Note that these patches are subject to review and revision.
These patches, applied to OpenWrt master
, should provide images suitable for both sysupgrade from both NOR and NAND and U-Boot flashing through the usual OpenWrt build process.
The above patch set includes mtd: spinand: Add support for GigaDevice GD5F1GQ4UFxxG, in upstream (Linux) review at this time.
I can’t comment on when/if these will be accepted into either the OpenWrt project or the Linux project. As I don’t have an AR300M in hand, I don’t know what NAND is inside of it, so can’t easily know if it will be as straightforward to add as I hope to that it will be.
Thanks Jeff for your excellent work. Not sure what will happen but hopefully it can be accepted.
1 Like
If you’re not a developer, this code doesn’t provide any performance or utility advantages over the current GL.iNet v3 firmware .
There are no pre-built images, repos, or other niceties. Any comments or experiences you may have working with this code would be welcomed. Thanks to @luochongjun for help testing the Paragon driver.
openwrt:master
← jeffsf:ath79-nand-pr
opened 07:29PM - 30 Jun 19 UTC
# Overview
This series of commits prepares for use of SPI-NAND from the upstr… eam Linux MTD framework for the ath79 target. It addresses upgrade issues associated with tar-style files and metadata, allowing "force-less" upgrade paths from ar71xx to ath79 builds, including from previous NOR builds to ath79 builds that support NAND.
Addresses comments in previous PRs around SPI-NAND support, including
https://github.com/openwrt/openwrt/pull/615
https://github.com/openwrt/openwrt/pull/1428#issuecomment-441594401
in the manner requested by @mkresin
> Please re-spin [PR 1428] as soon as we have kernel 4.19 support.
SPI-NAND support in this PR utilizes the upstream Linux framework, as requested.
The GL.iNet GL-AR300M and GL-AR750S devices are then supported using NAND with this framework.
The commits have been resequenced here from the order in which they were developed to provide clearer patches, rather than the original "find a problem and fix it" order. As a result, the reasoning behind some of the preliminary set of commits may not be completely clear until the devices are added in subsequent commits.
Original development done on `master` prior to the 19.07 branch and the change to Linux 4.19 for the ath79 target. This series should be able to be backported to v19 by adding `KERNEL_PATCHVER:=4.19` to `target/linux/ath79/nand/target.mk`
Boot logs and/or upgrade logs of any configuration or transition available on request.
# Roadmap of Commits
These logical "chunks" of commits are denoted in [my GitHub repo](https://github.com/jeffsf/openwrt) as tags. The links within each chunk's description below will show the commits and changes associated with each chunk.
The tags will be updated should this PR be rebased or changed prior to merge, keeping the tag-based links usable.
In addition to the supplied links, the tags are available in clones of my repo for local examination and exploration of the commits in this PR, without the need to apply remote patches to a local repo.
```
pr2184-00-merge_base
pr2184-04-Prepare_ath79-nand_target
pr2184-05-Enable_robust_upgrades
pr2184-06-GL-AR300M_NAND_support
pr2184-07-Add_GL-AR300M16
pr2184-08-GL-AR750S_NAND_support
```
Accepted from Patchwork:
* <strike>pr2184-01-Add_I2C_support</strike>
* <strike>pr2184-02-uboot-envtools_support_for_GL-AR300M-Lite</strike>
Superseded by commit 5b6a809092 and related:
* <strike>pr2184-03-Refactor_of_common_functions</strike>
## Prepare ath79-nand Target
<strike>* ath79: Remove legacy GL.iNet GL-AR300M NAND target
Removal for reimplementation [confirmed with original author](http://lists.infradead.org/pipermail/openwrt-devel/2019-May/017190.html).</strike>
Retained and _replaced_ on suggestion of @adrianschmutzler
* ath79: Prepare NAND subtarget for upstream support of SPI NAND
Use of subtarget-specific `nand/base-files/` makes this a lot cleaner and doesn't impact the generic or tiny targets.
Examination of the tiny target (and the one-board nature of `base-files/lib/functions/k2t.sh`) suggest that a few kB might be saved for the tiny target by similarly splitting out its own files from those for the generic target. This refactoring of the generic and tiny sub-targets was not performed. _(See further https://patchwork.ozlabs.org/patch/1181653/ by @adrianschmutzler for the ath79 target and https://github.com/openwrt/openwrt/pull/2513 for the ramips target.)_
https://github.com/jeffsf/openwrt/compare/jeffsf:pr2184-00-merge_base...jeffsf:pr2184-04-Prepare_ath79-nand_target
_Also available as https://patchwork.ozlabs.org/patch/1186259/_
## Enable Robust Upgrades
* build: sysupgrade-tar alt-board= for legacy upgrades
Existing sysupgrade tooling on the ar71xx platform isn't able to upgrade to ath79 NAND images, even with the use of SUPPORTED_DEVICES.
* sysupgrade: NAND: Prefer CONTROL for board, improve robustness
Rather than taking the first directory found in the tar as that from which the assets are obtained, trust the contents of the CONTROL file found. Though the CONTROL file could be fed to sh, parse it somewhat robustly to allow for a transition to JSON or other formats in the future.
grep -m 1 -o -E "\bBOARD=[^[:space:]'\"]+"
Exploration of legacy flashing revealed some "interesting" behavior of the NAND upgrade process off the "happy path". The most egregious were addressed.
Unmodified, `nand_do_upgrade_success()` continues to perform a reboot rather than returning. This continues to prevent boards from checking that the flash was successful prior to changing the next-boot partition. Do to the invasiveness of changing this, it was not refactored at this time. Future refactor of this should also consider using the existing `$CONF_TAR` rather than the hard-coded `local conf_tar="/tmp/sysupgrade.tgz"`
Error-checking was examined, but between the above concerns and the challenges on getting return codes from pipelined commands under `sh` (neither `pipefail` nor `PIPESTATUS` are available) it was not further pursued. Initial thoughts were that non-zero error codes might be split into those that were still bootable ("warnings") and those that were not bootable ("errors"), perhaps as positive and negative for ease of consistent implementation.
https://github.com/jeffsf/openwrt/compare/jeffsf:pr2184-04-Prepare_ath79-nand_target...jeffsf:pr2184-05-Enable_robust_upgrades
_Also available as https://patchwork.ozlabs.org/project/openwrt/list/?series=138554_
## GL-AR300M NAND Support
With the previous support in place, the boards can be added. Features such as access to NAND storage while booted under NOR (intentionally, or as a result of boot-count based fail over) and flashing either NOR-based or NAND-based firmware are provided.
Legacy NOR boards may be transitioned to full support of NAND without serial, U-Boot access, or use of "force" in sysupgrade. For example
Legacy NOR ==> glinet,gl-ar300m-nor ==> glinet,gl-ar300m-nand
Direct transition to glinet,gl-ar300m-nand from a NOR kernel is not possible and is prevented by checks already in place within sysupgrade. For example:
```
LEDE_RELEASE="OpenWrt 18.06.2 r7676-cddd7b4c77"
"model": {
"id": "gl-ar300m",
"name": "GL.iNet GL-AR300M"
},
root@OpenWrt:/# sysupgrade /tmp/OpenWrt-2019-06-29_0807-0700-ath79-nand-glinet_g
l-ar300m-nand-squashfs-sysupgrade.bin
Invalid image type.
Image check 'platform_check_image' failed.
```
https://github.com/jeffsf/openwrt/compare/jeffsf:pr2184-05-Enable_robust_upgrades...jeffsf:pr2184-06-GL-AR300M_NAND_support
## Add GL-AR300M16
As the glinet,gl-ar300m-nor board was moved to the NAND target in the previous commits, there is not a "generic" build suitable for the dual-port, NAND-less GL-AR300M16, or for users of the GL-AR300M that do not need access to the NAND (which adds ~320 kB at this time).
This commit clearly disambiguates the "generic" (NOR-only) build and its primary, intended device from the NAND-aware build.
[https://github.com/jeffsf/openwrt/compare/jeffsf:pr2184-06-GL-AR300M\_NAND\_support...jeffsf:pr2184-07-Add\_GL-AR300M16](https://github.com/jeffsf/openwrt/compare/jeffsf:pr2184-06-GL-AR300M_NAND_support...jeffsf:pr2184-07-Add_GL-AR300M16)
## GL-AR750S NAND Support
Two variants are provided, one with root file system on NOR flash, the other with it on NAND flash. Consistent with the OEM firmware at this time, the kernel always resides on NOR flash.
As noted in the commit message, the "glinet,gl-ar750s-nand" board name is reserved for a potential, future build that boots its kernel from NAND flash. It is likely that change to the U-Boot would be required to boot off NAND, either from the manufacturer or a third party. The current U-Boot provides for updating itself through an HTTP interface, without serial connectivity being required.
[https://github.com/jeffsf/openwrt/compare/jeffsf:pr2184-07-Add\_GL-AR300M16...pr2184-08-GL-AR750S\_NAND\_support](https://github.com/jeffsf/openwrt/compare/jeffsf:pr2184-07-Add_GL-AR300M16...pr2184-08-GL-AR750S_NAND_support)