Skip to content

Instantly share code, notes, and snippets.

@kidpixo
Created February 25, 2019 16:10
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kidpixo/ef1a26ae953e3939a4eebe1b6fd2f07c to your computer and use it in GitHub Desktop.
Save kidpixo/ef1a26ae953e3939a4eebe1b6fd2f07c to your computer and use it in GitHub Desktop.
How I got cc-tool to compile on my macosx (10.12.6)

Use CC-tool for CC253X on my mac

Links

  1. Flashing the firmware on the CC2531 USB stick | zigbee2mqtt.io
  2. dashesy/cc-tool: Mirror of cc-tool from SourceForge
  3. compiling - What is the correct syntax to add CFLAGS and LDFLAGS to "configure"? - Unix & Linux Stack Exchange
  4. Compiling Boost with GCC or Clang on macOS | Solarian Programmer

Compile cc-tool

Following 1 :

brew install autoconf automake libusb boost pkgconfig libtool ##install needed tools to compile the tool :-D
git clone https://github.com/dashesy/cc-tool.git
cd cc-tool\

Then, be sure to use clang++ instead g++ from macport or wathever you have in path. Include boost (c++) library from system (homebrew automagically symlink them under /opt/local/{bin,include}) like:

CC=/opt/local/bin/clang \
CXX=/opt/local/bin/clang++ \
LDFLAGS=-I/usr/local/include \
CPPFLAGS=-I/usr/local/include \
 ./bootstrap

CC=/opt/local/bin/clang \
CXX=/opt/local/bin/clang++ \
LDFLAGS=-I/usr/local/include \
CPPFLAGS=-I/usr/local/include \
 ./configure

make

## now test the executable
./cc-tool --help

Texas Instruments 8051-based System-On-Chip device programmer
 Version: 0.26

 Command line options:
  -h [ --help ]                  produce help message
  --log arg                      create log of all operations
  -d [ --device ] arg            set programmer deivce usb address 'bus:device'
  -f [ --fast ]                  set fast debug interface speed (by default:
                                 slow)
  -n [ --name ] arg              specify target name e.g. CC2530 etc.
  --allow-overlapping-records    allow overlapping records in hex files, the
                                 last one wins (by default: they are
                                 disallowed)
  -i [ --read-info-page ] arg    read info pages
  -a [ --read-mac-address ]      read mac address(es)
  -b [ --write-mac-address ] arg write (secondary) mac address
  -p [ --preserve-mac-address ]  preserve (secondary) mac address across
                                 writing
  -r [ --read ] arg              read flash memory
  -e [ --erase ]                 erase flash memory
  -w [ --write ] arg             write flash memory.
  -v [ --verify ] arg            verify flash after write, method '(r)ead' or
                                 '(c)cr' (used by default)
  --reset                        perform target reset
  -t [ --test ]                  search for programmer and target
  -l [ --lock ] arg              specify lock data in hex numbers or by string:
                                 debug[;pages:xx]
  -s [ --flash-size ] arg        specify target flash size in KB

 Supported targets:
   CC2530 CC2531 CC2533 CC2540 CC2541 CC2543 CC2544 CC2545 CC2510 CC2511 CC1111 CC1110 CC2430 CC2431

 Supported programmers:
  VID: 0x0451 PID: 0x16a2 Description: CC Debugger
  VID: 0x11a0 PID: 0xdb20 Description: SmartRF04 Evaluation Board
  VID: 0x11a0 PID: 0xeb20 Description: SmartRF04 Evaluation Board (Chinese)
  VID: 0x0451 PID: 0x16a0 Description: SmartRF05 Evaluation Board

@tuctboh
Copy link

tuctboh commented Oct 14, 2021

Thanks @antman2. That worked for me too!

@kidpixo
Copy link
Author

kidpixo commented Oct 15, 2021

I switched to Linux 100% , so I cannot update this anymore.
I bet this will not work on Apple M1 silicon for now.

Good luck!

@macfr76
Copy link

macfr76 commented Nov 10, 2021

Hi guys, I try to build on an Intel MacBook air with Macport installed.

When using this tweak, I get one more error :
configure: error: in `/Users/gr/Documents/TexasInstrument/cc-tool':
configure: error: C compiler cannot create executables

Any idea ?

@imakahn
Copy link

imakahn commented Nov 19, 2021

@macfr76

For macports:

sudo port install boost +universal
sudo port install autoconf automake libusb pkgconfig libtool
sudo port install clang-13

CC=/opt/local/bin/clang-mp-13 \
CXX=/opt/local/bin/clang++-mp-13 \
LDFLAGS=-I/opt/local/include \
CPPFLAGS=-I/opt/local/include \
./bootstrap

CC=/opt/local/bin/clang-mp-13 \
CXX=/opt/local/bin/clang++-mp-13 \
LDFLAGS=-I/opt/local/include \
CPPFLAGS=-I/opt/local/include \
./configure

make

Result:

  CXX      src/main.o
  CXX      src/application/cc_flasher.o
  CXX      src/application/cc_base.o
  CXX      src/common/log.o
  CXX      src/common/common.o
  CXX      src/common/timer.o
  CXX      src/usb/usb_device.o
  CXX      src/data/binary_file.o
  CXX      src/data/data_section.o
  CXX      src/data/data_section_store.o
  CXX      src/data/file.o
  CXX      src/data/hex_file.o
  CXX      src/data/read_target.o
  CXX      src/data/progress_watcher.o
  CXX      src/programmer/cc_253x_254x.o
  CXX      src/programmer/cc_251x_111x.o
  CXX      src/programmer/cc_243x.o
  CXX      src/programmer/cc_programmer.o
  CXX      src/programmer/cc_unit_driver.o
  CXX      src/programmer/cc_unit_info.o
  CXXLD    cc-tool
./cc-tool --help
Texas Instruments 8051-based System-On-Chip device programmer
 Version: 0.26

@Jpsy
Copy link

Jpsy commented Nov 20, 2021

The solution of @antman2 worked for me on macOS Big Sur 11.6 with Homebrew.
Also see https://stackoverflow.com/a/69141888/430742

@macfr76
Copy link

macfr76 commented Nov 21, 2021

Thanks a lot @imakahn for the macport setup, it works perfectly !

@psychowood
Copy link

psychowood commented Dec 25, 2021

Was anyone able to program with a usb-c only Mac? When I plug the CC debugger the led goes red, and as soon as I connect the CC2531 to the Mac the LED turns off.

EDIT: It looks like cable direction matters :) The downloader cable waas plugged reversed into the cc2531.

@kidpixo
Copy link
Author

kidpixo commented Dec 30, 2021

@psychowood not using mac anymore, but my biggest trouble was the GND.
It worked only using same ground for everything : debugger, 3v3/5v power , usb hub (=extra protection to avoid the magic smoke in my laptop).

@eizemazal
Copy link

Thanks @antman2, your solution also worked on my M1 Mac with Big Sur, only needed to change CXXFLAGS env var to add arch:
CXXFLAGS="-std=c++0x -arch x86_64"

(boost installed via homebrew)

@saschaludwig
Copy link

Thanks @antman2 - your solution worked here on macOS Monterey 12.2.1 with i7 CPU

@poenneby
Copy link

poenneby commented Nov 6, 2022

Thanks for posting this, it gave me a great head start. On a Homebrew-only system running macOS Catalina 10.15.7 I needed to modify a few things, though:

  • clang and clang++ paths were different
  • pkg_config couldn't find libusb-1.0.0 so I had to add LIBUSB_CFLAGS and LIBUSB_LIBS variables
  • when linking Boost it was complaining Undefined symbols for architecture x86_64

Here is what worked for me...

CC=/usr/bin/clang \
CXX=/usr/bin/clang++ \
CPPFLAGS=-I/usr/local/include \
LDFLAGS=-I/usr/local/include \
 ./bootstrap

CC=/usr/bin/clang \
CXX=/usr/bin/clang++ \
CPPFLAGS=-I/usr/local/include \
CXXFLAGS="-std=c++0x" \
LDFLAGS="-I/usr/local/include -lboost_system" \
LIBUSB_CFLAGS=-I/usr/local/include/libusb-1.0 \
LIBUSB_LIBS="-L/usr/local/lib -lusb-1.0" \
 ./configure

make clean ; make

Thanks @antman2, works on Intel Mac with Monterey 🙏

@heartinstaller
Copy link

heartinstaller commented Mar 12, 2023

Thank you @eizemazal @kidpixo

why this doesn't work

cc-tool-master % which boost
boost not found
cc-tool-master % which cc-tool
cc-tool not found

@eizemazal
Copy link

eizemazal commented Mar 13, 2023

why this doesn't work
cc-tool-master % which boost boost not found

because boost is a set of C++ libraries, there is no 'boost' binary in this package AFAIK. which is a tool to show path to binary that will be executed on given command, but there is no binary named boost

cc-tool-master % which cc-tool cc-tool not found

you have to put cc-tool in your path by adding directory with it to your PATH environment variable, or you can just create a symlink to it in a directory that is present in PATH:

sudo ln -s /path/to/your/cc-tool /usr/local/bin/cc-tool

@heartinstaller
Copy link

Thank you @eizemazal,
my CC2541 board is not getting recognized by ccdebugger(status led = RED) after i compiled using this following command and flashed(code was simple led blink). What do you think? i'm guessing i have accidentally erased the bootloader routine due to incorrect command. Please comment.
MacBook-Air Application code % sdcc -mmcs51 --code-loc 0x0000 --data-loc 0x0000 --iram-size 256 -I /usr/local/share/sdcc/include -I . -o ledblink.hex main.c

@eizemazal
Copy link

@gaurav3015 sorry I do not know. In fact I have no experience with CC2541 except for compiling tool for it, so you may better ask someone else about it)

@heartinstaller
Copy link

Thanks @eizemazal

@vkrzt
Copy link

vkrzt commented Dec 28, 2023

Hi guys, trying now on Sonoma 14.0 and getting that error, any suggestions? Thanks

checking for the toolset name used by Boost for /usr/bin/clang++... xgcc42 -xgcc
checking for boost/program_options.hpp... yes
checking for the Boost program_options library... no
configure: error: cannot find the flags to link with Boost program_options

@mdczaplicki
Copy link

mdczaplicki commented Jan 23, 2024

I'm on Sonoma 14.3 and get this error:

error: cannot find Boost headers version >= 1.74.0

I have to run bootstrap & configure with sudo to get here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment