Skip to content

Commit

Permalink
Switch back around to numbered #define's for processor selection.
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlohr committed Feb 13, 2024
1 parent 015a6ae commit 695fc89
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
8 changes: 4 additions & 4 deletions ch32v003fun/ch32v003fun.ld
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ ENTRY( InterruptVector )

MEMORY
{
#if TARGET_MCU == CH32V003
#if TARGET_MCU_LD == 0
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 16K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 2K
#elif TARGET_MCU == CH32V10x
#elif TARGET_MCU_LD == 1
#if MCU_PACKAGE == 1
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 64K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
Expand All @@ -15,7 +15,7 @@ MEMORY
#else
#error "Unknown MCU package"
#endif
#elif TARGET_MCU == CH32V20x
#elif TARGET_MCU_LD == 2
#if MCU_PACKAGE == 1
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 64K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 20K
Expand All @@ -28,7 +28,7 @@ MEMORY
#else
#error "Unknown MCU package"
#endif
#elif TARGET_MCU == CH32V30x
#elif TARGET_MCU_LD == 3
#if MCU_PACKAGE == 1
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 256K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 64K
Expand Down
5 changes: 3 additions & 2 deletions ch32v003fun/ch32v003fun.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ ifeq ($(TARGET_MCU),CH32V003)
-I. -Wall $(EXTRA_CFLAGS)

GENERATED_LD_FILE?=$(CH32V003FUN)/generated_ch32v003.ld
TARGET_MCU_LD:=0
LINKER_SCRIPT?=$(GENERATED_LD_FILE)
else
ifeq ($(findstring CH32V10,$(TARGET_MCU)),CH32V10)
Expand Down Expand Up @@ -99,10 +100,10 @@ clangd_clean :
FLASH_COMMAND?=$(MINICHLINK)/minichlink -w $< $(WRITE_SECTION) -b

$(GENERATED_LD_FILE) :
$(PREFIX)-gcc -E -P -x c -DTARGET_MCU=$(TARGET_MCU) $(CH32V003FUN)/ch32v003fun.ld > $(GENERATED_LD_FILE)
$(PREFIX)-gcc -E -P -x c -DTARGET_MCU=$(TARGET_MCU) -DMCU_PACKAGE=$(MCU_PACKAGE) -DTARGET_MCU_LD=$(TARGET_MCU_LD) $(CH32V003FUN)/ch32v003fun.ld > $(GENERATED_LD_FILE)


$(TARGET).elf : $(FILES_TO_COMPILE) $(LINKER_SCRIPT)
$(TARGET).elf : $(FILES_TO_COMPILE) $(LINKER_SCRIPT) $(EXTRA_ELF_DEPENDENCIES)
$(PREFIX)-gcc -o $@ $(FILES_TO_COMPILE) $(CFLAGS) $(LDFLAGS)

cv_flash : $(TARGET).bin
Expand Down
2 changes: 2 additions & 0 deletions ch32v003fun/ch32v10xfun.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ else ifeq ($(findstring C6, $(TARGET_MCU_PACKAGE)), C6)
MCU_PACKAGE:=2
endif

TARGET_MCU_LD:=1

GENERATED_LD_FILE:=$(CH32V003FUN)/generated_$(TARGET_MCU_PACKAGE).ld
LINKER_SCRIPT:=$(GENERATED_LD_FILE)
FILES_TO_COMPILE:=$(SYSTEM_C) $(TARGET).$(TARGET_EXT) $(ADDITIONAL_C_FILES)
Expand Down
2 changes: 2 additions & 0 deletions ch32v003fun/ch32v20xfun.mk
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ else
CFLAGS+=-DCH32V20x_D6
endif

TARGET_MCU_LD:=2

GENERATED_LD_FILE:=$(CH32V003FUN)/generated_$(TARGET_MCU_PACKAGE).ld
LINKER_SCRIPT:=$(GENERATED_LD_FILE)
FILES_TO_COMPILE:=$(SYSTEM_C) $(TARGET).$(TARGET_EXT) $(ADDITIONAL_C_FILES)
Expand Down
2 changes: 2 additions & 0 deletions ch32v003fun/ch32v30xfun.mk
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ else
CFLAGS+=-DCH32V30x_D8C
endif

TARGET_MCU_LD:=3

GENERATED_LD_FILE:=$(CH32V003FUN)/generated_$(TARGET_MCU_PACKAGE).ld
LINKER_SCRIPT:=$(GENERATED_LD_FILE)
FILES_TO_COMPILE:=$(SYSTEM_C) $(TARGET).$(TARGET_EXT) $(ADDITIONAL_C_FILES)
Expand Down

0 comments on commit 695fc89

Please sign in to comment.