16 #define BOOTROM_RP2040_MAGIC 0x01754d
18 #define BOOTROM_RP2350_MAGIC 0x02754d
19 #define BOOTROM_MAGIC_MASK 0xffffff
20 #define BOOTROM_MAGIC_ADDR 0x00000010
22 #define MAKE_TAG(a, b) (((b)<<8) | a)
23 #define FUNC_FLASH_EXIT_XIP MAKE_TAG('E', 'X')
24 #define FUNC_CONNECT_INTERNAL_FLASH MAKE_TAG('I', 'F')
25 #define FUNC_FLASH_RANGE_ERASE MAKE_TAG('R', 'E')
26 #define FUNC_FLASH_RANGE_PROGRAM MAKE_TAG('R', 'P')
27 #define FUNC_FLASH_FLUSH_CACHE MAKE_TAG('F', 'C')
28 #define FUNC_FLASH_ENTER_CMD_XIP MAKE_TAG('C', 'X')
29 #define FUNC_BOOTROM_STATE_RESET MAKE_TAG('S', 'R')
30 #define FUNC_BOOTROM_SET_STACK MAKE_TAG('S', 'S')
31 #define FUNC_FLASH_RESET_ADDRESS_TRANS MAKE_TAG('R', 'A')
34 #define RT_FLAG_FUNC_RISCV 0x01
35 #define RT_FLAG_FUNC_ARM_SEC 0x04
36 #define RT_FLAG_FUNC_ARM_NONSEC 0x10
37 #define RT_FLAG_DATA 0x40
40 #define BOOTROM_STATE_RESET_CURRENT_CORE 0x01
41 #define BOOTROM_STATE_RESET_OTHER_CORE 0x02
42 #define BOOTROM_STATE_RESET_GLOBAL_STATE 0x04
44 #define ACCESSCTRL_LOCK_OFFSET 0x40060000u
45 #define ACCESSCTRL_CFGRESET_OFFSET 0x40060008u
46 #define ACCESSCTRL_GPIO_NSMASK0_OFFSET 0x4006000cu
47 #define ACCESSCTRL_GPIO_ROM_OFFSET 0x40060014u
48 #define ACCESSCTRL_GPIO_XIP_AUX_OFFSET 0x400600e8u
50 #define ACCESSCTRL_SAVE_BASE ACCESSCTRL_GPIO_NSMASK0_OFFSET
51 #define ACCESSCTRL_SAVE_SIZE \
52 (ACCESSCTRL_GPIO_XIP_AUX_OFFSET + 4 - ACCESSCTRL_SAVE_BASE)
54 #define ACCESSCTRL_LOCK_DEBUG_BITS 0x00000008u
55 #define ACCESSCTRL_WRITE_PASSWORD 0xacce0000u
57 #define RP2040_SSI_DR0 0x18000060
58 #define RP2040_QSPI_CTRL 0x4001800c
60 #define RP2040_QSPI_CTRL_OUTOVER_MASK (3ul << 8)
61 #define RP2040_QSPI_CTRL_OUTOVER_LOW (2ul << 8)
62 #define RP2040_QSPI_CTRL_OUTOVER_HIGH (3ul << 8)
64 #define RP2350_QMI_DIRECT_CSR 0x400d0000
65 #define RP2350_QMI_DIRECT_TX 0x400d0004
66 #define RP2350_QMI_DIRECT_RX 0x400d0008
68 #define RP2350_QMI_DIRECT_CSR_EN BIT(0)
69 #define RP2350_QMI_DIRECT_CSR_ASSERT_CS0N BIT(2)
70 #define RP2350_QMI_DIRECT_TX_NOPUSH BIT(20)
71 #define RP2350_QMI_DIRECT_TX_OE BIT(19)
73 #define RP2XXX_SYSINFO_CHIP_ID 0x40000000
74 #define RP2XXX_CHIP_ID_PART_MANUFACTURER(id) ((id) & 0x0fffffff)
75 #define RP2XXX_CHIP_ID_MANUFACTURER 0x493
76 #define RP2XXX_MK_PART(part) (((part) << 12) | (RP2XXX_CHIP_ID_MANUFACTURER << 1) | 1)
77 #define RP2040_CHIP_ID_PART 0x0002
78 #define IS_RP2040(id) (RP2XXX_CHIP_ID_PART_MANUFACTURER(id) == RP2XXX_MK_PART(RP2040_CHIP_ID_PART))
79 #define RP2350_CHIP_ID_PART 0x0004
80 #define IS_RP2350(id) (RP2XXX_CHIP_ID_PART_MANUFACTURER(id) == RP2XXX_MK_PART(RP2350_CHIP_ID_PART))
81 #define RP2XXX_CHIP_ID_REVISION(id) ((id) >> 28)
83 #define RP2XXX_MAX_ALGO_STACK_USAGE 1024
84 #define RP2XXX_MAX_RAM_ALGO_SIZE 1024
86 #define RP2XXX_ROM_API_FIXED_FLASH_PAGE 256
87 #define RP2XXX_ROM_API_FIXED_FLASH_SECTOR 4096
105 0x5f, 0xf4, 0x40, 0x41,
108 0x30, 0xee, 0x10, 0xf7,
111 0x40, 0xec, 0x80, 0x07,
112 0x40, 0xec, 0x81, 0x07,
118 0x88, 0xed, 0x00, 0xe0
124 #define ROM_CALL_BATCH_ALGO_SIZE_BYTES 32
154 0x80, 0xf3, 0x0a, 0x88,
155 0x80, 0xf3, 0x0b, 0x88,
174 0x97, 0x04, 0x00, 0x00,
175 0x93, 0x84, 0x04, 0x02,
179 0x03, 0xa1, 0x44, 0x00,
226 #ifndef LOG_ROM_SYMBOL_DEBUG
227 #define LOG_ROM_SYMBOL_DEBUG LOG_DEBUG
232 LOG_ROM_SYMBOL_DEBUG(
"Looking up ROM symbol '%c%c' in RP2040 table", tag & 0xff, (tag >> 8) & 0xff);
236 LOG_ERROR(
"Only data and Secure Arm functions can be looked up in RP2040 ROM table");
240 uint16_t ptr_to_entry;
241 unsigned int offset_magic_to_table_ptr = flags ==
RT_FLAG_DATA ? 6 : 4;
252 if (entry_tag == tag) {
269 LOG_ROM_SYMBOL_DEBUG(
"Looking up ROM symbol '%c%c' in RP2350 A0 table", tag & 0xff, (tag >> 8) & 0xff);
283 LOG_WARNING(
"Ignoring non-default flags for RP2350 A0 lookup, hope you like Secure Arm functions");
286 uint16_t ptr_to_entry;
287 const unsigned int offset_magic_to_table_ptr = 4;
298 if (entry_tag == tag) {
313 uint16_t tag, uint16_t flags, uint16_t *symbol_out)
315 LOG_ROM_SYMBOL_DEBUG(
"Looking up ROM symbol '%c%c' in RP2350 A1 table", tag & 0xff, (tag >> 8) & 0xff);
323 uint16_t entry_tag, entry_flags;
329 if (entry_tag == 0) {
341 uint16_t matching_flags = flags & entry_flags;
343 if (tag == entry_tag && matching_flags != 0) {
346 while (!(matching_flags & 1)) {
350 matching_flags >>= 1;
356 *symbol_out = ptr_to_entry;
367 while (entry_flags) {
394 if (table_ptr < 0x7c00)
402 LOG_ERROR(
"RP2040/RP2350 BOOT ROM not found");
412 symtype_func, &
priv->jump_flash_exit_xip);
414 LOG_ERROR(
"Function FUNC_FLASH_EXIT_XIP not found in RP2xxx ROM");
419 symtype_func, &
priv->jump_connect_internal_flash);
421 LOG_ERROR(
"Function FUNC_CONNECT_INTERNAL_FLASH not found in RP2xxx ROM");
427 LOG_ERROR(
"Function FUNC_FLASH_RANGE_ERASE not found in RP2xxx ROM");
433 LOG_ERROR(
"Function FUNC_FLASH_RANGE_PROGRAM not found in RP2xxx ROM");
439 LOG_ERROR(
"Function FUNC_FLASH_FLUSH_CACHE not found in RP2xxx ROM");
445 LOG_ERROR(
"Function FUNC_FLASH_ENTER_CMD_XIP not found in RP2xxx ROM");
452 priv->jump_bootrom_reset_state = 0;
453 priv->jump_flash_reset_address_trans = 0;
459 priv->jump_bootrom_reset_state = 0;
460 LOG_WARNING(
"Function FUNC_BOOTROM_STATE_RESET not found in RP2xxx ROM. (probably an RP2350 A0)");
465 &
priv->jump_bootrom_set_varm_stack);
467 priv->jump_bootrom_set_varm_stack = 0;
468 LOG_WARNING(
"Function FUNC_BOOTROM_SET_STACK not found in RP2xxx ROM. (probably an RP2350 A0)");
473 symtype_func, &
priv->jump_flash_reset_address_trans);
475 priv->jump_flash_reset_address_trans = 0;
476 LOG_WARNING(
"Function FUNC_FLASH_RESET_ADDRESS_TRANS not found in RP2xxx ROM. (probably an RP2350 A0)");
491 if (!
priv->ram_algo_space) {
492 LOG_ERROR(
"No RAM code space allocated for ROM call");
495 if (
priv->ram_algo_space->size < batch_size) {
496 LOG_ERROR(
"RAM code space too small for call batch size of %u", n_calls);
501 for (
unsigned int i = 0; i < n_calls; ++i) {
504 for (
unsigned int j = 0; j < 4; ++j)
509 LOG_DEBUG(
"Returning early from call of 0 ROM functions");
513 const uint8_t *algo_code;
516 LOG_DEBUG(
"Using algo: rp2xxx_rom_call_batch_algo_armv8m");
519 LOG_DEBUG(
"Using algo: rp2xxx_rom_call_batch_algo_armv6m");
523 LOG_DEBUG(
"Using algo: rp2xxx_rom_call_batch_algo_riscv");
527 uint8_t *batch_bf = malloc(batch_size);
537 (
const uint32_t *)calls);
542 priv->ram_algo_space->address,
549 LOG_ERROR(
"Failed to write ROM batch algorithm to RAM code space");
557 unsigned int algo_timeout_ms = 3000;
565 algo_start_addr, algo_end_addr,
574 algo_start_addr, algo_end_addr,
580 LOG_ERROR(
"Failed to call ROM function batch");
594 uint16_t func_offset, uint32_t argdata[],
unsigned int n_args)
599 LOG_ERROR(
"no stack for flash programming code");
608 for (
unsigned int i = 0; i < n_args; ++i)
609 call.
args[i] = argdata[i];
617 priv->saved_accessctrl);
630 priv->saved_accessctrl);
635 priv->accessctrl_dirty =
false;
639 uint32_t accessctrl_lock_reg;
641 LOG_ERROR(
"Failed to read ACCESSCTRL lock register");
651 LOG_ERROR(
"ACCESSCTRL is locked, so can't reset permissions. Following steps might fail");
655 priv->accessctrl_dirty =
true;
660 LOG_DEBUG(
"Reset ACCESSCTRL permissions via CFGRESET");
674 LOG_ERROR(
"RP2350 init ARM core: set secure mode failed");
679 LOG_ERROR(
"No stack for flash programming code");
684 LOG_ERROR(
"No algorithm space for rcp_init code");
689 priv->ram_algo_space->address,
695 LOG_ERROR(
"Failed to load rcp_init algorithm into RAM");
700 priv->ram_algo_space->address);
709 priv->ram_algo_space->address,
730 LOG_ERROR(
"Could not allocate stack for flash programming code -- insufficient space");
735 if (!
priv->ram_algo_space) {
738 LOG_ERROR(
"Could not allocate RAM code space for ROM calls -- insufficient space");
746 LOG_ERROR(
"Failed to init ACCESSCTRL before ROM call");
752 LOG_ERROR(
"Failed to init Arm core 0 before ROM call");
756 uint32_t reset_args[1] = {
759 if (!
priv->jump_bootrom_reset_state) {
760 LOG_WARNING(
"RP2350 flash: no bootrom_reset_method");
769 LOG_ERROR(
"RP2350 flash: failed to call reset core state");
777 LOG_DEBUG(
"Enabling default Arm emulator stacks for RISC-V ROM calls");
781 LOG_ERROR(
"Failed to allocate memory for arguments to set_varmulet_user_stack()");
790 LOG_ERROR(
"Failed to initialise memory arguments for set_varmulet_user_stack()");
795 uint32_t set_stack_register_args[1] = {
799 set_stack_register_args,
ARRAY_SIZE(set_stack_register_args));
802 LOG_ERROR(
"Failed to initialise Arm emulation stacks for RISC-V");
808 LOG_DEBUG(
"Connecting flash IOs and issuing XIP exit sequence to flash");
811 .
pc =
priv->jump_connect_internal_flash,
812 .sp =
priv->stack->address +
priv->stack->size
815 .pc =
priv->jump_flash_exit_xip,
816 .sp =
priv->stack->address +
priv->stack->size
821 LOG_ERROR(
"RP2xxx flash: failed to exit flash XIP mode");
834 LOG_DEBUG(
"Flushing flash cache after write behind");
838 .
pc =
priv->jump_flush_cache,
839 .sp =
priv->stack->address +
priv->stack->size
842 .sp =
priv->stack->address +
priv->stack->size
846 int num_finishing_calls = 1;
851 finishing_calls[num_finishing_calls++].
pc =
priv->jump_enter_cmd_xip;
852 }
else if (
priv->jump_flash_reset_address_trans) {
854 finishing_calls[num_finishing_calls++].
pc =
priv->jump_flash_reset_address_trans;
859 LOG_ERROR(
"RP2xxx: failed to flush flash cache/restore XIP");
870 LOG_DEBUG(
"Cleaning up after flash operations");
874 if (
priv->accessctrl_dirty) {
876 priv->accessctrl_dirty =
false;
884 LOG_WARNING(
"RP2xxx: security state was not restored properly. Debug 'resume' will probably fail, use 'reset' instead");
891 if (
priv->ram_algo_space) {
893 priv->ram_algo_space = 0;
913 goto cleanup_and_return;
921 LOG_ERROR(
"Could not allocate bounce buffer for flash programming. Can't continue");
922 goto cleanup_and_return;
928 uint32_t write_size =
count > chunk_size ? chunk_size :
count;
929 LOG_DEBUG(
"Writing %" PRIu32
" bytes to offset 0x%" PRIx32,
933 LOG_ERROR(
"Could not load data into target bounce buffer");
945 LOG_ERROR(
"Failed to invoke flash programming code on target");
974 uint32_t offset_start =
bank->sectors[first].offset;
975 uint32_t offset_last =
bank->sectors[last].offset +
bank->sectors[last].size;
976 uint32_t
length = offset_last - offset_start;
977 LOG_DEBUG(
"erase %" PRIu32
" bytes starting at 0x%" PRIx32,
982 goto cleanup_and_return;
984 uint32_t offset_next = offset_start;
989 const uint32_t erase_chunk_size = 128 * 1024;
992 bool requires_loud_prints = offset_last - offset_next >= 2 * erase_chunk_size;
995 while (offset_next < offset_last) {
996 uint32_t remaining = offset_last - offset_next;
997 uint32_t call_size = remaining < erase_chunk_size ? remaining : erase_chunk_size;
999 if (offset_next % erase_chunk_size != 0 && call_size == erase_chunk_size)
1000 call_size = erase_chunk_size - offset_next % erase_chunk_size;
1003 " Erase chunk: 0x%08" PRIx32
" -> 0x%08" PRIx32,
1005 offset_next + call_size - 1
1011 uint32_t args[4] = {
1024 offset_next += call_size;
1059 const uint8_t *tx,
unsigned int tx_len,
1060 unsigned int dummy_len,
1061 uint8_t *rx,
unsigned int rx_len)
1063 int retval, retval2;
1071 unsigned int tx_cnt = 0;
1072 unsigned int rx_cnt = 0;
1073 unsigned int xfer_len = tx_len + dummy_len + rx_len;
1074 while (rx_cnt < xfer_len) {
1075 int in_flight = tx_cnt - rx_cnt;
1076 if (tx_cnt < xfer_len && in_flight < 14) {
1077 uint32_t
dr = tx_cnt < tx_len ? tx[tx_cnt] : 0;
1090 if (rx_cnt >= tx_len + dummy_len)
1091 rx[rx_cnt - tx_len - dummy_len] = (uint8_t)
dr;
1110 const uint8_t *tx,
unsigned int tx_len,
1111 unsigned int dummy_len,
1112 uint8_t *rx,
unsigned int rx_len)
1114 uint32_t direct_csr;
1117 LOG_ERROR(
"QMI DIRECT_CSR read failed");
1123 LOG_ERROR(
"QMI DIRECT mode enable failed");
1127 unsigned int tx_cnt = 0;
1128 unsigned int rx_cnt = 0;
1129 unsigned int xfer_len = tx_len + dummy_len + rx_len;
1130 while (tx_cnt < xfer_len || rx_cnt < rx_len) {
1131 int in_flight = tx_cnt - tx_len - dummy_len - rx_cnt;
1132 if (tx_cnt < xfer_len && in_flight < 4) {
1134 if (tx_cnt < tx_len)
1136 else if (tx_cnt < tx_len + dummy_len)
1148 if (rx_cnt < rx_len) {
1154 rx[rx_cnt] = (uint8_t)
dr;
1168 LOG_ERROR(
"QMI DIRECT mode disable failed");
1174 const uint8_t *tx,
unsigned int tx_len,
1175 unsigned int dummy_len,
1176 uint8_t *rx,
unsigned int rx_len)
1190 unsigned int words, uint32_t *
buffer)
1195 uint8_t data[4 * words +
priv->sfdp_dummy_detect];
1200 data, 4 * words +
priv->sfdp_dummy_detect);
1204 if (
priv->sfdp_dummy_detect) {
1205 for (
unsigned int i = 0; i <
priv->sfdp_dummy_detect; i++)
1207 priv->sfdp_dummy_detect = 0;
1208 priv->sfdp_dummy = i;
1211 for (
unsigned int i = 0; i < words; i++)
1214 for (
unsigned int i = 0; i < words; i++)
1227 LOG_ERROR(
"SYSINFO CHIP_ID read failed");
1231 LOG_ERROR(
"Unknown SYSINFO CHIP_ID 0x%08" PRIx32,
priv->id);
1243 uint32_t flash_id = 0;
1244 if (
priv->size_override) {
1245 priv->spi_dev.name =
"size override";
1246 LOG_DEBUG(
"SPI flash autodetection disabled, using configured size");
1266 if (p->device_id == flash_id) {
1268 bank->size = p->size_in_bytes;
1274 if (
bank->size == 0) {
1275 priv->sfdp_dummy_detect = 8;
1276 priv->sfdp_dummy = 0;
1279 bank->size =
priv->spi_dev.size_in_bytes;
1285 snprintf(
priv->dev_name,
sizeof(
priv->dev_name),
"%s rev %u",
1289 if (
bank->size == 0) {
1290 LOG_ERROR(
"%s, QSPI Flash id = 0x%06" PRIx32
" not recognised",
1291 priv->dev_name, flash_id);
1297 if (
priv->size_override) {
1298 LOG_INFO(
"%s, QSPI Flash size override = %u KiB in %u sectors",
1301 LOG_INFO(
"%s, QSPI Flash %s id = 0x%06" PRIx32
" size = %u KiB in %u sectors",
1302 priv->dev_name,
priv->spi_dev.name, flash_id,
1303 bank->size / 1024,
bank->num_sectors);
1306 free(
bank->sectors);
1311 priv->probed =
true;
1333 priv->size_override =
bank->size != 0;
1372 uint32_t args[4] = { 0 };
1384 goto cleanup_and_return;
1394 goto cleanup_and_return;
1430 if (
bank->target == old_target) {
1431 bank->target = new_target;
1433 priv->probed =
false;
1435 }
else if (
bank->target == new_target) {
1441 command_print(
CMD,
"Neither old nor new target %s found in flash bank list",
1448 .
name =
"rom_api_call",
1450 .help =
"arbitrary ROM API call",
1451 .usage =
"fc [p0 [p1 [p2 [p3]]]]",
1452 .handler = rp2xxx_rom_api_call_handler,
1455 .name =
"_switch_target",
1457 .help =
"internal use",
1458 .usage =
"old_target new_target",
1459 .handler = rp2xxx_switch_target_handler,
1468 .help =
"rp2xxx flash controller commands",
1478 .flash_bank_command = rp2xxx_flash_bank_command,
static bool is_arm(struct arm *arm)
static struct arm * target_to_arm(const struct target *target)
Convert target handle to generic ARM target state handle.
#define ARMV7M_COMMON_MAGIC
Support functions to access arbitrary bits in a byte array.
void command_print(struct command_invocation *cmd, const char *format,...)
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#define ERROR_COMMAND_SYNTAX_ERROR
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
#define COMMAND_PARSE_NUMBER(type, in, out)
parses the string in into out as a type, or prints a command error and passes the error code to the c...
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
#define ERROR_COMMAND_ARGUMENT_INVALID
int cortex_m_security_restore(struct target *target, struct cortex_m_saved_security *ssec)
Restores saved security context to MPU_CTRL, SAU_CTRL and DSCSR.
int cortex_m_set_secure(struct target *target, struct cortex_m_saved_security *ssec)
Forces Cortex-M core to the basic secure context with SAU and MPU off.
uint64_t buffer
Pointer to data buffer to send over SPI.
static struct esp_usb_jtag * priv
#define ERROR_FLASH_BANK_INVALID
struct flash_sector * alloc_block_array(uint32_t offset, uint32_t size, unsigned int num_blocks)
Allocate and fill an array of sectors or protection blocks.
int default_flash_blank_check(struct flash_bank *bank)
Provides default erased-bank check handling.
int default_flash_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
Provides default read implementation for flash memory.
void default_flash_free_driver_priv(struct flash_bank *bank)
Deallocates bank->driver_priv.
struct flash_bank * flash_bank_list(void)
#define LOG_CUSTOM_LEVEL(level, expr ...)
#define LOG_WARNING(expr ...)
#define ERROR_BUF_TOO_SMALL
#define LOG_TARGET_DEBUG(target, fmt_str,...)
#define LOG_ERROR(expr ...)
#define LOG_INFO(expr ...)
#define LOG_DEBUG(expr ...)
#define RP2350_QMI_DIRECT_CSR
#define RP2040_QSPI_CTRL_OUTOVER_LOW
static const uint8_t rp2xxx_rom_call_batch_algo_riscv[ROM_CALL_BATCH_ALGO_SIZE_BYTES]
#define RP2350_QMI_DIRECT_RX
#define LOG_ROM_SYMBOL_DEBUG
#define RP2350_QMI_DIRECT_TX
#define FUNC_FLASH_RANGE_ERASE
static int rp2350_init_arm_core0(struct target *target, struct rp2xxx_flash_bank *priv)
static int rp2350_a0_lookup_symbol(struct target *target, uint16_t tag, uint16_t flags, uint16_t *symbol_out)
static const struct command_registration rp2xxx_command_handler[]
static const int rp2xxx_rom_call_batch_algo_bkpt_offset
#define BOOTROM_RP2350_MAGIC
static int rp2xxx_call_rom_func(struct target *target, struct rp2xxx_flash_bank *priv, uint16_t func_offset, uint32_t argdata[], unsigned int n_args)
#define RP2040_QSPI_CTRL_OUTOVER_MASK
#define RT_FLAG_FUNC_RISCV
#define FUNC_FLASH_FLUSH_CACHE
static const uint8_t rcp_init_code[]
static int rp2xxx_flash_probe(struct flash_bank *bank)
static int rp2xxx_invalidate_cache_restore_xip(struct target *target, struct rp2xxx_flash_bank *priv)
static int rp2350_init_accessctrl(struct target *target, struct rp2xxx_flash_bank *priv)
#define RP2040_QSPI_CTRL_OUTOVER_HIGH
const struct flash_driver rp2xxx_flash
#define FUNC_FLASH_RESET_ADDRESS_TRANS
#define RP2350_QMI_DIRECT_CSR_EN
#define ROM_CALL_BATCH_ALGO_SIZE_BYTES
#define FUNC_FLASH_EXIT_XIP
static const struct command_registration rp2xxx_exec_command_handlers[]
COMMAND_HANDLER(rp2xxx_rom_api_call_handler)
#define ACCESSCTRL_WRITE_PASSWORD
#define FUNC_BOOTROM_SET_STACK
#define RP2XXX_CHIP_ID_REVISION(id)
static int rp2350_save_accessctrl(struct target *target, struct rp2xxx_flash_bank *priv)
static int rp2350_restore_accessctrl(struct target *target, struct rp2xxx_flash_bank *priv)
#define BOOTROM_STATE_RESET_CURRENT_CORE
static int rp2350_spi_tx_rx(struct target *target, const uint8_t *tx, unsigned int tx_len, unsigned int dummy_len, uint8_t *rx, unsigned int rx_len)
static int rp2040_spi_tx_rx(struct target *target, const uint8_t *tx, unsigned int tx_len, unsigned int dummy_len, uint8_t *rx, unsigned int rx_len)
static void cleanup_after_raw_flash_cmd(struct target *target, struct rp2xxx_flash_bank *priv)
static int rp2xxx_spi_tx_rx(struct flash_bank *bank, const uint8_t *tx, unsigned int tx_len, unsigned int dummy_len, uint8_t *rx, unsigned int rx_len)
#define ACCESSCTRL_LOCK_DEBUG_BITS
#define RT_FLAG_FUNC_ARM_SEC
static int rp2xxx_call_rom_func_batch(struct target *target, struct rp2xxx_flash_bank *priv, struct rp2xxx_rom_call_batch_record *calls, unsigned int n_calls)
#define FUNC_BOOTROM_STATE_RESET
#define RP2XXX_MAX_RAM_ALGO_SIZE
FLASH_BANK_COMMAND_HANDLER(rp2xxx_flash_bank_command)
#define ACCESSCTRL_CFGRESET_OFFSET
#define ACCESSCTRL_LOCK_OFFSET
#define FUNC_CONNECT_INTERNAL_FLASH
#define RP2XXX_ROM_API_FIXED_FLASH_PAGE
static int rp2xxx_flash_auto_probe(struct flash_bank *bank)
static int rp2xxx_populate_rom_pointer_cache(struct target *target, struct rp2xxx_flash_bank *priv)
#define RP2350_QMI_DIRECT_TX_OE
#define BOOTROM_MAGIC_ADDR
static int rp2xxx_flash_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
static const uint8_t rp2xxx_rom_call_batch_algo_armv6m[ROM_CALL_BATCH_ALGO_SIZE_BYTES]
#define RP2XXX_ROM_API_FIXED_FLASH_SECTOR
static int rp2350_lookup_rom_symbol(struct target *target, uint32_t ptr_to_entry, uint16_t tag, uint16_t flags, uint16_t *symbol_out)
#define RP2XXX_MAX_ALGO_STACK_USAGE
#define BOOTROM_MAGIC_MASK
#define FUNC_FLASH_RANGE_PROGRAM
#define BOOTROM_RP2040_MAGIC
static const int rcp_init_code_bkpt_offset
#define RP2350_QMI_DIRECT_TX_NOPUSH
#define ACCESSCTRL_GPIO_ROM_OFFSET
static int rp2040_ssel_active(struct target *target, bool active)
static int rp2xxx_read_sfdp_block(struct flash_bank *bank, uint32_t addr, unsigned int words, uint32_t *buffer)
#define RP2XXX_SYSINFO_CHIP_ID
#define ACCESSCTRL_SAVE_BASE
#define RP2350_QMI_DIRECT_CSR_ASSERT_CS0N
static int rp2040_lookup_rom_symbol(struct target *target, uint16_t tag, uint16_t flags, uint16_t *symbol_out)
static int setup_for_raw_flash_cmd(struct target *target, struct rp2xxx_flash_bank *priv)
static int rp2xxx_flash_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
static int rp2xxx_lookup_rom_symbol(struct target *target, uint16_t tag, uint16_t flags, uint16_t *symbol_out)
static const uint8_t rp2xxx_rom_call_batch_algo_armv8m[ROM_CALL_BATCH_ALGO_SIZE_BYTES]
#define FUNC_FLASH_ENTER_CMD_XIP
#define ACCESSCTRL_SAVE_SIZE
target_addr_t addr
Start address to search for the control block.
int spi_sfdp(struct flash_bank *bank, struct flash_device *dev, read_sfdp_block_t read_sfdp_block)
const struct flash_device flash_devices[]
#define SPIFLASH_READ_SFDP
unsigned int common_magic
Provides details of a flash bank, available either on-chip or through a major interface.
Provides the implementation-independent structure that defines all of the callbacks required by OpenO...
const char * name
Gives a human-readable name of this flash driver, This field is used to select and initialize the dri...
uint16_t jump_connect_internal_flash
struct cortex_m_saved_security saved_security
uint16_t jump_flash_reset_address_trans
uint8_t saved_accessctrl[ACCESSCTRL_SAVE_SIZE]
uint16_t jump_flash_range_erase
uint16_t jump_bootrom_reset_state
uint16_t jump_enter_cmd_xip
struct working_area * stack
unsigned int sfdp_dummy_detect
struct working_area * ram_algo_space
uint16_t jump_flush_cache
uint16_t jump_flash_exit_xip
struct flash_device spi_dev
uint16_t jump_bootrom_set_varm_stack
uint16_t jump_flash_range_program
struct target * get_target(const char *id)
void target_buffer_set_u32(struct target *target, uint8_t *buffer, uint32_t value)
int target_write_buffer(struct target *target, target_addr_t address, uint32_t size, const uint8_t *buffer)
int target_run_algorithm(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_param, target_addr_t entry_point, target_addr_t exit_point, unsigned int timeout_ms, void *arch_info)
Downloads a target-specific native code algorithm to the target, and executes it.
int target_write_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
Write count items of size bytes to the memory of target at the address given.
uint32_t target_get_working_area_avail(struct target *target)
int target_alloc_working_area(struct target *target, uint32_t size, struct working_area **area)
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
int target_free_working_area(struct target *target, struct working_area *area)
Free a working area.
int target_read_u16(struct target *target, target_addr_t address, uint16_t *value)
int target_read_u32(struct target *target, target_addr_t address, uint32_t *value)
int target_read_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
Read count items of size bytes from the memory of target at the address given.
struct target * get_current_target(struct command_context *cmd_ctx)
void target_buffer_set_u32_array(struct target *target, uint8_t *buffer, uint32_t count, const uint32_t *srcbuf)
uint32_t target_buffer_get_u32(struct target *target, const uint8_t *buffer)
#define ERROR_TARGET_NOT_HALTED
static const char * target_name(const struct target *target)
Returns the instance-specific name of the specified target.
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
static uint32_t le_to_h_u24(const uint8_t *buf)
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.
static void h_u24_to_be(uint8_t *buf, unsigned int val)
static uint32_t le_to_h_u32(const uint8_t *buf)