- May 28, 2020
-
-
Thibaut VARÈNE authored
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>
-
- May 08, 2020
-
-
Thibaut VARÈNE authored
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>
-
Thibaut VARÈNE authored
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>
-
- Apr 12, 2020
-
-
Adrian Schmutzler authored
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>
-
- Feb 24, 2020
-
-
Piotr Dymacz authored
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>
-
- Jan 26, 2020
-
-
Sven Roederer authored
"[[" 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 d6ac8ca7) Signed-off-by:
Sven Roederer <devel-sven@geroedel.de> [split patch, removed shebang] Signed-off-by:
Adrian Schmutzler <freifunk@adrianschmutzler.de>
-
- Jan 17, 2020
-
-
Rosen Penev authored
Not needed. https://github.com/koalaman/shellcheck/wiki/Sc2004 Signed-off-by:
Rosen Penev <rosenp@gmail.com>
-
- Nov 07, 2019
-
-
Rosy Song authored
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>
-
Adrian Schmutzler authored
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>
-
- Oct 22, 2019
-
-
Roman Yeryomin authored
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>
-
- Oct 15, 2019
-
-
Adrian Schmutzler authored
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>
-
- Oct 14, 2019
-
-
Adrian Schmutzler authored
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>
-
- Oct 13, 2019
-
-
Adrian Schmutzler authored
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>
-
- Sep 19, 2019
-
-
Adrian Schmutzler authored
For many devices, MAC addresses cannot be retrieved via the device tree alias. To still provide the label MAC address for those, this implements a second mechanism that will put the address into uci config. Note that this stores the actual MAC address, whereas in DTS we reference the bearing device. This is based on the work of Rosy Song <rosysong@rosinson.com> Signed-off-by:
Adrian Schmutzler <freifunk@adrianschmutzler.de>
-
Adrian Schmutzler authored
To refer to the MAC address on a device's label, one can specify the alias label-mac-device in the DTS which should point to the bearer of the corresponding MAC address. With the function get_mac_label, the user can retrieve then retrieve this address and use it as a value that uniquely identifies his device. This is severely helpful for several downstream functionalities, e.g. define MAC addresses of custom netifs or change the SSID to be easily recognizable. Signed-off-by:
Adrian Schmutzler <freifunk@adrianschmutzler.de>
-
- Sep 05, 2019
-
-
Adrian Schmutzler authored
The actual retrieval of the MAC address in mtd_get_mac_binary_ubi() is the same as in get_mac_binary(). Thus, use the latter function in the former to reduce duplicate code. This will also allow to benefit from the enhanced path check there and bring mtd_get_mac_binary_ubi() more in line with the similar mtd_get_mac_binary(). Signed-off-by:
Adrian Schmutzler <freifunk@adrianschmutzler.de>
-
David Bauer authored
The mtd_get_mac_text helper method did not support hexadecimal offset values, resulting them to break after 75bfc393 ("treewide: convert MAC address location offsets to hexadecimal") This commit fixes this by evaluating the hexadecimal input, converting them to decimal. Signed-off-by:
David Bauer <mail@david-bauer.net>
-
- Jul 09, 2019
-
-
Adrian Schmutzler authored
Logic was inverted when changing from string check to file check. Fix it. Fixes: 8592602d ("base-files: Really check path in get_mac_binary") Reported-by:
Matthias Schiffer <mschiffer@universe-factory.net> Signed-off-by:
Adrian Schmutzler <freifunk@adrianschmutzler.de>
-
- Jul 07, 2019
-
-
Adrian Schmutzler authored
Currently, path argument is only checked for being not empty. This changes behavior to actually check whether path exists. Signed-off-by:
Adrian Schmutzler <freifunk@adrianschmutzler.de>
-
- Jun 29, 2019
-
-
Florian Eckert authored
Add missing ubus api call for uptime value. Signed-off-by:
Florian Eckert <fe@dev.tdt.de>
-
- Jun 20, 2019
-
-
Robinson Wu authored
This patch adds a missing type property. This fixes the creation of oneshot and timer led triggers like: | ucidef_set_led_timer "system" "system" "zhuotk:green:system" "1000" "1000" from /etc/init.d/01_leds. Fixes: b06a286a ("base-files: cleanup led functions in uci-defaults.sh") Signed-off-by:
Robinson Wu <wurobinson@qq.com> Signed-off-by:
Christian Lamparter <chunkeey@gmail.com>
-
- May 20, 2019
-
-
Petr Štetiar authored
Commit "generic: ar8216: add mib_poll_interval switch attribute" has added mib_poll_interval global config option and commit "generic: ar8216: group MIB counters and use two basic ones only by default" has added mib_type config option. So this patch adds ucidef_set_ar8xxx_switch_mib helper function which would allow configuration of the above mentioned new switch config options. Signed-off-by:
Petr Štetiar <ynezz@true.cz>
-
- Apr 06, 2019
-
-
Tomasz Maciej Nowak authored
Currently leds migration scripts in ar71xx and lantiq share a lot of logic and introducing leds migration to another target would mean copying this code, again. Therefore add common logic to library in base-files package. Suggested-by:
Petr Štetiar <ynezz@true.cz> Signed-off-by:
Petr Štetiar <ynezz@true.cz> Signed-off-by:
Tomasz Maciej Nowak <tomek_n@o2.pl>
-
- Sep 29, 2018
-
-
Christian Lamparter authored
The swconfig switch led driver has the ability to switch between a "link, rx and/or tx" mode. However, this feature was not implemented in uci, the led init script and config_generate. This patch adds a seventh parameter to the ucidef_set_led_switch() function. The accepted values for this parameter are: link, rx and tx. Any permutations of these three values are supported, as long as they are properly encased with quotes. If the parameter is not specified it will default to "all" (link rx tx). Signed-off-by:
Christian Lamparter <chunkeey@gmail.com>
-
- Sep 25, 2018
-
-
Florian Eckert authored
Signed-off-by:
Florian Eckert <fe@dev.tdt.de> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> [PKG_RELEASE increase]
-
- Aug 11, 2018
-
-
Mathias Kresin authored
Add a function to get a mac stored as text from flash. The octets of the mac address need to be separated by any separator supported by macaddr_canonicalize(). Signed-off-by:
Dmitry Tunin <hanipouspilot@gmail.com> Signed-off-by:
Mathias Kresin <dev@kresin.me>
-
Mathias Kresin authored
Add the opening bracket right after the function name, to do it the same way for all functions in this file. Signed-off-by:
Dmitry Tunin <hanipouspilot@gmail.com> Signed-off-by:
Mathias Kresin <dev@kresin.me>
-
- Jul 17, 2018
-
-
Jo-Philipp Wich authored
When attempting to use any of the functions in network.sh while netifd is not started yet, the ubus interface dump query will fail with "Not found", yielding an empty response. Subsequently, jsonfilter is invoked with an empty string instead of a valid JSON document, causing it to emit a second "unexpected end of data" error. This caused the dnsmasq init script to log the following errors during early boot on some systems: procd: /etc/rc.d/S19dnsmasq: Command failed: Not found. procd: /etc/rc.d/S19dnsmasq: Failed to parse json data: unexpected end of data. Fix the issue by allowing the ubus query to fail with "Not found" but still logging other failures, and by passing an empty JSON object to jsonfilter if the interface status cache is empty. Signed-off-by:
Jo-Philipp Wich <jo@mein.io>
-
- May 25, 2018
-
-
Jo-Philipp Wich authored
The previous refactoring of ucidef_set_interface() removed the protocol selection heuristic which breaks the networking defaults for the majority of boards. Re-add the protocol selection and rename two bad "proto" references to the expected "protocol" value. Fixes: 85048a9c ("base-files: rework _ucidef_set_interface to be more generic") Signed-off-by:
Jo-Philipp Wich <jo@mein.io>
-
- May 24, 2018
-
-
Roman Yeryomin authored
This is a rework of previously submitted patch reworking ucidef_set_interface_raw [1]. Here, keep the idea but instead make _ucidef_set_interface more generic and use it instead of ucidef_set_interface_raw. Also change the users like ucidef_set_interface_lan and others. [1] https://patchwork.ozlabs.org/patch/844961/ Signed-off-by:
Roman Yeryomin <roman@advem.lv>
-
- Apr 04, 2018
-
-
Mathias Kresin authored
It's intentional that some boards within a target don't have all LEDs which are tried to be setup in a common script. Don't show a warning in such cases. Fixes: 4f4fc993 ("base-files: add more name source to get_dt_led helper function") Signed-off-by:
Mathias Kresin <dev@kresin.me>
-
- Mar 14, 2018
-
-
Mathias Kresin authored
Not all LED driver are using the label devicetree property for the led name. Add support for the TI/National Semiconductor LP55xx Led Drivers, which are using the chan-name property for the led name, as fallback. Signed-off-by:
Mathias Kresin <dev@kresin.me>
-
Mathias Kresin authored
Add a fucntion to get the a binary mac address from file. Use the new function for mtd_get_mac_binary() to limit duplicate code. Signed-off-by:
Mathias Kresin <dev@kresin.me>
-
- Jan 10, 2018
-
-
Martin Schiller authored
Add the uci option nameprefix to specifc a target netdev name. Patch the br2684ctl code to accept and set a netdev name via commandline parameters. It allows to use the same netdev name for ATM and PTM lines on lantiq xdsl hardware. Signed-off-by:
Martin Schiller <ms@dev.tdt.de> Signed-off-by:
Mathis Kresin <dev@kresin.me>
-
- Dec 14, 2017
-
-
Christian Lamparter authored
Lantiq and IPQ806X (which includes IPQ40XX) both define the same custom function {ipq806x|lantiq}_get_dt_led. This patch moves the function into the base-file package at lib/functions/leds.sh to make it more accessible for other targets as well. Cc: Mathias Kresin <dev@kresin.me> Cc: John Crispin <john@phrozen.org> Cc: Hannu Nyman <hannu.nyman@iki.fi> Signed-off-by:
Christian Lamparter <chunkeey@gmail.com>
-
- Jun 17, 2017
-
-
Mathias Kresin authored
The offset and factor are only related for LEDs which can have different brightness values. But binary LEDs are more common and don't require any further configuation than setting the factor to 1. Use offset = 0 and factor = 1 in case nothing else is specified. Signed-off-by:
Mathias Kresin <dev@kresin.me>
-
- Jun 08, 2017
-
-
Jo-Philipp Wich authored
* Change network_get_subnet6() to sensibly guess a suitable prefix Attempt to return the first non-linklocal, non-ula range, then attempt to return the first non-linklocal range and finally fall back to the previous behaviour of simply returning the first found item. * Fix network_get_ipaddrs_all() Instead of replicating the flawed logic appending a fixed ":1" suffix to IPv6 addresses, rely on network_get_ipaddrs() and network_get_ipaddrs6() to build a single list of all interface addresses. * Fix network_get_subnets6() Instead of replicating the flawed logic appending a fixed ":1" suffix to IPv6 addresses, rely on the ipv6-prefix-assignment.local-address field to figure out the proper network address. Signed-off-by:
Jo-Philipp Wich <jo@mein.io>
-
Jo-Philipp Wich authored
Rework the network_get_ipaddr6() and network_get_ipaddrs6() functions to fetch the effective local IPv6 address of delegated prefix from the "local-address" field instead of naively hardcoding ":1" as static suffix. Fixes FS#829. Signed-off-by:
Jo-Philipp Wich <jo@mein.io>
-
- May 14, 2017
-
-
Alberto Bursi authored
uci_set_leds_ataport() allows to set a led to show activity on a specific (s)ata port, which is needed for devices that have a Sata led for each sata port. The led trigger is from the 834-ledtrig-libata.patch LEDE kernel patch. uci_set_leds_usbhost() allows to set a led to show total usb activity. Signed-off-by:
Alberto Bursi <alberto.bursi@outlook.it> [Jo-Philipp Wich: use a single underscore to denote private functions] Signed-off-by:
Jo-Philipp Wich <jo@mein.io>
-
Alberto Bursi authored
create a function with code common to all led functions, create another function with code common to functions setting a simple led trigger, restore alphabetical order in function names. Signed-off-by:
Alberto Bursi <alberto.bursi@outlook.it> [Jo-Philipp Wich: use a single underscore to denote private functions] Signed-off-by:
Jo-Philipp Wich <jo@mein.io>
-