1
1
openwrt/target/linux/ramips/mt7621/base-files/etc/init.d/bootcount
Simonas Tamošaitis b991aaf174 ramips: mt7621: add Teltonika RUTM11 support
Specificaitons:
- MediaTek MT7621AT SoC
- 256 MB RAM
- 16MB SPI NOR Flash
- 256MB NAND (split in half for firmware fallback)
- 4x 10/100/1000 Mbps Ethernet, with passive PoE support on LAN1
- WLAN      : MediaTek dual-band WiFi 5
  - 2.4 GHz : b/g/n, MIMO 2x2
  - 5 GHz   : n/ac, MIMO 2x2
- Quectel EG060K-EA 4G CAT6 modem
- 2.0 USB Type-A HOST port
- 1x Digital input
- 1x Digital output
- 2x SIM slot (can be swapped via GPIO)

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

Installation
------------
Notice: update OEM firmware to 7.19 or later, earlier versions will
fail to flash openwrt factory firmware.

1. Check from which partition the device is currently running from

  $ cat /proc/bootconfig/chosen

  In case this output reads rutos-b, install a software update from
  Teltonika first. After upgrade completion, check this file now reads
  rutos-a before continuing.

2. Download the *-squashfs-factory.bin firmware image
3. Flash firmware image via WEB interface

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

Mobile connection:
- EG060K-EA:
    Execute AT commands:
        echo -ne 'AT+QCFG="usbnet",2\r\n' > /dev/ttyUSB2
        echo -ne 'AT+CFUN=1,1\r\n' > /dev/ttyUSB2
    Use ModemManager to establish mobile connection.

Signed-off-by: Simonas Tamošaitis <simsasss@gmail.com>
2026-05-20 00:02:31 +02:00

78 lines
2.6 KiB
Bash
Executable File

#!/bin/sh /etc/rc.common
START=99
boot() {
case $(board_name) in
alfa-network,quad-e4g)
[ -n "$(fw_printenv bootcount bootchanged 2>/dev/null)" ] &&\
echo -e "bootcount\nbootchanged\n" | /usr/sbin/fw_setenv -s -
;;
beeline,smartbox-turbo|\
beeline,smartbox-turbo-plus|\
rostelecom,rt-sf-1)
[[ $(hexdump -n 1 -e '/1 "%1d"' -s $((0x20001)) /dev/mtd3) == \
$((0xff)) ]] || printf '\xff' | dd of=/dev/mtdblock3 \
count=1 bs=1 seek=$((0x20001))
;;
jdcloud,re-cp-02)
echo -e "bootcount 0\nbootlimit 5\nupgrade_available 1" | /usr/sbin/fw_setenv -s -
;;
linksys,e5600|\
linksys,ea6350-v4|\
linksys,ea7300-v1|\
linksys,ea7300-v2|\
linksys,ea7500-v2|\
linksys,ea8100-v1|\
linksys,ea8100-v2)
mtd resetbc s_env || true
;;
belkin,rt1800|\
linksys,e7350|\
samknows,whitebox-v8)
fw_setenv bootcount 0
;;
dna,valokuitu-plus-ex400|\
genexis,pulse-ex400)
fw_setenv boot_cnt_primary 0
fw_setenv boot_cnt_alt 0
;;
zyxel,lte3301-plus)
[ $(printf %d $(fw_printenv -n DebugFlag)) -gt 0 ] || fw_setenv DebugFlag 1
[ $(printf %d $(fw_printenv -n Image1Stable)) -gt 0 ] || fw_setenv Image1Stable 1
[ $(printf %d $(fw_printenv -n Image1Try)) -gt 0 ] && fw_setenv Image1Try 0
;;
zyxel,lte5398-m904|\
zyxel,lte7490-m904|\
zyxel,nr7101)
[ $(printf %d $(fw_printenv -n DebugFlag)) -gt 0 ] || fw_setenv DebugFlag 0x1
[ $(printf %d $(fw_printenv -n Image1Stable)) -gt 0 ] || fw_setenv Image1Stable 1
[ $(printf %d $(fw_printenv -n Image1Try)) -gt 0 ] && fw_setenv Image1Try 0
;;
teltonika,rutm11|\
teltonika,rutm30|\
teltonika,rutm50)
#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
;;
esac
}