openwrt/target/linux/mediatek/filogic/base-files/etc/init.d/bootcount
Simonas Tamošaitis 69a8c7f71a
Some checks are pending
Build Kernel / Build all affected Kernels (push) Waiting to run
Build all core packages / Build all core packages for selected target (push) Waiting to run
Build host tools / Build host tools for linux and macos based systems (push) Waiting to run
mediatek: filogic: add Teltonika RUTC50 support
Specification:
- MediaTek MT7981A SoC
- 512 MB RAM
- 16MB SPI NOR Flash
- 512MB NAND (split in half for firmware fallback)
- 5x 10/100/1000 Mbps Ethernet, with passive PoE support on LAN1
- WLAN      : MediaTek dual-band WiFi 6
  - 2.4 GHz : b/g/n/ax, MIMO 2x2
  - 5 GHz   : a/n/ac/ax, MIMO 2x2
- Quectel RG520N-EB 5G R16 modem
- 2.0 USB Type-A HOST port
- 1x Digital input
- 1x Digital output
- 2x SIM slot (can be swapped via AT commands)

GPIO:
- 1 button (Reset)
- 13 LEDs (power, 4x WAN status, Wifi 2G, Wifi 5G, 3G, 4G, 5G, RSSI 1,2,3)
- 3 Modem control (power button, reset, status)
- 1 USB reset
- 1 Digital input
- 1 Digital output

Flashing via OEM WebUI:
1. Download the firmware image *-squashfs-factory.bin
2. Upload firmware image via OEM WebUI firmware update, do not keep settings

To revert back to OEM firmware:
https://wiki.teltonika-networks.com/view/Bootloader_menu

Use "ModemManager" to establish mobile data connection.

Signed-off-by: Simonas Tamošaitis <simsasss@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/19401
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2025-08-24 17:54:04 +02:00

52 lines
1.7 KiB
Bash
Executable file

#!/bin/sh /etc/rc.common
# SPDX-License-Identifier: GPL-2.0-only
START=99
boot() {
case $(board_name) in
xiaomi,mi-router-ax3000t)
. /lib/upgrade/common.sh
[ "$(rootfs_type)" = "tmpfs" ] && \
logger "bootcount: initramfs mode detected, exit" && \
return 0
[ "$(fw_printenv -n flag_try_sys2_failed 2>&1)" = "8" ] && \
logger "bootcount: rd03 model detected, exit" && \
return 0
fw_setenv -s - <<-EOF
flag_boot_rootfs 0
flag_boot_success 1
flag_last_success 0
flag_ota_reboot 0
flag_try_sys1_failed 0
flag_try_sys2_failed 0
EOF
logger "bootcount: rd23 model detected, nvram was updated"
;;
teltonika,rutc50)
#Bootloader expect successfull startup value after update, we need to write success value to bootconfig partition
#otherwise bootloader will fallback to previous root partition
. /lib/functions.sh
local PART="$(cmdline_get_var ubi.mtd)"
local MTD_INDEX=$(find_mtd_index bootconfig-a)
case "$PART" in
rutos-a)
[ "$(md5sum /dev/mtd$MTD_INDEX | awk '{print $1}')" = "adc4a78e76efc6b4afdc41925e4017c6" ] || {
logger -t "bootcount" "saving new failsafe boot config in /dev/mtd$MTD_INDEX bootconfig-a partition rutos-a"
echo -ne "\xe1\xb0\xba\xba\x01\x00\xf9\x01\xf8\x01\xf0\x00\x3d\xd4\xfb\x95" | mtd -e bootconfig-a write - bootconfig-a
}
;;
rutos-b)
[ "$(md5sum /dev/mtd$MTD_INDEX | awk '{print $1}')" = "2904b3476604ef153d1925acdde062e8" ] || {
logger -t "bootcount" "saving new failsafe boot config in /dev/mtd$MTD_INDEX bootconfig-a partition rutos-b"
echo -ne "\xe1\xb0\xba\xba\x01\x01\xf7\x01\xf8\x00\xf0\x00\xce\xd4\x44\x08" | mtd -e bootconfig-a write - bootconfig-a
}
;;
esac
;;
zyxel,ex5700-telenor)
fw_setenv uboot_bootcount 0
;;
esac
}