Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instruction for flashing firmware via Arduino #78

Closed
kirovilya opened this issue May 31, 2018 · 81 comments
Closed

Instruction for flashing firmware via Arduino #78

kirovilya opened this issue May 31, 2018 · 81 comments

Comments

@kirovilya
Copy link
Contributor

kirovilya commented May 31, 2018

I have a positive experience of flashing firmware cc253x through Arduino without CCDebugger. Based on wavesoft/CCLib#19 (comment)

Does it interest anyone? I can add the translation to the wiki, then edit the grammar. Or someone more experienced can make a translation.

@ciotlosm
Copy link
Contributor

I think would be great to have more flashing options. I just posted on the forum a way to flash using cc-tool (just seconds ago!): https://community.home-assistant.io/t/zigbee2mqtt-getting-rid-of-your-proprietary-zigbee-bridges-xiaomi-hue-tradfri/52108/176?u=ciotlosm

This is based on yet another great repo around CC2531 gateway emulation in C++ here: https://github.com/Frans-Willem/AqaraHub. That has a good tutorial on how to flash using cc-tool

@kirovilya
Copy link
Contributor Author

@ciotlosm It's great. cctool has an even better option, because in my case cclib it is necessary to slightly modify the firmware.
I'll try to flash through cctool and maybe delete my version, and leave them :)

@tb-killa
Copy link
Contributor

@kirovilya : Which Type of Arduino do you use ? I´m experiment via Nano V3.0 ATmega328P Micro-Board.
Btw: Here: http://magictale.com/2884/flashing-ble112-with-arduino-based-cc-debugger/ you will find an performance boosting Version but there we need to modifiy to add the CC253X Type.

@kirovilya
Copy link
Contributor Author

@ciotlosm Oh, no! I read that cctool uses ccdebugger :( so that flashing firmware through arduino will remain

@ciotlosm
Copy link
Contributor

@kirovilya sorry for that. I was posting offtopic as I was just happy to see more options for flashing.

@kirovilya
Copy link
Contributor Author

@tb-killa I uses Arduino Uno.
I seen this article, but can not check - need compiling with specific port...

@ciotlosm Don't worry :)

@kirovilya
Copy link
Contributor Author

kirovilya commented Jun 1, 2018

Check out please https://github.com/Koenkk/zigbee2mqtt/wiki/Getting-started#22-via-arduinoesp8266

@tb-killa
Copy link
Contributor

tb-killa commented Jun 1, 2018

@kirovilya you have to mention the needing of 3.3v on side of the usb Stick, because normaly you put an divider inside the connections. Or you use the internal resistor of the atmega themselve. I know it works without it but if some one broken the usb Stick you could say we mention it as an warning ;-)

@kirovilya
Copy link
Contributor Author

@tb-killa I refer to the instruction from CCLib and there it is mentioned about 5v on Arduino and 3.3v on the CC**** chip. Probably, the chip can work with 5v, but I did not check it :)

@definitio
Copy link

@kirovilya it works with esp8266 (wemos d1 mini) with changed pins. Maybe should be added to wiki?

@kirovilya
Copy link
Contributor Author

@definitio Did you test? Connection without resistors? What mean "changed pins"?

@definitio
Copy link

definitio commented Jun 1, 2018

@kirovilya yes, successfully flashed 1-2 weeks ago without resistors. I mean changed pins numbers.

@kirovilya
Copy link
Contributor Author

kirovilya commented Jun 1, 2018

@definitio Good news! Thank you!
Added in wiki.

@Koenkk
Copy link
Owner

Koenkk commented Jun 1, 2018

Thanks for the instructions!

To keep the getting started as noob friendly as possible I've moved this to Alternative firmware flashing methods

@kirovilya
Copy link
Contributor Author

Good. I close the issue

@ciotlosm
Copy link
Contributor

ciotlosm commented Jun 1, 2018

I've updated https://github.com/Koenkk/zigbee2mqtt/wiki/Getting-started with linux/macos instructions as well

@ciotlosm
Copy link
Contributor

ciotlosm commented Jun 2, 2018

@kirovilya in https://github.com/Koenkk/zigbee2mqtt/wiki/Alternative-firmware-flashing-methods you mention modified firmware for flashing via Arduino https://github.com/kirovilya/files/blob/master/CC2531ZNP-Pro-Secure_LinkKeyJoin_mod.hex

Is the above firmware different from the ones @Koenkk prepared? I'm trying to make sense and gather most of the firmwares in a logical place here: https://github.com/Koenkk/zigbee2mqtt-firmware for easier maintenance and linking.

@kirovilya
Copy link
Contributor Author

@ciotlosm that firmware not made from Koen firmware. It make from any firmware by remove second line from end (as described here wavesoft/CCLib#19)

@ciotlosm
Copy link
Contributor

ciotlosm commented Jun 3, 2018

Would you be able to add this firmware to:

https://github.com/Koenkk/zigbee2mqtt-firmware ?

@maur8ino
Copy link

maur8ino commented Aug 8, 2018

hi @definitio could you explain in detail which pins on the wemos d1 mini you connected to downloader cable?
I've tried different combination, but with no luck:

int CC_RST   = D4; // 2
int CC_DC    = D3; // 0
int CC_DD_I  = D2; // 4
int CC_DD_O  = D1; // 5
int CC_RST   = D7; // 13
int CC_DC    = D6; // 12
int CC_DD_I  = D5; // 14
int CC_DD_O  = D0; // 16

they both didn't work.

Thanks!

@definitio
Copy link

@maur8ino just flashed the latest firmware (with removed the second line from the end) with this settings:

int CC_RST   = 5;
int CC_DC    = 4;
int CC_DD_I  = 14;
int CC_DD_O  = 12;

@mmithril
Copy link

mmithril commented Sep 1, 2018

I am flashing according to your guide with Arduino Mega (5V board I suppose).

I was struggling with ./cc_info.py – response was always
ERROR: No chip found. Check your connection and/or wiring!

After I removed voltage divider (4.7 kΩ + 10 kΩ), it started working like a charm!

@ericstewart22
Copy link

ericstewart22 commented Sep 27, 2018

Is it possible to flash via a NodeMCU 1.0 (ESP-12E)? It seems to flash okay but I always get an error when trying to run:

python27.exe cc_info.py -p COM9

ERROR: Could not find CCLib_proxy device on port COM9

The light on the NodeMCU turns on for a bit and then turns off.

@HanschDennis
Copy link

@ericstewart22
Were you successful with the NodeMCU? I got the same error :(

@ericstewart22
Copy link

@HanschDennis No, unfortunately not. I'll let you know if I get it working.

@ericstewart22
Copy link

ericstewart22 commented Oct 2, 2018

I have a Raspberry Pi so I think I will try this fork to flash
https://github.com/kabbi/CCLib-raspberry

@larsdecker
Copy link

I have a Raspberry Pi so I think I will try this fork to flash
https://github.com/kabbi/CCLib-raspberry

Did it work?

@ericstewart22
Copy link

Not yet. Verification fails and it doesn't go past 25% or 50%. The LED on the 2531 is off when I start flashing and turns on (green) a few seconds later, at the same time verification fails; I think it's a clue as to what is happening but I'm not knowledgeable enough to troubleshoot. I attached a screenshot of what it looks like, in case you're having the same issue, or in case someone else on here can help me troubleshoot.

ubuntu_2018-10-09_14-59-35

@larsdecker
Copy link

At the moment, my USB Stick is still in the shipping process. I can try to look into the code, maybe i found something. I have only a little bit of experience of python. @ericstewart22 Can you please open a issue on the CCLib-raspberry project and post there a screenshot of the log? Maybe the maintainer of the project finds a solution for it.

On the main project of the CClib (https://github.com/wavesoft/CCLib) are resistances between the connections? @ericstewart22 Did you have resistances between your connections?

@BotoX
Copy link

BotoX commented Jan 1, 2019

  • Increase the timeout in the Arduino sketch to 1000 ms (the delay() statement)

This is actually the trick.
Increase the timeout to 5000.
Unplug power from the CC2531 dongle but keep it connected to the ESP.
Reset / power on the ESP.
Now within these 5 seconds power up the CC2531.
Done.

If the CC2531 is powered up then the ESP won't boot.
If the CC2531 is not powered up while the ESP inits the debugger it won't work.
So put a 5 second delay there, power up the ESP then power up the CC2531 and both problems are solved.

I had to use Python2 and run the script as root btw.

@janisHD
Copy link

janisHD commented Jan 11, 2019

Hello,

I have as well the CC2531 and try to manage flashing using an Arduino micro (5V). Connection is without resistors in between (seems to be no "killer"). The CC2531 is connected to a 5V USB power supply (Samsung 2,2 A max). The DD is connected like 2 (==D8 -> DO) -- 3 (==D6) -- DD (I tried different order as well, this one was the most stable).

Best results are with following connection order: unplug both, then 1st Arduino and within 5s (changed delay accordingly) the CC2531.

cc_info.py shows promising results:

image

Also cc_read_flash.py worked flawless, I dumped the original flash successfully.

BUUUTTT here comes the catch... cc_write_flash.py is not working with:

sudo python2.7 cc_write_flash.py -p /dev/tty.usbmodem141301 --in=CC2531ZNP_Kirovilya_mod.hex --erase

image

Any suggestions how this can be resolved?

@janisHD
Copy link

janisHD commented Jan 19, 2019

To all with similar problems:
I could resolve the issue with setting the baudrate to 1200 kpbs, any baudrate higher than that leads to a known issue:
arduino/ArduinoCore-avr#53

After making the changes in the .ino and ccproxy.py the flashing works flawlessly and within a few minutes!

Regards

@larsdecker
Copy link

Not that easy, to flash that stick. I now try it with the nodeMCU with no luck. When i try to check the values the nodeMCU seems to be go off (the blue led goes off). The green LED of usb stick is on. Have anyone some tricks how it work with the nodeMCU Amica?

@creativtransfer
Copy link

Have a look at https://hackaday.io/project/163487-zigbee-cc2531-smart-home-usb-adapter
There's a nice tutorial covering a complete install using an ESP8266 / Wemos D1 mini as a programmer.

@druxx
Copy link

druxx commented Jan 28, 2019

I'm close to giving up: after fighting with my CC2531 sticks for weeks, I'm finally able to flash more than 85%, but then I'm getting reproducibly an error:

Flashing:
-- Chip erase...
-- Flashing 4 memory blocks...
-> 0x0000 : 8176 bytes
Progress 100%... OK
-> 0x1ff6 : 10 bytes
Progress 100%... OK
-> 0x3fff0 : 1 bytes
Progress 100%... OK
-> 0x2000 : 239616 bytes
Progress 91%... ERROR: Could not read from the serial port!

I'm using an Arduino nano and I'm getting the same result on a MacBook and an Ubuntu desktop. I've played with the baud rates, but no success with 1200,4800,19200.

Any ideas why the flashing works properly for hours and then suddenly fails just shortly before finishing?

@druxx
Copy link

druxx commented Jan 29, 2019

hooray, I was able to flash my first CC2531.

Had to increase the read timeout from 3secs to 10secs. I've tried this before, but at at different baud rates. The whole thing is really a little bit tricky

@creativtransfer
Copy link

Good to hear you've made it.
Where exactly did you increase the timeout? Please post the relevant lines of code...

And which firmware have you installed now?

CC2531ZNP-Prod.hex
or
CC2531ZNP-Pro-Secure_LinkKeyJoin_mod.hex

@druxx
Copy link

druxx commented Feb 1, 2019

finally I was able to flash my two CC2531 with CC2531ZNP-Pro-Secure_LinkKeyJoin_mod.hex (and they work as expected).
My setup:

  • Ubuntu 18.04 Desktop

  • Arduino Nano V3.0

  • voltage divider 2.2k / 3.9k to be on the safe side, 100k / 200k doesn't work since the CC2531 has pull-up resistors

  • CC2531 USB stick
    Chip ID : 0xb524
    Flash size : 256 Kb
    Page size : 2 Kb
    SRAM size : 8 Kb
    USB : Yes

I had to increase the read timeout on the Python side for the serial transfer to a ridiculous high number of 20secs:
line# 85 in cclib/ccproxy.py:
self.ser = serial.Serial(port, baudrate=9600, timeout=20.0, write_timeout=3.0)

(Symptons with the default timeout of 3secs: the flashing stopped a dozen times after having flashed more than 85% with a read timeout on the serial transfer)

contrary to other reports here I had no success with other baud rates (tested: 1200,4800,19200)

@way2many
Copy link
Contributor

way2many commented Feb 7, 2019

I've followed exactly what @drndos did with a Wemos D1 mini (followed his pin configuration and his cable solution also) and @BotoX recommendation for a delay of 5000ms and was able to flash it just under 2 hours. Wemos was connected on my laptop with Windows 10 and the usb-stick was on a 5V 2 amp USB power supply. If errors on chip detection, check cables. Led lamp on CC2531 has to be off.

Hope this bit of information will help someone as it wasn't easy to follow all the different possible configurations.

I would also like to thanks @drndos for his pictures. It helped tremendously!

@timdonovanuk
Copy link

Hi - none of the links for getting started, alternate flashing methods etc work anymore :(

@creativtransfer
Copy link

Have you checked https://hackaday.io/project/163487-zigbee-cc2531-smart-home-usb-adapter ?
This is kind of a tutorial on how you do it with an ESP8266/nodeMCU/wemos d1 mini but it's basically the same for any other arduino compatible device. You just have to adjust your programming pins accordingly...

@AS137430
Copy link

AS137430 commented Feb 16, 2019

After weeks of trying, finally got the flash working with @vogler 's recommendation to use test hook cables. In earlier failed attempts: I improvised with Bus Pirate probe cable, nodeMCU v3, Arduino Mega...

I used a nodeMCU v2 with the following pinouts:

int CC_RST   = D5;
int CC_DC    = D7;
int CC_DD_I  = D6;
int CC_DD_O  = D8;

The Arduino sketch used these values

// Initialize serial port
  Serial.begin(9600);
  // Wait for chip to initialize
  delay(5000);

and I also incorporated @druxx 's idea to increase timeout in cclib/ccproxy.py:

   self.ser = serial.Serial(port, baudrate=9600, timeout=20.0, write_timeout=3.0)

And I confirmed what others have mentioned, the LED on the CC2531 will stay off while the nodeMCU's LED is on during flashing. I powered CC2531 with a Samsung phone charger.

EDIT:
Connection for DD: D6 -- DD -- D8 and surprisingly the flash time wasn't as long as I expected since others mentioned it took more than 2 hours. Mine took just over an hour and my estimate was 1.3 hours.

@creativtransfer
Copy link

What do you want to use for flashing? Arduino uno, nano, nodemcu, wemos d1 mini?
You have to look in your code, there you'll find something like this:
...
// Pinout configuration (Configured for wemos D1 mini)
int CC_RST = D5;
int CC_DC = D7;
int CC_DD_I = D6;
int CC_DD_O = D4;
...
In this case, it's for a wemos d1 mini, so just hook it up to the corresponding pins named D4, etc.

@timdonovanuk
Copy link

timdonovanuk commented Feb 27, 2019

I figured it out, but the problem with ambiguous instructions...the following diagram looks a lot like the debug cable, except its not, it represents the direct pins on the actual board:

image

If you're using the debugging cable (mine anyway) its actually (with the red cable strip at the bottom and the clip of the cable to your left, denoted by the indent)....:

image

Or to put it another way humans understand:

image

@fluffymadness
Copy link

fluffymadness commented Mar 7, 2019

tried flashing a cc2530 via nodemcu with baud 9600 delay in arduino sketch, and readtimeout:20 write_timeout:3 for serial in ccproxy.py
Sadly i only get the following:

Flashing:

  • Chip erase...
  • Flashing 4 memory blocks...
    -> 0x0000 : 8176 bytes
    Progress 100%... OK
    -> 0x1ff6 : 10 bytes
    Progress 0%... ERROR: Flash verification error on offset 0x1ff6

edit: I tried that a few times now...do I need an external power supply for the chip, because atm i power the cc2530 via the 3.3v pin of the nodemcu

@AS137430
Copy link

AS137430 commented Mar 8, 2019

@fluffymadness : Most of the other attempts seem to use separate power supply. You can try powering from PC/laptop USB and disconnect 3.3V of nodemcu.

Or you might want to try CCLoader #1057
https://github.com/Koenkk/zigbee2mqtt/issues/1057#issuecomment-468920302
https://github.com/Koenkk/zigbee2mqtt.io/blob/dev/information/alternative_flashing_methods.md

@fluffymadness
Copy link

Thx.
I got it running by flashing it via teensy 3.1 and external power supply.
Whats interesting...flashing via teensy only takes about 2minutes not 2 hours like listed.

@sparky3387
Copy link

sparky3387 commented Mar 24, 2019

EDIT: I Take it back this did not work, CCLoader says its working but is actually doing nothing, I may have had a dead chip, will update once replacements arrive

**FINAL NOTE: The chip was dead a replacement CC2531 and Programmer, got me up and running, for those of you in Australia you can use the 40mm Test Clips from Jaycar and they do the trick
IMG_20190404_234120
IMG_20190408_233115

**

Just to let people know who are looking CCLoader works very well with flashing a CC2530 via an ESP8266 (NodeMCU v3), using this fork, instructions and connection diagram

https://github.com/jeanniquini/CCLoader

https://github.com/Koenkk/zigbee2mqtt.io/blob/master/information/alternative_flashing_methods.md

image

image

image

@Tekno-man
Copy link

I know this has been closed but I didn't know where else to ask for help. I followed the instructions from https://hackaday.io/project/163487-zigbee-cc2531-smart-home-usb-adapter and everything seemed to be working but the information I gotten from the CC2531 was different to everyone else's. Is this likely a faulty unit or is there something I'm missing? I am using a nodemcu 8266 board.

C:\CCLib-master\Python>python cc_info.py -E -p com16

INFO: Found a CC2531 chip on com16

Chip information:
Chip ID : 0xb524
Flash size : 16 Kb
Page size : 2 Kb
SRAM size : 1 Kb
USB : No

Device information:
IEEE Address : 000000000000
PC : 0000

Debug status:
[ ] CHIP_ERASE_BUSY
[ ] PCON_IDLE
[X] CPU_HALTED
[ ] PM_ACTIVE
[ ] HALT_STATUS
[X] DEBUG_LOCKED
[X] OSCILLATOR_STABLE
[ ] STACK_OVERFLOW

Debug config:
[ ] SOFT_POWER_MODE
[ ] TIMERS_OFF
[ ] DMA_PAUSE
[ ] TIMER_SUSPEND

@creativtransfer
Copy link

The memory size details look somewhat strange. It should have 256kB of flash. Maybe it's just reporting a wrong value, because the flash is inside the CC2531 chip.

But since it was recognized by cc_info.py I'd just give it a try and flash it...
Can you post a photo of your device?

@Tekno-man
Copy link

I did try this and unfortunately I got the error "data to bit to fit fit in chips memory" which makes it sense as the read out says only 16kb of space!

@Tekno-man
Copy link

I'll have to take a photo tonight. Thanks for responding by the way, appreciate the advice.

@creativtransfer
Copy link

creativtransfer commented Aug 1, 2019 via email

@Tekno-man
Copy link

Hmmm, Im pretty sure on the top of the chip 256 was written also. This is the product I bought https://www.banggood.com/Wireless-Zigbee-CC2531-Sniffer-Bare-Board-Packet-Protocol-Analyzer-Module-USB-Interface-Dongle-p-1227206.html?rmmds=myorder&cur_warehouse=CN

@Tekno-man
Copy link

Here are the images of my set-up
20190802_212234
20190802_212256

@Tekno-man
Copy link

So I tried flashing with ccloader and it seems to have worked

@marcodlima
Copy link

So I tried flashing with ccloader and it seems to have worked

How did you do it?
I´m trying to flash it with cc_write_flash.py but it says: "ERROR: Data too bit to fit in chip's memory!"

With cc_info.py i got this:

Chip information:
Chip ID : 0xb524
Flash size : 16 Kb
Page size : 2 Kb
SRAM size : 1 Kb
USB : No

Device information:
IEEE Address : 000000000000
PC : 0000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests