← Documents Documentation/misc-devices/c2port.rst GitHub 원문 ↗

Linux 6.18.37 · Misc devices

C2 Port Support

Silicon Labs C2 2-wire interface로 microcontroller flash를 읽고 지우고 쓰는 Linux sysfs 절차를 설명합니다.

Source pathDocumentation/misc-devices/c2port.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

c2port.rst:1-94

C2port는 별도 EC2/EC3 adapter 없이 GPIO에 연결된 Silabs microcontroller flash를 programming합니다. Pin multiplex와 보안을 고려해 port access와 flash access를 두 단계로 enable합니다.

C2 flash programming
access=1dev_id·rev_id 확인flash_access=1read·erase·writereset=1

Access enable, 식별, flash permission, image 작업, reset 순서로 진행합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

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

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

저작권과 license

1-21

Copyright 2007 Rodolfo Giometti <[email protected]>. 이 program은 Free Software Foundation이 공표한 GNU General Public License version 2 또는 선택에 따라 그 이후 version의 조건으로 재배포하거나 수정할 수 있습니다.

유용하리라는 기대 아래 배포하지만 상품성이나 특정 목적 적합성에 대한 묵시적 보증을 포함해 어떠한 보증도 없습니다. 자세한 내용은 GNU General Public License를 참조합니다.

.. SPDX-License-Identifier: GPL-2.0
.. include:: <isonum.txt>

===============
C2 port support
===============

(C) Copyright 2007 Rodolfo Giometti <[email protected]>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.


개요

22-31

이 driver는 Silicon Labs(Silabs) microcontroller의 in-system programming에 사용하는 C2 Interface를 Linux에서 지원합니다.

EC2 또는 EC3 debug adapter 없이 in-system flash를 다시 programming할 수 있으며 microcontroller가 특수 GPIO pin으로 연결된 system에도 유용합니다.

Overview
--------

This driver implements the support for Linux of Silicon Labs (Silabs)
C2 Interface used for in-system programming of micro controllers.

By using this driver you can reprogram the in-system flash without EC2
or EC3 debug adapter. This solution is also useful in those systems
where the micro controller is connected via special GPIOs pins.

Reference와 protocol 범위

32-49

주요 reference는 Silicon Laboratories site의 `AN127: FLASH Programming via the C2 Interface`와 `C2 Specification`입니다. 원문 URL을 그대로 제공합니다.

C2는 low-pin-count Silicon Labs device에서 in-system programming, debugging, boundary-scan test를 가능하게 하는 2-wire serial bit-banging protocol입니다. 현재 code는 flash programming만 지원하지만 확장하기 쉽습니다.

References
----------

The C2 Interface main references are at (https://www.silabs.com)
Silicon Laboratories site], see:

- AN127: FLASH Programming via the C2 Interface at
  https://www.silabs.com/Support Documents/TechnicalDocs/an127.pdf

- C2 Specification at
  https://www.silabs.com/pages/DownloadDoc.aspx?FILEURL=Support%20Documents/TechnicalDocs/an127.pdf&src=SearchResults

however it implements a two wire serial communication protocol (bit
banging) designed to enable in-system programming, debugging, and
boundary-scan testing on low pin-count Silicon Labs devices. Currently
this code supports only flash programming but extensions are easy to
add.

Driver 사용법

50-94

Driver를 load하면 `/sys/class/c2port/c2port0/`의 sysfs attribute로 C2port 정보를 얻고 in-system flash를 읽거나 쓸 수 있습니다.

# ls /sys/class/c2port/c2port0/
access            flash_block_size  flash_erase       rev_id
dev_id            flash_blocks_num  flash_size        subsystem/
flash_access      flash_data        reset             uevent

C2 line이 다른 device와 multiplex될 수 있어 처음에는 C2port access가 disable되어 있습니다. 먼저 `access`에 1을 쓴 뒤 연결한 microcontroller의 device ID와 revision ID를 읽습니다.

# echo 1 > /sys/class/c2port/c2port0/access
# cat /sys/class/c2port/c2port0/dev_id
8
# cat /sys/class/c2port/c2port0/rev_id
1

보안 때문에 in-system flash access는 별도로 enable해야 합니다. `flash_access`에 1을 쓴 뒤 전체 flash를 image로 읽거나 erase하고, image를 다시 쓸 수 있습니다.

# echo 1 > /sys/class/c2port/c2port0/flash_access
# cat /sys/class/c2port/c2port0/flash_data > image
# echo 1 > /sys/class/c2port/c2port0/flash_erase
# cat image > /sys/class/c2port/c2port0/flash_data

Programming 뒤에는 새 code를 실행하도록 `reset`에 1을 써서 device를 reset해야 합니다.

# echo 1 > /sys/class/c2port/c2port0/reset
Using the driver
----------------

Once the driver is loaded you can use sysfs support to get C2port's
info or read/write in-system flash::

  # ls /sys/class/c2port/c2port0/
  access            flash_block_size  flash_erase       rev_id
  dev_id            flash_blocks_num  flash_size        subsystem/
  flash_access      flash_data        reset             uevent

Initially the C2port access is disabled since you hardware may have
such lines multiplexed with other devices so, to get access to the
C2port, you need the command::

  # echo 1 > /sys/class/c2port/c2port0/access

after that you should read the device ID and revision ID of the
connected micro controller::

  # cat /sys/class/c2port/c2port0/dev_id
  8
  # cat /sys/class/c2port/c2port0/rev_id
  1

However, for security reasons, the in-system flash access in not
enabled yet, to do so you need the command::

  # echo 1 > /sys/class/c2port/c2port0/flash_access

After that you can read the whole flash::

  # cat /sys/class/c2port/c2port0/flash_data > image

erase it::

  # echo 1 > /sys/class/c2port/c2port0/flash_erase

and write it::

  # cat image > /sys/class/c2port/c2port0/flash_data

after writing you have to reset the device to execute the new code::

  # echo 1 > /sys/class/c2port/c2port0/reset