17 #define BOOTROM_RP2040_MAGIC 0x01754d
19 #define BOOTROM_RP2350_MAGIC 0x02754d
20 #define BOOTROM_MAGIC_MASK 0xffffff
21 #define BOOTROM_MAGIC_ADDR 0x00000010
23 #define MAKE_TAG(a, b) (((b)<<8) | a)
24 #define FUNC_FLASH_EXIT_XIP MAKE_TAG('E', 'X')
25 #define FUNC_CONNECT_INTERNAL_FLASH MAKE_TAG('I', 'F')
26 #define FUNC_FLASH_RANGE_ERASE MAKE_TAG('R', 'E')
27 #define FUNC_FLASH_RANGE_PROGRAM MAKE_TAG('R', 'P')
28 #define FUNC_FLASH_FLUSH_CACHE MAKE_TAG('F', 'C')
29 #define FUNC_FLASH_ENTER_CMD_XIP MAKE_TAG('C', 'X')
30 #define FUNC_BOOTROM_STATE_RESET MAKE_TAG('S', 'R')
31 #define FUNC_BOOTROM_SET_STACK MAKE_TAG('S', 'S')
32 #define FUNC_FLASH_RESET_ADDRESS_TRANS MAKE_TAG('R', 'A')
35 #define RT_FLAG_FUNC_RISCV 0x01
36 #define RT_FLAG_FUNC_ARM_SEC 0x04
37 #define RT_FLAG_FUNC_ARM_NONSEC 0x10
38 #define RT_FLAG_DATA 0x40
41 #define BOOTROM_STATE_RESET_CURRENT_CORE 0x01
42 #define BOOTROM_STATE_RESET_OTHER_CORE 0x02
43 #define BOOTROM_STATE_RESET_GLOBAL_STATE 0x04
45 #define ACCESSCTRL_LOCK_OFFSET 0x40060000u
46 #define ACCESSCTRL_CFGRESET_OFFSET 0x40060008u
47 #define ACCESSCTRL_GPIO_NSMASK0_OFFSET 0x4006000cu
48 #define ACCESSCTRL_GPIO_ROM_OFFSET 0x40060014u
49 #define ACCESSCTRL_GPIO_XIP_AUX_OFFSET 0x400600e8u
51 #define ACCESSCTRL_SAVE_BASE ACCESSCTRL_GPIO_NSMASK0_OFFSET
52 #define ACCESSCTRL_SAVE_SIZE \
53 (ACCESSCTRL_GPIO_XIP_AUX_OFFSET + 4 - ACCESSCTRL_SAVE_BASE)
55 #define ACCESSCTRL_LOCK_DEBUG_BITS 0x00000008u
56 #define ACCESSCTRL_WRITE_PASSWORD 0xacce0000u
58 #define RP2040_SSI_DR0 0x18000060
59 #define RP2040_QSPI_CTRL 0x4001800c
61 #define RP2040_QSPI_CTRL_OUTOVER_MASK (3ul << 8)
62 #define RP2040_QSPI_CTRL_OUTOVER_LOW (2ul << 8)
63 #define RP2040_QSPI_CTRL_OUTOVER_HIGH (3ul << 8)
65 #define RP2350_QMI_DIRECT_CSR 0x400d0000
66 #define RP2350_QMI_DIRECT_TX 0x400d0004
67 #define RP2350_QMI_DIRECT_RX 0x400d0008
69 #define RP2350_QMI_DIRECT_CSR_EN BIT(0)
70 #define RP2350_QMI_DIRECT_CSR_ASSERT_CS0N BIT(2)
71 #define RP2350_QMI_DIRECT_TX_NOPUSH BIT(20)
72 #define RP2350_QMI_DIRECT_TX_OE BIT(19)
74 #define RP2XXX_SYSINFO_CHIP_ID 0x40000000
75 #define RP2XXX_CHIP_ID_PART_MANUFACTURER(id) ((id) & 0x0fffffff)
76 #define RP2XXX_CHIP_ID_MANUFACTURER 0x493
77 #define RP2XXX_MK_PART(part) (((part) << 12) | (RP2XXX_CHIP_ID_MANUFACTURER << 1) | 1)
78 #define RP2040_CHIP_ID_PART 0x0002
79 #define IS_RP2040(id) (RP2XXX_CHIP_ID_PART_MANUFACTURER(id) == RP2XXX_MK_PART(RP2040_CHIP_ID_PART))
80 #define RP2350_CHIP_ID_PART 0x0004
81 #define IS_RP2350(id) (RP2XXX_CHIP_ID_PART_MANUFACTURER(id) == RP2XXX_MK_PART(RP2350_CHIP_ID_PART))
82 #define RP2XXX_CHIP_ID_REVISION(id) ((id) >> 28)
84 #define RP2XXX_MAX_ALGO_STACK_USAGE 1024
85 #define RP2XXX_MAX_RAM_ALGO_SIZE 1024
87 #define RP2XXX_ROM_API_FIXED_FLASH_PAGE 256
88 #define RP2XXX_ROM_API_FIXED_FLASH_SECTOR 4096
106 0x5f, 0xf4, 0x40, 0x41,
109 0x30, 0xee, 0x10, 0xf7,
112 0x40, 0xec, 0x80, 0x07,
113 0x40, 0xec, 0x81, 0x07,
119 0x88, 0xed, 0x00, 0xe0
125 #define ROM_CALL_BATCH_ALGO_SIZE_BYTES 32
155 0x80, 0xf3, 0x0a, 0x88,
156 0x80, 0xf3, 0x0b, 0x88,
175 0x97, 0x04, 0x00, 0x00,
176 0x93, 0x84, 0x04, 0x02,
180 0x03, 0xa1, 0x44, 0x00,
227 #ifndef LOG_ROM_SYMBOL_DEBUG
228 #define LOG_ROM_SYMBOL_DEBUG LOG_DEBUG
233 LOG_ROM_SYMBOL_DEBUG(
"Looking up ROM symbol '%c%c' in RP2040 table", tag & 0xff, (tag >> 8) & 0xff);
237 LOG_ERROR(
"Only data and Secure Arm functions can be looked up in RP2040 ROM table");
241 uint16_t ptr_to_entry;
242 unsigned int offset_magic_to_table_ptr = flags ==
RT_FLAG_DATA ? 6 : 4;
253 if (entry_tag == tag) {
270 LOG_ROM_SYMBOL_DEBUG(
"Looking up ROM symbol '%c%c' in RP2350 A0 table", tag & 0xff, (tag >> 8) & 0xff);
284 LOG_WARNING(
"Ignoring non-default flags for RP2350 A0 lookup, hope you like Secure Arm functions");
287 uint16_t ptr_to_entry;
288 const unsigned int offset_magic_to_table_ptr = 4;
299 if (entry_tag == tag) {
314 uint16_t tag, uint16_t flags, uint16_t *symbol_out)
316 LOG_ROM_SYMBOL_DEBUG(
"Looking up ROM symbol '%c%c' in RP2350 A1 table", tag & 0xff, (tag >> 8) & 0xff);
324 uint16_t entry_tag, entry_flags;
330 if (entry_tag == 0) {
342 uint16_t matching_flags = flags & entry_flags;
344 if (tag == entry_tag && matching_flags != 0) {
347 while (!(matching_flags & 1)) {
351 matching_flags >>= 1;
357 *symbol_out = ptr_to_entry;
368 while (entry_flags) {
395 if (table_ptr < 0x7c00)
403 LOG_ERROR(
"RP2040/RP2350 BOOT ROM not found");
413 symtype_func, &
priv->jump_flash_exit_xip);
415 LOG_ERROR(
"Function FUNC_FLASH_EXIT_XIP not found in RP2xxx ROM");
420 symtype_func, &
priv->jump_connect_internal_flash);
422 LOG_ERROR(
"Function FUNC_CONNECT_INTERNAL_FLASH not found in RP2xxx ROM");
428 LOG_ERROR(
"Function FUNC_FLASH_RANGE_ERASE not found in RP2xxx ROM");
434 LOG_ERROR(
"Function FUNC_FLASH_RANGE_PROGRAM not found in RP2xxx ROM");
440 LOG_ERROR(
"Function FUNC_FLASH_FLUSH_CACHE not found in RP2xxx ROM");
446 LOG_ERROR(
"Function FUNC_FLASH_ENTER_CMD_XIP not found in RP2xxx ROM");
453 priv->jump_bootrom_reset_state = 0;
454 priv->jump_flash_reset_address_trans = 0;
460 priv->jump_bootrom_reset_state = 0;
461 LOG_WARNING(
"Function FUNC_BOOTROM_STATE_RESET not found in RP2xxx ROM. (probably an RP2350 A0)");
466 &
priv->jump_bootrom_set_varm_stack);
468 priv->jump_bootrom_set_varm_stack = 0;
469 LOG_WARNING(
"Function FUNC_BOOTROM_SET_STACK not found in RP2xxx ROM. (probably an RP2350 A0)");
474 symtype_func, &
priv->jump_flash_reset_address_trans);
476 priv->jump_flash_reset_address_trans = 0;
477 LOG_WARNING(
"Function FUNC_FLASH_RESET_ADDRESS_TRANS not found in RP2xxx ROM. (probably an RP2350 A0)");
492 if (!
priv->ram_algo_space) {
493 LOG_ERROR(
"No RAM code space allocated for ROM call");
496 if (
priv->ram_algo_space->size < batch_size) {
497 LOG_ERROR(
"RAM code space too small for call batch size of %u", n_calls);
502 for (
unsigned int i = 0; i < n_calls; ++i) {
505 for (
unsigned int j = 0; j < 4; ++j)
510 LOG_DEBUG(
"Returning early from call of 0 ROM functions");
514 const uint8_t *algo_code;
517 LOG_DEBUG(
"Using algo: rp2xxx_rom_call_batch_algo_armv8m");
520 LOG_DEBUG(
"Using algo: rp2xxx_rom_call_batch_algo_armv6m");
524 LOG_DEBUG(
"Using algo: rp2xxx_rom_call_batch_algo_riscv");
528 uint8_t *batch_bf = malloc(batch_size);
538 (
const uint32_t *)calls);
543 priv->ram_algo_space->address,
550 LOG_ERROR(
"Failed to write ROM batch algorithm to RAM code space");
558 unsigned int algo_timeout_ms = 3000;
566 algo_start_addr, algo_end_addr,
578 algo_start_addr, algo_end_addr,
584 LOG_ERROR(
"Failed to call ROM function batch");
598 uint16_t func_offset, uint32_t argdata[],
unsigned int n_args)
603 LOG_ERROR(
"no stack for flash programming code");
612 for (
unsigned int i = 0; i < n_args; ++i)
613 call.
args[i] = argdata[i];
621 priv->saved_accessctrl);
634 priv->saved_accessctrl);
639 priv->accessctrl_dirty =
false;
643 uint32_t accessctrl_lock_reg;
645 LOG_ERROR(
"Failed to read ACCESSCTRL lock register");
655 LOG_ERROR(
"ACCESSCTRL is locked, so can't reset permissions. Following steps might fail");
659 priv->accessctrl_dirty =
true;
664 LOG_DEBUG(
"Reset ACCESSCTRL permissions via CFGRESET");
678 LOG_ERROR(
"RP2350 init ARM core: set secure mode failed");
683 LOG_ERROR(
"No stack for flash programming code");
688 LOG_ERROR(
"No algorithm space for rcp_init code");
693 priv->ram_algo_space->address,
699 LOG_ERROR(
"Failed to load rcp_init algorithm into RAM");
704 priv->ram_algo_space->address);
713 priv->ram_algo_space->address,
734 LOG_ERROR(
"Could not allocate stack for flash programming code -- insufficient space");
739 if (!
priv->ram_algo_space) {
742 LOG_ERROR(
"Could not allocate RAM code space for ROM calls -- insufficient space");
750 LOG_ERROR(
"Failed to init ACCESSCTRL before ROM call");
756 LOG_ERROR(
"Failed to init Arm core 0 before ROM call");
760 uint32_t reset_args[1] = {
763 if (!
priv->jump_bootrom_reset_state) {
764 LOG_WARNING(
"RP2350 flash: no bootrom_reset_method");
773 LOG_ERROR(
"RP2350 flash: failed to call reset core state");
781 LOG_DEBUG(
"Enabling default Arm emulator stacks for RISC-V ROM calls");
785 LOG_ERROR(
"Failed to allocate memory for arguments to set_varmulet_user_stack()");
794 LOG_ERROR(
"Failed to initialise memory arguments for set_varmulet_user_stack()");
799 uint32_t set_stack_register_args[1] = {
803 set_stack_register_args,
ARRAY_SIZE(set_stack_register_args));
806 LOG_ERROR(
"Failed to initialise Arm emulation stacks for RISC-V");
812 LOG_DEBUG(
"Connecting flash IOs and issuing XIP exit sequence to flash");
815 .
pc =
priv->jump_connect_internal_flash,
816 .sp =
priv->stack->address +
priv->stack->size
819 .pc =
priv->jump_flash_exit_xip,
820 .sp =
priv->stack->address +
priv->stack->size
825 LOG_ERROR(
"RP2xxx flash: failed to exit flash XIP mode");
838 LOG_DEBUG(
"Flushing flash cache after write behind");
842 .
pc =
priv->jump_flush_cache,
843 .sp =
priv->stack->address +
priv->stack->size
846 .sp =
priv->stack->address +
priv->stack->size
850 int num_finishing_calls = 1;
855 finishing_calls[num_finishing_calls++].
pc =
priv->jump_enter_cmd_xip;
856 }
else if (
priv->jump_flash_reset_address_trans) {
858 finishing_calls[num_finishing_calls++].
pc =
priv->jump_flash_reset_address_trans;
863 LOG_ERROR(
"RP2xxx: failed to flush flash cache/restore XIP");
874 LOG_DEBUG(
"Cleaning up after flash operations");
878 if (
priv->accessctrl_dirty) {
880 priv->accessctrl_dirty =
false;
888 LOG_WARNING(
"RP2xxx: security state was not restored properly. Debug 'resume' will probably fail, use 'reset' instead");
895 if (
priv->ram_algo_space) {
897 priv->ram_algo_space = 0;
917 goto cleanup_and_return;
925 LOG_ERROR(
"Could not allocate bounce buffer for flash programming. Can't continue");
926 goto cleanup_and_return;
932 uint32_t write_size =
count > chunk_size ? chunk_size :
count;
933 LOG_DEBUG(
"Writing %" PRIu32
" bytes to offset 0x%" PRIx32,
937 LOG_ERROR(
"Could not load data into target bounce buffer");
949 LOG_ERROR(
"Failed to invoke flash programming code on target");
978 uint32_t offset_start =
bank->sectors[first].offset;
979 uint32_t offset_last =
bank->sectors[last].offset +
bank->sectors[last].size;
980 uint32_t
length = offset_last - offset_start;
981 LOG_DEBUG(
"erase %" PRIu32
" bytes starting at 0x%" PRIx32,
986 goto cleanup_and_return;
988 uint32_t offset_next = offset_start;
993 const uint32_t erase_chunk_size = 128 * 1024;
996 bool requires_loud_prints = offset_last - offset_next >= 2 * erase_chunk_size;
999 while (offset_next < offset_last) {
1000 uint32_t remaining = offset_last - offset_next;
1001 uint32_t call_size = remaining < erase_chunk_size ? remaining : erase_chunk_size;
1003 if (offset_next % erase_chunk_size != 0 && call_size == erase_chunk_size)
1004 call_size = erase_chunk_size - offset_next % erase_chunk_size;
1007 " Erase chunk: 0x%08" PRIx32
" -> 0x%08" PRIx32,
1009 offset_next + call_size - 1
1015 uint32_t args[4] = {
1028 offset_next += call_size;
1063 const uint8_t *tx,
unsigned int tx_len,
1064 unsigned int dummy_len,
1065 uint8_t *rx,
unsigned int rx_len)
1067 int retval, retval2;
1075 unsigned int tx_cnt = 0;
1076 unsigned int rx_cnt = 0;
1077 unsigned int xfer_len = tx_len + dummy_len + rx_len;
1078 while (rx_cnt < xfer_len) {
1079 int in_flight = tx_cnt - rx_cnt;
1080 if (tx_cnt < xfer_len && in_flight < 14) {
1081 uint32_t
dr = tx_cnt < tx_len ? tx[tx_cnt] : 0;
1094 if (rx_cnt >= tx_len + dummy_len)
1095 rx[rx_cnt - tx_len - dummy_len] = (uint8_t)
dr;
1114 const uint8_t *tx,
unsigned int tx_len,
1115 unsigned int dummy_len,
1116 uint8_t *rx,
unsigned int rx_len)
1118 uint32_t direct_csr;
1121 LOG_ERROR(
"QMI DIRECT_CSR read failed");
1127 LOG_ERROR(
"QMI DIRECT mode enable failed");
1131 unsigned int tx_cnt = 0;
1132 unsigned int rx_cnt = 0;
1133 unsigned int xfer_len = tx_len + dummy_len + rx_len;
1134 while (tx_cnt < xfer_len || rx_cnt < rx_len) {
1135 int in_flight = tx_cnt - tx_len - dummy_len - rx_cnt;
1136 if (tx_cnt < xfer_len && in_flight < 4) {
1138 if (tx_cnt < tx_len)
1140 else if (tx_cnt < tx_len + dummy_len)
1152 if (rx_cnt < rx_len) {
1158 rx[rx_cnt] = (uint8_t)
dr;
1172 LOG_ERROR(
"QMI DIRECT mode disable failed");
1178 const uint8_t *tx,
unsigned int tx_len,
1179 unsigned int dummy_len,
1180 uint8_t *rx,
unsigned int rx_len)
1194 unsigned int words, uint32_t *
buffer)
1199 uint8_t data[4 * words +
priv->sfdp_dummy_detect];
1204 data, 4 * words +
priv->sfdp_dummy_detect);
1208 if (
priv->sfdp_dummy_detect) {
1209 for (
unsigned int i = 0; i <
priv->sfdp_dummy_detect; i++)
1211 priv->sfdp_dummy_detect = 0;
1212 priv->sfdp_dummy = i;
1215 for (
unsigned int i = 0; i < words; i++)
1218 for (
unsigned int i = 0; i < words; i++)
1231 LOG_ERROR(
"SYSINFO CHIP_ID read failed");
1235 LOG_ERROR(
"Unknown SYSINFO CHIP_ID 0x%08" PRIx32,
priv->id);
1247 uint32_t flash_id = 0;
1248 if (
priv->size_override) {
1249 priv->spi_dev.name =
"size override";
1250 LOG_DEBUG(
"SPI flash autodetection disabled, using configured size");
1270 if (p->device_id == flash_id) {
1272 bank->size = p->size_in_bytes;
1278 if (
bank->size == 0) {
1279 priv->sfdp_dummy_detect = 8;
1280 priv->sfdp_dummy = 0;
1283 bank->size =
priv->spi_dev.size_in_bytes;
1289 snprintf(
priv->dev_name,
sizeof(
priv->dev_name),
"%s rev %u",
1293 if (
bank->size == 0) {
1294 LOG_ERROR(
"%s, QSPI Flash id = 0x%06" PRIx32
" not recognised",
1295 priv->dev_name, flash_id);
1301 if (
priv->size_override) {
1302 LOG_INFO(
"%s, QSPI Flash size override = %u KiB in %u sectors",
1305 LOG_INFO(
"%s, QSPI Flash %s id = 0x%06" PRIx32
" size = %u KiB in %u sectors",
1306 priv->dev_name,
priv->spi_dev.name, flash_id,
1307 bank->size / 1024,
bank->num_sectors);
1310 free(
bank->sectors);
1315 priv->probed =
true;
1337 priv->size_override =
bank->size != 0;
1376 uint32_t args[4] = { 0 };
1388 goto cleanup_and_return;
1398 goto cleanup_and_return;
1434 if (
bank->target == old_target) {
1435 bank->target = new_target;
1437 priv->probed =
false;
1439 }
else if (
bank->target == new_target) {
1445 command_print(
CMD,
"Neither old nor new target %s found in flash bank list",
1452 .
name =
"rom_api_call",
1454 .help =
"arbitrary ROM API call",
1455 .usage =
"fc [p0 [p1 [p2 [p3]]]]",
1456 .handler = rp2xxx_rom_api_call_handler,
1459 .name =
"_switch_target",
1461 .help =
"internal use",
1462 .usage =
"old_target new_target",
1463 .handler = rp2xxx_switch_target_handler,
1472 .help =
"rp2xxx flash controller commands",
1482 .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 RISCV_COMMON_MAGIC
#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...
Architecture info for RISC-V algorithms.
unsigned int common_magic
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)