CR600.JLinkScript 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*********************************************************************
  2. * (c) 1995 - 2018 SEGGER Microcontroller GmbH *
  3. * The Embedded Experts *
  4. * www.segger.com *
  5. **********************************************************************
  6. -------------------------- END-OF-HEADER -----------------------------
  7. File : ClouderSemi_CR600.JLinkScript
  8. Purpose : Contains device specific handling for ClouderSemi's CR600 series
  9. Literature:
  10. [1] J-Link User Guide
  11. Additional information:
  12. For more information about public functions that can be implemented in order to customize J-Link actions, please refer to [1]
  13. */
  14. /*********************************************************************
  15. *
  16. * Global functions
  17. *
  18. **********************************************************************
  19. */
  20. /*********************************************************************
  21. *
  22. * ResetTarget
  23. */
  24. int AfterResetTarget(void) {
  25. //
  26. // The flash of the CR600 (Cortex-M0) is located at address 0x20000000. This makes problems
  27. // for the IDE / debug probe as a default debug session start would fail as no breakpoint can
  28. // be set at the beginning of the application (flash) for two reasons:
  29. // 1) HW breakpoint --> Does not work due to the limitation of the core (does not allow HW BPs at addresses >= 0x20000000)
  30. // 2) Software breakpoint --> Does not work as it is flash memory
  31. //
  32. // Respecting those limitations, the only way to perform a correct debug session start (CPU
  33. // is halted at the application start (using a breakpoint) is to use flash breakpoints. Unfortunately,
  34. // the flash cannot be access after reset as it is enabled when the bootloader is executed. As there
  35. // is no option to halt the CPU *after* bootloader execution and *before* any target application code has been executed,
  36. // we perform some parts of the bootloader manually which allow us to program the flash and therefore allow us to set a
  37. // flash breakpoint at the application start.
  38. //
  39. // The sequence below comes from ClouderSemi.
  40. // SEGGER does neither provide any support for it nor guarantees the correct functionality.
  41. //
  42. JLINK_SYS_Report("Executing AfterResetTarget()");
  43. JLINK_MEM_WriteU32(0x4009B050, 0x3C);
  44. JLINK_MEM_WriteU32(0x40085000, 0x10);
  45. JLINK_MEM_WriteU32(0x40085008, 0x8);
  46. JLINK_MEM_WriteU32(0x4008500C, 0x3);
  47. JLINK_MEM_WriteU32(0x40085010, 0x18);
  48. JLINK_MEM_WriteU32(0x4008502C, 0x0);
  49. JLINK_MEM_WriteU32(0x40085004, 0x3012);
  50. return 0;
  51. }
  52. /*************************** end of file ****************************/