mirror of
https://git.openwrt.org/openwrt/openwrt.git
synced 2024-11-24 14:06:15 +00:00
7d33aedd10
A number of new (or with recently updated caldata) Mikrotik devices are using LZ77 magic for wlan tag hard_config data. New devices include the Chateau LTE12 [1], and ax devices [2] Newly factory flashed devices may include the hap ac3 [3] This can be seen in decoded OEM supout [4] dmesg: "radio data lz77 decompressed from"… Investigating an arm RouterOS flash.ko module, and supplied example hard_config dumps, the format was guessed via decompilation and live debugging [5]. This decoder was then built from the guessed format specification. debug prints can be enabled in a DYNAMIC_DEBUG kernel build via the kernel cmdline: chosen { - bootargs = "console=ttyS0,115200"; + bootargs = "console=ttyS0,115200 dyndbg=\"file drivers/platform/mikrotik/* +p\""; }; [1]: https://forum.openwrt.org/t/no-wireless-mikrotik-rbd53ig-5hacd2hnd/157763/4 [2]: https://forum.openwrt.org/t/mikrotik-routeros-v7-x-and-openwrt-sysupgrade/148072/17 [3]: https://forum.openwrt.org/t/adding-support-for-mikrotik-hap-ax2/133715/47 [4]: https://github.com/farseeker/go-mikrotik-rif [5]: https://github.com/john-tho/routeros-wlan-lz77-decode Signed-off-by: John Thomson <git@johnthomson.fastmail.com.au> Link: https://github.com/openwrt/openwrt/pull/15774 Signed-off-by: Robert Marko <robimarko@gmail.com>
39 lines
1.3 KiB
C
39 lines
1.3 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Common definitions for MikroTik RouterBoot data.
|
|
*
|
|
* Copyright (C) 2020 Thibaut VARÈNE <hacks+kernel@slashdirt.org>
|
|
*/
|
|
|
|
|
|
#ifndef _ROUTERBOOT_H_
|
|
#define _ROUTERBOOT_H_
|
|
|
|
#include <linux/types.h>
|
|
|
|
// these magic values are stored in cpu-endianness on flash
|
|
#define RB_MAGIC_HARD (('H') | ('a' << 8) | ('r' << 16) | ('d' << 24))
|
|
#define RB_MAGIC_SOFT (('S') | ('o' << 8) | ('f' << 16) | ('t' << 24))
|
|
#define RB_MAGIC_LZOR (('L') | ('Z' << 8) | ('O' << 16) | ('R' << 24))
|
|
#define RB_MAGIC_LZ77 (('L' << 24) | ('Z' << 16) | ('7' << 8) | ('7'))
|
|
#define RB_MAGIC_ERD (('E' << 16) | ('R' << 8) | ('D'))
|
|
|
|
#define RB_ART_SIZE 0x10000
|
|
|
|
#define RB_MTD_HARD_CONFIG "hard_config"
|
|
#define RB_MTD_SOFT_CONFIG "soft_config"
|
|
|
|
int routerboot_tag_find(const u8 *bufhead, const size_t buflen, const u16 tag_id, u16 *pld_ofs, u16 *pld_len);
|
|
int routerboot_rle_decode(const u8 *in, size_t inlen, u8 *out, size_t *outlen);
|
|
|
|
int rb_hardconfig_init(struct kobject *rb_kobj, struct mtd_info *mtd);
|
|
void rb_hardconfig_exit(void);
|
|
|
|
int rb_softconfig_init(struct kobject *rb_kobj, struct mtd_info *mtd);
|
|
void rb_softconfig_exit(void);
|
|
|
|
ssize_t routerboot_tag_show_string(const u8 *pld, u16 pld_len, char *buf);
|
|
ssize_t routerboot_tag_show_u32s(const u8 *pld, u16 pld_len, char *buf);
|
|
|
|
#endif /* _ROUTERBOOT_H_ */
|