Skip to content
Snippets Groups Projects
Commit c1240330 authored by joachim.schmidt's avatar joachim.schmidt
Browse files

Added an initialization script for the sja1105 switch.

parent 8d254fbe
No related branches found
No related tags found
No related merge requests found
Showing
with 483 additions and 10 deletions
......@@ -7,6 +7,7 @@ PetaLinux is an extension of the Yocto project that provides official support (X
**Please note that this workflow only works with Linux. Please consult the Linux distributions supported by Vivado. If you intend to use Windows and the Linux subsystem. Don't waste your time asking me questions.**
[PetaLinux 2020.2 Package List](https://www.xilinx.com/Attachment/2020.2_PetaLinux_Package_List.xlsx)
[PetaLinux 2020.2 user guide](https://www.xilinx.com/support/documentation/sw_manuals/xilinx2020_2/ug1144-petalinux-tools-reference-guide.pdf)
### First steps to perform
......@@ -213,7 +214,9 @@ The produced binary files can be found in the **./images/linux** folder.
**You can possibly check that the ZYNQ_SPI driver has been compiled.**
```
$ find . -name zynq_spi.o
> ./build/tmp/work/zynq_generic-xilinx-linux-gnueabi/u-boot-xlnx/v2020.01-xilinx-v2020.2+git999-r0/u-boot-xlnx-v2020.01-xilinx-v2020.2+git999/drivers/spi/zynq_spi.o
```
### Creation of the basic image of the U-Boot environment
......@@ -279,7 +282,7 @@ If you are using a single JTAG probe.
$ program_flash -f images/linux/BOOT.BIN -offset 0 -flash_type qspi-x4-single -fsbl images/linux/zynq_fsbl.elf -cable type xilinx_tcf url TCP:127.0.0.1:3121
```
The **program_flash** command is located in the Vitis installation folder **/tools/Xilinx/Vitis/2020.2/bin/program_flash**.
The **program_flash** command is located in the Vitis installation folder **/\<VITIS_PATH\>/2020.2/bin/program_flash** or in the PetaLinux installation folder **/\<PETALINUX_PATH\>/2020.2/bin/tools/xsct/bin**.
If you use several JTAG probes.
......@@ -353,6 +356,197 @@ $ git apply u-boot-scalp-sja1105.patch
And that's it.
### Howto create a init script (example with the init script for the configuration of the ethernet switch sja1105)
First, we start by creating a new PetaLinux application.
```
$ petalinux-create -t apps --template install -n sja1105-init --enable
```
Then we edit the BitBake file corresponding to the new application.
```
$ emacs project-spec/meta-user/recipes-apps/sja1105-init/sja1105-init.bb
```
**You can use another text editor than Emacs.**
Edit the file like this...
```
SUMMARY = "Simple sja1105-init application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://sja1105-init \
"
S = "${WORKDIR}"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
inherit update-rc.d
INITSCRIPT_NAME = "sja1105-init"
INITSCRIPT_PARAMS = "start 81 K ."
do_install() {
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${S}/sja1105-init ${D}${sysconfdir}/init.d/sja1105-init
install -d ${D}${sysconfdir}/rc0.d
install -m 0755 ${S}/sja1105-init ${D}${sysconfdir}/rc0.d/K81sja1105-init
}
FILES_${PN} += "${sysconfdir}/*"
```
Open the init script file.
```
$ emacs project-spec/meta-user/recipes-apps/sja1105-init/files/sja1105-init
```
Then, edit the init script file like this...
```
#!/bin/sh
echo "SJA1105 PetaLinux init script is running..."
ip link set swp0_east up
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : swp0_east port is up."
else
exit 1
fi
ip link set swp2_bottom up
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : swp2_bottom port is up."
else
exit 1
fi
ip link set swp3_top up
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : swp3_top port is up."
else
exit 1
fi
ip link set swp4_west up
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : swp4_west port is up."
else
exit 1
fi
ip link add name br0 type bridge
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : Added a new bridge-like interface."
else
exit 1
fi
ip link set dev br0 type bridge vlan_filtering 1
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : Configuration of the bridge interface in VLAN filtering mode."
else
exit 1
fi
ip link set dev swp0_east master br0
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : Addition of the swp0_east interface to the bridge interface."
else
exit 1
fi
ip link set dev swp2_bottom master br0
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : Addition of the swp2_bottom interface to the bridge interface."
else
exit 1
fi
ip link set dev swp3_top master br0
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : Addition of the swp3_top interface to the bridge interface."
else
exit 1
fi
ip link set dev swp4_west master br0
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : Addition of the swp4_west interface to the bridge interface."
else
exit 1
fi
bridge vlan add dev swp0_east vid 1 pvid untagged
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : Configuration of the swp0_east interface in untagged VLAN mode."
else
exit 1
fi
bridge vlan add dev swp2_bottom vid 2 pvid untagged
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : Configuration of the swp2_bottom interface in untagged VLAN mode."
else
exit 1
fi
bridge vlan add dev swp3_top vid 3 pvid untagged
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : Configuration of the swp3_top interface in untagged VLAN mode."
else
exit 1
fi
bridge vlan add dev swp4_west vid 4 pvid untagged
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : Configuration of the swp4_west interface in untagged VLAN mode."
else
exit 1
fi
ip link set br0 up
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : bridge-like interface is up."
else
exit 1
fi
```
Finaly build it...
```
$ petalinux-build -c sja1105-init -x do_install -f
$ petalinux-build -c rootfs
$ petalinux-build
```
**If you prefer to start by cleaning up your project, don't forget to add the ZYNQ_SPI driver again in the U-Boot configuration. And yes, the bug is still there.**
### Howto create a new BSP
TODO
PETALINUX_VER=2020.2
VALIDATE_HW_CHKSUM=1
HARDWARE_PATH=/home/jo/Documents/Projets/Hepia/scalp_project/scalp_firmware/designs/vivado/scalp_safe_firmware/2020.2/lin64/scalp_safe_firmware/scalp_safe_firmware.xsa
HARDWARE_CHECKSUM=c0e54849f94ffc5aaa53e1cad4e1235f
HARDWARE_CHECKSUM=e4c86ebb7157c318baafe6ea2691035e
YOCTO_SDK=5ff8fc5f85d1566b314bb73eaa378212
RFSCONFIG_CHKSUM=7fb2a289957dc67ab720c7cb67e09ee0
RFSCONFIG_CHKSUM=269e3949c0bcc4ef769c74fd4481e933
......@@ -4024,6 +4024,7 @@ CONFIG_imagefeature-debug-tweaks=y
#
# CONFIG_gpio-demo is not set
# CONFIG_peekpoke is not set
CONFIG_sja1105-init=y
#
# user packages
......
......@@ -35,7 +35,7 @@
#define CONFIG_MII
#define CONFIG_NET_MULTI
#define CONFIG_NETCONSOLE 1
#define CONFIG_SERVERIP 10.136.135.67
#define CONFIG_SERVERIP 192.168.1.153
#define CONFIG_IPADDR 192.168.0.10
#define CONFIG_GATEWAYIP 192.168.0.1
#define CONFIG_NETMASK 255.255.255.0
......
No preview for this file type
No preview for this file type
......@@ -3,3 +3,4 @@
CONFIG_gpio-demo
CONFIG_peekpoke
CONFIG_sja1105-init
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<key attr.name="base_addr" attr.type="string" for="node" id="BA"/>
<key attr.name="base_param" attr.type="string" for="node" id="BP"/>
<key attr.name="edge_hid" attr.type="int" for="edge" id="EH"/>
<key attr.name="high_addr" attr.type="string" for="node" id="HA"/>
<key attr.name="high_param" attr.type="string" for="node" id="HP"/>
<key attr.name="master_addrspace" attr.type="string" for="node" id="MA"/>
<key attr.name="master_instance" attr.type="string" for="node" id="MX"/>
<key attr.name="master_interface" attr.type="string" for="node" id="MI"/>
<key attr.name="master_segment" attr.type="string" for="node" id="MS"/>
<key attr.name="master_vlnv" attr.type="string" for="node" id="MV"/>
<key attr.name="memory_type" attr.type="string" for="node" id="TM"/>
<key attr.name="slave_instance" attr.type="string" for="node" id="SX"/>
<key attr.name="slave_interface" attr.type="string" for="node" id="SI"/>
<key attr.name="slave_segment" attr.type="string" for="node" id="SS"/>
<key attr.name="slave_vlnv" attr.type="string" for="node" id="SV"/>
<key attr.name="usage_type" attr.type="string" for="node" id="TU"/>
<key attr.name="vert_hid" attr.type="int" for="node" id="VH"/>
<key attr.name="vert_name" attr.type="string" for="node" id="VM"/>
<key attr.name="vert_type" attr.type="string" for="node" id="VT"/>
<graph edgedefault="undirected" id="G" parse.edgeids="canonical" parse.nodeids="canonical" parse.order="nodesfirst">
<node id="n0">
<data key="BA">0x43C00000</data>
<data key="BP">C_BASEADDR</data>
<data key="HA">0x43C0FFFF</data>
<data key="HP">C_HIGHADDR</data>
<data key="MA">Data</data>
<data key="MX">/processing_system7_0</data>
<data key="MI">M_AXI_GP0</data>
<data key="MS">SEG_scalp_axi4lite_0_SAXILiteAddr</data>
<data key="MV">xilinx.com:ip:processing_system7:5.5</data>
<data key="TM">both</data>
<data key="SX">/scalp_axi4lite_0</data>
<data key="SI">SAXILitexDIO</data>
<data key="SS">SAXILiteAddr</data>
<data key="SV">hepia.hesge.ch:user:scalp_axi4lite:1.2</data>
<data key="TU">register</data>
<data key="VT">AC</data>
</node>
<node id="n1">
<data key="TU">active</data>
<data key="VH">2</data>
<data key="VT">PM</data>
</node>
<node id="n2">
<data key="VM">scalp_zynqps</data>
<data key="VT">BC</data>
</node>
<node id="n3">
<data key="VH">2</data>
<data key="VM">scalp_zynqps</data>
<data key="VT">VR</data>
</node>
<edge id="e0" source="n2" target="n3">
</edge>
<edge id="e1" source="n3" target="n1">
</edge>
<edge id="e2" source="n0" target="n1">
<data key="EH">2</data>
</edge>
</graph>
</graphml>
# Load the PetaLinux SDK main gdbinit script
source plnx_gdbinit
PetaLinux User Application Template
===================================
This directory contains a PetaLinux user application created from a template.
You can easily import any already built application or script by copying
it into this directory, and editing the automatically generated Makefile
as described below.
Modify the "install:" target in Makefile to use $(TARGETINST) to install your
prebuilt application or script to the host copy of the target file system
referring to the comments of the "install:" target.
Before building the application, you will need to enable the application
from PetaLinux menuconfig by running:
"petalinux-config -c rootfs"
You will see your application in the "apps --->" submenu.
To install your prebuilt application or script to the target file system
copy on the host, simply run the command.
"petalinux-build -c rootfs/sja1105-init"
You will also need to rebuild PetaLinux bootable images so that the images
is updated with the updated target filesystem copy, run this command:
"petalinux-build -c rootfs"
You can also run one PetaLinux command to install the application to the
target filesystem host copy and update the bootable images as follows:
"petalinux-build"
#!/bin/sh
echo "SJA1105 PetaLinux init script is running..."
ip link set swp0_east up
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : swp0_east port is up."
else
exit 1
fi
ip link set swp2_bottom up
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : swp2_bottom port is up."
else
exit 1
fi
ip link set swp3_top up
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : swp3_top port is up."
else
exit 1
fi
ip link set swp4_west up
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : swp4_west port is up."
else
exit 1
fi
ip link add name br0 type bridge
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : Added a new bridge-like interface."
else
exit 1
fi
ip link set dev br0 type bridge vlan_filtering 1
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : Configuration of the bridge interface in VLAN filtering mode."
else
exit 1
fi
ip link set dev swp0_east master br0
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : Addition of the swp0_east interface to the bridge interface."
else
exit 1
fi
ip link set dev swp2_bottom master br0
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : Addition of the swp2_bottom interface to the bridge interface."
else
exit 1
fi
ip link set dev swp3_top master br0
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : Addition of the swp3_top interface to the bridge interface."
else
exit 1
fi
ip link set dev swp4_west master br0
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : Addition of the swp4_west interface to the bridge interface."
else
exit 1
fi
bridge vlan add dev swp0_east vid 1 pvid untagged
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : Configuration of the swp0_east interface in untagged VLAN mode."
else
exit 1
fi
bridge vlan add dev swp2_bottom vid 2 pvid untagged
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : Configuration of the swp2_bottom interface in untagged VLAN mode."
else
exit 1
fi
bridge vlan add dev swp3_top vid 3 pvid untagged
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : Configuration of the swp3_top interface in untagged VLAN mode."
else
exit 1
fi
bridge vlan add dev swp4_west vid 4 pvid untagged
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : Configuration of the swp4_west interface in untagged VLAN mode."
else
exit 1
fi
ip link set br0 up
if [ "$?" -eq "0" ] ; then
echo -e "[INFO] sja1105-init : bridge-like interface is up."
else
exit 1
fi
#
# This file is the sja1105-init recipe.
#
SUMMARY = "Simple sja1105-init application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://sja1105-init \
"
S = "${WORKDIR}"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
inherit update-rc.d
INITSCRIPT_NAME = "sja1105-init"
INITSCRIPT_PARAMS = "start 81 K ."
do_install() {
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${S}/sja1105-init ${D}${sysconfdir}/init.d/sja1105-init
install -d ${D}${sysconfdir}/rc0.d
install -m 0755 ${S}/sja1105-init ${D}${sysconfdir}/rc0.d/K81sja1105-init
}
FILES_${PN} += "${sysconfdir}/*"
#
# This file is the sja1105-init recipe.
#
SUMMARY = "Simple sja1105-init application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://sja1105-init \
"
S = "${WORKDIR}"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
inherit update-rc.d
INITSCRIPT_NAME = "sja1105-init"
INITSCRIPT_PARAMS = "start 81 K ."
do_install() {
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${S}/sja1105-init ${D}${sysconfdir}/init.d/sja1105-init
}
FILES_${PN} += "${sysconfdir}/*"
......@@ -165,7 +165,7 @@
//sja1105,role-phy;
fixed-link {
speed = <10>;
speed = <1000>;
full-duplex;
};
};
......@@ -177,7 +177,7 @@
//sja1105,role-phy;
fixed-link {
speed = <10>;
speed = <1000>;
full-duplex;
};
};
......@@ -189,7 +189,7 @@
//sja1105,role-mac;
fixed-link {
speed = <10>;
speed = <1000>;
full-duplex;
};
};
......@@ -201,7 +201,7 @@
//sja1105,role-phy;
fixed-link {
speed = <10>;
speed = <1000>;
full-duplex;
};
};
......@@ -213,7 +213,7 @@
//sja1105,role-mac;
fixed-link {
speed = <10>;
speed = <1000>;
full-duplex;
};
};
......@@ -246,7 +246,7 @@
//local-mac-address = [00 0a 35 00 00 00];
fixed-link {
speed = <10>;
speed = <1000>;
full-duplex;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment