1. 下载工具链
https://github.com/gnu-mcu-eclipse/riscv-none-gcc/releases
64bit下载: gnu-mcu-eclipse-riscv-none-gcc-7.2.0-4-20180606-1631-centos64.tgz
32bit下载: gnu-mcu-eclipse-riscv-none-gcc-7.2.0-4-20180606-1631-centos32.tgz
解压到 /usr/local 目录:
tar xvf gnu-mcu-eclipse-riscv-none-gcc-7.2.0-4-20180606-1631-centos64.tgz -C /usr/local/修改 ~/.bashrc 文件, 添加:
export PATH=/usr/local/gnu-mcu-eclipse/riscv-none-gcc/7.2.0-4-20180606-1631/bin/:$PATH
2. 编译qemu模拟器
sudo apt-get install libpixman-1-dev
git clone https://github.com/riscv/riscv-qemu.git
cd riscv-qemu/
git checkout riscv-qemu-3.0
./configure --target-list=riscv64-linux-user,riscv64-softmmu [--prefix=INSTALL_LOCATION]
make -j4
make install ###安装
3. 克隆 xboot 源码
git clone https://github.com/xboot/xboot.git
cd xboot
make CROSS_COMPILE=riscv-none-embed- PLATFORM=riscv64-virt -j4
4. 在 qemu 虚拟机平台运行 xboot
cd xboot
tools/qemu-system/linux/riscv64-virt-run.sh ###直接运行
tools/qemu-system/linux/riscv64-virt-dbg.sh ###调试运行
5. 开启 gdb 命令行调试.
riscv-none-embed-gdb
参考链接1: https://www.cnblogs.com/javaIOException/p/7525828.html
参考链接2: https://whycan.cn/t_1685.html
离线
编译成32/64bit版本:
riscv-none-embed-gcc -o test2 test2.S -g -nostdlib -march=rv64imafdc -mabi=lp64d
riscv-none-embed-gcc -o test2 test2.S -g -nostdlib -march=rv32imafdc -mabi=ilp32d
离线