-
Notifications
You must be signed in to change notification settings - Fork 1
CH32: control target configuration from the environment #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
|
||
|
|
||
| YES=TRUE | ||
| NO=FALSE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are defined in core/dev/Makefile
| #.include "words/dicthelp.s" | ||
|
|
||
| .if WANT_QEM_BUILD | ||
| .ifdef BUILD_QEM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dropped the WANT_ prefix to distinguish these from the set of config.inc parameters. They are not that anymore. I also had to swap BUILD and target ID, because 307_BUILD is not a valid symbol.
| TMPPATH?=$(HOME)/ng/dev/uc/minasm | ||
| MINICOM=/opt/homebrew/bin/minicom | ||
| MINICOM=/usr/local/bin/minicom | ||
| AMSHELL=$(TMPPATH)/tools/amforth-shell.py --port $(MODEM) --speed 115200 $1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pulled AMSHELL up to core Makefile.
| ifeq ($(wildcard $(TC_DIR)),) | ||
| ifeq ($(strip $(ARDUINO)),TRUE) | ||
| BIN_STUB=$(ARDU15)/packages/WCH/tools/riscv-none-embed-gcc/8.2.0/bin/riscv-none-embed- | ||
| TC_DIR = $(ARDU15)/packages/WCH/tools/riscv-none-embed-gcc/8.2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacing BIN_STUB with TC_DIR and CROSS to match the rest.
| OBJCOPY := $(BIN_STUB)objcopy | ||
| OBJDUMP := $(BIN_STUB)objdump | ||
| OBJSIZE := $(BIN_STUB)size | ||
| RANLIB := $(BIN_STUB)ranlib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pulled up to core Makefile
| ifeq ($(strip $(ASMONLY)),YES) | ||
| SRC_DIRS := . | ||
| SRCS = $(shell find $(SRC_DIRS) -name "*.S") | ||
| SRCS = $(shell find $(SRC_DIRS) -name "*.S" | sed 's|^./||') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
find returns the filename with the directory being searched prepended. That results in USER_OBJS to look like build/./amforth.S. This later causes troubles when you're trying to match targets that do not have the intervening dot directory. I needed this when I was trying to hit core Makefile targets, which I later gave up on (for now), but this seems like a good fix to keep regardless.
rv/mcu/ch32v307/Makefile
Outdated
| $(BUILD_DIR)/$(LIB_USER)/%,$(OBJS)) | ||
|
|
||
| INC_FLAGS := -I . -I ../.. -I $(AMFORTH)/core -I $(AMFORTH) | ||
| INC_FLAGS := -I . $(INCLUDES) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
INCLUDES is inherited from core Makefile
| ## Connect via AmShell | ||
| shell: | ||
| export EDITOR=emacs | ||
| $(AMSHELL) --no-error-on-output -i |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pulled up into core Makefile
| $(MINICOM) -D $(MODEM) --color=on -C minicom.cap | ||
|
|
||
| ## Update build info - run before build | ||
| info: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicates buildinfo from core Makefile
| $(HOME)/.cargo/bin/wlink flash $(BUILD_DIR)/$(TARGET_HEX) | ||
|
|
||
| ## Clean - run before build | ||
| clean: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicates clean from core Makefile.
868765a to
d338d8d
Compare
| run: cd rv/mcu/hifive1 && WANT_IGNORECASE=1 make all | ||
|
|
||
| - name: Build CH32 | ||
| run: cd rv/mcu/ch32v307 && WANT_IGNORECASE=1 make all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Building both 307 and QEM configurations now.
| mkdir -p build | ||
|
|
||
| AOPTS ?= -g --warn --fatal-warnings -alms=build/amforth.lst-as | ||
| ASFLAGS := -g --warn --fatal-warnings -alms=build/amforth.lst-as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adopting the naming convention from the CH32 Makefile.
| CPPFLAGS := $(FLAGS) $(INCLUDES) -MMD -MP $(DEFINES) | ||
|
|
||
| LDFLAGS := $(FLAGS) -T $(LD_FILE) -nostartfiles -Xlinker -t -Xlinker --gc-sections -Xlinker --verbose --specs=nano.specs --specs=nosys.specs \ | ||
| #LDFLAGS += -nostartfiles -Xlinker -t -Xlinker --gc-sections -Xlinker --verbose --specs=nano.specs --specs=nosys.specs \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused
|
|
||
| OBJS = $(SRCS:%=$(BUILD_DIR)/%.o) | ||
| DEPS = $(OBJS:.o=.d) | ||
| #DEPS = $(OBJS:.o=.d) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused
|
|
||
| ifeq ($(strip $(WANT_203)),YES) | ||
| # Default target to build | ||
| TARGET ?= 307 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Picked 307 as the default target config.
| # however dependencies of both targets are collected and executed, so this will run some unnecessary steps from core | ||
| # resulting in unnecessary files in build/ | ||
| $(BUILD_DIR)/$(TARGET_ELF): buildinfo $(USER_OBJS) $(BUILD_DIR)/libcode.a | ||
| $(BUILD_DIR)/$(TARGET_ELF): $(USER_OBJS) $(BUILD_DIR)/libcode.a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
buildinfo really should be prerequisite of the earlier file targets not the elf file.
d338d8d to
0d6a5ca
Compare
| SOCKSHELL=$(TMPPATH)/tools/socket-shell.py --port $(MODEM) --speed 115200 $1 | ||
| QEMU_RV32 ?= qemu-system-riscv32 | ||
| WLINK ?= $(HOME)/.cargo/bin/wlink | ||
| MINICOM ?= minicom |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaults for some of the .env parameters.
| TARGET_HEX := $(TARGET_NAME).hex | ||
| TARGET_BIN := $(TARGET_NAME).bin | ||
| TARGET_MAP := $(TARGET_NAME).map | ||
| TARGET_LIST := $(TARGET_NAME).list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this further down, closer to where it's used.
| CROSS = riscv-none-embed- | ||
| TOOLCHAIN = WCH-via-Arduino | ||
| OPENOCD = $(ARDU15)/packages/WCH/tools/openocd/1.0.0/bin/openocd | ||
| OPENCFG = $(ARDU15)/packages/WCH/tools/openocd/1.0.0/bin/wch-riscv.cfg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving the OpenOCD stuff here since it depends on ArduinoIDE being installed.
The build setup for CH32 controls the target configuration to build with config.inc parameters. This makes it difficult to change whatever is configured dynamically in CI. This PR allows overriding this with environment variables.
Summary of changes:
See more detailed explanations inline.