c2port.rst 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. .. SPDX-License-Identifier: GPL-2.0
  2. .. include:: <isonum.txt>
  3. ===============
  4. C2 port support
  5. ===============
  6. (C) Copyright 2007 Rodolfo Giometti <giometti@enneenne.com>
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. Overview
  16. --------
  17. This driver implements the support for Linux of Silicon Labs (Silabs)
  18. C2 Interface used for in-system programming of micro controllers.
  19. By using this driver you can reprogram the in-system flash without EC2
  20. or EC3 debug adapter. This solution is also useful in those systems
  21. where the micro controller is connected via special GPIOs pins.
  22. References
  23. ----------
  24. The C2 Interface main references are at (https://www.silabs.com)
  25. Silicon Laboratories site], see:
  26. - AN127: FLASH Programming via the C2 Interface at
  27. https://www.silabs.com/Support Documents/TechnicalDocs/an127.pdf
  28. - C2 Specification at
  29. https://www.silabs.com/pages/DownloadDoc.aspx?FILEURL=Support%20Documents/TechnicalDocs/an127.pdf&src=SearchResults
  30. however it implements a two wire serial communication protocol (bit
  31. banging) designed to enable in-system programming, debugging, and
  32. boundary-scan testing on low pin-count Silicon Labs devices. Currently
  33. this code supports only flash programming but extensions are easy to
  34. add.
  35. Using the driver
  36. ----------------
  37. Once the driver is loaded you can use sysfs support to get C2port's
  38. info or read/write in-system flash::
  39. # ls /sys/class/c2port/c2port0/
  40. access flash_block_size flash_erase rev_id
  41. dev_id flash_blocks_num flash_size subsystem/
  42. flash_access flash_data reset uevent
  43. Initially the C2port access is disabled since you hardware may have
  44. such lines multiplexed with other devices so, to get access to the
  45. C2port, you need the command::
  46. # echo 1 > /sys/class/c2port/c2port0/access
  47. after that you should read the device ID and revision ID of the
  48. connected micro controller::
  49. # cat /sys/class/c2port/c2port0/dev_id
  50. 8
  51. # cat /sys/class/c2port/c2port0/rev_id
  52. 1
  53. However, for security reasons, the in-system flash access in not
  54. enabled yet, to do so you need the command::
  55. # echo 1 > /sys/class/c2port/c2port0/flash_access
  56. After that you can read the whole flash::
  57. # cat /sys/class/c2port/c2port0/flash_data > image
  58. erase it::
  59. # echo 1 > /sys/class/c2port/c2port0/flash_erase
  60. and write it::
  61. # cat image > /sys/class/c2port/c2port0/flash_data
  62. after writing you have to reset the device to execute the new code::
  63. # echo 1 > /sys/class/c2port/c2port0/reset