diff --git a/mongoose.c b/mongoose.c index 56b7d73f..25d92e41 100644 --- a/mongoose.c +++ b/mongoose.c @@ -5452,18 +5452,26 @@ bool mg_ota_end(void) { -#if MG_OTA == MG_OTA_RT1020 || MG_OTA == MG_OTA_RT1060 +#if MG_OTA >= MG_OTA_RT1020 && MG_OTA <= MG_OTA_RT1064 static bool mg_imxrt_write(void *, const void *, size_t); static bool mg_imxrt_swap(void); +#if MG_OTA == MG_OTA_RT1064 +#define MG_IMXRT_FLASH_START 0x70000000 +#define FLEXSPI_NOR_INSTANCE 1 +#else +#define MG_IMXRT_FLASH_START 0x60000000 +#define FLEXSPI_NOR_INSTANCE 0 +#endif + // TODO(): fill at init, support more devices in a dynamic way // TODO(): then, check alignment is <= 256, see Wizard's #251 static struct mg_flash s_mg_flash_imxrt = { - (void *) 0x60000000, // Start, - 8 * 1024 * 1024, // Size, 8mb - 4 * 1024, // Sector size, 4k - 256, // Align, + (void *) MG_IMXRT_FLASH_START, // Start, + 4 * 1024 * 1024, // Size, 4mb + 4 * 1024, // Sector size, 4k + 256, // Align, mg_imxrt_write, mg_imxrt_swap, }; @@ -5592,9 +5600,8 @@ struct mg_flexspi_nor_config { #define MG_FLEXSPI_LUT_OPCODE1(x) \ (((uint32_t) (((uint32_t) (x)) << 26U)) & 0xFC000000U) -#define FLEXSPI_NOR_INSTANCE 0 - #if MG_OTA == MG_OTA_RT1020 +// RT102X boards support ROM API version 1.4 struct mg_flexspi_nor_driver_interface { uint32_t version; int (*init)(uint32_t instance, struct mg_flexspi_nor_config *config); @@ -5609,7 +5616,8 @@ struct mg_flexspi_nor_driver_interface { int (*xfer)(uint32_t instance, char *xfer); void (*clear_cache)(uint32_t instance); }; -#elif MG_OTA == MG_OTA_RT1060 +#else +// RT104x and RT106x support ROM API version 1.5 struct mg_flexspi_nor_driver_interface { uint32_t version; int (*init)(uint32_t instance, struct mg_flexspi_nor_config *config); @@ -5642,7 +5650,6 @@ MG_IRAM static bool flash_page_start(volatile uint32_t *dst) { } // Note: the get_config function below works both for RT1020 and 1060 -#if MG_OTA == MG_OTA_RT1020 // must reside in RAM, as flash will be erased static struct mg_flexspi_nor_config default_config = { .memConfig = {.tag = MG_FLEXSPI_CFG_BLK_TAG, @@ -5667,7 +5674,9 @@ MG_IRAM static int flexspi_nor_get_config( *config = &default_config; return 0; } -#else + +#if 0 +// ROM API get_config call (ROM version >= 1.5) MG_IRAM static int flexspi_nor_get_config( struct mg_flexspi_nor_config **config) { uint32_t options[] = {0xc0000000, 0x00}; diff --git a/mongoose.h b/mongoose.h index 19709fa6..ddf3d3cf 100644 --- a/mongoose.h +++ b/mongoose.h @@ -2655,6 +2655,7 @@ void mg_rpc_list(struct mg_rpc_req *r); #define MG_OTA_U2A 200 // Renesas U2A16, U2A8, U2A6 #define MG_OTA_RT1020 300 // IMXRT1020 #define MG_OTA_RT1060 301 // IMXRT1060 +#define MG_OTA_RT1064 302 // IMXRT1064 #define MG_OTA_MCXN 310 // MCXN947 #define MG_OTA_FLASH 900 // OTA via an internal flash #define MG_OTA_ESP32 910 // ESP32 OTA implementation diff --git a/src/ota.h b/src/ota.h index 116ef9d6..602340f9 100644 --- a/src/ota.h +++ b/src/ota.h @@ -13,6 +13,7 @@ #define MG_OTA_U2A 200 // Renesas U2A16, U2A8, U2A6 #define MG_OTA_RT1020 300 // IMXRT1020 #define MG_OTA_RT1060 301 // IMXRT1060 +#define MG_OTA_RT1064 302 // IMXRT1064 #define MG_OTA_MCXN 310 // MCXN947 #define MG_OTA_FLASH 900 // OTA via an internal flash #define MG_OTA_ESP32 910 // ESP32 OTA implementation diff --git a/src/ota_imxrt.c b/src/ota_imxrt.c index ad8a8828..0a01bfe4 100644 --- a/src/ota_imxrt.c +++ b/src/ota_imxrt.c @@ -2,18 +2,26 @@ #include "log.h" #include "ota.h" -#if MG_OTA == MG_OTA_RT1020 || MG_OTA == MG_OTA_RT1060 +#if MG_OTA >= MG_OTA_RT1020 && MG_OTA <= MG_OTA_RT1064 static bool mg_imxrt_write(void *, const void *, size_t); static bool mg_imxrt_swap(void); +#if MG_OTA == MG_OTA_RT1064 +#define MG_IMXRT_FLASH_START 0x70000000 +#define FLEXSPI_NOR_INSTANCE 1 +#else +#define MG_IMXRT_FLASH_START 0x60000000 +#define FLEXSPI_NOR_INSTANCE 0 +#endif + // TODO(): fill at init, support more devices in a dynamic way // TODO(): then, check alignment is <= 256, see Wizard's #251 static struct mg_flash s_mg_flash_imxrt = { - (void *) 0x60000000, // Start, - 8 * 1024 * 1024, // Size, 8mb - 4 * 1024, // Sector size, 4k - 256, // Align, + (void *) MG_IMXRT_FLASH_START, // Start, + 4 * 1024 * 1024, // Size, 4mb + 4 * 1024, // Sector size, 4k + 256, // Align, mg_imxrt_write, mg_imxrt_swap, }; @@ -142,9 +150,8 @@ struct mg_flexspi_nor_config { #define MG_FLEXSPI_LUT_OPCODE1(x) \ (((uint32_t) (((uint32_t) (x)) << 26U)) & 0xFC000000U) -#define FLEXSPI_NOR_INSTANCE 0 - #if MG_OTA == MG_OTA_RT1020 +// RT102X boards support ROM API version 1.4 struct mg_flexspi_nor_driver_interface { uint32_t version; int (*init)(uint32_t instance, struct mg_flexspi_nor_config *config); @@ -159,7 +166,8 @@ struct mg_flexspi_nor_driver_interface { int (*xfer)(uint32_t instance, char *xfer); void (*clear_cache)(uint32_t instance); }; -#elif MG_OTA == MG_OTA_RT1060 +#else +// RT104x and RT106x support ROM API version 1.5 struct mg_flexspi_nor_driver_interface { uint32_t version; int (*init)(uint32_t instance, struct mg_flexspi_nor_config *config); @@ -192,7 +200,6 @@ MG_IRAM static bool flash_page_start(volatile uint32_t *dst) { } // Note: the get_config function below works both for RT1020 and 1060 -#if MG_OTA == MG_OTA_RT1020 // must reside in RAM, as flash will be erased static struct mg_flexspi_nor_config default_config = { .memConfig = {.tag = MG_FLEXSPI_CFG_BLK_TAG, @@ -217,7 +224,9 @@ MG_IRAM static int flexspi_nor_get_config( *config = &default_config; return 0; } -#else + +#if 0 +// ROM API get_config call (ROM version >= 1.5) MG_IRAM static int flexspi_nor_get_config( struct mg_flexspi_nor_config **config) { uint32_t options[] = {0xc0000000, 0x00};