Skip to content

Commit

Permalink
at32f43x: Add detection of AT32F423 and basic support
Browse files Browse the repository at this point in the history
  • Loading branch information
ALTracer committed Oct 3, 2024
1 parent 96b1ad5 commit 3f66738
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/target/at32f43x.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,33 @@ static bool at32f405_detect(target_s *target, const uint32_t series)
return true;
}

static bool at32f423_detect(target_s *target, const uint32_t series)
{
/*
* AT32F423 always has 48 KiB of SRAM and one of
* Flash (C): 256 KiB, 2 KiB per sector, 0x700a_3000
* Flash (B): 128 KiB, 1 KiB per sector, 0x700a_2000
* Flash (8): 64 KiB, 1 KiB per sector, 0x7003_2000
*/
const uint16_t flash_size = target_mem32_read16(target, AT32F4x_FLASHSIZE);
const uint16_t sector_size = (series == AT32F423_SERIES_256KB) ? 2048U : 1024U;
at32f43_add_flash(target, 0x08000000, flash_size, sector_size, 0, AT32F43x_FLASH_BANK1_REG_OFFSET);

target_add_ram32(target, 0x20000000, 48U * 1024U);
target->driver = "AT32F423";
target->mass_erase = at32f43_mass_erase;

/* 512 byte User System Data area at 0x1fff_f800 (different USD_BASE, no EOPB0) */
//target_add_commands(target, at32f43_cmd_list, target->driver);

/* Same registers and freeze bits in DBGMCU as F437 */
target->attach = at32f43_attach;
target->detach = at32f43_detach;
at32f43_configure_dbgmcu(target);

return true;
}

/* Identify AT32F43x "High Performance" line devices (Cortex-M4) */
bool at32f43x_probe(target_s *target)
{
Expand All @@ -354,7 +381,7 @@ bool at32f43x_probe(target_s *target)
return at32f405_detect(target, series);
if ((series == AT32F423_SERIES_256KB || series == AT32F423_SERIES_128KB || series == AT32F423_SERIES_64KB) &&
project_id == 0x12U)
return false;
return at32f423_detect(target, series);

return false;
}
Expand Down

0 comments on commit 3f66738

Please sign in to comment.