FreeRTOS-Kernel/FreeRTOS/Demo/RISC-V-Qemu-virt_GCC/Makefile
Keith Packard eb97c5d325
Make a couple of demos build using picolibc (#1202)
* [RISC-V-Qemu-virt_GCC Demo] Add picolibc support

Add minimal picolibc support:

 * Use --specs=picolibc.specs to direct gcc at picolibc
 * Use -DPICOLIBC_INTEGER_PRINTF_SCANF to enable smaller printf implementation
 * Enable configUSE_PICOLIBC_TLS for thread local storage
 * Add TLS section to linker script

Signed-off-by: Keith Packard <keithpac@amazon.com>

* [CORTEX_MPU_M3_MPS2_QEMU_GCC Demo] Add picolibc support

Add minimal picolibc support to this demo

 * Use --specs=picolibc.specs to direct gcc at picolibc
 * Use -DPICOLIBC_INTEGER_PRINTF_SCANF to enable smaller printf implementation
 * Enable configUSE_PICOLIBC_TLS for thread local storage
 * Add TLS section to linker script
 * Replace newlib syscall hooks with picolibc ones

Signed-off-by: Keith Packard <keithpac@amazon.com>

---------

Signed-off-by: Keith Packard <keithpac@amazon.com>
Co-authored-by: Keith Packard <keithpac@amazon.com>
2024-04-03 10:13:14 +05:30

87 lines
2.5 KiB
Makefile

CROSS = riscv64-unknown-elf-
CC = $(CROSS)gcc
OBJCOPY = $(CROSS)objcopy
ARCH = $(CROSS)ar
# Generate GCC_VERSION in number format
GCC_VERSION = $(shell $(CC) --version | grep ^$(CC) | sed 's/^.* //g' | awk -F. '{ printf("%d%02d%02d"), $$1, $$2, $$3 }')
GCC_VERSION_NEED_ZICSR = "110100"
BUILD_DIR = build
RTOS_SOURCE_DIR = $(abspath ../../Source)
DEMO_SOURCE_DIR = $(abspath ../Common/Minimal)
CPPFLAGS = \
-D__riscv_float_abi_soft \
-DportasmHANDLE_INTERRUPT=handle_trap \
-I . -I ../Common/include \
-I $(RTOS_SOURCE_DIR)/include \
-I $(RTOS_SOURCE_DIR)/portable/GCC/RISC-V \
-I $(RTOS_SOURCE_DIR)/portable/GCC/RISC-V/chip_specific_extensions/RV32I_CLINT_no_extensions
CFLAGS = -mabi=ilp32 -mcmodel=medany \
-Wall \
-fmessage-length=0 \
-ffunction-sections \
-fdata-sections \
-fno-builtin-printf
ifeq ($(shell test $(GCC_VERSION) -ge $(GCC_VERSION_NEED_ZICSR) && echo true),true)
CFLAGS += -march=rv32imac_zicsr
else
CFLAGS += -march=rv32imac
endif
LDFLAGS = -nostartfiles -Tfake_rom.lds \
-march=rv32imac -mabi=ilp32 -mcmodel=medany \
-Xlinker --gc-sections \
-Xlinker --defsym=__stack_size=300 \
-Xlinker -Map=$(BUILD_DIR)/RTOSDemo.map
ifeq ($(DEBUG), 1)
CFLAGS += -Og -ggdb3
else
CFLAGS += -O2
endif
ifeq ($(PICOLIBC), 1)
CFLAGS += --specs=picolibc.specs -DPICOLIBC_INTEGER_PRINTF_SCANF
LDFLAGS += --specs=picolibc.specs -DPICOLIBC_INTEGER_PRINTF_SCANF
endif
SRCS = main.c main_blinky.c riscv-virt.c ns16550.c \
$(DEMO_SOURCE_DIR)/EventGroupsDemo.c \
$(DEMO_SOURCE_DIR)/TaskNotify.c \
$(DEMO_SOURCE_DIR)/TimerDemo.c \
$(DEMO_SOURCE_DIR)/blocktim.c \
$(DEMO_SOURCE_DIR)/dynamic.c \
$(DEMO_SOURCE_DIR)/recmutex.c \
$(RTOS_SOURCE_DIR)/event_groups.c \
$(RTOS_SOURCE_DIR)/list.c \
$(RTOS_SOURCE_DIR)/queue.c \
$(RTOS_SOURCE_DIR)/stream_buffer.c \
$(RTOS_SOURCE_DIR)/tasks.c \
$(RTOS_SOURCE_DIR)/timers.c \
$(RTOS_SOURCE_DIR)/portable/MemMang/heap_4.c \
$(RTOS_SOURCE_DIR)/portable/GCC/RISC-V/port.c
ASMS = start.S vector.S\
$(RTOS_SOURCE_DIR)/portable/GCC/RISC-V/portASM.S
OBJS = $(SRCS:%.c=$(BUILD_DIR)/%.o) $(ASMS:%.S=$(BUILD_DIR)/%.o)
DEPS = $(SRCS:%.c=$(BUILD_DIR)/%.d) $(ASMS:%.S=$(BUILD_DIR)/%.d)
$(BUILD_DIR)/RTOSDemo.axf: $(OBJS) fake_rom.lds Makefile
$(CC) $(LDFLAGS) $(OBJS) -o $@
$(BUILD_DIR)/%.o: %.c Makefile
@mkdir -p $(@D)
$(CC) $(CPPFLAGS) $(CFLAGS) -MMD -MP -c $< -o $@
$(BUILD_DIR)/%.o: %.S Makefile
@mkdir -p $(@D)
$(CC) $(CPPFLAGS) $(CFLAGS) -MMD -MP -c $< -o $@
clean:
rm -rf $(BUILD_DIR)
-include $(DEPS)