OpenOCD
hpm_xpi.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: BSD-3-Clause
2 /*
3  * Copyright (c) 2025 hpmicro
4  */
5 
6 #ifdef HAVE_CONFIG_H
7 #include "config.h"
8 #endif
9 #include "imp.h"
10 #include <helper/bits.h>
11 #include <helper/binarybuffer.h>
12 #include <helper/time_support.h>
13 #include <target/algorithm.h>
14 #include <target/image.h>
15 #include "target/riscv/program.h"
16 #include "target/riscv/riscv.h"
17 
18 #include "../../../contrib/loaders/flash/hpmicro/hpm_xpi_flash.h"
19 static uint8_t flash_algo[] = {
20 #include "../../../contrib/loaders/flash/hpmicro/hpm_xpi_flash.inc"
21 };
22 #define TIMEOUT_IN_MS (10000U)
23 #define ERASE_CHIP_TIMEOUT_IN_MS (100000U)
24 #define SECTOR_ERASE_TIMEOUT_IN_MS (100)
25 #define TYPICAL_TIMEOUT_IN_MS (500U)
26 #define BLOCK_SIZE (4096U)
27 #define NOR_CFG_OPT_HEADER (0xFCF90000UL)
28 
32 };
33 
34 struct hpm_xpi_priv {
35  uint32_t io_base;
36  uint32_t header;
37  uint32_t opt0;
38  uint32_t opt1;
39  bool probed;
40 };
41 
43  target_addr_t algo_entry)
44 {
45  struct reg_param reg_params[6];
46  struct target *target = bank->target;
47  struct hpm_xpi_priv *xpi_priv = bank->driver_priv;
48 
49  int xlen = riscv_xlen(target);
50  init_reg_param(&reg_params[0], "a0", xlen, PARAM_IN_OUT);
51  init_reg_param(&reg_params[1], "a1", xlen, PARAM_OUT);
52  init_reg_param(&reg_params[2], "a2", xlen, PARAM_OUT);
53  init_reg_param(&reg_params[3], "a3", xlen, PARAM_OUT);
54  init_reg_param(&reg_params[4], "a4", xlen, PARAM_OUT);
55  init_reg_param(&reg_params[5], "ra", xlen, PARAM_OUT);
56  buf_set_u64(reg_params[0].value, 0, xlen, bank->base);
57  buf_set_u64(reg_params[1].value, 0, xlen, xpi_priv->header);
58  buf_set_u64(reg_params[2].value, 0, xlen, xpi_priv->opt0);
59  buf_set_u64(reg_params[3].value, 0, xlen, xpi_priv->opt1);
60  buf_set_u64(reg_params[4].value, 0, xlen, xpi_priv->io_base);
61  buf_set_u64(reg_params[5].value, 0, xlen, algo_entry + FLASH_INIT + 4);
62  struct riscv_algorithm algorithm_info = {
64  };
65  int retval = target_run_algorithm(target, 0, NULL, ARRAY_SIZE(reg_params), reg_params,
66  algo_entry, algo_entry + FLASH_INIT + 4, TYPICAL_TIMEOUT_IN_MS, &algorithm_info);
67  if (retval != ERROR_OK) {
68  LOG_ERROR("Failed to execute run algorithm: %d", retval);
69  goto err;
70  }
71 
72  uint32_t stat = buf_get_u32(reg_params[0].value, 0, xlen);
73  if (stat) {
74  retval = ERROR_TARGET_FAILURE;
75  LOG_ERROR("init flash failed on target: 0x%" PRIx32, retval);
76  goto err;
77  }
78 
79 err:
80  for (size_t k = 0; k < ARRAY_SIZE(reg_params); k++)
81  destroy_reg_param(&reg_params[k]);
82 
83  return retval;
84 }
85 
86 static int hpm_xpi_probe(struct flash_bank *bank)
87 {
88  struct hpm_flash_info flash_info = {0};
89  struct working_area *data_wa = NULL;
90  struct flash_sector *sectors = NULL;
91  struct working_area *wa;
92  struct target *target = bank->target;
93 
94  struct hpm_xpi_priv *xpi_priv = bank->driver_priv;
95 
96  if (xpi_priv->probed) {
97  xpi_priv->probed = false;
98  bank->size = 0;
99  bank->num_sectors = 0;
100  free(bank->sectors);
101  bank->sectors = NULL;
102  }
103 
104  if (target->state != TARGET_HALTED) {
105  LOG_ERROR("Target not halted");
107  }
108 
109  int retval = target_alloc_working_area(target, sizeof(flash_algo), &wa);
110  if (retval != ERROR_OK) {
111  LOG_WARNING("Couldn't allocate %zd-byte working area",
112  sizeof(flash_algo));
113  return retval;
114  }
115 
116  retval = target_write_buffer(target, wa->address,
117  sizeof(flash_algo), flash_algo);
118  if (retval != ERROR_OK) {
119  LOG_ERROR("Failed to write code to 0x%" TARGET_PRIxADDR ": %d",
120  wa->address, retval);
122  return retval;
123  }
124 
126  if (retval != ERROR_OK) {
127  LOG_ERROR("Failed to run init flash algorithm: %d", retval);
128  return retval;
129  }
130 
132  &data_wa) != ERROR_OK) {
133  LOG_WARNING("Couldn't allocate %zd-byte working area",
134  sizeof(flash_info));
135  goto err;
136  }
137 
138  int xlen = riscv_xlen(target);
139  struct reg_param reg_params[3];
140  init_reg_param(&reg_params[0], "a0", xlen, PARAM_IN_OUT);
141  init_reg_param(&reg_params[1], "a1", xlen, PARAM_OUT);
142  init_reg_param(&reg_params[2], "ra", xlen, PARAM_OUT);
143  buf_set_u64(reg_params[0].value, 0, xlen, bank->base);
144  buf_set_u64(reg_params[1].value, 0, xlen, data_wa->address);
145  buf_set_u64(reg_params[2].value, 0, xlen, wa->address + FLASH_GET_INFO + 4);
146 
147  struct riscv_algorithm algorithm_info = {
149  };
150  retval = target_run_algorithm(target, 0, NULL, ARRAY_SIZE(reg_params), reg_params,
151  wa->address + FLASH_GET_INFO, wa->address + FLASH_GET_INFO + 4, TYPICAL_TIMEOUT_IN_MS,
152  &algorithm_info);
153  if (retval != ERROR_OK) {
154  LOG_ERROR("Failed to run algorithm at: %d", retval);
155  goto err;
156  }
157 
158  uint32_t stat = buf_get_u32(reg_params[0].value, 0, xlen);
159  if (stat) {
160  retval = ERROR_TARGET_FAILURE;
161  LOG_ERROR("flash get info failed on target: 0x%" PRIx32, retval);
162  goto err;
163  }
164 
165  target_read_u32(target, data_wa->address, &flash_info.total_sz_in_bytes);
166  target_read_u32(target, data_wa->address + 4, &flash_info.sector_sz_in_bytes);
167 
168  bank->size = flash_info.total_sz_in_bytes;
169  bank->num_sectors = flash_info.total_sz_in_bytes / flash_info.sector_sz_in_bytes;
170 
171  /* create and fill sectors array */
172  sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
173  if (!sectors) {
174  LOG_ERROR("not enough memory");
175  retval = ERROR_FAIL;
176  goto err;
177  }
178 
179  for (unsigned int sector = 0; sector < bank->num_sectors; sector++) {
180  sectors[sector].offset = sector * (flash_info.sector_sz_in_bytes);
181  sectors[sector].size = flash_info.sector_sz_in_bytes;
182  sectors[sector].is_erased = -1;
183  sectors[sector].is_protected = 0;
184  }
185 
186  bank->sectors = sectors;
187  xpi_priv->probed = true;
188 
189 err:
190  for (size_t k = 0; k < ARRAY_SIZE(reg_params); k++)
191  destroy_reg_param(&reg_params[k]);
194  return retval;
195 }
196 
197 static int hpm_xpi_auto_probe(struct flash_bank *bank)
198 {
199  struct hpm_xpi_priv *xpi_priv = bank->driver_priv;
200  if (xpi_priv->probed)
201  return ERROR_OK;
202  return hpm_xpi_probe(bank);
203 }
204 
205 static int hpm_xpi_write(struct flash_bank *bank, const uint8_t *buffer,
206  uint32_t offset, uint32_t count)
207 {
208  struct working_area *data_wa = NULL;
209  struct working_area *wa = NULL;
210  uint32_t data_size = BLOCK_SIZE;
211  uint32_t left = count, i = 0;
212  struct target *target = bank->target;
213 
214  if (target->state != TARGET_HALTED) {
215  LOG_ERROR("Target not halted");
217  }
218 
219  int retval = target_alloc_working_area(target, sizeof(flash_algo), &wa);
220  if (retval != ERROR_OK) {
221  LOG_WARNING("Couldn't allocate %zd-byte working area",
222  sizeof(flash_algo));
223  return retval;
224  }
225 
226  retval = target_write_buffer(target, wa->address,
227  sizeof(flash_algo), flash_algo);
228  if (retval != ERROR_OK) {
229  LOG_ERROR("Failed to write code to 0x%" TARGET_PRIxADDR ": %d",
230  wa->address, retval);
232  return retval;
233  }
234 
236  if (retval != ERROR_OK) {
237  LOG_ERROR("Failed to run init flash algorithm: %d", retval);
238  return retval;
239  }
240 
241  /* memory buffer */
242  uint32_t avail_buffer_size;
243  avail_buffer_size = target_get_working_area_avail(target);
244  if (avail_buffer_size <= 256) {
245  /* we already allocated the writing code, but failed to get a
246  * buffer, free the algorithm */
248  LOG_WARNING("no large enough working area available, can't do block memory writes");
250  }
251 
252  data_size = MIN(data_size, avail_buffer_size);
253  retval = target_alloc_working_area(target, data_size, &data_wa);
254  if (retval != ERROR_OK) {
255  LOG_WARNING("Couldn't allocate %d-byte working area", data_size);
256  return retval;
257  }
258 
259  int xlen = riscv_xlen(target);
260  struct reg_param reg_params[4];
261  struct riscv_algorithm algorithm_info = {
263  };
264  init_reg_param(&reg_params[0], "a0", xlen, PARAM_IN_OUT);
265  init_reg_param(&reg_params[1], "a1", xlen, PARAM_OUT);
266  init_reg_param(&reg_params[2], "a2", xlen, PARAM_OUT);
267  init_reg_param(&reg_params[3], "a3", xlen, PARAM_OUT);
268 
269  while (left) {
270  uint32_t trans_size = MIN(data_size, left);
271  retval = target_write_buffer(target, data_wa->address, trans_size, buffer + i * data_size);
272  if (retval != ERROR_OK) {
273  LOG_ERROR("Failed to write buffer to 0x%" TARGET_PRIxADDR ": %d", data_wa->address, retval);
274  goto err;
275  }
276 
277  buf_set_u32(reg_params[0].value, 0, xlen, bank->base);
278  buf_set_u32(reg_params[1].value, 0, xlen, offset + i * data_size);
279  buf_set_u32(reg_params[2].value, 0, xlen, data_wa->address);
280  buf_set_u32(reg_params[3].value, 0, xlen, trans_size);
281 
282  retval = target_run_algorithm(target, 0, NULL, 4, reg_params,
284  &algorithm_info);
285  if (retval != ERROR_OK) {
286  LOG_ERROR("Failed to execute algorithm at 0x%" TARGET_PRIxADDR ": %d", wa->address, retval);
287  goto err;
288  }
289 
290  uint32_t stat = buf_get_u32(reg_params[0].value, 0, xlen);
291  if (stat) {
293  LOG_ERROR("flash write failed on target: 0x%" PRIx32, retval);
294  goto err;
295  }
296  i++;
297  left -= trans_size;
298  }
299 
300 err:
301  if (data_wa)
303 
304  for (size_t k = 0; k < ARRAY_SIZE(reg_params); k++)
305  destroy_reg_param(&reg_params[k]);
306 
308  return retval;
309 }
310 
311 static int hpm_xpi_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
312 {
313  struct target *target = bank->target;
314  struct working_area *wa = NULL;
315 
316  if (target->state != TARGET_HALTED) {
317  LOG_ERROR("Target not halted");
319  }
320 
321  int retval = target_alloc_working_area(target, sizeof(flash_algo), &wa);
322  if (retval != ERROR_OK) {
323  LOG_WARNING("Couldn't allocate %zd-byte working area",
324  sizeof(flash_algo));
325  return retval;
326  }
327 
328  retval = target_write_buffer(target, wa->address,
329  sizeof(flash_algo), flash_algo);
330  if (retval != ERROR_OK) {
331  LOG_ERROR("Failed to write code to 0x%" TARGET_PRIxADDR ": %d",
332  wa->address, retval);
334  return retval;
335  }
336 
338  if (retval != ERROR_OK) {
339  LOG_ERROR("Failed to run init flash algorithm: %d", retval);
340  return retval;
341  }
342 
343  LOG_DEBUG("from sector %u to sector %u", first, last);
344 
345  int xlen = riscv_xlen(target);
346  struct reg_param reg_params[3];
347  init_reg_param(&reg_params[0], "a0", xlen, PARAM_IN_OUT);
348  init_reg_param(&reg_params[1], "a1", xlen, PARAM_OUT);
349  init_reg_param(&reg_params[2], "a2", xlen, PARAM_OUT);
350 
351  buf_set_u32(reg_params[0].value, 0, xlen, bank->base);
352  buf_set_u32(reg_params[1].value, 0, xlen, first * bank->sectors[0].size);
353  buf_set_u32(reg_params[2].value, 0, xlen, (last - first + 1) * bank->sectors[0].size);
354 
355  struct riscv_algorithm algorithm_info = {
357  };
358  retval = target_run_algorithm(target, 0, NULL, ARRAY_SIZE(reg_params), reg_params,
359  wa->address + FLASH_ERASE, wa->address + FLASH_ERASE + 4,
360  SECTOR_ERASE_TIMEOUT_IN_MS * (last - first + 1), &algorithm_info);
361  if (retval != ERROR_OK) {
362  LOG_ERROR("Failed to execute algorithm at 0x%" TARGET_PRIxADDR ": %d", wa->address, retval);
363  goto err;
364  }
365 
366  uint32_t stat = buf_get_u32(reg_params[0].value, 0, xlen);
367  if (stat) {
369  LOG_ERROR("flash erase failed on target: 0x%" PRIx32, retval);
370  goto err;
371  }
372 
373 err:
375  for (size_t k = 0; k < ARRAY_SIZE(reg_params); k++)
376  destroy_reg_param(&reg_params[k]);
377  return retval;
378 }
379 
380 static int hpm_xpi_erase_chip(struct flash_bank *bank)
381 {
382  struct target *target = bank->target;
383  struct working_area *wa = NULL;
384 
385  if (target->state != TARGET_HALTED) {
386  LOG_ERROR("Target not halted");
388  }
389 
390  int retval = target_alloc_working_area(target, sizeof(flash_algo), &wa);
391  if (retval != ERROR_OK) {
392  LOG_WARNING("Couldn't allocate %zd-byte working area",
393  sizeof(flash_algo));
394  return retval;
395  }
396 
397  retval = target_write_buffer(target, wa->address,
398  sizeof(flash_algo), flash_algo);
399  if (retval != ERROR_OK) {
400  LOG_ERROR("Failed to write code to 0x%" TARGET_PRIxADDR ": %d",
401  wa->address, retval);
403  return retval;
404  }
405 
407  if (retval != ERROR_OK) {
408  LOG_ERROR("Failed to run init flash algorithm: %d", retval);
409  return retval;
410  }
411 
412  int xlen = riscv_xlen(target);
413  struct reg_param reg_params[1];
414  init_reg_param(&reg_params[0], "a0", xlen, PARAM_IN_OUT);
415  buf_set_u64(reg_params[0].value, 0, xlen, bank->base);
416 
417  struct riscv_algorithm algorithm_info = {
419  };
420  retval = target_run_algorithm(target, 0, NULL, ARRAY_SIZE(reg_params), reg_params,
421  wa->address + FLASH_ERASE_CHIP, wa->address + FLASH_ERASE_CHIP + 4,
422  ERASE_CHIP_TIMEOUT_IN_MS, &algorithm_info);
423  if (retval != ERROR_OK) {
424  LOG_ERROR("Failed to execute algorithm at 0x%" TARGET_PRIxADDR ": %d", wa->address, retval);
425  goto err;
426  }
427 
428  uint32_t stat = buf_get_u32(reg_params[0].value, 0, xlen);
429  if (stat) {
431  LOG_ERROR("flash erase chip failed on target: 0x%" PRIx32, retval);
432  goto err;
433  }
434 
435 err:
437  for (size_t k = 0; k < ARRAY_SIZE(reg_params); k++)
438  destroy_reg_param(&reg_params[k]);
439  return retval;
440 }
441 
442 COMMAND_HANDLER(hpm_xpi_handle_erase_chip_command)
443 {
444  int retval;
445  struct flash_bank *bank;
446  struct target *target;
447  retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
448  if (retval != ERROR_OK)
449  return retval;
450 
451  target = bank->target;
452  if (target->state != TARGET_HALTED) {
453  LOG_ERROR("Target not halted");
455  }
456 
457  return hpm_xpi_erase_chip(bank);
458 }
459 
460 static const struct command_registration hpm_xpi_exec_command_handlers[] = {
461  {
462  .name = "mass_erase",
463  .handler = hpm_xpi_handle_erase_chip_command,
464  .mode = COMMAND_EXEC,
465  .usage = "bank_id",
466  .help = "erase entire flash device",
467  },
469 };
470 
472  {
473  .name = "hpm_xpi",
474  .mode = COMMAND_ANY,
475  .help = "hpm_xpi command group",
476  .usage = "",
478  },
480 };
481 
482 FLASH_BANK_COMMAND_HANDLER(hpm_xpi_flash_bank_command)
483 {
484  struct hpm_xpi_priv *xpi_priv;
485  uint32_t io_base;
486  uint32_t header;
487  uint32_t opt0;
488  uint32_t opt1;
489 
490  if (CMD_ARGC < 7)
492 
494 
495  switch (CMD_ARGC) {
496  case 7:
498  opt1 = 0;
499  opt0 = 7;
500  break;
501  case 8:
503  opt1 = 0;
505  break;
506  case 9:
510  break;
511  default:
513  }
514  xpi_priv = malloc(sizeof(struct hpm_xpi_priv));
515  if (!xpi_priv) {
516  LOG_ERROR("not enough memory");
517  return ERROR_FAIL;
518  }
519 
520  bank->driver_priv = xpi_priv;
521  xpi_priv->io_base = io_base;
522  xpi_priv->header = header;
523  xpi_priv->opt0 = opt0;
524  xpi_priv->opt1 = opt1;
525  xpi_priv->probed = false;
526 
527  return ERROR_OK;
528 }
529 
530 const struct flash_driver hpm_xpi_flash = {
531  .name = "hpm_xpi",
532  .flash_bank_command = hpm_xpi_flash_bank_command,
533  .commands = hpm_xpi_command_handlers,
534  .erase = hpm_xpi_erase,
535  .write = hpm_xpi_write,
536  .read = default_flash_read,
537  .verify = default_flash_verify,
538  .probe = hpm_xpi_probe,
539  .auto_probe = hpm_xpi_auto_probe,
540  .erase_check = default_flash_blank_check,
541  .free_driver_priv = default_flash_free_driver_priv,
542 };
void init_reg_param(struct reg_param *param, const char *reg_name, uint32_t size, enum param_direction direction)
Definition: algorithm.c:29
void destroy_reg_param(struct reg_param *param)
Definition: algorithm.c:38
@ PARAM_OUT
Definition: algorithm.h:16
@ PARAM_IN_OUT
Definition: algorithm.h:17
Support functions to access arbitrary bits in a byte array.
static uint32_t buf_get_u32(const uint8_t *_buffer, unsigned int first, unsigned int num)
Retrieves num bits from _buffer, starting at the first bit, returning the bits in a 32-bit word.
Definition: binarybuffer.h:104
static void buf_set_u32(uint8_t *_buffer, unsigned int first, unsigned int num, uint32_t value)
Sets num bits in _buffer, starting at the first bit, using the bits in value.
Definition: binarybuffer.h:34
static void buf_set_u64(uint8_t *_buffer, unsigned int first, unsigned int num, uint64_t value)
Sets num bits in _buffer, starting at the first bit, using the bits in value.
Definition: binarybuffer.h:65
#define CALL_COMMAND_HANDLER(name, extra ...)
Use this to macro to call a command helper (or a nested handler).
Definition: command.h:123
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
Definition: command.h:161
#define ERROR_COMMAND_SYNTAX_ERROR
Definition: command.h:405
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
Definition: command.h:156
#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...
Definition: command.h:445
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:256
@ COMMAND_ANY
Definition: command.h:42
@ COMMAND_EXEC
Definition: command.h:40
uint64_t buffer
Pointer to data buffer to send over SPI.
Definition: dw-spi-helper.h:0
uint8_t bank
Definition: esirisc.c:135
#define ERROR_FLASH_OPERATION_FAILED
Definition: flash/common.h:30
int default_flash_verify(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Provides default verify implementation for flash memory.
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.
static int hpm_xpi_run_algo_flash_init(struct flash_bank *bank, target_addr_t algo_entry)
Definition: hpm_xpi.c:42
static int hpm_xpi_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: hpm_xpi.c:311
static int hpm_xpi_auto_probe(struct flash_bank *bank)
Definition: hpm_xpi.c:197
static int hpm_xpi_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: hpm_xpi.c:205
static int hpm_xpi_erase_chip(struct flash_bank *bank)
Definition: hpm_xpi.c:380
#define TIMEOUT_IN_MS
Definition: hpm_xpi.c:22
#define TYPICAL_TIMEOUT_IN_MS
Definition: hpm_xpi.c:25
static int hpm_xpi_probe(struct flash_bank *bank)
Definition: hpm_xpi.c:86
static uint8_t flash_algo[]
Definition: hpm_xpi.c:19
#define ERASE_CHIP_TIMEOUT_IN_MS
Definition: hpm_xpi.c:23
const struct command_registration hpm_xpi_command_handlers[]
Definition: hpm_xpi.c:471
static const struct command_registration hpm_xpi_exec_command_handlers[]
Definition: hpm_xpi.c:460
const struct flash_driver hpm_xpi_flash
Definition: hpm_xpi.c:530
#define NOR_CFG_OPT_HEADER
Definition: hpm_xpi.c:27
#define BLOCK_SIZE
Definition: hpm_xpi.c:26
COMMAND_HANDLER(hpm_xpi_handle_erase_chip_command)
Definition: hpm_xpi.c:442
FLASH_BANK_COMMAND_HANDLER(hpm_xpi_flash_bank_command)
Definition: hpm_xpi.c:482
#define SECTOR_ERASE_TIMEOUT_IN_MS
Definition: hpm_xpi.c:24
#define LOG_WARNING(expr ...)
Definition: log.h:144
#define ERROR_FAIL
Definition: log.h:188
#define LOG_ERROR(expr ...)
Definition: log.h:147
#define LOG_DEBUG(expr ...)
Definition: log.h:124
#define ERROR_OK
Definition: log.h:182
#define FLASH_INIT
Definition: lpc288x.c:44
#define FLASH_ERASE
Definition: mdr.c:41
#define FLASH_PROGRAM
Definition: msp432.h:64
static const struct npcx_flash_info flash_info[]
Definition: npcx.c:55
unsigned int riscv_xlen(const struct target *target)
Definition: riscv.c:6420
#define RISCV_COMMON_MAGIC
Definition: riscv.h:18
struct target * target
Definition: rtt/rtt.c:26
const char * name
Definition: command.h:239
Provides details of a flash bank, available either on-chip or through a major interface.
Definition: nor/core.h:75
Provides the implementation-independent structure that defines all of the callbacks required by OpenO...
Definition: nor/driver.h:39
const char * name
Gives a human-readable name of this flash driver, This field is used to select and initialize the dri...
Definition: nor/driver.h:44
Describes the geometry and status of a single flash sector within a flash bank.
Definition: nor/core.h:28
int is_erased
Indication of erasure status: 0 = not erased, 1 = erased, other = unknown.
Definition: nor/core.h:42
uint32_t offset
Bus offset from start of the flash chip (in bytes).
Definition: nor/core.h:30
int is_protected
Indication of protection status: 0 = unprotected/unlocked, 1 = protected/locked, other = unknown.
Definition: nor/core.h:55
uint32_t size
Number of bytes in this flash sector.
Definition: nor/core.h:32
uint32_t total_sz_in_bytes
Definition: hpm_xpi.c:30
uint32_t sector_sz_in_bytes
Definition: hpm_xpi.c:31
uint32_t opt0
Definition: hpm_xpi.c:37
uint32_t io_base
Definition: hpm_xpi.c:35
uint32_t header
Definition: hpm_xpi.c:36
uint32_t opt1
Definition: hpm_xpi.c:38
bool probed
Definition: hpm_xpi.c:39
uint8_t * value
Definition: algorithm.h:30
Architecture info for RISC-V algorithms.
Definition: riscv.h:182
unsigned int common_magic
Definition: riscv.h:183
Definition: target.h:119
enum target_state state
Definition: target.h:167
target_addr_t address
Definition: target.h:89
int target_write_buffer(struct target *target, target_addr_t address, uint32_t size, const uint8_t *buffer)
Definition: target.c:2423
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.
Definition: target.c:787
uint32_t target_get_working_area_avail(struct target *target)
Definition: target.c:2233
int target_alloc_working_area(struct target *target, uint32_t size, struct working_area **area)
Definition: target.c:2131
int target_free_working_area(struct target *target, struct working_area *area)
Free a working area.
Definition: target.c:2187
int target_read_u32(struct target *target, target_addr_t address, uint32_t *value)
Definition: target.c:2615
#define ERROR_TARGET_NOT_HALTED
Definition: target.h:818
@ TARGET_HALTED
Definition: target.h:58
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
Definition: target.h:822
#define ERROR_TARGET_FAILURE
Definition: target.h:819
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.
Definition: types.h:57
uint64_t target_addr_t
Definition: types.h:279
#define TARGET_PRIxADDR
Definition: types.h:284
#define NULL
Definition: usb.h:16
uint8_t offset[4]
Definition: vdebug.c:9
uint8_t count[4]
Definition: vdebug.c:22