Merge pull request #2955 from cesanta/ota-rt10xx

IMXRT OTA: support included for 1024, 1040, 1064
This commit is contained in:
Sergio R. Caprile 2024-11-07 09:32:05 -03:00 committed by GitHub
commit 69859c61e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 40 additions and 20 deletions

View File

@ -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_write(void *, const void *, size_t);
static bool mg_imxrt_swap(void); 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(): fill at init, support more devices in a dynamic way
// TODO(): then, check alignment is <= 256, see Wizard's #251 // TODO(): then, check alignment is <= 256, see Wizard's #251
static struct mg_flash s_mg_flash_imxrt = { static struct mg_flash s_mg_flash_imxrt = {
(void *) 0x60000000, // Start, (void *) MG_IMXRT_FLASH_START, // Start,
8 * 1024 * 1024, // Size, 8mb 4 * 1024 * 1024, // Size, 4mb
4 * 1024, // Sector size, 4k 4 * 1024, // Sector size, 4k
256, // Align, 256, // Align,
mg_imxrt_write, mg_imxrt_write,
mg_imxrt_swap, mg_imxrt_swap,
}; };
@ -5592,9 +5600,8 @@ struct mg_flexspi_nor_config {
#define MG_FLEXSPI_LUT_OPCODE1(x) \ #define MG_FLEXSPI_LUT_OPCODE1(x) \
(((uint32_t) (((uint32_t) (x)) << 26U)) & 0xFC000000U) (((uint32_t) (((uint32_t) (x)) << 26U)) & 0xFC000000U)
#define FLEXSPI_NOR_INSTANCE 0
#if MG_OTA == MG_OTA_RT1020 #if MG_OTA == MG_OTA_RT1020
// RT102X boards support ROM API version 1.4
struct mg_flexspi_nor_driver_interface { struct mg_flexspi_nor_driver_interface {
uint32_t version; uint32_t version;
int (*init)(uint32_t instance, struct mg_flexspi_nor_config *config); 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); int (*xfer)(uint32_t instance, char *xfer);
void (*clear_cache)(uint32_t instance); 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 { struct mg_flexspi_nor_driver_interface {
uint32_t version; uint32_t version;
int (*init)(uint32_t instance, struct mg_flexspi_nor_config *config); 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 // 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 // must reside in RAM, as flash will be erased
static struct mg_flexspi_nor_config default_config = { static struct mg_flexspi_nor_config default_config = {
.memConfig = {.tag = MG_FLEXSPI_CFG_BLK_TAG, .memConfig = {.tag = MG_FLEXSPI_CFG_BLK_TAG,
@ -5667,7 +5674,9 @@ MG_IRAM static int flexspi_nor_get_config(
*config = &default_config; *config = &default_config;
return 0; return 0;
} }
#else
#if 0
// ROM API get_config call (ROM version >= 1.5)
MG_IRAM static int flexspi_nor_get_config( MG_IRAM static int flexspi_nor_get_config(
struct mg_flexspi_nor_config **config) { struct mg_flexspi_nor_config **config) {
uint32_t options[] = {0xc0000000, 0x00}; uint32_t options[] = {0xc0000000, 0x00};

View File

@ -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_U2A 200 // Renesas U2A16, U2A8, U2A6
#define MG_OTA_RT1020 300 // IMXRT1020 #define MG_OTA_RT1020 300 // IMXRT1020
#define MG_OTA_RT1060 301 // IMXRT1060 #define MG_OTA_RT1060 301 // IMXRT1060
#define MG_OTA_RT1064 302 // IMXRT1064
#define MG_OTA_MCXN 310 // MCXN947 #define MG_OTA_MCXN 310 // MCXN947
#define MG_OTA_FLASH 900 // OTA via an internal flash #define MG_OTA_FLASH 900 // OTA via an internal flash
#define MG_OTA_ESP32 910 // ESP32 OTA implementation #define MG_OTA_ESP32 910 // ESP32 OTA implementation

View File

@ -13,6 +13,7 @@
#define MG_OTA_U2A 200 // Renesas U2A16, U2A8, U2A6 #define MG_OTA_U2A 200 // Renesas U2A16, U2A8, U2A6
#define MG_OTA_RT1020 300 // IMXRT1020 #define MG_OTA_RT1020 300 // IMXRT1020
#define MG_OTA_RT1060 301 // IMXRT1060 #define MG_OTA_RT1060 301 // IMXRT1060
#define MG_OTA_RT1064 302 // IMXRT1064
#define MG_OTA_MCXN 310 // MCXN947 #define MG_OTA_MCXN 310 // MCXN947
#define MG_OTA_FLASH 900 // OTA via an internal flash #define MG_OTA_FLASH 900 // OTA via an internal flash
#define MG_OTA_ESP32 910 // ESP32 OTA implementation #define MG_OTA_ESP32 910 // ESP32 OTA implementation

View File

@ -2,18 +2,26 @@
#include "log.h" #include "log.h"
#include "ota.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_write(void *, const void *, size_t);
static bool mg_imxrt_swap(void); 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(): fill at init, support more devices in a dynamic way
// TODO(): then, check alignment is <= 256, see Wizard's #251 // TODO(): then, check alignment is <= 256, see Wizard's #251
static struct mg_flash s_mg_flash_imxrt = { static struct mg_flash s_mg_flash_imxrt = {
(void *) 0x60000000, // Start, (void *) MG_IMXRT_FLASH_START, // Start,
8 * 1024 * 1024, // Size, 8mb 4 * 1024 * 1024, // Size, 4mb
4 * 1024, // Sector size, 4k 4 * 1024, // Sector size, 4k
256, // Align, 256, // Align,
mg_imxrt_write, mg_imxrt_write,
mg_imxrt_swap, mg_imxrt_swap,
}; };
@ -142,9 +150,8 @@ struct mg_flexspi_nor_config {
#define MG_FLEXSPI_LUT_OPCODE1(x) \ #define MG_FLEXSPI_LUT_OPCODE1(x) \
(((uint32_t) (((uint32_t) (x)) << 26U)) & 0xFC000000U) (((uint32_t) (((uint32_t) (x)) << 26U)) & 0xFC000000U)
#define FLEXSPI_NOR_INSTANCE 0
#if MG_OTA == MG_OTA_RT1020 #if MG_OTA == MG_OTA_RT1020
// RT102X boards support ROM API version 1.4
struct mg_flexspi_nor_driver_interface { struct mg_flexspi_nor_driver_interface {
uint32_t version; uint32_t version;
int (*init)(uint32_t instance, struct mg_flexspi_nor_config *config); 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); int (*xfer)(uint32_t instance, char *xfer);
void (*clear_cache)(uint32_t instance); 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 { struct mg_flexspi_nor_driver_interface {
uint32_t version; uint32_t version;
int (*init)(uint32_t instance, struct mg_flexspi_nor_config *config); 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 // 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 // must reside in RAM, as flash will be erased
static struct mg_flexspi_nor_config default_config = { static struct mg_flexspi_nor_config default_config = {
.memConfig = {.tag = MG_FLEXSPI_CFG_BLK_TAG, .memConfig = {.tag = MG_FLEXSPI_CFG_BLK_TAG,
@ -217,7 +224,9 @@ MG_IRAM static int flexspi_nor_get_config(
*config = &default_config; *config = &default_config;
return 0; return 0;
} }
#else
#if 0
// ROM API get_config call (ROM version >= 1.5)
MG_IRAM static int flexspi_nor_get_config( MG_IRAM static int flexspi_nor_get_config(
struct mg_flexspi_nor_config **config) { struct mg_flexspi_nor_config **config) {
uint32_t options[] = {0xc0000000, 0x00}; uint32_t options[] = {0xc0000000, 0x00};