My Marlin configs for Fabrikator Mini and CTC i3 Pro B
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.

unwmemaccess.cpp 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /***************************************************************************
  2. * ARM Stack Unwinder, Michael.McTernan.2001@cs.bris.ac.uk
  3. * Updated, adapted and several bug fixes on 2018 by Eduardo José Tagle
  4. *
  5. * This program is PUBLIC DOMAIN.
  6. * This means that there is no copyright and anyone is able to take a copy
  7. * for free and use it as they wish, with or without modifications, and in
  8. * any context, commercially or otherwise. The only limitation is that I
  9. * don't guarantee that the software is fit for any purpose or accept any
  10. * liability for it's use or misuse - this software is without warranty.
  11. ***************************************************************************
  12. * File Description: Utility functions to access memory
  13. **************************************************************************/
  14. #if defined(__arm__) || defined(__thumb__)
  15. #include "unwmemaccess.h"
  16. /* Validate address */
  17. #ifdef ARDUINO_ARCH_SAM
  18. // For DUE, valid address ranges are
  19. // SRAM (0x20070000 - 0x20088000) (96kb)
  20. // FLASH (0x00080000 - 0x00100000) (512kb)
  21. //
  22. #define START_SRAM_ADDR 0x20070000
  23. #define END_SRAM_ADDR 0x20088000
  24. #define START_FLASH_ADDR 0x00080000
  25. #define END_FLASH_ADDR 0x00100000
  26. #endif
  27. #ifdef TARGET_LPC1768
  28. // For LPC1769:
  29. // SRAM (0x10000000 - 0x10008000) (32kb)
  30. // FLASH (0x00000000 - 0x00080000) (512kb)
  31. //
  32. #define START_SRAM_ADDR 0x10000000
  33. #define END_SRAM_ADDR 0x10008000
  34. #define START_FLASH_ADDR 0x00000000
  35. #define END_FLASH_ADDR 0x00080000
  36. #endif
  37. #if 0
  38. // For STM32F103CBT6
  39. // SRAM (0x20000000 - 0x20005000) (20kb)
  40. // FLASH (0x00000000 - 0x00020000) (128kb)
  41. //
  42. #define START_SRAM_ADDR 0x20000000
  43. #define END_SRAM_ADDR 0x20005000
  44. #define START_FLASH_ADDR 0x00000000
  45. #define END_FLASH_ADDR 0x00020000
  46. #endif
  47. #ifdef __STM32F1__
  48. // For STM32F103ZET6/STM32F103VET6
  49. // SRAM (0x20000000 - 0x20010000) (64kb)
  50. // FLASH (0x00000000 - 0x00080000) (512kb)
  51. //
  52. #define START_SRAM_ADDR 0x20000000
  53. #define END_SRAM_ADDR 0x20010000
  54. #define START_FLASH_ADDR 0x00000000
  55. #define END_FLASH_ADDR 0x00080000
  56. #endif
  57. #if defined(STM32F4) || defined(STM32F4xx)
  58. // For STM32F407VET
  59. // SRAM (0x20000000 - 0x20030000) (192kb)
  60. // FLASH (0x08000000 - 0x08080000) (512kb)
  61. //
  62. #define START_SRAM_ADDR 0x20000000
  63. #define END_SRAM_ADDR 0x20030000
  64. #define START_FLASH_ADDR 0x08000000
  65. #define END_FLASH_ADDR 0x08080000
  66. #endif
  67. #ifdef STM32F7
  68. // For STM32F765 in BORG
  69. // SRAM (0x20000000 - 0x20080000) (512kb)
  70. // FLASH (0x08000000 - 0x08100000) (1024kb)
  71. //
  72. #define START_SRAM_ADDR 0x20000000
  73. #define END_SRAM_ADDR 0x20080000
  74. #define START_FLASH_ADDR 0x08000000
  75. #define END_FLASH_ADDR 0x08100000
  76. #endif
  77. #ifdef __MK64FX512__
  78. // For MK64FX512 in TEENSY 3.5
  79. // SRAM (0x1FFF0000 - 0x20020000) (192kb)
  80. // FLASH (0x00000000 - 0x00080000) (512kb)
  81. //
  82. #define START_SRAM_ADDR 0x1FFF0000
  83. #define END_SRAM_ADDR 0x20020000
  84. #define START_FLASH_ADDR 0x00000000
  85. #define END_FLASH_ADDR 0x00080000
  86. #endif
  87. #ifdef __MK66FX1M0__
  88. // For MK66FX1M0 in TEENSY 3.6
  89. // SRAM (0x1FFF0000 - 0x20030000) (256kb)
  90. // FLASH (0x00000000 - 0x00140000) (1.25Mb)
  91. //
  92. #define START_SRAM_ADDR 0x1FFF0000
  93. #define END_SRAM_ADDR 0x20030000
  94. #define START_FLASH_ADDR 0x00000000
  95. #define END_FLASH_ADDR 0x00140000
  96. #endif
  97. static bool validate_addr(uint32_t addr) {
  98. // Address must be in SRAM range
  99. if (addr >= START_SRAM_ADDR && addr < END_SRAM_ADDR)
  100. return true;
  101. // Or in FLASH range
  102. if (addr >= START_FLASH_ADDR && addr < END_FLASH_ADDR)
  103. return true;
  104. return false;
  105. }
  106. bool UnwReadW(const uint32_t a, uint32_t *v) {
  107. if (!validate_addr(a))
  108. return false;
  109. *v = *(uint32_t *)a;
  110. return true;
  111. }
  112. bool UnwReadH(const uint32_t a, uint16_t *v) {
  113. if (!validate_addr(a))
  114. return false;
  115. *v = *(uint16_t *)a;
  116. return true;
  117. }
  118. bool UnwReadB(const uint32_t a, uint8_t *v) {
  119. if (!validate_addr(a))
  120. return false;
  121. *v = *(uint8_t *)a;
  122. return true;
  123. }
  124. #endif