Skip to content

Commit

Permalink
esp32c3: Added handling for correctly entering Flash mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonmux committed Aug 6, 2024
1 parent 36220de commit 6a3a19f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/target/esp32c3.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ static void esp32c3_spi_write(
target_s *target, uint16_t command, target_addr32_t address, const void *buffer, size_t length);
static void esp32c3_spi_run_command(target_s *target, uint16_t command, target_addr32_t address);

static bool esp32c3_enter_flash_mode(target_s *target);
static bool esp32c3_spi_flash_write(target_flash_s *flash, target_addr32_t dest, const void *src, size_t length);

/* Make an ESP32-C3 ready for probe operations having identified one */
Expand Down Expand Up @@ -166,6 +167,8 @@ bool esp32c3_probe(target_s *const target)
target->halt_poll = esp32c3_halt_poll;
/* Provide an implementation of the mass erase command */
target->mass_erase = bmp_spi_mass_erase;
/* Special care must be taken during Flash programming */
target->enter_flash_mode = esp32c3_enter_flash_mode;

/* Establish the target RAM mappings */
target_add_ram32(target, ESP32_C3_IBUS_SRAM0_BASE, ESP32_C3_IBUS_SRAM0_SIZE);
Expand Down Expand Up @@ -383,6 +386,12 @@ static void esp32c3_spi_run_command(target_s *const target, const uint16_t comma
esp32c3_spi_wait_complete(target);
}

static bool esp32c3_enter_flash_mode(target_s *const target)
{
esp32c3_disable_wdts(target);
return true;
}

static bool esp32c3_spi_flash_write(
target_flash_s *const flash, const target_addr32_t dest, const void *const src, const size_t length)
{
Expand Down

0 comments on commit 6a3a19f

Please sign in to comment.