Skip to content

Commit fce45af

Browse files
authored
Merge pull request #8484 from tannewt/improve_silabs
A few silabs improvements
2 parents 9f94b1b + 792def2 commit fce45af

File tree

6 files changed

+35
-34
lines changed

6 files changed

+35
-34
lines changed

ports/silabs/Makefile

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#
2525

2626
.SUFFIXES: # ignore builtin rules
27-
.PHONY: all clean slc-clean slc-generate dependents
27+
.PHONY: all clean slc-clean slc-generate dependents flash
2828
# Values set by the initial generation
2929
PROJECTNAME = circuitpython_efr32
3030
# 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
142142
+@$(MAKE) --no-print-directory slc-generate
143143

144144
$(OUTPUT_DIR)/firmware.out: $(SILABS_BUILD)/pin_functions.h $(SILABS_BUILD)/pins.c $(OBJ) $(OBJS) $(LIB_FILES)
145-
@echo 'Linking $(OUTPUT_DIR)/firmware.out'
146-
@echo "$(OBJS) $(OBJ)" > $(OUTPUT_DIR)/linker_objs
147-
$(CC) $(LD_FLAGS) @$(OUTPUT_DIR)/linker_objs $(LIBS) -o $(OUTPUT_DIR)/firmware.out
148-
$(OBJCOPY) $(OUTPUT_DIR)/firmware.out -O binary $(OUTPUT_DIR)/firmware.bin
145+
$(STEPECHO) 'Linking $(OUTPUT_DIR)/firmware.out'
146+
$(Q)echo "$(OBJS) $(OBJ)" > $(OUTPUT_DIR)/linker_objs
147+
$(Q)$(CC) $(LD_FLAGS) @$(OUTPUT_DIR)/linker_objs $(LIBS) -o $(OUTPUT_DIR)/firmware.out
148+
$(Q)$(OBJCOPY) $(OUTPUT_DIR)/firmware.out -O binary $(OUTPUT_DIR)/firmware.bin
149+
150+
flash: $(OUTPUT_DIR)/firmware.bin
151+
$(Q)commander flash -d EFR32MG24 --address 08000000 $(OUTPUT_DIR)/firmware.bin
149152

150153
$(OUTPUT_DIR)/firmware.hex:
151154

@@ -174,37 +177,11 @@ endif
174177
@sed -i 's/ autogen\// $(SILABS_BUILD)\/autogen\//g' $(SILABS_BUILD)/circuitpython_efr32.project.mak
175178
@sed -i 's/-T"autogen\//-T"$(SILABS_BUILD)\/autogen\//g' $(SILABS_BUILD)/circuitpython_efr32.project.mak
176179

177-
# tools/slc_cli_linux/bin/slc-cli/developer/exporter_templates/arm_gcc/arm_gcc.Makefile defines
178-
# ECHO = @
179-
# which is not compatible with py/mkenv.mk:
180+
# tools/slc_cli_linux/bin/slc-cli/developer/exporter_templates/arm_gcc/arm_gcc.Makefile includes
181+
# build rules and defines ECHO = @ when VERBOSE = 1 which is not compatible with py/mkenv.mk:
180182
# ECHO = @echo
181183
# so override ECHO
182-
$(OBJS): ECHO =
184+
$(OBJS): ECHO = $(Q)
183185
#$(OBJS):
184186

185-
$(OUTPUT_DIR)/%.o: %.c
186-
#@echo 'Building $<'
187-
@$(MKDIR_P) $(@D)
188-
@$(CC) $(CFLAGS) -c -o $@ $<
189-
190-
$(OUTPUT_DIR)/%.o: %.cpp
191-
#@echo 'Building $<'
192-
@$(MKDIR_P) $(@D)
193-
@$(CXX) $(CXXFLAGS) -c -o $@ $<
194-
195-
$(OUTPUT_DIR)/%.o: %.cc
196-
#@echo 'Building $<'
197-
@$(MKDIR_P) $(@D)
198-
@$(CXX) $(CXXFLAGS) -c -o $@ $<
199-
200-
$(OUTPUT_DIR)/%.o: %.s
201-
#@echo 'Building $<'
202-
@$(MKDIR_P) $(@D)
203-
@$(CC) $(ASMFLAGS) -c -o $@ $<
204-
205-
$(OUTPUT_DIR)/%.o: %.S
206-
#@echo 'Building $<'
207-
@$(MKDIR_P) $(@D)
208-
@$(CC) $(ASMFLAGS) -c -o $@ $<
209-
210187
include $(TOP)/py/mkrules.mk

ports/silabs/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Install necessary packages
3434
sudo apt install default-jre gcc-arm-none-eabi wget python3 python3-pip git git-lfs gettext uncrustify
3535
sudo python -m pip install --upgrade pip
3636

37+
**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.
38+
3739
## Supported boards ##
3840

3941
| Board | Code | Build CMD |
@@ -71,6 +73,13 @@ Clean the project by using:
7173

7274
make BOARD=explorerkit_xg24_brd2703a clean
7375

76+
## Flashing CircuitPython
77+
78+
Flash the project by using [Simplicity Commander](https://community.silabs.com/s/article/simplicity-commander?language=en_US):
79+
80+
make BOARD=explorerkit_xg24_brd2703a flash
81+
82+
7483
## Running CircuitPython ##
7584

7685
### Connecting to the Serial Console ###

ports/silabs/boards/devkit_xg24_brd2601b/mpconfigboard.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
#define BOARD_HSE_SOURCE (RCC_HSE_BYPASS)
3535
#define BOARD_HAS_LOW_SPEED_CRYSTAL (0)
3636

37+
#define CIRCUITPY_RGB_STATUS_R (&pin_PD2)
38+
#define CIRCUITPY_RGB_STATUS_G (&pin_PA4)
39+
#define CIRCUITPY_RGB_STATUS_B (&pin_PB0)
40+
3741
// On-board flash
3842
#define SPI_FLASH_MOSI_PIN (&pin_PC3)
3943
#define SPI_FLASH_MISO_PIN (&pin_PC2)

ports/silabs/boards/explorerkit_xg24_brd2703a/mpconfigboard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
#define BOARD_HSE_SOURCE (RCC_HSE_BYPASS)
3838
#define BOARD_HAS_LOW_SPEED_CRYSTAL (0)
3939

40+
#define MICROPY_HW_LED_STATUS (&pin_PA4)
41+
4042
#define DEFAULT_I2C_BUS_SDA (&pin_PC5)
4143
#define DEFAULT_I2C_BUS_SCL (&pin_PC4)
4244
#define DEFAULT_I2C_PERIPHERAL I2C0

ports/silabs/boards/sparkfun_thingplus_matter_mgm240p_brd2704a/mpconfigboard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
#define BOARD_HSE_SOURCE (RCC_HSE_BYPASS)
3535
#define BOARD_HAS_LOW_SPEED_CRYSTAL (0)
3636

37+
#define MICROPY_HW_LED_STATUS (&pin_PA8)
38+
3739
#define DEFAULT_I2C_BUS_SDA (&pin_PB4)
3840
#define DEFAULT_I2C_BUS_SCL (&pin_PB3)
3941
#define DEFAULT_I2C_PERIPHERAL I2C0

ports/silabs/common-hal/watchdog/WatchDogTimer.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,16 @@
3333
#include "em_wdog.h"
3434
#include "em_cmu.h"
3535

36+
static bool _wdt_init = false;
37+
3638
void common_hal_watchdog_feed(watchdog_watchdogtimer_obj_t *self) {
3739
WDOGn_Feed(DEFAULT_WDOG);
3840
}
3941

4042
void common_hal_watchdog_deinit(watchdog_watchdogtimer_obj_t *self) {
43+
if (!_wdt_init) {
44+
return;
45+
}
4146
WDOG_Enable(false);
4247
}
4348

@@ -105,6 +110,8 @@ void common_hal_watchdog_set_timeout(watchdog_watchdogtimer_obj_t *self,
105110

106111
// Initializing watchdog with chosen settings
107112
WDOGn_Init(DEFAULT_WDOG, &wdogInit);
113+
114+
_wdt_init = true;
108115
}
109116
}
110117

0 commit comments

Comments
 (0)