Giter Site home page Giter Site logo

cc3200tool's Introduction

CC3200 Tool

A small tool to write files in TI's CC3200 SimpleLink (TM) filesystem.

Copyright (C) 2016-2020 Allterco Robotics

NO LONGER ACTIVELY MAINTAINED HERE

Forks with CC3220 support exist, but not sure which one works best. @mon has adopted support for CC3200, go to https://github.com/mon/cc3200tool

Rationale

The only other tool which can officially do this is Uniflash, but good luck using that on a modern Linux system.

There is also cc3200prog which Energia sneak in their toolchain tarball, but it's not open source and can only write to /sys/mcuimg.bin.

Finally, there's the great guys at Cesanta who reversed the CC3200 bootloader protocol just enough to make day-to-day development on the platform possible. However, their tool is specific to smart.js and feeds on specially-crafted zip archives.

This tool is based on the work done by Cesanta but is written in Python and exposes a generic cli interface for uploading user files and application binaries on a CC3200-attached serial flash.

cc3200tool can upload NWP/MAC/PHY firmwares (/sys/servicepack.ucf), but it seems this only works on a clean FS. The tool also implements the functionality described in TI's Application Note CC3100/CC3200 Embedded Programming.

Installation

This runs on Python >=3.6 with recent pySerial.

To install, if you have pip and want system-wide:

pip install git+git://github.com/mon/cc3200tool.git

or clone this repǫ

git clone https://github.com/mon/cc3200tool.git
cd cc3200tool

then it's just like any other python package:

python setup.py install # as root, system-wide

# or in a virtualenv with pip
virtualenv env && ./env/bin/activate
pip install -e .
# then get updates with
git pull

Usage

You need a serial port connected to the target's UART interface. For programming to work, SOP2 needs to be asserted (i.e. tied to VCC) and a reset has to be peformed to switch the chip in bootloader mode. cc3200tool can optionally use the RTS and DTR lines of the serial port controller to automatically perform these actions via the --sop2 and --reset options.

See cc3200tool -h and cc3200tool <subcommand> -h for complete description of arguments. Some examples:

# upload an application
cc3200tool -p /dev/ttyUSB2 --sop2 ~dtr --reset prompt \
    write_file ./exe/myapp.bin /sys/mcuimg.bin

# format and upload an application binary
cc3200tool -p /dev/ttyUSB2 \
    format_flash --size 1M \
    write_file exe/program.bin /sys/mcuimg.bin

# dump a file on stdout
cc3200tool read_file /sys/mcuimg.bin -

# format the flash, upload a servciepack and two files
cc3200tool -p /dev/ttyUSB2 --sop2 ~rts --reset dtr \
    format_flash --size=1M \
    write_file --file-size=0x20000 \
        --signature ../servicepack-ota/ota_1.0.1.6-2.6.0.5.ucf.signed.bin \
        ../servicepack-ota/ota_1.0.1.6-2.6.0.5.ucf.ucf /sys/servicepack.ucf \
    write_file ../application_bootloader/gcc/exe/application_bootloader.bin /sys/mcuimg.bin \
    write_file yourapp.bin /sys/mcuimg1.bin

# list file and filesystem statistics (occupied and free block sequences)
cc3200tool -p /dev/ttyUSB2 list_filesystem

cc3200tool's People

Contributors

kaha6uc avatar kzyapkov avatar leechwort avatar mon avatar oleg-politechnik avatar rostakagmfun avatar s1ider avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cc3200tool's Issues

Maintainer needed

This tool was born out of necessity, but is no longer actively used in Allterco. There are now a few pull requests, and a few tasks that need to be done, Python3 support probably being the most important one as well as CC3220 support.

There are now a number of active forks, some of which implement both of the above, as well as other neat features. I wish there was a single, well-maintained, authoritative source where development progresses. This is a callout to @AlexLisnitski, @otsaregorodtsev, @s1ider, @SciLor, @mon and everyone else who contributed to this project in the past -- would you like to take over maintenance and integration of new features?

cc3200tool cannot run on Windows 7 64-bit laptop.

Hi,

I am trying this cc3200tool on Windows 7 64-bit laptop and got an issue. The following is the message. Should it work on Windows machine?

Thanks,

Nick

2017-02-02 15:04:02,364 -- Connecting to target...
2017-02-02 15:04:02,566 -- Connected, reading version...
2017-02-02 15:04:02,566 -- connected to target
2017-02-02 15:04:02,566 -- Version: CC3x00VersionInfo((0, 4, 1, 2), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (16, 0, 0, 0))
2017-02-02 15:04:02,566 -- This is a CC3200 device
2017-02-02 15:04:02,582 -- Switching to NWP bootloader...
2017-02-02 15:04:02,582 -- Switching UART to APPS...
2017-02-02 15:04:02,598 -- Resetting communications ...
2017-02-02 15:04:03,815 -- Uploading rbtl3100s.dll...
2017-02-02 15:04:03,815 -- Getting storage list...
2017-02-02 15:04:03,831 -- Getting storage info...
2017-02-02 15:04:03,845 -- storage info bytes: 0x10, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0
Traceback (most recent call last):
File "cc3200tool.py", line 761, in
File "cc3200tool.py", line 737, in main
File "cc3200tool.py", line 545, in switch_to_nwp_bootloader
File "cc3200tool.py", line 440, in _raw_write
TypeError: object of type 'NoneType' has no len()
Failed to execute script cc3200tool

CC3220 support

Hi, I've started to look at the cc3220.

After a minor adaption of your tool to handle the new version (and playing around with various settings in uniflash 4.3) , I managed to connect to a device in development mode.

Differences I found:

1: The system version is different:
Launchpad cc3220SF version = CC3x00VersionInfo((0, 1, 0, 3), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (25, 48, 0, 0))

2: The file info is different:
File without security on cc3220
0x0 0x4 0x1 0x2a 0x0 0x0 0x0 0x1 0x0 0x0 0xe 0x48 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x1 0x0 0x0 0x0 0x1
File without security on cc3200
0x1 0x8 0x0 0x2a 0x0 0x0 0x0 0x2 0x0 0x0 0xe 0x48 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0

3: Files must be defined without the "/"

Otherwise everything seems to be working ok in Development mode.

Production mode
When programming the device with Uniflash in Production mode, I can call the device actions like GetVersionInfo but when doing something on a file I get nack response (open_file and get_file_info for example). I would expect it only for secure file, but I get it on any type of file.

By any chance, have you tested something on the cc3220?

Cannot read system files

Thanks for the tool! It's a pity that TI does not provide a way to program the device in CLI.

When I do a format or a write file there is no error, but when I try to read a file it returns: "/sys/mcuimg.bin does not exist on target"

Do you have any idea what could be the source of the issue?

See the whole logs below if it can help:

C:\Users\cedric\AppData\Local\Programs\Python\Python36\python.exe C:/workspace/cc3200tool/cc3200tool/cc.py -p COM3 --sop2 ~dtr --reset ~rts read_file /sys/mcuimg.bin -
2017-11-13 11:02:50,561 -- Connecting to target...
2017-11-13 11:02:55,863 -- timed out while waiting for ack
2017-11-13 11:02:56,065 -- Connected, reading version...
2017-11-13 11:02:56,067 -- connected to target
2017-11-13 11:02:56,067 -- Version: CC3x00VersionInfo(<memory at 0x000001C98E529AC8>, <memory at 0x000001C98E529B88>, <memory at 0x000001C98E529C48>, <memory at 0x000001C98E529D08>, <memory at 0x000001C98E529DC8>)
2017-11-13 11:02:56,067 -- This is a CC3200 device
2017-11-13 11:02:56,067 -- Switching to NWP bootloader...
2017-11-13 11:02:56,082 -- Switching UART to APPS...
2017-11-13 11:02:56,098 -- Resetting communications ...
2017-11-13 11:02:57,314 -- Uploading rbtl3100s.dll...
2017-11-13 11:02:57,315 -- Getting storage list...
2017-11-13 11:02:57,332 -- Getting storage info...
2017-11-13 11:02:57,346 -- storage info bytes: 0x10, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0
2017-11-13 11:02:58,050 -- APPS version: CC3x00VersionInfo(<memory at 0x000001C98E97E288>, <memory at 0x000001C98E97E348>, <memory at 0x000001C98E97E408>, <memory at 0x000001C98E97E4C8>, <memory at 0x000001C98E97E588>)
Traceback (most recent call last):
File "C:/workspace/cc3200tool/cc3200tool/cc.py", line 813, in
main()
File "C:/workspace/cc3200tool/cc3200tool/cc.py", line 801, in main
cc.read_file(command.cc_filename, command.local_file)
File "C:/workspace/cc3200tool/cc3200tool/cc.py", line 694, in read_file
raise CC3200Error("{} does not exist on target".format(cc_fname))
main.CC3200Error: /sys/mcuimg.bin does not exist on target

On a related subject, In Uniflash there is the option to "List file System". Is it possible to implement this without too much reverse engineering?

Running without arguments raises exception

$ cc3200tool 
Traceback (most recent call last):
  File "/usr/local/bin/cc3200tool", line 22, in <module>
    main()
  File "/usr/local/lib/python2.7/dist-packages/cc3200tool/cc.py", line 695, in main
    args = commands[0]
IndexError: list index out of range

Writing a large image seems to fail.

If I build a release version of my program the image winds up being 77176 and it flashed fine using cc3200tool.

However, when I try to flash by debug build (175896 bytes), it fails to flash.

2614 >./flash.sh
+ cc3200tool -p /dev/ttyUSB1 --sop2 '~dtr' --reset prompt write_file target/thumbv7em-none-eabi/debug/sensorweb-firmware.bin /sys/mcuimg.bin
2016-12-01 20:30:15,145 -- Connecting to target...
Reset the device with SOP2 asserted and press Enter

2016-12-01 20:30:25,292 -- Connected, reading version...
2016-12-01 20:30:25,294 -- connected to target
2016-12-01 20:30:25,294 -- Version: CC3x00VersionInfo((0, 4, 1, 2), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (16, 0, 0, 0))
2016-12-01 20:30:25,294 -- This is a CC3200 device
2016-12-01 20:30:25,295 -- Switching to NWP bootloader...
2016-12-01 20:30:25,296 -- Switching UART to APPS...
2016-12-01 20:30:25,298 -- Resetting communications ...
2016-12-01 20:30:28,558 -- timed out while waiting for ack
2016-12-01 20:30:28,813 -- Uploading rbtl3100s.dll...
2016-12-01 20:30:28,814 -- Getting storage list...
2016-12-01 20:30:28,816 -- Getting storage info...
2016-12-01 20:30:28,818 -- storage info bytes: 0x10, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0
2016-12-01 20:30:29,504 -- APPS version: CC3x00VersionInfo((0, 4, 0, 2), (0, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0), (16, 0, 0, 0))
2016-12-01 20:30:29,507 -- File exists on target, erasing
2016-12-01 20:30:29,510 -- Erasing file /sys/mcuimg.bin...
2016-12-01 20:30:29,597 -- Uploading file target/thumbv7em-none-eabi/debug/sensorweb-firmware.bin -> /sys/mcuimg.bin [175896]...
2016-12-01 20:30:39,607 -- timed out while waiting for ack
Traceback (most recent call last):
  File "/usr/local/bin/cc3200tool", line 22, in <module>
    main()
  File "/usr/local/lib/python2.7/dist-packages/cc3200tool/cc.py", line 746, in main
    command.signature, command.file_size)
  File "/usr/local/lib/python2.7/dist-packages/cc3200tool/cc.py", line 621, in write_file
    self._open_file_for_write(cc_filename, alloc_size)
  File "/usr/local/lib/python2.7/dist-packages/cc3200tool/cc.py", line 485, in _open_file_for_write
    return self._open_file(filename, flags)
  File "/usr/local/lib/python2.7/dist-packages/cc3200tool/cc.py", line 493, in _open_file
    self._send_packet(command)
  File "/usr/local/lib/python2.7/dist-packages/cc3200tool/cc.py", line 370, in _send_packet
    "No ack for packet opcode=0x{:02x}".format(ord(data[0])))
cc3200tool.cc.CC3200Error: No ack for packet opcode=0x21

I tried doubling the timeout on line 270 from 5 to 10 with no change. I'm running on Ubuntu 16.04 and trying to flash a cc3200 LAUNCHXL board.

Gang image programming

Gang image programming
cc3200tool -p /dev/ttyUSB0 write_flash gangimage.bin
fails with:
TypeError: _send_packet() takes at least 2 arguments (1 given)

After changing line 424 of cc.py from
self._send_packet()
to
self._send_packet(command)
I get a new error:
cc3200tool.cc.CC3200Error: No ack for packet opcode=0x30

Using the --no-erase option makes write_flash work,
cc3200tool -p /dev/ttyUSB0 write_flash --no-erase true gangimage.bin
however, the written gang image does not boot (presumably because the flash was not initially empty).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.