├── .github └── workflows │ └── main.yml ├── .gitignore ├── LICENSE ├── MANIFEST.in ├── README.rst ├── ch55xtool ├── __init__.py ├── __main__.py ├── ch55xtool.py ├── extended.wcfg └── typeall.wcfg └── setup.py /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Publish package 2 | 3 | on: 4 | push: 5 | tags: 6 | - v* 7 | 8 | jobs: 9 | build-n-publish: 10 | runs-on: ubuntu-18.04 11 | steps: 12 | - uses: actions/checkout@master 13 | - name: Set up Python 3.9 14 | uses: actions/setup-python@v1 15 | with: 16 | python-version: 3.9 17 | - name: Install dependencies 18 | run: | 19 | python -m pip install wheel twine 20 | - name: Build Package 📦 21 | run: | 22 | python setup.py bdist_wheel sdist 23 | - name: Publish to PyPi 🚀 24 | uses: pypa/gh-action-pypi-publish@release/v1 25 | with: 26 | user: __token__ 27 | password: ${{ secrets.PYPI_API_TOKEN }} 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include ch55xtool/*.wcfg 2 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ch55xtool 2 | ========= 3 | 4 | Now available on pypi 5 | --------------------- 6 | 7 | An open sourced python command line flash tool for flashing WinChipHead 8 | CH55x series 8051 USB micro controllers, including CH551, CH552, CH553, 9 | CH554, CH559, CH569 (including CH56x), etc. with bootloader version(BTV) 10 | above 2.30 (including 2.30, 2.31, 2.40, 2.71), etc. 11 | (You can check the verision by using the official CH55x Tool.) 12 | 13 | Usage 14 | ----- 15 | 16 | - **-f/–flash ** Erase the whole chip, and flash the bin file 17 | to the CH55x. 18 | - **-e/–erase_flash** Erase the whole program flash. 19 | - **–verify_flash** [filename] Verify program flash contend with given 20 | file, if filename ommited verifying with flashed data. No verifying 21 | perormed without this flag. 22 | - **-r/–reset_at_end** Issue reset and run after all. 23 | - **-d/–data ** Erase the whole data flash and write the bin 24 | file to the CH55x. 25 | - **-c/–erase_dataflash** Erase the whole data flash. 26 | - **–verify_data** [filename] Verify data flash contend with given 27 | file, if filename ommited verifying with written data. No verifying 28 | perormed without this flag. 29 | - **-g/–read_dataflash** Read content of data flash to file. 30 | - **-p/–print_chip_cfg** Read and print chip configuration bits 3 x 32 31 | bit values. 32 | 33 | .. code:: bash 34 | 35 | python3 -m ch55xtool -f THE_BINARY_FILE.bin 36 | 37 | Tool Setup 38 | ---------- 39 | 40 | - Linux Distros > Most Linux distros come with libusb, so you only need 41 | to install the pyusb packge. 42 | 43 | .. code:: bash 44 | 45 | python3 -mpip install ch55xtool 46 | 47 | - Mac OS 48 | 49 | .. 50 | 51 | For Mac OS, you need to install both libusb and pyusb. 52 | 53 | .. code:: bash 54 | 55 | # If you dont have brew installed. 56 | # /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 57 | brew install libusb 58 | python3 -mpip install ch55xtool 59 | 60 | - As for Windows, oh no… :( 61 | 62 | 1. First, you need to download the 63 | `Zadig `__ for replacing the CH375 64 | driver from WCH to libusb. 65 | 2. Click the Options->List all devices, to show all devices 66 | 3. Find the device marked with **USB Module**, which presented 67 | driver is **CH375_balabala** 68 | 4. Replace the driver with libusb-win32. 69 | 5. Install the pyusb package with ``python -mpip install pyusb``. 70 | Since for windows, they dont use python3, but you have to make 71 | sure you have the pythono3 in the PATH 72 | 6. If you want to use the WCH Toolchain, open the device manager, 73 | find the device marked with **libusb-win32 deives**, right 74 | clicked on it, and Uninstall the driver and delete the driver. 75 | You can also check the FAQ of Zadig 76 | `HERE `__. 77 | 78 | FAQ 79 | --- 80 | 81 | - Why I got a **Error: No backend available** ? 82 | 83 | .. 84 | 85 | On windows, this means you dont a valid libusb device, see the guide 86 | above. For other system, you might dont have the libusb installed, 87 | follow the guide above. 88 | 89 | - Why it said **NO_DEV_FOUND** ? 90 | 91 | .. 92 | 93 | Pyusb unable to fine the device with given PID&VID. Maybe you dont 94 | power on your device, or it is not in DFU mode. 95 | 96 | - I got a **USB_ERROR_CANNOT_SET_CONFIG** error. 97 | 98 | .. 99 | 100 | This high probability is a permission issue. Add 101 | ``SUBSYSTEM=="usb", ATTRS{idVendor}=="4348", MODE="0666"`` to 102 | ``/etc/udev/rules.d/50-ch55x.rules``, and re-plug your device. 103 | Otherwise you need sudo. 104 | 105 | - I got a **USB_ERROR_CANNOT_DETACH_KERNEL_DRIVER**, or 106 | **USB_ERROR_CANNOT_CLAIM_INTERFACE** error. 107 | 108 | .. 109 | 110 | I never met with those problems on a working CH552. Checking the 111 | power, the previliage, and praying may help. 112 | 113 | - What if it return **Bootloader version not supported**? 114 | 115 | .. 116 | 117 | The program dont support BTVER lower than 2.30(welcome PR, but since 118 | they are too old, I dont have plan to support them). Or maybe they 119 | have a newer verison, for this situlation, it is welcome for you to 120 | open an issue. 121 | -------------------------------------------------------------------------------- /ch55xtool/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarsTechHAN/ch552tool/611401f65262d497169d405e66a5d4ea63a52b9d/ch55xtool/__init__.py -------------------------------------------------------------------------------- /ch55xtool/__main__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | 3 | import os 4 | import sys 5 | 6 | if sys.path[0] in ('', os.getcwd()): 7 | sys.path.pop(0) 8 | 9 | from ch55xtool.ch55xtool import main as _main # isort:skip # noqa 10 | 11 | if __name__ == '__main__': 12 | sys.exit(_main()) 13 | -------------------------------------------------------------------------------- /ch55xtool/ch55xtool.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import sys 5 | import os 6 | import time 7 | import argparse 8 | import random 9 | 10 | import usb.core 11 | import usb.util 12 | 13 | import configparser 14 | # ======= Some C-like static constants ======= 15 | DFU_ID_VENDOR = 0x4348 16 | DFU_ID_PRODUCT = 0x55e0 17 | 18 | EP_OUT_ADDR = 0x02 19 | EP_IN_ADDR = 0x82 20 | 21 | USB_MAX_TIMEOUT = 5000 22 | 23 | # ============================================= 24 | WCH_CMDS = { "Detect": b'\xA1', 25 | "End": b'\xA2', 26 | "SetKey": b'\xA3', 27 | "FlashErase": b'\xA4', 28 | "FlashWrite": b'\xA5', 29 | "FlashVerify": b'\xA6', 30 | "ReadConfig": b'\xA7', 31 | "WriteConfig": b'\xA8', 32 | "DataErase": b'\xA9', 33 | "DataWrite": b'\xAA', 34 | "DataRead": b'\xAB', 35 | "ReadOTP": b'\xC4', 36 | "WriteOTP": b'\xC3', 37 | } 38 | 39 | # Meaning of those two values not yet clear :( 40 | DETECT_PL_START = b'\x42\x10' 41 | #DETECT_PL_START = b'\x52\x11' 42 | DETECT_APP_ID_B = b'MCU ISP & WCH.CN' 43 | 44 | # Unknown bits work only all together like 0x07 !! 45 | FLAG_CFG1 = 0x01 46 | FLAG_CFG2 = 0x02 47 | FLAG_CFG3 = 0x04 48 | FLAG_CFGs = FLAG_CFG1 | FLAG_CFG2 | FLAG_CFG3 49 | # Those bits work individualy 50 | FLAG_BOOTVER = 0x08 51 | FLAG_UID = 0x10 52 | 53 | # ============================================= 54 | def get_chip_parameters(chip_id,wcfg_path, user_param_file='' ): 55 | chip_params = {} 56 | params_ini = configparser.ConfigParser() 57 | #params_ini.optionxform = lambda option: option 58 | params_ini.read(wcfg_path+'/typeall.wcfg') 59 | for section in params_ini.sections(): 60 | if(params_ini.has_option(section,'chipid')): 61 | if(params_ini.getint(section,'chipid') == chip_id): 62 | chip_params.update({'name':section}) 63 | chip_params.update({'chip_id':chip_id}) 64 | chip_params.update({'flash_size':params_ini.getint(section,'MaxFlashSize')}) 65 | chip_params.update({'dataflash_size':params_ini.getint(section,'MaxEepromSize')}) 66 | chip_params.update({'McuType':params_ini.getint(section,'McuType')}) 67 | break 68 | 69 | params_ini_ext = configparser.ConfigParser() 70 | #params_ini_ext.optionxform = lambda option: option 71 | params_ini_ext.read(wcfg_path+'/extended.wcfg') 72 | for section in params_ini_ext.sections(): 73 | if(params_ini_ext.has_option(section,'chipid')): 74 | if(params_ini_ext.getint(section,'chipid') == chip_id): 75 | chip_params.update({'name':section}) 76 | chip_params.update({'chip_id':chip_id}) 77 | chip_params.update({'flash_size':params_ini_ext.getint(section,'MaxFlashSize')}) 78 | chip_params.update({'dataflash_size':params_ini_ext.getint(section,'MaxEepromSize')}) 79 | if(params_ini_ext.has_option(section,'McuType')): 80 | chip_params.update({'McuType':params_ini_ext.getint(section,'McuType')}) 81 | break 82 | 83 | # Check we found any and all mandatory params exist 84 | if(chip_params.get('chip_id') == None or chip_params.get('name') == None): 85 | return None 86 | missing_defs = [] 87 | if( chip_params.get('flash_size') == None): missing_defs.append('MaxFlashSize') 88 | if( chip_params.get('dataflash_size') == None): missing_defs.append('MaxEepromSize') 89 | if(missing_defs): 90 | print('Chip configuration definitions shortage, mandatory fiels',missing_defs) 91 | return None 92 | 93 | section = chip_params.get('name') 94 | if(params_ini_ext.has_section(section)): 95 | if(params_ini_ext.has_option(section,'Tested')): 96 | chip_params.update({'tested':params_ini_ext.getboolean(section,'Tested')}) 97 | if(params_ini_ext.has_option(section,'CFGs')): 98 | chip_params.update({'cfgs_bits':eval(params_ini_ext.get(section,'CFGs'))}) 99 | 100 | if(user_param_file): 101 | params_ini_usr = configparser.ConfigParser() 102 | #params_ini_usr.optionxform = lambda option: option 103 | params_ini_usr.read(user_param_file) 104 | if(params_ini_usr.has_section(section)): 105 | if(params_ini_usr.has_option(section,'Tested')): 106 | chip_params.update({'tested':params_ini_usr.getboolean(section,'Tested')}) 107 | if(params_ini_usr.has_option(section,'CFGs')): 108 | if(chip_params.get('cfgs_bits') == None): 109 | chip_params.update({'cfgs_bits':eval(params_ini_usr.get(section,'CFGs'))}) 110 | else: 111 | chip_params['cfgs_bits'].update(eval(params_ini_usr.get(section,'CFGs'))) 112 | return chip_params 113 | 114 | def cmd_send(dev, cmd_bin, payload): 115 | pl_len = len(payload) 116 | packet = cmd_bin + pl_len.to_bytes(2,'little') + payload 117 | dev.write(EP_OUT_ADDR,packet) 118 | 119 | def cmd_reply_receive(dev, cmd_bin): 120 | cfg = dev.get_active_configuration() 121 | intf = cfg[(0,0)] 122 | ep_in = usb.util.find_descriptor(intf, bEndpointAddress=EP_IN_ADDR) 123 | reply = ep_in.read(ep_in.wMaxPacketSize, USB_MAX_TIMEOUT) 124 | if((reply != None) and (reply[0] == cmd_bin[0])): 125 | reply_val = reply[1] 126 | reply_payload_len = int.from_bytes(reply[2:4],'little') 127 | if(reply_payload_len > 0): 128 | reply_payload = reply[4:4+reply_payload_len] 129 | else: 130 | reply_payload = None 131 | else: 132 | reply_val = None 133 | reply_payload = None 134 | 135 | return reply_val, reply_payload 136 | 137 | def cmd_exec(dev, cmd, payload): 138 | cmd_bin = WCH_CMDS.get(cmd) 139 | if(cmd_bin != None): 140 | cmd_send(dev, cmd_bin, payload) 141 | return cmd_reply_receive(dev, cmd_bin) 142 | else: 143 | return None,None 144 | 145 | def __get_dfu_device(idVendor=DFU_ID_VENDOR, idProduct=DFU_ID_PRODUCT): 146 | dev = usb.core.find(idVendor=idVendor, idProduct=idProduct) 147 | if dev is None: 148 | return (None, 'NO_DEV_FOUND') 149 | try: 150 | if dev.is_kernel_driver_active(0): 151 | try: 152 | dev.detach_kernel_driver(0) 153 | except usb.core.USBError: 154 | return (None, 'USB_ERROR_CANNOT_DETACH_KERNEL_DRIVER') 155 | except BaseException: 156 | pass # Windows dont need detach 157 | 158 | try: 159 | dev.set_configuration() 160 | except usb.core.USBError: 161 | return (None, 'USB_ERROR_CANNOT_SET_CONFIG') 162 | 163 | try: 164 | usb.util.claim_interface(dev, 0) 165 | except usb.core.USBError: 166 | return (None, 'USB_ERROR_CANNOT_CLAIM_INTERFACE') 167 | 168 | return (dev, '') 169 | 170 | def __detect_ch5xx(dev): 171 | cmd_pl = DETECT_PL_START + DETECT_APP_ID_B 172 | ret, ret_pl = cmd_exec(dev, 'Detect', cmd_pl) 173 | if(ret != None and len(ret_pl) == 2): 174 | chip_id = ret_pl[0] 175 | chip_subid = ret_pl[1] 176 | else: 177 | chip_id = 0 178 | chip_subid = 0 179 | return ret, chip_id, chip_subid 180 | 181 | def __read_cfg_ch5xx(dev, req_fields, chip_id, chip_subid): 182 | predict_ret_pl_len = 2 # 2 byte for fields 183 | if(req_fields & FLAG_CFG1): predict_ret_pl_len += 4 184 | if(req_fields & FLAG_CFG2): predict_ret_pl_len += 4 185 | if(req_fields & FLAG_CFG3): predict_ret_pl_len += 4 186 | if(req_fields & FLAG_BOOTVER): predict_ret_pl_len += 4 187 | if(req_fields & FLAG_UID): predict_ret_pl_len += 8 188 | 189 | cmd_pl = req_fields.to_bytes(2,'little') 190 | ret, ret_pl = cmd_exec(dev, 'ReadConfig', cmd_pl) 191 | 192 | cfg_dict = {} 193 | if(ret is None): 194 | print("Get config failure!") 195 | return ret, cfg_dict 196 | 197 | reply_prc_bytes = 0 198 | reply_fields = int.from_bytes(ret_pl[reply_prc_bytes:reply_prc_bytes+2],'little') 199 | reply_prc_bytes += 2 200 | 201 | if(len(ret_pl) != predict_ret_pl_len or reply_fields != req_fields): 202 | print("Reply fields do not match requested!") 203 | 204 | cfg_dict["Fields"] = reply_fields 205 | if(reply_fields & FLAG_CFG1): 206 | cfg_dict[FLAG_CFG1] = int.from_bytes(ret_pl[reply_prc_bytes:reply_prc_bytes+4],'little') 207 | reply_prc_bytes += 4 208 | 209 | if(reply_fields & FLAG_CFG2): 210 | cfg_dict[FLAG_CFG2] = int.from_bytes(ret_pl[reply_prc_bytes:reply_prc_bytes+4],'little') 211 | reply_prc_bytes += 4 212 | 213 | if(reply_fields & FLAG_CFG3): 214 | cfg_dict[FLAG_CFG3] = int.from_bytes(ret_pl[reply_prc_bytes:reply_prc_bytes+4],'little') 215 | reply_prc_bytes += 4 216 | 217 | if(reply_fields & FLAG_BOOTVER): 218 | cfg_dict[FLAG_BOOTVER] = bytes(ret_pl[reply_prc_bytes:reply_prc_bytes+4]) 219 | reply_prc_bytes += 4 220 | 221 | if(reply_fields & FLAG_UID): 222 | if((chip_subid == 0x11) and (chip_id not in [0x55, 0x56, 0x57])): 223 | cfg_dict[FLAG_UID] = bytes(ret_pl[reply_prc_bytes:reply_prc_bytes+4]) + b'\x00'*4 224 | else: 225 | cfg_dict[FLAG_UID] = bytes(ret_pl[reply_prc_bytes:reply_prc_bytes+8]) 226 | reply_prc_bytes += 8 227 | 228 | return ret, cfg_dict 229 | 230 | def __write_cfg_ch5xx(dev, cfg_dict): 231 | cfg_fields = cfg_dict.get("Fields") 232 | if(cfg_fields is None): 233 | print("Not defined fields to set configuration.") 234 | return None, None 235 | set_fields = 0 236 | cmd_pl = b'' 237 | if(cfg_fields & FLAG_CFG1): 238 | field_val = cfg_dict.get(FLAG_CFG1) 239 | if(field_val != None): 240 | set_fields |= FLAG_CFG1 241 | cmd_pl += field_val.to_bytes(4,'little') 242 | else: 243 | print("Incorrect or no value for cfg field 0x%02X"%(FLAG_CFG1)) 244 | 245 | if(cfg_fields & FLAG_CFG2): 246 | field_val = cfg_dict.get(FLAG_CFG2) 247 | if(field_val != None): 248 | set_fields |= FLAG_CFG2 249 | cmd_pl += field_val.to_bytes(4,'little') 250 | else: 251 | print("Incorrect or no value for cfg field 0x%02X"%(FLAG_CFG2)) 252 | 253 | if(cfg_fields & FLAG_CFG3): 254 | field_val = cfg_dict.get(FLAG_CFG3) 255 | if(field_val != None): 256 | set_fields |= FLAG_CFG3 257 | cmd_pl += field_val.to_bytes(4,'little') 258 | else: 259 | print("Incorrect or no value for cfg field 0x%02X"%(FLAG_CFG3)) 260 | 261 | if(set_fields > 0): 262 | cmd_pl = set_fields.to_bytes(2,'little') + cmd_pl 263 | ret, ret_pl = cmd_exec(dev, 'WriteConfig', cmd_pl) 264 | return ret, ret_pl 265 | else: 266 | print("No setable chip fields in given config.") 267 | return None, None 268 | 269 | def __chip_uid_chk_sum(chip_subid, chip_uid): 270 | if(chip_subid == 0x11): 271 | return sum(chip_uid[:4]) & 0xFF 272 | else: 273 | return sum(chip_uid) & 0xFF 274 | 275 | def __gen_key_values(chip_id, chip_uid_chksum): 276 | # In original soft KeyBase length = 30 + (random int)%31 277 | key_base_len = random.randint(30,61) 278 | key_base = bytearray(key_base_len) 279 | for i in range(key_base_len): 280 | key_base[i] = random.randint(0,255) 281 | key = bytearray(8) 282 | key[0] = chip_uid_chksum ^ key_base[ 4 * (key_base_len // 7)] 283 | key[1] = chip_uid_chksum ^ key_base[ key_base_len // 5 ] 284 | key[2] = chip_uid_chksum ^ key_base[ key_base_len // 7 ] 285 | key[3] = chip_uid_chksum ^ key_base[ 6 * (key_base_len // 7)] 286 | key[4] = chip_uid_chksum ^ key_base[ 3 * (key_base_len // 7)] 287 | key[5] = chip_uid_chksum ^ key_base[ 3 * (key_base_len // 5)] 288 | key[6] = chip_uid_chksum ^ key_base[ 5 * (key_base_len // 7)] 289 | key[7] = (chip_id + key[0]) & 0xff 290 | return key, key_base 291 | 292 | def __send_key_base(dev, key_base): 293 | ret, ret_pl = cmd_exec(dev, 'SetKey', key_base) 294 | if (ret != None and len(ret_pl)>0): 295 | return ret_pl[0] == 0 296 | else: 297 | return None 298 | 299 | def __flash_ops_write_verify(dev, key_xor_chksum, data, func="FlashWrite"): 300 | if(func not in [ 'FlashWrite' , 'FlashVerify', 'DataWrite'] ): 301 | return False, -1 302 | data_length = len(data) 303 | curr_addr = 0 304 | cfg = dev.get_active_configuration() 305 | intf = cfg[(0,0)] 306 | ep_out = usb.util.find_descriptor(intf, bEndpointAddress=EP_OUT_ADDR) 307 | max_packet_size = ep_out.wMaxPacketSize 308 | max_data_len_perpack = max_packet_size - 3 - 5 309 | data_buff = bytearray(max_data_len_perpack) 310 | while curr_addr < data_length: 311 | left_len = data_length - curr_addr 312 | if (left_len) > max_data_len_perpack: 313 | pkt_length = max_data_len_perpack 314 | data_buff[:pkt_length] = data[curr_addr:curr_addr+pkt_length] 315 | else: 316 | pkt_length = left_len 317 | data_buff[:pkt_length] = data[curr_addr:curr_addr+pkt_length] 318 | tmp = left_len & 0x07 319 | if( tmp != 0): 320 | pad_len = 8 - tmp 321 | pkt_length += pad_len 322 | data_buff[left_len:pkt_length] = b'\x00'* pad_len 323 | 324 | for index in range(pkt_length): 325 | data_buff[index] ^= key_xor_chksum[index & 0x07] 326 | 327 | cmd_pl = curr_addr.to_bytes(4,'little') + bytes([random.randint(0,255)]) + data_buff[:pkt_length] 328 | 329 | ret, ret_pl = cmd_exec(dev, func, cmd_pl) 330 | if( ret == None or ret_pl[0] != 0x00): 331 | return False, curr_addr 332 | 333 | curr_addr = curr_addr + pkt_length 334 | if(curr_addr > data_length): 335 | return True, data_length 336 | else: 337 | return True, curr_addr 338 | 339 | def __data_flash_read(dev, data_flash_size): 340 | curr_addr = 0 341 | read_data = b'' 342 | cfg = dev.get_active_configuration() 343 | intf = cfg[(0,0)] 344 | ep_in = usb.util.find_descriptor(intf, bEndpointAddress=EP_IN_ADDR) 345 | max_packet_size = ep_in.wMaxPacketSize 346 | max_rcv_len_perpack = max_packet_size - 4 - 2 347 | while curr_addr < data_flash_size: 348 | left_len = data_flash_size - curr_addr 349 | if (left_len) > max_rcv_len_perpack: 350 | rcv_pkt_length = max_rcv_len_perpack 351 | else: 352 | rcv_pkt_length = left_len 353 | cmd_pl = curr_addr.to_bytes(4,'little') + rcv_pkt_length.to_bytes(2,'little') 354 | ret, ret_pl = cmd_exec(dev, 'DataRead', cmd_pl) 355 | if( ret == None or ret_pl[0] != 0x00): 356 | return None, read_data 357 | read_data += bytes(ret_pl[2:]) 358 | curr_addr = curr_addr + len(ret_pl[2:]) 359 | if(curr_addr > data_flash_size): 360 | return data_flash_size, read_data 361 | else: 362 | return curr_addr, read_data 363 | 364 | def __erase_program_flash_ch5xx(dev, chip_ref): 365 | # We assume pages size is 1kb 366 | erase_page_cnt = chip_ref['flash_size']>>10 367 | cmd_pl = erase_page_cnt.to_bytes(4,'little') 368 | ret, ret_pl = cmd_exec(dev,'FlashErase', cmd_pl) 369 | if ret_pl[0] == 0: 370 | return True 371 | else: 372 | return None 373 | 374 | def __erase_data_flash_ch5xx(dev, chip_ref): 375 | # We assume pages size is 1kb 376 | erase_page_cnt = chip_ref['dataflash_size']>>10 377 | if(erase_page_cnt == 0): 378 | erase_page_cnt = 1 379 | cmd_pl = int(0).to_bytes(4,'little') + erase_page_cnt.to_bytes(1,'little') 380 | ret, ret_pl = cmd_exec(dev,'DataErase', cmd_pl) 381 | if ret_pl[0] == 0: 382 | return True 383 | else: 384 | return None 385 | 386 | def __end_flash_ch5xx(dev, restart_after = False): 387 | cmd_pl = bytes([restart_after]) 388 | return cmd_exec(dev, "End", cmd_pl) 389 | 390 | def __get_list_from_given_options(options): 391 | opt_list = [] 392 | for opt_l in options: 393 | for opt in opt_l: 394 | for spl_opt in opt.split(','): 395 | opt_list.append(spl_opt.split('=')) 396 | return opt_list 397 | 398 | def __check_option_list(opt_list, chip_ref, verbose=False): 399 | opt_good = True 400 | if(chip_ref.get('cfgs_bits')): 401 | for opt in opt_list: 402 | if(chip_ref['cfgs_bits'].get(opt[0]) == None): 403 | print("Chip %s do not have option: %s" % (chip_ref['name'], opt[0]) ) 404 | opt_good = False 405 | elif(chip_ref['cfgs_bits'][opt[0]].get('need_value') and len(opt)<2 ): 406 | print("Chip %s option: %s need value be given by %s=value" % (chip_ref['name'], opt[0], opt[0]) ) 407 | opt_good = False 408 | elif(len(opt)>1 and not chip_ref['cfgs_bits'][opt[0]].get('need_value') ): 409 | print("Chip %s option: %s do not accept value but given =%d" % (chip_ref['name'], opt[0], eval(opt[1]) ) ) 410 | opt_good = False 411 | else: 412 | cfg_opt_dict = chip_ref['cfgs_bits'].get(opt[0]) 413 | if(len(opt)>1): 414 | value = eval(opt[1]) 415 | for cfg_flag in [FLAG_CFG1 , FLAG_CFG2, FLAG_CFG3]: 416 | cfg_flag_dict = chip_ref['cfgs_bits'][opt[0]].get(cfg_flag) 417 | if(cfg_flag_dict): 418 | cfg_flag_v = cfg_flag 419 | break 420 | if(cfg_flag_dict): 421 | #if(cfg_flag_dict.get('mask')): 422 | val_mask = chip_ref['cfgs_bits'][opt[0]][cfg_flag].get('mask') 423 | if(value & val_mask != value): 424 | print("Chip %s option: %s given value 0x%08x out of mask 0x%08x" % (chip_ref['name'], opt[0], value , val_mask) ) 425 | opt_good = False 426 | elif(verbose): 427 | print("Chip %s Good option: %s value %d" % (chip_ref['name'], opt[0], eval(opt[1]) ) ) 428 | else: 429 | if(verbose): 430 | print("Chip %s Good option: %s" % (chip_ref['name'], opt[0]) ) 431 | if(not opt_good and not verbose): 432 | break 433 | else: 434 | print("Chip %s do not have any config options to use." % (chip_ref['name'])) 435 | opt_good = False 436 | return opt_good 437 | 438 | def __apply_option_list(opt_list, chip_ref, chip_cfgs, verbose=False): 439 | cfgs_changed = False 440 | result_d = {} 441 | result_d.update(chip_cfgs.copy()) 442 | for opt in [['_reserved']] + opt_list: 443 | cfg_opt_dict = chip_ref['cfgs_bits'].get(opt[0]) 444 | for cfg_flag in [FLAG_CFG1 , FLAG_CFG2, FLAG_CFG3]: 445 | cfg_flag_dict = cfg_opt_dict.get(cfg_flag) 446 | if(cfg_flag_dict and (chip_cfgs['Fields'] & cfg_flag == cfg_flag) ): 447 | if(cfg_opt_dict.get('need_value')): 448 | value = eval(opt[1]) 449 | else: 450 | value = cfg_flag_dict.get('value') 451 | new_val = ( result_d[cfg_flag] & ( 0xffffffff ^ cfg_flag_dict.get('mask') ) ) | value 452 | if( opt[0] not in ['_reserved']): 453 | if( result_d[cfg_flag] != new_val ): 454 | cfgs_changed = True 455 | print("Config get changed") 456 | else: 457 | print("Configuration option %s already in chip configs." % (opt[0])) 458 | result_d.update( { cfg_flag : new_val } ) 459 | if(cfg_opt_dict.get('need_value')): 460 | break 461 | return cfgs_changed, result_d 462 | 463 | def main(): 464 | pathname = os.path.dirname(__file__) if '__file__' in globals() else os.path.dirname(sys.argv[0]) 465 | fullpath = os.path.abspath(pathname) 466 | 467 | parser = argparse.ArgumentParser( 468 | description="USBISP Tool For WinChipHead CH55x/CH56x .") 469 | 470 | parser.add_argument( 471 | '-f', '--flash', type=str, default='', 472 | help="The target file to be written to program flash. This must be a binary file (hex files are not supported). Flashing include chipe erase in front.") 473 | parser.add_argument( 474 | '-e', '--erase_flash', action='store_true', default=False, 475 | help="Erase chip program flash.") 476 | parser.add_argument( 477 | '--verify_flash', type=str, action='store', nargs='?', const='', default=None, 478 | help="Verify flash.") 479 | 480 | parser.add_argument( 481 | '-d', '--data', type=str, default='', 482 | help="The target file to be written to data flash. This must be a binary file (hex files are not supported). Flashing include chipe erase in front.") 483 | parser.add_argument( 484 | '-c', '--erase_dataflash', action='store_true', default=False, 485 | help="Clean chip data eeprom.") 486 | parser.add_argument( 487 | '-g', '--read_dataflash', type=str, default='', 488 | help="Read chip data eeprom.") 489 | parser.add_argument( 490 | '--verify_data', type=str, action='store', nargs='?', const='', default=None, 491 | help="Verify data flash.") 492 | 493 | parser.add_argument( 494 | '-p', '--print_chip_cfg', action='store_true', default=False, 495 | help="Read and print chip configuration bits 3 x 32bit values.") 496 | 497 | parser.add_argument( 498 | '--print_otp', type=int, 499 | help="Read and print OTP.") 500 | 501 | parser.add_argument( 502 | '-o', '--cfgs_options', action='append', nargs='+', 503 | help="Apply configuration options before operations.") 504 | parser.add_argument( 505 | '-a', '--cfgs_options_after', action='append', nargs='+', 506 | help="Apply configuration options after operations.") 507 | parser.add_argument( 508 | '--cfgs_options_force_action', action='store_true', default=False, 509 | help="!Warning! Use on own risk, configuration options enable action (writing).") 510 | parser.add_argument( 511 | '--cfgs_options_list', type=str, action='store', nargs='?', const='', default=None, 512 | help="List configuration options for detected chip or optional given chip name.") 513 | 514 | parser.add_argument( 515 | '-u', '--user_def', type=str, default='', 516 | help="Use additional user chip definition INI file.") 517 | 518 | parser.add_argument( 519 | '-r', '--reset_at_end', action='store_true', default=False, 520 | help="Reset as the end of operations.") 521 | parser.add_argument( 522 | '-l', '--list', action='store_true', default=False, 523 | help="List connected devices.") 524 | parser.add_argument( 525 | '-v', '--verbose', action='store_true', default=False, 526 | help="Verbose program process output.") 527 | 528 | args = parser.parse_args() 529 | 530 | verb = args.verbose 531 | addr = 0 532 | ret = __get_dfu_device() 533 | if ret[0] is None: 534 | print('Failed to get device, please check your libusb installation.') 535 | sys.exit(-1) 536 | 537 | dev = ret[0] 538 | 539 | ret, chip_id, chip_subid = __detect_ch5xx(dev) 540 | if ret is None: 541 | print('Unable to detect CH5xx.') 542 | print('Welcome to report this issue with a screen shot from the official CH5xx tool.') 543 | sys.exit(-1) 544 | 545 | if(args.user_def): 546 | chip_ref = get_chip_parameters(chip_id, fullpath, args.user_def) 547 | else: 548 | chip_ref = get_chip_parameters(chip_id, fullpath) 549 | 550 | if chip_ref is None: 551 | print('Chip ID: %x is not known = not supported' % chip_id) 552 | print('Welcome to report this issue with a screen shot from the official CH5xx tool.') 553 | sys.exit(-1) 554 | 555 | print('Found %s with SubId:%d' % (chip_ref['name'], chip_subid)) 556 | 557 | ret, chip_cfg = __read_cfg_ch5xx(dev, FLAG_BOOTVER | FLAG_UID, chip_id, chip_subid) 558 | if ret is None: 559 | print('Cannot read chip bootloader version/uniqe ID.') 560 | sys.exit(-1) 561 | else: 562 | bootver = chip_cfg.get(FLAG_BOOTVER) 563 | uid = chip_cfg.get(FLAG_UID) 564 | if( bootver is None or uid is None): 565 | print('Cannot read chip bootloader version or uniqe ID.') 566 | sys.exit(-1) 567 | 568 | # To prevent "detection break" 569 | _, _, _ = __detect_ch5xx(dev) 570 | 571 | ver_str = '%d%d.%d%d' % (bootver[0], bootver[1], bootver[2], bootver[3]) 572 | print('BTVER:%s' % ver_str) 573 | 574 | uid_str = '%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X' % (uid[0], uid[1], uid[2], uid[3], uid[4], uid[5], uid[6], uid[7]) 575 | print('UID:%s' % uid_str) 576 | 577 | if(float(ver_str)<2.3): 578 | sys.exit('Bootloader version not supported.') 579 | 580 | chk_sum = __chip_uid_chk_sum(chip_subid, uid) 581 | 582 | if(args.cfgs_options_list != None): 583 | if(args.cfgs_options_list != ''): 584 | print("Printing options for given name not supported") 585 | else: 586 | cfgs_opt_dict = chip_ref.get('cfgs_bits') 587 | if(cfgs_opt_dict): 588 | for opt_name in cfgs_opt_dict.keys(): 589 | if(cfgs_opt_dict[opt_name].get('need_value')): 590 | val_str = '=xxx' 591 | else: 592 | val_str = '' 593 | if(opt_name in ['_reserved']): 594 | continue 595 | opt_help = cfgs_opt_dict[opt_name].get('help') 596 | if(opt_help): 597 | print("Option '%s'\t - %s" % (opt_name+val_str, opt_help)) 598 | else: 599 | print("Option '%s'\t - no description" % (opt_name+val_str)) 600 | else: 601 | print("No known options for found chip.") 602 | 603 | if(args.cfgs_options): 604 | if(args.cfgs_options_force_action): 605 | print(" Configuration options action is high RISK, you take action on YOUR OWN RISK !!") 606 | else: 607 | print(" Configuration options work in simulation mode. No real action (updating/writing).\r\n To force real action at YOUR OWN RISK use '--cfgs_options_force_action'!!") 608 | opt_list = __get_list_from_given_options(args.cfgs_options) 609 | # Check all options exist and meet defines 610 | if(not __check_option_list(opt_list,chip_ref, verb)): 611 | print('Config options error.') 612 | sys.exit(-1) 613 | 614 | if(args.cfgs_options_after): 615 | if(args.cfgs_options_force_action): 616 | print(" Configuration options action is high RISK, you take action on YOUR OWN RISK !!") 617 | else: 618 | print(" Configuration options work in simulation mode. No real action (updating/writing).\r\n To force real action at YOUR OWN RISK use '--cfgs_options_force_action'!!") 619 | 620 | opt_list_after = __get_list_from_given_options(args.cfgs_options_after) 621 | # Check all options exist and meet defines 622 | if(not __check_option_list(opt_list_after,chip_ref, verb)): 623 | print('Config after options error.') 624 | sys.exit(-1) 625 | ret, chip_cfg = __read_cfg_ch5xx(dev, FLAG_CFGs, chip_id, chip_subid) 626 | if ret is None: 627 | print('Cannot read chip configs variables.') 628 | sys.exit(-1) 629 | 630 | if(args.print_chip_cfg): 631 | ret, chip_cfg = __read_cfg_ch5xx(dev, FLAG_CFGs, chip_id, chip_subid) 632 | if ret is None: 633 | print('Cannot read chip configs variables.') 634 | sys.exit(-1) 635 | else: 636 | cfg1 = chip_cfg.get(FLAG_CFG1) 637 | cfg2 = chip_cfg.get(FLAG_CFG2) 638 | cfg3 = chip_cfg.get(FLAG_CFG3) 639 | if( cfg1 is None or cfg2 is None or cfg3 is None): 640 | print('Cannot find chip configurations after read.') 641 | sys.exit(-1) 642 | print("Chip configs 0x%08X 0x%08X 0x%08X" % (cfg1, cfg2, cfg3) ) 643 | 644 | # To prevent "detection break" 645 | _, _, _ = __detect_ch5xx(dev) 646 | 647 | if(args.print_otp is not None): 648 | cmd_pl = args.print_otp.to_bytes(1,"little") 649 | print("Reading OTP",end="") 650 | ret, chip_otp = cmd_exec(dev, "ReadOTP", cmd_pl) 651 | if(ret is None): 652 | print('Cannot read chip OTP.') 653 | sys.exit(-1) 654 | else: 655 | if(chip_otp[0] == 0 and chip_otp[1] == 0 and len(chip_otp)>2 ) : 656 | print(":", list(chip_otp[2:])) 657 | else: 658 | print(" Respond failure:",list(chip_otp) ) 659 | 660 | if(args.cfgs_options): 661 | ret, chip_cfg = __read_cfg_ch5xx(dev, FLAG_CFGs, chip_id, chip_subid) 662 | if(ret is None): 663 | print('Cannot read chip configs variables.') 664 | sys.exit(-1) 665 | if( chip_cfg.get(FLAG_CFG1) is None or 666 | chip_cfg.get(FLAG_CFG2) is None or 667 | chip_cfg.get(FLAG_CFG3) is None 668 | ): 669 | print('Cannot find chip configurations after read.') 670 | sys.exit(-1) 671 | 672 | cfg_changed, new_cfg = __apply_option_list(opt_list,chip_ref,chip_cfg) 673 | 674 | if(verb): 675 | cfg1 = chip_cfg.get(FLAG_CFG1) 676 | cfg2 = chip_cfg.get(FLAG_CFG2) 677 | cfg3 = chip_cfg.get(FLAG_CFG3) 678 | 679 | ncfg1 = new_cfg.get(FLAG_CFG1) 680 | ncfg2 = new_cfg.get(FLAG_CFG2) 681 | ncfg3 = new_cfg.get(FLAG_CFG3) 682 | print("Chip configs before apply 0x%08X 0x%08X 0x%08X" % (cfg1, cfg2, cfg3) ) 683 | print("Chip configs after apply 0x%08X 0x%08X 0x%08X" % (ncfg1, ncfg2, ncfg3) ) 684 | 685 | if(args.cfgs_options_force_action and cfg_changed): 686 | ret, ret_pl = __write_cfg_ch5xx(dev, new_cfg) 687 | if(ret is None): 688 | print('Cannot write chip configs variables.') 689 | sys.exit(-1) 690 | elif(ret_pl[0]): 691 | print('Error at writing chip configs variables. Resp: ', ret_pl[:]) 692 | sys.exit(-1) 693 | # To repeat original SW 694 | _, _ = __read_cfg_ch5xx(dev, FLAG_CFGs, chip_id, chip_subid) 695 | elif(not cfg_changed): 696 | print('All given configuration options already set, nothing to realy write.') 697 | # To prevent "detection break" 698 | _, _, _ = __detect_ch5xx(dev) 699 | 700 | if(args.read_dataflash !=''): 701 | ret, ret_data = __data_flash_read(dev, chip_ref['dataflash_size']) 702 | if(ret is not None): 703 | data_write_file = open(args.read_dataflash,'wb') 704 | data_write_file.write(ret_data) 705 | data_write_file.close() 706 | 707 | if(args.data != ''): 708 | dataflash_write_data = open(args.data, 'rb').read() 709 | if(args.data.endswith('.hex') or args.data.endswith('.ihx')): 710 | print("WARNING: This looks like a hex file. This tool only supports binary files.") 711 | if len(dataflash_write_data) > chip_ref['dataflash_size']: 712 | print('The binary for Data flashing is too large for the device.') 713 | print('Binary size: %d, DataFlash size: %d' % (len(dataflash_write_data),chip_ref['dataflash_size'])) 714 | sys.exit(-1) 715 | 716 | if(args.data != '' or args.erase_dataflash==True): 717 | print('Erasing chip data flash.',end="") 718 | ret = __erase_data_flash_ch5xx(dev,chip_ref) 719 | if ret is None: 720 | sys.exit(' Failed.') 721 | else: 722 | print(' Done.') 723 | 724 | if(args.data != ''): 725 | if(len(dataflash_write_data)>0): 726 | if(dataflash_write_data[0]==58): 727 | print("WARNING: Flashing data looks like a hex file. This tool only supports binary files.") 728 | enc_key, key_b = __gen_key_values(chip_id, chk_sum) 729 | ret = __send_key_base(dev,key_b) 730 | if ret is None: 731 | sys.exit('Failed to write key for DataFlash write to CH5xx.') 732 | print('DataFlashing chip.',end='') 733 | ret, addr = __flash_ops_write_verify(dev, enc_key, dataflash_write_data, func="DataWrite") 734 | if(ret): 735 | if(verb): 736 | print(' Done. Amount: %d ' % (addr) ) 737 | else: 738 | print(' Done. ') 739 | else: 740 | sys.exit(' Failed. Address %d' %(addr) ) 741 | else: 742 | print('Nothing to write to program flash.') 743 | 744 | if(args.verify_data != None): 745 | if(args.verify_data != ''): 746 | dataflash_verify_data = open(args.verify_data, 'rb').read() 747 | if(args.verify_data.endswith('.hex') or args.verify_data.endswith('.ihx')): 748 | print("WARNING: This looks like a hex file. This tool only supports binary files.") 749 | if len(dataflash_verify_data) > chip_ref['dataflash_size']: 750 | print('The binary for verifying is too large for the device.') 751 | print('Binary size: %d, DataFlash size: %d' % (len(dataflash_verify_data),chip_ref['dataflash_size'])) 752 | sys.exit(-1) 753 | else: 754 | if(args.data == ''): 755 | dataflash_verify_data = b'' 756 | else: 757 | dataflash_verify_data = dataflash_write_data 758 | 759 | if(len(dataflash_verify_data)>0): 760 | if(dataflash_verify_data[0]==58): 761 | print("WARNING: Verifying data looks like a hex file. This tool only supports binary files.") 762 | 763 | print('Verifying Dataflash.',end='') 764 | ret, ret_data = __data_flash_read(dev, len(dataflash_verify_data)) 765 | if ret is None: 766 | sys.exit(' Data read failed. Read amount %d.' %(len(ret_data))) 767 | elif(len(ret_data) != len(dataflash_verify_data)): 768 | sys.exit(' Failed. Sizes differ: received %d to compare %d' %(len(ret_data), len(dataflash_verify_data)) ) 769 | elif(ret_data != dataflash_verify_data): 770 | print(' Compare failed ', end='') 771 | for i in range(len(ret_data)): 772 | if(ret_data[i] != dataflash_verify_data[i]): 773 | print('at address %d.' %(i)) 774 | break 775 | sys.exit(-1) 776 | else: 777 | if(verb): 778 | print(' Done. Amount: %d ' % (len(ret_data)) ) 779 | else: 780 | print(' Done. ') 781 | else: 782 | print('Nothing to verifying with data flash.') 783 | 784 | flash_file = args.flash 785 | if(flash_file != ''): 786 | flash_write_data = open(flash_file, 'rb').read() 787 | if(flash_file.endswith('.hex') or flash_file.endswith('.ihx')): 788 | print("WARNING: This looks like a hex file. This tool only supports binary files.") 789 | if len(flash_write_data) > chip_ref['flash_size']: 790 | print('The binary for flashing is too large for the device.') 791 | print('Binary size: %d, Flash size: %d' % (len(flash_write_data),chip_ref['flash_size'])) 792 | sys.exit(-1) 793 | 794 | if(flash_file != '' or args.erase_flash==True): 795 | print('Erasing chip flash.',end="") 796 | ret = __erase_program_flash_ch5xx(dev,chip_ref) 797 | if ret is None: 798 | sys.exit(' Failed.') 799 | else: 800 | print(' Done.') 801 | 802 | if(flash_file != ''): 803 | if(len(flash_write_data)>0): 804 | if(flash_write_data[0]==58): 805 | print("WARNING: Flashing data looks like a hex file. This tool only supports binary files.") 806 | enc_key, key_b = __gen_key_values(chip_id, chk_sum) 807 | ret = __send_key_base(dev,key_b) 808 | if ret is None: 809 | sys.exit('Failed to write key for flash write to CH5xx.') 810 | print('Flashing chip.',end='') 811 | ret, addr = __flash_ops_write_verify(dev, enc_key, flash_write_data, func="FlashWrite") 812 | if(ret): 813 | if(verb): 814 | print(' Done. Amount: %d ' % (addr) ) 815 | else: 816 | print(' Done. ') 817 | else: 818 | sys.exit(' Failed. Address %d' %(addr) ) 819 | else: 820 | print('Nothing to write to program flash.') 821 | 822 | if(args.verify_flash != None): 823 | if(args.verify_flash != ''): 824 | flash_verify_data = open(args.verify_flash, 'rb').read() 825 | if(args.verify_flash.endswith('.hex') or args.verify_flash.endswith('.ihx')): 826 | print("WARNING: This looks like a hex file. This tool only supports binary files.") 827 | if len(flash_verify_data) > chip_ref['flash_size']: 828 | print('The binary for verifying is too large for the device.') 829 | print('Binary size: %d, Flash size: %d' % (len(flash_verify_data),chip_ref['flash_size'])) 830 | sys.exit(-1) 831 | else: 832 | if(flash_file == ''): 833 | flash_verify_data = b'' 834 | else: 835 | flash_verify_data = flash_write_data 836 | 837 | if(len(flash_verify_data)>0): 838 | if(flash_verify_data[0]==58): 839 | print("WARNING: Verifying data looks like a hex file. This tool only supports binary files.") 840 | enc_key, key_b = __gen_key_values(chip_id, chk_sum) 841 | ret = __send_key_base(dev,key_b) 842 | if ret is None: 843 | sys.exit('Failed to write key for flash verify to CH5xx.') 844 | print('Verifying flash.',end='') 845 | ret, addr = __flash_ops_write_verify(dev, enc_key, flash_verify_data, func="FlashVerify") 846 | if(ret): 847 | if(verb): 848 | print(' Done. Amount: %d ' % (addr) ) 849 | else: 850 | print(' Done. ') 851 | else: 852 | sys.exit(' Failed. Address %d' %(addr) ) 853 | else: 854 | print('Nothing to verifying with program flash.') 855 | 856 | if(args.cfgs_options_after): 857 | ret, chip_cfg = __read_cfg_ch5xx(dev, FLAG_CFGs, chip_id, chip_subid) 858 | if(ret is None): 859 | print('Cannot read chip configs variables.') 860 | sys.exit(-1) 861 | if( chip_cfg.get(FLAG_CFG1) is None or 862 | chip_cfg.get(FLAG_CFG2) is None or 863 | chip_cfg.get(FLAG_CFG3) is None 864 | ): 865 | print('Cannot find chip configurations after read.') 866 | sys.exit(-1) 867 | 868 | cfg_changed, new_cfg = __apply_option_list(opt_list_after,chip_ref,chip_cfg) 869 | 870 | if(verb): 871 | cfg1 = chip_cfg.get(FLAG_CFG1) 872 | cfg2 = chip_cfg.get(FLAG_CFG2) 873 | cfg3 = chip_cfg.get(FLAG_CFG3) 874 | 875 | ncfg1 = new_cfg.get(FLAG_CFG1) 876 | ncfg2 = new_cfg.get(FLAG_CFG2) 877 | ncfg3 = new_cfg.get(FLAG_CFG3) 878 | print("Chip configs before apply 0x%08X 0x%08X 0x%08X" % (cfg1, cfg2, cfg3) ) 879 | print("Chip configs after apply 0x%08X 0x%08X 0x%08X" % (ncfg1, ncfg2, ncfg3) ) 880 | 881 | if(args.cfgs_options_force_action and cfg_changed): 882 | ret, ret_pl = __write_cfg_ch5xx(dev, new_cfg) 883 | if(ret is None): 884 | print('Cannot write chip configs variables.') 885 | sys.exit(-1) 886 | elif(ret_pl[0]): 887 | print('Error at writing chip configs variables. Resp: ', ret_pl[:]) 888 | sys.exit(-1) 889 | # To repeat original SW 890 | _, _ = __read_cfg_ch5xx(dev, FLAG_CFGs, chip_id, chip_subid) 891 | elif(not cfg_changed): 892 | print('All given configuration options already set, nothing to realy write.') 893 | 894 | # To prevent "detection break" 895 | _, _, _ = __detect_ch5xx(dev) 896 | 897 | print('Finalize communication.',end="") 898 | ret, ret_pl = __end_flash_ch5xx(dev, restart_after = args.reset_at_end) 899 | if(ret is True): 900 | print(' Restart and run.') 901 | elif(ret is None): 902 | sys.exit('Failed to finish communication. No response.') 903 | else: 904 | if(ret_pl != None): 905 | if ret_pl[0] != 0x00: 906 | resp_str = ' Response: %02x' % (ret_pl[0]) 907 | sys.exit('Failed to finish communication.'+ resp_str) 908 | else: 909 | print(' Done.') 910 | else: 911 | sys.exit('Failed to finish communication. Response without value.') 912 | 913 | if __name__ == '__main__': 914 | sys.exit(main()) 915 | -------------------------------------------------------------------------------- /ch55xtool/extended.wcfg: -------------------------------------------------------------------------------- 1 | [CH552] 2 | Tested=1 3 | CFGs={ 4 | '_reserved': { 5 | FLAG_CFG1 :{'mask':0xffffffff,'value':0xffffffff }, 6 | FLAG_CFG2 :{'mask':0xfffffff0,'value':0x00000000 }, 7 | FLAG_CFG3 :{'mask':0xffff0fff,'value':0x000002ff } 8 | }, 9 | 'default': { 10 | FLAG_CFG2 :{'mask':0x0f,'value':0x03 }, 11 | FLAG_CFG3 :{'mask':0x0000f000,'value':0x00004000 }, 12 | 'help':'Write default CFGs values' 13 | }, 14 | 'cfg2_val': { 15 | 'need_value': True, 16 | FLAG_CFG2 :{'mask':0xf }, 17 | 'help':'Direct define value for CFG2 in mask 0x0000000F' 18 | }, 19 | 'cfg3_val': { 20 | 'need_value': True, 21 | FLAG_CFG3 :{'mask':0xf000 }, 22 | 'help':'Direct define value for CFG3 in mask 0x0000F000' 23 | }, 24 | 'En_RST_RESET': { 25 | FLAG_CFG3 :{'mask': 1<<12 , 'value': 1<<12 }, 26 | 'help':'Enable RST pin as manual reset input pin.' 27 | }, 28 | 'Dis_RST_RESET': { 29 | FLAG_CFG3 :{'mask': 1<<12, 'value': 0 }, 30 | 'help':'Disable RST pin as manual reset input pin.' 31 | } 32 | } 33 | 34 | [CH582] 35 | Tested=1 36 | CFGs={ 37 | '_reserved': { 38 | FLAG_CFG1 :{'mask':0xffffffff,'value':0xffffffff }, 39 | FLAG_CFG2 :{'mask':0xffffffff,'value':0xffffffff }, 40 | FLAG_CFG3 :{'mask':0xffffffff,'value':0xffffffff } 41 | }, 42 | 'default': { 43 | FLAG_CFG2 :{'mask':0xffffffff,'value':0xffffffff }, 44 | FLAG_CFG3 :{'mask': 0xffffffff, 'value': 0x4FFF0FD5}, 45 | 'help':'Write default CFGs values' 46 | }, 47 | 'Dis_Debug': { 48 | FLAG_CFG3 :{'mask': 0xffffffff , 'value': 0x4FFF0F4D }, 49 | 'help':'Enable Debug port ' 50 | }, 51 | 'En_Debug': { 52 | FLAG_CFG3 :{'mask': 0xffffffff, 'value': 0x4FFF0FD5 }, 53 | 'help':'Disable Debug port' 54 | } 55 | } 56 | 57 | [CH592] 58 | Tested=1 59 | CFGs={ 60 | '_reserved': { 61 | FLAG_CFG1 :{'mask':0xffffffff,'value':0xffffffff }, 62 | FLAG_CFG2 :{'mask':0xffffffff,'value':0xffffffff }, 63 | FLAG_CFG3 :{'mask':0xffffffff,'value':0xffffffff } 64 | }, 65 | 'default': { 66 | FLAG_CFG2 :{'mask':0xffffffff,'value':0xffffffff }, 67 | FLAG_CFG3 :{'mask': 0xffffffff, 'value': 0x4FFF0FD5}, 68 | 'help':'Write default CFGs values' 69 | }, 70 | 'Dis_Debug': { 71 | FLAG_CFG3 :{'mask': 0xffffffff , 'value': 0x4FFF0F4D }, 72 | 'help':'Enable Debug port ' 73 | }, 74 | 'En_Debug': { 75 | FLAG_CFG3 :{'mask': 0xffffffff, 'value': 0x4FFF0FD5 }, 76 | 'help':'Disable Debug port' 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /ch55xtool/typeall.wcfg: -------------------------------------------------------------------------------- 1 | [WCHCHIP] 2 | ChipName0=CH561 3 | ChipName1=CH563 4 | ChipName2=CH565 5 | ChipName3=CH566 6 | ChipName4=CH567 7 | ChipName5=CH568 8 | ChipName6=CH569 9 | ChipName7=CH551 10 | ChipName8=CH552 11 | ChipName9=CH554 12 | ChipName10=CH555 13 | ChipName11=CH556 14 | ChipName12=CH557 15 | ChipName13=CH558 16 | ChipName14=CH559 17 | ChipName15=CH544 18 | ChipName16=CH545 19 | ChipName17=CH546 20 | ChipName18=CH547 21 | ChipName19=CH548 22 | ChipName20=CH549 23 | ChipName21=CH571 24 | ChipName22=CH573 25 | ChipName23=CH577 26 | ChipName24=CH578 27 | ChipName25=CH579 28 | ChipName26=CH32F103 29 | ChipName27=CH32V103 30 | ChipName28=CH581 31 | ChipName29=CH582 32 | ChipName30=CH583 33 | ChipName31=CH32V303 34 | ChipName32=CH32V305 35 | ChipName33=CH32V307 36 | ChipName34=CH32F203 37 | ChipName35=CH32F205 38 | ChipName36=CH32F207 39 | ChipName37=CH32F208 40 | ChipName38= 41 | ChipName39= 42 | ChipName40= 43 | 44 | [CH561] 45 | McuType=0 46 | MaxFlashSize=65536 47 | MaxEepromSize=28672 48 | IsNetworkDown=1 49 | IsUsbDown=0 50 | IsSerialDown=1 51 | chipid=97 52 | 53 | [CH563] 54 | McuType=0 55 | MaxFlashSize=229376 56 | MaxEepromSize=28672 57 | IsNetworkDown=1 58 | IsUsbDown=1 59 | IsSerialDown=1 60 | chipid=99 61 | 62 | [CH565] 63 | McuType=0 64 | MaxFlashSize=458752 65 | MaxEepromSize=32768 66 | IsNetworkDown=0 67 | IsUsbDown=1 68 | IsSerialDown=1 69 | chipid=101 70 | eepromStartAddr=0 71 | Introduction = "" 72 | 73 | [CH566] 74 | McuType=0 75 | MaxFlashSize=65536 76 | MaxEepromSize=32768 77 | IsNetworkDown=0 78 | IsUsbDown=1 79 | IsSerialDown=1 80 | chipid=102 81 | eepromStartAddr=0 82 | Introduction = "" 83 | 84 | [CH567] 85 | McuType=0 86 | MaxFlashSize=196608 87 | MaxEepromSize=32768 88 | IsNetworkDown=0 89 | IsUsbDown=1 90 | IsSerialDown=1 91 | chipid=103 92 | eepromStartAddr=0 93 | Introduction = "" 94 | 95 | [CH568] 96 | McuType=0 97 | MaxFlashSize=196608 98 | MaxEepromSize=32768 99 | IsNetworkDown=0 100 | IsUsbDown=1 101 | IsSerialDown=1 102 | chipid=104 103 | eepromStartAddr=0 104 | Introduction = "" 105 | 106 | [CH569] 107 | McuType=0 108 | MaxFlashSize=458752 109 | MaxEepromSize=32768 110 | IsNetworkDown=0 111 | IsUsbDown=1 112 | IsSerialDown=1 113 | chipid=105 114 | eepromStartAddr=0 115 | Introduction = "" 116 | 117 | [CH551] 118 | McuType=1 119 | MaxFlashSize=10240 120 | MaxEepromSize=128 121 | IsNetworkDown=0 122 | IsUsbDown=1 123 | IsSerialDown=0 124 | chipid=81 125 | eepromStartAddr=49152 126 | Introduction = "" 127 | 128 | [CH552] 129 | McuType=1 130 | MaxFlashSize=14336 131 | MaxEepromSize=128 132 | IsNetworkDown=0 133 | IsUsbDown=1 134 | IsSerialDown=1 135 | chipid=82 136 | eepromStartAddr=49152 137 | Introduction = "" 138 | 139 | [CH554] 140 | McuType=1 141 | MaxFlashSize=14336 142 | MaxEepromSize=128 143 | IsNetworkDown=0 144 | IsUsbDown=1 145 | IsSerialDown=1 146 | chipid=84 147 | eepromStartAddr=49152 148 | Introduction = "" 149 | 150 | [CH555] 151 | McuType=1 152 | MaxFlashSize=61440 153 | MaxEepromSize=1024 154 | IsNetworkDown=0 155 | IsUsbDown=1 156 | IsSerialDown=1 157 | chipid=85 158 | eepromStartAddr=61440 159 | Introduction = "" 160 | 161 | [CH556] 162 | McuType=1 163 | MaxFlashSize=61440 164 | MaxEepromSize=1024 165 | IsNetworkDown=0 166 | IsUsbDown=1 167 | IsSerialDown=1 168 | chipid=86 169 | eepromStartAddr=61440 170 | Introduction = "" 171 | 172 | [CH557] 173 | McuType=1 174 | MaxFlashSize=61440 175 | MaxEepromSize=1024 176 | IsNetworkDown=0 177 | IsUsbDown=1 178 | IsSerialDown=1 179 | chipid=87 180 | eepromStartAddr=61440 181 | Introduction = "" 182 | 183 | [CH558] 184 | McuType=1 185 | MaxFlashSize=32768 186 | MaxEepromSize=5120 187 | IsNetworkDown=0 188 | IsUsbDown=1 189 | IsSerialDown=1 190 | chipid=88 191 | eepromStartAddr=57344 192 | Introduction = "" 193 | 194 | [CH559] 195 | McuType=1 196 | MaxFlashSize=61440 197 | MaxEepromSize=1024 198 | IsNetworkDown=0 199 | IsUsbDown=1 200 | IsSerialDown=1 201 | chipid=89 202 | eepromStartAddr=61440 203 | Introduction = "" 204 | 205 | [CH544] 206 | McuType=2 207 | MaxFlashSize=61440 208 | MaxEepromSize=3072 209 | IsNetworkDown=0 210 | IsUsbDown=1 211 | IsSerialDown=1 212 | chipid=68 213 | eepromStartAddr=61440 214 | Introduction = "" 215 | 216 | [CH545] 217 | McuType=2 218 | MaxFlashSize=61440 219 | MaxEepromSize=3072 220 | IsNetworkDown=0 221 | IsUsbDown=1 222 | IsSerialDown=1 223 | chipid=69 224 | eepromStartAddr=61440 225 | Introduction = "" 226 | 227 | [CH546] 228 | McuType=2 229 | MaxFlashSize=32768 230 | MaxEepromSize=1024 231 | IsNetworkDown=0 232 | IsUsbDown=1 233 | IsSerialDown=1 234 | chipid=70 235 | eepromStartAddr=61440 236 | Introduction = "" 237 | 238 | [CH547] 239 | McuType=2 240 | MaxFlashSize=61440 241 | MaxEepromSize=1024 242 | IsNetworkDown=0 243 | IsUsbDown=1 244 | IsSerialDown=1 245 | chipid=71 246 | eepromStartAddr=61440 247 | Introduction = "" 248 | 249 | [CH548] 250 | McuType=2 251 | MaxFlashSize=32768 252 | MaxEepromSize=1024 253 | IsNetworkDown=0 254 | IsUsbDown=1 255 | IsSerialDown=1 256 | chipid=72 257 | eepromStartAddr=61440 258 | Introduction = "" 259 | 260 | [CH549] 261 | McuType=2 262 | MaxFlashSize=61440 263 | MaxEepromSize=1024 264 | IsNetworkDown=0 265 | IsUsbDown=1 266 | IsSerialDown=1 267 | chipid=73 268 | eepromStartAddr=61440 269 | Introduction = "" 270 | 271 | [CH571] 272 | McuType=3 273 | MaxFlashSize=196608 274 | MaxEepromSize=32768 275 | IsNetworkDown=0 276 | IsUsbDown=1 277 | IsSerialDown=1 278 | chipid=113 279 | eepromStartAddr=256000 280 | Introduction = "" 281 | 282 | [CH573] 283 | McuType=3 284 | MaxFlashSize=458752 285 | MaxEepromSize=32768 286 | IsNetworkDown=0 287 | IsUsbDown=1 288 | IsSerialDown=1 289 | chipid=115 290 | eepromStartAddr=256000 291 | Introduction = "" 292 | 293 | [CH577] 294 | McuType=3 295 | MaxFlashSize=131072 296 | MaxEepromSize=2048 297 | IsNetworkDown=0 298 | IsUsbDown=1 299 | IsSerialDown=1 300 | chipid=119 301 | eepromStartAddr=131072 302 | Introduction = "" 303 | 304 | [CH578] 305 | McuType=3 306 | MaxFlashSize=163840 307 | MaxEepromSize=2048 308 | IsNetworkDown=0 309 | IsUsbDown=1 310 | IsSerialDown=1 311 | chipid=120 312 | eepromStartAddr=163840 313 | Introduction = "" 314 | 315 | [CH579] 316 | McuType=3 317 | MaxFlashSize=256000 318 | MaxEepromSize=2048 319 | IsNetworkDown=0 320 | IsUsbDown=1 321 | IsSerialDown=1 322 | chipid=121 323 | eepromStartAddr=256000 324 | Introduction = "" 325 | 326 | [CH32F103] 327 | McuType=4 328 | MaxFlashSize=65536 329 | MaxEepromSize=0 330 | IsNetworkDown=0 331 | IsUsbDown=1 332 | IsSerialDown=1 333 | chipid=50 334 | eepromStartAddr=0 335 | Introduction = "" 336 | 337 | [CH32V103] 338 | McuType=5 339 | MaxFlashSize=65536 340 | MaxEepromSize=0 341 | IsNetworkDown=0 342 | IsUsbDown=1 343 | IsSerialDown=1 344 | chipid=50 345 | eepromStartAddr=0 346 | Introduction = "" 347 | 348 | [CH581] 349 | McuType=6 350 | MaxFlashSize=196608 351 | MaxEepromSize=32768 352 | IsNetworkDown=0 353 | IsUsbDown=1 354 | IsSerialDown=1 355 | chipid=129 356 | eepromStartAddr=0 357 | Introduction = "" 358 | 359 | [CH582] 360 | McuType=6 361 | MaxFlashSize=458752 362 | MaxEepromSize=32768 363 | IsNetworkDown=0 364 | IsUsbDown=1 365 | IsSerialDown=1 366 | chipid=130 367 | eepromStartAddr=0 368 | Introduction = "" 369 | 370 | [CH583] 371 | McuType=6 372 | MaxFlashSize=458752 373 | MaxEepromSize=557056 374 | IsNetworkDown=0 375 | IsUsbDown=1 376 | IsSerialDown=1 377 | chipid=131 378 | eepromStartAddr=0 379 | Introduction = "" 380 | 381 | [CH32V303] 382 | McuType=7 383 | MaxFlashSize=262144 384 | MaxEepromSize=0 385 | IsNetworkDown=0 386 | IsUsbDown=1 387 | IsSerialDown=1 388 | chipid=48 389 | eepromStartAddr=0 390 | Introduction = "" 391 | 392 | [CH32V305] 393 | McuType=7 394 | MaxFlashSize=131072 395 | MaxEepromSize=0 396 | IsNetworkDown=0 397 | IsUsbDown=1 398 | IsSerialDown=1 399 | chipid=80 400 | eepromStartAddr=0 401 | Introduction = "" 402 | 403 | [CH32V307] 404 | McuType=7 405 | MaxFlashSize=262144 406 | MaxEepromSize=0 407 | IsNetworkDown=0 408 | IsUsbDown=1 409 | IsSerialDown=1 410 | chipid=112 411 | eepromStartAddr=0 412 | Introduction = "" 413 | 414 | [CH32F203] 415 | McuType=8 416 | MaxFlashSize=262144 417 | MaxEepromSize=0 418 | IsNetworkDown=0 419 | IsUsbDown=1 420 | IsSerialDown=1 421 | chipid=48 422 | eepromStartAddr=0 423 | Introduction = "" 424 | 425 | [CH32F205] 426 | McuType=8 427 | MaxFlashSize=131072 428 | MaxEepromSize=0 429 | IsNetworkDown=0 430 | IsUsbDown=1 431 | IsSerialDown=1 432 | chipid=80 433 | eepromStartAddr=0 434 | Introduction = "" 435 | 436 | [CH32F207] 437 | McuType=8 438 | MaxFlashSize=262144 439 | MaxEepromSize=0 440 | IsNetworkDown=0 441 | IsUsbDown=1 442 | IsSerialDown=1 443 | chipid=112 444 | eepromStartAddr=0 445 | Introduction = "" 446 | 447 | [CH32F208] 448 | McuType=8 449 | MaxFlashSize=131072 450 | MaxEepromSize=0 451 | IsNetworkDown=0 452 | IsUsbDown=1 453 | IsSerialDown=1 454 | chipid=128 455 | eepromStartAddr=0 456 | Introduction = "" 457 | 458 | [CH32V203C8T6] 459 | McuType=7 460 | MaxFlashSize=65536 461 | MaxEepromSize=0 462 | IsNetworkDown=0 463 | IsUsbDown=1 464 | IsSerialDown=1 465 | chipid=49 466 | eepromStartAddr=0 467 | Introduction = "" 468 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import setuptools 2 | 3 | setuptools.setup( 4 | name="ch55xtool", 5 | version="1.0.4", 6 | author="Han Xiao", 7 | author_email="hansh-sz@hotmail.com", 8 | maintainer="https://github.com/MarsTechHAN/ch552tool/graphs/contributors", 9 | maintainer_email="hansh-sz@hotmail.com", 10 | description="An open sourced python tool for flashing WCH CH55x series USB microcontroller", 11 | long_description=open("README.rst").read(), 12 | long_description_content_type="text/x-rst", 13 | url="https://github.com/MarsTechHAN/ch552tool", 14 | packages=setuptools.find_packages(), 15 | package_data={'ch55xtool': ['*.wcfg', 'ch55xtool/*.wcfg']}, 16 | include_package_data=True, 17 | platforms=["all"], 18 | classifiers=[ 19 | "Development Status :: 4 - Beta", 20 | "Operating System :: OS Independent", 21 | "Intended Audience :: Developers", 22 | "License :: OSI Approved :: MIT License", 23 | "Environment :: Console", 24 | "Natural Language :: English", 25 | "Programming Language :: Python", 26 | "Programming Language :: Python :: Implementation", 27 | "Programming Language :: Python :: 2.7", 28 | "Programming Language :: Python :: 3", 29 | "Programming Language :: Python :: 3.6", 30 | "Programming Language :: Python :: 3.7", 31 | "Programming Language :: Python :: 3.8", 32 | "Programming Language :: Python :: 3.9", 33 | "Programming Language :: Python :: 3.10", 34 | "Programming Language :: Python :: 3.11", 35 | "Topic :: Software Development :: Embedded Systems", 36 | ], 37 | entry_points = { 38 | 'console_scripts': [ 39 | 'ch55xtool = ch55xtool.ch55xtool:main' 40 | ] 41 | }, 42 | python_requires='>=3.5', 43 | install_requires=['pyusb>=1.0.0']) 44 | --------------------------------------------------------------------------------