Browse Source

Add default implementation of user_rf_cal_sector_set() callback.

Suddenly introduced in SDK 1.5.4+patch/SDK 2.0.0, another callback most
users won't care about. Vendor's description is: "Set the target flash
sector to store RF_CAL parameters. The system parameter area (4 flash
sectors) has already been used, so the RF_CAL parameters will be stored
in the target sector set by user_rf_cal_sector_set." It's a mystery how
all the previous SDK version worked without a need to store this info
in flash (actually, that was one of the "selling points" of ESP8266,
setting it aside from all other chips which had RF calibration in flash),
and 2.0.0 suddenly decided to do it.

So, make this default user_rf_cal_sector_set() implementation return
flash_sectors - 5, so the last 20KB/5 sectors of flash should be
reserved for systems needs (vs 16KB/4 sectors in previous SDKs).
Paul Sokolovsky 8 năm trước cách đây
mục cha
commit
e629109c76
2 tập tin đã thay đổi với 16 bổ sung1 xóa
  1. 5 1
      Makefile
  2. 11 0
      user_rf_cal_sector_set.c

+ 5 - 1
Makefile

@@ -184,10 +184,11 @@ $(VENDOR_SDK_DIR_1.5.4)/.dir: $(VENDOR_SDK_ZIP_1.5.4)
 
 sdk_patch: $(VENDOR_SDK_DIR)/.dir .sdk_patch_$(VENDOR_SDK)
 
-.sdk_patch_2.0.0:
+.sdk_patch_2.0.0: user_rf_cal_sector_set.o
 	echo -e "#undef ESP_SDK_VERSION\n#define ESP_SDK_VERSION 020000" >>$(VENDOR_SDK_DIR)/include/esp_sdk_ver.h
 	$(PATCH) -d $(VENDOR_SDK_DIR) -p1 < c_types-c99_sdk_2.patch
 	cd $(VENDOR_SDK_DIR)/lib; mkdir -p tmp; cd tmp; $(TOOLCHAIN)/bin/xtensa-lx106-elf-ar x ../libcrypto.a; cd ..; $(TOOLCHAIN)/bin/xtensa-lx106-elf-ar rs libwpa.a tmp/*.o
+	$(TOOLCHAIN)/bin/xtensa-lx106-elf-ar r $(VENDOR_SDK_DIR)/lib/libmain.a user_rf_cal_sector_set.o
 	@touch $@
 
 .sdk_patch_1.5.4:
@@ -320,6 +321,9 @@ sdk_patch: $(VENDOR_SDK_DIR)/.dir .sdk_patch_$(VENDOR_SDK)
 empty_user_rf_pre_init.o: empty_user_rf_pre_init.c $(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc
 	$(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc -O2 -c $<
 
+user_rf_cal_sector_set.o: user_rf_cal_sector_set.c $(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc
+	$(TOOLCHAIN)/bin/xtensa-lx106-elf-gcc -O2 -c $<
+
 lwip: toolchain sdk_patch
 ifeq ($(STANDALONE),y)
 	make -C esp-open-lwip -f Makefile.open install \

+ 11 - 0
user_rf_cal_sector_set.c

@@ -0,0 +1,11 @@
+#include <c_types.h>
+#include <spi_flash.h>
+
+uint32 user_rf_cal_sector_set(void) {
+    extern char flashchip;
+    SpiFlashChip *flash = (SpiFlashChip*)(&flashchip + 4);
+    // We know that sector size in 4096
+    //uint32_t sec_num = flash->chip_size / flash->sector_size;
+    uint32_t sec_num = flash->chip_size >> 12;
+    return sec_num - 5;
+}