Learn with SHAKTI
Using Arty-7 100T with SHAKTI
STEP 1: Prerequisites
Note: Please ensure SHAKTI C Class is programmed onto the Arty-7 100t board
1. Install the required packages.
sudo apt-get install python-serial
If you face any error while running any command, Please refer FAQ section.
2. Please ensure SHAKTI toolchain is installed successfully.
which riscv64-unknown-elf-gcc
which openocd
3. Please connect Arty-7 100t board to the system using the microUSB cable.
Step 2: Write a simple C program to print Hello world
Copy paste the below content in it and save it as first.c
STEP 3: Compile and Build
1. Move inside the spiking folder and update it.
cd spiking
git pull
2. In the spiking folder, Run the below commands to compile first.c for SHAKTI. The necessary header and linker files are included in the spiking repository.
- To generate crt.o from crt.S which is available in spiking folder.
riscv64-unknown-elf-gcc -mcmodel=medany -static -std=gnu99 -fno-builtin-printf -c crt.S -o crt.o
- To generate syscalls.shakti from syscalls.c which is available in spiking folder.
riscv64-unknown-elf-gcc -mcmodel=medany -static -std=gnu99 -fno-builtin-printf -c syscalls.c -o syscalls.shakti -lm -lgcc
- To generate uart.o from uart.c which is available in spiking folder.
riscv64-unknown-elf-gcc -mcmodel=medany -static -std=gnu99 -fno-builtin-printf -c uart.c -o uart.o -lm -lgcc
-
To generate first.o from first.c which is the file created in the earlier step.
riscv64-unknown-elf-gcc -mcmodel=medany -static -std=gnu99 -fno-builtin-printf -c first.c -o first.o -lm -lgcc
-
To link all the object files (.o, .shakti) using the linker file link.ld.
riscv64-unknown-elf-gcc -T link.ld first.o uart.o crt.o syscalls.shakti -o first.shakti -static -nostartfiles -lm -lgcc
STEP 4: Debugging
The Arty-7 100T board is programmed with SHAKTI C class SoC. Please ensure Arty-7 100T board is connected to the the Host PC.
- The Arty-7 100T board should be attached to the OpenOCD debugger, in order to debug your program using the RISC-V GNU Debugger (GDB) software. Read how RISC-V GDB and OpenOCD work together to establish a connection between the Microprocessor and Host PC.
- Since we have built the application, already. We can straight away load it to the Arty-7 100T board and test.
If you face any error while running any command, Please refer FAQ section.
sudo miniterm.py /dev/ttyUSB0 19200
--- Miniterm on /dev/ttyUSB0 19200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
Note: "/dev/ttyUSB0" - ttyUSB means "USB serial port adapter" and the "0" ( "0" or "1" or "2") is the USB device number to which the board is connected and 19200 is the default baud rate.
sudo $(which openocd) -f ftdi.cfg
[sudo] password for rise:
Open On-Chip Debugger 0.10.0+dev-00615-gfd9c54b (2019-07-12-15:10) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html adapter speed: 1000 kHz none separate Info : auto-selecting first available session transport "jtag". To override use 'transport select'. Info : Simple Register based Bscan Tunnel Selected Info : clock speed 1000 kHz Info : JTAG tap: riscv.cpu tap/device found: 0x13631093 (mfg: 0x049 (Xilinx), part: 0x3631, ver: 0x1) Info : datacount=12 progbufsize=0 Warn : We won't be able to execute fence instructions on this target. Memory may not always appear consistent. (progbufsize=0, impebreak=0) Info : Examined RISC-V core; found 1 harts Info : hart 0: XLEN=64, misa=0x800000000014112d Info : Listening on port 3333 for gdb connections Info : Listening on port 6666 for tcl connections Info : Listening on port 4444 for telnet connections Info : accepting 'gdb' connection on tcp/3333
riscv64-unknown-elf-gdb
GNU gdb (GDB) 9.1 Copyright (C) 2020 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 "--host=x86_64-pc-linux-gnu --target=riscv64-unknown-elf". Type "show configuration" for configuration details. For bug reporting instructions, please see: < 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".
(gdb) set remotetimeout unlimited
(gdb) target remote localhost:3333
Remote debugging using localhost:3333 warning: No executable has been specified and target does not support determining executable automatically. Try using the "file" command. Python Exception'gdb.Inferior' object has no attribute 'progspace': 0x0000000000000004 in ?? ()
(gdb) file first.shakti
A program is being debugged already. Are you sure you want to change the file? (y or n) y Reading symbols from first.shakti...(no debugging symbols found)...done.
(gdb) load
Loading section .text.init, size 0x1c2 lma 0x80000000 Loading section .tohost, size 0x48 lma 0x80001000 Loading section .text, size 0x1018 lma 0x80001048 Loading section .rodata, size 0x1b0 lma 0x80002060 Start address 0x80000000, load size 5074 Transfer rate: 6 KB/sec, 1268 bytes/write.
(gdb) c
Continuing.
sudo miniterm.py /dev/ttyUSB0 19200
--- Miniterm on /dev/ttyUSB0 19200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
hello, world