OpenOCD
bluenrg-x.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /***************************************************************************
4  * Copyright (C) 2017 by Michele Sardo *
5  * msmttchr@gmail.com *
6  ***************************************************************************/
7 
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif
11 
12 #include <helper/binarybuffer.h>
13 #include "helper/types.h"
14 #include <target/algorithm.h>
15 #include <target/armv7m.h>
16 #include <target/cortex_m.h>
17 #include "imp.h"
18 #include "bluenrg-x.h"
19 
20 #define BLUENRG2_JTAG_REG (flash_priv_data_2.jtag_idcode_reg)
21 #define BLUENRGLP_JTAG_REG (flash_priv_data_lp.jtag_idcode_reg)
22 #define BLUENRGLPF_JTAG_REG (flash_priv_data_lpf.jtag_idcode_reg)
23 
24 #define DIE_ID_REG(bluenrgx_info) (bluenrgx_info->flash_ptr->die_id_reg)
25 #define JTAG_IDCODE_REG(bluenrgx_info) (bluenrgx_info->flash_ptr->jtag_idcode_reg)
26 #define FLASH_PAGE_SIZE(bluenrgx_info) (bluenrgx_info->flash_ptr->flash_page_size)
27 
28 #define FLASH_SIZE_REG_MASK (0xFFFF)
29 
31  uint32_t die_id_reg;
32  uint32_t jtag_idcode_reg;
33  uint32_t flash_base;
34  uint32_t flash_regs_base;
35  uint32_t flash_page_size;
36  uint32_t jtag_idcode;
37  char *part_name;
38 };
39 
40 static const struct flash_ctrl_priv_data flash_priv_data_1 = {
41  .die_id_reg = 0x4090001C,
42  .jtag_idcode_reg = 0x40900028,
43  .flash_base = 0x10040000,
44  .flash_regs_base = 0x40100000,
45  .flash_page_size = 2048,
46  .jtag_idcode = 0x00000000,
47  .part_name = "BLUENRG-1",
48 };
49 
50 static const struct flash_ctrl_priv_data flash_priv_data_2 = {
51  .die_id_reg = 0x4090001C,
52  .jtag_idcode_reg = 0x40900028,
53  .flash_base = 0x10040000,
54  .flash_regs_base = 0x40100000,
55  .flash_page_size = 2048,
56  .jtag_idcode = 0x0200A041,
57  .part_name = "BLUENRG-2",
58 };
59 
60 static const struct flash_ctrl_priv_data flash_priv_data_lp = {
61  .die_id_reg = 0x40000000,
62  .jtag_idcode_reg = 0x40000004,
63  .flash_base = 0x10040000,
64  .flash_regs_base = 0x40001000,
65  .flash_page_size = 2048,
66  .jtag_idcode = 0x0201E041,
67  .part_name = "STM32WB07 (BLUENRG-LP)",
68 };
69 
70 static const struct flash_ctrl_priv_data flash_priv_data_lps = {
71  .die_id_reg = 0x40000000,
72  .jtag_idcode_reg = 0x40000004,
73  .flash_base = 0x10040000,
74  .flash_regs_base = 0x40001000,
75  .flash_page_size = 2048,
76  .jtag_idcode = 0x02028041,
77  .part_name = "STM32WB05 (BLUENRG-LPS)",
78 };
79 
80 static const struct flash_ctrl_priv_data flash_priv_data_lpf = {
81  .die_id_reg = 0x40000000,
82  .jtag_idcode_reg = 0x40000004,
83  .flash_base = 0x10040000,
84  .flash_regs_base = 0x40001000,
85  .flash_page_size = 2048,
86  .jtag_idcode = 0x02032041,
87  .part_name = "STM32WB09 (BLUENRG-LPF)",
88 };
89 
91  bool probed;
92  uint32_t die_id;
94 };
95 
96 static const struct flash_ctrl_priv_data *flash_ctrl[] = {
102 };
103 
104 /* flash_bank bluenrg-x 0 0 0 0 <target#> */
105 FLASH_BANK_COMMAND_HANDLER(bluenrgx_flash_bank_command)
106 {
107  struct bluenrgx_flash_bank *bluenrgx_info;
108  /* Create the bank structure */
109  bluenrgx_info = calloc(1, sizeof(*bluenrgx_info));
110 
111  /* Check allocation */
112  if (!bluenrgx_info) {
113  LOG_ERROR("failed to allocate bank structure");
114  return ERROR_FAIL;
115  }
116 
117  bank->write_start_alignment = 16;
118  bank->write_end_alignment = 16;
119 
120  bank->driver_priv = bluenrgx_info;
121 
122  bluenrgx_info->probed = false;
123 
124  if (CMD_ARGC < 6)
126 
127  return ERROR_OK;
128 }
129 
130 static inline uint32_t bluenrgx_get_flash_reg(struct flash_bank *bank, uint32_t reg_offset)
131 {
132  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
133  return bluenrgx_info->flash_ptr->flash_regs_base + reg_offset;
134 }
135 
136 static inline int bluenrgx_read_flash_reg(struct flash_bank *bank, uint32_t reg_offset, uint32_t *value)
137 {
138  return target_read_u32(bank->target, bluenrgx_get_flash_reg(bank, reg_offset), value);
139 }
140 
141 static inline int bluenrgx_write_flash_reg(struct flash_bank *bank, uint32_t reg_offset, uint32_t value)
142 {
143  return target_write_u32(bank->target, bluenrgx_get_flash_reg(bank, reg_offset), value);
144 }
145 
146 static int bluenrgx_wait_for_interrupt(struct flash_bank *bank, uint32_t interrupt_flag)
147 {
148  bool flag_raised = false;
149  for (unsigned int j = 0; j < 100; j++) {
150  uint32_t value;
152  LOG_ERROR("Register read failed");
153  return ERROR_FAIL;
154  }
155 
156  if (value & interrupt_flag) {
157  flag_raised = true;
158  break;
159  }
160  }
161 
162  /* clear the interrupt */
163  if (flag_raised) {
164  if (bluenrgx_write_flash_reg(bank, FLASH_REG_IRQRAW, interrupt_flag) != ERROR_OK) {
165  LOG_ERROR("Cannot clear interrupt flag");
166  return ERROR_FAIL;
167  }
168 
169  return ERROR_OK;
170  }
171 
172  LOG_ERROR("Erase command failed (timeout)");
173  return ERROR_TIMEOUT_REACHED;
174 }
175 
176 static inline int bluenrgx_wait_for_command(struct flash_bank *bank)
177 {
180 
181  return ERROR_FAIL;
182 }
183 
184 static int bluenrgx_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
185 {
186  int retval = ERROR_OK;
187  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
188  unsigned int num_sectors = (last - first + 1);
189  const bool mass_erase = (num_sectors == bank->num_sectors);
190  struct target *target = bank->target;
191  uint32_t address, command;
192 
193  /* check preconditions */
194  if (!bluenrgx_info->probed)
196 
197  if (bank->target->state != TARGET_HALTED) {
198  LOG_ERROR("Target not halted");
200  }
201  /* Disable blue module */
202  if (target_write_u32(target, 0x200000c0, 0) != ERROR_OK) {
203  LOG_ERROR("Blue disable failed");
204  return ERROR_FAIL;
205  }
206 
207  if (mass_erase) {
209  address = bank->base;
211  LOG_ERROR("Register write failed");
212  return ERROR_FAIL;
213  }
214 
216  (address - bank->base) >> 2) != ERROR_OK) {
217  LOG_ERROR("Register write failed");
218  return ERROR_FAIL;
219  }
220 
222  LOG_ERROR("Register write failed");
223  return ERROR_FAIL;
224  }
225 
227  return ERROR_FAIL;
228 
229  } else {
231  for (unsigned int i = first; i <= last; i++) {
232  address = bank->base+i*FLASH_PAGE_SIZE(bluenrgx_info);
233  LOG_DEBUG("address = %08" PRIx32 ", index = %u", address, i);
234 
236  LOG_ERROR("Register write failed");
237  return ERROR_FAIL;
238  }
239 
241  (address - bank->base) >> 2) != ERROR_OK) {
242  LOG_ERROR("Register write failed");
243  return ERROR_FAIL;
244  }
245 
247  LOG_ERROR("Failed");
248  return ERROR_FAIL;
249  }
250 
252  return ERROR_FAIL;
253  }
254  }
255 
256  return retval;
257 
258 }
259 
260 static int bluenrgx_write_with_loader(struct flash_bank *bank, const uint8_t *buffer,
261  uint32_t offset, uint32_t count)
262 {
263  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
264  struct target *target = bank->target;
265  uint32_t buffer_size = 16384 + 8;
266  struct working_area *write_algorithm;
267  struct working_area *write_algorithm_stack;
268  struct working_area *source;
269  uint32_t address = bank->base + offset;
270  struct reg_param reg_params[5];
271  struct mem_param mem_params[1];
272  struct armv7m_algorithm armv7m_info;
273  int retval = ERROR_OK;
274 
275  /* See contrib/loaders/flash/bluenrg-x/bluenrg-x_write.c for source and
276  * hints how to generate the data!
277  */
278  static const uint8_t bluenrgx_flash_write_code[] = {
279 #include "../../../contrib/loaders/flash/bluenrg-x/bluenrg-x_write.inc"
280  };
281 
282  if (target_alloc_working_area(target, sizeof(bluenrgx_flash_write_code),
283  &write_algorithm) != ERROR_OK) {
284  LOG_WARNING("no working area available, can't do block memory writes");
286  }
287 
288  retval = target_write_buffer(target, write_algorithm->address,
289  sizeof(bluenrgx_flash_write_code),
290  bluenrgx_flash_write_code);
291  if (retval != ERROR_OK)
292  return retval;
293 
294  /* memory buffer */
296  LOG_WARNING("no large enough working area available");
298  }
299 
300  /* Stack area */
302  &write_algorithm_stack) != ERROR_OK) {
303  LOG_DEBUG("no working area for target algorithm stack");
305  }
306 
307  armv7m_info.common_magic = ARMV7M_COMMON_MAGIC;
308  armv7m_info.core_mode = ARM_MODE_THREAD;
309 
310  init_reg_param(&reg_params[0], "r0", 32, PARAM_IN_OUT);
311  init_reg_param(&reg_params[1], "r1", 32, PARAM_OUT);
312  init_reg_param(&reg_params[2], "r2", 32, PARAM_OUT);
313  init_reg_param(&reg_params[3], "r3", 32, PARAM_OUT);
314  init_reg_param(&reg_params[4], "sp", 32, PARAM_OUT);
315  /* Put the 4th parameter at the location in the stack frame of target write() function.
316  * See contrib/loaders/flash/bluenrg-x/bluenrg-x_write.lst
317  * 34 ldr r6, [sp, #88]
318  * ^^^ offset
319  */
320  init_mem_param(&mem_params[0], write_algorithm_stack->address + 88, 32, PARAM_OUT);
321  /* Stack for target write algorithm - target write() function has
322  * __attribute__((naked)) so it does not setup the new stack frame.
323  * Therefore the stack frame uses the area from SP upwards!
324  * Interrupts are disabled and no subroutines are called from write()
325  * so no need to allocate stack below SP.
326  * TODO: remove __attribute__((naked)) and use similar parameter passing as stm32l4x */
327  buf_set_u32(reg_params[4].value, 0, 32, write_algorithm_stack->address);
328 
329  /* FIFO start address (first two words used for write and read pointers) */
330  buf_set_u32(reg_params[0].value, 0, 32, source->address);
331  /* FIFO end address (first two words used for write and read pointers) */
332  buf_set_u32(reg_params[1].value, 0, 32, source->address + source->size);
333  /* Flash memory address */
334  buf_set_u32(reg_params[2].value, 0, 32, address);
335  /* Number of bytes */
336  buf_set_u32(reg_params[3].value, 0, 32, count);
337  /* Flash register base address */
338  buf_set_u32(mem_params[0].value, 0, 32, bluenrgx_info->flash_ptr->flash_regs_base);
339 
340  LOG_DEBUG("source->address = " TARGET_ADDR_FMT, source->address);
341  LOG_DEBUG("source->address+ source->size = " TARGET_ADDR_FMT, source->address+source->size);
342  LOG_DEBUG("write_algorithm_stack->address = " TARGET_ADDR_FMT, write_algorithm_stack->address);
343  LOG_DEBUG("address = %08" PRIx32, address);
344  LOG_DEBUG("count = %08" PRIx32, count);
345 
347  buffer,
348  count/16,
349  16, /* Block size: we write in block of 16 bytes to enjoy burstwrite speed */
350  1,
351  mem_params,
352  5,
353  reg_params,
354  source->address,
355  source->size,
356  write_algorithm->address,
357  0,
358  &armv7m_info);
359 
360  if (retval == ERROR_FLASH_OPERATION_FAILED) {
361  LOG_ERROR("error executing bluenrg-x flash write algorithm");
362 
363  uint32_t error = buf_get_u32(reg_params[0].value, 0, 32);
364 
365  if (error != 0)
366  LOG_ERROR("flash write failed = %08" PRIx32, error);
367  }
368 
369  if (retval == ERROR_OK) {
370  uint32_t rp;
371  /* Read back rp and check that is valid */
372  retval = target_read_u32(target, source->address+4, &rp);
373  if (retval == ERROR_OK) {
374  if ((rp < source->address+8) || (rp > (source->address + source->size))) {
375  LOG_ERROR("flash write failed = %08" PRIx32, rp);
377  }
378  }
379  }
380 
382  target_free_working_area(target, write_algorithm);
383  target_free_working_area(target, write_algorithm_stack);
384 
385  destroy_reg_param(&reg_params[0]);
386  destroy_reg_param(&reg_params[1]);
387  destroy_reg_param(&reg_params[2]);
388  destroy_reg_param(&reg_params[3]);
389  destroy_reg_param(&reg_params[4]);
390  destroy_mem_param(&mem_params[0]);
391 
392  return retval;
393 }
394 
395 static int bluenrgx_write_without_loader(struct flash_bank *bank, const uint8_t *buffer,
396  uint32_t offset, uint32_t count)
397 {
398  struct target *target = bank->target;
399  unsigned int data_count = count / FLASH_DATA_WIDTH;
400 
401  while (data_count--) {
402  /* clear flags */
404  LOG_ERROR("Register write failed");
405  return ERROR_FAIL;
406  }
407 
409  LOG_ERROR("Register write failed");
410  return ERROR_FAIL;
411  }
412 
415  LOG_ERROR("Failed to write data");
416  return ERROR_FAIL;
417  }
418 
420  LOG_ERROR("Failed");
421  return ERROR_FAIL;
422  }
423 
425  return ERROR_FAIL;
426 
427  /* increment offset, and buffer */
430  }
431 
432  return ERROR_OK;
433 }
434 
435 static int bluenrgx_write(struct flash_bank *bank, const uint8_t *buffer,
436  uint32_t offset, uint32_t count)
437 {
438  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
439  int retval = ERROR_OK;
440 
441  /* check preconditions */
442  if (!bluenrgx_info->probed)
444 
445  if ((offset + count) > bank->size) {
446  LOG_ERROR("Requested write past beyond of flash size: (offset+count) = %" PRIu32 ", size=%" PRIu32,
447  (offset + count),
448  bank->size);
450  }
451 
452  if (bank->target->state != TARGET_HALTED) {
453  LOG_ERROR("Target not halted");
455  }
456 
457  assert(offset % FLASH_WORD_LEN == 0);
458  assert(count % FLASH_WORD_LEN == 0);
459 
461  /* if resources are not available write without a loader */
462  if (retval == ERROR_TARGET_RESOURCE_NOT_AVAILABLE) {
463  LOG_WARNING("falling back to programming without a flash loader (slower)");
465  }
466  return retval;
467 }
468 
469 static int bluenrgx_probe(struct flash_bank *bank)
470 {
471  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
472  uint32_t idcode, size_info, die_id;
473  int retval = target_read_u32(bank->target, BLUENRGLP_JTAG_REG, &idcode);
474 
475  if (retval != ERROR_OK)
476  return retval;
477 
479  && idcode != flash_priv_data_lpf.jtag_idcode) {
480  retval = target_read_u32(bank->target, BLUENRG2_JTAG_REG, &idcode);
481  if (retval != ERROR_OK)
482  return retval;
483  }
484 
485  /* Default device is BlueNRG-1 */
486  bluenrgx_info->flash_ptr = &flash_priv_data_1;
488 
489  for (size_t i = 0; i < ARRAY_SIZE(flash_ctrl); i++) {
490  if (idcode == (*flash_ctrl[i]).jtag_idcode) {
491  bluenrgx_info->flash_ptr = flash_ctrl[i];
492  bank->base = (*flash_ctrl[i]).flash_base;
493  break;
494  }
495  }
496  retval = bluenrgx_read_flash_reg(bank, FLASH_SIZE_REG, &size_info);
497  size_info = size_info & FLASH_SIZE_REG_MASK;
498  if (retval != ERROR_OK)
499  return retval;
500 
501  retval = target_read_u32(bank->target, DIE_ID_REG(bluenrgx_info), &die_id);
502  if (retval != ERROR_OK)
503  return retval;
504 
505  bank->size = (size_info + 1) * FLASH_WORD_LEN;
506  bank->num_sectors = bank->size / FLASH_PAGE_SIZE(bluenrgx_info);
507  bank->sectors = realloc(bank->sectors, sizeof(struct flash_sector) * bank->num_sectors);
508 
509  for (unsigned int i = 0; i < bank->num_sectors; i++) {
510  bank->sectors[i].offset = i * FLASH_PAGE_SIZE(bluenrgx_info);
511  bank->sectors[i].size = FLASH_PAGE_SIZE(bluenrgx_info);
512  bank->sectors[i].is_erased = -1;
513  bank->sectors[i].is_protected = 0;
514  }
515 
516  bluenrgx_info->probed = true;
517  bluenrgx_info->die_id = die_id;
518 
519  return ERROR_OK;
520 }
521 
523 {
524  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
525 
526  if (bluenrgx_info->probed)
527  return ERROR_OK;
528 
529  return bluenrgx_probe(bank);
530 }
531 
532 /* This method must return a string displaying information about the bank */
534 {
535  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
536  int mask_number, cut_number;
537 
538  if (!bluenrgx_info->probed) {
539  int retval = bluenrgx_probe(bank);
540  if (retval != ERROR_OK) {
541  command_print_sameline(cmd, "Unable to find bank information.");
542  return retval;
543  }
544  }
545 
546  mask_number = (bluenrgx_info->die_id >> 4) & 0xF;
547  cut_number = bluenrgx_info->die_id & 0xF;
548 
549  command_print_sameline(cmd, "%s - Rev: %d.%d",
550  bluenrgx_info->flash_ptr->part_name, mask_number, cut_number);
551  return ERROR_OK;
552 }
553 
554 const struct flash_driver bluenrgx_flash = {
555  .name = "bluenrg-x",
556  .flash_bank_command = bluenrgx_flash_bank_command,
557  .erase = bluenrgx_erase,
558  .protect = NULL,
559  .write = bluenrgx_write,
560  .read = default_flash_read,
561  .probe = bluenrgx_probe,
562  .erase_check = default_flash_blank_check,
563  .protect_check = NULL,
564  .auto_probe = bluenrgx_auto_probe,
565  .info = bluenrgx_get_info,
566 };
void destroy_mem_param(struct mem_param *param)
Definition: algorithm.c:23
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
void init_mem_param(struct mem_param *param, uint32_t address, uint32_t size, enum param_direction direction)
Definition: algorithm.c:15
@ PARAM_OUT
Definition: algorithm.h:16
@ PARAM_IN_OUT
Definition: algorithm.h:17
@ ARM_MODE_THREAD
Definition: arm.h:94
#define ARMV7M_COMMON_MAGIC
Definition: armv7m.h:224
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 const struct flash_ctrl_priv_data * flash_ctrl[]
Definition: bluenrg-x.c:96
static const struct flash_ctrl_priv_data flash_priv_data_lp
Definition: bluenrg-x.c:60
static int bluenrgx_write_with_loader(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: bluenrg-x.c:260
#define DIE_ID_REG(bluenrgx_info)
Definition: bluenrg-x.c:24
#define FLASH_PAGE_SIZE(bluenrgx_info)
Definition: bluenrg-x.c:26
static int bluenrgx_wait_for_interrupt(struct flash_bank *bank, uint32_t interrupt_flag)
Definition: bluenrg-x.c:146
static uint32_t bluenrgx_get_flash_reg(struct flash_bank *bank, uint32_t reg_offset)
Definition: bluenrg-x.c:130
const struct flash_driver bluenrgx_flash
Definition: bluenrg-x.c:554
static int bluenrgx_wait_for_command(struct flash_bank *bank)
Definition: bluenrg-x.c:176
static int bluenrgx_write_without_loader(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: bluenrg-x.c:395
#define BLUENRG2_JTAG_REG
Definition: bluenrg-x.c:20
static const struct flash_ctrl_priv_data flash_priv_data_2
Definition: bluenrg-x.c:50
static int bluenrgx_write_flash_reg(struct flash_bank *bank, uint32_t reg_offset, uint32_t value)
Definition: bluenrg-x.c:141
static int bluenrgx_probe(struct flash_bank *bank)
Definition: bluenrg-x.c:469
static int bluenrgx_get_info(struct flash_bank *bank, struct command_invocation *cmd)
Definition: bluenrg-x.c:533
static int bluenrgx_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: bluenrg-x.c:184
FLASH_BANK_COMMAND_HANDLER(bluenrgx_flash_bank_command)
Definition: bluenrg-x.c:105
#define FLASH_SIZE_REG_MASK
Definition: bluenrg-x.c:28
static int bluenrgx_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: bluenrg-x.c:435
static const struct flash_ctrl_priv_data flash_priv_data_lps
Definition: bluenrg-x.c:70
static int bluenrgx_read_flash_reg(struct flash_bank *bank, uint32_t reg_offset, uint32_t *value)
Definition: bluenrg-x.c:136
static const struct flash_ctrl_priv_data flash_priv_data_lpf
Definition: bluenrg-x.c:80
#define BLUENRGLP_JTAG_REG
Definition: bluenrg-x.c:21
static int bluenrgx_auto_probe(struct flash_bank *bank)
Definition: bluenrg-x.c:522
static const struct flash_ctrl_priv_data flash_priv_data_1
Definition: bluenrg-x.c:40
#define FLASH_INT_CMDSTART
Definition: bluenrg-x.h:31
#define FLASH_REG_DATA0
Definition: bluenrg-x.h:19
#define FLASH_SIZE_REG
Definition: bluenrg-x.h:23
#define FLASH_INT_CMDDONE
Definition: bluenrg-x.h:30
#define FLASH_CMD_ERASE_PAGE
Definition: bluenrg-x.h:26
#define FLASH_REG_COMMAND
Definition: bluenrg-x.h:11
#define FLASH_DATA_WIDTH_W
Definition: bluenrg-x.h:35
#define FLASH_WORD_LEN
Definition: bluenrg-x.h:34
#define FLASH_REG_ADDRESS
Definition: bluenrg-x.h:16
#define FLASH_CMD_MASSERASE
Definition: bluenrg-x.h:27
#define FLASH_REG_IRQRAW
Definition: bluenrg-x.h:15
#define FLASH_DATA_WIDTH
Definition: bluenrg-x.h:36
#define FLASH_CMD_BURSTWRITE
Definition: bluenrg-x.h:29
void command_print_sameline(struct command_invocation *cmd, const char *format,...)
Definition: command.c:352
#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
static int mass_erase(struct target *target, uint16_t *hfm_ustat)
Executes the FM mass erase command.
Definition: dsp5680xx.c:1854
uint64_t buffer
Pointer to data buffer to send over SPI.
Definition: dw-spi-helper.h:0
uint32_t buffer_size
Size of dw_spi_program::buffer.
Definition: dw-spi-helper.h:5
uint32_t address
Starting address. Sector aligned.
Definition: dw-spi-helper.h:0
uint8_t bank
Definition: esirisc.c:135
#define ERROR_FLASH_BANK_NOT_PROBED
Definition: flash/common.h:35
#define ERROR_FLASH_OPERATION_FAILED
Definition: flash/common.h:30
#define ERROR_FLASH_DST_OUT_OF_BANK
Definition: flash/common.h:31
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.
#define LOG_WARNING(expr ...)
Definition: log.h:130
#define ERROR_FAIL
Definition: log.h:174
#define LOG_ERROR(expr ...)
Definition: log.h:133
#define ERROR_TIMEOUT_REACHED
Definition: log.h:177
#define LOG_DEBUG(expr ...)
Definition: log.h:110
#define ERROR_OK
Definition: log.h:168
struct rtt_source source
Definition: rtt/rtt.c:23
unsigned int common_magic
Definition: armv7m.h:299
enum arm_mode core_mode
Definition: armv7m.h:301
const struct flash_ctrl_priv_data * flash_ptr
Definition: bluenrg-x.c:93
When run_command is called, a new instance will be created on the stack, filled with the proper value...
Definition: command.h:76
Provides details of a flash bank, available either on-chip or through a major interface.
Definition: nor/core.h:75
uint32_t flash_base
Definition: bluenrg-x.c:33
uint32_t flash_page_size
Definition: bluenrg-x.c:35
uint32_t jtag_idcode_reg
Definition: bluenrg-x.c:32
uint32_t jtag_idcode
Definition: bluenrg-x.c:36
uint32_t die_id_reg
Definition: bluenrg-x.c:31
uint32_t flash_regs_base
Definition: bluenrg-x.c:34
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
Definition: target.h:119
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_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.
Definition: target.c:1275
int target_alloc_working_area(struct target *target, uint32_t size, struct working_area **area)
Definition: target.c:2070
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
Definition: target.c:2650
int target_free_working_area(struct target *target, struct working_area *area)
Free a working area.
Definition: target.c:2128
int target_run_flash_async_algorithm(struct target *target, const uint8_t *buffer, uint32_t count, int block_size, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, uint32_t buffer_start, uint32_t buffer_size, uint32_t entry_point, uint32_t exit_point, void *arch_info)
Streams data to a circular buffer on target intended for consumption by code running asynchronously o...
Definition: target.c:940
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 TARGET_ADDR_FMT
Definition: types.h:342
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.
Definition: types.h:57
#define NULL
Definition: usb.h:16
uint8_t cmd
Definition: vdebug.c:1
uint8_t offset[4]
Definition: vdebug.c:9
uint8_t count[4]
Definition: vdebug.c:22