aboutsummaryrefslogtreecommitdiffstats
path: root/package/utils
diff options
context:
space:
mode:
authorRoger Pueyo Centelles <roger.pueyo@guifi.net>2019-11-28 13:29:12 +0100
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>2020-01-23 15:28:03 +0100
commit7d39946ea0fe954bcd0c4d52fffc6d9dc6248cf6 (patch)
treee60c257a7e24b1ff028ab50c94c020407a7fe0ec /package/utils
parentba730d61af3b860e5d5a086a318a6c2a84e68c9c (diff)
downloadupstream-7d39946ea0fe954bcd0c4d52fffc6d9dc6248cf6.tar.gz
upstream-7d39946ea0fe954bcd0c4d52fffc6d9dc6248cf6.tar.bz2
upstream-7d39946ea0fe954bcd0c4d52fffc6d9dc6248cf6.zip
rbextract: support devices directly showing ERD magic
Older ath79-based MikroTik devices have the ERD calibration data compressed and stored different to newer IPQ40xx ones. This commit adds support for these former ones. Signed-off-by: Roger Pueyo Centelles <roger.pueyo@guifi.net> Acked-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
Diffstat (limited to 'package/utils')
-rw-r--r--package/utils/rbextract/Makefile3
-rw-r--r--package/utils/rbextract/src/rbextract.c28
2 files changed, 30 insertions, 1 deletions
diff --git a/package/utils/rbextract/Makefile b/package/utils/rbextract/Makefile
index b055a615cf..4bc6898b11 100644
--- a/package/utils/rbextract/Makefile
+++ b/package/utils/rbextract/Makefile
@@ -2,6 +2,7 @@
# Copyright (C) 2010 Gabor Juhos <juhosg@openwrt.org>
# Copyright (C) 2018 Chris Schimp <silverchris@gmail.com>
# Copyright (C) 2019 Robert Marko <robimarko@gmail.com>
+# Copyright (C) 2019 Roger Pueyo Centelles <roger.pueyo@guifi.net>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
@@ -10,7 +11,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=rbextract
-PKG_RELEASE:=1
+PKG_RELEASE:=2
CMAKE_INSTALL:=1
include $(INCLUDE_DIR)/package.mk
diff --git a/package/utils/rbextract/src/rbextract.c b/package/utils/rbextract/src/rbextract.c
index 0985497f3f..ceed2494a1 100644
--- a/package/utils/rbextract/src/rbextract.c
+++ b/package/utils/rbextract/src/rbextract.c
@@ -333,7 +333,35 @@ __rb_get_wlan_data(void)
goto err_free_rle_out;
}
}
+ /* Older ath79-based boards directly show the RB_MAGIC_ERD bytes followed by
+ the LZO-compressed calibration data with no RLE */
+ if (magic == RB_MAGIC_ERD) {
+ if (tag_len > RB_ART_SIZE) {
+ printf("Calibration data too large\n");
+ goto err_free_lzo_in;
+ }
+
+ err = routerboot_find_tag(tag, tag_len,
+ 0x1, &buf_lzo_in, &erd_tag_len);
+ if (err) {
+ printf("No ERD chunk found\n");
+ goto err_free_lzo_out;
+ }
+
+ printf("Decompressing with LZO\n");
+ lzo_out_len = RB_ART_SIZE;
+ err = lzo1x_decompress_safe(buf_lzo_in, tag_len,
+ buf_lzo_out, &lzo_out_len, NULL);
+ /* For some reason, I get this "input not consumed" error
+ * even though the output is correct, so ignore it. */
+ if (err && err != LZO_E_INPUT_NOT_CONSUMED) {
+ printf("unable to decompress calibration data: %d\n",
+ err);
+ goto err_free_lzo_out;
+ }
+ buf_rle_out = buf_lzo_out;
+ }
return buf_rle_out;
err_free_rle_out: