2019-04-09 05:48:31 +00:00
|
|
|
#
|
|
|
|
# Copyright (C) 2019 OpenWrt.org
|
|
|
|
#
|
|
|
|
|
|
|
|
. /lib/functions.sh
|
|
|
|
|
|
|
|
iodata_mstc_prepare_fail() {
|
|
|
|
echo "failed to check and prepare the environment, rebooting..."
|
|
|
|
umount -a
|
|
|
|
reboot -f
|
|
|
|
}
|
|
|
|
|
2023-08-06 07:09:35 +00:00
|
|
|
# read/write 1byte in mtd device
|
ramips: add support for I-O DATA WN-DX1200GR
I-O DATA WN-DX1200GR is a 2.4/5 GHz band 11ac (WiFi-5) router, based on
MT7621A.
Specification:
- SoC : MediaTek MT7621A
- RAM : DDR3 128 MiB
- Flash : raw NAND 128 MiB
- WLAN : 2.4/5 GHz 2T2R
- 2.4 GHz : MediaTek MT7603E
- 5 GHz : MediaTek MT7613BE
- Ethernet : 10/100/1000 Mbps x5
- Switch : MediaTek MT7530 (SoC)
- LEDs/keys : 2x/3x (2x buttons, 1x slide-switch)
- UART : through-hole on PCB
- J5: 3.3V, TX, RX, NC, GND from triangle-mark
- 57600n8
- Power : 12 VDC, 1 A
Flash instruction using initramfs image:
1. Boot WN-DX1200GR normally
2. Access to "http://192.168.0.1/" and open firmware update page
("ファームウェア")
3. Select the OpenWrt initramfs image and click update ("更新") button
to perform firmware update
4. On the initramfs image, perform sysupgrade with the
squashfs-sysupgrade image
5. Wait ~120 seconds to complete flashing
Notes:
- currently, mt7615e driver in mt76 doesn't fully support MT7613
(MT7663) wifi chip
- the eeprom data in flash is not used by mt7615e driver and the
driver reports the tx-power up to 3dBm
- the correct MAC address for MT7613BE in eeprom data cannot be
assigned to the phy
- last 0x80000 (512 KiB) in NAND flash is not used on stock firmware
- stock firmware requires "customized uImage header" (called as "combo
image") by MSTC (MitraStar Technology Corp.), but U-Boot doesn't
- uImage magic ( 0x0 - 0x3 ) : 0x434F4D43 ("COMC")
- header crc32 ( 0x4 - 0x7 ) : with "data length" and "data crc32"
- image name (0x20 - 0x37) : model ID and firmware versions
- data length (0x38 - 0x3b) : kernel + rootfs
- data crc32 (0x3c - 0x3f) : kernel + rootfs
MAC addresses:
LAN: 50:41:B9:xx:xx:08 (Ubootenv, ethaddr (text) / Factory, 0x1E000 (hex))
WAN: 50:41:B9:xx:xx:0A (Factory, 0x1E006 (hex))
2.4GHz: 50:41:B9:xx:xx:08 (Factory, 0x4 (hex))
5GHz: 50:41:B9:xx:xx:09 (Factory, 0x8004 (hex))
Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
[add check whether dflag_offset is set]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-01-26 14:50:51 +00:00
|
|
|
#
|
|
|
|
# parameters:
|
2023-08-06 07:09:35 +00:00
|
|
|
# $1: target mtd device ("/dev/mtdblockN")
|
|
|
|
# $2: offset of target value (decimal or hex)
|
|
|
|
# $3: value to set (decimal or hex, don't set when reading)
|
|
|
|
iodata_mstc_rw_byte() {
|
|
|
|
local mtd="$1"
|
|
|
|
local offset="$2"
|
|
|
|
local setval="$3"
|
|
|
|
local _val=$(hexdump -s $offset -n 1 -e '"%d"' $mtd)
|
ramips: add support for I-O DATA WN-DX1200GR
I-O DATA WN-DX1200GR is a 2.4/5 GHz band 11ac (WiFi-5) router, based on
MT7621A.
Specification:
- SoC : MediaTek MT7621A
- RAM : DDR3 128 MiB
- Flash : raw NAND 128 MiB
- WLAN : 2.4/5 GHz 2T2R
- 2.4 GHz : MediaTek MT7603E
- 5 GHz : MediaTek MT7613BE
- Ethernet : 10/100/1000 Mbps x5
- Switch : MediaTek MT7530 (SoC)
- LEDs/keys : 2x/3x (2x buttons, 1x slide-switch)
- UART : through-hole on PCB
- J5: 3.3V, TX, RX, NC, GND from triangle-mark
- 57600n8
- Power : 12 VDC, 1 A
Flash instruction using initramfs image:
1. Boot WN-DX1200GR normally
2. Access to "http://192.168.0.1/" and open firmware update page
("ファームウェア")
3. Select the OpenWrt initramfs image and click update ("更新") button
to perform firmware update
4. On the initramfs image, perform sysupgrade with the
squashfs-sysupgrade image
5. Wait ~120 seconds to complete flashing
Notes:
- currently, mt7615e driver in mt76 doesn't fully support MT7613
(MT7663) wifi chip
- the eeprom data in flash is not used by mt7615e driver and the
driver reports the tx-power up to 3dBm
- the correct MAC address for MT7613BE in eeprom data cannot be
assigned to the phy
- last 0x80000 (512 KiB) in NAND flash is not used on stock firmware
- stock firmware requires "customized uImage header" (called as "combo
image") by MSTC (MitraStar Technology Corp.), but U-Boot doesn't
- uImage magic ( 0x0 - 0x3 ) : 0x434F4D43 ("COMC")
- header crc32 ( 0x4 - 0x7 ) : with "data length" and "data crc32"
- image name (0x20 - 0x37) : model ID and firmware versions
- data length (0x38 - 0x3b) : kernel + rootfs
- data crc32 (0x3c - 0x3f) : kernel + rootfs
MAC addresses:
LAN: 50:41:B9:xx:xx:08 (Ubootenv, ethaddr (text) / Factory, 0x1E000 (hex))
WAN: 50:41:B9:xx:xx:0A (Factory, 0x1E006 (hex))
2.4GHz: 50:41:B9:xx:xx:08 (Factory, 0x4 (hex))
5GHz: 50:41:B9:xx:xx:09 (Factory, 0x8004 (hex))
Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
[add check whether dflag_offset is set]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-01-26 14:50:51 +00:00
|
|
|
|
2023-08-06 07:09:35 +00:00
|
|
|
if [ -z "$setval" ]; then
|
|
|
|
echo $_val
|
|
|
|
return 0
|
ramips: add support for I-O DATA WN-DX1200GR
I-O DATA WN-DX1200GR is a 2.4/5 GHz band 11ac (WiFi-5) router, based on
MT7621A.
Specification:
- SoC : MediaTek MT7621A
- RAM : DDR3 128 MiB
- Flash : raw NAND 128 MiB
- WLAN : 2.4/5 GHz 2T2R
- 2.4 GHz : MediaTek MT7603E
- 5 GHz : MediaTek MT7613BE
- Ethernet : 10/100/1000 Mbps x5
- Switch : MediaTek MT7530 (SoC)
- LEDs/keys : 2x/3x (2x buttons, 1x slide-switch)
- UART : through-hole on PCB
- J5: 3.3V, TX, RX, NC, GND from triangle-mark
- 57600n8
- Power : 12 VDC, 1 A
Flash instruction using initramfs image:
1. Boot WN-DX1200GR normally
2. Access to "http://192.168.0.1/" and open firmware update page
("ファームウェア")
3. Select the OpenWrt initramfs image and click update ("更新") button
to perform firmware update
4. On the initramfs image, perform sysupgrade with the
squashfs-sysupgrade image
5. Wait ~120 seconds to complete flashing
Notes:
- currently, mt7615e driver in mt76 doesn't fully support MT7613
(MT7663) wifi chip
- the eeprom data in flash is not used by mt7615e driver and the
driver reports the tx-power up to 3dBm
- the correct MAC address for MT7613BE in eeprom data cannot be
assigned to the phy
- last 0x80000 (512 KiB) in NAND flash is not used on stock firmware
- stock firmware requires "customized uImage header" (called as "combo
image") by MSTC (MitraStar Technology Corp.), but U-Boot doesn't
- uImage magic ( 0x0 - 0x3 ) : 0x434F4D43 ("COMC")
- header crc32 ( 0x4 - 0x7 ) : with "data length" and "data crc32"
- image name (0x20 - 0x37) : model ID and firmware versions
- data length (0x38 - 0x3b) : kernel + rootfs
- data crc32 (0x3c - 0x3f) : kernel + rootfs
MAC addresses:
LAN: 50:41:B9:xx:xx:08 (Ubootenv, ethaddr (text) / Factory, 0x1E000 (hex))
WAN: 50:41:B9:xx:xx:0A (Factory, 0x1E006 (hex))
2.4GHz: 50:41:B9:xx:xx:08 (Factory, 0x4 (hex))
5GHz: 50:41:B9:xx:xx:09 (Factory, 0x8004 (hex))
Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
[add check whether dflag_offset is set]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
2021-01-26 14:50:51 +00:00
|
|
|
fi
|
2019-04-09 05:48:31 +00:00
|
|
|
|
2023-08-06 07:09:35 +00:00
|
|
|
# decimal or hex -> decimal
|
|
|
|
setval=$((setval))
|
|
|
|
[ "$_val" = "$setval" ] && return 0
|
|
|
|
setval="$(printf '%02x' $setval)"
|
|
|
|
|
|
|
|
if ! (printf "\x$setval" | dd bs=1 seek=$((offset)) conv=notrunc of=$mtd 2>/dev/null); then
|
|
|
|
return 1
|
2019-04-09 05:48:31 +00:00
|
|
|
fi
|
2023-08-06 07:09:35 +00:00
|
|
|
}
|
2019-04-09 05:48:31 +00:00
|
|
|
|
2023-08-06 07:09:35 +00:00
|
|
|
# set flag in mtd device on I-O DATA devices manufactured by MSTC
|
|
|
|
# (MitraStar Technology Corp.)
|
|
|
|
#
|
|
|
|
# parameters:
|
|
|
|
# $1: parameter name
|
|
|
|
# $2: mtd name contains target flag
|
|
|
|
# $3: offset of flag
|
|
|
|
# $4: valid flag values ("n,n,...", ex:"0,1" or "1,2")
|
|
|
|
# $5: value to set to the flag
|
|
|
|
iodata_mstc_set_flag() {
|
|
|
|
local name="$1"
|
|
|
|
local mtddev="$(find_mtd_part $2)"
|
|
|
|
local offset="$3"
|
|
|
|
local valid="$4"
|
|
|
|
local setval="$5"
|
2019-04-09 05:48:31 +00:00
|
|
|
|
2023-08-06 07:09:35 +00:00
|
|
|
if [ -z "$offset" ]; then
|
|
|
|
echo "no $name flag offset provided"
|
2019-04-09 05:48:31 +00:00
|
|
|
iodata_mstc_prepare_fail
|
|
|
|
fi
|
2023-08-06 07:09:35 +00:00
|
|
|
|
|
|
|
if [ -z "$mtddev" ]; then
|
|
|
|
echo "cannot find \"$2\" mtd partition"
|
2019-04-09 05:48:31 +00:00
|
|
|
iodata_mstc_prepare_fail
|
|
|
|
fi
|
|
|
|
|
2023-08-06 07:09:35 +00:00
|
|
|
local flag=$(iodata_mstc_rw_byte "$mtddev" "$offset")
|
|
|
|
local _tmp
|
|
|
|
for i in ${valid//,/ }; do
|
|
|
|
if [ "$flag" = "$((i))" ]; then
|
|
|
|
_tmp=$flag
|
|
|
|
break
|
2019-04-09 05:48:31 +00:00
|
|
|
fi
|
2023-08-06 07:09:35 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
if [ -z "$_tmp" ]; then
|
|
|
|
echo "failed to get valid $name flag, please check the value at $offset in $mtddev"
|
|
|
|
iodata_mstc_prepare_fail
|
2019-04-09 05:48:31 +00:00
|
|
|
fi
|
2023-08-06 07:09:35 +00:00
|
|
|
echo "current: $name => $flag"
|
|
|
|
|
|
|
|
if [ "$flag" != "$((setval))" ]; then
|
|
|
|
if ! iodata_mstc_rw_byte "$mtddev" "$offset" "$setval"; then
|
|
|
|
echo "failed to set \"$name\" flag"
|
2019-04-09 05:48:31 +00:00
|
|
|
iodata_mstc_prepare_fail
|
|
|
|
fi
|
2023-08-06 07:09:35 +00:00
|
|
|
echo " --> set \"$name\" flag to $setval (valid: $valid)"
|
2019-04-09 05:48:31 +00:00
|
|
|
fi
|
|
|
|
}
|