I just got my HiFive1 yesterday and so far everything work OK. I was able to compile some sample programs under software/ like hello and it works fine even with run_gdb (the documentation is a bit outdated as it indicate run_debug).
But I then had to spent a couple of hours to try to find and compile a simple assembly program. After some search, I found some sample program, so I used this one here:
Next problem was that there is no facility to compile and build assembly files, so I had to create a hello_assembly dir un software, and wrote this Makefile:
TARGET = hello_assembly
FILES = hello_assembly.s
#CFLAGS = -O2 -nostdlib -nostartfiles -fno-builtin-printf
builddir := ../../work/build
# Pointers to various important tools in the toolchain.
toolchain_builddir := $(builddir)/riscv-gnu-toolchain/riscv64-unknown-elf
toolchain_prefix := $(toolchain_builddir)/prefix
RISCV_PATH ?= $(toolchain_prefix)
RISCV_AS := $(abspath $(RISCV_PATH)/bin/riscv64-unknown-elf-as)
RISCV_LD := $(abspath $(RISCV_PATH)/bin/riscv64-unknown-elf-ld)
#ASM_FLAGS = -f
OBJS = $(FILES:.s=.o)
all : $(TARGET)
hello_assembly : $(OBJS)
$(RISCV_LD) -o $(TARGET) $(OBJS)
%.o : %.s
$(RISCV_AS) $(ASM_FLAGS) -o $@ $<
.PHONY : clean
clean:
rm -f *.o *.a
#BSP_BASE = ../../bsp
#include $(BSP_BASE)/env/common.mk
Now if I run make software PROGRAM=hello_assembly it builds fine and I can upload it. However, I cannot use run_dbg, this is what happens:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from software/hello_assembly/hello_assembly...(no debugging symbols found)...done.
Remote debugging using localhost:3333
0x00007fff20400370 in ?? ()
(gdb) bt
#0 0x00007fff20400370 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) info files
Symbols from "/home/jasem/Projects/development/hardware/freedom-e-sdk/software/hello_assembly/hello_assembly".
Extended remote serial target in gdb-specific protocol:
Debugging a target over a serial line.
While running this, GDB does not access memory from...
Local exec file:
`/home/jasem/Projects/development/hardware/freedom-e-sdk/software/hello_assembly/hello_assembly', file type elf64-littleriscv.
Entry point: 0x10078
0x0000000000010078 - 0x00000000000100b0 is .text
0x00000000000100b0 - 0x00000000000100bd is .rodata
(gdb) j 0x10078
Function "0x10078" not defined.
(gdb) j 10078
No symbol table is loaded. Use the "file" command.
(gdb) j _start
Continuing at 0x10078.
Remote connection closed
In the terminal where I have openocd running, I see this:
Open On-Chip Debugger 0.10.0+dev (2017-10-22-00:41)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
adapter speed: 10000 kHz
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"
Info : clock speed 10000 kHz
Info : JTAG tap: riscv.cpu tap/device found: 0x10e31913 (mfg: 0x489 (SiFive, Inc.), part: 0x0e31, ver: 0x1)
Info : Examined RISCV core; XLEN=32, misa=0x40001105
Info : Listening on port 3333 for gdb connections
Info : [0] Found 2 triggers
halted at 0x20400370 due to debug interrupt
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : accepting 'gdb' connection on tcp/3333
Info : Found flash device 'issi is25lp128' (ID 0x0018609d)
Core got an exception (0xffffffff) while reading from 0x10078
Core got an exception (0xffffffff) while reading from 0x1007c
Core got an exception (0xffffffff) while reading from 0x10080
Core got an exception (0xffffffff) while reading from 0x10084
Core got an exception (0xffffffff) while reading from 0x10088
Core got an exception (0xffffffff) while reading from 0x1008c
Core got an exception (0xffffffff) while reading from 0x10090
Core got an exception (0xffffffff) while reading from 0x10094
Core got an exception (0xffffffff) while reading from 0x10098
Core got an exception (0xffffffff) while reading from 0x1009c
Core got an exception (0xffffffff) while reading from 0x100a0
Core got an exception (0xffffffff) while reading from 0x100a4
Core got an exception (0xffffffff) while reading from 0x100a8
Core got an exception (0xffffffff) while reading from 0x100ac
Core got an exception (0xffffffff) while reading from 0x100b0
Core got an exception (0xffffffff) while reading from 0x100b4
Core got an exception (0xffffffff) while reading from 0x100b8
Core got an exception (0xffffffff) while reading from 0x100bc
Core got an exception (0xffffffff) while reading from 0x100c0
Core got an exception (0xffffffff) while reading from 0x100c4
Core got an exception (0xffffffff) while reading from 0x100c8
Core got an exception (0xffffffff) while reading from 0x100cc
Core got an exception (0xffffffff) while reading from 0x100d0
Core got an exception (0xffffffff) while reading from 0x100d4
Core got an exception (0xffffffff) while reading from 0x100d8
Error: gdb sent a packet with wrong register size
Info : dropped 'gdb' connection
So I’m stuck now. If I try to add more debugging via --gstabs+ but then the assembler fails with internal error. Any hints on what to do?