stm32/flash: Add flash_is_valid_addr, and extend sectors for 2MB F7.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
4c8a68df6f
commit
736daebfc8
@ -70,10 +70,15 @@ static const flash_layout_t flash_layout[] = {
|
|||||||
{ 0x08020000, 0x20000, 3 },
|
{ 0x08020000, 0x20000, 3 },
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
|
// This is for dual-bank mode disabled
|
||||||
static const flash_layout_t flash_layout[] = {
|
static const flash_layout_t flash_layout[] = {
|
||||||
{ 0x08000000, 0x08000, 4 },
|
{ 0x08000000, 0x08000, 4 },
|
||||||
{ 0x08020000, 0x20000, 1 },
|
{ 0x08020000, 0x20000, 1 },
|
||||||
|
#if FLASH_SECTOR_TOTAL == 8
|
||||||
{ 0x08040000, 0x40000, 3 },
|
{ 0x08040000, 0x40000, 3 },
|
||||||
|
#else
|
||||||
|
{ 0x08040000, 0x40000, 7 },
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -139,6 +144,13 @@ static uint32_t get_page(uint32_t addr) {
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool flash_is_valid_addr(uint32_t addr) {
|
||||||
|
uint8_t last = MP_ARRAY_SIZE(flash_layout) - 1;
|
||||||
|
uint32_t end_of_flash = flash_layout[last].base_address +
|
||||||
|
flash_layout[last].sector_count * flash_layout[last].sector_size;
|
||||||
|
return flash_layout[0].base_address <= addr && addr < end_of_flash;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t flash_get_sector_info(uint32_t addr, uint32_t *start_addr, uint32_t *size) {
|
uint32_t flash_get_sector_info(uint32_t addr, uint32_t *start_addr, uint32_t *size) {
|
||||||
if (addr >= flash_layout[0].base_address) {
|
if (addr >= flash_layout[0].base_address) {
|
||||||
uint32_t sector_index = 0;
|
uint32_t sector_index = 0;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#ifndef MICROPY_INCLUDED_STM32_FLASH_H
|
#ifndef MICROPY_INCLUDED_STM32_FLASH_H
|
||||||
#define MICROPY_INCLUDED_STM32_FLASH_H
|
#define MICROPY_INCLUDED_STM32_FLASH_H
|
||||||
|
|
||||||
|
bool flash_is_valid_addr(uint32_t addr);
|
||||||
uint32_t flash_get_sector_info(uint32_t addr, uint32_t *start_addr, uint32_t *size);
|
uint32_t flash_get_sector_info(uint32_t addr, uint32_t *start_addr, uint32_t *size);
|
||||||
int flash_erase(uint32_t flash_dest, uint32_t num_word32);
|
int flash_erase(uint32_t flash_dest, uint32_t num_word32);
|
||||||
int flash_write(uint32_t flash_dest, const uint32_t *src, uint32_t num_word32);
|
int flash_write(uint32_t flash_dest, const uint32_t *src, uint32_t num_word32);
|
||||||
|
Loading…
Reference in New Issue
Block a user