Skip to content

Commit

Permalink
risc-v: Fix build flags and linker scripts (FreeRTOS#906)
Browse files Browse the repository at this point in the history
1. miss debug info in assembly code
RISC-V-spike-htif_GCC
        LDFLAGS add arch and abi info for linker
            for riscv64-unknown-elf multilib, if there is no arch and abi
            info, will link to default lib and have below error
            target emulation `elf32-littleriscv' does not match `elf64-littleriscv'
        use CFLAGS to replace ASFLAGS when compile assembly code
            because DEBUG flag is added in CFLAGS, if we use ASFLAGS to compile
            assembly code, there is no debug info in assembly code objfile

2. binutils 2.39 ld warn 'has a LOAD segment with RWX permissions'
RISC-V-Qemu-virt_GCC
RISC-V-spike-htif_GCC
RISC-V_RV32_QEMU_VIRT_GCC

3. fix build fail
RISC-V_RV32_QEMU_VIRT_GCC

Signed-off-by: Eric Chan <[email protected]>
  • Loading branch information
e14002270 authored May 31, 2023
1 parent f6f2b67 commit d60b34c
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion FreeRTOS/Demo/RISC-V-Qemu-virt_GCC/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ LDFLAGS = -nostartfiles -Tfake_rom.lds \
-march=rv32imac -mabi=ilp32 -mcmodel=medany \
-Xlinker --gc-sections \
-Xlinker --defsym=__stack_size=300 \
-Xlinker -Map=RTOSDemo.map
-Xlinker -Map=$(BUILD_DIR)/RTOSDemo.map

ifeq ($(DEBUG), 1)
CFLAGS += -Og -ggdb3
Expand Down
3 changes: 1 addition & 2 deletions FreeRTOS/Demo/RISC-V-Qemu-virt_GCC/fake_rom.lds
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ SECTIONS
_etext = .;
} >rom AT>rom

.rodata.align :
.rodata.align ALIGN(4):
{
. = ALIGN(4);
_rodata = .;
} >rom AT>rom

Expand Down
4 changes: 2 additions & 2 deletions FreeRTOS/Demo/RISC-V-spike-htif_GCC/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ CFLAGS = -march=$(MARCH) -mabi=$(MABI) -mcmodel=medany \
-ffunction-sections \
-fdata-sections \
-fno-builtin-printf
ASFLAGS = -march=$(MARCH) -mabi=$(MABI) -mcmodel=medany
LDFLAGS = -nostartfiles \
-march=$(MARCH) -mabi=$(MABI) -mcmodel=medany \
-Xlinker --gc-sections \
-Xlinker --defsym=__stack_size=$(STACK_SIZE)

Expand Down Expand Up @@ -76,7 +76,7 @@ $(BUILD_DIR)/%$(XLEN).o: %.c Makefile

$(BUILD_DIR)/%$(XLEN).o: %.S Makefile
@mkdir -p $(@D)
$(CC) $(CPPFLAGS) $(ASFLAGS) -MMD -MP -c $< -o $@
$(CC) $(CPPFLAGS) $(CFLAGS) -MMD -MP -c $< -o $@

# Run lds through the C preprocessor, to replace BASE_ADDRESS with the actual
# value. It might be simpler to use sed instead.
Expand Down
3 changes: 1 addition & 2 deletions FreeRTOS/Demo/RISC-V-spike-htif_GCC/fake_rom.lds
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ SECTIONS
_etext = .;
} >rom AT>rom

.rodata.align :
.rodata.align ALIGN(4):
{
. = ALIGN(4);
_rodata = .;
} >rom AT>rom

Expand Down
2 changes: 1 addition & 1 deletion FreeRTOS/Demo/RISC-V_RV32_QEMU_VIRT_GCC/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ to exclude the API function. */
format the raw data provided by the uxTaskGetSystemState() function in to human
readable ASCII form. See the notes in the implementation of vTaskList() within
FreeRTOS/Source/tasks.c for limitations. */
#define configUSE_STATS_FORMATTING_FUNCTIONS 1
#define configUSE_STATS_FORMATTING_FUNCTIONS 0

/* The QEMU target is capable of running all the tests tasks at the same
* time. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ SECTIONS
_etext = .;
} >rom AT>rom

.rodata.align :
.rodata.align ALIGN(4):
{
. = ALIGN(4);
_rodata = .;
} >rom AT>rom

Expand Down

0 comments on commit d60b34c

Please sign in to comment.