esp8266 / esp8266/Arduino

Flash-size agnostic mode, problem with spi_flash_* functions

Open
#9,027 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
16.7k
Forks
13.1k
PR merge metrics
No merged PRs in 30d

Description

### Basic Infos

- [x] This issue complies with the [issue POLICY doc](https://github.com/esp8266/Arduino/blob/master/POLICY.md).
- [x] I have read the documentation at [readthedocs](https://arduino-esp8266.readthedocs.io/en/latest) and the issue is not addressed there.
- [x] I have tested that the issue is present in current master branch (aka latest git).
- [x] I have searched the issue tracker for a similar issue.
- [x] If there is a stack dump, I have decoded it.
- [x] I have filled out all fields below.

#### Platform

- Hardware: [ESP-12|ESP-07]
- Core Version: [Core:3.1.2]
- Development Env: [Platformio]
- Operating System: [Windows]

### Settings in IDE

- Module: [Generic ESP8266 Module]
- Flash Mode: [dout]
- Flash Size: [1MB]
- Upload Using: [SERIAL/OTA]

### Problem Description

I'm trying to make "Flash-size agnostic build". Firmware still depends on selected ldscript flash size in SDK functions spi_flash_*. FS not working if firmware was build with ldscript flash size less than actual.

Steps to reproduce:
1. Add to sketch: FLASH_MAP_SETUP_CONFIG(FLASH_MAP_OTA)
2. Set -DFLASH_MAP_SUPPORT=1
3. Build firmware for 1M board (i.e. ESP07). Or set board_build.ldscript = eagle.flash.1m128.ld (or anything less than 4M). Or eagle.flash.auto.ld (if boards default flash size is 1M)
4. Upload to any 4M board
5. Everything works (OTA/Arduino updates, except for FS. Can't mount, can't format.

```cpp
DEBUGV("Chip size %d\n", flashchip->chip_size);
DEBUGV("Real Chip size %d\n", ESP.getFlashChipRealSize());
```

```
Chip size 1048576
Real Chip size 4194304
```

Problem: incorrect value in flashchip->chip_size is used by spi_flash_* functions for bounds checking. Flash read above 1M fails.

Possible fix:
flashchip->chip_size = ESP.getFlashChipRealSize();
(somewhere in the code)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.