Skip to content

Commit

Permalink
Add 256/64 build
Browse files Browse the repository at this point in the history
  • Loading branch information
cpq committed Jan 21, 2024
1 parent f883504 commit 3880300
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 6 additions & 2 deletions examples/wch/ch32v307-make-baremetal-builtin/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# By default, this firmware is built with 288/32 flash/ram device configuration
# To build it with 256/64 configuration, run the following:
# make CFLAGS_EXTRA="-Wl,--defsym -Wl,RAM_64K=1"

ROOT ?= $(realpath $(PWD)/../../..)
PREFIX ?= riscv-none-elf
#PREFIX ?= docker run --platform linux/amd64 --rm -it -v$(ROOT):$(ROOT) -w $(PWD) mdashnet/riscv riscv-none-elf
CFLAGS = -W -Wall -Wextra -Wundef -Wshadow -Wdouble-promotion
CFLAGS += -Wformat-truncation -Wconversion -Wno-sign-conversion
CFLAGS += -ffunction-sections -fdata-sections -fno-common
CFLAGS += -DSYSCLK_FREQ_144MHz_HSE -I. -Ivendor -g3 -Os
CFLAGS += -march=rv32imafc -mabi=ilp32 $(CFLAGS_EXTRA)
CFLAGS += -march=rv32imafc -mabi=ilp32
LDFLAGS = -T vendor/link.ld -nostartfiles --specs=nano.specs --specs=nosys.specs -Wl,--gc-sections
SOURCES = hal.c main.c mongoose.c net.c packed_fs.c
SOURCES += vendor/system_ch32v30x.c vendor/startup_ch32v30x_D8C.S
Expand All @@ -24,7 +28,7 @@ firmware.bin: firmware.elf
$(PREFIX)-size --format=berkeley $<

firmware.elf: $(SOURCES) hal.h mongoose_custom.h Makefile
$(PREFIX)-gcc $(SOURCES) $(CFLAGS) $(LDFLAGS) -o $@
$(PREFIX)-gcc $(SOURCES) $(CFLAGS) $(LDFLAGS) $(CFLAGS_EXTRA) -o $@

flash: firmware.bin
wchisp flash $<
Expand Down
10 changes: 7 additions & 3 deletions examples/wch/ch32v307-make-baremetal-builtin/vendor/link.ld
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ __stack_size = 4096;
PROVIDE( _stack_size = __stack_size );

MEMORY {
/* Possible configurations: 192/128, 224/96, 256/64, 288/32 */
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 288k
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32k
/*
* Possible configurations: 192/128, 224/96, 256/64, 288/32
* By default, we're building with 288/32 configuration
* To build with 256/64, add -Wl,--defsym=RAM_64K=1
*/
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = DEFINED(RAM_64K) ? 256k : 288k
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = DEFINED(RAM_64K) ? 64k : 32k
}

SECTIONS {
Expand Down

0 comments on commit 3880300

Please sign in to comment.