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 "helper/align.h"
15 #include <target/algorithm.h>
16 #include <target/armv7m.h>
17 #include <target/cortex_m.h>
18 #include "imp.h"
19 #include "bluenrg-x.h"
20 
21 #define BLUENRG2_JTAG_REG (flash_priv_data_2.jtag_idcode_reg)
22 #define BLUENRGLP_JTAG_REG (flash_priv_data_lp.jtag_idcode_reg)
23 #define BLUENRGLPF_JTAG_REG (flash_priv_data_lpf.jtag_idcode_reg)
24 
25 #define DIE_ID_REG(bluenrgx_info) (bluenrgx_info->flash_ptr->die_id_reg)
26 #define JTAG_IDCODE_REG(bluenrgx_info) (bluenrgx_info->flash_ptr->jtag_idcode_reg)
27 #define FLASH_PAGE_SIZE(bluenrgx_info) (bluenrgx_info->flash_ptr->flash_page_size)
28 
29 #define FLASH_SIZE_REG_MASK (0xFFFF)
30 
32  uint32_t die_id_reg;
33  uint32_t jtag_idcode_reg;
34  uint32_t flash_base;
35  uint32_t flash_regs_base;
36  uint32_t flash_page_size;
37  uint32_t jtag_idcode;
38  char *part_name;
39 };
40 
41 static const struct flash_ctrl_priv_data flash_priv_data_1 = {
42  .die_id_reg = 0x4090001C,
43  .jtag_idcode_reg = 0x40900028,
44  .flash_base = 0x10040000,
45  .flash_regs_base = 0x40100000,
46  .flash_page_size = 2048,
47  .jtag_idcode = 0x00000000,
48  .part_name = "BLUENRG-1",
49 };
50 
51 static const struct flash_ctrl_priv_data flash_priv_data_2 = {
52  .die_id_reg = 0x4090001C,
53  .jtag_idcode_reg = 0x40900028,
54  .flash_base = 0x10040000,
55  .flash_regs_base = 0x40100000,
56  .flash_page_size = 2048,
57  .jtag_idcode = 0x0200A041,
58  .part_name = "BLUENRG-2",
59 };
60 
61 static const struct flash_ctrl_priv_data flash_priv_data_lp = {
62  .die_id_reg = 0x40000000,
63  .jtag_idcode_reg = 0x40000004,
64  .flash_base = 0x10040000,
65  .flash_regs_base = 0x40001000,
66  .flash_page_size = 2048,
67  .jtag_idcode = 0x0201E041,
68  .part_name = "STM32WB07 (BLUENRG-LP)",
69 };
70 
71 static const struct flash_ctrl_priv_data flash_priv_data_lps = {
72  .die_id_reg = 0x40000000,
73  .jtag_idcode_reg = 0x40000004,
74  .flash_base = 0x10040000,
75  .flash_regs_base = 0x40001000,
76  .flash_page_size = 2048,
77  .jtag_idcode = 0x02028041,
78  .part_name = "STM32WB05 (BLUENRG-LPS)",
79 };
80 
81 static const struct flash_ctrl_priv_data flash_priv_data_lpf = {
82  .die_id_reg = 0x40000000,
83  .jtag_idcode_reg = 0x40000004,
84  .flash_base = 0x10040000,
85  .flash_regs_base = 0x40001000,
86  .flash_page_size = 2048,
87  .jtag_idcode = 0x02032041,
88  .part_name = "STM32WB09 (BLUENRG-LPF)",
89 };
90 
91 static const struct flash_ctrl_priv_data flash_priv_data_spirit3 = {
92  .die_id_reg = 0x40000000,
93  .jtag_idcode_reg = 0x40000004,
94  .flash_base = 0x10040000,
95  .flash_regs_base = 0x40001000,
96  .flash_page_size = 2048,
97  .jtag_idcode = 0x02027041,
98  .part_name = "STM32WL33/WL3R (SPIRIT3/3R)",
99 };
100 
102  bool probed;
103  uint32_t die_id;
105 };
106 
107 static const struct flash_ctrl_priv_data *flash_ctrl[] = {
114 };
115 
116 /* flash_bank bluenrg-x 0 0 0 0 <target#> */
117 FLASH_BANK_COMMAND_HANDLER(bluenrgx_flash_bank_command)
118 {
119  struct bluenrgx_flash_bank *bluenrgx_info;
120  /* Create the bank structure */
121  bluenrgx_info = calloc(1, sizeof(*bluenrgx_info));
122 
123  /* Check allocation */
124  if (!bluenrgx_info) {
125  LOG_ERROR("failed to allocate bank structure");
126  return ERROR_FAIL;
127  }
128 
129  bank->write_start_alignment = 16;
130  bank->write_end_alignment = 16;
131 
132  bank->driver_priv = bluenrgx_info;
133 
134  bluenrgx_info->probed = false;
135 
136  if (CMD_ARGC < 6)
138 
139  return ERROR_OK;
140 }
141 
142 static inline uint32_t bluenrgx_get_flash_reg(struct flash_bank *bank, uint32_t reg_offset)
143 {
144  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
145  return bluenrgx_info->flash_ptr->flash_regs_base + reg_offset;
146 }
147 
148 static inline int bluenrgx_read_flash_reg(struct flash_bank *bank, uint32_t reg_offset, uint32_t *value)
149 {
150  return target_read_u32(bank->target, bluenrgx_get_flash_reg(bank, reg_offset), value);
151 }
152 
153 static inline int bluenrgx_write_flash_reg(struct flash_bank *bank, uint32_t reg_offset, uint32_t value)
154 {
155  return target_write_u32(bank->target, bluenrgx_get_flash_reg(bank, reg_offset), value);
156 }
157 
158 static int bluenrgx_wait_for_interrupt(struct flash_bank *bank, uint32_t interrupt_flag)
159 {
160  bool flag_raised = false;
161  for (unsigned int j = 0; j < 100; j++) {
162  uint32_t value;
164  LOG_ERROR("Register read failed");
165  return ERROR_FAIL;
166  }
167 
168  if (value & interrupt_flag) {
169  flag_raised = true;
170  break;
171  }
172  }
173 
174  /* clear the interrupt */
175  if (flag_raised) {
176  if (bluenrgx_write_flash_reg(bank, FLASH_REG_IRQRAW, interrupt_flag) != ERROR_OK) {
177  LOG_ERROR("Cannot clear interrupt flag");
178  return ERROR_FAIL;
179  }
180 
181  return ERROR_OK;
182  }
183 
184  LOG_ERROR("Erase command failed (timeout)");
185  return ERROR_TIMEOUT_REACHED;
186 }
187 
188 static inline int bluenrgx_wait_for_command(struct flash_bank *bank)
189 {
192 
193  return ERROR_FAIL;
194 }
195 
196 static int bluenrgx_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
197 {
198  int retval = ERROR_OK;
199  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
200  unsigned int num_sectors = (last - first + 1);
201  const bool mass_erase = (num_sectors == bank->num_sectors);
202  struct target *target = bank->target;
203  uint32_t address, command;
204 
205  /* check preconditions */
206  if (!bluenrgx_info->probed)
208 
209  if (bank->target->state != TARGET_HALTED) {
210  LOG_ERROR("Target not halted");
212  }
213  /* Disable blue module */
214  if (target_write_u32(target, 0x200000c0, 0) != ERROR_OK) {
215  LOG_ERROR("Blue disable failed");
216  return ERROR_FAIL;
217  }
218 
219  if (mass_erase) {
221  address = bank->base;
223  LOG_ERROR("Register write failed");
224  return ERROR_FAIL;
225  }
226 
228  (address - bank->base) >> 2) != ERROR_OK) {
229  LOG_ERROR("Register write failed");
230  return ERROR_FAIL;
231  }
232 
234  LOG_ERROR("Register write failed");
235  return ERROR_FAIL;
236  }
237 
239  return ERROR_FAIL;
240 
241  } else {
243  for (unsigned int i = first; i <= last; i++) {
244  address = bank->base+i*FLASH_PAGE_SIZE(bluenrgx_info);
245  LOG_DEBUG("address = %08" PRIx32 ", index = %u", address, i);
246 
248  LOG_ERROR("Register write failed");
249  return ERROR_FAIL;
250  }
251 
253  (address - bank->base) >> 2) != ERROR_OK) {
254  LOG_ERROR("Register write failed");
255  return ERROR_FAIL;
256  }
257 
259  LOG_ERROR("Failed");
260  return ERROR_FAIL;
261  }
262 
264  return ERROR_FAIL;
265  }
266  }
267 
268  return retval;
269 
270 }
271 
272 static int bluenrgx_write_with_loader(struct flash_bank *bank, const uint8_t *buffer,
273  uint32_t offset, uint32_t count)
274 {
275  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
276  struct target *target = bank->target;
277  uint32_t max_buffer_size = 16384 + 8;
278  struct working_area *write_algorithm;
279  struct working_area *write_algorithm_stack;
280  struct working_area *source;
281  uint32_t address = bank->base + offset;
282  struct reg_param reg_params[5];
283  struct mem_param mem_params[1];
284  struct armv7m_algorithm armv7m_info;
285  int retval = ERROR_OK;
286 
287  /* See contrib/loaders/flash/bluenrg-x/bluenrg-x_write.c for source and
288  * hints how to generate the data!
289  */
290  static const uint8_t bluenrgx_flash_write_code[] = {
291 #include "../../../contrib/loaders/flash/bluenrg-x/bluenrg-x_write.inc"
292  };
293 
294  if (target_alloc_working_area(target, sizeof(bluenrgx_flash_write_code),
295  &write_algorithm) != ERROR_OK) {
296  LOG_WARNING("no working area available, can't do block memory writes");
298  }
299 
300  retval = target_write_buffer(target, write_algorithm->address,
301  sizeof(bluenrgx_flash_write_code),
302  bluenrgx_flash_write_code);
303  if (retval != ERROR_OK)
304  return retval;
305 
306  /* Compute usable buffer size by excluding 128 bytes for write_algorithm_stack
307  * and 8 bytes for read and write pointers.
308  */
309  uint32_t buffer_size = target_get_working_area_avail(target) - 128 - 8;
310  /* buffer size should be multiple of FLASH_DATA_WIDTH*/
312  buffer_size += 8;
313 
314  if (buffer_size < 256) {
315  LOG_WARNING("large enough working area not available, can't do block memory writes");
316  target_free_working_area(target, write_algorithm);
318  } else if (buffer_size > max_buffer_size) {
319  /* probably won't benefit from more than 16k ... */
320  buffer_size = max_buffer_size;
321  }
322 
323  /* memory buffer */
325  LOG_WARNING("no large enough working area available");
327  }
328 
329  /* Stack area */
331  &write_algorithm_stack) != ERROR_OK) {
332  LOG_DEBUG("no working area for target algorithm stack");
334  }
335 
336  armv7m_info.common_magic = ARMV7M_COMMON_MAGIC;
337  armv7m_info.core_mode = ARM_MODE_THREAD;
338 
339  init_reg_param(&reg_params[0], "r0", 32, PARAM_IN_OUT);
340  init_reg_param(&reg_params[1], "r1", 32, PARAM_OUT);
341  init_reg_param(&reg_params[2], "r2", 32, PARAM_OUT);
342  init_reg_param(&reg_params[3], "r3", 32, PARAM_OUT);
343  init_reg_param(&reg_params[4], "sp", 32, PARAM_OUT);
344  /* Put the 4th parameter at the location in the stack frame of target write() function.
345  * See contrib/loaders/flash/bluenrg-x/bluenrg-x_write.lst
346  * 34 ldr r6, [sp, #88]
347  * ^^^ offset
348  */
349  init_mem_param(&mem_params[0], write_algorithm_stack->address + 88, 32, PARAM_OUT);
350  /* Stack for target write algorithm - target write() function has
351  * __attribute__((naked)) so it does not setup the new stack frame.
352  * Therefore the stack frame uses the area from SP upwards!
353  * Interrupts are disabled and no subroutines are called from write()
354  * so no need to allocate stack below SP.
355  * TODO: remove __attribute__((naked)) and use similar parameter passing as stm32l4x */
356  buf_set_u32(reg_params[4].value, 0, 32, write_algorithm_stack->address);
357 
358  /* FIFO start address (first two words used for write and read pointers) */
359  buf_set_u32(reg_params[0].value, 0, 32, source->address);
360  /* FIFO end address (first two words used for write and read pointers) */
361  buf_set_u32(reg_params[1].value, 0, 32, source->address + source->size);
362  /* Flash memory address */
363  buf_set_u32(reg_params[2].value, 0, 32, address);
364  /* Number of bytes */
365  buf_set_u32(reg_params[3].value, 0, 32, count);
366  /* Flash register base address */
367  buf_set_u32(mem_params[0].value, 0, 32, bluenrgx_info->flash_ptr->flash_regs_base);
368 
369  LOG_DEBUG("source->address = " TARGET_ADDR_FMT, source->address);
370  LOG_DEBUG("source->address+ source->size = " TARGET_ADDR_FMT, source->address+source->size);
371  LOG_DEBUG("write_algorithm_stack->address = " TARGET_ADDR_FMT, write_algorithm_stack->address);
372  LOG_DEBUG("address = %08" PRIx32, address);
373  LOG_DEBUG("count = %08" PRIx32, count);
374 
376  buffer,
377  count/16,
378  16, /* Block size: we write in block of 16 bytes to enjoy burstwrite speed */
379  1,
380  mem_params,
381  5,
382  reg_params,
383  source->address,
384  source->size,
385  write_algorithm->address,
386  0,
387  &armv7m_info);
388 
389  if (retval == ERROR_FLASH_OPERATION_FAILED) {
390  LOG_ERROR("error executing bluenrg-x flash write algorithm");
391 
392  uint32_t error = buf_get_u32(reg_params[0].value, 0, 32);
393 
394  if (error != 0)
395  LOG_ERROR("flash write failed = %08" PRIx32, error);
396  }
397 
398  if (retval == ERROR_OK) {
399  uint32_t rp;
400  /* Read back rp and check that is valid */
401  retval = target_read_u32(target, source->address+4, &rp);
402  if (retval == ERROR_OK) {
403  if ((rp < source->address+8) || (rp > (source->address + source->size))) {
404  LOG_ERROR("flash write failed = %08" PRIx32, rp);
406  }
407  }
408  }
409 
411  target_free_working_area(target, write_algorithm);
412  target_free_working_area(target, write_algorithm_stack);
413 
414  destroy_reg_param(&reg_params[0]);
415  destroy_reg_param(&reg_params[1]);
416  destroy_reg_param(&reg_params[2]);
417  destroy_reg_param(&reg_params[3]);
418  destroy_reg_param(&reg_params[4]);
419  destroy_mem_param(&mem_params[0]);
420 
421  return retval;
422 }
423 
424 static int bluenrgx_write_without_loader(struct flash_bank *bank, const uint8_t *buffer,
425  uint32_t offset, uint32_t count)
426 {
427  struct target *target = bank->target;
428  unsigned int data_count = count / FLASH_DATA_WIDTH;
429 
430  while (data_count--) {
431  /* clear flags */
433  LOG_ERROR("Register write failed");
434  return ERROR_FAIL;
435  }
436 
438  LOG_ERROR("Register write failed");
439  return ERROR_FAIL;
440  }
441 
444  LOG_ERROR("Failed to write data");
445  return ERROR_FAIL;
446  }
447 
449  LOG_ERROR("Failed");
450  return ERROR_FAIL;
451  }
452 
454  return ERROR_FAIL;
455 
456  /* increment offset, and buffer */
459  }
460 
461  return ERROR_OK;
462 }
463 
464 static int bluenrgx_write(struct flash_bank *bank, const uint8_t *buffer,
465  uint32_t offset, uint32_t count)
466 {
467  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
468  int retval = ERROR_OK;
469 
470  /* check preconditions */
471  if (!bluenrgx_info->probed)
473 
474  if ((offset + count) > bank->size) {
475  LOG_ERROR("Requested write past beyond of flash size: (offset+count) = %" PRIu32 ", size=%" PRIu32,
476  (offset + count),
477  bank->size);
479  }
480 
481  if (bank->target->state != TARGET_HALTED) {
482  LOG_ERROR("Target not halted");
484  }
485 
486  assert(offset % FLASH_WORD_LEN == 0);
487  assert(count % FLASH_WORD_LEN == 0);
488 
490  /* if resources are not available write without a loader */
491  if (retval == ERROR_TARGET_RESOURCE_NOT_AVAILABLE) {
492  LOG_WARNING("falling back to programming without a flash loader (slower)");
494  }
495  return retval;
496 }
497 
498 static int bluenrgx_probe(struct flash_bank *bank)
499 {
500  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
501  uint32_t idcode, size_info, die_id;
502  int retval = target_read_u32(bank->target, BLUENRGLP_JTAG_REG, &idcode);
503 
504  if (retval != ERROR_OK)
505  return retval;
506 
508  && idcode != flash_priv_data_lpf.jtag_idcode
509  && idcode != flash_priv_data_spirit3.jtag_idcode) {
510  retval = target_read_u32(bank->target, BLUENRG2_JTAG_REG, &idcode);
511  if (retval != ERROR_OK)
512  return retval;
513  }
514 
515  /* Default device is BlueNRG-1 */
516  bluenrgx_info->flash_ptr = &flash_priv_data_1;
518 
519  for (size_t i = 0; i < ARRAY_SIZE(flash_ctrl); i++) {
520  if (idcode == (*flash_ctrl[i]).jtag_idcode) {
521  bluenrgx_info->flash_ptr = flash_ctrl[i];
522  bank->base = (*flash_ctrl[i]).flash_base;
523  break;
524  }
525  }
526  retval = bluenrgx_read_flash_reg(bank, FLASH_SIZE_REG, &size_info);
527  size_info = size_info & FLASH_SIZE_REG_MASK;
528  if (retval != ERROR_OK)
529  return retval;
530 
531  retval = target_read_u32(bank->target, DIE_ID_REG(bluenrgx_info), &die_id);
532  if (retval != ERROR_OK)
533  return retval;
534 
535  bank->size = (size_info + 1) * FLASH_WORD_LEN;
536  bank->num_sectors = bank->size / FLASH_PAGE_SIZE(bluenrgx_info);
537  bank->sectors = realloc(bank->sectors, sizeof(struct flash_sector) * bank->num_sectors);
538 
539  for (unsigned int i = 0; i < bank->num_sectors; i++) {
540  bank->sectors[i].offset = i * FLASH_PAGE_SIZE(bluenrgx_info);
541  bank->sectors[i].size = FLASH_PAGE_SIZE(bluenrgx_info);
542  bank->sectors[i].is_erased = -1;
543  bank->sectors[i].is_protected = 0;
544  }
545 
546  bluenrgx_info->probed = true;
547  bluenrgx_info->die_id = die_id;
548 
549  return ERROR_OK;
550 }
551 
553 {
554  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
555 
556  if (bluenrgx_info->probed)
557  return ERROR_OK;
558 
559  return bluenrgx_probe(bank);
560 }
561 
562 /* This method must return a string displaying information about the bank */
564 {
565  struct bluenrgx_flash_bank *bluenrgx_info = bank->driver_priv;
566  int mask_number, cut_number;
567 
568  if (!bluenrgx_info->probed) {
569  int retval = bluenrgx_probe(bank);
570  if (retval != ERROR_OK) {
571  command_print_sameline(cmd, "Unable to find bank information.");
572  return retval;
573  }
574  }
575 
576  mask_number = (bluenrgx_info->die_id >> 4) & 0xF;
577  cut_number = bluenrgx_info->die_id & 0xF;
578 
579  command_print_sameline(cmd, "%s - Rev: %d.%d",
580  bluenrgx_info->flash_ptr->part_name, mask_number, cut_number);
581  return ERROR_OK;
582 }
583 
584 const struct flash_driver bluenrgx_flash = {
585  .name = "bluenrg-x",
586  .flash_bank_command = bluenrgx_flash_bank_command,
587  .erase = bluenrgx_erase,
588  .protect = NULL,
589  .write = bluenrgx_write,
590  .read = default_flash_read,
591  .probe = bluenrgx_probe,
592  .erase_check = default_flash_blank_check,
593  .protect_check = NULL,
594  .auto_probe = bluenrgx_auto_probe,
595  .info = bluenrgx_get_info,
596  .free_driver_priv = default_flash_free_driver_priv,
597 };
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
#define ALIGN_DOWN(x, a)
Definition: align.h:21
@ 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:107
static const struct flash_ctrl_priv_data flash_priv_data_lp
Definition: bluenrg-x.c:61
static int bluenrgx_write_with_loader(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: bluenrg-x.c:272
#define DIE_ID_REG(bluenrgx_info)
Definition: bluenrg-x.c:25
#define FLASH_PAGE_SIZE(bluenrgx_info)
Definition: bluenrg-x.c:27
static int bluenrgx_wait_for_interrupt(struct flash_bank *bank, uint32_t interrupt_flag)
Definition: bluenrg-x.c:158
static uint32_t bluenrgx_get_flash_reg(struct flash_bank *bank, uint32_t reg_offset)
Definition: bluenrg-x.c:142
const struct flash_driver bluenrgx_flash
Definition: bluenrg-x.c:584
static int bluenrgx_wait_for_command(struct flash_bank *bank)
Definition: bluenrg-x.c:188
static int bluenrgx_write_without_loader(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: bluenrg-x.c:424
#define BLUENRG2_JTAG_REG
Definition: bluenrg-x.c:21
static const struct flash_ctrl_priv_data flash_priv_data_2
Definition: bluenrg-x.c:51
static const struct flash_ctrl_priv_data flash_priv_data_spirit3
Definition: bluenrg-x.c:91
static int bluenrgx_write_flash_reg(struct flash_bank *bank, uint32_t reg_offset, uint32_t value)
Definition: bluenrg-x.c:153
static int bluenrgx_probe(struct flash_bank *bank)
Definition: bluenrg-x.c:498
static int bluenrgx_get_info(struct flash_bank *bank, struct command_invocation *cmd)
Definition: bluenrg-x.c:563
static int bluenrgx_erase(struct flash_bank *bank, unsigned int first, unsigned int last)
Definition: bluenrg-x.c:196
FLASH_BANK_COMMAND_HANDLER(bluenrgx_flash_bank_command)
Definition: bluenrg-x.c:117
#define FLASH_SIZE_REG_MASK
Definition: bluenrg-x.c:29
static int bluenrgx_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
Definition: bluenrg-x.c:464
static const struct flash_ctrl_priv_data flash_priv_data_lps
Definition: bluenrg-x.c:71
static int bluenrgx_read_flash_reg(struct flash_bank *bank, uint32_t reg_offset, uint32_t *value)
Definition: bluenrg-x.c:148
static const struct flash_ctrl_priv_data flash_priv_data_lpf
Definition: bluenrg-x.c:81
#define BLUENRGLP_JTAG_REG
Definition: bluenrg-x.c:22
static int bluenrgx_auto_probe(struct flash_bank *bank)
Definition: bluenrg-x.c:552
static const struct flash_ctrl_priv_data flash_priv_data_1
Definition: bluenrg-x.c:41
#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:1855
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:144
#define ERROR_FAIL
Definition: log.h:188
#define LOG_ERROR(expr ...)
Definition: log.h:147
#define ERROR_TIMEOUT_REACHED
Definition: log.h:191
#define LOG_DEBUG(expr ...)
Definition: log.h:124
#define ERROR_OK
Definition: log.h:182
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:104
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:34
uint32_t flash_page_size
Definition: bluenrg-x.c:36
uint32_t jtag_idcode_reg
Definition: bluenrg-x.c:33
uint32_t jtag_idcode
Definition: bluenrg-x.c:37
uint32_t die_id_reg
Definition: bluenrg-x.c:32
uint32_t flash_regs_base
Definition: bluenrg-x.c:35
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:2405
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:1289
uint32_t target_get_working_area_avail(struct target *target)
Definition: target.c:2216
int target_alloc_working_area(struct target *target, uint32_t size, struct working_area **area)
Definition: target.c:2112
int target_write_u32(struct target *target, target_addr_t address, uint32_t value)
Definition: target.c:2671
int target_free_working_area(struct target *target, struct working_area *area)
Free a working area.
Definition: target.c:2170
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:946
int target_read_u32(struct target *target, target_addr_t address, uint32_t *value)
Definition: target.c:2597
#define ERROR_TARGET_NOT_HALTED
Definition: target.h:817
@ TARGET_HALTED
Definition: target.h:58
#define ERROR_TARGET_RESOURCE_NOT_AVAILABLE
Definition: target.h:821
#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