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

Adding the automatic configuration of the FPGA with the bitstream file.

parent 1c1774bc
Branches
Tags SCALP-SAFE-v0.4.2
No related merge requests found
Showing
with 205 additions and 4 deletions
......@@ -82,10 +82,10 @@ and File -> Export -> Export Hardware -> include bitstream
$ cd <SCALP_PROJECT_FOLDER>
$ git clone https://gitedu.hesge.ch/soma/scalp_petalinux.git
$ cd scalp_petalinux
$ git checkout SCALP-SAFE-v0.4.1
$ git checkout SCALP-SAFE-v0.4.2
```
**Use version 0.4.1 only for the GIT scalp_petalinux repository and not for the GIT scalp_firmware repository. The version difference is not an error.**
**Use version 0.4.2 only for the GIT scalp_petalinux repository and not for the GIT scalp_firmware repository. The version difference is not an error.**
### Create new Petalinux project from a BSP
......@@ -97,7 +97,7 @@ $ petalinux-create --type project -s <path-to-bsp> --name <PROJECT NAME>
$ cd <PROJECT NAME>
```
In my case **\<path-to-bsp\>** corresponds to /home/jo/Documents/Projets/Hepia/scalp_project/scalp_petalinux/bsp/SCALP-SAFE-FIRMWARE-BSP-V0.4.1.bsp
In my case **\<path-to-bsp\>** corresponds to /home/jo/Documents/Projets/Hepia/scalp_project/scalp_petalinux/bsp/SCALP-SAFE-FIRMWARE-BSP-V0.4.2.bsp
### Importing hardware configuration
......@@ -523,6 +523,8 @@ We start by packaging the BOOT.BIN firmware.
$ petalinux-package --boot --fsbl images/linux/zynq_fsbl.elf --fpga images/linux/system.bit --u-boot --add images/linux/ubi-image.ubi --offset 0x500000 --force
```
**With the UBI embedded flash memory volume manager, it must be ensured that the entire flash memory has been erased before use.**
Zeros are added at the end of the BOOT.BIN file up to the size of the SPI NOR memory.
```
......
File added
......@@ -3,4 +3,4 @@ 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
YOCTO_SDK=5ff8fc5f85d1566b314bb73eaa378212
RFSCONFIG_CHKSUM=098862acb0a15bbc6a0d0999eb493baa
RFSCONFIG_CHKSUM=cbbefadac8312a93a2731682ecb50ade
File added
......@@ -4022,6 +4022,8 @@ CONFIG_imagefeature-debug-tweaks=y
#
# apps
#
CONFIG_bitstream-conf=y
CONFIG_bitstream-init=y
# CONFIG_gpio-demo is not set
# CONFIG_peekpoke is not set
CONFIG_sja1105-conf=y
......
......@@ -5,3 +5,5 @@ CONFIG_gpio-demo
CONFIG_peekpoke
CONFIG_sja1105-init
CONFIG_sja1105-conf
CONFIG_bitstream-init
CONFIG_bitstream-conf
# 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/bitstream-conf"
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"
#
# This file is the bitstream-conf recipe.
#
SUMMARY = "Simple bitstream-conf application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://bitstream-conf \
"
S = "${WORKDIR}"
do_install() {
install -d ${D}/${bindir}
install -m 0755 ${S}/bitstream-conf ${D}/${bindir}
}
#!/bin/sh
export FIRMWARE_FOLDER_PATH="/lib/firmware/"
export FIRMWARE_BASE_FOLDER_PATH=${FIRMWARE_FOLDER_PATH}"base/"
export BITSTREAM_FILE_NAME="scalp_safe_firmware.bit.bin"
export BITSTREAM_PATH=${FIRMWARE_FOLDER_PATH}${BITSTREAM_FILE_NAME}
export BITSTREAM_BASE_PATH=${FIRMWARE_BASE_FOLDER_PATH}${BITSTREAM_FILE_NAME}
bitstream_copy()
{
echo "[INFO] bitstream-conf : Copy the bitstream configuration file to the /lib/firmware/ folder."
cp ${BITSTREAM_BASE_PATH} ${BITSTREAM_PATH}
}
bitstream_conf()
{
echo "[INFO] bitstream-conf : Configuration of the PL part from the bitstream configuration file."
echo 0 > /sys/class/fpga_manager/fpga0/flags
echo ${BITSTREAM_FILE_NAME} > /sys/class/fpga_manager/fpga0/firmware
}
bitstream_copy
bitstream_conf
# 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/bitstream-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"
#
# This file is the bitstream-init recipe.
#
SUMMARY = "Simple bitstream-init application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://bitstream-init \
"
S = "${WORKDIR}"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
inherit update-rc.d
INITSCRIPT_NAME = "bitstream-init"
INITSCRIPT_PARAMS = "start 03 S ."
do_install() {
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${S}/bitstream-init ${D}${sysconfdir}/init.d/bitstream-init
install -d ${D}${sysconfdir}/rc2.d
install -m 0755 ${S}/bitstream-init ${D}${sysconfdir}/rc2.d/S03bitstream-init
install -d ${D}${sysconfdir}/rc3.d
install -m 0755 ${S}/bitstream-init ${D}${sysconfdir}/rc3.d/S03bitstream-init
install -d ${D}${sysconfdir}/rc4.d
install -m 0755 ${S}/bitstream-init ${D}${sysconfdir}/rc4.d/S03bitstream-init
install -d ${D}${sysconfdir}/rc5.d
install -m 0755 ${S}/bitstream-init ${D}${sysconfdir}/rc5.d/S03bitstream-init
}
FILES_${PN} += "${sysconfdir}/*"
#!/bin/sh
### BEGIN INIT INFO
# Provides: bitstream-init
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: bitstream init.d script configuration.
### END INIT INFO
SCRIPT=bitstream-conf
RUNAS=root
PIDFILE=/var/run/bitstream-init.pid
LOGFILE=/var/log/bitstream-init.log
start() {
if [ -f /var/run/$PIDNAME ] && kill -0 $(cat /var/run/$PIDNAME); then
echo 'Service already running' >&2
return 1
fi
echo 'Starting service…' >&2
local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!"
su -c "$CMD" $RUNAS > "$PIDFILE"
echo 'Service started' >&2
}
stop() {
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
echo 'Service not running' >&2
return 1
fi
echo 'Stopping service…' >&2
echo 'Log files /var/log/bitstream-init.log and /var/log/bitstream-conf.log' >&2
kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
echo 'Service stopped' >&2
}
case "$1" in
start)
start
;;
stop)
stop
;;
retart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart|uninstall}"
esac
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment