Mauro Carvalho Chehab | 433b1b0 | 2020-06-15 08:50:15 +0200 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0 |
| 2 | .. include:: <isonum.txt> |
| 3 | |
| 4 | =============== |
| 5 | C2 port support |
| 6 | =============== |
Rodolfo Giometti | 4e17e1d | 2008-11-12 13:27:12 -0800 | [diff] [blame] | 7 | |
| 8 | (C) Copyright 2007 Rodolfo Giometti <giometti@enneenne.com> |
| 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 | |
Alexander A. Klimov | 93431e0 | 2020-05-26 08:05:44 +0200 | [diff] [blame] | 35 | The C2 Interface main references are at (https://www.silabs.com) |
Rodolfo Giometti | 4e17e1d | 2008-11-12 13:27:12 -0800 | [diff] [blame] | 36 | Silicon Laboratories site], see: |
| 37 | |
| 38 | - AN127: FLASH Programming via the C2 Interface at |
Mauro Carvalho Chehab | 433b1b0 | 2020-06-15 08:50:15 +0200 | [diff] [blame] | 39 | https://www.silabs.com/Support Documents/TechnicalDocs/an127.pdf |
Rodolfo Giometti | 4e17e1d | 2008-11-12 13:27:12 -0800 | [diff] [blame] | 40 | |
| 41 | - C2 Specification at |
Mauro Carvalho Chehab | 433b1b0 | 2020-06-15 08:50:15 +0200 | [diff] [blame] | 42 | https://www.silabs.com/pages/DownloadDoc.aspx?FILEURL=Support%20Documents/TechnicalDocs/an127.pdf&src=SearchResults |
Rodolfo Giometti | 4e17e1d | 2008-11-12 13:27:12 -0800 | [diff] [blame] | 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 |
Mauro Carvalho Chehab | 433b1b0 | 2020-06-15 08:50:15 +0200 | [diff] [blame] | 54 | info or read/write in-system flash:: |
Rodolfo Giometti | 4e17e1d | 2008-11-12 13:27:12 -0800 | [diff] [blame] | 55 | |
Mauro Carvalho Chehab | 433b1b0 | 2020-06-15 08:50:15 +0200 | [diff] [blame] | 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 |
Rodolfo Giometti | 4e17e1d | 2008-11-12 13:27:12 -0800 | [diff] [blame] | 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 |
Mauro Carvalho Chehab | 433b1b0 | 2020-06-15 08:50:15 +0200 | [diff] [blame] | 63 | C2port, you need the command:: |
Rodolfo Giometti | 4e17e1d | 2008-11-12 13:27:12 -0800 | [diff] [blame] | 64 | |
Mauro Carvalho Chehab | 433b1b0 | 2020-06-15 08:50:15 +0200 | [diff] [blame] | 65 | # echo 1 > /sys/class/c2port/c2port0/access |
Rodolfo Giometti | 4e17e1d | 2008-11-12 13:27:12 -0800 | [diff] [blame] | 66 | |
| 67 | after that you should read the device ID and revision ID of the |
Mauro Carvalho Chehab | 433b1b0 | 2020-06-15 08:50:15 +0200 | [diff] [blame] | 68 | connected micro controller:: |
Rodolfo Giometti | 4e17e1d | 2008-11-12 13:27:12 -0800 | [diff] [blame] | 69 | |
Mauro Carvalho Chehab | 433b1b0 | 2020-06-15 08:50:15 +0200 | [diff] [blame] | 70 | # cat /sys/class/c2port/c2port0/dev_id |
| 71 | 8 |
| 72 | # cat /sys/class/c2port/c2port0/rev_id |
| 73 | 1 |
Rodolfo Giometti | 4e17e1d | 2008-11-12 13:27:12 -0800 | [diff] [blame] | 74 | |
| 75 | However, for security reasons, the in-system flash access in not |
Mauro Carvalho Chehab | 433b1b0 | 2020-06-15 08:50:15 +0200 | [diff] [blame] | 76 | enabled yet, to do so you need the command:: |
Rodolfo Giometti | 4e17e1d | 2008-11-12 13:27:12 -0800 | [diff] [blame] | 77 | |
Mauro Carvalho Chehab | 433b1b0 | 2020-06-15 08:50:15 +0200 | [diff] [blame] | 78 | # echo 1 > /sys/class/c2port/c2port0/flash_access |
Rodolfo Giometti | 4e17e1d | 2008-11-12 13:27:12 -0800 | [diff] [blame] | 79 | |
Mauro Carvalho Chehab | 433b1b0 | 2020-06-15 08:50:15 +0200 | [diff] [blame] | 80 | After that you can read the whole flash:: |
Rodolfo Giometti | 4e17e1d | 2008-11-12 13:27:12 -0800 | [diff] [blame] | 81 | |
Mauro Carvalho Chehab | 433b1b0 | 2020-06-15 08:50:15 +0200 | [diff] [blame] | 82 | # cat /sys/class/c2port/c2port0/flash_data > image |
Rodolfo Giometti | 4e17e1d | 2008-11-12 13:27:12 -0800 | [diff] [blame] | 83 | |
Mauro Carvalho Chehab | 433b1b0 | 2020-06-15 08:50:15 +0200 | [diff] [blame] | 84 | erase it:: |
Rodolfo Giometti | 4e17e1d | 2008-11-12 13:27:12 -0800 | [diff] [blame] | 85 | |
Mauro Carvalho Chehab | 433b1b0 | 2020-06-15 08:50:15 +0200 | [diff] [blame] | 86 | # echo 1 > /sys/class/c2port/c2port0/flash_erase |
Rodolfo Giometti | 4e17e1d | 2008-11-12 13:27:12 -0800 | [diff] [blame] | 87 | |
Mauro Carvalho Chehab | 433b1b0 | 2020-06-15 08:50:15 +0200 | [diff] [blame] | 88 | and write it:: |
Rodolfo Giometti | 4e17e1d | 2008-11-12 13:27:12 -0800 | [diff] [blame] | 89 | |
Mauro Carvalho Chehab | 433b1b0 | 2020-06-15 08:50:15 +0200 | [diff] [blame] | 90 | # cat image > /sys/class/c2port/c2port0/flash_data |
Rodolfo Giometti | 4e17e1d | 2008-11-12 13:27:12 -0800 | [diff] [blame] | 91 | |
Mauro Carvalho Chehab | 433b1b0 | 2020-06-15 08:50:15 +0200 | [diff] [blame] | 92 | after writing you have to reset the device to execute the new code:: |
Rodolfo Giometti | 4e17e1d | 2008-11-12 13:27:12 -0800 | [diff] [blame] | 93 | |
Mauro Carvalho Chehab | 433b1b0 | 2020-06-15 08:50:15 +0200 | [diff] [blame] | 94 | # echo 1 > /sys/class/c2port/c2port0/reset |