Line 8... |
Line 8... |
[grid="none"]
|
[grid="none"]
|
|=======================
|
|=======================
|
| Application/bootloader start-up code | `sw/common/crt0.S`
|
| Application/bootloader start-up code | `sw/common/crt0.S`
|
| Application/bootloader linker script | `sw/common/neorv32.ld`
|
| Application/bootloader linker script | `sw/common/neorv32.ld`
|
| Core hardware driver libraries | `sw/lib/include/` & `sw/lib/source/`
|
| Core hardware driver libraries | `sw/lib/include/` & `sw/lib/source/`
|
| Makefiles | e.g. `sw/example/blink_led/makefile`
|
| Central makefile | `sw/common/common.mk`
|
| Auxiliary tool for generating NEORV32 executables | `sw/image_gen/`
|
| Auxiliary tool for generating NEORV32 executables | `sw/image_gen/`
|
| Default bootloader | `sw/bootloader/bootloader.c`
|
| Default bootloader | `sw/bootloader/bootloader.c`
|
|=======================
|
|=======================
|
|
|
Last but not least, the NEORV32 ecosystem provides some example programs for testing the hardware, for
|
Last but not least, the NEORV32 ecosystem provides some example programs for testing the hardware, for
|
Line 87... |
Line 87... |
|
|
// ####################################################################################################################
|
// ####################################################################################################################
|
:sectnums:
|
:sectnums:
|
=== Application Makefile
|
=== Application Makefile
|
|
|
Application compilation is based on **GNU makefiles**. Each project in the `sw/example` folder features
|
Application compilation is based on a single, centralized **GNU makefiles** `sw/common/common.mk`. Each project in the
|
a makefile. All these makefiles are identical. When creating a new project, copy an existing project folder or
|
`sw/example` folder features a makefile that just includes this central makefile. When creating a new project, copy an existing project folder or
|
at least the makefile to your new project folder. I suggest to create new projects also in `sw/example` to keep
|
at least the makefile to your new project folder. I suggest to create new projects also in `sw/example` to keep
|
the file dependencies. Of course, these dependencies can be manually configured via makefiles variables
|
the file dependencies. Of course, these dependencies can be manually configured via makefiles variables
|
when your project is located somewhere else.
|
when your project is located somewhere else.
|
|
|
|
[NOTE]
|
Before you can use the makefiles, you need to install the RISC-V GCC toolchain. Also, you have to add the
|
Before you can use the makefiles, you need to install the RISC-V GCC toolchain. Also, you have to add the
|
installation folder of the compiler to your system's `PATH` variable. More information can be found in chapter
|
installation folder of the compiler to your system's `PATH` variable. More information can be found in
|
<<_lets_get_it_started>>.
|
https://stnolting.github.io/neorv32/ug/#_software_toolchain_setup[User Guide: Software Toolchain Setup].
|
|
|
The makefile is invoked by simply executing make in your console:
|
The makefile is invoked by simply executing make in your console:
|
|
|
[source,bash]
|
[source,bash]
|
----
|
----
|
Line 107... |
Line 108... |
----
|
----
|
|
|
:sectnums:
|
:sectnums:
|
==== Targets
|
==== Targets
|
|
|
Just executing `make` will show the help menu showing all available targets. The following targets are
|
Just executing `make` (or executing `make help`) will show the help menu listing all available targets.
|
available:
|
|
|
|
[cols="<3,<15"]
|
[source,makefile]
|
[grid="none"]
|
----
|
|=======================
|
$ make
|
| `help` | Show a short help text explaining all available targets.
|
<<< NEORV32 Application Makefile >>>
|
| `check` | Check the compiler toolchain. You should run this target at least once after installing the toolchain.
|
Make sure to add the bin folder of RISC-V GCC to your PATH variable.
|
| `info` | Show the makefile configuration (see section <<_configuration>>).
|
Targets:
|
| `exe` | Compile all sources and generate application executable for upload via bootloader.
|
help - show this text
|
| `install` | Compile all sources, generate executable (via exe target) for upload via bootloader and generate and install IMEM VHDL initialization image file `rtl/core/neorv32_application_image.vhd`.
|
check - check toolchain
|
| `all` | Execute `exe` and `install`.
|
info - show makefile/toolchain configuration
|
| `clean` | Remove all generated files in the current folder.
|
exe - compile and generate executable for upload via bootloader
|
| `clean_all` | Remove all generated files in the current folder and also removes the compiled core libraries and the compiled image generator tool.
|
hex - compile and generate executable raw file
|
| `bootloader` | Compile all sources, generate executable and generate and install BOOTROM VHDL initialization image file `rtl/core/neorv32_bootloader_image.vhd`. This target modifies the ROM origin and length in the linker script by setting the `make_bootloader` define.
|
install - compile, generate and install VHDL IMEM boot image (for application)
|
| `upload` | Upload NEORV32 executable to the bootloader via serial port
|
all - exe + hex + install
|
|=======================
|
elf_info - show ELF layout info
|
|
clean - clean up project
|
|
clean_all - clean up project, core libraries and image generator
|
|
bootloader - compile, generate and install VHDL BOOTROM boot image (for bootloader only!)
|
|
----
|
|
|
[TIP]
|
|
An assembly listing file (`main.asm`) is created by the compilation flow for further analysis or debugging purpose.
|
|
|
|
:sectnums:
|
:sectnums:
|
==== Configuration
|
==== Configuration
|
|
|
The compilation flow is configured via variables right at the beginning of the makefile:
|
The compilation flow is configured via variables right at the beginning of the **central**
|
|
makefile (`sw/common/common.mk`):
|
|
|
|
[TIP]
|
|
The makefile configuration variables can be (re-)defined directly when invoking the makefile. For
|
|
example via `$ make MARCH=-march=rv32ic clean_all exe`. You can also make project-specific definitions
|
|
of all variables inside the project's actual makefile (e.g., `sw/example/blink_led/makefile`).
|
|
|
[source,makefile]
|
[source,makefile]
|
----
|
----
|
# *****************************************************************************
|
# *****************************************************************************
|
# USER CONFIGURATION
|
# USER CONFIGURATION
|
Line 148... |
Line 156... |
entry)
|
entry)
|
ASM_INC ?= -I .
|
ASM_INC ?= -I .
|
# Optimization
|
# Optimization
|
EFFORT ?= -Os
|
EFFORT ?= -Os
|
# Compiler toolchain
|
# Compiler toolchain
|
RISCV_TOOLCHAIN ?= riscv32-unknown-elf
|
RISCV_PREFIX ?= riscv32-unknown-elf-
|
# CPU architecture and ABI
|
# CPU architecture and ABI
|
MARCH ?= -march=rv32i
|
MARCH ?= -march=rv32i
|
MABI ?= -mabi=ilp32
|
MABI ?= -mabi=ilp32
|
# User flags for additional configuration (will be added to compiler flags)
|
# User flags for additional configuration (will be added to compiler flags)
|
USER_FLAGS ?=
|
USER_FLAGS ?=
|
# Serial port for executable upload via bootloer
|
|
COM_PORT ?= /dev/ttyUSB0
|
|
# Relative or absolute path to the NEORV32 home folder
|
# Relative or absolute path to the NEORV32 home folder
|
NEORV32_HOME ?= ../../..
|
NEORV32_HOME ?= ../../..
|
# *****************************************************************************
|
# *****************************************************************************
|
----
|
----
|
|
|
Line 168... |
Line 174... |
|=======================
|
|=======================
|
| _APP_SRC_ | The source files of the application (`*.c`, `*.cpp`, `*.S` and `*.s` files are allowed; file of these types in the project folder are automatically added via wildcards). Additional files can be added; separated by white spaces
|
| _APP_SRC_ | The source files of the application (`*.c`, `*.cpp`, `*.S` and `*.s` files are allowed; file of these types in the project folder are automatically added via wildcards). Additional files can be added; separated by white spaces
|
| _APP_INC_ | Include file folders; separated by white spaces; must be defined with `-I` prefix
|
| _APP_INC_ | Include file folders; separated by white spaces; must be defined with `-I` prefix
|
| _ASM_INC_ | Include file folders that are used only for the assembly source files (`*.S`/`*.s`).
|
| _ASM_INC_ | Include file folders that are used only for the assembly source files (`*.S`/`*.s`).
|
| _EFFORT_ | Optimization level, optimize for size (`-Os`) is default; legal values: `-O0`, `-O1`, `-O2`, `-O3`, `-Os`
|
| _EFFORT_ | Optimization level, optimize for size (`-Os`) is default; legal values: `-O0`, `-O1`, `-O2`, `-O3`, `-Os`
|
| _RISCV_TOOLCHAIN_ | The toolchain prefix to be used; follows the naming convention "architecture-vendor-output"
|
| _RISCV_PREFIX_ | The toolchain prefix to be used; follows the naming convention "architecture-vendor-output-"
|
| _MARCH_ | The targetd RISC-V architecture/ISA. Only `rv32` is supported by the NEORV32. Enable compiler support of optional CPU extension by adding the according extension letter (e.g. `rv32im` for _M_ CPU extension). See section <<_enabling_risc_v_cpu_extensions>>.
|
| _MARCH_ | The targetd RISC-V architecture/ISA. Only `rv32` is supported by the NEORV32. Enable compiler support of optional CPU extension by adding the according extension letter (e.g. `rv32im` for _M_ CPU extension). See https://stnolting.github.io/neorv32/ug/#_enabling_risc_v_cpu_extensions[User Guide: Enabling RISC-V CPU Extensions] for more information.
|
| _MABI_ | The default 32-bit integer ABI.
|
| _MABI_ | The default 32-bit integer ABI.
|
| _USER_FLAGS_ | Additional flags that will be forwarded to the compiler tools
|
| _USER_FLAGS_ | Additional flags that will be forwarded to the compiler tools
|
| _NEORV32_HOME_ | Relative or absolute path to the NEORV32 project home folder. Adapt this if the makefile/project is not in the project's `sw/example folder`.
|
| _NEORV32_HOME_ | Relative or absolute path to the NEORV32 project home folder. Adapt this if the makefile/project is not in the project's `sw/example folder`.
|
| _COM_PORT_ | Default serial port for executable upload to bootloader.
|
| _COM_PORT_ | Default serial port for executable upload to bootloader.
|
|=======================
|
|=======================
|
Line 199... |
Line 205... |
| `-falign-labels=4`
|
| `-falign-labels=4`
|
| `-falign-loops=4`
|
| `-falign-loops=4`
|
| `-falign-jumps=4`
|
| `-falign-jumps=4`
|
|=======================
|
|=======================
|
|
|
[TIP]
|
|
The makefile configuration variables can be (re-)defined directly when invoking the makefile. For
|
|
example: `$ make MARCH=-march=rv32ic clean_all exe`
|
|
|
|
|
|
|
|
|
|
// ####################################################################################################################
|
// ####################################################################################################################
|
:sectnums:
|
:sectnums:
|
Line 306... |
Line 308... |
|
|
[cols="<1,<9"]
|
[cols="<1,<9"]
|
[grid="none"]
|
[grid="none"]
|
|=======================
|
|=======================
|
| `-app_bin` | Generates an executable binary file `neorv32_exe.bin` (for UART uploading via the bootloader).
|
| `-app_bin` | Generates an executable binary file `neorv32_exe.bin` (for UART uploading via the bootloader).
|
|
| `-app_hex` | Generates a plain ASCII hex-char file `neorv32_exe.hex` that can be used to initialize custom (instruction-) memories (in synthesis/simulation).
|
| `-app_img` | Generates an executable VHDL memory initialization image for the processor-internal IMEM. This option generates the `rtl/core/neorv32_application_image.vhd` file.
|
| `-app_img` | Generates an executable VHDL memory initialization image for the processor-internal IMEM. This option generates the `rtl/core/neorv32_application_image.vhd` file.
|
| `-bld_img` | Generates an executable VHDL memory initialization image for the processor-internal BOOT ROM. This option generates the `rtl/core/neorv32_bootloader_image.vhd` file.
|
| `-bld_img` | Generates an executable VHDL memory initialization image for the processor-internal BOOT ROM. This option generates the `rtl/core/neorv32_bootloader_image.vhd` file.
|
|=======================
|
|=======================
|
|
|
All these options are managed by the makefile. The _normal application_ compilation flow will generate the `neorv32_exe.bin`
|
All these options are managed by the makefile. The _normal application_ compilation flow will generate the `neorv32_exe.bin`
|
Line 531... |
Line 534... |
LED is permanently activated and the system must be manually reset.
|
LED is permanently activated and the system must be manually reset.
|
|
|
[cols="<2,<13"]
|
[cols="<2,<13"]
|
[grid="rows"]
|
[grid="rows"]
|
|=======================
|
|=======================
|
| **`ERROR_0`** | If you try to transfer an invalid executable (via UART or from the external SPI flash), this error message shows up. There might be a transfer protocol configuration error in the terminal program. See section <<_uploading_and_starting_of_a_binary_executable_image_via_uart>> for more information. Also, if no SPI flash was found during an auto-boot attempt, this message will be displayed.
|
| **`ERROR_0`** | If you try to transfer an invalid executable (via UART or from the external SPI flash), this error message shows up. There might be a transfer protocol configuration error in the terminal program. Also, if no SPI flash was found during an auto-boot attempt, this message will be displayed.
|
| **`ERROR_1`** | Your program is way too big for the internal processor’s instructions memory. Increase the memory size or reduce (optimize!) your application code.
|
| **`ERROR_1`** | Your program is way too big for the internal processor’s instructions memory. Increase the memory size or reduce your application code.
|
| **`ERROR_2`** | This indicates a checksum error. Something went wrong during the transfer of the program image (upload via UART or loading from the external SPI flash). If the error was caused by a UART upload, just try it again. When the error was generated during a flash access, the stored image might be corrupted.
|
| **`ERROR_2`** | This indicates a checksum error. Something went wrong during the transfer of the program image (upload via UART or loading from the external SPI flash). If the error was caused by a UART upload, just try it again. When the error was generated during a flash access, the stored image might be corrupted.
|
| **`ERROR_3`** | This error occurs if the attached SPI flash cannot be accessed. Make sure you have the right type of flash and that it is properly connected to the NEORV32 SPI port using chip select #0.
|
| **`ERROR_3`** | This error occurs if the attached SPI flash cannot be accessed. Make sure you have the right type of flash and that it is properly connected to the NEORV32 SPI port using chip select #0.
|
|=======================
|
|=======================
|
|
|
|
|