aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/files/drivers/mtd
Commit message (Collapse)AuthorAgeFilesLines
* kernel: mtdsplit_fit: support FIT with external dataDaniel Golle2021-04-091-39/+243
| | | | | | | | | | | | | | | | | | U-Boot has recently added support for having data blobs in uImage.FIT images stored at offsets after the FDT structure rather than embedding the data into the FDT structure itself. This is useful as it allows parts of the image to be mapped by the FIT partition parser, and it allows the FIT structure itself to be parsed more easily as it usually fits into single page. mtdsplit_fit assumed that the total length of an image is identical to the length of the FDT structure. For uImage.FIT with external data this assumption no longer holds true. Add support for uImage.FIT with external data to mtdsplit_fit and in in that case only split-off rootfs_data -- selecting and mapping rootfs partition is left to the block partition parser just like on UBI and block/GPT based platforms. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* kernel: create bootfs partition when parsing on BCM4908Rafał Miłecki2021-03-241-5/+9
| | | | | | | | It's helpful for accessing booting data (DTS, kernel, etc.). It has to be used carefully as CFE's JFFS2 support is quite dumb. It doesn't recognize deleted files and has problems handling 0 inode. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* kernel: add support for enabling fit firmware partition parser via cmdlineFelix Fietkau2021-02-281-0/+6
| | | | | | | | | This is useful for dual-boot setups where the loader sets variables depending on the flash boot partition. For example the Linksys E8450 sets mtdparts=master for the first partition and mtdparts=slave for the second one. Signed-off-by: Felix Fietkau <nbd@nbd.name>
* kernel: mtdsplit: add support for BCM63XX CFE firmwareÁlvaro Fernández Rojas2021-02-223-0/+192
| | | | | | | | Broadcom CFE bootloader relies on a tag for identifying the current firmware, such as version, image start address, kernel address and size, rootfs size, board id, signatures, etc. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
* kernel: mtdsplit_uimage: replace "edimax, uimage" parserBjørn Mork2021-01-221-99/+30
| | | | | | | | The "edimax,uimage"" parser can be replaced by the generic parser using device specific openwrt,partition-magic and openwrt,offset properties. Signed-off-by: Bjørn Mork <bjorn@mork.no>
* kernel: mtdsplit_uimage: add "openwrt, offset" and "openwrt, partition-magic"Bjørn Mork2021-01-221-12/+28
| | | | | | | | Some devices prepend a standard U-Boot Image with a vendor specific header, having its own magic. Adding two new properties will support validation of such images, including the additional magic. Signed-off-by: Bjørn Mork <bjorn@mork.no>
* kernel: mtdsplit_uimage: replace "netgear, uimage" parserBjørn Mork2021-01-221-67/+0
| | | | | | | | | | | | | | | | | | | The "netgear,uimage" parser can be replaced by the generic parser using device specific openwrt,ih-magic and openwrt,ih-type properties. Device tree properties for the following devices have not been set, as they have been dropped from OpenWrt with the removal of the ar71xx target: FW_MAGIC_WNR2000V1 0x32303031 FW_MAGIC_WNR2000V4 0x32303034 FW_MAGIC_WNR1000V2_VC 0x31303030 FW_MAGIC_WPN824N 0x31313030 Tested-by: Sander Vanheule <sander@svanheule.net> # WNDR3700v2 Tested-by: Stijn Segers <foss@volatilesystems.org> # WNDR3700v1 Signed-off-by: Bjørn Mork <bjorn@mork.no>
* kernel: mtdsplit_uimage: add "openwrt, ih-type" device-tree propertyBjørn Mork2021-01-221-10/+14
| | | | | | | Some devices use uimage headers with a non-default ih_type. Add support for overriding this in device tree. Signed-off-by: Bjørn Mork <bjorn@mork.no>
* kernel: mtdsplit_uimage: replace "allnet, uimage" parserBjørn Mork2021-01-221-49/+0
| | | | | | | Convert users to the generic "openwrt,uimage" using device specific "openwrt,ih-magic" properties, and remove "allnet,uimage". Signed-off-by: Bjørn Mork <bjorn@mork.no>
* kernel: mtdsplit_uimage: replace "openwrt, okli" parserBjørn Mork2021-01-221-53/+0
| | | | | | | | | The only difference between the "openwrt,okli" and the generic parser is the magic. Set this in device tree for all affected devices and remove the "openwrt,okli" parser. Tested-by: Michael Pratt <mcpratt@protonmail.com> # EAP300 v2, ENS202EXT and ENH202 Signed-off-by: Bjørn Mork <bjorn@mork.no>
* kernel: mtdsplit_uimage: add "openwrt, ih-magic" device-tree propertyBjørn Mork2021-01-221-18/+23
| | | | | | | Many devices use uimages with non-standard magic values. Let device tree override the default magic. Signed-off-by: Bjørn Mork <bjorn@mork.no>
* kernel: mtdsplit_uimage: replace "fonfxc" and "sge" parsersBjørn Mork2021-01-221-85/+8
| | | | | | | | Convert users of the "fonfxc" and "sge" parsers to the generic "openwrt,uimage", using device specific "openwrt,padding" properties. Tested-by: Stijn Segers <foss@volatilesystems.org> [DIR-878 A1] Signed-off-by: Bjørn Mork <bjorn@mork.no>
* kernel: mtdsplit_uimage: read extralen from device treeBjørn Mork2021-01-221-10/+14
| | | | | | | An "openwrt,padding" property in device tree can replace two device specific parsers. Signed-off-by: Bjørn Mork <bjorn@mork.no>
* kernel: add parser finding rootfs after CFE bootfsRafał Miłecki2021-01-223-0/+99
| | | | | | | | | | | | | | It's required for BCM4908. It cannot use "bcm-wfi-fw" parser because that one requires *two* JFFS2 partitions which is untested / unsupported on the BCM4908 architecture. With a single JFFS2 partition "bcm-wfi-fw" parser will: 1. Fail to find "vmlinux.lz" as it doesn't follow "1-openwrt" file 2. Create partitions that don't precisely match bootfs layout The new parser is described in details in the MTD_SPLIT_CFE_BOOTFS symbol help message. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* kernel: add GS110TPPV1 support to mtdsplit_uimageJohn Crispin2020-11-261-3/+5
| | | | | | The ID is used be a Realtek based switch made by Netgear. Signed-off-by: John Crispin <john@phrozen.org>
* kernel: rename mtdpart_get_master to mtd_get_masterFelix Fietkau2020-11-131-1/+1
| | | | | | Preparation for supporting newer kernels Signed-off-by: Felix Fietkau <nbd@nbd.name>
* kernel: add support for ALLNET devices in mtdsplitBirger Koblitz2020-09-141-0/+50
| | | | | | | Add support for uimage headers from ALLNET and provide support for the SG8208M and SG8310PM devices' magic bytes. Signed-off-by: Birger Koblitz <git@birger-koblitz.de>
* kernel: mtdsplit: support ELF loader splittingSander Vanheule2020-09-093-0/+293
| | | | | | | | | | | | | | | | | | | | | | | | | To parse the ELF kernel loader, a small ELF parser is used that can handle both ELF32 or ELF64 class loaders. The splitter assumes that the kernel is always located before the rootfs, whether it is embedded in the loader or not. If the kernel is located after the rootfs on the firmware partition, then the rootfs splitter will include it in the dynamically created rootfs_data partition and the kernel will be corrupted. The kernel image is preferably embedded inside the ELF loader, so the end of the loader equals the end of the kernel partition. This is due to the way mtd_find_rootfs_from searches for the the rootfs: - if the kernel image is embedded in the loader, the appended rootfs may follow the loader immediately, within the same erase block. - if the kernel image is not embedded in the loader, but placed at some offset behind the loader (OKLI-style loader), the rootfs must be aligned to an erase-block after the loader and kernel image. In case section header table is empty, determine the elf loader size by finding the end of the last segment, as defined by the program header table. Signed-off-by: Sander Vanheule <sander@svanheule.net>
* kernel: mtdsplit_uimage: add SGE parserMathieu Martin-Borret2020-07-131-0/+38
| | | | | | | Adding SGE parser for SGE (T&W) Shenzhen Gongjin Electronics to add 96 bytes padding the the firmware image Signed-off-by: Mathieu Martin-Borret <mathieu.mb@protonmail.com>
* kernel: mtdsplit: bcm_wfi: always add img partitionsÁlvaro Fernández Rojas2020-06-031-9/+44
| | | | | | | | | This is useful when booting OpenWrt from ramdisks in order to have both images partitions defined. Furthermore, instead of always using img2 for the inactive image, let's use img1 or img2 accordingly. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
* kernel: mtdsplit: support Broadcom WFI bootflagsÁlvaro Fernández Rojas2020-06-021-0/+110
| | | | | | | | When firmware is flashed, cferam.000 extension is renamed to the next number. When booting, CFE scans the NAND and picks the partition with the highest cferam extension and ignores the other one. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
* kernel: mtdsplit: improve JFFS2 scanÁlvaro Fernández Rojas2020-06-021-6/+20
| | | | | | Allow retrieving full file name and length by parameters. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
* kernel: mtdsplit: bcm_wfi: refactor codeÁlvaro Fernández Rojas2020-06-021-82/+69
| | | | | | Create new parse_bcm_wfi function with common code from current parsers. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
* kernel: mtdsplit: bcm_wfi: remove brcm,wfi-sercomm compatibilityÁlvaro Fernández Rojas2020-06-021-2/+1
| | | | | | | The only Sercomm WFI user has been migrated to a dedicated firmware parser. Keep support for no cferam partition based on a boolean DT property. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
* kernel: mtdsplit: bcm_wfi: support Sercomm bootflagsÁlvaro Fernández Rojas2020-06-021-0/+148
| | | | | | | | Sercomm uses 2 bootflag partitions and boots the firmware with the highest bootflag. Support splitting the firmware partition while keeping support for unsplitted layout. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
* kernel: mtdsplit: bcm_wfi: code refactoringÁlvaro Fernández Rojas2020-06-021-15/+18
| | | | | | | | - Rename master to mtd. - Pass mtd size as an argument. - Rename of_match_table. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
* generic: routerbootpart.c: disambiguate SPDX-License-IdentifierThibaut VARÈNE2020-05-201-1/+1
| | | | | | I meant it to be GPL-2.0-only, as evidenced by the boilerplate. Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
* kernel: mtdsplit: bcm_wfi: add sercomm supportÁlvaro Fernández Rojas2020-05-191-23/+47
| | | | | | SERCOMM creates separates partitions for cferam. Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
* kernel: mtdsplit: add BCM WFI supportÁlvaro Fernández Rojas2020-05-183-0/+209
| | | | Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
* generic: drop outdated kernel version switches in local driversAdrian Schmutzler2020-05-171-20/+0
| | | | | | | This drops the obsolete version switches for non-supported kernels from local drivers in generic target. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
* generic: routerbootpart MTD parser for RouterBootThibaut VARÈNE2020-05-081-0/+365
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This driver provides an OF MTD parser to properly assign the RouterBoot partitions on the flash. This parser builds from the "fixed-partitions" one (see ofpart.c), but it can handle dynamic partitions as found on routerboot devices. The parent node must contain the following: compatible = "mikrotik,routerboot-partitions"; #address-cells = <1>; #size-cells = <1>; Children routerbootpart DTS nodes are defined as follows: For fixed partitions node-name@unit-address { reg = <prop-encoded-array>; label = <string>; read-only; lock; }; All properties but reg are optional. For dynamic partitions: node-name { size = <prop-encoded-array>; label = <string>; read-only; lock; }; size property is mandatory unless the next partition is a fixed one or a "well-known" one (matched from the strings defined below) in which case it can be omitted or set to 0; other properties are optional. By default dynamic partitions are appended after the preceding one, except for "well-known" ones which are automatically located on flash. Well-known partitions (matched via label or node-name): - "hard_config" - "soft_config" - "dtb_config" This parser requires the DTS to list partitions in ascending order as expected on the MTD device. This parser has been successfully tested on BE (ath79) and LE (ipq40xx and ramips) hardware. Tested-by: Baptiste Jonglez <git@bitsofnetworks.org> Tested-by: Roger Pueyo Centelles <roger.pueyo@guifi.net> Tested-by: Tobias Schramm <t.schramm@manjaro.org> Tested-by: Christopher Hill <ch6574@gmail.com> Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
* kernel: fix include of myloader.o since kernel 5.4Adrian Schmutzler2020-04-241-182/+0
| | | | | | | | | | | | | | | | | | | | | | Between 4.19 and 5.4, mtd parsers have been moved to "parsers" subdirectory. Based on this, the selection of myloader.o in OpenWrt was also moved to that subdirectory, while the Kconfig and our local myloader.c file remained in /drivers/mtd. This resulted in linking errors like the following (on ath25@5.4): make[8]: *** No rule to make target 'drivers/mtd/parsers/myloader.o', ... needed by 'drivers/mtd/parsers/built-in.a'. Stop. make[7]: *** [scripts/Makefile.build:500: drivers/mtd/parsers] Error 2 make[6]: *** [scripts/Makefile.build:500: drivers/mtd] Error 2 Since myloader.c is not too big, this patch moves it to the kernel patches, allowing to adjust the path for kernel 5.4 and keeping Makefiles and file paths better in sync. Other patches have been refreshed accordingly. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
* kernel: Fix off-by-one error in FIT mtd partition search.Oldřich Jedlička2019-10-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This fixes off-by-one error introduced in commit dc76900021b8 ("kernel: Correctly search for the FIT image in mtd partition.") Function `mtd_read` starts reading at `offset` and needs `hdr_len` number of bytes to be available. Suppose the easiest case when `offset` is `0` and `hdr_len` equals to `mtd->size` - the `for` loop will not be entered even when enough bytes are available to be read. Same happens for any non-zero `offset`, when `hdr_len` is just enough bytes to be read until `mtd->size` is reached. Imagine that for example `mtd->size=5`, `offset=4` and `hdr_len=1`. Then `offset+hdr_len=5` and the check has to be `offset+hdr_len <= mtd->size`, i.e. `5 <= 5`. The check for `offset + hdr_len` value needs to be inclusive, therefore use `<=`. Fixes: dc76900021b8 ("kernel: Correctly search for the FIT image in mtd partition.") Signed-off-by: Oldřich Jedlička <oldium.pro@gmail.com> [adjusted commit ref, fixes tag] Signed-off-by: Petr Štetiar <ynezz@true.cz>
* kernel: Correctly search for the FIT image in mtd partition.Fredrik Olofsson2019-09-191-2/+2
| | | | | | Previously all iterations of the loop checked offset=0 in the partition. Signed-off-by: Fredrik Olofsson <fredrik.olofsson@anyfinetworks.com>
* kernel: mtdsplit_uimage: add support for okli imageChuanhong Guo2019-08-081-0/+58
| | | | | | | | | | This adds support for uImage used by OpenWrt kernel loader. The parser searches for uImage header at flash eraseblock boundary and it might attempt to split any firmware with loader, therefore this entry doesn't have MTD_PARSER_TYPE_FIRMWARE so that this parser is only used when explicitly defined in dts. Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
* kernel: drop Fon(Foxconn) parser matching for the "firmware" partitionRafał Miłecki2019-08-061-1/+0
| | | | | | | | | | | | | | | | This parser's matching function appears to be too generic as it matches e.g. Buffalo WZR-HP-G300NH. That results in incorrect parts parsing. Luckily this parser is needed by Fon FON2601 only which uses DT-based ramips target. It means we can depend on mtd subsystem matching of "fonfxc,uimage" string. That said triggering this parser based on the "firmware" (or whatever MTD_SPLIT_FIRMWARE_NAME is) partiiton name is not needed. It can be dropped which will automatically fix the Buffalo WZR-HP-G300NH case. Fixes: a1c6a316d299 ("ramips: add support for Fon FON2601") Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* Revert "kernel: generic: fix fonfxc uimage parser"Rafał Miłecki2019-08-061-14/+7
| | | | | | | | | | | | | | | | | This reverts commit e92a14709d37f64dcba8c81fa51e61e5f10f439a. mtdsplit_uimage_parse_fonfxc() gets called in two situations: 1) It was /requested/ from DT using "fonfxc,uimage" compatible string 2) It was called by parsing code after finding "firmware" (MTD_SPLIT_FIRMWARE_NAME) due to the parser's type Code added in the /fix/ commit basically just disabled the second case. If that's the real goal it could be achieved by simply dropping type MTD_PARSER_TYPE_FIRMWARE. It may however require another solution as it's possible that some non-DT target actually needs fonfxc uImage parsing. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* kernel: generic: fix fonfxc uimage parserNOGUCHI Hiroshi2019-08-041-7/+14
| | | | | | | | | | | | | | | | We cannot distinguish between fonfxc uImage and generic uImage because fonfxc uImage header is almost same as generic uImage, except padding length after image name. The fonfxc uImage parser is available when specifying directly with DT compatible property. So this patch adds check if the partition DT node is compatible with the parser. Ref: https://bugs.openwrt.org/index.php?do=details&task_id=2413 Fixes: a1c6a316d299 ("ramips: add support for Fon FON2601") Signed-off-by: NOGUCHI Hiroshi <drvlabo@gmail.com> [commit light touches and removed C code comment] Signed-off-by: Petr Štetiar <ynezz@true.cz>
* ramips: add support for Fon FON2601NOGUCHI Hiroshi2019-07-261-12/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | FON2601 is a wireless router. Specification: - SoC: Mediatek MT7620A (580MHz) - RAM: 128 MiB - ROM: 16 MiB SPI Flash - Wireless: for 11b/g/n (upto 300 Mbps): MT7620A built-in WMAC for 11a/n/ac (upto 867 Mbps): MT7662E - Ethernet LAN: 1 port, upto 100 Mbps - Ethernet WAN: 1 port, upto 1000 Mbps - USB: 1 port (USB 2.0 host) - LEDs: 4 (all can be controlled by SoC's GPIO) - buttons: 1 (Displayed as "WPS" on enclosure) - serial port: 57600n8 pins: Vcc(3.3V), Rx, Tx, GND (left to right, viewed from outside of board) Installation (only available via UART): 1. download sysupgrade binary image by wget command 2. write sysupgrade binary image to Flash command is: mtd write sysupgrade.bin firmware 3. reboot Important Notice: Only one button is displayed as "WPS" on enclosure. However, it is configured as "reset" (factory resetting feature). Signed-off-by: NOGUCHI Hiroshi <drvlabo@gmail.com> [removed unrelated openwrt-keyring revert, missing -Wall for uimage_padhdr] Signed-off-by: Petr Štetiar <ynezz@true.cz>
* kernel: Add missing includes mtdsplit_*.cHauke Mehrtens2019-07-079-0/+9
| | | | | | | | | | | This fixes the following compile problem with kernel 4.9 on lantiq: drivers/mtd/mtdsplit/mtdsplit_uimage.c:244:34: error: array type has incomplete element type 'struct of_device_id' static const struct of_device_id mtdsplit_uimage_of_match_table[] = { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/mtd/mtdsplit/mtdsplit_uimage.c:245:4: error: field name not in record or union initializer { .compatible = "denx,uimage" }, Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
* kernel: mtdsplit: wrgg: Support big and little endianLinus Walleij2019-03-131-0/+10
| | | | | | | | | | | | | | | | | | | The WRGG images exist in both big and little endian variants, as can be seen from the image generator in tools/firmware-utils/src/mkwrggimg.c, you either pass the "-b" flag or not. The D-Link DIR-685 is using little endian images so we need to support splitting these. Detect endianness like this: if the kernel entity size gets silly big (bigger than the flash memory) we are probably using the wrong endianness. Example: my kernel of 0x0067ff64 was switched around by wrong endianness and detected as 0x64ff67a0 (the actual size in swapped endianness + header 0xa0). Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
* kernel: add DT binding support to the Edimax uImage parserMathias Kresin2019-01-191-0/+10
| | | | | | It allows specifying those parsers directly in the DT. Signed-off-by: Mathias Kresin <dev@kresin.me>
* kernel: add DT binding support to the fit parserChristian Lamparter2018-12-171-0/+6
| | | | | | It allows specifying default and Netgear parsers directly in the DT. Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
* kernel: drop unneeded LINUX_VERSION_CODE checksRafał Miłecki2018-12-135-28/+0
| | | | | | | All those parsers are used by 4.14 targets. They don't need that backward compatibility code. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* kernel: add DT binding support to the LZMA and WRG parsersRafał Miłecki2018-12-132-0/+14
| | | | | | It allows specifying those parsers directly in the DT. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* kernel: add DT binding support to the TRX and minor parsersRafał Miłecki2018-12-092-0/+26
| | | | | | It allows specifying those parsers directly in the DT. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* kernel: add DT binding support to AVM EVA parserDavid Bauer2018-12-061-0/+6
| | | | | | | It allows selecting split-firmware parser directly by specifying image-format in the device-tree. Signed-off-by: David Bauer <mail@david-bauer.net>
* kernel: add DT binding support to the jimage parserPawel Dembicki2018-11-301-0/+11
| | | | | | | | It allows specifying jimage parser directly in the DT. Tested on LAVA LR-25G001 Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
* kernel: add missing version.h include to the TP-LINK parserRafał Miłecki2018-11-241-0/+1
| | | | | Fixes: a29c8d685be7 ("kernel: add DT binding support to the TP-LINK parser") Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* kernel: add DT binding support to the TP-LINK parserRafał Miłecki2018-11-241-0/+10
| | | | | | It allows triggering it directly by specifying format in the DT. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>