From 46559496c610d09bd393d099486ebf6c33e7c294 Mon Sep 17 00:00:00 2001 From: Our Air Quality Date: Wed, 25 Apr 2018 23:03:31 +1000 Subject: [PATCH] Recognise some new flash size codes. This at least recognises the 2MB-c1, 4MB-c1, 8MB, and 16MB flash size codes. --- core/app_main.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/core/app_main.c b/core/app_main.c index 8b27f94..f854dce 100644 --- a/core/app_main.c +++ b/core/app_main.c @@ -174,25 +174,32 @@ void IRAM sdk_user_start(void) { } switch (buf8[3] >> 4) { case 0x0: // 4 Mbit (512 KByte) - flash_sectors = 128; + flash_size = 524288; break; case 0x1: // 2 Mbit (256 Kbyte) - flash_sectors = 64; + flash_size = 262144; break; case 0x2: // 8 Mbit (1 Mbyte) - flash_sectors = 256; + flash_size = 1048576; break; case 0x3: // 16 Mbit (2 Mbyte) - flash_sectors = 512; + case 0x5: // 16 Mbit (2 Mbyte) + flash_size = 2097152; break; case 0x4: // 32 Mbit (4 Mbyte) - flash_sectors = 1024; + case 0x6: // 32 Mbit (4 Mbyte) + flash_size = 4194304; + break; + case 0x8: // 64 Mbit (8 Mbyte) + flash_size = 8388608; + break; + case 0x9: // 128 Mbit (16 Mbyte) + flash_size = 16777216; break; default: // Invalid -- Assume 4 Mbit (512 KByte) - flash_sectors = 128; + flash_size = 524288; } - //FIXME: we should probably calculate flash_sectors by starting with flash_size and dividing by sdk_flashchip.sector_size instead of vice-versa. - flash_size = flash_sectors * 4096; + flash_sectors = flash_size / sdk_flashchip.sector_size; sdk_flashchip.chip_size = flash_size; set_spi0_divisor(flash_speed_divisor); sdk_SPIRead(flash_size - 4096, buf32, BOOT_INFO_SIZE);