Add definition of NODE_STORE_TYPEDEF_ATTR and NODE_STORE_ATTR.
This commit is contained in:
parent
1b9479a650
commit
0420b6d72f
|
@ -35,7 +35,8 @@
|
|||
#define NODE_ERR
|
||||
#endif /* NODE_ERROR */
|
||||
|
||||
#define NODE_STORE_ATTR __attribute__((aligned(4),packed))
|
||||
#define NODE_STORE_TYPEDEF_ATTR __attribute__((aligned(4),packed))
|
||||
#define NODE_STORE_ATTR __attribute__((aligned(4)))
|
||||
|
||||
#define CLIENT_SSL_ENABLE
|
||||
#define GPIO_INTERRUPT_ENABLE
|
||||
|
|
|
@ -7,12 +7,10 @@
|
|||
#include "flash_api.h"
|
||||
#include "spi_flash.h"
|
||||
|
||||
#include "c_stdio.h"
|
||||
|
||||
SPIFlashInfo *ICACHE_FLASH_ATTR
|
||||
flash_get_info(void)
|
||||
{
|
||||
static SPIFlashInfo spi_flash_info __attribute__((aligned(4)));
|
||||
static SPIFlashInfo spi_flash_info NODE_STORE_ATTR;
|
||||
static bool is_spi_flash_info_initialized = false;
|
||||
// Make the code more fast
|
||||
if (!is_spi_flash_info_initialized)
|
||||
|
@ -20,6 +18,7 @@ flash_get_info(void)
|
|||
SPIRead(0, &spi_flash_info, sizeof(spi_flash_info));
|
||||
is_spi_flash_info_initialized = true;
|
||||
}
|
||||
// return (SPIFlashInfo *)(0x40200000);
|
||||
return &spi_flash_info;
|
||||
}
|
||||
|
||||
|
@ -75,8 +74,7 @@ flash_set_size(uint8_t size)
|
|||
// Dangerous, here are dinosaur infested!!!!!
|
||||
// Reboot required!!!
|
||||
// If you don't know what you're doing, your nodemcu may turn into stone ...
|
||||
c_printf("\nSet size!!! %d\n", size);
|
||||
uint8_t data[SPI_FLASH_SEC_SIZE] __attribute__((aligned(4)));
|
||||
uint8_t data[SPI_FLASH_SEC_SIZE] NODE_STORE_ATTR;
|
||||
SPIRead(0, data, sizeof(data));
|
||||
SPIFlashInfo *p_spi_flash_info = (SPIFlashInfo *)(data);
|
||||
p_spi_flash_info->size = size;
|
||||
|
@ -195,19 +193,9 @@ flash_init_data_default(void)
|
|||
// Dangerous, here are dinosaur infested!!!!!
|
||||
// Reboot required!!!
|
||||
// It will init system data to default!
|
||||
uint8_t flash_init_data[128] __attribute__((aligned(4))) =
|
||||
{
|
||||
0x05, 0x00, 0x04, 0x02, 0x05, 0x05, 0x05, 0x02, 0x05, 0x00, 0x04, 0x05, 0x05, 0x04, 0x05, 0x05,
|
||||
0x04, 0xFE, 0xFD, 0xFF, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0, 0xE1, 0x0A, 0xFF, 0xFF, 0xF8, 0x00,
|
||||
0xF8, 0xF8, 0x52, 0x4E, 0x4A, 0x44, 0x40, 0x38, 0x00, 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x05,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xE1, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x93, 0x43, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
SPIEraseSector((flash_get_sec_num() - 4));
|
||||
SPIWrite((flash_get_sec_num() - 4) * SPI_FLASH_SEC_SIZE, flash_init_data, sizeof(flash_init_data));
|
||||
SPIWrite((flash_get_sec_num() - 4) * SPI_FLASH_SEC_SIZE, 0x10000 - SPI_FLASH_SEC_SIZE + (0), 128);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define __FLASH_API_H__
|
||||
#include "ets_sys.h"
|
||||
#include "user_config.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t unknown0;
|
||||
|
@ -28,7 +29,7 @@ typedef struct
|
|||
SIZE_16MBIT = 3,
|
||||
SIZE_32MBIT = 4,
|
||||
} size : 4;
|
||||
} NODE_STORE_ATTR SPIFlashInfo;
|
||||
} NODE_STORE_TYPEDEF_ATTR SPIFlashInfo;
|
||||
|
||||
SPIFlashInfo *flash_get_info(void);
|
||||
uint8_t flash_get_size(void);
|
||||
|
|
Loading…
Reference in New Issue