Flash programming on Renesas DA14706 seems to leave the flash controller in an invalid state

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Flash programming on Renesas DA14706 seems to leave the flash controller in an invalid state

      Hello,

      When I use J-Link commander to write a binary to the flash using the J-Link OB on the evaluation board, the SoC will then not boot and following the execution in Ozone shows that it stays in the boot ROM for a while and then reset.

      I noticed that if I run any example program from the Renesas SDK from RAM using their IDE, the flashed binary will then boot without issues. I dug through the init code of the SDK and found that the function that configure the flash controller (on this SoC the flash is external so different modules may be used and depending on the CPU clock speed some settings may need to be changed, so there is a function for that) allows the SoC to boot again.

      I took note of all the writes the SDK was performing from this function and replicated them using J-Link Commander and it worked ! Here is the script:

      Source Code

      1. // The lowest serial number is the M33 core
      2. device DA14706
      3. // Select the single wire debug interface. JTAG is not present
      4. si SWD
      5. // Max supported speed
      6. speed 4000
      7. connect
      8. //exec EnableEraseAllFlashBanks
      9. //erase
      10. loadfile test_fw_image.bin 0x38000000
      11. sleep 100
      12. // oqspi_enter_manual_access_mode
      13. // OQSPIF_CTRLMODE_REG -> Manual access mode (lsb bit to zero, the rest taken from ozone)
      14. W4 0x36000004 0xF8018F82
      15. // -> oqspi_flash_exit_continuous_mode
      16. // OQSPIF_CTRLBUS_REG -> chip select enable
      17. W4 0x36000000 0x10
      18. sleep 200
      19. // OQSPIF_WRITEDATA_REG -> OQSPI_EXIT_CONTINUOUS_MODE_WORD
      20. W4 0x36000018 0xffffffff
      21. // OQSPIF_CTRLBUS_REG -> chip select disable
      22. W4 0x36000000 0x20
      23. sleep 100
      24. // oqspi_set_manual_access_bus_mode(SINGLE, true)
      25. // -> hw_oqspi_set_manual_access_bus_mode(SINGLE)
      26. // OQSPIF_CTRLBUS_REG -> Set single mode
      27. W4 0x36000000 0x1
      28. sleep 100
      29. // -> hw_oqspi_set_io(SINGLE)
      30. // OQSPIF_CTRLMODE_REG
      31. // SET OSPIC_IO2/3_OEN and OSPIC_IO2/3_DAT
      32. // also disable OSPIC_IO_UH_OEN
      33. W4 0x36000004 0xF0018FBE
      34. sleep 100
      35. // oqspi_mx25u6432_enable_quad_mode
      36. // OQSPIF_CTRLBUS_REG -> chip select enable
      37. W4 0x36000000 0x10
      38. sleep 200
      39. // OQSPIF_WRITEDATA_REG -> Write enable latch opcode
      40. W1 0x36000018 0x6
      41. // OQSPIF_CTRLBUS_REG -> chip select disable
      42. W4 0x36000000 0x20
      43. sleep 100
      44. // OQSPIF_CTRLBUS_REG -> chip select enable
      45. W4 0x36000000 0x10
      46. // OQSPIF_WRITEDATA_REG -> OQSPI_WRITE_STATUS_REG_OPCODE
      47. W1 0x36000018 0x1
      48. sleep 20
      49. // OQSPIF_WRITEDATA_REG -> 0x<config_reg><status reg> (one byte each)
      50. // status reg = OQSPI_MACRONIX_QUAD_STATUS_REG_QUAD_ENABLE_MASK
      51. // config reg = default dummy cycles and drive strength config (MX25U6432F datasheet)
      52. W2 0x36000018 0x0740
      53. sleep 100
      54. // OQSPIF_CTRLBUS_REG -> chip select disable
      55. W4 0x36000000 0x20
      56. sleep 100
      57. // Reset using pin. There is one on the board and that's the only one that work to get the card to boot
      58. RSetType 2
      59. ResetX 500
      60. go
      61. q
      Display All

      If I understood the documentation right, this SoC should be able to be able to read the first sectors of the flash to configure itself for fast XiP mode (lpccs-docs.renesas.com/um-b-15…html#da1470x-flash-layout -> product header). I tried to configure the flash controller in single spi mode to use this mechanism to no avail, only quad spi (as in the code snippet above) seems to do the trick. I also did not try to optimize the script, I really emulated what the SDK functions did.

      I'm not sure if the bug is in J-Link or Renesas and if it can be fixed, but if this workaround can save some poor soul some time that's already worth it :)

      I'm using J-Link V7.98d and SDK-10.2.6.49 on MacOS. The problem was already present in J-Link V7.96b.