- LS1021ATSN
The sja1105-tool is a Linux userspace application for configuring the NXP SJA1105 Automotive Ethernet L2 switch. The tool supports:
- Importing a configuration for the SJA1105 switch from an XML file
- Exporting the current SJA1105 configuration as an XML file
- Uploading the current SJA1105 configuration to the switch through its SPI interface
- Inspecting the current SJA1105 configuration
- On-the-fly modification of the current SJA1105 configuration through command line or scripting interface
To compile this demo you need to have setup a Linux machine with the following:
- An ARMv7 toolchain for the LS1021. You can get one from Linaro (version used here is 7.4.1).
cd <base_dir>
mkdir linaro-armv7-toolchain
cd linaro-armv7-toolchain
wget https://releases.linaro.org/components/toolchain/binaries/latest-7/arm-linux-gnueabihf/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf.tar.xz
wget https://releases.linaro.org/components/toolchain/binaries/latest-7/arm-linux-gnueabihf/sysroot-glibc-linaro-2.25-2019.02-arm-linux-gnueabihf.tar.xz
tar xvf gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf.tar.xz
tar xvf sysroot-glibc-linaro-2.25-2019.02-arm-linux-gnueabihf.tar.xz
# rm -rf gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf.tar.xz
# rm -rf sysroot-glibc-linaro-2.25-2019.02-arm-linux-gnueabihf.tar.xz
# Copy and paste this command down until (and including) the EOF
cat << 'EOF' > envsetup
#!/bin/bash
export TOPDIR=$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd)
export SYSROOT_PATH="${TOPDIR}/sysroot-glibc-linaro-2.25-2019.02-arm-linux-gnueabihf"
export PKG_CONFIG_PATH="${SYSROOT_PATH}/usr/lib/pkgconfig"
export PATH="${TOPDIR}/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin:$PATH"
export CC="arm-linux-gnueabihf-gcc -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=${SYSROOT_PATH}"
export CXX="arm-linux-gnueabihf-g++ -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=${SYSROOT_PATH}"
export CPP="arm-linux-gnueabihf-gcc -E -march=armv7-a -mfloat-abi=hard -mfpu=neon -mtune=cortex-a7 --sysroot=${SYSROOT_PATH}"
export AS="arm-linux-gnueabihf-as "
export LD="arm-linux-gnueabihf-ld --sysroot=${SYSROOT_PATH}"
export GDB="arm-linux-gnueabihf-gdb"
export STRIP="arm-linux-gnueabihf-strip"
export RANLIB="arm-linux-gnueabihf-ranlib"
export OBJCOPY="arm-linux-gnueabihf-objcopy"
export OBJDUMP="arm-linux-gnueabihf-objdump"
export AR="arm-linux-gnueabihf-ar"
export NM="arm-linux-gnueabihf-nm"
export M4="m4"
export TARGET_PREFIX="arm-linux-gnueabihf-"
export CONFIGURE_FLAGS="--target=arm-linux-gnueabihf --host=arm-linux-gnueabihf --build=x86_64-linux --with-libtool-sysroot=${SYSROOT_PATH}"
export CFLAGS="-O2 -pipe -g -feliminate-unused-debug-types -I${SYSROOT_PATH}/include"
export CXXFLAGS="-O2 -pipe -g -feliminate-unused-debug-types -I${SYSROOT_PATH}/include"
export LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -L${SYSROOT_PATH}/lib"
export ARCH="arm"
export CROSS_COMPILE="arm-linux-gnueabihf-"
EOF
# Keep a note of this folder, because we'll be referring it later in the tutorial
export TOOLCHAIN_PATH="${PWD}"
- Libxml2. Unfortunately, this is not included in the standalone ARM toolchain we're using, so we have to add it manually:
cd <base_dir>
# Grab the latest libxml tarball (I used 2.9.3)
wget http://xmlsoft.org/sources/libxml2-sources-2.9.3.tar.gz
# Extract it in the current directory
tar xvf libxml2-sources-2.9.3.tar.gz
cd libxml2-2.9.3
# Remember the $TOOLCHAIN_PATH we set just above
source "${TOOLCHAIN_PATH}/envsetup"
./configure \
--prefix="${SYSROOT_PATH}" \
--host=arm-linux-gnueabihf \
--includedir="${SYSROOT_PATH}/usr/include" \
--libdir="${SYSROOT_PATH}/usr/lib" \
--without-python \
--without-lzma
make -j 128
make install
# When compiling sja1105-tool, it will use pkg-config to find the proper
# location of libxml2, which is the --libdir parameter from above.
cd <base_dir>
git clone git@github.com:openil/sja1105-tool.git
cd sja1105-tool
# Again, remember your $TOOLCHAIN_PATH
source "${TOOLCHAIN_PATH}/envsetup"
make -j 128
# To build the manpages, run "make man" or "make all"
# However, this step requires the "pandoc" package to be installed.
DESTDIR=out make install
The following manual pages are provided:
cd docs/man
man -l ./sja1105-tool.1 # General command overview
man -l ./sja1105-tool-config.1 # Detailed usage of sja1105-tool config
man -l ./sja1105-tool-status.1 # Detailed usage of sja1105-tool status
man -l ./sja1105-tool-reset.1 # Detailed usage of sja1105-tool reset
man -l ./sja1105-conf.5 # File format for sja1105-tool configuration
man -l ./sja1105-tool-config-format.5 # File format for XML switch configuration tables
Chassis port label | Switch port number | PHY ID |
---|---|---|
ETH2 | RGMII 1 | 3 |
ETH3 | RGMII 2 | 4 |
ETH4 | RGMII 3 | 5 |
ETH5 | RGMII 0 | 6 |
Internal | RGMII 4 | - |
- Link speed autonegotiation is not supported.
In the default LS1021ATSN configuration, link speed on all ports is set to 1000Mbps.
The 5 ports of the SJA1105 switch do not have a Linux kernel driver. As such, the PHY chip (BCM5464R) attached to the 4 externally connected ports of the LS1021ATSN board (ETH2, ETH3, ETH4, ETH5) is not controlled by the Linux kernel either.
There is a workaround for this issue, that is to disable auto-negotiation on the
PHY and keep the link speeds manually in sync between the PHY and the switch
ports. The init script that does this is etc/sja1105-link-speed-fixup
,
and is deployed in OpenIL at /etc/init.d/S46sja1105-link-speed-fixup
.
Link speeds should be set at their desired values in this init script.
- Clock synchronization via TTEthernet (SAE AS6802) is not supported.
When creating a new issue in the Github tracker, it may be useful to describe the usage scenario, as well as provide an XML configuration and an SPI dump of the configuration you are sending to the switch.
To get an XML configuration:
sja1105-tool config save bug.xml
To get an SPI dump:
# Modify /etc/sja1105/sja1105.conf:
# dry_run = false
sja1105-tool config upload > spi_dump.log