diff --git a/ports/mimxrt/Makefile b/ports/mimxrt/Makefile index 7f93a6826d..ed7cc0630a 100644 --- a/ports/mimxrt/Makefile +++ b/ports/mimxrt/Makefile @@ -373,6 +373,10 @@ else CFLAGS += -Os -DNDEBUG endif +# Set default values for optional variables +MICROPY_HW_SDRAM_AVAIL ?= 0 +MICROPY_HW_SDRAM_SIZE ?= 0 + # Configure default compiler flags CFLAGS += \ $(INC) \ @@ -389,6 +393,8 @@ CFLAGS += \ -DFSL_SDK_ENABLE_DRIVER_CACHE_CONTROL=1 \ -DI2C_RETRY_TIMES=1000000 \ -DMICROPY_HW_FLASH_SIZE=$(MICROPY_HW_FLASH_SIZE) \ + -DMICROPY_HW_SDRAM_AVAIL=$(MICROPY_HW_SDRAM_AVAIL) \ + -DMICROPY_HW_SDRAM_SIZE=$(MICROPY_HW_SDRAM_SIZE) \ -DSPI_RETRY_TIMES=1000000 \ -DUART_RETRY_TIMES=1000000 \ -DXIP_BOOT_HEADER_ENABLE=1 \ @@ -458,12 +464,6 @@ CFLAGS += \ -DMBEDTLS_CONFIG_FILE='"mbedtls/mbedtls_config.h"' endif -ifdef MICROPY_HW_SDRAM_AVAIL -CFLAGS += \ - -DMICROPY_HW_SDRAM_AVAIL=$(MICROPY_HW_SDRAM_AVAIL) \ - -DMICROPY_HW_SDRAM_SIZE=$(MICROPY_HW_SDRAM_SIZE) -endif - CFLAGS += $(CFLAGS_MOD) $(CFLAGS_EXTRA) # ============================================================================= diff --git a/ports/mimxrt/board_init.c b/ports/mimxrt/board_init.c index c3dbb652bc..12496890ac 100644 --- a/ports/mimxrt/board_init.c +++ b/ports/mimxrt/board_init.c @@ -52,7 +52,7 @@ void board_init(void) { CLOCK_EnableClock(kCLOCK_Iomuxc); // ------------- SDRAM ------------ // - #ifdef MICROPY_HW_SDRAM_AVAIL + #if MICROPY_HW_SDRAM_AVAIL mimxrt_sdram_init(); #endif diff --git a/ports/mimxrt/boards/MIMXRT1021.ld b/ports/mimxrt/boards/MIMXRT1021.ld index 1263cd336c..60557f1bbf 100644 --- a/ports/mimxrt/boards/MIMXRT1021.ld +++ b/ports/mimxrt/boards/MIMXRT1021.ld @@ -27,7 +27,7 @@ dtcm_size = 0x00018000; ocrm_start = 0x20200000; ocrm_size = 0x00018000; -#ifdef MICROPY_HW_SDRAM_AVAIL +#if MICROPY_HW_SDRAM_AVAIL sdram_start = 0x80000000; sdram_size = MICROPY_HW_SDRAM_SIZE; #endif @@ -37,7 +37,7 @@ __stack_size__ = 0x6000; _estack = __StackTop; _sstack = __StackLimit; -#ifdef MICROPY_HW_SDRAM_AVAIL +#if MICROPY_HW_SDRAM_AVAIL _gc_heap_start = ORIGIN(m_sdram); _gc_heap_end = ORIGIN(m_sdram) + LENGTH(m_sdram); #else diff --git a/ports/mimxrt/boards/MIMXRT1052.ld b/ports/mimxrt/boards/MIMXRT1052.ld index f7c60d24f4..3e5739acf5 100644 --- a/ports/mimxrt/boards/MIMXRT1052.ld +++ b/ports/mimxrt/boards/MIMXRT1052.ld @@ -29,7 +29,7 @@ dtcm_size = 0x00020000; ocrm_start = 0x20200000; ocrm_size = 0x00040000; -#ifdef MICROPY_HW_SDRAM_AVAIL +#if MICROPY_HW_SDRAM_AVAIL sdram_start = 0x80000000; sdram_size = MICROPY_HW_SDRAM_SIZE; #endif @@ -39,7 +39,7 @@ __stack_size__ = 0x6000; _estack = __StackTop; _sstack = __StackLimit; -#ifdef MICROPY_HW_SDRAM_AVAIL +#if MICROPY_HW_SDRAM_AVAIL _gc_heap_start = ORIGIN(m_sdram); _gc_heap_end = ORIGIN(m_sdram) + LENGTH(m_sdram); #else diff --git a/ports/mimxrt/boards/MIMXRT1062.ld b/ports/mimxrt/boards/MIMXRT1062.ld index f588e5bd9e..fc4eb20c07 100644 --- a/ports/mimxrt/boards/MIMXRT1062.ld +++ b/ports/mimxrt/boards/MIMXRT1062.ld @@ -29,7 +29,7 @@ dtcm_size = 0x00020000; ocrm_start = 0x20200000; ocrm_size = 0x000C0000; -#ifdef MICROPY_HW_SDRAM_AVAIL +#if MICROPY_HW_SDRAM_AVAIL sdram_start = 0x80000000; sdram_size = MICROPY_HW_SDRAM_SIZE; #endif @@ -39,7 +39,7 @@ __stack_size__ = 0x8000; _estack = __StackTop; _sstack = __StackLimit; -#ifdef MICROPY_HW_SDRAM_AVAIL +#if MICROPY_HW_SDRAM_AVAIL _gc_heap_start = ORIGIN(m_sdram); _gc_heap_end = ORIGIN(m_sdram) + LENGTH(m_sdram); #else diff --git a/ports/mimxrt/boards/MIMXRT1064.ld b/ports/mimxrt/boards/MIMXRT1064.ld index b36c528453..148f1f23e2 100644 --- a/ports/mimxrt/boards/MIMXRT1064.ld +++ b/ports/mimxrt/boards/MIMXRT1064.ld @@ -31,7 +31,7 @@ dtcm_size = 0x00020000; ocrm_start = 0x20200000; ocrm_size = 0x000C0000; -#ifdef MICROPY_HW_SDRAM_AVAIL +#if MICROPY_HW_SDRAM_AVAIL sdram_start = 0x80000000; sdram_size = MICROPY_HW_SDRAM_SIZE; #endif @@ -41,7 +41,7 @@ __stack_size__ = 0x6000; _estack = __StackTop; _sstack = __StackLimit; -#ifdef MICROPY_HW_SDRAM_AVAIL +#if MICROPY_HW_SDRAM_AVAIL _gc_heap_start = ORIGIN(m_sdram); _gc_heap_end = ORIGIN(m_sdram) + LENGTH(m_sdram); #else diff --git a/ports/mimxrt/boards/common.ld b/ports/mimxrt/boards/common.ld index 7aee66e2e8..fbc99da3dd 100644 --- a/ports/mimxrt/boards/common.ld +++ b/ports/mimxrt/boards/common.ld @@ -46,7 +46,7 @@ MEMORY m_dtcm (RW) : ORIGIN = dtcm_start, LENGTH = dtcm_size m_ocrm (RW) : ORIGIN = ocrm_start, LENGTH = ocrm_size - #ifdef MICROPY_HW_SDRAM_AVAIL + #if MICROPY_HW_SDRAM_AVAIL m_sdram (RX) : ORIGIN = sdram_start, LENGTH = sdram_size #endif } @@ -55,7 +55,7 @@ MEMORY SECTIONS { __flash_start = flash_start; - #ifdef MICROPY_HW_SDRAM_AVAIL + #if MICROPY_HW_SDRAM_AVAIL __sdram_start = sdram_start; #endif __vfs_start = ORIGIN(m_vfs);