1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-24 00:35:39 +03:00

Program flash using full range of buffer

This commit is contained in:
blckmn 2025-01-06 20:34:05 +11:00
parent ed8861e76c
commit 4cf0ae8175
4 changed files with 10 additions and 11 deletions

View file

@ -45,7 +45,7 @@ void configFlashClearFlags(void)
// NOOP
}
configStreamerResult_e configWriteWord(uintptr_t address, config_streamer_buffer_type_t value)
configStreamerResult_e configWriteWord(uintptr_t address, config_streamer_buffer_type_t *buffer)
{
uint32_t interrupts = save_and_disable_interrupts();
@ -54,13 +54,12 @@ configStreamerResult_e configWriteWord(uintptr_t address, config_streamer_buffer
flash_range_erase(address, FLASH_PAGE_SIZE);
}
STATIC_ASSERT(CONFIG_STREAMER_BUFFER_SIZE == sizeof(uint32_t) * 1, "CONFIG_STREAMER_BUFFER_SIZE does not match written size");
STATIC_ASSERT(CONFIG_STREAMER_BUFFER_SIZE == sizeof(config_streamer_buffer_type_t) * CONFIG_STREAMER_BUFFER_SIZE, "CONFIG_STREAMER_BUFFER_SIZE does not match written size");
// TODO: refactor to stream the entire buffer to flash also possibly avoid disabling interrupts.
// Write data to flash
// TODO: synchronise second core...
flash_range_program(address, (uint8_t*)&value, sizeof(uint32_t));
flash_range_program(address, buffer, CONFIG_STREAMER_BUFFER_SIZE);
restore_interrupts(interrupts);
return CONFIG_RESULT_SUCCESS;

View file

@ -183,6 +183,7 @@ MCU_COMMON_SRC = \
PICO/system.c \
PICO/io_pico.c \
PICO/bus_spi_pico.c \
PICO/serial_uart_pico.c
PICO/serial_uart_pico.c \
PICO/config_flash.c
DEVICE_FLAGS +=

View file

@ -31,8 +31,6 @@
#define SPI_IO_AF_SDI_CFG 0
#define SPI_IO_CS_CFG 0
// Register address offsets for atomic RMW aliases
#define REG_ALIAS_RW_BITS (_u(0x0) << _u(12))
#define REG_ALIAS_XOR_BITS (_u(0x1) << _u(12))

View file

@ -117,10 +117,11 @@
#undef USE_FLASH_PY25Q128HA
#undef USE_FLASH_W25Q64FV
#define FLASH_PAGE_SIZE 0x4000
//#define FLASH_PAGE_SIZE 0x1
#define CONFIG_IN_FLASH
#define FLASH_CONFIG_STREAMER_BUFFER_SIZE 4
#define FLASH_CONFIG_BUFFER_ALIGN_TYPE uint32_t
#define FLASH_CONFIG_STREAMER_BUFFER_SIZE 256
#define FLASH_CONFIG_BUFFER_TYPE uint8_t
/* to be moved to a config file once target if working */
#define LED0_PIN P6