Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: GPL-2.0
0002 .. include:: <isonum.txt>
0003 
0004 ===============
0005 C2 port support
0006 ===============
0007 
0008 (C) Copyright 2007 Rodolfo Giometti <giometti@enneenne.com>
0009 
0010 This program is free software; you can redistribute it and/or modify
0011 it under the terms of the GNU General Public License as published by
0012 the Free Software Foundation; either version 2 of the License, or
0013 (at your option) any later version.
0014 
0015 This program is distributed in the hope that it will be useful,
0016 but WITHOUT ANY WARRANTY; without even the implied warranty of
0017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0018 GNU General Public License for more details.
0019 
0020 
0021 
0022 Overview
0023 --------
0024 
0025 This driver implements the support for Linux of Silicon Labs (Silabs)
0026 C2 Interface used for in-system programming of micro controllers.
0027 
0028 By using this driver you can reprogram the in-system flash without EC2
0029 or EC3 debug adapter. This solution is also useful in those systems
0030 where the micro controller is connected via special GPIOs pins.
0031 
0032 References
0033 ----------
0034 
0035 The C2 Interface main references are at (https://www.silabs.com)
0036 Silicon Laboratories site], see:
0037 
0038 - AN127: FLASH Programming via the C2 Interface at
0039   https://www.silabs.com/Support Documents/TechnicalDocs/an127.pdf
0040 
0041 - C2 Specification at
0042   https://www.silabs.com/pages/DownloadDoc.aspx?FILEURL=Support%20Documents/TechnicalDocs/an127.pdf&src=SearchResults
0043 
0044 however it implements a two wire serial communication protocol (bit
0045 banging) designed to enable in-system programming, debugging, and
0046 boundary-scan testing on low pin-count Silicon Labs devices. Currently
0047 this code supports only flash programming but extensions are easy to
0048 add.
0049 
0050 Using the driver
0051 ----------------
0052 
0053 Once the driver is loaded you can use sysfs support to get C2port's
0054 info or read/write in-system flash::
0055 
0056   # ls /sys/class/c2port/c2port0/
0057   access            flash_block_size  flash_erase       rev_id
0058   dev_id            flash_blocks_num  flash_size        subsystem/
0059   flash_access      flash_data        reset             uevent
0060 
0061 Initially the C2port access is disabled since you hardware may have
0062 such lines multiplexed with other devices so, to get access to the
0063 C2port, you need the command::
0064 
0065   # echo 1 > /sys/class/c2port/c2port0/access
0066 
0067 after that you should read the device ID and revision ID of the
0068 connected micro controller::
0069 
0070   # cat /sys/class/c2port/c2port0/dev_id
0071   8
0072   # cat /sys/class/c2port/c2port0/rev_id
0073   1
0074 
0075 However, for security reasons, the in-system flash access in not
0076 enabled yet, to do so you need the command::
0077 
0078   # echo 1 > /sys/class/c2port/c2port0/flash_access
0079 
0080 After that you can read the whole flash::
0081 
0082   # cat /sys/class/c2port/c2port0/flash_data > image
0083 
0084 erase it::
0085 
0086   # echo 1 > /sys/class/c2port/c2port0/flash_erase
0087 
0088 and write it::
0089 
0090   # cat image > /sys/class/c2port/c2port0/flash_data
0091 
0092 after writing you have to reset the device to execute the new code::
0093 
0094   # echo 1 > /sys/class/c2port/c2port0/reset