Skip to content

Commit 99d4ccc

Browse files
committed
Enabled I and D caches + sdioio works -- most times
1 parent 81c7665 commit 99d4ccc

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

ports/stm/boards/daisy_seed_with_sdram/mpconfigboard.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ MCU_PACKAGE = UFBGA176
1313
LD_COMMON = boards/common_tcm.ld
1414
LD_FILE = boards/STM32H750.ld
1515

16-
CIRCUITPY_SDIOIO = 0
16+
CIRCUITPY_SDIOIO = 1

ports/stm/common-hal/sdioio/SDCard.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,13 @@ int common_hal_sdioio_sdcard_writeblocks(sdioio_sdcard_obj_t *self, uint32_t sta
242242
wait_write_complete(self);
243243
self->state_programming = true;
244244
common_hal_mcu_disable_interrupts();
245-
HAL_StatusTypeDef r = HAL_SD_WriteBlocks(&self->handle, bufinfo->buf, start_block, bufinfo->len / 512, 1000);
245+
#ifdef STM32H750xx
246+
// longer timeouts needed because code executing from QSPI is slower
247+
uint32_t time_out = SDMMC_DATATIMEOUT;
248+
#else
249+
uint32_t time_out = 1000;
250+
#endif
251+
HAL_StatusTypeDef r = HAL_SD_WriteBlocks(&self->handle, bufinfo->buf, start_block, bufinfo->len / 512, time_out);
246252
common_hal_mcu_enable_interrupts();
247253
if (r != HAL_OK) {
248254
return -EIO;
@@ -255,7 +261,13 @@ int common_hal_sdioio_sdcard_readblocks(sdioio_sdcard_obj_t *self, uint32_t star
255261
check_whole_block(bufinfo);
256262
wait_write_complete(self);
257263
common_hal_mcu_disable_interrupts();
258-
HAL_StatusTypeDef r = HAL_SD_ReadBlocks(&self->handle, bufinfo->buf, start_block, bufinfo->len / 512, 1000);
264+
#ifdef STM32H750xx
265+
// longer timeouts needed because code executing from QSPI is slower
266+
uint32_t time_out = SDMMC_DATATIMEOUT;
267+
#else
268+
uint32_t time_out = 1000;
269+
#endif
270+
HAL_StatusTypeDef r = HAL_SD_ReadBlocks(&self->handle, bufinfo->buf, start_block, bufinfo->len / 512, time_out);
259271
common_hal_mcu_enable_interrupts();
260272
if (r != HAL_OK) {
261273
return -EIO;

ports/stm/supervisor/port.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,16 @@ __attribute__((used, naked)) void Reset_Handler(void) {
146146
start execution of the firmware from the external flash.
147147
It also makes the SystemInit() call not necessary for this chip.
148148
*/
149+
#if defined(__ICACHE_PRESENT) && (__ICACHE_PRESENT == 1U)
150+
/* Enable I cache. */
151+
SCB_EnableICache();
152+
#endif /* __ICACHE_PRESENT */
153+
154+
#if defined(__DCACHE_PRESENT) && (__DCACHE_PRESENT == 1U)
155+
/* Enable D cache. */
156+
SCB_EnableDCache();
157+
#endif /* __DCACHE_PRESENT */
158+
149159
#else
150160
SystemInit();
151161
#endif

0 commit comments

Comments
 (0)