JTAG DCC channel for terminal I/O (was: wishlist)

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

  • JTAG DCC channel for terminal I/O (was: wishlist)

    Hello

    since we are approaching Christmas, I would submit to Segger JLink tech guys this request: can you realize a little simple terminal program (freeware I hope), to monitor the DCC channel for debug I/O with ARM micros?

    It would be very helpful to receive (and send) data through the JTAG privileged channel, and near unintrusively respect to ARM (I know ARM needs little code snippets to communicate with DCC).

    Thanks

    The post was edited 1 time, last by suppgrg ().

  • Hello,

    thanks for sharing the idea. We will create a little (free) utility.
    We are quite busy right now, so it may take a few weeks.

    In the meantime, we'll add a command to J-Link commander (jlink.exe) which does the same thing:
    "term" will act as a DCC terminal until the user presses Crtl-C.

    It is already working;
    we'll make this available in the next Beta version, probably tomorrow.

    Happy holidays!
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hello,

    The upcoming J-Link Commander version includes the terminal function.
    Attached a picture which shows this feature. We have included a DCC handler in our TCP/IP stack, showing debug information .

    DCC routines for IAR and GNU ARM tool suite will be included in the J-Link software package.

    You can download the latest BETA version of the software from the J-Link download page.

    You just need to implement your debug I/O routines using the DCC routines.
    Of course it is also necessary to periodically call the DCC_Process() function, e.g. in a timer interrupt.

    Let us know if you need further help.

    Happy holidays...

    Souhail
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • For those who cannot wait to add DCC source code their application:

    Here the implementation for the GNU ARM tool suite:

    C Source Code

    1. /*********************************************************************
    2. * SEGGER MICROCONTROLLER SYSTEME GmbH *
    3. * Solutions for real time microcontroller applications *
    4. **********************************************************************
    5. * *
    6. * (c) 2006 -2007 SEGGER Microcontroller Systeme GmbH *
    7. * *
    8. * Internet: www.segger.com Support: support@segger.com *
    9. * *
    10. **********************************************************************
    11. ----------------------------------------------------------------------
    12. File : JLINKDCC_Process.c
    13. Purpose : Data handler for ARM J-Link type communication via DCC
    14. Notes : (1) How to use
    15. In order to use the DCC communication to read / write memory, the
    16. following needs to be done:
    17. * Add this file to the project / make-file
    18. * Make sure this data handler is called regularly
    19. * Add the JLINKDCC data abort handler (optional)
    20. For details, refer to the documentation or see file JLINKDCC_HandleDataAbort.s79.
    21. (2) Compatibility
    22. The J-Link ARM DCC handler is compatible to the DCC communication
    23. protocol used by IAR in the embedded workbench for ARM and allows
    24. using the live data window in C-Spy
    25. ---------------------------END-OF-HEADER------------------------------
    26. */
    27. #include "JLINKDCC.h"
    28. extern unsigned long CP14_ReadDCCStat(void);
    29. extern unsigned long CP14_ReadDCC(void);
    30. extern void CP14_WriteDCC(unsigned long Data);
    31. /*********************************************************************
    32. *
    33. * Defines, configurable
    34. *
    35. **********************************************************************
    36. */
    37. #define SUPPORT_READ_U8 1 // Support byte reads if 1. 0 to disable.
    38. #define SUPPORT_READ_U16 1 // Support half word reads if 1. 0 to disable.
    39. #define SUPPORT_READ_U32 1 // Support word reads if 1. 0 to disable.
    40. #define SUPPORT_WRITE_U8 1 // Support byte writes if 1. 0 to disable.
    41. #define SUPPORT_WRITE_U16 1 // Support half word writes if 1. 0 to disable.
    42. #define SUPPORT_WRITE_U32 1 // Support word writes if 1. 0 to disable.
    43. #define SUPPORT_ABORT 1 // Support aborts.
    44. /*********************************************************************
    45. *
    46. * Defines, non- configurable
    47. *
    48. **********************************************************************
    49. */
    50. #define U8 unsigned char
    51. #define U16 unsigned short
    52. #define U32 unsigned int
    53. #define DCC_OP_READ_U32 0x01000000
    54. #define DCC_OP_READ_U16 0x02000000
    55. #define DCC_OP_READ_U8 0x04000000
    56. #define DCC_OP_GET_CAPS 0x08000000
    57. #define DCC_OP_WRITE_U32 0x10000000
    58. #define DCC_OP_WRITE_U16 0x20000000
    59. #define DCC_OP_WRITE_U8 0x40000000
    60. #define DCC_OP_ODD_ADDR 0x80000000
    61. #define DCC_OP_COMMAND 0x00000001
    62. #define DCC_CAP_READ_U32 0x01
    63. #define DCC_CAP_READ_U16 0x02
    64. #define DCC_CAP_READ_U8 0x04
    65. #define DCC_CAP_ABORT 0x08
    66. #define DCC_CAP_WRITE_U32 0x10
    67. #define DCC_CAP_WRITE_U16 0x20
    68. #define DCC_CAP_WRITE_U8 0x40
    69. #define DCC_SIGNATURE 0x91CA0000
    70. #define DCC_CONFIG ((DCC_CAP_READ_U8 * SUPPORT_READ_U8) \
    71. | (DCC_CAP_READ_U16 * SUPPORT_READ_U16) \
    72. | (DCC_CAP_READ_U32 * SUPPORT_READ_U32) \
    73. | (DCC_CAP_WRITE_U8 * SUPPORT_WRITE_U8) \
    74. | (DCC_CAP_WRITE_U16 * SUPPORT_WRITE_U16) \
    75. | (DCC_CAP_WRITE_U32 * SUPPORT_WRITE_U32) \
    76. | (DCC_CAP_ABORT * SUPPORT_ABORT))
    77. #define SUPPORT_WRITE (SUPPORT_WRITE_U8 | SUPPORT_WRITE_U16 | SUPPORT_WRITE_U32)
    78. /*********************************************************************
    79. *
    80. * Global data
    81. *
    82. **********************************************************************
    83. */
    84. U8 JLINKDCC_IsInHandler;
    85. U8 JLINKDCC_AbortOccurred;
    86. /*********************************************************************
    87. *
    88. * Static data
    89. *
    90. **********************************************************************
    91. */
    92. static U16 _NumReadItems;
    93. static U32 _Command;
    94. static U32 _Addr;
    95. static char _acBuffer[256];
    96. static int _RdPos;
    97. static int _WrPos;
    98. #if (SUPPORT_WRITE)
    99. static U32 _Data;
    100. #endif
    101. /*********************************************************************
    102. *
    103. * Public code
    104. *
    105. **********************************************************************
    106. */
    107. /*********************************************************************
    108. *
    109. * DCC_Process
    110. *
    111. * Function description
    112. * This function should be called more or less regularily to allow
    113. * memory reads while the application progam is running.
    114. * The more often it is called, the higher the memory read speed.
    115. */
    116. void DCC_Process(void) {
    117. U32 Data;
    118. //
    119. // Avoid problems if this code is called from multiple threads or interrupts
    120. //
    121. if (JLINKDCC_IsInHandler) {
    122. return;
    123. }
    124. JLINKDCC_IsInHandler = 1;
    125. //
    126. // Perform communication for memory read / write as far as configured
    127. //
    128. if (CP14_ReadDCCStat() & 1) {
    129. Data = CP14_ReadDCC();
    130. if (Data & DCC_OP_COMMAND) {
    131. _Command = Data;
    132. #if (DCC_CONFIG & (DCC_CAP_READ_U8 | DCC_CAP_WRITE_U8))
    133. if (_Command & DCC_OP_ODD_ADDR) {
    134. _Addr |= 1;
    135. }
    136. #endif
    137. if (_Command & (DCC_OP_READ_U32 | DCC_OP_READ_U16 | DCC_OP_READ_U8 | DCC_OP_GET_CAPS)) {
    138. _NumReadItems = (_Command >> 2) & 0xffff;
    139. } else {
    140. #if (DCC_CONFIG & DCC_CAP_WRITE_U32)
    141. if (_Command & DCC_OP_WRITE_U32) {
    142. _Data |= (_Command << 14) & 0xffff0000;
    143. } else
    144. #endif
    145. #if (SUPPORT_WRITE)
    146. {
    147. _Data = (_Command >> 2) & 0xffff;
    148. }
    149. #endif
    150. #if (DCC_CONFIG & DCC_CAP_WRITE_U8)
    151. if (_Command & DCC_OP_WRITE_U8) {
    152. *(U8*)_Addr = _Data;
    153. _Addr += 1;
    154. }
    155. #endif
    156. #if (DCC_CONFIG & DCC_CAP_WRITE_U16)
    157. if (_Command & DCC_OP_WRITE_U16) {
    158. *(U16*)_Addr = _Data;
    159. _Addr += 2;
    160. }
    161. #endif
    162. #if (DCC_CONFIG & DCC_CAP_WRITE_U32)
    163. if (_Command & DCC_OP_WRITE_U32) {
    164. *(U32*)_Addr =_Data;
    165. _Addr += 4;
    166. }
    167. #endif
    168. }
    169. goto Done;
    170. }
    171. _Addr = Data;
    172. }
    173. if (_NumReadItems) {
    174. if ((CP14_ReadDCCStat() & 2) == 0) {
    175. Data = (DCC_CONFIG | DCC_SIGNATURE);
    176. #if (DCC_CONFIG & DCC_CAP_ABORT)
    177. Data |= (JLINKDCC_AbortOccurred << 8);
    178. if (_Command & DCC_OP_GET_CAPS) {
    179. JLINKDCC_AbortOccurred = 0;
    180. }
    181. #endif
    182. #if (DCC_CONFIG & DCC_CAP_READ_U8)
    183. if (_Command & DCC_OP_READ_U8) {
    184. Data = *(U8*)_Addr;
    185. _Addr += 1;
    186. }
    187. #endif
    188. #if (DCC_CONFIG & DCC_CAP_READ_U16)
    189. if (_Command & DCC_OP_READ_U16) {
    190. Data = *(U16*)_Addr;
    191. _Addr += 2;
    192. }
    193. #endif
    194. #if (DCC_CONFIG & DCC_CAP_READ_U32)
    195. if (_Command & DCC_OP_READ_U32) {
    196. Data = *(U32*)_Addr;
    197. _Addr += 4;
    198. }
    199. #endif
    200. CP14_WriteDCC(Data);
    201. _NumReadItems--;
    202. }
    203. }
    204. Done:
    205. //
    206. // Handle terminal out. Up to 3 bytes in one 32-bit unit
    207. //
    208. if ((CP14_ReadDCCStat() & 2) == 0) {
    209. int NumBytes;
    210. NumBytes = _WrPos - _RdPos;
    211. if (NumBytes < 0) {
    212. NumBytes += sizeof(_acBuffer);
    213. }
    214. if (NumBytes) {
    215. int i;
    216. if (NumBytes > 3) {
    217. NumBytes = 3;
    218. }
    219. Data = 0;
    220. for (i = 0; i < NumBytes; i++) {
    221. Data |= _acBuffer[_RdPos] << (8*i);
    222. _RdPos++;
    223. if (_RdPos == sizeof(_acBuffer)) {
    224. _RdPos = 0;
    225. }
    226. }
    227. Data |= (NumBytes - 1) << 24;
    228. CP14_WriteDCC(Data);
    229. }
    230. }
    231. JLINKDCC_IsInHandler = 0;
    232. }
    233. /*********************************************************************
    234. *
    235. * JLINKDCC_SendChar
    236. *
    237. * Function description
    238. */
    239. void JLINKDCC_SendChar(char c) {
    240. int Pos;
    241. Pos = _WrPos + 1;
    242. if (Pos == sizeof(_acBuffer)) {
    243. Pos = 0;
    244. }
    245. if (Pos == _RdPos) {
    246. return;
    247. }
    248. _acBuffer[_WrPos] = c;
    249. _WrPos = Pos;
    250. }
    251. /*********************************************************************
    252. *
    253. * JLINKDCC_SendString
    254. *
    255. * Function description
    256. */
    257. void JLINKDCC_SendString(const char * s) {
    258. char c;
    259. while (1) {
    260. c = *s++;
    261. if (c == 0) {
    262. break;
    263. }
    264. JLINKDCC_SendChar(c);
    265. }
    266. }
    267. /*************************** end of file ****************************/
    Display All

    Brainfuck Source Code

    1. /**********************************************************
    2. * SEGGER MICROCONTROLLER SYSTEME GmbH
    3. * Solutions for real time microcontroller applications
    4. ***********************************************************
    5. *
    6. * File : JLINKDCC_Process_ASM.s
    7. * Purpose : Routines for setting and writing co-processor register CP14
    8. (DCC-communication) (GNU ARM tool suite)
    9. --------- END-OF-HEADER ---------------------------------
    10. */
    11. /*********************************************************************
    12. *
    13. * GNU ARM
    14. *
    15. */
    16. .text
    17. .global CP14_ReadDCCStat
    18. .global CP14_ReadDCC
    19. .global CP14_WriteDCC
    20. .arm
    21. .section .text, "ax"
    22. /*********************************************************************
    23. *
    24. * Public code
    25. *
    26. **********************************************************************
    27. */
    28. /*********************************************************************
    29. *
    30. * CP14_ReadDCCStat
    31. */
    32. CP14_ReadDCCStat:
    33. mrc P14,0,R0,C0,C0,0
    34. bx lr
    35. /*********************************************************************
    36. *
    37. * CP14_ReadDCC
    38. */
    39. CP14_ReadDCC:
    40. mrc P14,0,R0,C1,C0,0
    41. bx lr
    42. /*********************************************************************
    43. *
    44. * CP14_WriteDCC
    45. */
    46. CP14_WriteDCC:
    47. mcr P14,0,R0,C1,C0,0
    48. bx lr
    49. .end
    50. /**************************** End of file ***************************/
    Display All


    -- Souhail
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • DCC Terminal Input from Host to Target

    Hello,

    In my opinion, it seems there is no way to receive data from Host to the Target (using JLINK>term command), but only it is possible to use it as a simple Target to Host console.
    When using jlink3.79h_beta after any key-press the 'term' session exit.

    My idea was to write a simple terminal with VT100 escape capabilites using DCC,
    but in the Jlink-SDK package there is no example on using:


    JLINKARM_ReadDcc()
    JLINKARM_WriteDcc()

    Anyone, does have some knowledge on that?


    Thanks!
  • Hello "Gelware",

    the J-Link SDK contains the source code of the J-Link commander (Jlink.exe).
    Since the current Beta supports the "term" command, it uses the DCC read/write functions
    and and be used as sample.

    Please contact us (info@segger.com) and we'll send you the latest SDK.

    You are right that the J-Link commanders "term" command supports one-way
    communication only currently and is not a full terminal, but it would indeed
    be quite helpful to have such an application, preferably stand-alone.

    Best regards,
    Rolf
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • hello,
    i would like to reanimate this thread because i would like to use the dcc feature too.
    I would be interested in using the dcc in conjunction with the terminal i/o window of the iar workbench.
    sending from the target to the debugger through dcc is working fine by including the jlinkdcc_process.c module and periodically calling the function JLINKDCC_Process() at the target.
    but i'm not able to receive characters which are send from the terminal i/o window to the target. _HandleRead() is called peridodically but _ReadDCCStat() returns always 0. so it seems that dcc is only working in one direction.
    is this a known problem or already not implemented feature?
    many thanks in advance
    gerhard