Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
96e3fbd
apollo3: Normalised the code organisation
dragonmux Aug 26, 2025
fd11f43
at32f43x: Normalised the code organisation
dragonmux Aug 26, 2025
edf5cf9
efm32: Fixed the `target` and `flash` nomenclature
dragonmux Aug 26, 2025
3ef4ea6
efm32: Fixed a padding issue in the efm32_devices array
dragonmux Aug 26, 2025
5fc92ad
efm32: Compressed the temp grades text a little better
dragonmux Aug 26, 2025
b5b4c7c
efm32: Cleaned up the way the search loops for the temp grade and pac…
dragonmux Aug 26, 2025
5d804bb
efm32: Standardised the comment style used
dragonmux Aug 26, 2025
d59aa94
efm32: Switch the loop style for efm32_flash_erase() from `while` to …
dragonmux Aug 26, 2025
96bb317
efm32: Modernise efm32_flash_erase() to use the modern Flash API guar…
dragonmux Aug 26, 2025
9b35f87
kinetis: Fixed the `target` and `flash` nomenclature
dragonmux Aug 27, 2025
1d084a6
kinetis: Normalised the code organisation
dragonmux Aug 27, 2025
08d8c09
kinetis: Switch the loop style for kinetis_flash_cmd_erase() from `wh…
dragonmux Aug 27, 2025
1b9a34a
efm32: Modernise kinetis_flash_cmd_erase() to use the modern Flash AP…
dragonmux Aug 27, 2025
6429ce7
kinetis: Switch the loop style for kinetis_flash_cmd_write() from `wh…
dragonmux Aug 27, 2025
b73a035
kinetis: Further code style cleanup and types improvements
dragonmux Aug 27, 2025
f1b167c
lmi: Fixed the macro prefixing
dragonmux Aug 27, 2025
f36629a
lmi: Modernised the lmi_flash_erase() loop a bit
dragonmux Aug 27, 2025
4a613d3
stm32h5: Fixed a missign `default` statement in stm32h5_probe()'s dis…
dragonmux Aug 27, 2025
f684831
ch579: Normalised the comment style
dragonmux Aug 28, 2025
8f94219
ch32vx: Fixed some DEBUG_INFO format specifier issues, and a couple o…
dragonmux Aug 28, 2025
72e9b00
ch32f1: Fixed the macro prefixing and nomenclature
dragonmux Aug 29, 2025
c875dce
efm32: Normalised the code organisation
dragonmux Aug 31, 2025
b549bde
lmi: Normalised the code organisation
dragonmux Aug 31, 2025
8957fea
lpc15xx: Normalised the code organisation
dragonmux Aug 31, 2025
54111a5
lpc15xx: Fixed the `target` nomenclature
dragonmux Aug 31, 2025
6d2db07
lpc546xx: Fixed the `target` and `flash` nomenclature
dragonmux Aug 31, 2025
9ea1b72
lpc546xx: Cleaned up in the reset command implementation using a mode…
dragonmux Aug 31, 2025
ef2e90d
lpc546xx: Normalised the code organisation
dragonmux Aug 31, 2025
00a0208
lpc55xx: Fixed some clang-tidy lints
dragonmux Aug 31, 2025
7d67346
lpc43xx: Fixed the `target` and `flash` nomenclature
dragonmux Aug 31, 2025
fd509a7
lpc43xx: Normalised the code organisation
dragonmux Aug 31, 2025
2692ec0
lpc40xx: Swizzled some logic in the probe routine for more consistent…
dragonmux Sep 7, 2025
ac69198
lpc17xx: Swizzled some logic in the probe routine for more consistent…
dragonmux Sep 7, 2025
c900f40
lpc55xx: Normalised the code organisation a bit
dragonmux Sep 7, 2025
6795d17
msp432p4: Fixed the `target` and `flash` nomenclature
dragonmux Sep 7, 2025
14139d9
msp432p4: Fixed some issues with the logging used
dragonmux Sep 7, 2025
cf497ee
msp432p4: Switched the loop style for msp432_flash_erase() from `whil…
dragonmux Sep 7, 2025
5f5b2ef
msp432p4: Modernised msp432_flash_erase() to use the modern Flash API…
dragonmux Sep 7, 2025
3a62d7c
msp432p4: `const` improvements and further nomenclature fixes for `ta…
dragonmux Sep 8, 2025
9b65728
mspm0: Normalised the code organisation a bit
dragonmux Sep 8, 2025
ccc7ed2
nrf51: Fixed the `target` and `flash` nomenclature
dragonmux Sep 8, 2025
6b9948a
nrf51: Normalised the code organisation a bit
dragonmux Sep 8, 2025
cb2c67d
nrf54l: Normalised the code organisation a bit
dragonmux Sep 8, 2025
1cc4f56
nrf91: Normalised the code organisation a bit
dragonmux Sep 8, 2025
4a53527
nxpke04: Fixed the `target` and `flash` nomenclature
dragonmux Sep 8, 2025
b1a56c1
nxpke04: Normalised the code organisation a bit
dragonmux Sep 8, 2025
2266c94
puya: Fixed some clang-tidy warnings and a code organisation oops
dragonmux Sep 8, 2025
367ea2d
nrf54l: Added missing copyright notice and license per comments in #1316
dragonmux Sep 8, 2025
d679ca6
nrf91: Added missing copyright notice and license per comments in #1316
dragonmux Sep 8, 2025
3e48511
nrf51: Fixed up the comment style for top-of-file
dragonmux Sep 8, 2025
26a1d1d
nrf54l: Added the top-of-file comment block which was missing
dragonmux Sep 8, 2025
987e484
nrf91: Added the top-of-file comment block which was missing
dragonmux Sep 8, 2025
ee78dc1
s32k3xx: Fixed several code organisation issues and clang-tidy warnings
dragonmux Sep 9, 2025
5b546b7
sam3x: Fixed several clang-tidy warnings and the top-of-file comment …
dragonmux Sep 9, 2025
2d25bde
sam4l: Fixed up the comment style for top-of-file
dragonmux Sep 9, 2025
5e579de
sam4l: Fixed the `target` and `flash` nomenclature
dragonmux Sep 9, 2025
798b725
sam4l: Fixed the macro prefixing and nomenclature
dragonmux Sep 10, 2025
50c966a
samd: Fixed the `target` and `flash` nomenclature
dragonmux Sep 10, 2025
86b9fb9
samd: Normalised the code organisation a bit
dragonmux Sep 10, 2025
b5eb404
samd: Fixed several clang-tidy warnings
dragonmux Sep 10, 2025
d000ecb
stm32f1: Fixed a couple of clang-tidy warnings
dragonmux Sep 10, 2025
bb92268
stm32f1: Fixed up the comment style for top-of-file
dragonmux Sep 11, 2025
b1d44de
stm32f1: Fixed the macro prefixing and nomenclature
dragonmux Sep 11, 2025
b068c09
stm32h5: Fixed the macro nomenclature
dragonmux Sep 11, 2025
2351e77
stm32f4: Fixed the macro prefixing and nomenclature
dragonmux Sep 13, 2025
f88bbc0
stm32f4: Normalised the code organisation a bit
dragonmux Sep 13, 2025
f1af0db
stm32g0: Fixed the macro prefixing and nomenclature
dragonmux Sep 13, 2025
57a7722
stm32g0: Fixed a clang-tidy lint about a missing `default` case
dragonmux Sep 14, 2025
e530d89
stm32h7: Fixed the macro prefixing
dragonmux Sep 14, 2025
2b62ce0
stm32l0: Fixed some clang-tidy lints about missing `default` cases
dragonmux Sep 14, 2025
4d9bcd1
stm32l4: Normalised the code organisation a bit
dragonmux Sep 14, 2025
00eba64
stm32l4: Fixed the macro prefixing and nomenclature
dragonmux Sep 14, 2025
ede1384
stm32l4: Fixed up the comment style for top-of-file
dragonmux Sep 14, 2025
7ccc076
stm32l4: Fixed some more macro prefixing and nomenclature
dragonmux Sep 18, 2025
1990447
stm32l4: Fixed some prefixing and nomenclature for the FPEC regs maps
dragonmux Sep 18, 2025
4cbd27f
target: Fixed a couple of clang-tidy warnings
dragonmux Sep 18, 2025
fd5ecdb
target_flash: Added back in a diagnostic for the Flash write calls to…
dragonmux Sep 18, 2025
245683d
adiv5_swd: Fixed a consistency issue in one of the mode switch diagno…
dragonmux Sep 21, 2025
228109d
at32f43x: Removed an unnecessary check that the `len` parameter to `a…
dragonmux Sep 21, 2025
cc51a08
at32f43x: Removed some now unnessary diagnostics from `at32f43_flash_…
dragonmux Sep 21, 2025
a45b1e9
at32f43x: `const`-correctness for the function signatures
dragonmux Oct 1, 2025
25d8585
stm32l4: `const`-correctness for the function signatures
dragonmux Oct 1, 2025
216aadb
stm32l0: `const`-correctness for the function signatures
dragonmux Oct 1, 2025
ca196af
stm32h7: `const`-correctness for the function signatures
dragonmux Oct 1, 2025
957679a
stm32g0: `const`-correctness for the function signatures
dragonmux Oct 1, 2025
86830d6
stm32g0: Code organisation and nomenclature improvements for the opti…
dragonmux Oct 1, 2025
5cb2a94
stm32g0: Modernised and simplified the erase logic in stm32g0_flash_e…
dragonmux Oct 1, 2025
92d54ac
stm32f4: `const`-correctness for the function signatures
dragonmux Oct 1, 2025
fd8c690
stm32f4: Modernised and simplified the erase logic in stm32f4_flash_e…
dragonmux Oct 1, 2025
d829f0a
stm32f1: `const`-correctness for the function signatures
dragonmux Oct 1, 2025
680fef8
stm32f1: Fixed the incorrect address mask issue from #1826 in the `mm…
dragonmux Oct 1, 2025
3b84144
sam4l: `const`-correctness for the function signatures
dragonmux Oct 1, 2025
f28113c
sam4l: Fixed the style of one of the comments in `sam4l_flash_write()`
dragonmux Oct 1, 2025
d5cca86
sam4l: Removed unnecessary diagnostics (which were also at the wrong …
dragonmux Oct 1, 2025
0c28aab
sam4l: Target Flash API guarantees that `len` will be `blocksize` for…
dragonmux Oct 1, 2025
530af6c
sam3x: `const`-correctness for the function signatures
dragonmux Oct 1, 2025
b82396e
s32k3xx: `const`-correctness for the function signatures
dragonmux Oct 1, 2025
b5d90bc
s32k3xx: Fixed up the comment style for top-of-file
dragonmux Oct 1, 2025
7756158
rp2040: Fixed up the comment style for top-of-file
dragonmux Oct 1, 2025
56c1082
samd: Fixed the `target` nomenclature in `rp_cmd_reset_usb_boot()`
dragonmux Oct 1, 2025
25b8137
rp2040: `const`-correctness for the function signatures
dragonmux Oct 1, 2025
038fb11
rp2040: Fixed the macro prefixing and nomenclature
dragonmux Oct 1, 2025
04c4846
rp2040: More cleanup for `const`-correctness and nomenclature
dragonmux Oct 1, 2025
107f248
puya: `const`-correctness for the function signatures
dragonmux Oct 1, 2025
3dd0dcd
nxpke04: `const`-correctness for the function signatures
dragonmux Oct 1, 2025
3c5737e
stm32g0: Make use of the target structure's `unsafe_enabled` member i…
dragonmux Oct 1, 2025
2ac71ef
nxpke04: `sector_erase` duplicates `erase_range` command, deprecate i…
dragonmux Oct 2, 2025
bfc82ad
nrf91: Modernised and simplified the erase logic in `nrf91_flash_eras…
dragonmux Oct 2, 2025
32b6a2f
nrf91: `const`-correctness for the function signatures
dragonmux Oct 2, 2025
9cd1f61
nrf54l: `const`-correctness for the function signatures
dragonmux Oct 2, 2025
5d4c420
nrf51: `const`-correctness for the function signatures
dragonmux Oct 2, 2025
04c47a1
nrf51: Modernised and simplified the erase logic in `nrf51_flash_eras…
dragonmux Oct 2, 2025
97cb621
nrf51: Code organisation improvements for the recovery AP code
dragonmux Oct 2, 2025
3059f8e
mspm0: `const`-correctness for the function signatures
dragonmux Oct 2, 2025
de1d930
mspm0: Removed unnecessary diagnostics (target Flash API already prov…
dragonmux Oct 2, 2025
30e5eee
msp432p4: Normalised the code organisation a bit
dragonmux Oct 2, 2025
fae5d2d
msp432p4: `const`-correctness for the function signatures
dragonmux Oct 2, 2025
3f3d07b
msp432p4: Removed unnecessary diagnostics (target Flash API already p…
dragonmux Oct 2, 2025
276dc1b
msp432p4: Fixed up the comment style for top-of-file
dragonmux Oct 3, 2025
1f3e558
lpc546xx: `const`-correctness for the function signatures
dragonmux Oct 3, 2025
503fee9
lpc546xx: Remove the deprecated `erase_sector` command
dragonmux Oct 3, 2025
8ff8dc0
lpc55xx: Fixed up the comment style for top-of-file
dragonmux Oct 3, 2025
d6a0814
lpc55xx: Fixed various type usage and missing `const` in the part inf…
dragonmux Oct 4, 2025
62f05d7
lpc55xx: `const`-correctness for the function signatures
dragonmux Oct 4, 2025
41ca92f
lpc55xx: Split the `lpc55xx_enter_flash_mode()` mini binary into two …
dragonmux Oct 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/target/adiv5_swd.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static void dormant_to_swd_sequence(void)
swd_proc.seq_out(ADIV5_JTAG_TO_DORMANT_SEQUENCE1, 31U);
swd_proc.seq_out(ADIV5_JTAG_TO_DORMANT_SEQUENCE2, 8U);
/* Send the 128-bit Selection Alert sequence on SWDIOTMS */
DEBUG_INFO("Switching out of dormant state into SWD\n");
DEBUG_INFO("Switching from dormant to SWD\n");
swd_proc.seq_out(ADIV5_SELECTION_ALERT_SEQUENCE_0, 32U);
swd_proc.seq_out(ADIV5_SELECTION_ALERT_SEQUENCE_1, 32U);
swd_proc.seq_out(ADIV5_SELECTION_ALERT_SEQUENCE_2, 32U);
Expand Down
11 changes: 6 additions & 5 deletions src/target/apollo3.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/*
* This file is part of the Black Magic Debug project.
*
* Copyright (C) 2022-2023 1BitSquared <[email protected]>
* Copyright (C) 2022-2025 1BitSquared <[email protected]>
* Written by Sid Price <[email protected]>
* Modified by Rachel Mant <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -22,9 +23,6 @@
#include "target.h"
#include "target_internal.h"

static bool apollo_3_flash_erase(target_flash_s *flash, target_addr_t addr, size_t len);
static bool apollo_3_flash_write(target_flash_s *flash, target_addr_t dest, const void *src, size_t len);

#define APOLLO_3_FLASH_BASE_ADDRESS 0x00000000U
#define APOLLO_3_FLASH_SIZE 0x00100000U
#define APOLLO_3_FLASH_BLOCK_SIZE 0x2000U
Expand Down Expand Up @@ -81,6 +79,9 @@ static bool apollo_3_flash_write(target_flash_s *flash, target_addr_t dest, cons
#define APOLLO_3_VENDOR_ID_ADDRESS 0x40020010U /* Vendor ID Register */
#define APOLLO_3_VENDOR_ID 0x414d4251U

static bool apollo_3_flash_erase(target_flash_s *flash, target_addr_t addr, size_t len);
static bool apollo_3_flash_write(target_flash_s *flash, target_addr_t dest, const void *src, size_t len);

static void apollo_3_add_flash(target_s *target)
{
target_flash_s *flash = calloc(1, sizeof(*flash));
Expand Down Expand Up @@ -109,7 +110,7 @@ bool apollo_3_probe(target_s *target)
/* Read the CHIPPN register to gather MCU details */
uint32_t mcu_chip_partnum = target_mem32_read32(target, APOLLO_3_CHIPPN_REGISTER);
/* Check the chip is an Apollo 3 */
if ((mcu_chip_partnum & APOLLO_3_CHIPPN_PART_NUMBER_MASK) != 0x06000000) {
if ((mcu_chip_partnum & APOLLO_3_CHIPPN_PART_NUMBER_MASK) != 0x06000000U) {
DEBUG_INFO("Invalid chip type read\n");
return false;
}
Expand Down
73 changes: 33 additions & 40 deletions src/target/at32f43x.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/*
* This file is part of the Black Magic Debug project.
*
* Copyright (C) 2023-2024 1BitSquared <[email protected]>
* Copyright (C) 2023-2025 1BitSquared <[email protected]>
* Written by ALTracer <[email protected]>
* Modified by Rachel Mant <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -37,21 +38,6 @@
#include "cortexm.h"
#include "stm32_common.h"

static bool at32f43_cmd_option(target_s *target, int argc, const char **argv);
static bool at32f43_cmd_uid(target_s *target, int argc, const char **argv);

const command_s at32f43_cmd_list[] = {
{"option", at32f43_cmd_option, "Manipulate option bytes"},
{"uid", at32f43_cmd_uid, "Print unique device ID"},
{NULL, NULL, NULL},
};

static bool at32f43_flash_prepare(target_flash_s *flash);
static bool at32f43_flash_erase(target_flash_s *flash, target_addr_t addr, size_t len);
static bool at32f43_flash_write(target_flash_s *flash, target_addr_t dest, const void *src, size_t len);
static bool at32f43_flash_done(target_flash_s *flash);
static bool at32f43_mass_erase(target_s *target, platform_timeout_s *print_progess);

/* Flash memory controller register map */
#define AT32F43x_FLASH_REG_BASE 0x40023c00U
#define AT32F43x_FLASH_UNLOCK (AT32F43x_FLASH_REG_BASE + 0x04U)
Expand Down Expand Up @@ -134,6 +120,21 @@ static bool at32f43_mass_erase(target_s *target, platform_timeout_s *print_proge
#define AT32F4x_PROJECT_ID 0x1ffff7f3U
#define AT32F4x_FLASHSIZE 0x1ffff7e0U

static bool at32f43_cmd_option(target_s *target, int argc, const char **argv);
static bool at32f43_cmd_uid(target_s *target, int argc, const char **argv);

const command_s at32f43_cmd_list[] = {
{"option", at32f43_cmd_option, "Manipulate option bytes"},
{"uid", at32f43_cmd_uid, "Print unique device ID"},
{NULL, NULL, NULL},
};

static bool at32f43_flash_prepare(target_flash_s *flash);
static bool at32f43_flash_erase(target_flash_s *flash, target_addr_t addr, size_t len);
static bool at32f43_flash_write(target_flash_s *flash, target_addr_t dest, const void *src, size_t len);
static bool at32f43_flash_done(target_flash_s *flash);
static bool at32f43_mass_erase(target_s *target, platform_timeout_s *print_progess);

typedef struct at32f43_flash {
target_flash_s target_flash;
uint32_t bank_reg_offset; /* Flash register offset for this bank */
Expand Down Expand Up @@ -165,7 +166,7 @@ static void at32f43_add_flash(target_s *const target, const target_addr_t addr,
target_add_flash(target, target_flash);
}

static void at32f43_configure_dbgmcu(target_s *target)
static void at32f43_configure_dbgmcu(target_s *const target)
{
/*
* Enable sleep state emulation (clocks fed by HICK)
Expand All @@ -184,7 +185,7 @@ static void at32f43_configure_dbgmcu(target_s *target)
target_mem32_write32(target, AT32F43x_DBGMCU_APB1_PAUSE, dbgmcu_apb1_pause | dbgmcu_apb1_pause_mask);
}

static bool at32f43_attach(target_s *target)
static bool at32f43_attach(target_s *const target)
{
if (!cortexm_attach(target))
return false;
Expand All @@ -193,7 +194,7 @@ static bool at32f43_attach(target_s *target)
return true;
}

static void at32f43_detach(target_s *target)
static void at32f43_detach(target_s *const target)
{
const uint32_t dbgmcu_ctrl = target_mem32_read32(target, AT32F43x_DBGMCU_CTRL);
const uint32_t dbgmcu_apb1_pause = target_mem32_read32(target, AT32F43x_DBGMCU_APB1_PAUSE);
Expand All @@ -205,7 +206,7 @@ static void at32f43_detach(target_s *target)
}

/* Identify AT32F43x "High Performance" line devices */
static bool at32f43_detect(target_s *target, const uint16_t part_id)
static bool at32f43_detect(target_s *const target, const uint16_t part_id)
{
/*
* AT32F435 EOPB0 ZW/NZW split reconfiguration unsupported,
Expand Down Expand Up @@ -304,7 +305,7 @@ static bool at32f43_detect(target_s *target, const uint16_t part_id)
}

/* Identify AT32F405 Mainstream devices */
static bool at32f405_detect(target_s *target, const uint32_t series)
static bool at32f405_detect(target_s *const target, const uint32_t series)
{
/*
* AT32F405/F402 always contain 1 bank with 128 sectors
Expand Down Expand Up @@ -335,7 +336,7 @@ static bool at32f405_detect(target_s *target, const uint32_t series)
}

/* Identify AT32F423 Value line devices */
static bool at32f423_detect(target_s *target, const uint32_t series)
static bool at32f423_detect(target_s *const target, const uint32_t series)
{
/*
* AT32F423 always has 48 KiB of SRAM and one of
Expand Down Expand Up @@ -363,7 +364,7 @@ static bool at32f423_detect(target_s *target, const uint32_t series)
}

/* Identify any Arterytek devices with Cortex-M4 and FPEC at 0x4002_3c00 */
bool at32f43x_probe(target_s *target)
bool at32f43x_probe(target_s *const target)
{
// Artery clones use Cortex M4 cores
if ((target->cpuid & CORTEX_CPUID_PARTNO_MASK) != CORTEX_M4)
Expand Down Expand Up @@ -459,37 +460,30 @@ static bool at32f43_flash_busy_wait(
return !(status & AT32F43x_FLASH_STS_PRGMERR);
}

static bool at32f43_flash_prepare(target_flash_s *target_flash)
static bool at32f43_flash_prepare(target_flash_s *const target_flash)
{
target_s *target = target_flash->t;
const at32f43_flash_s *const flash = (at32f43_flash_s *)target_flash;
const uint32_t bank_reg_offset = flash->bank_reg_offset;
return at32f43_flash_unlock(target, bank_reg_offset);
}

static bool at32f43_flash_done(target_flash_s *target_flash)
static bool at32f43_flash_done(target_flash_s *const target_flash)
{
target_s *target = target_flash->t;
const at32f43_flash_s *const flash = (at32f43_flash_s *)target_flash;
const uint32_t bank_reg_offset = flash->bank_reg_offset;
return at32f43_flash_lock(target, bank_reg_offset);
}

static bool at32f43_flash_erase(target_flash_s *target_flash, target_addr_t addr, size_t len)
static bool at32f43_flash_erase(target_flash_s *const target_flash, const target_addr_t addr, const size_t len)
{
(void)len;
target_s *target = target_flash->t;
const at32f43_flash_s *const flash = (at32f43_flash_s *)target_flash;
const uint32_t bank_reg_offset = flash->bank_reg_offset;

if (len != target_flash->blocksize) {
DEBUG_ERROR(
"%s: Requested erase length %zu does not match blocksize %zu!\n", __func__, len, target_flash->blocksize);
return false;
}

at32f43_flash_clear_eop(target, bank_reg_offset);
DEBUG_TARGET("%s: 0x%08" PRIX32 "+%" PRIu32 " reg_base 0x%08" PRIX32 "\n", __func__, addr, (uint32_t)len,
bank_reg_offset + AT32F43x_FLASH_REG_BASE);

/* Prepare for page/sector erase */
target_mem32_write32(target, AT32F43x_FLASH_CTRL + bank_reg_offset, AT32F43x_FLASH_CTRL_SECERS);
Expand All @@ -503,16 +497,15 @@ static bool at32f43_flash_erase(target_flash_s *target_flash, target_addr_t addr
return at32f43_flash_busy_wait(target, bank_reg_offset, NULL);
}

static bool at32f43_flash_write(target_flash_s *target_flash, target_addr_t dest, const void *src, size_t len)
static bool at32f43_flash_write(
target_flash_s *const target_flash, const target_addr_t dest, const void *src, const size_t len)
{
target_s *target = target_flash->t;
const at32f43_flash_s *const flash = (at32f43_flash_s *)target_flash;
const uint32_t bank_reg_offset = flash->bank_reg_offset;
const align_e psize = ALIGN_32BIT;

at32f43_flash_clear_eop(target, bank_reg_offset);
DEBUG_TARGET("%s: 0x%08" PRIX32 "+%" PRIu32 " reg_base 0x%08" PRIX32 "\n", __func__, dest, (uint32_t)len,
bank_reg_offset + AT32F43x_FLASH_REG_BASE);

/* Write to bank corresponding to flash region */
target_mem32_write32(target, AT32F43x_FLASH_CTRL + bank_reg_offset, AT32F43x_FLASH_CTRL_FPRGM);
Expand Down Expand Up @@ -550,7 +543,7 @@ static bool at32f43_mass_erase(target_s *const target, platform_timeout_s *const
return true;
}

static bool at32f43_option_erase(target_s *target)
static bool at32f43_option_erase(target_s *const target)
{
/* bank_reg_offset is 0, option bytes belong to first bank */
at32f43_flash_clear_eop(target, 0);
Expand Down Expand Up @@ -654,7 +647,7 @@ static bool at32f43_option_write(target_s *const target, const uint32_t addr, co
return result;
}

static bool at32f43_cmd_option(target_s *target, int argc, const char **argv)
static bool at32f43_cmd_option(target_s *const target, const int argc, const char **const argv)
{
const uint32_t read_protected = target_mem32_read32(target, AT32F43x_FLASH_USD) & AT32F43x_FLASH_USD_RDP;
const bool erase_requested = argc == 2 && strcmp(argv[1], "erase") == 0;
Expand Down Expand Up @@ -712,7 +705,7 @@ static bool at32f43_cmd_option(target_s *target, int argc, const char **argv)
return true;
}

static bool at32f43_cmd_uid(target_s *target, int argc, const char **argv)
static bool at32f43_cmd_uid(target_s *const target, const int argc, const char **const argv)
{
(void)argc;
(void)argv;
Expand Down
Loading
Loading