-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SEGGER Embedded Studio support for X-HEEP (#370)
SEGGER support for X-HEEP
- Loading branch information
1 parent
beee13e
commit 109bacf
Showing
6 changed files
with
244 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
For FW development, `X-HEEP` can be used together with different Integrated Development Environments (IDEs) flavours. Up to now, full support is just provided by [Segger Embedded Studio (SES)](https://www.segger.com/products/development-tools/embedded-studio/editions/risc-v/). This readme guides you through all the needed steps to get SES working and debugging when prototyping `X-HEEP` into the pynq-z2 board. | ||
|
||
# Prerequisite | ||
|
||
## 1. SES installation. | ||
The platform was only tested under Linux and version 7.32 of the Embedded Studio for RISC-V. Please, go to the Segger [download center](https://www.segger.com/downloads/embedded-studio/) to get that version. It is assumed that you have already installed the RISC-V compiler and openOCD. If the latter is not true, check the main [Readme](https://github.com/esl-epfl/x-heep) please. | ||
|
||
# Configuration | ||
|
||
After installing SES, you need to indicate to Segger your Toolchain directory (RISC-V Compiler) as well as your openOCD installation folder. Those need to be specified into `xheep.emProject` file. | ||
|
||
For the RISC-V Compiler path, **line 71**: | ||
``` | ||
build_toolchain_directory="/home/< user >/tools/riscv/bin" | ||
``` | ||
Please, substitute that path to your current path where the RISC-V compiler was installed. Do not forget to target the `bin` folder inside the installation folder of the toolchain. | ||
|
||
For the openOCS path, **line 88**: | ||
``` | ||
gdb_server_command_line="/home/< user >/tools/openocd/bin/openocd -f "$(ProjectDir)/../../tb/core-v-mini-mcu-pynq-z2-esl-programmer.cfg"" | ||
``` | ||
Please, substitute that path to your current path where openOCD was installed. Do not forget to target the `openocd` file inside the `bin` installation folder of openocd. | ||
|
||
# Building | ||
|
||
Once the paths are set properly, you can open `xheep.emProject` with SES. That will launch SES with one solution already configured, `xheep_ses`, and one project into that solution `helloworld`. Note that this project has already everything configured to run the `helloworld` application of the main repo, i.e. all the source files are linked to the project as well as the `c user include directories` already set up. Moreover, this project is configured to be running (compile, linking, and debug) by using the on-chip linker `sw/linker/link.ld`. If you want to change any of these options, you will need to change the options of the project or the options of the solution. Note that the project is currently set-up to be working on the `Debug_External` configuration. Please, do not move to other configuration when building and/or debugging. Finally, to build the whole project just press `F7` or `Build > Build helloworld`. | ||
|
||
The output should be like this: | ||
|
||
<p align="left"><img src="ides/img/build_screenshot.png" width="450"></p> | ||
|
||
Note that on the right part, you have the memory usage based on the linker we have configured. If you do not see this, you can activate that view in `View > Memory Usage`. | ||
|
||
# Debugging | ||
|
||
Finally, after building (compile and linking), you can directly start debugging by pressing `F5` or also `Target > Connect GDB Server` and `Debug > Go`. You also have the possibility to activate the terminal to see directly into the SES window the printing characters. | ||
|
||
The output should be something like this: | ||
|
||
<p align="left"><img src="ides/img/debug_screenshot.png" width="450"></p> | ||
|
||
Note that when debugging and setting breakpoints, please, go one-by-one (one breakpoint at a time). Several breakpoints support will be supported in the following releases. | ||
|
||
Further improvements and support will be provided and explain in following releases. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
<!DOCTYPE CrossStudio_Project_File> | ||
<solution Name="xheep_ses" target="20" version="2"> | ||
<configuration Name="Debug" hidden="Yes" /> | ||
<configuration | ||
Name="Debug External" | ||
build_toolchain_directory="$(ProjectDir)/tools/riscv/bin" | ||
inherited_configurations="External GNU" /> | ||
<configuration | ||
Name="Debug Internal" | ||
inherited_configurations="Internal;Debug" /> | ||
<configuration Name="External GNU" Platform="RISCV" hidden="Yes" /> | ||
<configuration | ||
Name="Release" | ||
c_preprocessor_definitions="NDEBUG" | ||
gcc_debugging_level="Level 2" | ||
gcc_omit_frame_pointer="Yes" | ||
gcc_optimization_level="Level 2 balanced" | ||
hidden="Yes" /> | ||
<configuration | ||
Name="Release External" | ||
inherited_configurations="External GNU" /> | ||
<configuration | ||
Name="Release Internal" | ||
inherited_configurations="Internal;Release" /> | ||
<project Name="helloworld"> | ||
<configuration | ||
LIBRARY_HEAP_TYPE="None" | ||
LIBRARY_IO_TYPE="SEMIHOST (host-formatted)" | ||
Name="Common" | ||
arm_keep_assembly="Yes" | ||
arm_linker_search_path="$(ProjectDir)/../../sw/device/lib/base/;$(ProjectDir)/../../sw/device/lib/base/freestanding/;$(ProjectDir)/../../sw/device/lib/runtime/;$(ProjectDir)/../../sw/device/lib/drivers/uart/;$(ProjectDir)/../../sw/device/lib/drivers/rv_plic/;$(ProjectDir)/../../sw/device/lib/drivers/fast_intr_ctrl/;$(ProjectDir)/../../sw/device/lib/drivers/soc_ctrl/;$(ProjectDir)/../../sw/device/lib/drivers/i2s/;$(ProjectDir)/../../sw/device/lib/drivers/i2c/;$(ProjectDir)/../../sw/device/lib/drivers/gpio/;$(ProjectDir)/../../sw/device/lib/drivers/dma/;$(ProjectDir)/../../sw/device/lib/drivers/spi_host/;$(ProjectDir)/../../sw/device/target/pynq-z2/" | ||
build_always_rebuild="Yes" | ||
build_quietly="No" | ||
build_toolchain_directory="" | ||
compiler_diagnostics_show_caret="No" | ||
debug_target_connection="GDB Server" | ||
gcc_debugging_level="Level 3" | ||
gcc_dwarf_generate_pubnames="No" | ||
gcc_dwarf_version="None" | ||
gcc_short_enum="None" | ||
gcc_use_cxa_at_exit="No" | ||
gdb_server_allow_memory_access_during_execution="Yes" | ||
gdb_server_autostart_server="No" | ||
gdb_server_command_line="" | ||
gdb_server_ignore_checksum_errors="No" | ||
gdb_server_port="3333" | ||
gdb_server_register_access="General and Individual" | ||
gdb_server_reset_command="reset halt" | ||
gdb_server_type="OpenOCD" | ||
link_include_standard_libraries="No" | ||
link_linker_script_file="$(ProjectDir)/../../sw/linker/link.ld" | ||
link_use_linker_script_file="Yes" | ||
linker_additional_files="" | ||
linker_output_format="hex" | ||
linker_pre_build_command="$(StudioDir)/bin/mkld -section-placement-file $(StudioDir)/targets/flash_placement_riscv.xml -memory-map-segments "$(MemorySegments)" -symbols __STACKSIZE__=1024;__HEAPSIZE__=1024 Setup/flash_rv32.ld" | ||
linker_section_placements_segments="RAM0 RX 0x00000000 0x00000C800;RAM1 RWX 0x00000C800 0x00003800" | ||
project_directory="" | ||
project_type="Executable" | ||
rv_abi="ilp32" | ||
rv_architecture="rv32imc" | ||
rv_relax="No" | ||
target_device_name="RV32" /> | ||
<configuration | ||
BUILD_OPTIONS="RV32 GNU" | ||
Name="Debug External" | ||
RISCV_TOOLCHAIN_VARIANT="Standard" | ||
arm_assembler_variant="gcc" | ||
arm_compiler_variant="gcc" | ||
build_always_rebuild="Yes" | ||
build_generic_options_file_name="" | ||
build_toolchain_directory="/home/< user >/tools/riscv/bin" | ||
c_additional_options="-march=rv32imc -w -Os -g -nostdlib" | ||
c_include_files="" | ||
c_preprocessor_definitions="HOST_BUILD;ON_CHIP" | ||
c_user_include_directories="$(ProjectDir)/../../sw/device/lib/base/;$(ProjectDir)/../../sw/device/lib/base/freestanding/;$(ProjectDir)/../../sw/device/lib/runtime/;$(ProjectDir)/../../sw/device/lib/drivers/uart/;$(ProjectDir)/../../sw/device/lib/drivers/rv_plic/;$(ProjectDir)/../../sw/device/lib/drivers/fast_intr_ctrl/;$(ProjectDir)/../../sw/device/lib/drivers/soc_ctrl/;$(ProjectDir)/../../sw/device/lib/drivers/i2s/;$(ProjectDir)/../../sw/device/lib/drivers/i2c/;$(ProjectDir)/../../sw/device/lib/drivers/gpio/;$(ProjectDir)/../../sw/device/lib/drivers/dma/;$(ProjectDir)/../../sw/device/lib/drivers/spi_host/;$(ProjectDir)/../../sw/device/target/pynq-z2/" | ||
c_user_include_directories_c_only="" | ||
debug_target_connection="GDB Server" | ||
external_build_file_name="" | ||
external_c_compile_command=""$(ToolChainDir)/$(GCCPrefix)gcc" $(COptions) $(COnlyOptions) $(Defines) $(Undefines) $(Includes) $(IncludeFiles) -c "$(RelInputPath)" -o "$(RelTargetPath)"" | ||
external_cpp_compile_command=""$(ToolChainDir)/$(GCCPrefix)g++" -c $(COptions) $(CppOnlyOptions) $(Defines) $(Undefines) $(Includes) $(IncludeFiles) "$(RelInputPath)" -MD -MF "$(RelDependencyPath)" -fno-diagnostics-show-caret -o "$(RelTargetPath)"" | ||
external_cpp_link_command=""$(ToolChainDir)/$(GCCPrefix)g++" $(Objects) $(LinkOptions) -T "$(RelLinkerScriptPath)" -o "$(RelTargetPath)" -Xlinker -Map="$(RelMapPath)"" | ||
external_link_command=""$(ToolChainDir)/$(GCCPrefix)gcc" $(Objects) $(LinkOptions) -Wl,-Map="$(RelMapPath)" -T "$(RelLinkerScriptPath)" -o "$(RelTargetPath)"" | ||
external_load_file_type="Detect" | ||
gcc_cl_dwarf_version="None" | ||
gdb_breakpoint_types="Hardware Only" | ||
gdb_server_allow_memory_access_during_execution="Yes" | ||
gdb_server_autostart_server="Yes" | ||
gdb_server_command_line="/home/< user >/tools/openocd/bin/openocd -f "$(ProjectDir)/../../tb/core-v-mini-mcu-pynq-z2-esl-programmer.cfg"" | ||
gdb_server_ignore_checksum_errors="No" | ||
gdb_server_log_file="$(ProjectDir)/gdb_out.txt" | ||
gdb_server_port="3333" | ||
gdb_server_register_access="General and Individual" | ||
gdb_server_reset_command="reset halt" | ||
gdb_server_type="OpenOCD" | ||
gnu_cl_enable_debug_info="Yes" | ||
gnu_cl_optimization_level="None" | ||
link_linker_script_file="$(ProjectDir)/../../sw/linker/link.ld" | ||
linker_additional_options="-I "$(ProjectDir)/../../sw/device/lib/base/";-I "$(ProjectDir)/../../sw/device/lib/base/freestanding/";-I "$(ProjectDir)/../../sw/device/lib/runtime/";-I "$(ProjectDir)/../../sw/device/lib/drivers/uart/";-I "$(ProjectDir)/../../sw/device/lib/drivers/rv_plic/";-I "$(ProjectDir)/../../sw/device/lib/drivers/fast_intr_ctrl/";-I "$(ProjectDir)/../../sw/device/lib/drivers/soc_ctrl/";-I "$(ProjectDir)/../../sw/device/lib/drivers/i2s/";-I "$(ProjectDir)/../../sw/device/lib/drivers/i2c/";-I "$(ProjectDir)/../../sw/device/lib/drivers/gpio/";-I "$(ProjectDir)/../../sw/device/lib/drivers/dma/";-I "$(ProjectDir)/../../sw/device/lib/drivers/spi_host/";-I "$(ProjectDir)/../../sw/device/target/pynq-z2/";-static "$(ProjectDir)/../../sw/device/lib/crt/crt0.S" "$(ProjectDir)/../../sw/device/lib/crt/vectors.S";-L "$(ToolChainDir)/../riscv32-unknown-elf/lib";-lc -lm -lgcc -flto -ffunction-sections -fdata-sections -specs=nano.specs -w -march=rv32imc -Os -g -nostdlib" | ||
linker_post_build_command="$(ToolChainDir)/riscv32-unknown-elf-objdump -S "$(ProjectDir)/$(OutDir)/$(ProjectName).elf" > "$(ProjectDir)/$(OutDir)/$(ProjectName).disasm"" | ||
linker_pre_build_command="" | ||
linker_section_placements_segments="RAM0 RX 0x00000000 0x00000C800;RAM1 RWX 0x00000C800 0x00003800" | ||
post_build_command="$(ToolChainDir)/riscv32-unknown-elf-objcopy -O verilog "$(ProjectDir)/$(OutDir)/$(ProjectName).elf" "$(ProjectDir)/$(OutDir)/$(ProjectName)_vfmt.hex"" | ||
pre_build_command="" | ||
rv32gnu_cl_arch="rv32imc" | ||
rv_arch_ext="" | ||
rv_arch_zicsr="Yes" | ||
rv_arch_zifencei="Yes" | ||
rv_debug_extensions="None" | ||
rv_toolchain_prefix="" | ||
use_compiler_driver="No" /> | ||
<configuration | ||
BUILD_OPTIONS="RV32 GNU" | ||
Name="External GNU" | ||
build_generic_options_file_name="$(StudioDir)/targets/RV32GNU_build_options.xml" | ||
build_toolchain_directory="" | ||
gcc_prefix="riscv32-unknown-elf-" | ||
link_linker_script_file="Setup/flash_rv32.ld" | ||
link_use_linker_script_file="Yes" | ||
linker_additional_options="" | ||
linker_pre_build_command="$(StudioDir)/bin/mkld -section-placement-file $(StudioDir)/targets/flash_placement_riscv.xml -memory-map-segments "$(MemorySegments)" -symbols __STACKSIZE__=1024;__HEAPSIZE__=1024 Setup/flash_rv32.ld" | ||
project_type="Externally Built Executable" | ||
rv32gnu_cl_abi="ilp32" | ||
rv32gnu_cl_arch="rv32i" /> | ||
<configuration | ||
Name="Release External" | ||
gnu_cl_enable_debug_info="No" | ||
gnu_cl_optimization_level="Level 1" /> | ||
<folder Name="base"> | ||
<file file_name="../../sw/device/lib/base/bitfield.c" /> | ||
<file file_name="../../sw/device/lib/base/memory.c" /> | ||
<file file_name="../../sw/device/lib/base/memory.h" /> | ||
<file file_name="../../sw/device/lib/base/mmio.c" /> | ||
</folder> | ||
<folder Name="crt"> | ||
<file file_name="../../sw/device/lib/crt/crt0.S" /> | ||
<file file_name="../../sw/device/lib/crt/vectors.S" /> | ||
</folder> | ||
<folder Name="drivers"> | ||
<file file_name="../../sw/device/lib/drivers/dma/dma.c" /> | ||
<file file_name="../../sw/device/lib/drivers/fast_intr_ctrl/fast_intr_ctrl.c" /> | ||
<file file_name="../../sw/device/lib/drivers/gpio/gpio.c" /> | ||
<file file_name="../../sw/device/lib/drivers/rv_plic/rv_plic.c" /> | ||
<file file_name="../../sw/device/lib/drivers/soc_ctrl/soc_ctrl.c" /> | ||
<file file_name="../../sw/device/lib/drivers/uart/uart.c" /> | ||
</folder> | ||
<folder Name="runtime"> | ||
<file file_name="../../sw/device/lib/runtime/handler.c" /> | ||
<file file_name="../../sw/device/lib/runtime/init.c" /> | ||
<file file_name="../../sw/device/lib/runtime/syscalls.c" /> | ||
</folder> | ||
<folder Name="source"> | ||
<file file_name="../../sw/applications/hello_world/main.c" /> | ||
</folder> | ||
</project> | ||
</solution> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!DOCTYPE CrossStudio_Session_File> | ||
<session> | ||
<Bookmarks/> | ||
<Breakpoints groups="Breakpoints" active_group="Breakpoints"/> | ||
<ExecutionProfileWindow/> | ||
<FrameBuffer/> | ||
<Memory1/> | ||
<Memory2/> | ||
<Memory3/> | ||
<Memory4/> | ||
<Project> | ||
<ProjectSessionItem path="xheep_ses"/> | ||
<ProjectSessionItem path="xheep_ses;helloworld"/> | ||
</Project> | ||
<Register1/> | ||
<Register2/> | ||
<Register3/> | ||
<Register4/> | ||
<Threads> | ||
<ThreadsWindow showLists=""/> | ||
</Threads> | ||
<TraceWindow> | ||
<Trace enabled="Yes"/> | ||
</TraceWindow> | ||
<Watch1> | ||
<Watches active="1" update="Never"/> | ||
</Watch1> | ||
<Watch2> | ||
<Watches active="0" update="Never"/> | ||
</Watch2> | ||
<Watch3> | ||
<Watches active="0" update="Never"/> | ||
</Watch3> | ||
<Watch4> | ||
<Watches active="0" update="Never"/> | ||
</Watch4> | ||
<Files/> | ||
<EMStudioWindow activeProject="helloworld" fileDialogDefaultFilter="*" autoConnectTarget="GDB Server" buildConfiguration="Debug External" sessionSettings="" debugSearchFileMap="" fileDialogInitialDirectory="" debugSearchPath="" autoConnectCapabilities="1343"/> | ||
</session> |