{"id":19989593,"url":"https://github.com/wavesoft/cclib","last_synced_at":"2025-08-21T02:32:07.966Z","repository":{"id":18002413,"uuid":"21017871","full_name":"wavesoft/CCLib","owner":"wavesoft","description":"An arduino library that implements the CC.Debugger protocol of TI","archived":false,"fork":false,"pushed_at":"2019-01-25T13:42:38.000Z","size":348,"stargazers_count":177,"open_issues_count":20,"forks_count":77,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-04-08T02:01:45.647Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wavesoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-19T22:32:47.000Z","updated_at":"2025-04-03T04:37:33.000Z","dependencies_parsed_at":"2022-09-04T15:41:22.075Z","dependency_job_id":null,"html_url":"https://github.com/wavesoft/CCLib","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wavesoft/CCLib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesoft%2FCCLib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesoft%2FCCLib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesoft%2FCCLib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesoft%2FCCLib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wavesoft","download_url":"https://codeload.github.com/wavesoft/CCLib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wavesoft%2FCCLib/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271416948,"owners_count":24755998,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-21T02:00:08.990Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T04:48:34.708Z","updated_at":"2025-08-21T02:32:07.642Z","avatar_url":"https://github.com/wavesoft.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# CCLib\n\n[![Build Status (Travis)](https://travis-ci.org/wavesoft/CCLib.svg?branch=master)](https://travis-ci.org/wavesoft/CCLib) [![Build Status (AppVeyor)](https://img.shields.io/appveyor/ci/wavesoft/CCLib/master.svg)](https://ci.appveyor.com/project/wavesoft/cclib) [![Join the chat at https://gitter.im/Arduino-CCLib](https://badges.gitter.im/Arduino-CCLib.svg)](https://gitter.im/Arduino-CCLib)\n\nA set of utilities to convert your Arduino board to a CC.Debugger for flashing Texas Instruments' CCxxxx chips.\nIt currently supports the CC2530/40/41 chips ([compatibility table](#compatibility-table)) but with [your help it can support any chip](#contributing-other-chip-drivers) compatible with the CC.Debugger protocol.\n\nKeep in mind but this more than just a set of utilities! It comes with complete, reusable Arduino and Python libraries for adding CC.Debugger support to your projects!\n\n## Usage\n\nIf you are just in hurry to flash your CCxxxx chip, follow this guide, however you should first check the [compatibility table](#compatibility-table) later in this document!\n\n### 1. Prepare your arduino board\n\n1. Install the `Arduino/CCLib` library [to your arduino IDE](https://www.arduino.cc/en/Guide/Libraries)\n2. Load the `CCLib_proxy` example and change the the `LED`, `CC_RST`, `CC_DC`, `CC_DD_I` and `CC_DD_O` constants to match your configuration.\n3. Flash it to your Teensy/Arduino\n4. We are going to need a voltage divider from 5V (arduino) to 3.3V (CCxxxx chip), therefore you will need to wire your arduino according to the following diagram:\n\n```\nFor the DD Pin:\n\n \u003cCC_DD_O\u003e --[ 100k ]-- \u003cCC_DD_I\u003e --[ 200k ]-- \u003cGND\u003e\n                            |\n                           {DD}\n\nFor the DC Pin:\n\n \u003cCC_DC\u003e --[ 100k ]-- {DC} --[ 200k ]-- \u003cGND\u003e\n\nFor the RST Pin:\n\n \u003cCC_RST\u003e --[ 100k ]-- {RST} --[ 200k ]-- \u003cGND\u003e\n```\n\nWhere `{DD}`, `{DC}` and `{RST}` are the pins on the CCxxxx chip and `\u003cCC_DD_O\u003e`, `\u003cCC_DD_I\u003e`, `\u003cCC_DC\u003e`, `\u003cCC_RST\u003e` are the pins in your ardiuno board.\n\nIn an arduino/breadboard set-up, this looks like this:\n\n\u003cimg src=\"https://raw.githubusercontent.com/wavesoft/CCLib/master/Schematic/arduino-wiring.png\" width=\"550\" /\u003e\n\n### 2. Prepare your software\n\n1. You will need Python 2.7 or later installed to your system\n2. Open a terminal and change directory into the `Python` folder of this project\n3. Install required python modules by typing: `pip install -r requirements.txt`\n4. Test your set-up:\n```\n~$ ./cc_info.py -p [serial port]\n```\n\nIf you see something like this, you are ready:\n\n```\nChip information:\n      Chip ID : 0x4113\n   Flash size : 16 Kb\n    SRAM size : 1 Kb\n          USB : No\n\nDevice information:\n IEEE Address : 13fe41b61cde\n           PC : 002f\n```\n\nHowever, if you see something like this, something is wrong and you should probably check your wiring and/or reset the arduino board or the CC board.\n\n```\nChip information:\n      Chip ID : 0x4113\n   Flash size : 16 Kb\n    SRAM size : 1 Kb\n          USB : No\n\nDevice information:\n IEEE Address : 000000000000\n           PC : 0000\n```\n\n### 3. Using the software\n\nThe python utilities provide a straightforward interface for reading/writing to your CCxxxx chip:\n\n* __cc_info.py__ : Read generic information from your CCxxxx chip. Usage exampe:\n```\n~$ ./cc_info.py -p /dev/ttyS0\n```\n\n* __cc_read_flash.py__ : Read the flash memory and write it to a hex/bin file. Usage example:\n```\n~$ ./cc_read_flash.py -p /dev/ttyS0 --out=output.hex\n```\n\n* __cc_write_flash.py__ : Write a hex/bin file to the flash memory. You can optionally specify the `--erase` parameter to firt perform a full chip-erase. Usage example:\n```\n~$ ./cc_write_flash.py -p /dev/ttyS0 --in=output.hex --erase\n```\n\n* __cc_resume.py__ : Exit from debug mode and resume chip operations. Usage example:\n```\n~$ ./cc_resume.py -p /dev/ttyS0\n```\n\n_NOTE:_ If you don't want to use the `--port` parameter with every command you can define the `CC_SERIAL` environment variable, pointing to the serial port you are using:\n\n```\n~$ export CC_SERIAL=/dev/ttyS0\n```\n\n## Compatibility Table\n\nIn order to flash a CCxxxx chip there is a need to invoke CPU instructions, which makes the process cpu-dependant. This means that this code cannot be reused off-the-shelf for other CCxxxx chips. The following table lists the chips reported to work (or could work) with this library:\n\n\u003ctable\u003e\n    \u003ctr\u003e\n        \u003cth\u003eChip\u003c/th\u003e\n        \u003cth\u003eChip ID\u003c/th\u003e\n        \u003cth\u003eDriver\u003c/th\u003e\n        \u003cth\u003eStatus\u003c/th\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eCC2530\u003c/td\u003e\n        \u003ctd\u003e\u003cstrong\u003e0xa5\u003c/strong\u003e..\u003c/td\u003e\n        \u003ctd\u003eCC254X\u003c/td\u003e\n        \u003ctd\u003e:white_check_mark: Works\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eCC2531\u003c/td\u003e\n        \u003ctd\u003e\u003cstrong\u003e0xb5\u003c/strong\u003e..\u003c/td\u003e\n        \u003ctd\u003eCC254X\u003c/td\u003e\n        \u003ctd\u003e:large_orange_diamond: Looking for testers\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eCC2533\u003c/td\u003e\n        \u003ctd\u003e\u003cstrong\u003e0x95\u003c/strong\u003e..\u003c/td\u003e\n        \u003ctd\u003eCC254X\u003c/td\u003e\n        \u003ctd\u003e:large_orange_diamond: Looking for testers\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eCC2540\u003c/td\u003e\n        \u003ctd\u003e\u003cstrong\u003e0x8d\u003c/strong\u003e..\u003c/td\u003e\n        \u003ctd\u003eCC254X\u003c/td\u003e\n        \u003ctd\u003e:white_check_mark: Works\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eCC2541\u003c/td\u003e\n        \u003ctd\u003e\u003cstrong\u003e0x41\u003c/strong\u003e..\u003c/td\u003e\n        \u003ctd\u003eCC254X\u003c/td\u003e\n        \u003ctd\u003e:large_orange_diamond: Looking for testers\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n        \u003ctd\u003eCS2510\u003c/td\u003e\n        \u003ctd\u003e\u003cstrong\u003e0x81\u003c/strong\u003e..\u003c/td\u003e\n        \u003ctd\u003eCS2510\u003c/td\u003e\n        \u003ctd\u003e:large_orange_diamond: Looking for testers\u003c/td\u003e\n    \u003c/tr\u003e\n\u003c/table\u003e\n\n### Contributing other chip drivers\n\nSince the arduino sketch is quite simple, it's possible to support any CCxxxx device solely by creating a new chip driver. Even if your chip uses a different debug protocol instruction set (such as CC2510) you can modify it on-the-fly.\n\nIn order to create a new chip driver you should create a new file in the `Python/cclib/chip` folder with the name of your chip (for example `cc2510.py`), and create a new Python class, subclassing from the `ChipDriver` class. For example:\n\n```python\nclass CC2510(ChipDriver):\n    \"\"\"\n    Chip-specific code for CC2510 SOC\n    \"\"\"\n\n    @staticmethod\n    def test(chipID):\n        \"\"\"\n        Check if this ChipID can be handled by this class\n        \"\"\"\n        return ((self.chipID \u0026 0xff00) == 0x8100)\n\n    def chipName(self):\n        \"\"\"\n        Return Chip Name\n        \"\"\"\n        return \"CC2510\"\n\n    def initialize(self):\n        \"\"\"\n        Initialize chip driver\n        \"\"\"\n\n        # Get chip info\n        self.chipInfo = self.getChipInfo()\n\n        # Populate variables\n        self.flashSize = self.chipInfo['flash'] * 1024\n        self.flashPageSize = 0x400\n        self.sramSize = self.chipInfo['sram'] * 1024\n        self.bulkBlockSize = 0x800\n        self.flashWordSize = 2\n\n```\n\nAnd you must then register your class in the `Python/cclib/ccdebugger.py`\n\n```python\n# Chip drivers the CCDebugger will test for\nfrom cclib.chip.cc2540x import CC254X\nfrom cclib.chip.cc2510 import CC2510\nCHIP_DRIVERS = [ CC254X, CC2510 ]\n```\n\nAfter that you need to implement all the functions exposed by the `ChipDriver` (available in `Python/cclib/chip/__init__.py`), but you can just copy the `cc2540x.py` driver and work on top of it.\n\nWe are looking forward for your support for new chips!\n\n## Protocol\n\nThe protocol used between your computer and your Arduino is quite simple and not really fault-proof. This was intended as a pure proxy mechanism in order to experiment with the CC Debugging protocol from the computer. Therefore, if you interrupt any operation in the middle, you will most probably have to unplug and re-plug your Teensy/Arduino. That said, here is the protocol:\n\nSince most of the debug commands are at max 4-bytes long, we are sending from the computer a constant-sized frame of 4-bytes:\n\n    +-----------+-----------+-----------+-----------+\n    |  Command  |   Data 0  |   Data 1  |   Data 2  |\n    +-----------+-----------+-----------+-----------+\n\nThe only exceptions are:\n\n  * The brust-write command (CMD_BRUSTWR), where up to 2048 bytes might follow the 4-byte frame, and\n  * The instrunctionset update command (CMD_INSTR_UPD), were 16 bytes must follow the 4-byte frame.\n\nThe Teensy/Arduino will always reply with the following 3-byte long frame:\n\n    +-----------+-----------+-----------+\n    |   Status  |    ResH   |  Err/ResL |\n    +-----------+-----------+-----------+\n\nIf the status code is `ANS_OK(1)`, the `ResH:ResL` word contains the resulting word (or byte) of the command. If it's `ANS_ERR(2)`, the `ResL` byte contains the error code.\n\n\n## Disclaimer\n\nUsers have successfully flashed various BlueGiga BLE112/BLE113 (CC2540) modules with this solution, however the developers DO NOT GUARANTEE THAT THIS WILL WORK IN YOUR CASE! **The developers cannot be held liable for any damage caused by using this library, directly or indirectly. YOU ARE USING THIS CODE SOLELY AT YOUR OWN RISK!**\n\n## License\n\nCopyright (c) 2014-2016 Ioannis Charalampidis\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwavesoft%2Fcclib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwavesoft%2Fcclib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwavesoft%2Fcclib/lists"}