This isn't going to be a normal "Help with xxxxx device" threads..
The tl;dr: I've got hardware that needs to be reconfigured from the ground up as a proper OpenWrt device.
Backstory:
I jumped in on the Kickstarter for an Itus Networks iGuardian (then renamed Shield). I received it in 2015 and then promptly lost it. I found the box in 2019.
Found out Itus Networks went under in 2016. The OEM box was running a one-off OpenWrt.
Device Specs:
dual core OcteonIII CN7020 1.2 (1ghz), 1GB RAM, 4GB mmc storage (currently divided into 4 paritions.. 1 fat, 3 ext3). The device also has a SD card slot. 3 1000BaseT ethernet adapters and a RJ45 console port. The device runs uboot and is a 3 stage boot process.
I can get OpenWrt to run.. It runs VERY well.. But, the way Itus Networks seems to have shipped the device, and the way I copied in trying to fumble my way through this, doesn't seem viable to support.
From what I can tell:
octboot2.bin
u-boot-octeon_rhino_itus7x.bin
are my uboot files. The device has a 3 position GPIO switch on the front panel to select from three "modes"/images (Router/Gateway/Bridgfe) to load..
/dev/mmcblk1
<-- Main mmc
/dev/mmcblk1p1
<- FAT partition holding the bin files, including Openwrt's
These are ext3 extroot
for the images..
/dev/mmcblk1p2
<- Router
/dev/mmcblk1p3
<- Gateway
/dev/mmcblk1p4
<- Bridge
The image OpenWrt creates is openwrt-octeon-itusrouter-initramfs-kernel.bin
, which gets renamed to ItusrouterImage
, etc before being loaded on /dev/mmcblk1p1
file
output for image:
bin/targets/octeon/generic/openwrt-octeon-itusrouter-initramfs-kernel.bin: ELF 64-bit MSB executable, MIPS, MIPS64 rel2 version 1 (SYSV), statically linked, stripped
The image gets loaded and the init
then pivots to the extroot
The custom init
I had to put in target/linux/generic/other-files/
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
mount -t proc proc /proc
mount -t sysfs sys /sys
mount -t tmpfs dev /dev
mkdir -p /dev/pts
mount -t devpts devpts /dev/pts
# Figure out what mode the Shield is in
# We need to determine what Mode the Shield is in - Time to query the GPIOs
GPIO=99
GPIO16=99
GPIO17=99
GPIO=16
echo ${GPIO} > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio$GPIO/direction
GPIO16=$(cat /sys/class/gpio/gpio${GPIO}/value)
echo $GPIO > /sys/class/gpio/unexport
GPIO=17
echo $GPIO > /sys/class/gpio/export
echo in > /sys/class/gpio/gpio$GPIO/direction
GPIO17=$(cat /sys/class/gpio/gpio${GPIO}/value)
echo $GPIO > /sys/class/gpio/unexport
if [ $GPIO16 -eq 0 ]; then
# Gateway Mode
export SHIELD_MODE="Gateway"
sys_ext=/sys/block/mmcblk1/mmcblk1p3
dev_ext=/dev/mmcblk1p3
dev_ext_major=179
dev_ext_minor=3
else
if [ $GPIO17 -eq 0 ]; then
# Bridge Mode
export SHIELD_MODE="Bridge"
sys_ext=/sys/block/mmcblk1/mmcblk1p4
dev_ext=/dev/mmcblk1p4
dev_ext_major=179
dev_ext_minor=4
else
# Router Mode
export SHIELD_MODE="Router"
sys_ext=/sys/block/mmcblk1/mmcblk1p2
dev_ext=/dev/mmcblk1p2
dev_ext_major=179
dev_ext_minor=2
fi
fi
extroot_dir=/extroot
count=0
while true
do
if [[ ${count} -eq 25 ]]
then
echo "Timed out."; break
fi
if [ -d ${sys_ext} ]
then
echo "Found ${sys_ext} : ${count}"; break
fi
i=0
marks='/ - \ |'
if [ $# -lt 4 ]; then
set -- "$@" $marks
fi
shift $(( (i+1) % $# ))
printf 'Waiting for external root to mount: %s\r' "$1"
sleep 1
count=$((count+1))
done
if [ ! -b ${dev_ext} ]
then
echo "Creating ${dev_ext}"; mknod ${dev_ext} b ${dev_ext_major} ${dev_ext_minor}
fi
mkdir ${extroot_dir}
mount ${dev_ext} ${extroot_dir} -o noatime
umount /sys
umount /proc
umount /dev/pts
umount /dev
count=0
while true
do
if [ -e ${extroot_dir}/init ]
then
# Found an init, but is it ours?
if [ -e ${extroot_dir}/.norwits ]
then
echo ${SHIELD_MODE} > ${extroot_dir}/.mode
exec switch_root ${extroot_dir} /sbin/init
else
# Not our external rootfs! Time to go bubye.
# Remove everything, then wait for the next loop to populate with our stuff.
rm -rf ${extroot_dir}/*
fi
else
# No init found - Setting up the extroot block
echo "${extroot_dir}/init not found! Setting up block device for initial boot."
#Set up the call for firstboot.
firstboot=1
cp -a -f bin dev etc init lib lib64 mnt overlay proc rom root sbin sys tmp usr var www ${extroot_dir}
sleep 5
echo "# Empty File to validate correct block setup - DO NOT REMOVE" > ${extroot_dir}/.norwits
fi
i=0
marks='/ - \ |'
if [ $# -lt 4 ]; then
set -- "$@" $marks
fi
shift $(( (i+1) % $# ))
printf 'Waiting for external root to mount: %s\r' "$1"
sleep 1
count=$((count+1))
if [[ ${count} -eq 5 ]]
then
echo "Timed out."; break
fi
done
export INITRAMFS=1
exec /sbin/init
This essentially seems to treat the device as a Embedded LIVE CD. In this way, I can't update the kernel without replacing the BIN image, and trying to ensure everything that needs to be updates lib and dep wise on the extroot also get's copied.
I'm looking for ideas.. I'm looking for advice on how it should be done. The hardware is open.
So, for the really tech enthusists out there, what would you do? I know i can get it to work.. I have it working. I don't know enough to know if it's done properly or not.. Just that this is how Itus did it before they went bubye..