openwrt/scripts/linksys-image.sh

77 lines
2.0 KiB
Bash
Raw Normal View History

realtek: add support for Linksys LGS310C Hardware specification ---------------------- * RTL8380M SoC, 1 MIPS 4KEc core @ 500MHz * 256MB DRAM * 32MB NOR Flash * 8 x 10/100/1000BASE-T ports * 2 x SFP ports * Power LED, Fault LED * Reset button on front panel * UART (115200 8N1) via populated standard pin header marked JP1 TODO: The SFP ports use a shared SCL GPIO that the driver cannot handle. The left SFP port (lan9) is defined and fully functional while the laser on the right SFP port (lan10) is off by default. UART pinout ----------- [o]ooo|JP1 | ||`------ GND | |`------- RX | `-------- TX `---------- Vcc (3V3) Installation using OEM webinterface ----------------------------------- 1. Make sure you are running OEM firmware in secondary slot 2. Install squashfs-factory.imag to primary slot by upload via http Installation using serial interface ----------------------------------- 1. Press "a" "c" "p" during message "Enter correct key to stop autoboot" 2. Load image with "upgrade runtime <TFTP IP>:squashfs-sysupgrade.bin" command 3. Switch to primary slot with "setsys bootpartition 0" 4. Store config with "savesys" 5. Boot the image with `boota` command Dual-boot with stock firmware using writable u-boot-env ------------------------------------------------------- From stock to OpenWrt / primary image 1 (CLI as admin): - > boot system image1 - > reboot From OpenWrt to stock / boot image 2: (shell as root) - # fw_setsys bootpartition 1 - # reboot Debrick using serial interface ------------------------------ 1. Press "a" "c" "p" during message "Enter correct key to stop autoboot" 2. Load vendor image with "upgrade runtime <TFTP IP>:LGS310xxxxx.imag" 3. switch to primary partition "setsys bootpartition 0" 4. safe config "savesys" Further documentation --------------------- See https://openwrt.org/toh/linksys/lgs352c It has been developed and tested on device with v1 revision. Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de> Link: https://github.com/openwrt/openwrt/pull/16068 [Add missing 'w' in name of firmware partition] Signed-off-by: Sander Vanheule <sander@svanheule.net>
2024-09-14 21:17:44 +00:00
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Copyright (C) 2024 OpenWrt.org
#
# This script creates a tar file for the Linksys switches of the LGS3xxC/LGS3xxMPC
# series. It contains not only the OpenWrt firmware but additional scripts that
# are needed for the upgrade.
#
# ./linksys-image.py <ImageFile> <ImageFileOut> <LinksysModel>
#
# Known values for LinksysModel are currently
#
# LGS310MPC 60402010
# LGS310C 60402060
# LGS328PC 60401070
# LGS328PC(RTL8218D) 60401080
# LGS310MPCv2 60402090
# LGS328MPC 60412020
# LGS328C 60412040
# LGS328MPCv2 60412060
# LGS352MPC 60422030
# LGS352C 60422050
# LGS352MPCv2 60422070
# The check script that verifies if the images matches the hardware model
gen_imagecheck() {
echo '#!/bin/sh'
echo 'if [ "$1" = "'${1}'" ]; then'
echo 'echo 0'
echo 'else'
echo 'echo 1'
echo 'fi'
}
# Generic attributes
gen_fwinfo() {
echo 'FW_VERSION=1.01.100\nBOOT_VERSION=01.00.01'
}
# The central upgrade script. It allows to install OpenWrt only to first partition.
gen_imageupgrade() {
echo '#!/bin/sh'
echo 'flash_bank=65536'
echo 'filesize=`stat --format=%s ./series_vmlinux.bix`'
echo 'num_bank=`expr \( ${filesize} + ${flash_bank} - 1 \) / ${flash_bank}`'
echo 'filesize_bank=`expr ${num_bank} \* ${flash_bank}`'
echo 'case $1 in'
echo '1)'
echo 'mtd_debug erase $2 0 ${filesize_bank} >/dev/null 2>&1'
echo 'mtd_debug write $2 0 ${filesize} ./series_vmlinux.bix >/dev/null 2>&1'
echo 'mtd_debug read $2 0 100 image1.img >/dev/null 2>&1'
echo 'CreateImage -r ./image1.img > /tmp/app/image1.txt'
echo 'echo 0'
echo ';;'
echo '*)'
echo 'echo 1'
echo 'esac'
}
tmpdir="$( mktemp -d 2> /dev/null )"
imgdir=$tmpdir/image
mkdir $imgdir
gen_imagecheck $3 > $imgdir/iss_imagecheck.sh
gen_imageupgrade > $imgdir/iss_imageupgrade.sh
gen_fwinfo > $imgdir/firmware_information.txt
chmod +x $imgdir/iss_imagecheck.sh
chmod +x $imgdir/iss_imageupgrade.sh
cp $1 $imgdir/series_vmlinux.bix
tar cf $2 -C $tmpdir image/
rm -rf $tmpdir