Skip to content

Instantly share code, notes, and snippets.

@meatherly
Created August 11, 2023 14:59
Show Gist options
  • Save meatherly/a1a3fde9a0dfab82d13227d305df0ad3 to your computer and use it in GitHub Desktop.
Save meatherly/a1a3fde9a0dfab82d13227d305df0ad3 to your computer and use it in GitHub Desktop.
NXP ls1028 Felix Ubuntu Router Setup
#!/bin/bash
#
# Simple switch configuration
#
# Assume both ENETC and Felix drivers are already loaded
#
BRIDGE=br0
MAC_ROOT=bc:8d:bf:7c:5b
# Create bridge device in net namespace
ip link add name $BRIDGE type bridge
ip link set $BRIDGE up
# Configure switch ports
# * set MAC address
# * bring up interface
# * move net device into the bridge net namespace
# * set bridge device as master
swps=($(ls /sys/bus/pci/devices/0000:00:00.5/net/))
nr=${#swps[@]}
for (( i=0; i<$nr; i++ ))
do
echo "adding ${swps[$i]} to bridge .."
ip link set ${swps[$i]} address $MAC_ROOT:$(echo "${swps[$i]}" | tr -dc '0-9')
ip link set ${swps[$i]} master $BRIDGE
ip link set ${swps[$i]} up
done
# bring up ENETC ports connected to switch ports
enetc2=$(ls /sys/bus/pci/devices/0000:00:00.2/net/)
ip link set $enetc2 up
# move ENETC port connected to switch CPU port in bridge ns
enetc3=$(ls /sys/bus/pci/devices/0000:00:00.0/net/)
ip link set $enetc3 up
# Check configuration
bridge link show
# Add IP address to bridge
ip addr add 192.168.2.1/24 dev br0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment