From 792def24f369d1dce64e0d63b7ee52e140c0b777 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Tue, 17 Oct 2023 11:10:03 -0700 Subject: [PATCH] A few silabs improvements * Fix watchdog code crash. * Define status LEDs for all boards. * Add flash target to Makefile. * Reduce build verbosity. --- ports/silabs/Makefile | 45 +++++-------------- ports/silabs/README.md | 9 ++++ .../devkit_xg24_brd2601b/mpconfigboard.h | 4 ++ .../explorerkit_xg24_brd2703a/mpconfigboard.h | 2 + .../mpconfigboard.h | 2 + .../common-hal/watchdog/WatchDogTimer.c | 7 +++ 6 files changed, 35 insertions(+), 34 deletions(-) diff --git a/ports/silabs/Makefile b/ports/silabs/Makefile index 71092afcbf..6a2165333d 100644 --- a/ports/silabs/Makefile +++ b/ports/silabs/Makefile @@ -24,7 +24,7 @@ # .SUFFIXES: # ignore builtin rules -.PHONY: all clean slc-clean slc-generate dependents +.PHONY: all clean slc-clean slc-generate dependents flash # Values set by the initial generation PROJECTNAME = circuitpython_efr32 # If the build directory is not given, make it reflect the board name. @@ -142,10 +142,13 @@ $(SILABS_BUILD)/$(PROJECTNAME).Makefile: | $(HEADER_BUILD)/mpversion.h +@$(MAKE) --no-print-directory slc-generate $(OUTPUT_DIR)/firmware.out: $(SILABS_BUILD)/pin_functions.h $(SILABS_BUILD)/pins.c $(OBJ) $(OBJS) $(LIB_FILES) - @echo 'Linking $(OUTPUT_DIR)/firmware.out' - @echo "$(OBJS) $(OBJ)" > $(OUTPUT_DIR)/linker_objs - $(CC) $(LD_FLAGS) @$(OUTPUT_DIR)/linker_objs $(LIBS) -o $(OUTPUT_DIR)/firmware.out - $(OBJCOPY) $(OUTPUT_DIR)/firmware.out -O binary $(OUTPUT_DIR)/firmware.bin + $(STEPECHO) 'Linking $(OUTPUT_DIR)/firmware.out' + $(Q)echo "$(OBJS) $(OBJ)" > $(OUTPUT_DIR)/linker_objs + $(Q)$(CC) $(LD_FLAGS) @$(OUTPUT_DIR)/linker_objs $(LIBS) -o $(OUTPUT_DIR)/firmware.out + $(Q)$(OBJCOPY) $(OUTPUT_DIR)/firmware.out -O binary $(OUTPUT_DIR)/firmware.bin + +flash: $(OUTPUT_DIR)/firmware.bin + $(Q)commander flash -d EFR32MG24 --address 08000000 $(OUTPUT_DIR)/firmware.bin $(OUTPUT_DIR)/firmware.hex: @@ -174,37 +177,11 @@ endif @sed -i 's/ autogen\// $(SILABS_BUILD)\/autogen\//g' $(SILABS_BUILD)/circuitpython_efr32.project.mak @sed -i 's/-T"autogen\//-T"$(SILABS_BUILD)\/autogen\//g' $(SILABS_BUILD)/circuitpython_efr32.project.mak -# tools/slc_cli_linux/bin/slc-cli/developer/exporter_templates/arm_gcc/arm_gcc.Makefile defines -# ECHO = @ -# which is not compatible with py/mkenv.mk: +# tools/slc_cli_linux/bin/slc-cli/developer/exporter_templates/arm_gcc/arm_gcc.Makefile includes +# build rules and defines ECHO = @ when VERBOSE = 1 which is not compatible with py/mkenv.mk: # ECHO = @echo # so override ECHO -$(OBJS): ECHO = +$(OBJS): ECHO = $(Q) #$(OBJS): -$(OUTPUT_DIR)/%.o: %.c - #@echo 'Building $<' - @$(MKDIR_P) $(@D) - @$(CC) $(CFLAGS) -c -o $@ $< - -$(OUTPUT_DIR)/%.o: %.cpp - #@echo 'Building $<' - @$(MKDIR_P) $(@D) - @$(CXX) $(CXXFLAGS) -c -o $@ $< - -$(OUTPUT_DIR)/%.o: %.cc - #@echo 'Building $<' - @$(MKDIR_P) $(@D) - @$(CXX) $(CXXFLAGS) -c -o $@ $< - -$(OUTPUT_DIR)/%.o: %.s - #@echo 'Building $<' - @$(MKDIR_P) $(@D) - @$(CC) $(ASMFLAGS) -c -o $@ $< - -$(OUTPUT_DIR)/%.o: %.S - #@echo 'Building $<' - @$(MKDIR_P) $(@D) - @$(CC) $(ASMFLAGS) -c -o $@ $< - include $(TOP)/py/mkrules.mk diff --git a/ports/silabs/README.md b/ports/silabs/README.md index 17423f57a3..3813104727 100644 --- a/ports/silabs/README.md +++ b/ports/silabs/README.md @@ -34,6 +34,8 @@ Install necessary packages sudo apt install default-jre gcc-arm-none-eabi wget python3 python3-pip git git-lfs gettext uncrustify sudo python -m pip install --upgrade pip +**Note** that this uses git lfs and will not link without it. The error is something like "Unknown file format" because git lfs has a text placeholder file. + ## Supported boards ## | Board | Code | Build CMD | @@ -71,6 +73,13 @@ Clean the project by using: make BOARD=explorerkit_xg24_brd2703a clean +## Flashing CircuitPython + +Flash the project by using [Simplicity Commander](https://community.silabs.com/s/article/simplicity-commander?language=en_US): + + make BOARD=explorerkit_xg24_brd2703a flash + + ## Running CircuitPython ## ### Connecting to the Serial Console ### diff --git a/ports/silabs/boards/devkit_xg24_brd2601b/mpconfigboard.h b/ports/silabs/boards/devkit_xg24_brd2601b/mpconfigboard.h index 5456e1ecd5..2504c12c63 100644 --- a/ports/silabs/boards/devkit_xg24_brd2601b/mpconfigboard.h +++ b/ports/silabs/boards/devkit_xg24_brd2601b/mpconfigboard.h @@ -34,6 +34,10 @@ #define BOARD_HSE_SOURCE (RCC_HSE_BYPASS) #define BOARD_HAS_LOW_SPEED_CRYSTAL (0) +#define CIRCUITPY_RGB_STATUS_R (&pin_PD2) +#define CIRCUITPY_RGB_STATUS_G (&pin_PA4) +#define CIRCUITPY_RGB_STATUS_B (&pin_PB0) + // On-board flash #define SPI_FLASH_MOSI_PIN (&pin_PC3) #define SPI_FLASH_MISO_PIN (&pin_PC2) diff --git a/ports/silabs/boards/explorerkit_xg24_brd2703a/mpconfigboard.h b/ports/silabs/boards/explorerkit_xg24_brd2703a/mpconfigboard.h index eb1efca12d..db3257e689 100644 --- a/ports/silabs/boards/explorerkit_xg24_brd2703a/mpconfigboard.h +++ b/ports/silabs/boards/explorerkit_xg24_brd2703a/mpconfigboard.h @@ -37,6 +37,8 @@ #define BOARD_HSE_SOURCE (RCC_HSE_BYPASS) #define BOARD_HAS_LOW_SPEED_CRYSTAL (0) +#define MICROPY_HW_LED_STATUS (&pin_PA4) + #define DEFAULT_I2C_BUS_SDA (&pin_PC5) #define DEFAULT_I2C_BUS_SCL (&pin_PC4) #define DEFAULT_I2C_PERIPHERAL I2C0 diff --git a/ports/silabs/boards/sparkfun_thingplus_matter_mgm240p_brd2704a/mpconfigboard.h b/ports/silabs/boards/sparkfun_thingplus_matter_mgm240p_brd2704a/mpconfigboard.h index ea43ef27cd..463a2e5b1f 100644 --- a/ports/silabs/boards/sparkfun_thingplus_matter_mgm240p_brd2704a/mpconfigboard.h +++ b/ports/silabs/boards/sparkfun_thingplus_matter_mgm240p_brd2704a/mpconfigboard.h @@ -34,6 +34,8 @@ #define BOARD_HSE_SOURCE (RCC_HSE_BYPASS) #define BOARD_HAS_LOW_SPEED_CRYSTAL (0) +#define MICROPY_HW_LED_STATUS (&pin_PA8) + #define DEFAULT_I2C_BUS_SDA (&pin_PB4) #define DEFAULT_I2C_BUS_SCL (&pin_PB3) #define DEFAULT_I2C_PERIPHERAL I2C0 diff --git a/ports/silabs/common-hal/watchdog/WatchDogTimer.c b/ports/silabs/common-hal/watchdog/WatchDogTimer.c index d65c794833..21b6cc6126 100644 --- a/ports/silabs/common-hal/watchdog/WatchDogTimer.c +++ b/ports/silabs/common-hal/watchdog/WatchDogTimer.c @@ -33,11 +33,16 @@ #include "em_wdog.h" #include "em_cmu.h" +static bool _wdt_init = false; + void common_hal_watchdog_feed(watchdog_watchdogtimer_obj_t *self) { WDOGn_Feed(DEFAULT_WDOG); } void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) { + if (!_wdt_init) { + return; + } WDOG_Enable(false); } @@ -105,6 +110,8 @@ void common_hal_watchdog_set_timeout(watchdog_watchdogtimer_obj_t *self, // Initializing watchdog with chosen settings WDOGn_Init(DEFAULT_WDOG, &wdogInit); + + _wdt_init = true; } }