mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-26 22:41:03 +08:00
IMXRT OTA: support included for 1024, 1040, 1064
This commit is contained in:
parent
cde270728f
commit
9878518e29
29
mongoose.c
29
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};
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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};
|
||||
|
Loading…
x
Reference in New Issue
Block a user