Merge pull request #550 from hmueller01/fix-#546

Fix #546 to compile with different SDKs
This commit is contained in:
martin-ger
2025-02-08 10:32:28 +01:00
committed by GitHub
6 changed files with 106 additions and 155 deletions
+4 -3
View File
@@ -66,7 +66,6 @@ SDK_INCDIR = include include/json
# these are the names and options to generate them
FW_FILE_1_ADDR = 0x02000
FW_FILE_2_ADDR = 0x82000
FW_FILE_ESP_INIT_ADDR = 0x3FC000
# select which tools to use as compiler, librarian and linker
CC := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
@@ -98,7 +97,6 @@ MODULE_INCDIR := $(addsuffix /include,$(INCDIR))
FW_FILE_1 := $(addprefix $(FW_BASE)/,$(FW_FILE_1_ADDR).bin)
FW_FILE_2 := $(addprefix $(FW_BASE)/,$(FW_FILE_2_ADDR).bin)
FW_FILE_ESP_INIT := $(SDK_BASE)/bin/esp_init_data_default_v08_vdd33.bin
RBOOT_FILE := $(addprefix $(FW_BASE)/,0x00000.bin)
V ?= $(VERBOSE)
@@ -160,7 +158,7 @@ $(FW_BASE):
$(Q) mkdir -p $@
flash: $(FW_BASE)/sha1sums
$(ESPTOOL) --port $(ESPPORT) --baud $(ESPTOOLBAUD) write_flash $(ESPTOOLOPTS) 0x00000 $(RBOOT_FILE) $(FW_FILE_1_ADDR) $(FW_FILE_1) $(FW_FILE_2_ADDR) $(FW_FILE_2) $(FW_FILE_ESP_INIT_ADDR) $(FW_FILE_ESP_INIT)
$(ESPTOOL) --port $(ESPPORT) --baud $(ESPTOOLBAUD) write_flash $(ESPTOOLOPTS) 0x00000 $(RBOOT_FILE) $(FW_FILE_1_ADDR) $(FW_FILE_1) $(FW_FILE_2_ADDR) $(FW_FILE_2)
flash0: $(FW_BASE)/sha1sums
$(ESPTOOL) --port $(ESPPORT) --baud $(ESPTOOLBAUD) write_flash $(ESPTOOLOPTS) $(FW_FILE_1_ADDR) $(FW_FILE_1)
@@ -171,6 +169,9 @@ flash1: $(FW_BASE)/sha1sums
flashboth: $(FW_BASE)/sha1sums
$(ESPTOOL) --port $(ESPPORT) --baud $(ESPTOOLBAUD) write_flash $(ESPTOOLOPTS) $(FW_FILE_1_ADDR) $(FW_FILE_1) $(FW_FILE_2_ADDR) $(FW_FILE_2)
flasherase: $(FW_BASE)/sha1sums
$(ESPTOOL) --port $(ESPPORT) --baud $(ESPTOOLBAUD) erase_flash
clean:
$(Q) rm -rf $(FW_BASE) $(BUILD_BASE)
$(Q) find . -name "*~" -print0 | xargs -0 rm -rf
Binary file not shown.
Binary file not shown.
+2 -2
View File
@@ -1,3 +1,3 @@
daf262de48406b4badc2d40de6587b3103c5789c firmware/0x02000.bin
174849a68536e8071f58d65e71368e1e511382bb firmware/0x82000.bin
328b8dcff7cca18c63b01a11b079ca62529d5cbc firmware/0x02000.bin
20d9a4001a755ad702bbc9996a17afebaa96eeed firmware/0x82000.bin
9bd7d25204d71b3db5f35e0b2def8a6aaa7f765c firmware/0x00000.bin
+96 -147
View File
@@ -1,3 +1,4 @@
#include "version.h"
#include "user_interface.h"
#include "lwip/ip.h"
#include "lwip/lwip_napt.h"
@@ -25,21 +26,21 @@ uint32_t reg0, reg1, reg3;
reg3 = *(uint32*)(0x3ff0005c);
if (reg3 != 0) {
mac[0] = (reg3 >> 16) & 0xff;
mac[1] = (reg3 >> 8) & 0xff;
mac[2] = reg3 & 0xff;
mac[0] = (reg3 >> 16) & 0xff;
mac[1] = (reg3 >> 8) & 0xff;
mac[2] = reg3 & 0xff;
} else
if (((reg1 >> 16) & 0xff) == 0) {
mac[0] = 0x18;
mac[1] = 0xfe;
mac[2] = 0x34;
mac[0] = 0x18;
mac[1] = 0xfe;
mac[2] = 0x34;
} else
if (((reg1 >> 16) & 0xff) == 1) {
mac[0] = 0xac;
mac[1] = 0xd0;
mac[2] = 0x74;
mac[0] = 0xac;
mac[1] = 0xd0;
mac[2] = 0x74;
} else {
os_printf("MAC read error\r\n");
os_printf("MAC read error\r\n");
}
mac[3] = (reg1 >> 8) & 0xff;
@@ -200,7 +201,7 @@ int ICACHE_FLASH_ATTR config_load(sysconfig_p config)
os_printf("Length Mismatch (should be %d), probably old version of config, loading defaults\r\n", sizeof(sysconfig_t));
config_load_default(config);
config_save(config);
return -1;
return -1;
}
ip_route_max = config->no_routes;
@@ -243,7 +244,7 @@ void ICACHE_FLASH_ATTR blob_load(uint8_t blob_no, uint32_t *data, uint16_t len)
void ICACHE_FLASH_ATTR blob_zero(uint8_t blob_no, uint16_t len)
{
int i;
int i;
uint8_t z[len];
os_memset(z, 0,len);
uint16_t base_address = FLASH_BLOCK_NO + 1 + blob_no;
@@ -251,6 +252,44 @@ int i;
spi_flash_write(base_address * SPI_FLASH_SEC_SIZE, (uint32_t *)z, len);
}
// For versions ESP8266_NONOS_SDK v1.5.2 to v2.2.1, user_rf_cal_sector_set() need to be added.
// Docker SDK comes with a user_rf_cal_sector_set() in libmain.a, needed for official SDKs.
#if USER_RF_CAL
uint32 ICACHE_FLASH_ATTR user_rf_cal_sector_set(void)
{
enum flash_size_map size_map = system_get_flash_size_map();
uint32 rf_cal_sec = 0;
switch (size_map)
{
case FLASH_SIZE_4M_MAP_256_256:
rf_cal_sec = 128 - 5;
break;
case FLASH_SIZE_8M_MAP_512_512:
rf_cal_sec = 256 - 5;
break;
case FLASH_SIZE_16M_MAP_512_512:
case FLASH_SIZE_16M_MAP_1024_1024:
rf_cal_sec = 512 - 5;
break;
case FLASH_SIZE_32M_MAP_512_512:
case FLASH_SIZE_32M_MAP_1024_1024:
rf_cal_sec = 1024 - 5;
break;
case FLASH_SIZE_64M_MAP_1024_1024:
rf_cal_sec = 2048 - 5;
break;
case FLASH_SIZE_128M_MAP_1024_1024:
rf_cal_sec = 4096 - 5;
break;
default:
rf_cal_sec = 0;
break;
}
return rf_cal_sec;
}
#endif
const uint8_t esp_init_data_default[] = {
"\x05\x08\x04\x02\x05\x05\x05\x02\x05\x00\x04\x05\x05\x04\x05\x05"
"\x04\xFE\xFD\xFF\xF0\xF0\xF0\xE0\xE0\xE0\xE1\x0A\xFF\xFF\xF8\x00"
@@ -261,57 +300,40 @@ const uint8_t esp_init_data_default[] = {
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xFF\x00\x00\x00\x00"
"\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"};
void user_rf_pre_init() {
uint8_t esp_init_data_current[sizeof(esp_init_data_default)];
void user_rf_pre_init()
{
uint8_t esp_init_data_current[sizeof(esp_init_data_default)];
enum flash_size_map size_map = system_get_flash_size_map();
uint32 rf_cal_sec = 0, addr, i;
enum flash_size_map size_map = system_get_flash_size_map();
uint32 rf_cal_sec = 0, addr, i;
//os_printf("\nUser preinit: ");
switch (size_map) {
case FLASH_SIZE_4M_MAP_256_256:
rf_cal_sec = 128 - 5;
break;
rf_cal_sec = user_rf_cal_sector_set();
addr = ((rf_cal_sec)*SPI_FLASH_SEC_SIZE) + SPI_FLASH_SEC_SIZE;
spi_flash_read(addr, (uint32_t *)esp_init_data_current, sizeof(esp_init_data_current));
case FLASH_SIZE_8M_MAP_512_512:
rf_cal_sec = 256 - 5;
break;
for (i = 0; i < sizeof(esp_init_data_default); i++)
{
if (esp_init_data_current[i] != esp_init_data_default[i])
{
spi_flash_erase_sector(rf_cal_sec);
spi_flash_erase_sector(rf_cal_sec + 1);
spi_flash_erase_sector(rf_cal_sec + 2);
addr = ((rf_cal_sec)*SPI_FLASH_SEC_SIZE) + SPI_FLASH_SEC_SIZE;
os_printf("Writing rfcal init data @0x%08X\n", addr);
spi_flash_write(addr, (uint32 *)esp_init_data_default, sizeof(esp_init_data_default));
case FLASH_SIZE_16M_MAP_512_512:
case FLASH_SIZE_16M_MAP_1024_1024:
rf_cal_sec = 512 - 5;
break;
case FLASH_SIZE_32M_MAP_512_512:
case FLASH_SIZE_32M_MAP_1024_1024:
rf_cal_sec = 1024 - 5;
break;
default:
rf_cal_sec = 0;
break;
}
addr = ((rf_cal_sec) * SPI_FLASH_SEC_SIZE)+SPI_FLASH_SEC_SIZE;
spi_flash_read(addr, (uint32_t *)esp_init_data_current, sizeof(esp_init_data_current));
for (i=0; i<sizeof(esp_init_data_default); i++) {
if (esp_init_data_current[i] != esp_init_data_default[i]) {
spi_flash_erase_sector(rf_cal_sec);
spi_flash_erase_sector(rf_cal_sec+1);
spi_flash_erase_sector(rf_cal_sec+2);
addr = ((rf_cal_sec) * SPI_FLASH_SEC_SIZE)+SPI_FLASH_SEC_SIZE;
os_printf("Storing rfcal init data @ address=0x%08X\n", addr);
spi_flash_write(addr, (uint32 *)esp_init_data_default, sizeof(esp_init_data_default));
break;
break;
}
/*
else
{
os_printf("RF data[%u] is ok\n", i);
}
*/
}
/* else {
os_printf("RF data[%u] is ok\n", i);
}*/
}
}
/*
#if ESP_SDK_VERSION_NUMBER >= 0x030000
// user_pre_init is required from SDK v3.0.0 onwards
// It is used to register the parition map with the SDK, primarily to allow
// the app to use the SDK's OTA capability. We don't make use of that in
@@ -322,105 +344,32 @@ void user_rf_pre_init() {
// The location and length of these are from the 2A SDK getting started guide
void ICACHE_FLASH_ATTR user_pre_init(void)
{
bool rc = false;
static const partition_item_t part_table[] =
{
{SYSTEM_PARTITION_RF_CAL,
0x3fb000,
0x1000},
{SYSTEM_PARTITION_PHY_DATA,
0x3fc000,
0x1000},
{SYSTEM_PARTITION_SYSTEM_PARAMETER,
0x3fd000,
0x3000},
};
/*
enum flash_size_map size_map = system_get_flash_size_map();
uint32 rf_cal_sec = 0, addr, i;
//os_printf("\nUser preinit: ");
switch (size_map) {
case FLASH_SIZE_4M_MAP_256_256:
rf_cal_sec = 128 - 5;
break;
case FLASH_SIZE_8M_MAP_512_512:
rf_cal_sec = 256 - 5;
break;
case FLASH_SIZE_16M_MAP_512_512:
case FLASH_SIZE_16M_MAP_1024_1024:
rf_cal_sec = 512 - 5;
break;
case FLASH_SIZE_32M_MAP_512_512:
case FLASH_SIZE_32M_MAP_1024_1024:
rf_cal_sec = 1024 - 5;
break;
default:
rf_cal_sec = 0;
break;
}
bool rc = false;
static const partition_item_t part_table[] =
{
{SYSTEM_PARTITION_RF_CAL,
rf_cal_sec * 0x1000,
0x3fb000,
0x1000},
{SYSTEM_PARTITION_PHY_DATA,
(rf_cal_sec + 1) * 0x1000,
0x3fc000,
0x1000},
{SYSTEM_PARTITION_SYSTEM_PARAMETER,
(rf_cal_sec + 2) * 0x1000,
0x3fd000,
0x3000},
};
// This isn't an ideal approach but there's not much point moving on unless
// or until this has succeeded cos otherwise the SDK will just barf and
// refuse to call user_init()
while (!rc)
{
rc = system_partition_table_regist(part_table,
sizeof(part_table)/sizeof(part_table[0]),
4);
}
return;
}
*/
#if NO_RF_CAL
uint32 ICACHE_FLASH_ATTR user_rf_cal_sector_set(void)
{
enum flash_size_map size_map = system_get_flash_size_map();
uint32 rf_cal_sec = 0;
switch (size_map) {
case FLASH_SIZE_4M_MAP_256_256:
rf_cal_sec = 128 - 5;
break;
case FLASH_SIZE_8M_MAP_512_512:
rf_cal_sec = 256 - 5;
break;
case FLASH_SIZE_16M_MAP_512_512:
case FLASH_SIZE_16M_MAP_1024_1024:
rf_cal_sec = 512 - 5;
break;
case FLASH_SIZE_32M_MAP_512_512:
case FLASH_SIZE_32M_MAP_1024_1024:
rf_cal_sec = 1024 - 5;
break;
case FLASH_SIZE_64M_MAP_1024_1024:
rf_cal_sec = 2048 - 5;
break;
case FLASH_SIZE_128M_MAP_1024_1024:
rf_cal_sec = 4096 - 5;
break;
default:
rf_cal_sec = 0;
break;
// This isn't an ideal approach but there's not much point moving on unless
// or until this has succeeded cos otherwise the SDK will just barf and
// refuse to call user_init()
while (!rc)
{
rc = system_partition_table_regist(part_table,
sizeof(part_table) / sizeof(part_table[0]), 4);
}
return rf_cal_sec;
// check and update esp_init_data
user_rf_pre_init();
return;
}
#endif
+4 -3
View File
@@ -1,7 +1,7 @@
#ifndef _USER_CONFIG_
#define _USER_CONFIG_
#define ESP_REPEATER_VERSION "V2.2.16"
#define ESP_REPEATER_VERSION "V2.2.17"
#define LOCAL_ACCESS 0x01
#define REMOTE_ACCESS 0x02
@@ -16,9 +16,10 @@
#define MAX_DHCP 8
//
// Set this to 1 if user_rf_cal_sector_set() is missing in your lib
// Docker SDK comes with a user_rf_cal_sector_set() in libmain.a.
// Define this to 1 if you use an official SDK (and need the user_rf_cal_sector_set() here)
//
#define NO_RF_CAL 0
#define USER_RF_CAL 0
//
// Size of the console buffers