3131
3232set -Eeuo pipefail
3333
34+ # sudo's secure_path overrides PATH even with -E; ensure SDE paths are included.
35+ if [[ -n " ${SDE_INSTALL:- } " ]]; then
36+ PATH=" $SDE_INSTALL /bin:$PATH "
37+ fi
38+ if [[ -n " ${SDE:- } " ]]; then
39+ PATH=" $SDE :$PATH "
40+ fi
41+ export PATH
42+
3443# ##########################
3544# Configuration (edit me) #
3645# ##########################
@@ -160,7 +169,8 @@ run_xt_cfgen_fallback() {
160169
161170 info " Attempting fallback loader for '$target_mod ' via: $script "
162171 set +e
163- " $script "
172+ # xt-cfgen.sh expects sibling scripts (e.g. xt-setup.sh) to be in PATH
173+ PATH=" $SDE_INSTALL /bin:$PATH " " $script "
164174 local rc=$?
165175 set -e
166176
@@ -198,9 +208,14 @@ load_kernel_module_if_needed() {
198208 warn " Loader for '$kmod ' not found at $loader ; trying xt-cfgen.sh fallback."
199209 if run_xt_cfgen_fallback " $kmod " ; then
200210 continue
201- else
202- return 2
203211 fi
212+ # bf_fpga is not available on all platforms (e.g. Asterfusion).
213+ # If the module file doesn't exist in the kernel, treat it as optional.
214+ if ! modinfo bf_fpga > /dev/null 2>&1 ; then
215+ warn " Kernel module 'bf_fpga' not available on this system; skipping (non-fatal)."
216+ continue
217+ fi
218+ return 2
204219 fi
205220
206221 require_exe " $loader "
@@ -226,6 +241,11 @@ load_kernel_module_if_needed() {
226241 if run_xt_cfgen_fallback " $kmod " ; then
227242 continue
228243 fi
244+ # bf_fpga is not available on all platforms (e.g. Asterfusion).
245+ if ! modinfo bf_fpga > /dev/null 2>&1 ; then
246+ warn " Kernel module 'bf_fpga' not available on this system; skipping (non-fatal)."
247+ continue
248+ fi
229249 fi
230250
231251 if is_mod_loaded " $kmod " ; then
@@ -635,6 +655,7 @@ cmd_install() {
635655
636656cmd_start () {
637657 info " === p4tg: START ==="
658+ backup_platform_conf
638659 require_env_dir SDE
639660 require_env_dir SDE_INSTALL
640661 load_kernel_module_if_needed || exit $?
@@ -745,7 +766,6 @@ main() {
745766 done
746767
747768 local cmd=" ${args[0]:- help} "
748- backup_platform_conf
749769 case " $cmd " in
750770 install) cmd_install ;;
751771 update) cmd_install ;;
0 commit comments