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 
90 static const struct flash_ctrl_priv_data flash_priv_data_spirit3 = {
91  .die_id_reg = 0x40000000,
92  .jtag_idcode_reg = 0x40000004,
93  .flash_base = 0x10040000,
94  .flash_regs_base = 0x40001000,
95  .flash_page_size = 2048,
96  .jtag_idcode = 0x02027041,
97  .part_name = "STM32WL33 (SPIRIT3)",
98 };
99 
101  bool probed;
102  uint32_t die_id;
104 };
105 
106 static const struct flash_ctrl_priv_data *flash_ctrl[] = {
113 };
114 
115 /* flash_bank bluenrg-x 0 0 0 0 <target#> */
116 FLASH_BANK_COMMAND_HANDLER(bluenrgx_flash_bank_command)
117 {
118  struct bluenrgx_flash_bank *bluenrgx_info;
119  /* Create the bank structure */
120  bluenrgx_info = calloc(1, sizeof(*bluenrgx_info));
121 
122  /* Check allocation */
123  if (!bluenrgx_info) {
124  LOG_ERROR("failed to allocate bank structure");
125  return ERROR_FAIL;
126  }
127 
128  bank->write_start_alignment = 16;
129  bank->write_end_alignment = 16;
130 
131  bank->driver_priv = bluenrgx_info;
132 
133  bluenrgx_info->probed = false;
134 
135  if (CMD_ARGC < 6)
137 
138  return ERROR_OK;
139 }
140 
141 static inline uint32_t bluenrgx_get_flash_reg(struct flash_bank *bank, uint32_t reg_offset)
142 {
143  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
144  return bluenrgx_info->flash_ptr->flash_regs_base + reg_offset;
145 }
146 
147 static inline int bluenrgx_read_flash_reg(struct flash_bank *bank, uint32_t reg_offset, uint32_t *value)
148 {
149  return target_read_u32(bank->target, bluenrgx_get_flash_reg(bank, reg_offset), value);
150 }
151 
152 static inline int bluenrgx_write_flash_reg(struct flash_bank *bank, uint32_t reg_offset, uint32_t value)
153 {
154  return target_write_u32(bank->target, bluenrgx_get_flash_reg(bank, reg_offset), value);
155 }
156 
157 static int bluenrgx_wait_for_interrupt(struct flash_bank *bank, uint32_t interrupt_flag)
158 {
159  bool flag_raised = false;
160  for (unsigned int j = 0; j < 100; j++) {
161  uint32_t value;
163  LOG_ERROR("Register read failed");
164  return ERROR_FAIL;
165  }
166 
167  if (value & interrupt_flag) {
168  flag_raised = true;
169  break;
170  }
171  }
172 
173  /* clear the interrupt */
174  if (flag_raised) {
175  if (bluenrgx_write_flash_reg(bank, FLASH_REG_IRQRAW, interrupt_flag) != ERROR_OK) {
176  LOG_ERROR("Cannot clear interrupt flag");
177  return ERROR_FAIL;
178  }
179 
180  return ERROR_OK;
181  }
182 
183  LOG_ERROR("Erase command failed (timeout)");
184  return ERROR_TIMEOUT_REACHED;
185 }
186 
187 static inline int bluenrgx_wait_for_command(struct flash_bank *bank)
188 {
191 
192  return ERROR_FAIL;
193 }
194 
195 static int bluenrgx_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
196 {
197  int retval = ERROR_OK;
198  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
199  unsigned int num_sectors = (last - first + 1);
200  const bool mass_erase = (num_sectors == bank->num_sectors);
201  struct target *target = bank->target;
202  uint32_t address, command;
203 
204  /* check preconditions */
205  if (!bluenrgx_info->probed)
207 
208  if (bank->target->state != TARGET_HALTED) {
209  LOG_ERROR("Target not halted");
211  }
212  /* Disable blue module */
213  if (target_write_u32(target, 0x200000c0, 0) != ERROR_OK) {
214  LOG_ERROR("Blue disable failed");
215  return ERROR_FAIL;
216  }
217 
218  if (mass_erase) {
220  address = bank->base;
222  LOG_ERROR("Register write failed");
223  return ERROR_FAIL;
224  }
225 
227  (address - bank->base) >> 2) != ERROR_OK) {
228  LOG_ERROR("Register write failed");
229  return ERROR_FAIL;
230  }
231 
233  LOG_ERROR("Register write failed");
234  return ERROR_FAIL;
235  }
236 
238  return ERROR_FAIL;
239 
240  } else {
242  for (unsigned int i = first; i <= last; i++) {
243  address = bank->base+i*FLASH_PAGE_SIZE(bluenrgx_info);
244  LOG_DEBUG("address = %08" PRIx32 ", index = %u", address, i);
245 
247  LOG_ERROR("Register write failed");
248  return ERROR_FAIL;
249  }
250 
252  (address - bank->base) >> 2) != ERROR_OK) {
253  LOG_ERROR("Register write failed");
254  return ERROR_FAIL;
255  }
256 
258  LOG_ERROR("Failed");
259  return ERROR_FAIL;
260  }
261 
263  return ERROR_FAIL;
264  }
265  }
266 
267  return retval;
268 
269 }
270 
271 static int bluenrgx_write_with_loader(struct flash_bank *bank, const uint8_t *buffer,
272  uint32_t offset, uint32_t count)
273 {
274  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
275  struct target *target = bank->target;
276  uint32_t buffer_size = 16384 + 8;
277  struct working_area *write_algorithm;
278  struct working_area *write_algorithm_stack;
279  struct working_area *source;
280  uint32_t address = bank->base + offset;
281  struct reg_param reg_params[5];
282  struct mem_param mem_params[1];
283  struct armv7m_algorithm armv7m_info;
284  int retval = ERROR_OK;
285 
286  /* See contrib/loaders/flash/bluenrg-x/bluenrg-x_write.c for source and
287  * hints how to generate the data!
288  */
289  static const uint8_t bluenrgx_flash_write_code[] = {
290 #include "../../../contrib/loaders/flash/bluenrg-x/bluenrg-x_write.inc"
291  };
292 
293  if (target_alloc_working_area(target, sizeof(bluenrgx_flash_write_code),
294  &write_algorithm) != ERROR_OK) {
295  LOG_WARNING("no working area available, can't do block memory writes");
297  }
298 
299  retval = target_write_buffer(target, write_algorithm->address,
300  sizeof(bluenrgx_flash_write_code),
301  bluenrgx_flash_write_code);
302  if (retval != ERROR_OK)
303  return retval;
304 
305  /* memory buffer */
307  LOG_WARNING("no large enough working area available");
309  }
310 
311  /* Stack area */
313  &write_algorithm_stack) != ERROR_OK) {
314  LOG_DEBUG("no working area for target algorithm stack");
316  }
317 
318  armv7m_info.common_magic = ARMV7M_COMMON_MAGIC;
319  armv7m_info.core_mode = ARM_MODE_THREAD;
320 
321  init_reg_param(&reg_params[0], "r0", 32, PARAM_IN_OUT);
322  init_reg_param(&reg_params[1], "r1", 32, PARAM_OUT);
323  init_reg_param(&reg_params[2], "r2", 32, PARAM_OUT);
324  init_reg_param(&reg_params[3], "r3", 32, PARAM_OUT);
325  init_reg_param(&reg_params[4], "sp", 32, PARAM_OUT);
326  /* Put the 4th parameter at the location in the stack frame of target write() function.
327  * See contrib/loaders/flash/bluenrg-x/bluenrg-x_write.lst
328  * 34 ldr r6, [sp, #88]
329  * ^^^ offset
330  */
331  init_mem_param(&mem_params[0], write_algorithm_stack->address + 88, 32, PARAM_OUT);
332  /* Stack for target write algorithm - target write() function has
333  * __attribute__((naked)) so it does not setup the new stack frame.
334  * Therefore the stack frame uses the area from SP upwards!
335  * Interrupts are disabled and no subroutines are called from write()
336  * so no need to allocate stack below SP.
337  * TODO: remove __attribute__((naked)) and use similar parameter passing as stm32l4x */
338  buf_set_u32(reg_params[4].value, 0, 32, write_algorithm_stack->address);
339 
340  /* FIFO start address (first two words used for write and read pointers) */
341  buf_set_u32(reg_params[0].value, 0, 32, source->address);
342  /* FIFO end address (first two words used for write and read pointers) */
343  buf_set_u32(reg_params[1].value, 0, 32, source->address + source->size);
344  /* Flash memory address */
345  buf_set_u32(reg_params[2].value, 0, 32, address);
346  /* Number of bytes */
347  buf_set_u32(reg_params[3].value, 0, 32, count);
348  /* Flash register base address */
349  buf_set_u32(mem_params[0].value, 0, 32, bluenrgx_info->flash_ptr->flash_regs_base);
350 
351  LOG_DEBUG("source->address = " TARGET_ADDR_FMT, source->address);
352  LOG_DEBUG("source->address+ source->size = " TARGET_ADDR_FMT, source->address+source->size);
353  LOG_DEBUG("write_algorithm_stack->address = " TARGET_ADDR_FMT, write_algorithm_stack->address);
354  LOG_DEBUG("address = %08" PRIx32, address);
355  LOG_DEBUG("count = %08" PRIx32, count);
356 
358  buffer,
359  count/16,
360  16, /* Block size: we write in block of 16 bytes to enjoy burstwrite speed */
361  1,
362  mem_params,
363  5,
364  reg_params,
365  source->address,
366  source->size,
367  write_algorithm->address,
368  0,
369  &armv7m_info);
370 
371  if (retval == ERROR_FLASH_OPERATION_FAILED) {
372  LOG_ERROR("error executing bluenrg-x flash write algorithm");
373 
374  uint32_t error = buf_get_u32(reg_params[0].value, 0, 32);
375 
376  if (error != 0)
377  LOG_ERROR("flash write failed = %08" PRIx32, error);
378  }
379 
380  if (retval == ERROR_OK) {
381  uint32_t rp;
382  /* Read back rp and check that is valid */
383  retval = target_read_u32(target, source->address+4, &rp);
384  if (retval == ERROR_OK) {
385  if ((rp < source->address+8) || (rp > (source->address + source->size))) {
386  LOG_ERROR("flash write failed = %08" PRIx32, rp);
388  }
389  }
390  }
391 
393  target_free_working_area(target, write_algorithm);
394  target_free_working_area(target, write_algorithm_stack);
395 
396  destroy_reg_param(&reg_params[0]);
397  destroy_reg_param(&reg_params[1]);
398  destroy_reg_param(&reg_params[2]);
399  destroy_reg_param(&reg_params[3]);
400  destroy_reg_param(&reg_params[4]);
401  destroy_mem_param(&mem_params[0]);
402 
403  return retval;
404 }
405 
406 static int bluenrgx_write_without_loader(struct flash_bank *bank, const uint8_t *buffer,
407  uint32_t offset, uint32_t count)
408 {
409  struct target *target = bank->target;
410  unsigned int data_count = count / FLASH_DATA_WIDTH;
411 
412  while (data_count--) {
413  /* clear flags */
415  LOG_ERROR("Register write failed");
416  return ERROR_FAIL;
417  }
418 
420  LOG_ERROR("Register write failed");
421  return ERROR_FAIL;
422  }
423 
426  LOG_ERROR("Failed to write data");
427  return ERROR_FAIL;
428  }
429 
431  LOG_ERROR("Failed");
432  return ERROR_FAIL;
433  }
434 
436  return ERROR_FAIL;
437 
438  /* increment offset, and buffer */
441  }
442 
443  return ERROR_OK;
444 }
445 
446 static int bluenrgx_write(struct flash_bank *bank, const uint8_t *buffer,
447  uint32_t offset, uint32_t count)
448 {
449  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
450  int retval = ERROR_OK;
451 
452  /* check preconditions */
453  if (!bluenrgx_info->probed)
455 
456  if ((offset + count) > bank->size) {
457  LOG_ERROR("Requested write past beyond of flash size: (offset+count) = %" PRIu32 ", size=%" PRIu32,
458  (offset + count),
459  bank->size);
461  }
462 
463  if (bank->target->state != TARGET_HALTED) {
464  LOG_ERROR("Target not halted");
466  }
467 
468  assert(offset % FLASH_WORD_LEN == 0);
469  assert(count % FLASH_WORD_LEN == 0);
470 
472  /* if resources are not available write without a loader */
473  if (retval == ERROR_TARGET_RESOURCE_NOT_AVAILABLE) {
474  LOG_WARNING("falling back to programming without a flash loader (slower)");
476  }
477  return retval;
478 }
479 
480 static int bluenrgx_probe(struct flash_bank *bank)
481 {
482  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
483  uint32_t idcode, size_info, die_id;
484  int retval = target_read_u32(bank->target, BLUENRGLP_JTAG_REG, &idcode);
485 
486  if (retval != ERROR_OK)
487  return retval;
488 
490  && idcode != flash_priv_data_lpf.jtag_idcode
491  && idcode != flash_priv_data_spirit3.jtag_idcode) {
492  retval = target_read_u32(bank->target, BLUENRG2_JTAG_REG, &idcode);
493  if (retval != ERROR_OK)
494  return retval;
495  }
496 
497  /* Default device is BlueNRG-1 */
498  bluenrgx_info->flash_ptr = &flash_priv_data_1;
500 
501  for (size_t i = 0; i < ARRAY_SIZE(flash_ctrl); i++) {
502  if (idcode == (*flash_ctrl[i]).jtag_idcode) {
503  bluenrgx_info->flash_ptr = flash_ctrl[i];
504  bank->base = (*flash_ctrl[i]).flash_base;
505  break;
506  }
507  }
508  retval = bluenrgx_read_flash_reg(bank, FLASH_SIZE_REG, &size_info);
509  size_info = size_info & FLASH_SIZE_REG_MASK;
510  if (retval != ERROR_OK)
511  return retval;
512 
513  retval = target_read_u32(bank->target, DIE_ID_REG(bluenrgx_info), &die_id);
514  if (retval != ERROR_OK)
515  return retval;
516 
517  bank->size = (size_info + 1) * FLASH_WORD_LEN;
518  bank->num_sectors = bank->size / FLASH_PAGE_SIZE(bluenrgx_info);
519  bank->sectors = realloc(bank->sectors, sizeof(struct flash_sector) * bank->num_sectors);
520 
521  for (unsigned int i = 0; i < bank->num_sectors; i++) {
522  bank->sectors[i].offset = i * FLASH_PAGE_SIZE(bluenrgx_info);
523  bank->sectors[i].size = FLASH_PAGE_SIZE(bluenrgx_info);
524  bank->sectors[i].is_erased = -1;
525  bank->sectors[i].is_protected = 0;
526  }
527 
528  bluenrgx_info->probed = true;
529  bluenrgx_info->die_id = die_id;
530 
531  return ERROR_OK;
532 }
533 
535 {
536  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
537 
538  if (bluenrgx_info->probed)
539  return ERROR_OK;
540 
541  return bluenrgx_probe(bank);
542 }
543 
544 /* This method must return a string displaying information about the bank */
546 {
547  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
548  int mask_number, cut_number;
549 
550  if (!bluenrgx_info->probed) {
551  int retval = bluenrgx_probe(bank);
552  if (retval != ERROR_OK) {
553  command_print_sameline(cmd, "Unable to find bank information.");
554  return retval;
555  }
556  }
557 
558  mask_number = (bluenrgx_info->die_id >> 4) & 0xF;
559  cut_number = bluenrgx_info->die_id & 0xF;
560 
561  command_print_sameline(cmd, "%s - Rev: %d.%d",
562  bluenrgx_info->flash_ptr->part_name, mask_number, cut_number);
563  return ERROR_OK;
564 }
565 
566 const struct flash_driver bluenrgx_flash = {
567  .name = "bluenrg-x",
568  .flash_bank_command = bluenrgx_flash_bank_command,
569  .erase = bluenrgx_erase,
570  .protect = NULL,
571  .write = bluenrgx_write,
572  .read = default_flash_read,
573  .probe = bluenrgx_probe,
574  .erase_check = default_flash_blank_check,
575  .protect_check = NULL,
576  .auto_probe = bluenrgx_auto_probe,
577  .info = bluenrgx_get_info,
578  .free_driver_priv = default_flash_free_driver_priv,
579 };
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:229
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:106
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:271
#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:157
static uint32_t bluenrgx_get_flash_reg(struct flash_bank *bank, uint32_t reg_offset)
Definition: bluenrg-x.c:141
const struct flash_driver bluenrgx_flash
Definition: bluenrg-x.c:566
static int bluenrgx_wait_for_command(struct flash_bank *bank)
Definition: bluenrg-x.c:187
static int bluenrgx_write_without_loader(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: bluenrg-x.c:406
#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 const struct flash_ctrl_priv_data flash_priv_data_spirit3
Definition: bluenrg-x.c:90
static int bluenrgx_write_flash_reg(struct flash_bank *bank, uint32_t reg_offset, uint32_t value)
Definition: bluenrg-x.c:152
static int bluenrgx_probe(struct flash_bank *bank)
Definition: bluenrg-x.c:480
static int bluenrgx_get_info(struct flash_bank *bank, struct command_invocation *cmd)
Definition: bluenrg-x.c:545
static int bluenrgx_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: bluenrg-x.c:195
FLASH_BANK_COMMAND_HANDLER(bluenrgx_flash_bank_command)
Definition: bluenrg-x.c:116
#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:446
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:147
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:534
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:378
#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
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.
void default_flash_free_driver_priv(struct flash_bank *bank)
Deallocates bank->driver_priv.
#define LOG_WARNING(expr ...)
Definition: log.h:137
#define ERROR_FAIL
Definition: log.h:181
#define LOG_ERROR(expr ...)
Definition: log.h:140
#define ERROR_TIMEOUT_REACHED
Definition: log.h:184
#define LOG_DEBUG(expr ...)
Definition: log.h:117
#define ERROR_OK
Definition: log.h:175
struct rtt_source source
Definition: rtt/rtt.c:23
unsigned int common_magic
Definition: armv7m.h:306
enum arm_mode core_mode
Definition: armv7m.h:308
const struct flash_ctrl_priv_data * flash_ptr
Definition: bluenrg-x.c:103
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:2359
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:1283
int target_alloc_working_area(struct target *target, uint32_t size, struct working_area **area)
Definition: target.c:2078
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
Definition: target.c:2624
int target_free_working_area(struct target *target, struct working_area *area)
Free a working area.
Definition: target.c:2136
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:2550
#define ERROR_TARGET_NOT_HALTED
Definition: target.h:795
@ TARGET_HALTED
Definition: target.h:58
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
Definition: target.h:799
#define TARGET_ADDR_FMT
Definition: types.h:286
#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