diff --git a/.gitignore b/.gitignore index 8f6eeebcf..7eda11634 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,8 @@ *.o *libmusl.a *liblwip.a -.DS_Store \ No newline at end of file +.DS_Store + +.cache/ +compile_commands.json +.clangd diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/config.mk b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/config.mk index 71507b771..7cd2dab34 100644 --- a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/config.mk +++ b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/config.mk @@ -1,11 +1,14 @@ +# newer risc-v toolchain requires `zicsr` extension for csr-related ops +export MARCH := rv32imac_zicsr +# export MARCH := rv32imacxw_zicsr -export CFLAGS := -march=rv32imac -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -g -export AFLAGS := -march=rv32imac -mabi=ilp32 -x assembler-with-cpp -ggdb -export LFLAGS := -march=rv32imac -mabi=ilp32 -nostartfiles -Wl,--gc-sections,-Map=XiZi-ch32v208vct6.map,-cref,-u,_start -T $(BSP_ROOT)/link.ld +export CFLAGS := -march=$(MARCH) -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -g +export AFLAGS := -march=$(MARCH) -mabi=ilp32 -x assembler-with-cpp -ggdb +export LFLAGS := -march=$(MARCH) -mabi=ilp32 -nostartfiles -Wl,--gc-sections,-Map=XiZi-ch32v208vct6.map,-cref,-u,_start -T $(BSP_ROOT)/link.ld -# export CFLAGS := -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -g -std=gnu99 -# export AFLAGS := -march=rv32imac -mabi=ilp32 -x assembler-with-cpp -ggdb -# export LFLAGS := -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -g -T $(BSP_ROOT)/link.ld -nostartfiles -Xlinker --gc-sections -Wl,-Map,"XiZi-ch32v307vct6.map" --specs=nano.specs --specs=nosys.specs +# export CFLAGS := -march=$(MARCH) -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -g -std=gnu99 +# export AFLAGS := -march=$(MARCH) -mabi=ilp32 -x assembler-with-cpp -ggdb +# export LFLAGS := -march=$(MARCH) -mabi=ilp32 -msmall-data-limit=8 -msave-restore -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -g -T $(BSP_ROOT)/link.ld -nostartfiles -Xlinker --gc-sections -Wl,-Map,"XiZi-ch32v307vct6.map" --specs=nano.specs --specs=nosys.specs export APPLFLAGS := -nostartfiles -Wl,--gc-sections,-Map=XiZi-app.map,-cref,-u, -T $(BSP_ROOT)/link_userspace.lds diff --git a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/include/ModuleConfig.h b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/include/ModuleConfig.h index 581d3ae86..3921094a7 100644 --- a/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/include/ModuleConfig.h +++ b/Ubiquitous/XiZi_IIoT/board/ch32v208rbt6/third_party_driver/include/ModuleConfig.h @@ -13,6 +13,8 @@ #ifndef __MODULECONFIG_H__ #define __MODULECONFIG_H__ +#include + #include "debug.h" /*Address where configuration information is stored*/ diff --git a/Ubiquitous/XiZi_IIoT/compiler.mk b/Ubiquitous/XiZi_IIoT/compiler.mk index 4a91b1ba0..da99cbccc 100644 --- a/Ubiquitous/XiZi_IIoT/compiler.mk +++ b/Ubiquitous/XiZi_IIoT/compiler.mk @@ -30,15 +30,15 @@ CFLAGS += $(DEFINES) AFLAGS += $(DEFINES) CXXFLAGS += $(DEFINES) BUILD_DIR := $(KERNEL_ROOT)/build -APP_DIR := Ubiquitous/XiZi +APP_DIR := Ubiquitous/XiZi_IIoT .PHONY:COMPILER COMPILER: @if [ "${SRC_DIR_TEMP}" != "" ]; then \ - for dir in $(SRC_DIR_TEMP);do \ - $(MAKE) -C $$dir; \ - done; \ + for dir in $(SRC_DIR_TEMP); do \ + $(MAKE) -C $$dir; \ + done; \ fi @/bin/echo -n $(OBJS) " " >> $(KERNEL_ROOT)/build/make.obj @@ -52,7 +52,7 @@ $(eval OBJS += $(LOCALC)) \ $(if $(strip $(LOCALC)),$(eval $(LOCALC): $(1) @if [ ! -d $$(@D) ]; then mkdir -p $$(@D); fi @echo cc $$< - @/bin/echo -n $(dir $(LOCALC)) >>$(KERNEL_ROOT)/build/make.dep + @echo -n $(dir $(LOCALC)) >>$(KERNEL_ROOT)/build/make.dep @($(CROSS_COMPILE)gcc -MM $$(CFLAGS) -c $$<) >>$(KERNEL_ROOT)/build/make.dep @$(CROSS_COMPILE)gcc $$(CFLAGS) -c $$< -o $$@)) endef @@ -64,7 +64,7 @@ $(eval LOCALCPP := $(addprefix $(BUILD_DIR)/,$(COBJ))) \ $(eval OBJS += $(LOCALCPP)) \ $(if $(strip $(LOCALCPP)),$(eval $(LOCALCPP): $(1) @if [ ! -d $$(@D) ]; then mkdir -p $$(@D); fi - @echo cc $$< + @echo cpp $$< @/bin/echo -n $(dir $(LOCALCPP)) >>$(KERNEL_ROOT)/build/make.dep @$(CROSS_COMPILE)g++ -MM $$(CXXFLAGS) -c $$< >>$(KERNEL_ROOT)/build/make.dep @$(CROSS_COMPILE)g++ $$(CXXFLAGS) -c $$< -o $$@)) @@ -90,7 +90,7 @@ $(eval LOCALS := $(addprefix $(BUILD_DIR)/,$(SOBJ))) \ $(eval OBJS += $(LOCALS)) \ $(if $(strip $(LOCALS)),$(eval $(LOCALS): $(1) @if [ ! -d $$(@D) ]; then mkdir -p $$(@D); fi - @echo cc $$< + @echo asm $$< @/bin/echo -n $(dir $(LOCALC)) >>$(KERNEL_ROOT)/build/make.dep @$(CROSS_COMPILE)gcc -MM $$(CFLAGS) -c $$< >>$(KERNEL_ROOT)/build/make.dep @$(CROSS_COMPILE)gcc $$(AFLAGS) -c $$< -o $$@)) @@ -124,7 +124,7 @@ $(if $(SRCS),$(foreach f,$(SRCS),$(call add_S_file,$(addprefix $(CUR_DIR)/,$(f)) SRCS := $(strip $(filter %.a,$(SRC_FILES))) $(if $(SRCS),$(foreach f,$(SRCS),$(call add_a_file,$(addprefix $(CUR_DIR)/,$(f))))) -COMPILER:$(OBJS) +COMPILER:$(OBJS) diff --git a/Ubiquitous/XiZi_IIoT/lib/newlib/Makefile b/Ubiquitous/XiZi_IIoT/lib/newlib/Makefile index 04f58c55d..9d1d30cdd 100644 --- a/Ubiquitous/XiZi_IIoT/lib/newlib/Makefile +++ b/Ubiquitous/XiZi_IIoT/lib/newlib/Makefile @@ -1,5 +1,11 @@ SRC_FILES := stdio.c fs_syscalls.c time_syscalls.c mem_syscalls.c task_syscalls.c +$(eval _SDIDINIT_EXISTS := $(shell echo \ + '#include \nint main() { (void)_GLOBAL_REENT->__sdidinit; return 0; }' \ + | $(CROSS_COMPILE)gcc $(CFLAGS) -x c -o /dev/null -c - 2>/dev/null && echo 1 || echo 0)) +ifeq ($(_SDIDINIT_EXISTS), 1) +CFLAGS += -D_SDIDINIT_EXISTS +endif include $(KERNEL_ROOT)/compiler.mk diff --git a/Ubiquitous/XiZi_IIoT/lib/newlib/stdio.c b/Ubiquitous/XiZi_IIoT/lib/newlib/stdio.c index 6ae393a96..b18aed5bd 100644 --- a/Ubiquitous/XiZi_IIoT/lib/newlib/stdio.c +++ b/Ubiquitous/XiZi_IIoT/lib/newlib/stdio.c @@ -106,7 +106,10 @@ int LibcStdioSetConsole(const char* device_name, int mode) _GLOBAL_REENT->_stderr = std_console; } /* set the __sdidinit as 1 */ + // this field is deprecated in newer versions of libc +#ifdef _SDIDINIT_EXISTS _GLOBAL_REENT->__sdidinit = 1; +#endif } if (std_console)