3030
3131#include "extmod/vfs.h"
3232#include "extmod/vfs_fat.h"
33- #include "py/gc .h"
33+ #include "py/misc .h"
3434#include "py/obj.h"
3535#include "py/runtime.h"
3636#include "lib/oofatfs/ff.h"
@@ -256,12 +256,12 @@ void spi_flash_init(void) {
256256 if (spi_flash_is_initialised ) {
257257 return ;
258258 }
259-
259+
260260 samd_peripherals_sercom_clock_init (SPI_FLASH_SERCOM , SPI_FLASH_SERCOM_INDEX );
261261
262262 // Set up with defaults, then change.
263263 spi_m_sync_init (& spi_flash_desc , SPI_FLASH_SERCOM );
264-
264+
265265 hri_sercomspi_write_CTRLA_DOPO_bf (SPI_FLASH_SERCOM , SPI_FLASH_DOPO );
266266 hri_sercomspi_write_CTRLA_DIPO_bf (SPI_FLASH_SERCOM , SPI_FLASH_DIPO );
267267
@@ -398,7 +398,7 @@ static bool flush_scratch_flash(void) {
398398static bool allocate_ram_cache (void ) {
399399 uint8_t blocks_per_sector = SPI_FLASH_ERASE_SIZE / FILESYSTEM_BLOCK_SIZE ;
400400 uint8_t pages_per_block = FILESYSTEM_BLOCK_SIZE / SPI_FLASH_PAGE_SIZE ;
401- MP_STATE_VM (flash_ram_cache ) = gc_alloc (blocks_per_sector * pages_per_block * sizeof (uint32_t ), false);
401+ MP_STATE_VM (flash_ram_cache ) = m_malloc_maybe (blocks_per_sector * pages_per_block * sizeof (uint32_t ), false);
402402 if (MP_STATE_VM (flash_ram_cache ) == NULL ) {
403403 return false;
404404 }
@@ -409,7 +409,7 @@ static bool allocate_ram_cache(void) {
409409 bool success = true;
410410 for (i = 0 ; i < blocks_per_sector ; i ++ ) {
411411 for (j = 0 ; j < pages_per_block ; j ++ ) {
412- uint8_t * page_cache = gc_alloc (SPI_FLASH_PAGE_SIZE , false);
412+ uint8_t * page_cache = m_malloc_maybe (SPI_FLASH_PAGE_SIZE , false);
413413 if (page_cache == NULL ) {
414414 success = false;
415415 break ;
@@ -427,11 +427,11 @@ static bool allocate_ram_cache(void) {
427427 i ++ ;
428428 for (; i > 0 ; i -- ) {
429429 for (; j > 0 ; j -- ) {
430- gc_free (MP_STATE_VM (flash_ram_cache )[(i - 1 ) * pages_per_block + (j - 1 )]);
430+ m_free (MP_STATE_VM (flash_ram_cache )[(i - 1 ) * pages_per_block + (j - 1 )]);
431431 }
432432 j = pages_per_block ;
433433 }
434- gc_free (MP_STATE_VM (flash_ram_cache ));
434+ m_free (MP_STATE_VM (flash_ram_cache ));
435435 MP_STATE_VM (flash_ram_cache ) = NULL ;
436436 }
437437 return success ;
@@ -474,13 +474,13 @@ static bool flush_ram_cache(bool keep_cache) {
474474 MP_STATE_VM (flash_ram_cache )[i * pages_per_block + j ],
475475 SPI_FLASH_PAGE_SIZE );
476476 if (!keep_cache ) {
477- gc_free (MP_STATE_VM (flash_ram_cache )[i * pages_per_block + j ]);
477+ m_free (MP_STATE_VM (flash_ram_cache )[i * pages_per_block + j ]);
478478 }
479479 }
480480 }
481481 // We're done with the cache for now so give it back.
482482 if (!keep_cache ) {
483- gc_free (MP_STATE_VM (flash_ram_cache ));
483+ m_free (MP_STATE_VM (flash_ram_cache ));
484484 MP_STATE_VM (flash_ram_cache ) = NULL ;
485485 }
486486 return true;
0 commit comments