runninglinuxkernel / riscv_programming_practice

178 stars 59 forks source link

example_18_3_gdb_asm Memory address 0x10010048 is invalid #2

Closed sunmin89 closed 9 months ago

sunmin89 commented 1 year ago

Hi, this example failed to execute.

spike --rbb-port=1234 -m0x10000000:0x20000 --isa=rv64gcv test

Listening for remote bitbang connection on port 1234.
Access exception occurred while loading payload test:
Memory address 0x10010048 is invalid

My host is OS ubuntu 18.04

And my self built riscv64-unknown-elf-gcc info is :

Using built-in specs.
COLLECT_GCC=riscv64-unknown-elf-gcc
COLLECT_LTO_WRAPPER=/home/sunmin/aosp-out/rvv/bin/libexec/gcc/riscv64-unknown-elf/12.0.1/lto-wrapper
Target: riscv64-unknown-elf
Configured with: /home/sunmin/aosp-out/rvv/riscv-gnu-toolchain/build/../riscv-gcc/configure --target=riscv64-unknown-elf --prefix=/home/sunmin/aosp-out/rvv/bin --disable-shared --disable-threads --enable-languages=c,c++ --with-pkgversion=g42df3464463 --with-system-zlib --enable-tls --with-newlib --with-sysroot=/home/sunmin/aosp-out/rvv/bin/riscv64-unknown-elf --with-native-system-header-dir=/include --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libgomp --disable-nls --disable-tm-clone-registry --src=../../riscv-gcc --enable-multilib --with-abi=lp64d --with-arch=rv64imafdc --with-tune=rocket --with-isa-spec=2.2 'CFLAGS_FOR_TARGET=-Os   -mcmodel=medlow' 'CXXFLAGS_FOR_TARGET=-Os   -mcmodel=medlow'
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 12.0.1 20220505 (prerelease) (g42df3464463)
sunmin89 commented 1 year ago

It seems that this issue is related to spike version, my version is two new (1.1.1-dev ), while v1.1.0 seems okay [1]

I wish the author can update the example code accordingly.

Besides, this example also need openocd. It doesn't work if you install it from apt install openocd.

Prebuilt binary from [3] doesn't work for me either.

One should build it from source by himself [2].

good luck!

[1] https://github.com/riscv-software-src/riscv-isa-sim/releases/tag/v1.1.0 [2] https://github.com/riscv/riscv-openocd [3] https://muforth.nimblemachines.com/getting-openocd-for-risc-v/

runninglinuxkernel commented 1 year ago

Thanks your point out, the v1.1.0 version of spike was the latest version when i wrote this book one or two years ago. i think the specific version of Spike is better for readers.

This example code is for the Chinese book RISC-V Architecture programming and practicing, you can buy it on JD. https://item.jd.com/13629613.html

It is no plan to update the code to the latest spike until the second version of this book. But bug fix and feedback are welcome.

For this book, we have provided a pre-configured VMware/VirtualBox image for readers, which has installed the RISC-V toolchain, like RISC-V GCC, RVV GCC, spike, openocd, eclipse on Ubuntu 20.04.

Here is the step to get the download address of this VMware/Virtualbox image: 关注 "奔跑吧Linux社区“ 微信公众号,输入“risc-v”获取下载地址。

We strongly recommended that use our pre-configured VMware/VirtualBox image. if you want to compile and install the RVV GCC toolchain by scratch, pls follow our guide I have added in Chapter_18 folder. https://github.com/runninglinuxkernel/riscv_programming_practice/commit/5e6ac8cd1cd16f11a030115494e18e066a53dd0a