summaryrefslogtreecommitdiffstats
path: root/scripts/socfpga_import_preloader
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/socfpga_import_preloader')
-rwxr-xr-xscripts/socfpga_import_preloader100
1 files changed, 86 insertions, 14 deletions
diff --git a/scripts/socfpga_import_preloader b/scripts/socfpga_import_preloader
index 6c748fadb8..e917dcafef 100755
--- a/scripts/socfpga_import_preloader
+++ b/scripts/socfpga_import_preloader
@@ -1,16 +1,70 @@
-#!/bin/bash
+#!/usr/bin/env bash
+
+usage() {
+ echo "USAGE: $0
+ parameters:
+ -s|--spl-dir <SPL_GENERATED_DIR>
+ -i|--isw-handoff <ISW_HANDOFF>
+ -b|--board <BOARD_DIRECTORY>
+ optional:
+ -e|--embedded-sdk <ALTERA_EMBEDDED_SDK>"
+ echo "EXAMPLE: $0 -i ~/cv_soc_devkit_ghrd/hps_isw_handoff/soc_system_hps_0/ -b arch/arm/boards/altera-socdk -e ~/altera-embedded-sdk/"
+ exit 1
+}
-if [ "$#" -lt "2" ]
-then
- echo "USAGE: $0 <EMBEDDED_SDK> <ISW_HANDOFF> <BOARD_DIRECTORY>"
- echo "EXAMPLE: $0 ~/altera-embedded-sdk/ ~/cv_soc_devkit_ghrd/hps_isw_handoff/soc_system_hps_0/ arch/arm/boards/altera-socdk"
+die() {
+ printf '%s\n' "$1" >&2
exit 1
-fi
+}
+
+generate=
+splroot=
+embeddedsw=
+handoff=
+boardroot=
+
+while :; do
+ case $1 in
+ -e|--embedded-sdk)
+ if [ "$2" ]; then
+ generate=1
+ splroot="$(mktemp -d)"
+ embeddedsw=${2}
+ shift
+ else
+ die 'ERROR: "--embedded-sdk" requires a non-empty option argument.'
+ fi
+ ;;
+ -s|--spl-dir)
+ if [ "$2" ]; then
+ splroot="$2"
+ shift
+ else
+ die 'ERROR: "--spl-dir" requires a non-empty option argument.'
+ fi
+ ;;
+ -i|--isw-handoff)
+ if [ "$2" ]; then
+ handoff="$2"
+ shift
+ else
+ die 'ERROR: "--isw-handoff" requires a non-empty option argument.'
+ fi
+ ;;
+ -b|--board)
+ if [ "$2" ]; then
+ boardroot="$2"
+ shift
+ else
+ die 'ERROR: "--board" requires a non-empty option argument.'
+ fi
+ ;;
+ *)
+ break
+ esac
+ shift
+done
-splroot="$(mktemp -d)"
-embeddedsw=$1
-handoff=$2
-boardroot=$3
bareboxsrc=.
cd ${bareboxsrc}
@@ -25,6 +79,9 @@ copy_source() {
cp $src $tgt
+ dos2unix $tgt
+
+ echo " Fixing conditional compilation..."
unifdef -D HCX_COMPAT_MODE=1 -D ENABLE_INST_ROM_WRITE=1 $tgt -o $tgt
echo " Fixing extern/static keywords..."
@@ -45,9 +102,9 @@ copy_source() {
sed -i 's/alt_8/int8_t/g' $tgt
sed -i 's/#include "alt_types.h"//g' $tgt
- echo " Fixing include pathes..."
+ echo " Fixing include paths..."
# Fix include pathes
- sed -i 's/#include <iocsr_config_cyclone5.h>/#include <mach\/cyclone5-scan-manager.h>/g' $tgt
+ sed -i 's/#include <iocsr_config_cyclone5.h>/#include <mach\/socfpga\/cyclone5-scan-manager.h>/g' $tgt
sed -i 's/#include <pinmux_config.h>/#include <common.h>/g' $tgt
sed -i 's/#include "sequencer_auto.h"//g' $tgt
sed -i 's/#include "sequencer_defines.h"//g' $tgt
@@ -57,7 +114,20 @@ copy_source() {
sed -i 's/ $//g' $tgt
}
-python2.7 ${embeddedsw}/embedded/ip/altera/preloader/scripts/iswgen.py -i ${handoff} -o ${splroot}/
+generate_spl() {
+ USE_SOCEDS_PYTHON=1 SOCEDS_DESTROY_PATH=1 \
+ ${embeddedsw}/embedded/embedded_command_shell.sh python \
+ ${embeddedsw}/embedded/ip/altera/preloader/scripts/iswgen.py \
+ -i ${handoff} -o ${splroot}/
+}
+
+if [ -z $splroot ] || [ -z $boardroot ] || [ -z $handoff ]; then
+ usage
+fi
+
+if [ $generate ]; then
+ generate_spl
+fi
copy_source ${splroot}/iocsr_config_cyclone5.c ${boardroot}/iocsr_config_cyclone5.c
copy_source ${splroot}/pinmux_config_cyclone5.c ${boardroot}/pinmux_config.c
@@ -69,6 +139,8 @@ copy_source ${handoff}/sequencer_auto_ac_init.c ${boardroot}/sequencer_auto_ac_i
copy_source ${handoff}/sequencer_auto_inst_init.c ${boardroot}/sequencer_auto_inst_init.c
copy_source ${handoff}/sequencer_defines.h ${boardroot}/sequencer_defines.h
-rm -r ${splroot}
+if [ $generate ]; then
+ rm -r ${splroot}
+fi
echo "DONE"