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 
17 #include "../../../contrib/loaders/flash/hpmicro/hpm_xpi_flash.h"
18 static uint8_t flash_algo[] = {
19 #include "../../../contrib/loaders/flash/hpmicro/hpm_xpi_flash.inc"
20 };
21 #define TIMEOUT_IN_MS (10000U)
22 #define ERASE_CHIP_TIMEOUT_IN_MS (100000U)
23 #define SECTOR_ERASE_TIMEOUT_IN_MS (100)
24 #define TYPICAL_TIMEOUT_IN_MS (500U)
25 #define BLOCK_SIZE (4096U)
26 #define NOR_CFG_OPT_HEADER (0xFCF90000UL)
27 
31 };
32 
33 struct hpm_xpi_priv {
34  uint32_t io_base;
35  uint32_t header;
36  uint32_t opt0;
37  uint32_t opt1;
38  bool probed;
39 };
40 
42  target_addr_t algo_entry)
43 {
44  struct reg_param reg_params[6];
45  struct target *target = bank->target;
46  struct hpm_xpi_priv *xpi_priv = bank->driver_priv;
47 
48  int xlen = riscv_xlen(target);
49  init_reg_param(&reg_params[0], "a0", xlen, PARAM_IN_OUT);
50  init_reg_param(&reg_params[1], "a1", xlen, PARAM_OUT);
51  init_reg_param(&reg_params[2], "a2", xlen, PARAM_OUT);
52  init_reg_param(&reg_params[3], "a3", xlen, PARAM_OUT);
53  init_reg_param(&reg_params[4], "a4", xlen, PARAM_OUT);
54  init_reg_param(&reg_params[5], "ra", xlen, PARAM_OUT);
55  buf_set_u64(reg_params[0].value, 0, xlen, bank->base);
56  buf_set_u64(reg_params[1].value, 0, xlen, xpi_priv->header);
57  buf_set_u64(reg_params[2].value, 0, xlen, xpi_priv->opt0);
58  buf_set_u64(reg_params[3].value, 0, xlen, xpi_priv->opt1);
59  buf_set_u64(reg_params[4].value, 0, xlen, xpi_priv->io_base);
60  buf_set_u64(reg_params[5].value, 0, xlen, algo_entry + FLASH_INIT + 4);
61  int retval = target_run_algorithm(target, 0, NULL, ARRAY_SIZE(reg_params), reg_params,
62  algo_entry, algo_entry + FLASH_INIT + 4, TYPICAL_TIMEOUT_IN_MS, NULL);
63  if (retval != ERROR_OK) {
64  LOG_ERROR("Failed to execute run algorithm: %d", retval);
65  goto err;
66  }
67 
68  uint32_t stat = buf_get_u32(reg_params[0].value, 0, xlen);
69  if (stat) {
70  retval = ERROR_TARGET_FAILURE;
71  LOG_ERROR("init flash failed on target: 0x%" PRIx32, retval);
72  goto err;
73  }
74 
75 err:
76  for (size_t k = 0; k < ARRAY_SIZE(reg_params); k++)
77  destroy_reg_param(&reg_params[k]);
78 
79  return retval;
80 }
81 
82 static int hpm_xpi_probe(struct flash_bank *bank)
83 {
84  struct hpm_flash_info flash_info = {0};
85  struct working_area *data_wa = NULL;
86  struct flash_sector *sectors = NULL;
87  struct working_area *wa;
88  struct target *target = bank->target;
89 
90  struct hpm_xpi_priv *xpi_priv = bank->driver_priv;
91 
92  if (xpi_priv->probed) {
93  xpi_priv->probed = false;
94  bank->size = 0;
95  bank->num_sectors = 0;
96  free(bank->sectors);
97  bank->sectors = NULL;
98  }
99 
100  if (target->state != TARGET_HALTED) {
101  LOG_ERROR("Target not halted");
103  }
104 
105  int retval = target_alloc_working_area(target, sizeof(flash_algo), &wa);
106  if (retval != ERROR_OK) {
107  LOG_WARNING("Couldn't allocate %zd-byte working area",
108  sizeof(flash_algo));
109  return retval;
110  }
111 
112  retval = target_write_buffer(target, wa->address,
113  sizeof(flash_algo), flash_algo);
114  if (retval != ERROR_OK) {
115  LOG_ERROR("Failed to write code to 0x%" TARGET_PRIxADDR ": %d",
116  wa->address, retval);
118  return retval;
119  }
120 
122  if (retval != ERROR_OK) {
123  LOG_ERROR("Failed to run init flash algorithm: %d", retval);
124  return retval;
125  }
126 
128  &data_wa) != ERROR_OK) {
129  LOG_WARNING("Couldn't allocate %zd-byte working area",
130  sizeof(flash_info));
131  goto err;
132  }
133 
134  int xlen = riscv_xlen(target);
135  struct reg_param reg_params[3];
136  init_reg_param(&reg_params[0], "a0", xlen, PARAM_IN_OUT);
137  init_reg_param(&reg_params[1], "a1", xlen, PARAM_OUT);
138  init_reg_param(&reg_params[2], "ra", xlen, PARAM_OUT);
139  buf_set_u64(reg_params[0].value, 0, xlen, bank->base);
140  buf_set_u64(reg_params[1].value, 0, xlen, data_wa->address);
141  buf_set_u64(reg_params[2].value, 0, xlen, wa->address + FLASH_GET_INFO + 4);
142 
143  retval = target_run_algorithm(target, 0, NULL, ARRAY_SIZE(reg_params), reg_params,
144  wa->address + FLASH_GET_INFO, wa->address + FLASH_GET_INFO + 4, TYPICAL_TIMEOUT_IN_MS, NULL);
145  if (retval != ERROR_OK) {
146  LOG_ERROR("Failed to run algorithm at: %d", retval);
147  goto err;
148  }
149 
150  uint32_t stat = buf_get_u32(reg_params[0].value, 0, xlen);
151  if (stat) {
152  retval = ERROR_TARGET_FAILURE;
153  LOG_ERROR("flash get info failed on target: 0x%" PRIx32, retval);
154  goto err;
155  }
156 
157  target_read_u32(target, data_wa->address, &flash_info.total_sz_in_bytes);
158  target_read_u32(target, data_wa->address + 4, &flash_info.sector_sz_in_bytes);
159 
160  bank->size = flash_info.total_sz_in_bytes;
161  bank->num_sectors = flash_info.total_sz_in_bytes / flash_info.sector_sz_in_bytes;
162 
163  /* create and fill sectors array */
164  sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
165  if (!sectors) {
166  LOG_ERROR("not enough memory");
167  retval = ERROR_FAIL;
168  goto err;
169  }
170 
171  for (unsigned int sector = 0; sector < bank->num_sectors; sector++) {
172  sectors[sector].offset = sector * (flash_info.sector_sz_in_bytes);
173  sectors[sector].size = flash_info.sector_sz_in_bytes;
174  sectors[sector].is_erased = -1;
175  sectors[sector].is_protected = 0;
176  }
177 
178  bank->sectors = sectors;
179  xpi_priv->probed = true;
180 
181 err:
182  for (size_t k = 0; k < ARRAY_SIZE(reg_params); k++)
183  destroy_reg_param(&reg_params[k]);
186  return retval;
187 }
188 
189 static int hpm_xpi_auto_probe(struct flash_bank *bank)
190 {
191  struct hpm_xpi_priv *xpi_priv = bank->driver_priv;
192  if (xpi_priv->probed)
193  return ERROR_OK;
194  return hpm_xpi_probe(bank);
195 }
196 
197 static int hpm_xpi_write(struct flash_bank *bank, const uint8_t *buffer,
198  uint32_t offset, uint32_t count)
199 {
200  struct working_area *data_wa = NULL;
201  struct working_area *wa = NULL;
202  uint32_t data_size = BLOCK_SIZE;
203  uint32_t left = count, i = 0;
204  struct target *target = bank->target;
205 
206  if (target->state != TARGET_HALTED) {
207  LOG_ERROR("Target not halted");
209  }
210 
211  int retval = target_alloc_working_area(target, sizeof(flash_algo), &wa);
212  if (retval != ERROR_OK) {
213  LOG_WARNING("Couldn't allocate %zd-byte working area",
214  sizeof(flash_algo));
215  return retval;
216  }
217 
218  retval = target_write_buffer(target, wa->address,
219  sizeof(flash_algo), flash_algo);
220  if (retval != ERROR_OK) {
221  LOG_ERROR("Failed to write code to 0x%" TARGET_PRIxADDR ": %d",
222  wa->address, retval);
224  return retval;
225  }
226 
228  if (retval != ERROR_OK) {
229  LOG_ERROR("Failed to run init flash algorithm: %d", retval);
230  return retval;
231  }
232 
233  /* memory buffer */
234  uint32_t avail_buffer_size;
235  avail_buffer_size = target_get_working_area_avail(target);
236  if (avail_buffer_size <= 256) {
237  /* we already allocated the writing code, but failed to get a
238  * buffer, free the algorithm */
240  LOG_WARNING("no large enough working area available, can't do block memory writes");
242  }
243 
244  data_size = MIN(data_size, avail_buffer_size);
245  retval = target_alloc_working_area(target, data_size, &data_wa);
246  if (retval != ERROR_OK) {
247  LOG_WARNING("Couldn't allocate %d-byte working area", data_size);
248  return retval;
249  }
250 
251  int xlen = riscv_xlen(target);
252  struct reg_param reg_params[4];
253  init_reg_param(&reg_params[0], "a0", xlen, PARAM_IN_OUT);
254  init_reg_param(&reg_params[1], "a1", xlen, PARAM_OUT);
255  init_reg_param(&reg_params[2], "a2", xlen, PARAM_OUT);
256  init_reg_param(&reg_params[3], "a3", xlen, PARAM_OUT);
257 
258  while (left) {
259  uint32_t trans_size = MIN(data_size, left);
260  retval = target_write_buffer(target, data_wa->address, trans_size, buffer + i * data_size);
261  if (retval != ERROR_OK) {
262  LOG_ERROR("Failed to write buffer to 0x%" TARGET_PRIxADDR ": %d", data_wa->address, retval);
263  goto err;
264  }
265 
266  buf_set_u32(reg_params[0].value, 0, xlen, bank->base);
267  buf_set_u32(reg_params[1].value, 0, xlen, offset + i * data_size);
268  buf_set_u32(reg_params[2].value, 0, xlen, data_wa->address);
269  buf_set_u32(reg_params[3].value, 0, xlen, trans_size);
270 
271  retval = target_run_algorithm(target, 0, NULL, 4, reg_params,
273  if (retval != ERROR_OK) {
274  LOG_ERROR("Failed to execute algorithm at 0x%" TARGET_PRIxADDR ": %d", wa->address, retval);
275  goto err;
276  }
277 
278  uint32_t stat = buf_get_u32(reg_params[0].value, 0, xlen);
279  if (stat) {
281  LOG_ERROR("flash write failed on target: 0x%" PRIx32, retval);
282  goto err;
283  }
284  i++;
285  left -= trans_size;
286  }
287 
288 err:
289  if (data_wa)
291 
292  for (size_t k = 0; k < ARRAY_SIZE(reg_params); k++)
293  destroy_reg_param(&reg_params[k]);
294 
296  return retval;
297 }
298 
299 static int hpm_xpi_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
300 {
301  struct target *target = bank->target;
302  struct working_area *wa = NULL;
303 
304  if (target->state != TARGET_HALTED) {
305  LOG_ERROR("Target not halted");
307  }
308 
309  int retval = target_alloc_working_area(target, sizeof(flash_algo), &wa);
310  if (retval != ERROR_OK) {
311  LOG_WARNING("Couldn't allocate %zd-byte working area",
312  sizeof(flash_algo));
313  return retval;
314  }
315 
316  retval = target_write_buffer(target, wa->address,
317  sizeof(flash_algo), flash_algo);
318  if (retval != ERROR_OK) {
319  LOG_ERROR("Failed to write code to 0x%" TARGET_PRIxADDR ": %d",
320  wa->address, retval);
322  return retval;
323  }
324 
326  if (retval != ERROR_OK) {
327  LOG_ERROR("Failed to run init flash algorithm: %d", retval);
328  return retval;
329  }
330 
331  LOG_DEBUG("from sector %u to sector %u", first, last);
332 
333  int xlen = riscv_xlen(target);
334  struct reg_param reg_params[3];
335  init_reg_param(&reg_params[0], "a0", xlen, PARAM_IN_OUT);
336  init_reg_param(&reg_params[1], "a1", xlen, PARAM_OUT);
337  init_reg_param(&reg_params[2], "a2", xlen, PARAM_OUT);
338 
339  buf_set_u32(reg_params[0].value, 0, xlen, bank->base);
340  buf_set_u32(reg_params[1].value, 0, xlen, first * bank->sectors[0].size);
341  buf_set_u32(reg_params[2].value, 0, xlen, (last - first + 1) * bank->sectors[0].size);
342 
343  retval = target_run_algorithm(target, 0, NULL, ARRAY_SIZE(reg_params), reg_params,
344  wa->address + FLASH_ERASE, wa->address + FLASH_ERASE + 4,
345  SECTOR_ERASE_TIMEOUT_IN_MS * (last - first + 1), NULL);
346  if (retval != ERROR_OK) {
347  LOG_ERROR("Failed to execute algorithm at 0x%" TARGET_PRIxADDR ": %d", wa->address, retval);
348  goto err;
349  }
350 
351  uint32_t stat = buf_get_u32(reg_params[0].value, 0, xlen);
352  if (stat) {
354  LOG_ERROR("flash erase failed on target: 0x%" PRIx32, retval);
355  goto err;
356  }
357 
358 err:
360  for (size_t k = 0; k < ARRAY_SIZE(reg_params); k++)
361  destroy_reg_param(&reg_params[k]);
362  return retval;
363 }
364 
365 static int hpm_xpi_erase_chip(struct flash_bank *bank)
366 {
367  struct target *target = bank->target;
368  struct working_area *wa = NULL;
369 
370  if (target->state != TARGET_HALTED) {
371  LOG_ERROR("Target not halted");
373  }
374 
375  int retval = target_alloc_working_area(target, sizeof(flash_algo), &wa);
376  if (retval != ERROR_OK) {
377  LOG_WARNING("Couldn't allocate %zd-byte working area",
378  sizeof(flash_algo));
379  return retval;
380  }
381 
382  retval = target_write_buffer(target, wa->address,
383  sizeof(flash_algo), flash_algo);
384  if (retval != ERROR_OK) {
385  LOG_ERROR("Failed to write code to 0x%" TARGET_PRIxADDR ": %d",
386  wa->address, retval);
388  return retval;
389  }
390 
392  if (retval != ERROR_OK) {
393  LOG_ERROR("Failed to run init flash algorithm: %d", retval);
394  return retval;
395  }
396 
397  int xlen = riscv_xlen(target);
398  struct reg_param reg_params[1];
399  init_reg_param(&reg_params[0], "a0", xlen, PARAM_IN_OUT);
400  buf_set_u64(reg_params[0].value, 0, xlen, bank->base);
401 
402  retval = target_run_algorithm(target, 0, NULL, ARRAY_SIZE(reg_params), reg_params,
403  wa->address + FLASH_ERASE_CHIP, wa->address + FLASH_ERASE_CHIP + 4, ERASE_CHIP_TIMEOUT_IN_MS, NULL);
404  if (retval != ERROR_OK) {
405  LOG_ERROR("Failed to execute algorithm at 0x%" TARGET_PRIxADDR ": %d", wa->address, retval);
406  goto err;
407  }
408 
409  uint32_t stat = buf_get_u32(reg_params[0].value, 0, xlen);
410  if (stat) {
412  LOG_ERROR("flash erase chip failed on target: 0x%" PRIx32, retval);
413  goto err;
414  }
415 
416 err:
418  for (size_t k = 0; k < ARRAY_SIZE(reg_params); k++)
419  destroy_reg_param(&reg_params[k]);
420  return retval;
421 }
422 
423 COMMAND_HANDLER(hpm_xpi_handle_erase_chip_command)
424 {
425  int retval;
426  struct flash_bank *bank;
427  struct target *target;
428  retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
429  if (retval != ERROR_OK)
430  return retval;
431 
432  target = bank->target;
433  if (target->state != TARGET_HALTED) {
434  LOG_ERROR("Target not halted");
436  }
437 
438  return hpm_xpi_erase_chip(bank);
439 }
440 
441 static const struct command_registration hpm_xpi_exec_command_handlers[] = {
442  {
443  .name = "mass_erase",
444  .handler = hpm_xpi_handle_erase_chip_command,
445  .mode = COMMAND_EXEC,
446  .usage = "bank_id",
447  .help = "erase entire flash device",
448  },
450 };
451 
453  {
454  .name = "hpm_xpi",
455  .mode = COMMAND_ANY,
456  .help = "hpm_xpi command group",
457  .usage = "",
459  },
461 };
462 
463 FLASH_BANK_COMMAND_HANDLER(hpm_xpi_flash_bank_command)
464 {
465  struct hpm_xpi_priv *xpi_priv;
466  uint32_t io_base;
467  uint32_t header;
468  uint32_t opt0;
469  uint32_t opt1;
470 
471  if (CMD_ARGC < 7)
473 
475 
476  switch (CMD_ARGC) {
477  case 7:
479  opt1 = 0;
480  opt0 = 7;
481  break;
482  case 8:
484  opt1 = 0;
486  break;
487  case 9:
491  break;
492  default:
494  }
495  xpi_priv = malloc(sizeof(struct hpm_xpi_priv));
496  if (!xpi_priv) {
497  LOG_ERROR("not enough memory");
498  return ERROR_FAIL;
499  }
500 
501  bank->driver_priv = xpi_priv;
502  xpi_priv->io_base = io_base;
503  xpi_priv->header = header;
504  xpi_priv->opt0 = opt0;
505  xpi_priv->opt1 = opt1;
506  xpi_priv->probed = false;
507 
508  return ERROR_OK;
509 }
510 
511 const struct flash_driver hpm_xpi_flash = {
512  .name = "hpm_xpi",
513  .flash_bank_command = hpm_xpi_flash_bank_command,
514  .commands = hpm_xpi_command_handlers,
515  .erase = hpm_xpi_erase,
516  .write = hpm_xpi_write,
517  .read = default_flash_read,
518  .verify = default_flash_verify,
519  .probe = hpm_xpi_probe,
520  .auto_probe = hpm_xpi_auto_probe,
521  .erase_check = default_flash_blank_check,
522  .free_driver_priv = default_flash_free_driver_priv,
523 };
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:118
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
Definition: command.h:156
#define ERROR_COMMAND_SYNTAX_ERROR
Definition: command.h:400
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
Definition: command.h:151
#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:440
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:251
@ 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:41
static int hpm_xpi_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: hpm_xpi.c:299
static int hpm_xpi_auto_probe(struct flash_bank *bank)
Definition: hpm_xpi.c:189
static int hpm_xpi_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: hpm_xpi.c:197
static int hpm_xpi_erase_chip(struct flash_bank *bank)
Definition: hpm_xpi.c:365
#define TIMEOUT_IN_MS
Definition: hpm_xpi.c:21
#define TYPICAL_TIMEOUT_IN_MS
Definition: hpm_xpi.c:24
static int hpm_xpi_probe(struct flash_bank *bank)
Definition: hpm_xpi.c:82
static uint8_t flash_algo[]
Definition: hpm_xpi.c:18
#define ERASE_CHIP_TIMEOUT_IN_MS
Definition: hpm_xpi.c:22
const struct command_registration hpm_xpi_command_handlers[]
Definition: hpm_xpi.c:452
static const struct command_registration hpm_xpi_exec_command_handlers[]
Definition: hpm_xpi.c:441
const struct flash_driver hpm_xpi_flash
Definition: hpm_xpi.c:511
#define NOR_CFG_OPT_HEADER
Definition: hpm_xpi.c:26
#define BLOCK_SIZE
Definition: hpm_xpi.c:25
COMMAND_HANDLER(hpm_xpi_handle_erase_chip_command)
Definition: hpm_xpi.c:423
FLASH_BANK_COMMAND_HANDLER(hpm_xpi_flash_bank_command)
Definition: hpm_xpi.c:463
#define SECTOR_ERASE_TIMEOUT_IN_MS
Definition: hpm_xpi.c:23
#define LOG_WARNING(expr ...)
Definition: log.h:131
#define ERROR_FAIL
Definition: log.h:175
#define LOG_ERROR(expr ...)
Definition: log.h:134
#define LOG_DEBUG(expr ...)
Definition: log.h:111
#define ERROR_OK
Definition: log.h:169
#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
#define MIN(a, b)
Definition: replacements.h:22
unsigned int riscv_xlen(const struct target *target)
Definition: riscv.c:6060
struct target * target
Definition: rtt/rtt.c:26
const char * name
Definition: command.h:234
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:29
uint32_t sector_sz_in_bytes
Definition: hpm_xpi.c:30
uint32_t opt0
Definition: hpm_xpi.c:36
uint32_t io_base
Definition: hpm_xpi.c:34
uint32_t header
Definition: hpm_xpi.c:35
uint32_t opt1
Definition: hpm_xpi.c:37
bool probed
Definition: hpm_xpi.c:38
uint8_t * value
Definition: algorithm.h:30
Definition: target.h:119
enum target_state state
Definition: target.h:160
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:2351
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:783
uint32_t target_get_working_area_avail(struct target *target)
Definition: target.c:2174
int target_alloc_working_area(struct target *target, uint32_t size, struct working_area **area)
Definition: target.c:2070
int target_free_working_area(struct target *target, struct working_area *area)
Free a working area.
Definition: target.c:2128
int target_read_u32(struct target *target, target_addr_t address, uint32_t *value)
Definition: target.c:2559
#define ERROR_TARGET_NOT_HALTED
Definition: target.h:786
@ TARGET_HALTED
Definition: target.h:58
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
Definition: target.h:790
#define ERROR_TARGET_FAILURE
Definition: target.h:787
#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