This is my playground to build RISC-V baremetal/newlib programs with little build-related effort.
- riscv-gnu-toolchain
compiled with--with-cmodel=medany
You must first create .config
in the source directory.
You can create default configuration file by make defconfig
.
Following variables are expected to be customized.
CONFIG_TARGET_ISA
CONFIG_TARGET_ABI
CONFIG_ADDR_START
Text entrypoint addressCONFIG_ADDR_DATA
(can be an address orauto
)
Data start address (RAM)CONFIG_ADDR_STACK
(can be an address orauto
)
Data stack address (RAM)CONFIG_STACK_SIZE
Stack size in bytes (only valid ifCONFIG_ADDR_STACK
isauto
)
- Create either
[NAME].bare.c
or[NAME].bare.S
- Add the path to
src_targets
environment inSOURCES.mk
.
- Create either
[NAME].newlib.c
or[NAME].newlib.S
- Add the path to
src_targets
environment inSOURCES.mk
.
Add relative path to the source file to src_liball
environment in SOURCES.mk
.
Use src_libcrt
environment instead of src_liball
.
All you have to do is run make
.
You can also generate objdump
by make dump
.
Default linker script is based on GNU Binutils 2.37.
Make script is partially based on OpenSBI but heavily modified for hobby use.
See the source code for details.