debugging.tex 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. Debugging hardware can be tricky especially when doing kernel and drivers
  2. development. It might become handy for you to add serial console to your
  3. device as well as using JTAG to debug your code.
  4. \subsection{Adding a serial port}
  5. Most routers come with an UART integrated into the System-on-chip
  6. and its pins are routed on the Printed Circuit Board to allow
  7. debugging, firmware replacement or serial device connection (like
  8. modems).
  9. Finding an UART on a router is fairly easy since it only needs at
  10. least 4 signals (without modem signaling) to work : VCC, GND, TX and
  11. RX. Since your router is very likely to have its I/O pins working at
  12. 3.3V (TTL level), you will need a level shifter such as a Maxim MAX232
  13. to change the level from 3.3V to your computer level which is usually
  14. at 12V.
  15. To find out the serial console pins on the PCB, you will be looking
  16. for a populated or unpopulated 4-pin header, which can be far from
  17. the SoC (signals are relatively slow) and usually with tracks on
  18. the top or bottom layer of the PCB, and connected to the TX and RX.
  19. Once found, you can easily check where is GND, which is connected to
  20. the same ground layer than the power connector. VCC should be fixed
  21. at 3.3V and connected to the supply layer, TX is also at 3.3V level
  22. but using a multimeter as an ohm-meter and showing an infinite
  23. value between TX and VCC pins will tell you about them being different
  24. signals (or not). RX and GND are by default at 0V, so using the same
  25. technique you can determine the remaining pins like this.
  26. If you do not have a multimeter a simple trick that usually works is
  27. using a speaker or a LED to determine the 3.3V signals. Additionnaly
  28. most PCB designer will draw a square pad to indicate ping number 1.
  29. Once found, just interface your level shifter with the device and the
  30. serial port on the PC on the other side. Most common baudrates for the
  31. off-the-shelf devices are 9600, 38400 and 115200 with 8-bits data, no
  32. parity, 1-bit stop.
  33. \subsection{JTAG}
  34. JTAG stands for Joint Test Action Group, which is an IEEE workgroup
  35. defining an electrical interface for integrated circuit testing and
  36. programming.
  37. There is usually a JTAG automate integrated into your System-on-Chip
  38. or CPU which allows an external software, controlling the JTAG adapter
  39. to make it perform commands like reads and writes at arbitray locations.
  40. Additionnaly it can be useful to recover your devices if you erased the
  41. bootloader resident on the flash.
  42. Different CPUs have different automates behavior and reset sequence,
  43. most likely you will find ARM and MIPS CPUs, both having their standard
  44. to allow controlling the CPU behavior using JTAG.
  45. Finding JTAG connector on a PCB can be a little easier than finding the
  46. UART since most vendors leave those headers unpopulated after production.
  47. JTAG connectors are usually 12, 14, or 20-pins headers with one side of
  48. the connector having some signals at 3.3V and the other side being
  49. connected to GND.