A non-IDE approach to programming the HPS ARM A9 core on the DE1-SoC (by Martin Nguyen).
The ARM DS-5 IDE provides an easy way to program the HPS but it requires a license that I couldn't obtain. I've been looking for other alternatives to program the HPS using only command-line tools to no avail. After a lot of reading on various blogs and too many PDFs on DE1-SoC, I've found a workaround.
Altera GCC toolchain (for arm-none-eabi-gcc, arm-none-eabi-as,...), maybe GNU Arm Embedded Toolchain could also work but to be tested
Quartus Prime (for command-line tools to interface with the DE1-SoC)
There is the Intel FPGA Monitor Program that can load and debug a binary on the HPS but it is deprecated. I downloaded a copy and tried to reverse engineer the commands it used to flash the board.
I used ProcMon from Sysinternals to record all the commands it calls. An interesting command is quartus_hps.exe
.
In fact, quartus_hps.exe
is actually the GDB server that Intel FPGA Monitor program will connect to for debugging.
I also found other commands it used to build the binaries. Here, flicker.s
is the assembly code for our demo HEX flickering program.
cd D:/Programming/de1soc_flicker/; make clean
rm -f flicker.srec flicker.axf flicker.s.o
cd D:/Programming/de1soc_flicker/; make compile
rm -f flicker.s.o
arm-altera-eabi-as -mfloat-abi=soft -march=armv7-a -mcpu=cortex-a9 --gstabs -I "$GNU_ARM_TOOL_ROOTDIR/arm-altera-eabi/include/" flicker.s -o flicker.s.o
rm -f flicker.axf
arm-altera-eabi-ld --defsym arm_program_mem=0x0 --defsym arm_available_mem_size=0x3ffffff8 --defsym __cs3_stack=0x3ffffff8 -T"D:/intelFPGA_lite/18.0/University_Program/Monitor_Program/build/altera-socfpga-unhosted-as.ld" -e _start -u _start flicker.s.o -o flicker.axf
rm -f flicker.srec
arm-altera-eabi-objcopy -O srec flicker.axf flicker.srec
and the commmand to start the GDB server on port 4444:
D:\intelFPGA_lite\18.0\quartus\bin64\quartus_hps.exe "--cable=DE-SoC [USB-1]" -o GDBSERVER -gdbport0 4444 --preloader D:/intelFPGA_lite/18.0/University_Program/Monitor_Program/arm_tools/u-boot-spl.de1-soc.srec --preloaderaddr 0xffff13a0 --source D:/Programming/de1soc_flicker/flicker.srec
All that is left is to connect to the GDB server with your preferred GDB GUI or just gdb
.
$ gdb
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) target remote localhost:4444
Remote debugging using localhost:4444
0xffff5ec0 in ?? ()
(gdb)