Skip to content

Commit ea7cca4

Browse files
committed
Merge remote-tracking branch 'origin/pr-mk4'
2 parents a23693d + 6d75278 commit ea7cca4

File tree

21 files changed

+194
-244
lines changed

21 files changed

+194
-244
lines changed

extmod/vfs_fat.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,9 @@ STATIC mp_obj_t vfs_fat_mount(mp_obj_t self_in, mp_obj_t readonly, mp_obj_t mkfs
379379
if (res == FR_NO_FILESYSTEM && mp_obj_is_true(mkfs)) {
380380
uint8_t working_buf[FF_MAX_SS];
381381
res = f_mkfs(&self->fatfs, FM_FAT | FM_SFD, 0, working_buf, sizeof(working_buf));
382+
if (res == FR_MKFS_ABORTED) { // Probably doesn't support FAT16
383+
res = f_mkfs(&self->fatfs, FM_FAT32, 0, working_buf, sizeof(working_buf));
384+
}
382385
}
383386
if (res != FR_OK) {
384387
mp_raise_OSError(fresult_to_errno_table[res]);

lib/oofatfs/ffconf.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@
7373
/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
7474

7575

76+
#ifndef FF_USE_FASTSEEK
7677
#define FF_USE_FASTSEEK 0
78+
#endif
7779
/* This option switches fast seek function. (0:Disable or 1:Enable) */
7880

7981

lib/stm32lib

Submodule stm32lib updated 754 files

micropython

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../external/micropython

ports/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# this file only useful for Coldcard project
22
stm32/boards/COLDCARD
3+
stm32/boards/COLDCARD_MK4
34
unix/coldcard-mpy
45
unix/unix_random.P
56

ports/stm32/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ endif
400400
ifeq ($(MCU_SERIES),$(filter $(MCU_SERIES),f4 f7 h7 l4))
401401
HAL_SRC_C += $(addprefix $(HAL_DIR)/Src/stm32$(MCU_SERIES)xx_,\
402402
hal_sd.c \
403+
hal_sd_ex.c \
403404
ll_sdmmc.c \
404405
ll_fmc.c \
405406
)

ports/stm32/adc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
extern const mp_obj_type_t pyb_adc_type;
3030
extern const mp_obj_type_t pyb_adc_all_type;
3131

32-
#if defined(ADC_CHANNEL_VBAT)
32+
#if defined(ADC_CHANNEL_VBAT) && MICROPY_HW_ENABLE_ADC
3333

3434
static inline void adc_deselect_vbat(ADC_TypeDef *adc, uint32_t channel) {
3535
(void)adc;

ports/stm32/dma.c

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,49 @@ static const uint8_t dma_irqn[NSTREAM] = {
351351
DMA1_Channel4_5_6_7_IRQn,
352352
};
353353

354+
355+
#elif defined(STM32L4) && defined(DMAMUX1)
356+
357+
// newer L4+ series parts have a DMAMUX unit
358+
#define NCONTROLLERS (2)
359+
#define NSTREAMS_PER_CONTROLLER (7)
360+
#define NSTREAM (NCONTROLLERS * NSTREAMS_PER_CONTROLLER)
361+
362+
#define DMA_SUB_INSTANCE_AS_UINT8(dma_request) (dma_request)
363+
364+
#define DMA1_ENABLE_MASK (0x007f) // Bits in dma_enable_mask corresponding to DMA1
365+
#define DMA2_ENABLE_MASK (0x3f80) // Bits in dma_enable_mask corresponding to DMA2
366+
367+
// DMA1 streams
368+
const dma_descr_t dma_SPI_1_RX = { DMA1_Channel1, DMA_REQUEST_SPI1_RX, dma_id_0, &dma_init_struct_spi_i2c };
369+
const dma_descr_t dma_SPI_1_TX = { DMA1_Channel2, DMA_REQUEST_SPI1_TX, dma_id_1, &dma_init_struct_spi_i2c };
370+
const dma_descr_t dma_SPI_2_RX = { DMA1_Channel3, DMA_REQUEST_SPI2_RX, dma_id_2, &dma_init_struct_spi_i2c };
371+
const dma_descr_t dma_SPI_2_TX = { DMA1_Channel4, DMA_REQUEST_SPI2_TX, dma_id_3, &dma_init_struct_spi_i2c };
372+
const dma_descr_t dma_I2C_2_RX = { DMA1_Channel5, DMA_REQUEST_I2C2_RX, dma_id_4, &dma_init_struct_spi_i2c };
373+
const dma_descr_t dma_I2C_2_TX = { DMA1_Channel6, DMA_REQUEST_I2C2_TX, dma_id_5, &dma_init_struct_spi_i2c };
374+
const dma_descr_t dma_I2C_1_RX = { DMA1_Channel5, DMA_REQUEST_I2C1_RX, dma_id_4, &dma_init_struct_spi_i2c };
375+
const dma_descr_t dma_I2C_1_TX = { DMA1_Channel6, DMA_REQUEST_I2C1_TX, dma_id_5, &dma_init_struct_spi_i2c };
376+
377+
static const uint8_t dma_irqn[NSTREAM] = {
378+
DMA1_Channel1_IRQn,
379+
DMA1_Channel2_IRQn,
380+
DMA1_Channel3_IRQn,
381+
DMA1_Channel4_IRQn,
382+
DMA1_Channel5_IRQn,
383+
DMA1_Channel6_IRQn,
384+
DMA1_Channel7_IRQn,
385+
DMA2_Channel1_IRQn,
386+
DMA2_Channel2_IRQn,
387+
DMA2_Channel3_IRQn,
388+
DMA2_Channel4_IRQn,
389+
DMA2_Channel5_IRQn,
390+
DMA2_Channel6_IRQn,
391+
DMA2_Channel7_IRQn,
392+
};
393+
394+
// chip has some special DMA between SDMCC and system
395+
#undef ENABLE_SDIO
396+
354397
#elif defined(STM32L4)
355398

356399
#define NCONTROLLERS (2)
@@ -460,6 +503,7 @@ static const uint8_t dma_irqn[NSTREAM] = {
460503
DMA2_Channel7_IRQn,
461504
};
462505

506+
463507
#elif defined(STM32H7)
464508

465509
#define NCONTROLLERS (2)
@@ -1044,7 +1088,11 @@ static void dma_idle_handler(uint32_t tick) {
10441088
}
10451089
}
10461090

1047-
#if defined(STM32F0) || defined(STM32L0) || defined(STM32L4)
1091+
#if defined(STM32L4) && defined(DMAMUX1)
1092+
1093+
// not required on L4+?
1094+
1095+
#elif defined(STM32F0) || defined(STM32L0) || defined(STM32L4)
10481096

10491097
void dma_nohal_init(const dma_descr_t *descr, uint32_t config) {
10501098
DMA_Channel_TypeDef *dma = descr->instance;

ports/stm32/flash.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ static const flash_layout_t flash_layout[] = {
9797
};
9898
#endif
9999

100+
#elif defined(STM32L4S5xx)
101+
102+
// as defined stm32lib/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_flash.h
103+
// - operating in single-bank mode (DBANK=0), total 2M; 8k pages
104+
static const flash_layout_t flash_layout[] = {
105+
{ (uint32_t)FLASH_BASE, 0x2000, (2<<20)/0x2000 },
106+
};
107+
100108
#elif defined(STM32L0) || defined(STM32L4) || defined(STM32WB)
101109

102110
static const flash_layout_t flash_layout[] = {

ports/stm32/flashbdev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ STATIC byte flash_cache_mem[0x4000] __attribute__((aligned(4))); // 16k
113113
#elif defined(STM32L432xx) || \
114114
defined(STM32L451xx) || defined(STM32L452xx) || defined(STM32L462xx) || \
115115
defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L496xx) || \
116-
defined(STM32WB)
116+
defined(STM32WB) || defined(STM32L4S5xx)
117117

118118
// The STM32L4xx doesn't have CCRAM, so we use SRAM2 for this, although
119119
// actual location and size is defined by the linker script.

0 commit comments

Comments
 (0)