I own a Shuttle Omninas KD20 on which I tried to install OpenWrt (this was already 2 years ago and I gave up at that time. Now i want to know if I can revive the KD20. This is what I did:
-
I successfully created the file lede-oxnas-kd20-factory.tar.gz and did a firmware update
-
The KD20 started with no problem and I could ssh into it (new MAC, new ID).
-
Then I made a mistake because i thought I'm clever and looked for the latest OpenWrt firmware release available for the KD20, which I thought was 23.05.4 and replaced the files to upload in the next steps with the newer ones. I think used tftp to upload files.
-
No problem at all with the steps ’re-format UBI' and 'write kernel' only I did it with the newer version 23.9.4 which was probably a BIG MISTAKE.
-
After this, the KD20 boots but the ON/OFF Led turns red and that's it.
-
I can ping the KD20 but all ports are closed, no web, no ssh, and the serial console doesn't work either after I tried to use it - in a wrong way which probably damaged the 3.3V power regulator feeding the UART.
After this I gave up. Now I asked ChatGPT for a solution to prepare a SATA disk and make the KD20 boot from there. The outcome was the following:
- I have a disk image which I insert into Bay 1 and power up
- The blue power LED flashes, the turns solid blue and then solid red. The disk 1 LED lights blue.
- The KD20 is not visible on the network.
I created the disk image using the following procedure - based on openwrt-23.05.4-oxnas-ox820-shuttle_kd20-squashfs-sysupgrade.tar as quoted below. No write to NVRAM is included, I just want to boot into a system where I can get access with ssh to fix the NVRAM from there.
I assume a kernel panic while loading. I also tried to to include a network console to no avail so far. I’m still confident to get the job done finally, but at the moment I would welcome any hint on what I’m doing wrong.
#!/usr/bin/env bash
set -euo pipefail
PS4='Line $LINENO:'
# -------------------------------------------------
# build-kd20-rescue.sh
# Creates a bootable KD20 rescue SATA disk (2GB, ext3)
# Usage: sudo ./build-kd20-rescue.sh openwrt-23.05.4-oxnas-ox820-shuttle_kd20-squashfs-sysupgrade.tar
# -------------------------------------------------
TARFILE="${1:-openwrt-23.05.4-oxnas-ox820-shuttle_kd20-squashfs-sysupgrade.tar}"
IMGNAME="kd20-rescue.img"
IMGSIZE_MB=2048
MNTDIR="./mnt_kd20"
TMPDIR="./kd20_tmp"
ROOTFS_DIR="./rootfs_unsquash"
# ------------------ cleanup ------------------
sudo umount "$MNTDIR" 2>/dev/null || true
sudo losetup -D
rm -rf "$MNTDIR" "$TMPDIR" "$ROOTFS_DIR" "$IMGNAME"
mkdir -p "$MNTDIR" "$TMPDIR"
# ------------------ create image and partition ------------------
dd if=/dev/zero of="$IMGNAME" bs=1M count="$IMGSIZE_MB" status=progress
parted --script "$IMGNAME" mklabel msdos
parted --script "$IMGNAME" mkpart primary ext3 1MiB 100%
LOOPDEV=$(sudo losetup -Pf --show "$IMGNAME")
PART="${LOOPDEV}p1"
sleep 0.5
sudo mkfs.ext3 -L KD20ROOT "$PART"
sudo mount "$PART" "$MNTDIR"
# ------------------ extract sysupgrade tar ------------------
tar -xf "$TARFILE" -C "$TMPDIR"
SRCDIR=$(find "$TMPDIR" -maxdepth 2 -type d -name "sysupgrade-*" | head -n1)
KERNEL="$SRCDIR/kernel"
ROOTFS_SQUASH="$SRCDIR/root"
# ------------------ extract rootfs ------------------
rm -rf ./rootfs_unsquash
unsquashfs -d ./rootfs_unsquash "$ROOTFS_SQUASH"
# ------------------ install kernel ------------------
mkdir -p "$MNTDIR/boot"
sudo cp "$KERNEL" "$MNTDIR/boot/uImage"
sudo sync
# ------------------ copy rootfs ------------------
sudo rsync -aHAX --numeric-ids "$ROOTFS_DIR/" "$MNTDIR/"
# ------------------ boot script ------------------
cat > /tmp/boot.txt <<'EOF'
# KD20 SATA rescue boot script
setenv bootargs 'console=ttyS0,115200 root=/dev/sda1 rootfstype=ext3 rw init=/sbin/init'
echo "Loading kernel from SATA..."
ext2load ide 0:1 0x6400000 /boot/uImage
echo "Booting kernel..."
bootm 0x6400000
EOF
sudo mv /tmp/boot.txt "$MNTDIR/boot/boot.txt"
sudo mkimage -A arm -O linux -T script -C none -n "KD20 Rescue Boot" -d "$MNTDIR/boot/boot.txt" "$MNTDIR/boot/boot.scr"
# ------------------ network configuration ------------------
sudo tee "$MNTDIR/etc/config/network" > /dev/null <<'EOF'
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config interface 'lan'
option ifname 'eth0'
option proto 'static'
option ipaddr '192.168.20.60'
option netmask '255.255.255.0'
option gateway '192.168.20.1'
option dns '8.8.8.8'
EOF
# ------------------ dropbear SSH ------------------
sudo tee "$MNTDIR/etc/config/dropbear" > /dev/null <<'EOF'
config dropbear
option PasswordAuth 'on'
option RootPasswordAuth 'on'
option Port '22'
EOF
# ------------------ rc.local for logging ------------------
sudo tee "$MNTDIR/etc/rc.local" > /dev/null <<'EOF'
#!/bin/sh
LOG=/root/start.log
echo "$(date): rc.local starting" >> $LOG 2>&1
mount >> $LOG 2>&1
dmesg | tail -n 200 >> $LOG 2>&1
/sbin/ifconfig eth0 192.168.20.60 netmask 255.255.255.0 up >> $LOG 2>&1 || true
/sbin/route add default gw 192.168.20.1 >> $LOG 2>&1 || true
/etc/init.d/dropbear start >> $LOG 2>&1 || true
echo "$(date): rc.local finished" >> $LOG 2>&1
exit 0
EOF
sudo chmod +x "$MNTDIR/etc/rc.local"
# ------------------ root password ------------------
HASH=$(python3 -c 'import crypt; print(crypt.crypt("root", crypt.mksalt(crypt.METHOD_SHA512)))')
sudo awk -v H="$HASH" '$1=="root" {$2=H} {print}' "$MNTDIR/etc/shadow" | sudo tee "$MNTDIR/etc/shadow" >/dev/null
sudo chmod 600 "$MNTDIR/etc/shadow"
# ------------------ final cleanup ------------------
sync
sudo umount "$MNTDIR"
sudo losetup -d "$LOOPDEV"
rm -rf "$TMPDIR" "$ROOTFS_DIR"
echo "Done! Image: $IMGNAME"
echo "Write with: sudo dd if=$IMGNAME of=/dev/sdX bs=4M conv=fsync status=progress"