Updated to latest IDF.
WiFi STA module updated to reflect IDF name changes. Platform flash and partition api updated to reflect IDF name changes. Eventually these (and the SPIFFS module) will likely need to be updated to exclusively work with the esp_partition_xxx() functions in order to support working with encrypted flash.
This commit is contained in:
parent
e160eaf938
commit
5c1bb4c6d6
|
@ -179,10 +179,10 @@ static void on_scan_done (const system_event_t *evt)
|
||||||
if (!lua_isnoneornil (L, -1))
|
if (!lua_isnoneornil (L, -1))
|
||||||
{
|
{
|
||||||
uint16_t num_ap = 0;
|
uint16_t num_ap = 0;
|
||||||
esp_err_t err = esp_wifi_get_ap_num (&num_ap);
|
esp_err_t err = esp_wifi_scan_get_ap_num (&num_ap);
|
||||||
wifi_ap_list_t *aps = luaM_malloc (L, num_ap * sizeof (wifi_ap_list_t));
|
wifi_ap_record_t *aps = luaM_malloc (L, num_ap * sizeof (wifi_ap_record_t));
|
||||||
if ((err == ESP_OK) && (aps) &&
|
if ((err == ESP_OK) && (aps) &&
|
||||||
(err = esp_wifi_get_ap_list (&num_ap, aps)) == ESP_OK)
|
(err = esp_wifi_scan_get_ap_records (&num_ap, aps)) == ESP_OK)
|
||||||
{
|
{
|
||||||
lua_pushnil (L); // no error
|
lua_pushnil (L); // no error
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,13 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "rom/spi_flash.h"
|
#include "rom/spi_flash.h"
|
||||||
|
|
||||||
#include "../../bootloader/src/main/bootloader_config.h"
|
#include "esp_flash_data_types.h"
|
||||||
|
|
||||||
#define FLASH_HDR_ADDR 0x1000
|
#define FLASH_HDR_ADDR 0x1000
|
||||||
|
|
||||||
static inline struct flash_hdr flash_load_rom_header (void)
|
static inline esp_image_header_t flash_load_rom_header (void)
|
||||||
{
|
{
|
||||||
struct flash_hdr hdr;
|
esp_image_header_t hdr;
|
||||||
if (ESP_OK !=
|
if (ESP_OK !=
|
||||||
spi_flash_read (FLASH_HDR_ADDR, (uint32_t *)&hdr, sizeof (hdr)))
|
spi_flash_read (FLASH_HDR_ADDR, (uint32_t *)&hdr, sizeof (hdr)))
|
||||||
{
|
{
|
||||||
|
@ -79,11 +79,11 @@ uint32_t flash_rom_get_size_byte(void)
|
||||||
switch (flash_load_rom_header ().spi_size)
|
switch (flash_load_rom_header ().spi_size)
|
||||||
{
|
{
|
||||||
default: // Unknown flash size, fall back mode.
|
default: // Unknown flash size, fall back mode.
|
||||||
case SPI_SIZE_1MB: flash_size = FLASH_SIZE_1MBYTE; break;
|
case ESP_IMAGE_FLASH_SIZE_1MB: flash_size = FLASH_SIZE_1MBYTE; break;
|
||||||
case SPI_SIZE_2MB: flash_size = FLASH_SIZE_2MBYTE; break;
|
case ESP_IMAGE_FLASH_SIZE_2MB: flash_size = FLASH_SIZE_2MBYTE; break;
|
||||||
case SPI_SIZE_4MB: flash_size = FLASH_SIZE_4MBYTE; break;
|
case ESP_IMAGE_FLASH_SIZE_4MB: flash_size = FLASH_SIZE_4MBYTE; break;
|
||||||
case SPI_SIZE_8MB: flash_size = FLASH_SIZE_8MBYTE; break;
|
case ESP_IMAGE_FLASH_SIZE_8MB: flash_size = FLASH_SIZE_8MBYTE; break;
|
||||||
case SPI_SIZE_16MB: flash_size = FLASH_SIZE_16MBYTE; break;
|
case ESP_IMAGE_FLASH_SIZE_16MB: flash_size = FLASH_SIZE_16MBYTE; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return flash_size;
|
return flash_size;
|
||||||
|
@ -95,7 +95,7 @@ static bool flash_rom_set_size_type(uint8_t size_code)
|
||||||
// Reboot required!!!
|
// Reboot required!!!
|
||||||
// If you don't know what you're doing, your nodemcu may turn into stone ...
|
// If you don't know what you're doing, your nodemcu may turn into stone ...
|
||||||
NODE_DBG("\nBEGIN SET FLASH HEADER\n");
|
NODE_DBG("\nBEGIN SET FLASH HEADER\n");
|
||||||
struct flash_hdr *hdr = (struct flash_hdr *)malloc (SPI_FLASH_SEC_SIZE);
|
esp_image_header_t *hdr = (esp_image_header_t *)malloc (SPI_FLASH_SEC_SIZE);
|
||||||
if (!hdr)
|
if (!hdr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -125,11 +125,11 @@ bool flash_rom_set_size_byte(uint32_t size)
|
||||||
uint8_t size_code = 0;
|
uint8_t size_code = 0;
|
||||||
switch (size)
|
switch (size)
|
||||||
{
|
{
|
||||||
case FLASH_SIZE_1MBYTE: size_code = SPI_SIZE_1MB; break;
|
case FLASH_SIZE_1MBYTE: size_code = ESP_IMAGE_FLASH_SIZE_1MB; break;
|
||||||
case FLASH_SIZE_2MBYTE: size_code = SPI_SIZE_2MB; break;
|
case FLASH_SIZE_2MBYTE: size_code = ESP_IMAGE_FLASH_SIZE_2MB; break;
|
||||||
case FLASH_SIZE_4MBYTE: size_code = SPI_SIZE_4MB; break;
|
case FLASH_SIZE_4MBYTE: size_code = ESP_IMAGE_FLASH_SIZE_4MB; break;
|
||||||
case FLASH_SIZE_8MBYTE: size_code = SPI_SIZE_8MB; break;
|
case FLASH_SIZE_8MBYTE: size_code = ESP_IMAGE_FLASH_SIZE_8MB; break;
|
||||||
case FLASH_SIZE_16MBYTE: size_code = SPI_SIZE_16MB; break;
|
case FLASH_SIZE_16MBYTE: size_code = ESP_IMAGE_FLASH_SIZE_16MB; break;
|
||||||
default: ok = false; break;
|
default: ok = false; break;
|
||||||
}
|
}
|
||||||
if (ok)
|
if (ok)
|
||||||
|
@ -154,10 +154,10 @@ uint32_t flash_rom_get_speed(void)
|
||||||
{
|
{
|
||||||
switch (flash_load_rom_header ().spi_speed)
|
switch (flash_load_rom_header ().spi_speed)
|
||||||
{
|
{
|
||||||
case SPI_SPEED_40M: return 40000000;
|
case ESP_IMAGE_SPI_SPEED_40M: return 40000000;
|
||||||
case SPI_SPEED_26M: return 26700000; // TODO: verify 26.7MHz
|
case ESP_IMAGE_SPI_SPEED_26M: return 26700000; // TODO: verify 26.7MHz
|
||||||
case SPI_SPEED_20M: return 20000000;
|
case ESP_IMAGE_SPI_SPEED_20M: return 20000000;
|
||||||
case SPI_SPEED_80M: return 80000000;
|
case ESP_IMAGE_SPI_SPEED_80M: return 80000000;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -35,12 +35,12 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "../../bootloader/src/main/bootloader_config.h"
|
#include "esp_flash_data_types.h"
|
||||||
#include "esp_spi_flash.h"
|
#include "esp_spi_flash.h"
|
||||||
|
|
||||||
static inline bool possible_idx (uint8_t idx)
|
static inline bool possible_idx (uint8_t idx)
|
||||||
{
|
{
|
||||||
return ((idx +1) * sizeof (partition_info_t)) < SPI_FLASH_SEC_SIZE;
|
return ((idx +1) * sizeof (esp_partition_info_t)) < SPI_FLASH_SEC_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,13 +49,13 @@ bool platform_partition_info (uint8_t idx, platform_partition_t *info)
|
||||||
if (!possible_idx (idx))
|
if (!possible_idx (idx))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
partition_info_t pi;
|
esp_partition_info_t pi;
|
||||||
esp_err_t err = spi_flash_read (
|
esp_err_t err = spi_flash_read (
|
||||||
PARTITION_ADD + idx * sizeof(pi), (uint32_t *)&pi, sizeof (pi));
|
ESP_PARTITION_TABLE_ADDR + idx * sizeof(pi), (uint32_t *)&pi, sizeof (pi));
|
||||||
if (err != ESP_OK)
|
if (err != ESP_OK)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (pi.magic != PARTITION_MAGIC)
|
if (pi.magic != ESP_PARTITION_MAGIC)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
memcpy (info->label, pi.label, sizeof (info->label));
|
memcpy (info->label, pi.label, sizeof (info->label));
|
||||||
|
@ -70,33 +70,35 @@ bool platform_partition_info (uint8_t idx, platform_partition_t *info)
|
||||||
|
|
||||||
bool platform_partition_add (const platform_partition_t *info)
|
bool platform_partition_add (const platform_partition_t *info)
|
||||||
{
|
{
|
||||||
partition_info_t *part_table = (partition_info_t *)malloc(SPI_FLASH_SEC_SIZE);
|
esp_partition_info_t *part_table =
|
||||||
|
(esp_partition_info_t *)malloc(SPI_FLASH_SEC_SIZE);
|
||||||
if (!part_table)
|
if (!part_table)
|
||||||
return false;
|
return false;
|
||||||
esp_err_t err =
|
esp_err_t err = spi_flash_read (
|
||||||
spi_flash_read (PARTITION_ADD, (uint32_t *)part_table, SPI_FLASH_SEC_SIZE);
|
ESP_PARTITION_TABLE_ADDR, (uint32_t *)part_table, SPI_FLASH_SEC_SIZE);
|
||||||
if (err != ESP_OK)
|
if (err != ESP_OK)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
uint8_t idx = 0;
|
uint8_t idx = 0;
|
||||||
for (; possible_idx (idx); ++idx)
|
for (; possible_idx (idx); ++idx)
|
||||||
if (part_table[idx].magic != PARTITION_MAGIC)
|
if (part_table[idx].magic != ESP_PARTITION_MAGIC)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (possible_idx (idx))
|
if (possible_idx (idx))
|
||||||
{
|
{
|
||||||
partition_info_t *slot = &part_table[idx];
|
esp_partition_info_t *slot = &part_table[idx];
|
||||||
slot->magic = PARTITION_MAGIC;
|
slot->magic = ESP_PARTITION_MAGIC;
|
||||||
slot->type = info->type;
|
slot->type = info->type;
|
||||||
slot->subtype = info->subtype;
|
slot->subtype = info->subtype;
|
||||||
slot->pos.offset = info->offs;
|
slot->pos.offset = info->offs;
|
||||||
slot->pos.size = info->size;
|
slot->pos.size = info->size;
|
||||||
memcpy (slot->label, info->label, sizeof (slot->label));
|
memcpy (slot->label, info->label, sizeof (slot->label));
|
||||||
memset (slot->reserved, 0xff, sizeof (slot->reserved));
|
memset (slot->reserved, 0xff, sizeof (slot->reserved));
|
||||||
err = spi_flash_erase_sector (PARTITION_ADD / SPI_FLASH_SEC_SIZE);
|
err = spi_flash_erase_sector (
|
||||||
|
ESP_PARTITION_TABLE_ADDR / SPI_FLASH_SEC_SIZE);
|
||||||
if (err == ESP_OK)
|
if (err == ESP_OK)
|
||||||
err = spi_flash_write (
|
err = spi_flash_write (
|
||||||
PARTITION_ADD, (uint32_t *)part_table, SPI_FLASH_SEC_SIZE);
|
ESP_PARTITION_TABLE_ADDR, (uint32_t *)part_table, SPI_FLASH_SEC_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 12caaed28063e32d8b1fb13e13548b6fa52f87b3
|
Subproject commit eb067ce90827a31a1b01eac531767a17c55048c1
|
Loading…
Reference in New Issue