Browse Source

Emergency update, fix flash size auto detection bug.
64Mbit and 128Mbit supported by hardware, but not supported by this SDK 0.9.5. Waiting SDK update.

HuangRui 9 years ago
parent
commit
0232c13b83
2 changed files with 12 additions and 1 deletions
  1. 11 1
      app/platform/flash_api.c
  2. 1 0
      app/platform/flash_api.h

+ 11 - 1
app/platform/flash_api.c

@@ -57,9 +57,11 @@ uint32_t flash_get_size_byte(void)
     case SIZE_32MBIT:
         // 32Mbit, 4MByte
         flash_size = 4 * 1024 * 1024;
+        break;
     case SIZE_64MBIT:
         // 64Mbit, 8MByte
         flash_size = 8 * 1024 * 1024;
+        break;
     case SIZE_128MBIT:
         // 128Mbit, 16MByte
         flash_size = 16 * 1024 * 1024;
@@ -132,7 +134,15 @@ bool flash_set_size_byte(uint32_t size)
 
 uint16_t flash_get_sec_num(void)
 {
-    return flash_get_size_byte() / SPI_FLASH_SEC_SIZE;
+    //static uint16_t sec_num = 0;
+    // return flash_get_size_byte() / (SPI_FLASH_SEC_SIZE);
+    // c_printf("\nflash_get_size_byte()=%d\n", ( flash_get_size_byte() / (SPI_FLASH_SEC_SIZE) ));
+    // if( sec_num == 0 )
+    //{
+    //    sec_num = 4 * 1024 * 1024 / (SPI_FLASH_SEC_SIZE);
+    //}
+    //return sec_num;
+    return ( flash_get_size_byte() / (SPI_FLASH_SEC_SIZE) );
 }
 
 uint8_t flash_get_mode(void)

+ 1 - 0
app/platform/flash_api.h

@@ -3,6 +3,7 @@
 #include "ets_sys.h"
 #include "user_config.h"
 #include "cpu_esp8266.h"
+
 #define FLASH_MAP_START_ADDRESS (INTERNAL_FLASH_START_ADDRESS)
 
 /******************************************************************************