summaryrefslogtreecommitdiffstats
path: root/package/base-files/files/lib/functions
Commit message (Collapse)AuthorAgeFilesLines
* base-files: Add new functions for ath11k caldataPaweł Owoc2024-04-232-37/+65
| | | | | | | | | | | | Add new functions for ath11k caldata: - ath11k_patch_mac (from 0 to 5) - ath11k_remove_regdomain - ath11k_set_macflag (some pre-caldata have the nvMacFlag flag unset which is needed to change the MAC address) Additionaly for ath10k caldata: - ath10k_remove_regdomain Signed-off-by: Paweł Owoc <frut3k7@gmail.com>
* base-files: minor fix to mmc_get_mac_ascii functionRodrigo Balerdi2024-04-071-0/+1
| | | | | | | This is mostly a cosmetic cleanup. The absence of the return statement was not causing any problems. Signed-off-by: Rodrigo Balerdi <lanchon@gmail.com>
* base-files: move uci_set_poe() to uci-defaults.shSander Vanheule2024-02-121-0/+11
| | | | | | | | | PoE devices in the realtek target have the possibility to add PSE info to the board description via 02_network. Make this available for all targets, by moving the uci_set_poe() function to the globally available uci-default.sh script. Signed-off-by: Sander Vanheule <sander@svanheule.net>
* base-files: ipcalc.sh: Add tests for unroutable, etcPhilip Prindeville2023-12-121-0/+70
| | | | | | See RFC-1918, RFC-3927, and RFC-1122. Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
* base-files: ipcalc.sh: Add netmask2prefix functionPhilip Prindeville2023-12-121-0/+39
| | | | | | Also add is_contiguous to check if it's a valid netmask. Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
* base-files: ipcalc.sh: Add prefix-to-netmask conversionPhilip Prindeville2023-12-121-0/+13
| | | | | | | Seems like it might be used in other places, so factor it into the library. Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
* base-files: ipcalc.sh: Add some commentary, etc.Philip Prindeville2023-12-121-0/+6
| | | | | | | | Explain some of the more obscure logic, or where we deviate from what the original awk code did. Also, give a count of the usable addresses on the subnet. Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
* base-files: ipcalc.sh: Rewrite in pure shellPhilip Prindeville2023-12-121-0/+140
| | | | | | Also add better error checking on input. Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
* base-files: add mmc_get_mac_ascii functionDaniel Golle2023-12-091-5/+25
| | | | | | | | Similar to the *_get_mac_binary function, also split the common parts off mtd_get_mac_ascii into new get_mac_ascii function and introduce mmc_get_mac_ascii which uses it. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* base-files: support parse DT LED color and functionShiji Yang2023-12-021-0/+31
| | | | | | | | | The 'label' property in led node has been deprecated and we'd better to avoid using it. This patch allows us to extract DT OF LED name from the newly introduced LED properties "color", "function" and "function-enumerator". Signed-off-by: Shiji Yang <yangshiji66@qq.com>
* base-files: add additional uci-defaults function for GRO and conduitChristian Marangi2023-11-101-0/+8
| | | | | | | | | | | | | | Add additional uci-defaults function for configuring GRO settings and conduit for network devices. Tweaking the GRO values might increase performance on some low spec device that lack some offload feature on gmac. Tweaking conduit interface is specific to DSA based devices and is useful for multi-CPU scenario where one CPU is dedicated to one single port. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
* base-files: generalize ucidef_set_network_deviceChristian Marangi2023-11-101-7/+7
| | | | | | | | | | | Generalize ucidef_set_network_device functions to use a more generic _ucidef_set_network_device_common that takes as args the option and the value to apply instead of hardcoding. This is to reduce duplicated code in preparation for addition of additional option for board.d usage. Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
* base-files: fix wrong ucidef_set_network_device_mac network-device entryMichael 'ASAP' Weinrich2023-10-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | The ucidef_set_network_device_* functions in uci-defaults.sh disagree on whether to use "network-device" or "network_device" in board.json. With the additional caveat that jshn will translate hyphens (-) into underscores (_). This casues problems in netifd which expected "network_device" causing boards which depend on assigning MACs in board.json via uci-defaults.sh (or jshn in general) to fail. This commit addresses the issue by using network_device in uci-defaults.sh. The bug was uncovered in the forums here: https://forum.openwrt.org/t/support-for-rtl838x-based-managed-switches/57875/2596 This was exposed by commit 4ebba8a05d09 ("realtek: add support for HPE 1920-8g-poe+") where the board_config_load call from 03_gpio introduced the key normalization by jshn. Fixes: 9290539ca9c7 ("base-files: allow setting device and bridge macs") Tested-by: Stijn Segers <foss@volatilesystems.org> Signed-off-by: Michael 'ASAP' Weinrich <michael@a5ap.net> [ improve commit title, description and fix wrong Tested-by tag ] Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
* base-files: add support for retrieving IPv6 assignmentsMark Baker2023-02-241-0/+14
| | | | | | | In DHCPv6-PD enabled environments, addresses are assigned to interfaces. These new functions retrieve the IPv6 assigned prefix(es). Signed-off-by: Mark Baker <mark@vpost.net>
* base-files: rework mtd_get_mac_text()Michael Pratt2023-01-061-11/+5
| | | | | | | | | | | | | | It's necessary to be able to specify the length for MAC addresses that are stored in flash, for example, in a case where it is stored without any delimiter. Let both offset and length have default values. Add a sanity check related to partition size. Also, clean up syntax and unnecessary lines. Signed-off-by: Michael Pratt <mcpratt@pm.me>
* ramips: add basic support for tp-link er605-v2Nikolay Martynov2023-01-041-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a MT7621-based device with 128MB NAND flash, 256MB RAM, and a USB port. The board has headers to attach console. In order for them to work two solder bridges near those pads need to be made. The defice has the following partition table: ``` 0x000000000000-0x000000080000 : "u-boot" 0x000000080000-0x000000100000 : "u-boot-env" 0x000000100000-0x000000140000 : "factory" 0x000000140000-0x000007e00000 : "firmware" 0x000007e00000-0x000008000000 : "panic-ops" ``` `firmware` partition contains UBI volumes. Unfortunately I accidentally wiped partition and I no longer have access to it. `firmware` partition contains 'secondary' U-Boot which is run by 'first' u-boot. It also contains various configuration partitions that include device info and MAC address. There also seems to be 'primary' and 'backup' set of 'main' volumes. U-boot has `mtkupgrade` command that just overrides data on firmware partitions. Firmware file provided by TP-Link cannot be used with that command. U-boot also has 'recovery' http server. Unfortunately I was not able to make it work with manufacturer's firmware. Manufacturer's firmware essentially contains multiple UBI volumes along with 'partition table'. Unfortunately I no longer can properly run manufacturer's firmware so I cannot at the moment try to a support for building 'factory' images. This patch adds support for initramfs image as well as sysupgrade image. This seems to be pretty standard MT7621 board otherwise. Things that work: * network * leds * usb * factory MAC detection Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>
* sunxi: ensure NanoPi R1 has unique MAC addressJan-Niklas Burfeind2022-12-251-0/+8
| | | | | | | | | | | | | | | | | | | | Ensure the MAC address for all NanoPi R1 boards is assigned uniquely for each board. The vendor ships the device in two variants; one with and one without eMMC; but both without static mac-addresses. In order to assign both board types unique MAC addresses, fall back on the same method used for the NanoPi R2S and R4S in case the EEPROM chip is not present by generating the board MAC from the SD card CID. [0] https://wiki.friendlyelec.com/wiki/index.php/NanoPi_R1#Hardware_Spec Similar too and based on: commit b5675f500daf ("rockchip: ensure NanoPi R4S has unique MAC address") Co-authored-by: David Bauer <mail@david-bauer.net> Signed-off-by: Jan-Niklas Burfeind <git@aiyionpri.me>
* base-files: add helper functions for adding wlan device entries to board.jsonFelix Fietkau2022-10-142-0/+19
| | | | | | | | | | | These will be used to give WLAN PHYs a specific name based on path specified in board.json. The platform board.d script can assign a specific order based on available slots (PCIe slots, WMAC device) and device tree configuration. This helps with maintaining config compatibility in case the device path changes due to kernel upgrades. Signed-off-by: Felix Fietkau <nbd@nbd.name>
* base-files: Actually set default nameOlliver Schinagl2022-09-221-1/+1
| | | | | | | | | | | The currently used shell expansion doesn't seem to exist [0] and also does not work. This surely was not intended, so lets allow default naming to actually work. [0]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html Fixes: be09c5a3cd65 ("base-files: add board.d support for bridge device") Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
* ath79: add support for TP-Link Deco S4Nick French2022-09-111-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for TP-Link Deco S4 wifi router The label refers to the device as S4R and the TP-Link firmware site calls it the Deco S4 v2. (There does not appear to be a v1) Hardware (and FCC id) are identical to the Deco M4R v2 but the flash layout is ordered differently and the OEM firmware encrypts some config parameters (including the label mac address) in flash In order to set the encrypted mac address, the wlan's caldata node is removed from the DTS so the mac can be decrypted with the help of the uencrypt tool and patched into the wlan fw via hotplug Specifications: SoC: QCA9563-AL3A RAM: Zentel A3R1GE40JBF Wireless 2.4GHz: QCA9563-AL3A (main SoC) Wireless 5GHz: QCA9886 Ethernet Switch: QCA8337N-AL3C Flash: 16 MB SPI NOR UART serial access (115200N1) on board via solder pads: RX = TP1 pad TX = TP2 pad GND = C201 (pad nearest board edge) The device's bootloader and web gui will only accept images that were signed using TP-Link's RSA key, however a memory safety bug in the bootloader can be leveraged to install openwrt without accessing the serial console. See developer forum S4 support page for link to a "firmware" file that starts a tftp client, or you may generate one on your own like this: ``` python - > deco_s4_faux_fw_tftp.bin <<EOF import sys from struct import pack b = pack('>I', 0x00008000) + b'X'*16 + b"fw-type:" \ + b'x'*256 + b"S000S001S002" + pack('>I', 0x80060200) \ b += b"\x00"*(0x200-len(b)) \ + pack(">33I", *[0x3c0887fc, 0x35083ddc, 0xad000000, 0x24050000, 0x3c048006, 0x348402a0, 0x3c1987f9, 0x373947f4, 0x0320f809, 0x00000000, 0x24050000, 0x3c048006, 0x348402d0, 0x3c1987f9, 0x373947f4, 0x0320f809, 0x00000000, 0x24050000, 0x3c048006, 0x34840300, 0x3c1987f9, 0x373947f4, 0x0320f809, 0x00000000, 0x24050000, 0x3c048006, 0x34840400, 0x3c1987f9, 0x373947f4, 0x0320f809, 0x00000000, 0x1000fff1, 0x00000000]) b += b"\xff"*(0x2A0-len(b)) + b"setenv serverip 192.168.0.2\x00" b += b"\xff"*(0x2D0-len(b)) + b"setenv ipaddr 192.168.0.1\x00" b += b"\xff"*(0x300-len(b)) + b"tftpboot 0x81000000 initramfs-kernel.bin\x00" b += b"\xff"*(0x400-len(b)) + b"bootm 0x81000000\x00" b += b"\xff"*(0x8000-len(b)) sys.stdout.buffer.write(b) EOF ``` Installation: 1. Run tftp server on pc with static ip 192.168.0.2 2. Place openwrt "initramfs-kernel.bin" image in tftp root dir 3. Connect pc to router ethernet port1 4. While holding in reset button on bottom of router, power on router 5. From pc access router webgui at http://192.168.0.1 6. Upload deco_s4_faux_fw_tftp.bin 7. Router will load and execture in-memory openwrt 8. Switch pc back to dhcp or static 192.168.1.x 9. Flash openwrt sysupgrade image via luci/ssh at 192.168.1.1 Revert to stock: Press and hold reset button while powering device to start the bootloader's recovery mode, where stock firmware can be uploaded via web gui at 192.168.0.1 Please note that one additional non-github commits is also needed: firmware-utils: add tplink-safeloader support for Deco S4 Signed-off-by: Nick French <nickfrench@gmail.com>
* base-files: rename ethernet devs on known boardsMartin Kennedy2022-09-101-0/+8
| | | | | | | | | | | | | | | | Some platforms lack an established way to name netdevs; for example, on x86, PCIe-based ethernet interfaces will be named starting from eth0 in the order they are probed. This is a problem for many devices supported explicitly by OpenWrt which have hard-wired, standalone or on-CPU NICs not supported by DSA (which is usually used to rename the ports based on their ostensible function). To fix this, add a mapping between ethernet device name and sysfs device path to board.json; this allows us to configure ethernet device names we know about for a given board so that they correspond to external labeling. Signed-off-by: Martin Kennedy <hurricos@gmail.com>
* base-files: add mtd_get_mac_encrypted_arcadyan functionMikhail Zhilkin2022-08-191-0/+31
| | | | | | | | | Some Arcadyan devices (e.g. MTS WG430223) keep their config in encrypted mtd. This adds mtd_get_mac_encrypted_arcadyan() function to get the MAC address from the encrypted partition. Function uses uencrypt utility for decryption (and openssl if the uencrypt wasn't found). Signed-off-by: Mikhail Zhilkin <csharper2005@gmail.com>
* base-files: add support for heartbeat led triggerAlexey Smirnov2022-02-191-0/+9
| | | | | | | | | | | This patch adds support for creation heartbeat led trigger with, for example, this command: ucidef_set_led_heartbeat "..." "..." "..." from /etc/board.d/01_leds. Signed-off-by: Alexey Smirnov <s.alexey@gmail.com>
* base-files: add minimal mmc supportDavide Fioravanti2021-11-012-0/+22
| | | | | | | | | | | | | | | | Added minimal mmc support for helper functions: - find_mmc_part: Look for a given partition name. Returns the coresponding partition path - caldata_extract_mmc: Look for a given partition name and then extracts the calibration data - mmc_get_mac_binary: Returns the mac address from a given partition name and offset Signed-off-by: Davide Fioravanti <pantanastyle@gmail.com> Signed-off-by: Robert Marko <robimarko@gmail.com> [replace dd with caldata_dd, moved sysupgrade mmc to orbi] Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
* base-files: generate network config with "device" optionsRafał Miłecki2021-05-271-5/+5
| | | | | | | Replace "ifname" with "device" as netifd has been recently patches to used the later one. It's more clear and accurate. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* base-files: use "ports" array in board.json network for bridgesRafał Miłecki2021-05-181-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | Bridge aggregates multiple ports so use a more accurate name ("ports") and format (array) for storing them in board.json. Example: "network": { "lan": { "ports": [ "lan1", "lan2", "lan3", "lan4" ], "protocol": "static" }, "wan": { "ifname": "wan", "protocol": "dhcp" } } Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* treewide: drop shebang from non-executable lib filesAdrian Schmutzler2021-01-294-6/+0
| | | | | | | | | | | | This drops the shebang from another bunch of files in various /lib folders, as these are sourced and the shebang is useless. Fix execute bit in one case, too. This should cover almost all trivial cases now, i.e. where /lib is actually used for library files. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
* package/base-files: caldata: use dd iflag fullblockJohn Thomson2020-12-111-12/+25
| | | | | | | | | | | | | | | | This dd flag ensures that the requested size is retrieved from pipes or special filesystems (if available). Without this flag, on multi-core systems, Piped or special filesystem data can be truncated when a size greater than PIPE_BUF is requested. Fixes: FS#3494 Fixes: 7557e7f ("package/base-files: caldata: work around dd's limitation") Cc: Thibaut VARÈNE <hacks@slashdirt.org> Signed-off-by: John Thomson <git@johnthomson.fastmail.com.au>
* base-files: allow setting device and bridge macsJohn Crispin2020-12-021-1/+17
| | | | | | | | | Add code for setting mac addresses inside board.json and rendering them out to uci. On switches we want to have a unique MAC on each port. With 48 port switches that would require 48 device sections in /etc/config/network. Doing so via board.json is easier. Signed-off-by: John Crispin <john@phrozen.org>
* base-files: add board.d support for bridge deviceJohn Crispin2020-11-041-0/+4
| | | | | | | | | Latest netifd allows us to setup network bridges with implicit vlan tagging. For this to work, we need to setup several additional uci sections. This feature is particularly usefull for DSA tupe devices. Add board.d and uci-defaults support for generating the sections. Signed-off-by: John Crispin <john@phrozen.org>
* base-files: allow exceptions when removing devicename from LEDsAdrian Schmutzler2020-10-021-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Without the model-based devicename for LEDs, there are still cases where a third component is required, typically when it refers to internal "devices" like phys etc. An example are the following two found on ramips: - rt2800soc-phy0::radio - rt2800pci-phy0::radio So far, the rt2800*-phy: prefixes would be removed by the devicename removal ("migration") script, and the configuration for these LEDs would be broken. To address this, this patch allows to add arguments to a call of remove_devicename_leds, which will be compared against the first part of the LED names/labels, and then be ignored by the routine, and thus not removed: remove_devicename_leds "rt2800soc-phy0" "rt2800pci-phy0" This mechanism is supposed to be used when a "devicename" applies to several devices. If only a single device is affected, it might be more effective to use a case statement and exclude the device from migration by that entirely. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
* base-files: add function to remove devicename from LED labelsAdrian Schmutzler2020-10-021-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, we request LED labels in OpenWrt to follow the scheme modelname:color:function However, specifying the modelname at the beginning is actually entirely useless for the devices we support in OpenWrt. In patches subsequent to this one, we will thus remove the modelname from the label definitions on various targets. To migrate the existing definitions from older installations, a migration script needs to be deployed that does modelname:color:function -> color:function e.g. dir-789:green:status -> green:status This patch introduces two functions that do exactly that: For each entry in /etc/config/system, the routine will check whether two (or more) colons are present, and then remove everything up to (and including) the first colon. For now, this will be applied unconditionally, i.e. if the function is called for a device, all labels will be cut like this. However, for a future case of mixed three-part and two-part labels, it should not be too hard to provide a function argument with exceptions to the removal. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
* base-files: support label-property-less in get_dt_ledsChristian Lamparter2020-09-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | | The LED's "label" property has been deprecated in upstream by: |commit c5d18dd6b64e09dd6984bda9bdd55160af537a8c |Author: Jacek Anaszewski <jacek.anaszewski@gmail.com> |Date: Sun Jun 9 20:19:04 2019 +0200 | | dt-bindings: leds: Add properties for LED name construction | | Introduce dedicated properties for conveying information about | LED function and color. Mark old "label" property as deprecated. | | Additionally function-enumerator property is being provided | for the cases when neither function nor color can be used | for LED differentiation. in order to be somewhat prepared, this patch adds a fallback as a last resort to make the current led code work by falling back to the node-name as the "label". Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
* base-files: fix comment typo in lib/functions/network.shWalter Sonius2020-09-021-1/+1
| | | | | | | | Fix typo in comment. Signed-off-by: Walter Sonius <walterav1984@gmail.com> [commit title/message facelift] Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
* base-files: add support for compat_version on deviceAdrian Schmutzler2020-07-311-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We regularly encounter the situation that devices are subject to changes that will make them incompatible to previous versions. Removing SUPPORTED_DEVICES will not really be helpful in most of these cases, as this only helps after a rename. To solve this situation, this patchset introduces a compatibility version for devices. To complement the DEVICE_COMPAT_VERSION set for the image to be flashed, this implements a compat_version on the device, so it will have something to compare with the image. The only viable way to achieve this seems to be via board.d files, i.e. this is technically adding a compat version for the device's config. Like for the network setup, this will set up a command ucidef_set_compat_version to set the compat_version in board.d. This will then add a string to /etc/board.json, which will be translated into uci system config by bin/config_generate. By this, the compat_version, being a version of the config, will also be exposed to the user. As with DEVICE_COMPAT_VERSION, missing uci entry will be assumed as compat_version "1.0", so we only need to add this if a device needs to be bumped, e.g. ucidef_set_compat_version "1.1" Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
* base-files: add function for generating random MACDavid Bauer2020-07-281-0/+12
| | | | | | | | | | This adds a function for generating a valid random MAC address (unset MC bit / set locally administered bit). It is necessary for devices which do not have a MAC address programmed by the manufacturer. Signed-off-by: David Bauer <mail@david-bauer.net>
* base-files: add functions to set or clear bit in MAC addressSungbo Eo2020-07-081-2/+18
| | | | | | | | Some devices (e.g. Arduino Yun) need bitwise operations during MAC address setup. This commit adds generalized versions of macaddr_setbit_la(), which are helpful when manipulating a single bit in a MAC address. Signed-off-by: Sungbo Eo <mans0n@gorani.run>
* base-files: gpio switch: add named GPIO supportKuan-Yi Li2020-06-181-1/+1
| | | | | | | | | | | | | | | | Previously, gpio_switch only accepts GPIO pin number as input. Once a GPIO pin is exported and named by device tree, its pin state cannot be configured and saved across reboots by UCI. This patch adds support for named GPIO pins. Thus GPIO pin can be exported by device tree with active high/low correctly configured, having human-readable name in /sys/class/gpio/ is also now possible. More importantly, GPIO pins which are referenced by name will be immune from pin mapping breakage while unintentional pin number changes are introduced by kernel or driver updates. Signed-off-by: Kuan-Yi Li <kyli@abysm.org>
* base-files: fix LED IDE triggerThomas Albers2020-06-031-1/+1
| | | | | | | | | | This changes the ide-disk LED trigger to the generic disk-activity as ide-disk trigger was removed in upstream commit eb25cb9956cc ("leds: convert IDE trigger to common disk trigger"). Signed-off-by: Thomas Albers <thomas.gameiro@googlemail.com> [split into separate commit, commit description facelift] Signed-off-by: Petr Štetiar <ynezz@true.cz>
* package/base-files: caldata: work around dd's limitationThibaut VARÈNE2020-05-281-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | tl;dr: dd will silently truncate the output if reading from special files (e.g. sysfs attributes) with a too large bs parameter. This problem was exposed on some RouterBOARD ipq40xx devices which use a caldata payload which is larger than PAGE_SIZE, contrary to all other currently supported RouterBOARD devices: the caldata would fail to properly load with the current scripts. Background: dd doesn't seem to correctly handle read() results that return less than requested data. sysfs attributes have a kernel exchange buffer which is at most PAGE_SIZE big, so only 1 page can be read() at a time. In this case, if bs is larger than PAGE_SIZE, dd will silently truncate blocks to PAGE_SIZE. With the current scripts using bs=<size> count=1, the data is truncated to PAGE_SIZE as soon as the requested <size> exceeds this value. This commit works around this problem by using `cat` in the caldata routines that can read from a file (routines that read from mtd devices are untouched). cat correctly handles partial read requests. The output is then piped to dd with the same parameters as before, to ensure that the resulting file remains exactly the same. This is a simple workaround, the downside is that it uses a pipe and one more executable, and therefore has a larger memory footprint and is slower. This is deemed acceptable considering these routines are only used at boot time. Tested-by: Robert Marko <robimarko@gmail.com> Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
* package/base-files: add caldata_sysfsload_from_file()Thibaut VARÈNE2020-05-081-0/+15
| | | | | | | | This routine enables loading caldata binary via the kernel sysfs loader See https://www.kernel.org/doc/html/v4.19/driver-api/firmware/fallback-mechanisms.html Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
* package/base-files: caldata: allow setting target fileThibaut VARÈNE2020-05-081-8/+21
| | | | | | | This will enable platforms to extract caldata to an arbitrary file, or patch mac in an abitrary file. Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
* base-files: source functions.sh in /lib/functions/system.shAdrian Schmutzler2020-04-121-0/+1
| | | | | | | | The file /lib/functions/system.sh depends on find_mtd_index() and find_mtd_part() located in /lib/function.sh, so let's source that file. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
* base-files: diag: restore default trigger for 'boot' LEDPiotr Dymacz2020-02-241-4/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For devices without a dedicated 'diag' LED, we use sometimes one of other LEDs for indicating at least 'boot', 'failsafe' and 'upgrade' stages. In some cases, at the same time these LEDs have defined default triggers in DTS using 'linux,default-trigger' property. Current 'diag' setup removes the trigger and turns off 'boot' LED after bootup. One of the examples of such device is TP-Link TL-WR841N v14 (ramips) which uses 'wlan' LED with defined 'linux,default-trigger' for 'diag': aliases { led-boot = &led_wlan; led-failsafe = &led_wlan; led-upgrade = &led_wlan; }; [...] led_wlan: wlan { label = "tl-wr841n-v14:green:wlan"; gpios = <&gpio1 9 GPIO_ACTIVE_LOW>; linux,default-trigger = "phy0tpt"; }; This patch extends 'diag.sh' and 'leds.sh' scripts to make sure default trigger defined in DTS is restored for 'diag' LED which isn't used for indicating 'running' stage. Acked-by: Adrian Schmutzler <freifunk@adrianschmutzler.de> Signed-off-by: Piotr Dymacz <pepe2k@gmail.com>
* base-files: remove some bashismsSven Roederer2020-01-261-1/+1
| | | | | | | | | | "[[" is a bash extension for test. As the ash-implementation is not fully compatible we drop its usage. Also change to "=" for simple test, which is sufficient. (see d6ac8ca76c04ed) Signed-off-by: Sven Roederer <devel-sven@geroedel.de> [split patch, removed shebang] Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
* base-files/system.sh: remove $ in $(())Rosen Penev2020-01-171-1/+1
| | | | | | | | Not needed. https://github.com/koalaman/shellcheck/wiki/Sc2004 Signed-off-by: Rosen Penev <rosenp@gmail.com>
* base-files: rename hostname with EUI of mac addressRosy Song2019-11-071-0/+7
| | | | | | | | | | | | | | | If a label MAC address is provided for device, system will rename the hostname with OpenWrt_{eui mac address}. This helps to distinguish between different devices. Since it's no good idea to nest json_* functions, this code does not use get_mac_label directly, but only get_mac_label_dt as external resource. Signed-off-by: Rosy Song <rosysong@rosinson.com> [merged with commit introducing macaddr_geteui, rebased on updated label MAC address storage, extended commit message] Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
* base-files: don't store label MAC address in uci system configAdrian Schmutzler2019-11-071-3/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | If set, label MAC address is available from one of two sources, device tree or board.json. So far, the function get_mac_label was meant for retrieving the address, while an option in uci system config was specified only for case 2 (board.json). The uci config option has several drawbacks: - it is only used for a fraction of devices (those not in DT) - label MAC address is a device property, while config implies user interaction - label_macaddr option will only be set if /etc/config/system does not exist (i.e. only for new installations) Thus, this patch changes the behavior of get_mac_label: Instead of writing the value in board.json to uci system config and reading from this location afterwards, get_mac_label now extracts data from board.json directly. The uci config option won't be used anymore. In addition, two utility functions for extraction only from DT or from board.json are introduced. Since this is only changing the access to the label MAC address, it won't interfere with the addresses stored in the code base so far. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
* base-files: uci-defaults: do config flush in one shotRoman Yeryomin2019-10-221-2/+1
| | | | | | | | | | | Moving a file between tmpfs and other fs is neither faster nor safer, thus no point in doing it in two steps. Use new jshn option to write output directly to file. Originally discussed here: http://lists.openwrt.org/pipermail/openwrt-devel/2017-December/010127.html Signed-off-by: Roman Yeryomin <roman@advem.lv>
* treewide: use a single ath10k MAC patching function with checksumAdrian Schmutzler2019-10-151-7/+1
| | | | | | | | | | | | | | | | 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>