c2port.txt 2.8 KB

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