README.txt 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. Console over Lightweight Link
  2. =============================
  3. LWL is a Lightweight bidirectional communication between target and debug host
  4. without any need for additional hardware.
  5. It works with openOCD and other debuggers that are capable of reading and
  6. writing memory while the target is running...it should run with JLink
  7. for example, if you've got the SDK and modify this file accordingly.
  8. Principle of operation is simple; An 'upword' of 32 bits communicates
  9. from the target to the host, a 'downword' of the same size runs in the
  10. opposite direction. These two words can be in any memory that is
  11. read/write access for both the target and the debug host. A simple ping
  12. pong handshake protocol over these words allows up/down link communication.
  13. On the upside no additional integration is needed. On the downside it may be
  14. necessary to feed lwl with cycles to poll for changes in the downword,
  15. depending on the use case. For the case of a simple console, that's not
  16. needed.
  17. For convenience these communication locations are automatically discovered
  18. from the RAM by searching through it. Just define downwordaddr and
  19. upwordaddr if you want to work with fixed locations.
  20. Bit configuration
  21. -----------------
  22. Downword (Host to target);
  23. A D U VV XXX O2 O1 O0
  24. A 31 1 - Service Active (Set by host)
  25. D 30 1 - Downsense (Toggled when there is data)
  26. U 29 1 - Upsense ack (Toggled to acknowledge receipt of uplink data)
  27. VV 28-27 2 - Valid Octets (Number of octets valid in the message)
  28. XXX 26-24 3 - Port in use (Type of the message)
  29. O2 23-16 8 - Octet 2
  30. O1 15-08 8 - Octet 1
  31. O0 07-00 8 - Octet 0
  32. Upword (Target to Host);
  33. A 31 1 - Service Active (Set by device)
  34. D 30 1 - Downsense ack (Toggled to acknowledge receipt of downlink data)
  35. U 29 1 - Upsense (Toggled when there is data)
  36. VV 28-27 2 - Valid upword octets
  37. XXX 26-24 3 - Port in use (Type of the message)
  38. O2 23-16 8 - Octet 2
  39. O1 15-08 8 - Octet 1
  40. O0 07-00 8 - Octet 0
  41. Port 1 is used for Console. No other ports are currently defined.
  42. Usage
  43. =====
  44. No special python modules are needed, it should be possible to run the
  45. application simply as shown below:
  46. In the first terminal execute the openocd command to connect to the board.
  47. Assuming that you already flashed to firmware (nuttx.bin) with the LWL
  48. console support. For stm32f4discovery board I use this command:
  49. ------------------------------------------
  50. $ sudo openocd -f board/stm32f4discovery.cfg
  51. Open On-Chip Debugger v0.10.0-esp32-20200526-6-g4c41a632 (2020-06-23-10:12)
  52. Licensed under GNU GPL v2
  53. For bug reports, read
  54. http://openocd.org/doc/doxygen/bugs.html
  55. Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
  56. srst_only separate srst_nogate srst_open_drain connect_deassert_srst
  57. Info : Listening on port 6666 for tcl connections
  58. Info : Listening on port 4444 for telnet connections
  59. Info : clock speed 2000 kHz
  60. Info : STLINK V2J17S0 (API v2) VID:PID 0483:3748
  61. Info : Target voltage: 3.216252
  62. Info : stm32f4x.cpu: hardware has 6 breakpoints, 4 watchpoints
  63. Info : Listening on port 3333 for gdb connections
  64. Info : accepting 'tcl' connection on tcp/6666
  65. invalid command name "ocd_mdw"
  66. 0x20000000: 000000ff
  67. 0x20000000: 000000ff
  68. 0x20000004: 7216a318
  69. 0x2000000c: 994b5b1b
  70. 0x2000000c: 994b5b1b
  71. 0x2000000c: 994b5b1b
  72. ...
  73. The "0x2000000c:..." will repeat all the time.
  74. Now in another terminal execute:
  75. ------------------------------------------
  76. $ ./ocdconsole.py
  77. ==Link Activated
  78. nsh>
  79. nsh> help
  80. help usage: help [-v] [<cmd>]
  81. ? echo exit hexdump ls mh sleep xd
  82. cat exec help kill mb mw usleep
  83. nsh>
  84. ------------------------------------------
  85. This code is designed to be 'hardy' and will survive a shutdown and
  86. restart of the openocd process. When your target application
  87. changes then the location of the upword and downword may change,
  88. so they are re-searched for again. To speed up the start process
  89. consider putting those words at fixed locations (e.g. via the
  90. linker file) and referencing them directly.
  91. Future work/Improvements
  92. ========================
  93. Currently the lwl driver on NuttX side is doing polling, but for
  94. better performance it could use interrupts to detect when the memory
  95. position was modified to read the data.
  96. It also will avoid using busy waiting inside the driver, look at
  97. nuttx/arch/arm/src/common/arm_lwl_console.c for more information.