You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

714 lines
18 KiB

  1. /***************************************************************************
  2. * Copyright (C) 2005 by Dominic Rath *
  3. * Dominic.Rath@gmx.de *
  4. * *
  5. * Copyright (C) 2008 by Spencer Oliver *
  6. * spen@spen-soft.co.uk *
  7. *
  8. * Copyright (C) 2008 by Oyvind Harboe *
  9. * oyvind.harboe@zylin.com *
  10. * *
  11. * This program is free software; you can redistribute it and/or modify *
  12. * it under the terms of the GNU General Public License as published by *
  13. * the Free Software Foundation; either version 2 of the License, or *
  14. * (at your option) any later version. *
  15. * *
  16. * This program is distributed in the hope that it will be useful, *
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  19. * GNU General Public License for more details. *
  20. * *
  21. * You should have received a copy of the GNU General Public License *
  22. * along with this program; if not, write to the *
  23. * Free Software Foundation, Inc., *
  24. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  25. ***************************************************************************/
  26. #ifdef HAVE_CONFIG_H
  27. #include "config.h"
  28. #endif
  29. #include "str9x.h"
  30. #include "arm966e.h"
  31. static uint32_t bank1start = 0x00080000;
  32. static int str9x_register_commands(struct command_context_s *cmd_ctx);
  33. static int str9x_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank);
  34. static int str9x_erase(struct flash_bank_s *bank, int first, int last);
  35. static int str9x_protect(struct flash_bank_s *bank, int set, int first, int last);
  36. static int str9x_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t offset, uint32_t count);
  37. static int str9x_probe(struct flash_bank_s *bank);
  38. //static int str9x_handle_part_id_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
  39. static int str9x_protect_check(struct flash_bank_s *bank);
  40. static int str9x_info(struct flash_bank_s *bank, char *buf, int buf_size);
  41. static int str9x_handle_flash_config_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
  42. flash_driver_t str9x_flash =
  43. {
  44. .name = "str9x",
  45. .register_commands = str9x_register_commands,
  46. .flash_bank_command = str9x_flash_bank_command,
  47. .erase = str9x_erase,
  48. .protect = str9x_protect,
  49. .write = str9x_write,
  50. .probe = str9x_probe,
  51. .auto_probe = str9x_probe,
  52. .erase_check = default_flash_blank_check,
  53. .protect_check = str9x_protect_check,
  54. .info = str9x_info
  55. };
  56. static int str9x_register_commands(struct command_context_s *cmd_ctx)
  57. {
  58. command_t *str9x_cmd = register_command(cmd_ctx, NULL, "str9x", NULL, COMMAND_ANY, NULL);
  59. register_command(cmd_ctx, str9x_cmd, "flash_config", str9x_handle_flash_config_command, COMMAND_EXEC,
  60. "configure str9 flash controller");
  61. return ERROR_OK;
  62. }
  63. static int str9x_build_block_list(struct flash_bank_s *bank)
  64. {
  65. str9x_flash_bank_t *str9x_info = bank->driver_priv;
  66. int i;
  67. int num_sectors;
  68. int b0_sectors = 0, b1_sectors = 0;
  69. uint32_t offset = 0;
  70. /* set if we have large flash str9 */
  71. str9x_info->variant = 0;
  72. str9x_info->bank1 = 0;
  73. switch (bank->size)
  74. {
  75. case (256 * 1024):
  76. b0_sectors = 4;
  77. break;
  78. case (512 * 1024):
  79. b0_sectors = 8;
  80. break;
  81. case (1024 * 1024):
  82. bank1start = 0x00100000;
  83. str9x_info->variant = 1;
  84. b0_sectors = 16;
  85. break;
  86. case (2048 * 1024):
  87. bank1start = 0x00200000;
  88. str9x_info->variant = 1;
  89. b0_sectors = 32;
  90. break;
  91. case (128 * 1024):
  92. str9x_info->variant = 1;
  93. str9x_info->bank1 = 1;
  94. b1_sectors = 8;
  95. bank1start = bank->base;
  96. break;
  97. case (32 * 1024):
  98. str9x_info->bank1 = 1;
  99. b1_sectors = 4;
  100. bank1start = bank->base;
  101. break;
  102. default:
  103. LOG_ERROR("BUG: unknown bank->size encountered");
  104. exit(-1);
  105. }
  106. num_sectors = b0_sectors + b1_sectors;
  107. bank->num_sectors = num_sectors;
  108. bank->sectors = malloc(sizeof(flash_sector_t) * num_sectors);
  109. str9x_info->sector_bits = malloc(sizeof(uint32_t) * num_sectors);
  110. num_sectors = 0;
  111. for (i = 0; i < b0_sectors; i++)
  112. {
  113. bank->sectors[num_sectors].offset = offset;
  114. bank->sectors[num_sectors].size = 0x10000;
  115. offset += bank->sectors[i].size;
  116. bank->sectors[num_sectors].is_erased = -1;
  117. bank->sectors[num_sectors].is_protected = 1;
  118. str9x_info->sector_bits[num_sectors++] = (1 << i);
  119. }
  120. for (i = 0; i < b1_sectors; i++)
  121. {
  122. bank->sectors[num_sectors].offset = offset;
  123. bank->sectors[num_sectors].size = str9x_info->variant == 0 ? 0x2000 : 0x4000;
  124. offset += bank->sectors[i].size;
  125. bank->sectors[num_sectors].is_erased = -1;
  126. bank->sectors[num_sectors].is_protected = 1;
  127. if (str9x_info->variant)
  128. str9x_info->sector_bits[num_sectors++] = (1 << i);
  129. else
  130. str9x_info->sector_bits[num_sectors++] = (1 << (i + 8));
  131. }
  132. return ERROR_OK;
  133. }
  134. /* flash bank str9x <base> <size> 0 0 <target#>
  135. */
  136. static int str9x_flash_bank_command(struct command_context_s *cmd_ctx,
  137. char *cmd, char **args, int argc, struct flash_bank_s *bank)
  138. {
  139. str9x_flash_bank_t *str9x_info;
  140. if (argc < 6)
  141. {
  142. LOG_WARNING("incomplete flash_bank str9x configuration");
  143. return ERROR_FLASH_BANK_INVALID;
  144. }
  145. str9x_info = malloc(sizeof(str9x_flash_bank_t));
  146. bank->driver_priv = str9x_info;
  147. str9x_build_block_list(bank);
  148. str9x_info->write_algorithm = NULL;
  149. return ERROR_OK;
  150. }
  151. static int str9x_protect_check(struct flash_bank_s *bank)
  152. {
  153. int retval;
  154. str9x_flash_bank_t *str9x_info = bank->driver_priv;
  155. target_t *target = bank->target;
  156. int i;
  157. uint32_t adr;
  158. uint32_t status = 0;
  159. uint16_t hstatus = 0;
  160. if (bank->target->state != TARGET_HALTED)
  161. {
  162. LOG_ERROR("Target not halted");
  163. return ERROR_TARGET_NOT_HALTED;
  164. }
  165. /* read level one protection */
  166. if (str9x_info->variant)
  167. {
  168. if (str9x_info->bank1)
  169. {
  170. adr = bank1start + 0x18;
  171. if ((retval = target_write_u16(target, adr, 0x90)) != ERROR_OK)
  172. {
  173. return retval;
  174. }
  175. if ((retval = target_read_u16(target, adr, &hstatus)) != ERROR_OK)
  176. {
  177. return retval;
  178. }
  179. status = hstatus;
  180. }
  181. else
  182. {
  183. adr = bank1start + 0x14;
  184. if ((retval = target_write_u16(target, adr, 0x90)) != ERROR_OK)
  185. {
  186. return retval;
  187. }
  188. if ((retval = target_read_u32(target, adr, &status)) != ERROR_OK)
  189. {
  190. return retval;
  191. }
  192. }
  193. }
  194. else
  195. {
  196. adr = bank1start + 0x10;
  197. if ((retval = target_write_u16(target, adr, 0x90)) != ERROR_OK)
  198. {
  199. return retval;
  200. }
  201. if ((retval = target_read_u16(target, adr, &hstatus)) != ERROR_OK)
  202. {
  203. return retval;
  204. }
  205. status = hstatus;
  206. }
  207. /* read array command */
  208. if ((retval = target_write_u16(target, adr, 0xFF)) != ERROR_OK)
  209. {
  210. return retval;
  211. }
  212. for (i = 0; i < bank->num_sectors; i++)
  213. {
  214. if (status & str9x_info->sector_bits[i])
  215. bank->sectors[i].is_protected = 1;
  216. else
  217. bank->sectors[i].is_protected = 0;
  218. }
  219. return ERROR_OK;
  220. }
  221. static int str9x_erase(struct flash_bank_s *bank, int first, int last)
  222. {
  223. target_t *target = bank->target;
  224. int i;
  225. uint32_t adr;
  226. uint8_t status;
  227. uint8_t erase_cmd;
  228. if (bank->target->state != TARGET_HALTED)
  229. {
  230. LOG_ERROR("Target not halted");
  231. return ERROR_TARGET_NOT_HALTED;
  232. }
  233. /* Check if we erase whole bank */
  234. if ((first == 0) && (last == (bank->num_sectors - 1)))
  235. {
  236. /* Optimize to run erase bank command instead of sector */
  237. erase_cmd = 0x80;
  238. }
  239. else
  240. {
  241. /* Erase sector command */
  242. erase_cmd = 0x20;
  243. }
  244. for (i = first; i <= last; i++)
  245. {
  246. int retval;
  247. adr = bank->base + bank->sectors[i].offset;
  248. /* erase sectors */
  249. if ((retval = target_write_u16(target, adr, erase_cmd)) != ERROR_OK)
  250. {
  251. return retval;
  252. }
  253. if ((retval = target_write_u16(target, adr, 0xD0)) != ERROR_OK)
  254. {
  255. return retval;
  256. }
  257. /* get status */
  258. if ((retval = target_write_u16(target, adr, 0x70)) != ERROR_OK)
  259. {
  260. return retval;
  261. }
  262. int timeout;
  263. for (timeout = 0; timeout < 1000; timeout++) {
  264. if ((retval = target_read_u8(target, adr, &status)) != ERROR_OK)
  265. {
  266. return retval;
  267. }
  268. if (status & 0x80)
  269. break;
  270. alive_sleep(1);
  271. }
  272. if (timeout == 1000)
  273. {
  274. LOG_ERROR("erase timed out");
  275. return ERROR_FAIL;
  276. }
  277. /* clear status, also clear read array */
  278. if ((retval = target_write_u16(target, adr, 0x50)) != ERROR_OK)
  279. {
  280. return retval;
  281. }
  282. /* read array command */
  283. if ((retval = target_write_u16(target, adr, 0xFF)) != ERROR_OK)
  284. {
  285. return retval;
  286. }
  287. if (status & 0x22)
  288. {
  289. LOG_ERROR("error erasing flash bank, status: 0x%x", status);
  290. return ERROR_FLASH_OPERATION_FAILED;
  291. }
  292. /* If we ran erase bank command, we are finished */
  293. if (erase_cmd == 0x80)
  294. break;
  295. }
  296. for (i = first; i <= last; i++)
  297. bank->sectors[i].is_erased = 1;
  298. return ERROR_OK;
  299. }
  300. static int str9x_protect(struct flash_bank_s *bank,
  301. int set, int first, int last)
  302. {
  303. target_t *target = bank->target;
  304. int i;
  305. uint32_t adr;
  306. uint8_t status;
  307. if (bank->target->state != TARGET_HALTED)
  308. {
  309. LOG_ERROR("Target not halted");
  310. return ERROR_TARGET_NOT_HALTED;
  311. }
  312. for (i = first; i <= last; i++)
  313. {
  314. /* Level One Protection */
  315. adr = bank->base + bank->sectors[i].offset;
  316. target_write_u16(target, adr, 0x60);
  317. if (set)
  318. target_write_u16(target, adr, 0x01);
  319. else
  320. target_write_u16(target, adr, 0xD0);
  321. /* query status */
  322. target_read_u8(target, adr, &status);
  323. /* clear status, also clear read array */
  324. target_write_u16(target, adr, 0x50);
  325. /* read array command */
  326. target_write_u16(target, adr, 0xFF);
  327. }
  328. return ERROR_OK;
  329. }
  330. static int str9x_write_block(struct flash_bank_s *bank,
  331. uint8_t *buffer, uint32_t offset, uint32_t count)
  332. {
  333. str9x_flash_bank_t *str9x_info = bank->driver_priv;
  334. target_t *target = bank->target;
  335. uint32_t buffer_size = 8192;
  336. working_area_t *source;
  337. uint32_t address = bank->base + offset;
  338. reg_param_t reg_params[4];
  339. armv4_5_algorithm_t armv4_5_info;
  340. int retval = ERROR_OK;
  341. uint32_t str9x_flash_write_code[] = {
  342. /* write: */
  343. 0xe3c14003, /* bic r4, r1, #3 */
  344. 0xe3a03040, /* mov r3, #0x40 */
  345. 0xe1c430b0, /* strh r3, [r4, #0] */
  346. 0xe0d030b2, /* ldrh r3, [r0], #2 */
  347. 0xe0c130b2, /* strh r3, [r1], #2 */
  348. 0xe3a03070, /* mov r3, #0x70 */
  349. 0xe1c430b0, /* strh r3, [r4, #0] */
  350. /* busy: */
  351. 0xe5d43000, /* ldrb r3, [r4, #0] */
  352. 0xe3130080, /* tst r3, #0x80 */
  353. 0x0afffffc, /* beq busy */
  354. 0xe3a05050, /* mov r5, #0x50 */
  355. 0xe1c450b0, /* strh r5, [r4, #0] */
  356. 0xe3a050ff, /* mov r5, #0xFF */
  357. 0xe1c450b0, /* strh r5, [r4, #0] */
  358. 0xe3130012, /* tst r3, #0x12 */
  359. 0x1a000001, /* bne exit */
  360. 0xe2522001, /* subs r2, r2, #1 */
  361. 0x1affffed, /* bne write */
  362. /* exit: */
  363. 0xeafffffe, /* b exit */
  364. };
  365. /* flash write code */
  366. if (target_alloc_working_area(target, 4 * 19, &str9x_info->write_algorithm) != ERROR_OK)
  367. {
  368. LOG_WARNING("no working area available, can't do block memory writes");
  369. return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
  370. };
  371. target_write_buffer(target, str9x_info->write_algorithm->address, 19 * 4, (uint8_t*)str9x_flash_write_code);
  372. /* memory buffer */
  373. while (target_alloc_working_area(target, buffer_size, &source) != ERROR_OK)
  374. {
  375. buffer_size /= 2;
  376. if (buffer_size <= 256)
  377. {
  378. /* if we already allocated the writing code, but failed to get a buffer, free the algorithm */
  379. if (str9x_info->write_algorithm)
  380. target_free_working_area(target, str9x_info->write_algorithm);
  381. LOG_WARNING("no large enough working area available, can't do block memory writes");
  382. return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
  383. }
  384. }
  385. armv4_5_info.common_magic = ARMV4_5_COMMON_MAGIC;
  386. armv4_5_info.core_mode = ARMV4_5_MODE_SVC;
  387. armv4_5_info.core_state = ARMV4_5_STATE_ARM;
  388. init_reg_param(&reg_params[0], "r0", 32, PARAM_OUT);
  389. init_reg_param(&reg_params[1], "r1", 32, PARAM_OUT);
  390. init_reg_param(&reg_params[2], "r2", 32, PARAM_OUT);
  391. init_reg_param(&reg_params[3], "r3", 32, PARAM_IN);
  392. while (count > 0)
  393. {
  394. uint32_t thisrun_count = (count > (buffer_size / 2)) ? (buffer_size / 2) : count;
  395. target_write_buffer(target, source->address, thisrun_count * 2, buffer);
  396. buf_set_u32(reg_params[0].value, 0, 32, source->address);
  397. buf_set_u32(reg_params[1].value, 0, 32, address);
  398. buf_set_u32(reg_params[2].value, 0, 32, thisrun_count);
  399. if ((retval = target_run_algorithm(target, 0, NULL, 4, reg_params, str9x_info->write_algorithm->address, str9x_info->write_algorithm->address + (18 * 4), 10000, &armv4_5_info)) != ERROR_OK)
  400. {
  401. LOG_ERROR("error executing str9x flash write algorithm");
  402. retval = ERROR_FLASH_OPERATION_FAILED;
  403. break;
  404. }
  405. if (buf_get_u32(reg_params[3].value, 0, 32) != 0x80)
  406. {
  407. retval = ERROR_FLASH_OPERATION_FAILED;
  408. break;
  409. }
  410. buffer += thisrun_count * 2;
  411. address += thisrun_count * 2;
  412. count -= thisrun_count;
  413. }
  414. target_free_working_area(target, source);
  415. target_free_working_area(target, str9x_info->write_algorithm);
  416. destroy_reg_param(&reg_params[0]);
  417. destroy_reg_param(&reg_params[1]);
  418. destroy_reg_param(&reg_params[2]);
  419. destroy_reg_param(&reg_params[3]);
  420. return retval;
  421. }
  422. static int str9x_write(struct flash_bank_s *bank,
  423. uint8_t *buffer, uint32_t offset, uint32_t count)
  424. {
  425. target_t *target = bank->target;
  426. uint32_t words_remaining = (count / 2);
  427. uint32_t bytes_remaining = (count & 0x00000001);
  428. uint32_t address = bank->base + offset;
  429. uint32_t bytes_written = 0;
  430. uint8_t status;
  431. int retval;
  432. uint32_t check_address = offset;
  433. uint32_t bank_adr;
  434. int i;
  435. if (bank->target->state != TARGET_HALTED)
  436. {
  437. LOG_ERROR("Target not halted");
  438. return ERROR_TARGET_NOT_HALTED;
  439. }
  440. if (offset & 0x1)
  441. {
  442. LOG_WARNING("offset 0x%" PRIx32 " breaks required 2-byte alignment", offset);
  443. return ERROR_FLASH_DST_BREAKS_ALIGNMENT;
  444. }
  445. for (i = 0; i < bank->num_sectors; i++)
  446. {
  447. uint32_t sec_start = bank->sectors[i].offset;
  448. uint32_t sec_end = sec_start + bank->sectors[i].size;
  449. /* check if destination falls within the current sector */
  450. if ((check_address >= sec_start) && (check_address < sec_end))
  451. {
  452. /* check if destination ends in the current sector */
  453. if (offset + count < sec_end)
  454. check_address = offset + count;
  455. else
  456. check_address = sec_end;
  457. }
  458. }
  459. if (check_address != offset + count)
  460. return ERROR_FLASH_DST_OUT_OF_BANK;
  461. /* multiple half words (2-byte) to be programmed? */
  462. if (words_remaining > 0)
  463. {
  464. /* try using a block write */
  465. if ((retval = str9x_write_block(bank, buffer, offset, words_remaining)) != ERROR_OK)
  466. {
  467. if (retval == ERROR_TARGET_RESOURCE_NOT_AVAILABLE)
  468. {
  469. /* if block write failed (no sufficient working area),
  470. * we use normal (slow) single dword accesses */
  471. LOG_WARNING("couldn't use block writes, falling back to single memory accesses");
  472. }
  473. else if (retval == ERROR_FLASH_OPERATION_FAILED)
  474. {
  475. LOG_ERROR("flash writing failed with error code: 0x%x", retval);
  476. return ERROR_FLASH_OPERATION_FAILED;
  477. }
  478. }
  479. else
  480. {
  481. buffer += words_remaining * 2;
  482. address += words_remaining * 2;
  483. words_remaining = 0;
  484. }
  485. }
  486. while (words_remaining > 0)
  487. {
  488. bank_adr = address & ~0x03;
  489. /* write data command */
  490. target_write_u16(target, bank_adr, 0x40);
  491. target_write_memory(target, address, 2, 1, buffer + bytes_written);
  492. /* get status command */
  493. target_write_u16(target, bank_adr, 0x70);
  494. int timeout;
  495. for (timeout = 0; timeout < 1000; timeout++)
  496. {
  497. target_read_u8(target, bank_adr, &status);
  498. if (status & 0x80)
  499. break;
  500. alive_sleep(1);
  501. }
  502. if (timeout == 1000)
  503. {
  504. LOG_ERROR("write timed out");
  505. return ERROR_FAIL;
  506. }
  507. /* clear status reg and read array */
  508. target_write_u16(target, bank_adr, 0x50);
  509. target_write_u16(target, bank_adr, 0xFF);
  510. if (status & 0x10)
  511. return ERROR_FLASH_OPERATION_FAILED;
  512. else if (status & 0x02)
  513. return ERROR_FLASH_OPERATION_FAILED;
  514. bytes_written += 2;
  515. words_remaining--;
  516. address += 2;
  517. }
  518. if (bytes_remaining)
  519. {
  520. uint8_t last_halfword[2] = {0xff, 0xff};
  521. int i = 0;
  522. while (bytes_remaining > 0)
  523. {
  524. last_halfword[i++] = *(buffer + bytes_written);
  525. bytes_remaining--;
  526. bytes_written++;
  527. }
  528. bank_adr = address & ~0x03;
  529. /* write data command */
  530. target_write_u16(target, bank_adr, 0x40);
  531. target_write_memory(target, address, 2, 1, last_halfword);
  532. /* query status command */
  533. target_write_u16(target, bank_adr, 0x70);
  534. int timeout;
  535. for (timeout = 0; timeout < 1000; timeout++)
  536. {
  537. target_read_u8(target, bank_adr, &status);
  538. if (status & 0x80)
  539. break;
  540. alive_sleep(1);
  541. }
  542. if (timeout == 1000)
  543. {
  544. LOG_ERROR("write timed out");
  545. return ERROR_FAIL;
  546. }
  547. /* clear status reg and read array */
  548. target_write_u16(target, bank_adr, 0x50);
  549. target_write_u16(target, bank_adr, 0xFF);
  550. if (status & 0x10)
  551. return ERROR_FLASH_OPERATION_FAILED;
  552. else if (status & 0x02)
  553. return ERROR_FLASH_OPERATION_FAILED;
  554. }
  555. return ERROR_OK;
  556. }
  557. static int str9x_probe(struct flash_bank_s *bank)
  558. {
  559. return ERROR_OK;
  560. }
  561. #if 0
  562. static int str9x_handle_part_id_command(struct command_context_s *cmd_ctx,
  563. char *cmd, char **args, int argc)
  564. {
  565. return ERROR_OK;
  566. }
  567. #endif
  568. static int str9x_info(struct flash_bank_s *bank, char *buf, int buf_size)
  569. {
  570. snprintf(buf, buf_size, "str9x flash driver info");
  571. return ERROR_OK;
  572. }
  573. static int str9x_handle_flash_config_command(struct command_context_s *cmd_ctx,
  574. char *cmd, char **args, int argc)
  575. {
  576. str9x_flash_bank_t *str9x_info;
  577. flash_bank_t *bank;
  578. target_t *target = NULL;
  579. if (argc < 5)
  580. {
  581. return ERROR_COMMAND_SYNTAX_ERROR;
  582. }
  583. bank = get_flash_bank_by_num(strtoul(args[0], NULL, 0));
  584. if (!bank)
  585. {
  586. command_print(cmd_ctx, "flash bank '#%s' is out of bounds", args[0]);
  587. return ERROR_OK;
  588. }
  589. str9x_info = bank->driver_priv;
  590. target = bank->target;
  591. if (bank->target->state != TARGET_HALTED)
  592. {
  593. LOG_ERROR("Target not halted");
  594. return ERROR_TARGET_NOT_HALTED;
  595. }
  596. /* config flash controller */
  597. target_write_u32(target, FLASH_BBSR, strtoul(args[1], NULL, 0));
  598. target_write_u32(target, FLASH_NBBSR, strtoul(args[2], NULL, 0));
  599. target_write_u32(target, FLASH_BBADR, (strtoul(args[3], NULL, 0) >> 2));
  600. target_write_u32(target, FLASH_NBBADR, (strtoul(args[4], NULL, 0) >> 2));
  601. /* set bit 18 instruction TCM order as per flash programming manual */
  602. arm966e_write_cp15(target, 62, 0x40000);
  603. /* enable flash bank 1 */
  604. target_write_u32(target, FLASH_CR, 0x18);
  605. return ERROR_OK;
  606. }