diff options
author | Steffen Trumtrar <s.trumtrar@pengutronix.de> | 2021-06-11 10:02:33 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-08-23 16:09:26 +0200 |
commit | c54e4c9107379e6122fb070edcee638256bb9bda (patch) | |
tree | 2c649aff5ae8df85d7e47d9a1921278d09dfa67b /scripts | |
parent | db73e5d8de2a1e4814ec32b07b03d4212c001420 (diff) | |
download | barebox-c54e4c9107379e6122fb070edcee638256bb9bda.tar.gz barebox-c54e4c9107379e6122fb070edcee638256bb9bda.tar.xz |
scripts: socfpga_import_preloader: make sdk optional
The commit a9b2e6089d82686564220013f14e9f0ffcc725e2 allowed generating
everything needed in one step. This was however a bit too ambitious.
The script now requires that the Altera Embedded SDK is always
installed. There are situations where this is unwanted.
Beef up the code a little bit to allow having the SDK as an optional
argument and make the other input parameters location independent.
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Link: https://lore.barebox.org/20210611080233.15141-1-s.trumtrar@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/socfpga_import_preloader | 88 |
1 files changed, 77 insertions, 11 deletions
diff --git a/scripts/socfpga_import_preloader b/scripts/socfpga_import_preloader index 23e3c380db..2bec9f2d21 100755 --- a/scripts/socfpga_import_preloader +++ b/scripts/socfpga_import_preloader @@ -1,16 +1,70 @@ #!/usr/bin/env bash -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" +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 -fi +} + +die() { + printf '%s\n' "$1" >&2 + exit 1 +} + +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} @@ -57,7 +111,17 @@ copy_source() { sed -i 's/ $//g' $tgt } -python2.7 ${embeddedsw}/embedded/ip/altera/preloader/scripts/iswgen.py -i ${handoff} -o ${splroot}/ +generate_spl() { + python2.7 ${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 +133,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" |