Skip to content

Commit

Permalink
Replace static DTBs with the distro DTB
Browse files Browse the repository at this point in the history
Replace static DTBs that we distributed in /boot from files directory in
this repo with the distro DTB.
Refactor SFP/PHY selection procedure to use fdt editing in U-Boot to
disable PHY and enable SFP when SFP is present on boot.
Refactor install and provide boot.scr script for SATA boot, which is
probably impossible to create on install in Omnia Rescue because the
rescue image does not have chroot busybox applet.
  • Loading branch information
tmshlvck committed Mar 26, 2024
1 parent 2f2f6ff commit 37d864e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 34 deletions.
13 changes: 4 additions & 9 deletions omnia/create-medkit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ EOF
# enable watchdog
sed -i 's/#RuntimeWatchdogSec=0/RuntimeWatchdogSec=30/' $ROOTDIR/etc/systemd/system.conf
# create static DTBs
cp $BUILDROOT/files/armada-385-turris-omnia-phy.dtb $ROOTDIR/boot/
cp $BUILDROOT/files/armada-385-turris-omnia-sfp.dtb $ROOTDIR/boot/
# copy genbootscr
cd $BUILDROOT
cp files/genbootscr $ROOTDIR/etc/kernel/postinst.d/z99-genbootscr
Expand Down Expand Up @@ -97,10 +93,11 @@ apt-get -y install ssh btrfs-progs i2c-tools firmware-atheros mtd-utils bridge-u
sed -i 's/^.\?PermitRootLogin .\+$/PermitRootLogin yes/' /etc/ssh/sshd_config
echo "spi_nor" >>/etc/modules
ENDSCRIPT
# cleanup QEMU
#$SUDO rm -f ${ROOTDIR}${QEMU}
/etc/kernel/postinst.d/z99-genbootscr -r /dev/sda1
mv /boot/boot.scr /boot/boot.scr-sda1
/etc/kernel/postinst.d/z99-genbootscr -r /dev/mmcblk0p1
ENDSCRIPT

# create package
cd $ROOTDIR
Expand All @@ -112,8 +109,6 @@ d=`date "+%Y%m%d"`
$SUDO mv omnia-medkit.tar.gz omnia-medkit-${d}.tar.gz
$SUDO md5sum omnia-medkit-${d}.tar.gz >omnia-medkit-${d}.tar.gz.md5

exit 0

# cleanup rootdir
$SUDO rm -rf $ROOTDIR

Binary file removed omnia/files/armada-385-turris-omnia-phy.dtb
Binary file not shown.
Binary file removed omnia/files/armada-385-turris-omnia-sfp.dtb
Binary file not shown.
28 changes: 10 additions & 18 deletions omnia/files/genbootscr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

help () {
print_help () {
echo "genbootscr.sh\n\n -h|--help - print this help\n -r|--root </dev/blockdevice> -- force root partition"
}

Expand All @@ -14,7 +14,7 @@ while [[ $# -gt 0 ]]; do
;;
-h|--help)
print_help
shift # past argument
exit 1
;;
-*|--*)
echo "Unknown option $1"
Expand Down Expand Up @@ -57,15 +57,7 @@ if [ -z "${KERNEL_VER}" ]; then
fi

INITRD="/boot/initrd.img-${KERNEL_VER}"

DTPHY="/usr/lib/linux-image-${KERNEL_VER}/armada-385-turris-omnia-phy.dtb"
DTSFP="/usr/lib/linux-image-${KERNEL_VER}/armada-385-turris-omnia-sfp.dtb"
if [ ! -f "${DTPHY}" ]; then
DTPHY="/boot/armada-385-turris-omnia-phy.dtb"
fi
if [ ! -f "${DTSFP}" ]; then
DTSFP="/boot/armada-385-turris-omnia-sfp.dtb"
fi
DT="/usr/lib/linux-image-${KERNEL_VER}/armada-385-turris-omnia.dtb"

echo "Selected kernel Image: $KERNEL_IMAGE"
echo "Searching InitRD: $INITRD"
Expand All @@ -74,24 +66,24 @@ cat >/boot/boot.txt <<EOF
setenv bootargs "earlyprintk console=\$console pcie_aspm=off root=$ROOT rootdelay=2 rootflags=subvol=@,commit=5 rw"
setenv omnia_boot_prep '${SCRIPT_PREPEND}'
setenv omnia_boot_lk 'load $BOOTDEV \${kernel_addr_r} /@${KERNEL_IMAGE}'
setenv omnia_boot_ldt_phy 'load $BOOTDEV \${fdt_addr_r} /@$DTPHY'
setenv omnia_boot_ldt_sfp 'load $BOOTDEV \${fdt_addr_r} /@$DTSFP'
setenv omnia_fixup_mac0 'setexpr fmac0 gsub : " " \$ethaddr; fdt resize; fdt set /soc/internal-regs/ethernet@70000 local-mac-address "[\${fmac0}]"'
setenv omnia_fixup_mac1 'setexpr fmac1 gsub : " " \$eth1addr; fdt resize; fdt set /soc/internal-regs/ethernet@30000 local-mac-address "[\${fmac1}]"'
setenv omnia_fixup_mac2 'setexpr fmac2 gsub : " " \$eth2addr; fdt resize; fdt set /soc/internal-regs/ethernet@34000 local-mac-address "[\${fmac2}]"'
setenv omnia_boot_ldt 'load $BOOTDEV \${fdt_addr_r} /@$DT'
setenv omnia_fixup_sfp 'if gpio input gpio@71_4; then echo SFP; fdt set /soc/internal-regs/mdio@72004/ethernet-phy@1 status "disabled"; fdt set /sfp status "okay"; fdt set /soc/internal-regs/ethernet@34000 managed "in-band-status"; fdt rm /soc/internal-regs/ethernet@34000 phys; fdt rm /soc/internal-regs/ethernet@34000 phy-handle; else echo PHY; fi;'
setenv omnia_fixup_mac0 'setexpr fmac0 gsub : " " \$ethaddr; fdt set /soc/internal-regs/ethernet@70000 local-mac-address "[\${fmac0}]"'
setenv omnia_fixup_mac1 'setexpr fmac1 gsub : " " \$eth1addr; fdt set /soc/internal-regs/ethernet@30000 local-mac-address "[\${fmac1}]"'
setenv omnia_fixup_mac2 'setexpr fmac2 gsub : " " \$eth2addr; fdt set /soc/internal-regs/ethernet@34000 local-mac-address "[\${fmac2}]"'
EOF

if [ -f "${INITRD}" ]; then
cat >>/boot/boot.txt <<EOF
setenv omnia_boot_lrd 'load $BOOTDEV \${ramdisk_addr_r} /@${INITRD}'
setenv omnia_boot_brd 'bootz \${kernel_addr_r} \${ramdisk_addr_r}:0x\${filesize} \${fdt_addr_r};'
setenv omnia_boot 'run omnia_boot_prep; run omnia_boot_lk; if gpio input gpio@71_4; then echo SFP; run omnia_boot_ldt_sfp; else echo PHY; run omnia_boot_ldt_phy; fi; fdt addr \${fdt_addr_r}; run omnia_fixup_mac0; run omnia_fixup_mac1; run omnia_fixup_mac2; run omnia_boot_lrd; run omnia_boot_brd'
setenv omnia_boot 'run omnia_boot_prep; run omnia_boot_lk; run omnia_boot_ldt; fdt addr \${fdt_addr_r}; fdt resize 1024; run omnia_fixup_sfp; run omnia_fixup_mac0; run omnia_fixup_mac1; run omnia_fixup_mac2; run omnia_boot_lrd; run omnia_boot_brd'
run omnia_boot
EOF
else
cat >>/boot/boot.txt <<EOF
setenv omnia_boot_b 'bootz \${kernel_addr_r} - \${fdt_addr_r};'
setenv omnia_boot 'run omnia_boot_prep; run omnia_boot_lk; if gpio input gpio@71_4; then echo SFP; run omnia_boot_ldt_sfp; else echo PHY; run omnia_boot_ldt_phy; fi; fdt addr \${fdt_addr_r}; run omnia_fixup_mac0; run omnia_fixup_mac1; run omnia_fixup_mac2; run omnia_boot_b;'
setenv omnia_boot 'run omnia_boot_prep; run omnia_boot_lk; run omnia_boot_ldt; fdt addr \${fdt_addr_r}; fdt resize 1024; run omnia_fixup_sfp; run omnia_fixup_mac0; run omnia_fixup_mac1; run omnia_fixup_mac2; run omnia_boot_b;'
run omnia_boot
EOF
fi
Expand Down
14 changes: 7 additions & 7 deletions omnia/files/interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@ auto lo
iface lo inet loopback

# LAN
auto eth0
iface eth0 inet manual
auto end0
iface end0 inet manual

auto eth1
iface eth1 inet manual
auto end1
iface end1 inet manual

auto br0
iface br0 inet static
bridge_ports lan0 lan1 lan2 lan3 lan4
pre-up ip link set up dev eth0; ip link set up dev eth1; for i in `seq 0 4`; do ip link set up dev lan${i}; done
pre-up ip link set up dev end0; ip link set up dev end1; for i in `seq 0 4`; do ip link set up dev lan${i}; done
address 192.168.1.1
netmask 255.255.255.0
bridge_stp off
bridge_waitport 0
bridge_fd 0

# WAN
#auto eth2
#iface eth2 inet dhcp
#auto end2
#iface end2 inet dhcp

0 comments on commit 37d864e

Please sign in to comment.