Skip to content

Commit 3163847

Browse files
committed
stm32/mboot: Add support for G0 MCUs.
Signed-off-by: Damien George <damien@micropython.org>
1 parent c7923b1 commit 3163847

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

ports/stm32/boards/stm32g0b1xe.ld

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ MEMORY
33
{
44
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
55
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 352K
6+
FLASH_APP (rx) : ORIGIN = 0x08008000, LENGTH = 320K
67
FLASH_FS (rx) : ORIGIN = 0x08058000, LENGTH = 160K /* starting @ 352K */
78
}
89

ports/stm32/i2cslave.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ static inline void i2c_slave_init(i2c_slave_t *i2c, int irqn, int irq_pri, int a
4343
RCC->APB1ENR |= 1 << (RCC_APB1ENR_I2C1EN_Pos + i2c_idx);
4444
volatile uint32_t tmp = RCC->APB1ENR; // Delay after enabling clock
4545
(void)tmp;
46+
#elif defined(STM32G0)
47+
RCC->APBENR1 |= 1 << (RCC_APBENR1_I2C1EN_Pos + i2c_idx);
48+
volatile uint32_t tmp = RCC->APBENR1; // Delay after enabling clock
49+
(void)tmp;
4650
#elif defined(STM32H7)
4751
RCC->APB1LENR |= 1 << (RCC_APB1LENR_I2C1EN_Pos + i2c_idx);
4852
volatile uint32_t tmp = RCC->APB1LENR; // Delay after enabling clock

ports/stm32/mboot/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ SRC_C += \
134134
SRC_O += \
135135
$(STARTUP_FILE) \
136136
$(SYSTEM_FILE) \
137-
ports/stm32/resethandler.o \
137+
138+
ifeq ($(MCU_SERIES),$(filter $(MCU_SERIES),f0 g0 l0))
139+
SRC_O += ports/stm32/resethandler_m0.o
140+
else
141+
SRC_O += ports/stm32/resethandler.o
142+
endif
138143

139144
ifeq ($(MBOOT_ENABLE_PACKING), 1)
140145

ports/stm32/mboot/main.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ void SystemClock_Config(void) {
371371
#if defined(STM32F4) || defined(STM32F7)
372372
#define AHBxENR AHB1ENR
373373
#define AHBxENR_GPIOAEN_Pos RCC_AHB1ENR_GPIOAEN_Pos
374+
#elif defined(STM32G0)
375+
#define AHBxENR IOPENR
376+
#define AHBxENR_GPIOAEN_Pos RCC_IOPENR_GPIOAEN_Pos
374377
#elif defined(STM32H7)
375378
#define AHBxENR AHB4ENR
376379
#define AHBxENR_GPIOAEN_Pos RCC_AHB4ENR_GPIOAEN_Pos
@@ -406,7 +409,9 @@ void mp_hal_pin_config_speed(uint32_t port_pin, uint32_t speed) {
406409
/******************************************************************************/
407410
// FLASH
408411

409-
#if defined(STM32WB)
412+
#if defined(STM32G0)
413+
#define FLASH_END (FLASH_BASE + FLASH_SIZE - 1)
414+
#elif defined(STM32WB)
410415
#define FLASH_END FLASH_END_ADDR
411416
#endif
412417

@@ -426,6 +431,8 @@ void mp_hal_pin_config_speed(uint32_t port_pin, uint32_t speed) {
426431
#define FLASH_LAYOUT_STR "@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg" MBOOT_SPIFLASH_LAYOUT MBOOT_SPIFLASH2_LAYOUT
427432
#elif defined(STM32F765xx) || defined(STM32F767xx) || defined(STM32F769xx)
428433
#define FLASH_LAYOUT_STR "@Internal Flash /0x08000000/04*032Kg,01*128Kg,07*256Kg" MBOOT_SPIFLASH_LAYOUT MBOOT_SPIFLASH2_LAYOUT
434+
#elif defined(STM32G0)
435+
#define FLASH_LAYOUT_STR "@Internal Flash /0x08000000/256*02Kg" MBOOT_SPIFLASH_LAYOUT MBOOT_SPIFLASH2_LAYOUT
429436
#elif defined(STM32H743xx)
430437
#define FLASH_LAYOUT_STR "@Internal Flash /0x08000000/16*128Kg" MBOOT_SPIFLASH_LAYOUT MBOOT_SPIFLASH2_LAYOUT
431438
#elif defined(STM32H750xx)
@@ -1349,7 +1356,9 @@ void stm32_main(uint32_t initial_r0) {
13491356
#endif
13501357
#endif
13511358

1359+
#if __CORTEX_M >= 0x03
13521360
NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
1361+
#endif
13531362

13541363
#if USE_CACHE && defined(STM32F7)
13551364
SCB_EnableICache();
@@ -1547,7 +1556,13 @@ void I2Cx_EV_IRQHandler(void) {
15471556

15481557
#if !USE_USB_POLLING
15491558

1550-
#if defined(STM32WB)
1559+
#if defined(STM32G0)
1560+
1561+
void USB_UCPD1_2_IRQHandler(void) {
1562+
HAL_PCD_IRQHandler(&pcd_fs_handle);
1563+
}
1564+
1565+
#elif defined(STM32WB)
15511566

15521567
void USB_LP_IRQHandler(void) {
15531568
HAL_PCD_IRQHandler(&pcd_fs_handle);

0 commit comments

Comments
 (0)