summaryrefslogtreecommitdiff
path: root/scripts/support
diff options
context:
space:
mode:
authorAndrew Boie <andrew.p.boie@intel.com>2016-07-11 13:16:24 -0700
committerInaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>2016-07-12 18:09:57 +0000
commit50131a3d0e85f99171b308281a77b53a1b3a1c23 (patch)
tree799b4e42bff1f5727cee669e12b3e19b87cd8210 /scripts/support
parent4eee43d4d41712acbb12aaa1a93c273837bfdd31 (diff)
altera_max10: support 'make flash' and 'make debug'
For both of these, we send the .elf binary over the JTAG and it gets written directly into SRAM. The CPU boots the image from the entry point (__start). This does not provision the kernel onto device's User Flash Memory (UFM). Implementation of this is still in progress see ZEP-273. Change-Id: Iae8188a21e4a3eecfda0f4f0bb220c0607d719cb Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Diffstat (limited to 'scripts/support')
-rwxr-xr-xscripts/support/nios2.sh48
1 files changed, 32 insertions, 16 deletions
diff --git a/scripts/support/nios2.sh b/scripts/support/nios2.sh
index 1b96ab16b..2981345cf 100755
--- a/scripts/support/nios2.sh
+++ b/scripts/support/nios2.sh
@@ -5,35 +5,51 @@ set -e
HEX_NAME=${O}/${KERNEL_HEX_NAME}
ELF_NAME=${O}/${KERNEL_ELF_NAME}
-GDB_TCP_PORT=1234
+# XXX nios2-gdb-server doesn't seem to clean up after itself properly,
+# and often will report "Unable to bind (98)" when restarting a session.
+# Eventually the kernel cleans things up, but it takes a couple minutes.
+# Use a random port each time so this doesn't annoy users. Use netstat to
+# confirm that the randomly selected port isn't being used.
+GDB_TCP_PORT=
+while [ -z "$GDB_TCP_PORT" ]; do
+ GDB_TCP_PORT=$(shuf -i1024-49151 -n1)
+ netstat -atn | grep "127[.]0[.]0[.]1[:]$GDB_TCP_PORT" || break
+ GDB_TCP_PORT=
+done
-REQUIRED_PROGRAMS="quartus_cpf quartus_pgm nios2-gdb-server"
+REQUIRED_PROGRAMS="nios2-gdb-server nios2-download"
for pgm in ${REQUIRED_PROGRAMS}; do
type -P $pgm > /dev/null 2>&1 || { echo >&2 "$pgm not found in PATH"; exit 1; }
done
-do_flash() {
- if [ -z "${NIOS2_CPU_SOF}" ]; then
- echo "Please set NIOS2_CPU_SOF variable to location of CPU .sof data"
- exit 1
- fi
+# XXX do_flash() and do_debug() only support cases where the .elf is sent
+# over the JTAG and the CPU directly boots from __start. CONFIG_XIP and
+# CONFIG_INCLUDE_RESET_VECTOR must be disabled.
- ${ZEPHYR_BASE}/scripts/support/quartus-flash.py \
- --sof ${NIOS2_CPU_SOF} \
- --kernel ${HEX_NAME}
+do_flash() {
+ nios2-download --go ${ELF_NAME}
}
do_debug() {
- do_debugserver &
+ do_debugserver 1 &
# connect to the GDB server
- ${GDB} ${TUI} -ex "target remote :${GDB_TCP_PORT}" ${ELF_NAME}
+ ${GDB} ${TUI} -ex "target remote :${GDB_TCP_PORT}" -ex "load" ${ELF_NAME}
}
do_debugserver() {
- nios2-gdb-server --tcpport ${GDB_TCP_PORT}
+ # Calling with an arg will result in setsid being used, which will prevent
+ # Ctrl-C in GDB from killing the server. The server automatically exits
+ # when the remote GDB disconnects.
+ if [ -n "$1" ]; then
+ SETSID=/usr/bin/setsid
+ else
+ SETSID=
+ fi
+ echo "Nios II GDB server running on port ${GDB_TCP_PORT}"
+ ${SETSID} nios2-gdb-server --tcpport ${GDB_TCP_PORT} --init-cache --reset-target
}
@@ -42,12 +58,12 @@ shift
case "${CMD}" in
flash)
- do_flash "$@"
+ do_flash
;;
debugserver)
- do_debugserver "$@"
+ do_debugserver
;;
debug)
- do_debug "$@"
+ do_debug
;;
esac