Further non-functional flash changes
This commit is contained in:
parent
294d6dc867
commit
300dc68955
@ -62,7 +62,7 @@ _Min_Stack_Size = 0x400; /* required amount of stack */
|
||||
MEMORY
|
||||
{
|
||||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
|
||||
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K
|
||||
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K - 256 - 100K
|
||||
}
|
||||
|
||||
/* Define output sections */
|
||||
|
@ -30,8 +30,8 @@
|
||||
#define MICROPY_HW_BOARD_NAME "STM32F411E_DISCO"
|
||||
#define MICROPY_HW_MCU_NAME "STM32F411xE"
|
||||
|
||||
// #define FLASH_SIZE (0x7D000)
|
||||
// #define FLASH_PAGE_SIZE (0x4000)
|
||||
#define FLASH_SIZE (0x80000) //512K
|
||||
#define FLASH_PAGE_SIZE (0x4000) //16K
|
||||
|
||||
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
|
||||
|
||||
|
@ -57,5 +57,5 @@ void stm32f4_peripherals_clocks_init(void) {
|
||||
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
||||
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
|
||||
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3);
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ static const flash_layout_t flash_layout[] = {
|
||||
#endif
|
||||
};
|
||||
|
||||
//Return the sector of a given flash address.
|
||||
uint32_t flash_get_sector_info(uint32_t addr, uint32_t *start_addr, uint32_t *size) {
|
||||
if (addr >= flash_layout[0].base_address) {
|
||||
uint32_t sector_index = 0;
|
||||
@ -122,6 +123,7 @@ bool supervisor_flash_write_block(const uint8_t *src, uint32_t block) {
|
||||
int32_t dest = convert_block_to_flash_addr(block);
|
||||
if (dest == -1) {
|
||||
// bad block number
|
||||
mp_printf(&mp_plat_print, "BAD FLASH BLOCK ERROR");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -142,14 +144,25 @@ bool supervisor_flash_write_block(const uint8_t *src, uint32_t block) {
|
||||
if (HAL_FLASHEx_Erase(&EraseInitStruct, &SectorError) != HAL_OK) {
|
||||
// error occurred during sector erase
|
||||
HAL_FLASH_Lock(); // lock the flash
|
||||
mp_printf(&mp_plat_print, "FLASH SECTOR ERASE ERROR");
|
||||
return false;
|
||||
}
|
||||
|
||||
__HAL_FLASH_DATA_CACHE_DISABLE();
|
||||
__HAL_FLASH_INSTRUCTION_CACHE_DISABLE();
|
||||
|
||||
__HAL_FLASH_DATA_CACHE_RESET();
|
||||
__HAL_FLASH_INSTRUCTION_CACHE_RESET();
|
||||
|
||||
__HAL_FLASH_INSTRUCTION_CACHE_ENABLE();
|
||||
__HAL_FLASH_DATA_CACHE_ENABLE();
|
||||
|
||||
// program the flash word by word
|
||||
for (int i = 0; i < (FILESYSTEM_BLOCK_SIZE / 4); i++) {
|
||||
if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, dest, *src) != HAL_OK) {
|
||||
// error occurred during flash write
|
||||
HAL_FLASH_Lock(); // lock the flash
|
||||
mp_printf(&mp_plat_print, "FLASH WRITE ERROR");
|
||||
return false;
|
||||
}
|
||||
dest += 4;
|
||||
|
@ -46,7 +46,7 @@
|
||||
#define INTERNAL_FLASH_FILESYSTEM_START_ADDR ((STM32_FLASH_SIZE + STM32_FLASH_OFFSET) - INTERNAL_FLASH_FILESYSTEM_SIZE - CIRCUITPY_INTERNAL_NVM_SIZE)
|
||||
#define INTERNAL_FLASH_FILESYSTEM_NUM_BLOCKS (INTERNAL_FLASH_FILESYSTEM_SIZE / FILESYSTEM_BLOCK_SIZE)
|
||||
|
||||
// #define INTERNAL_FLASH_SYSTICK_MASK (0x1ff) // 512ms
|
||||
// #define INTERNAL_FLASH_IDLE_TICK(tick) (((tick) & INTERNAL_FLASH_SYSTICK_MASK) == 2)
|
||||
#define INTERNAL_FLASH_SYSTICK_MASK (0x1ff) // 512ms
|
||||
#define INTERNAL_FLASH_IDLE_TICK(tick) (((tick) & INTERNAL_FLASH_SYSTICK_MASK) == 2)
|
||||
|
||||
#endif // MICROPY_INCLUDED_STM32F4_INTERNAL_FLASH_H
|
||||
|
Loading…
Reference in New Issue
Block a user