efm8-arduino-programmer icon indicating copy to clipboard operation
efm8-arduino-programmer copied to clipboard

Update for Nano and Uno

Open ciotlosm opened this issue 7 years ago • 29 comments

It seems there is fork that simplifies a bit the firmware Upload: https://github.com/christophe94700/efm8-arduino-programmer

@christophe94700 Could you please try and merge upstream? @conorpp If possible, could you switch to using flash instead of server/client? It seem based on a few other forks that PORTD is compatible with Uno and Nano. Does mega support PORTD?

ciotlosm avatar Feb 09 '18 06:02 ciotlosm

Hi, it's very difficult for me to speak english because i am French. For my question, it's possible to write a long text for my comprehension. Thank :)

christophe94700 avatar Feb 09 '18 13:02 christophe94700

@christophe94700 Hey, pas de problème! J'ai vu que vous avez fait de bonnes améliorations au code. Ma demande était que vous faites un PR (Pull Request) au dépôt de code original de @conorpp . De cette façon, d'autres personnes bénéficient de votre amélioration.

I hope I got that right in French. I understand a little as I learned in school (I'm from Romania).

ciotlosm avatar Feb 09 '18 14:02 ciotlosm

Je ne suis pas un spécialiste de GIT, on fait comment un PR? It's not easy !

christophe94700 avatar Feb 09 '18 17:02 christophe94700

The python class PI() implements the programming interface to the arduino.

@christophe94700 implemented a direct programming way by writing the following code:

port=sys.argv[1]
firmware=open(sys.argv[2], 'r').read()
programmers = PI(port)

programmers.prog(firmware)

To update prog_client.py to support direct programming should be straight forward. I agree that a "direct" method is better for most people rather than server/client. I would like to keep an option to connect to a server though. I appreciate any PRs.

Your comment on PORTD. This is just the "raw" mapping of the GPIOs (rather than the arduino pin 0, 1, etc.) and are used so that programming happens quicker. The downside is that the PORT/PIN to arduino pin mapping is different for each microcontroller and you have to look them up. To use the code on other devices, you just have to change PORT/PIN correctly.

Here is the mapping for arduino mega 2560 chip. To use arduino mega pin 2, use PE4 (PORTE, pin 4). Any of the arduino digital pins should work. Here are the mappings for Uno and Nano.

Hope that makes sense.

conorpp avatar Feb 10 '18 19:02 conorpp

@conorpp makes sense. I think the approach that would benefit all would be:

  1. Extract configuration of PORT/PIN outside of https://github.com/conorpp/efm8-arduino-programmer/blob/master/prog/prog.ino and allow different configs based on platform
  2. Extract flashing logic in a separate file and allow both a client and a direct firmware uploader (bypassing server).

ciotlosm avatar Feb 14 '18 09:02 ciotlosm

@christophe94700 Thank you for your fork. I tried it on a UNO. I get only this image Can you give me tipp or do you have an idea whats wrong?

Jason2866 avatar Jun 01 '18 13:06 Jason2866

Hello Jason, Have you programmed your Arduino with the classic IDE?

christophe94700 avatar Jun 02 '18 12:06 christophe94700

Hello @christophe94700 yes i used for programming the Arduino classic IDE V.1.8.5 Just used Python from Atom.io for flash.py

Jason2866 avatar Jun 02 '18 13:06 Jason2866

it's run for me. No problem

image

christophe94700 avatar Jun 02 '18 14:06 christophe94700

I use a Arduino Pro mini 3.3 Volt (Atmega 328) "for Arduino Uno and maps C2D and C2CK to digital pins 5 and 6, respectively." I use D5 and D6 Correct or missed i something? Directly connected a USB - serial Adapter (CH340)

Jason2866 avatar Jun 02 '18 15:06 Jason2866

Does still not work for me. Got it finally programmed with a forked Tasmota build. https://github.com/ErikAndren/Sonoff-Tasmota/tree/add-rf-flash-5.14

Thx for your help!

Jason2866 avatar Jun 02 '18 21:06 Jason2866

Dear all,

I using NANO and python 2.7, Winxp, seems suck, please help.

C:\Documents and Settings\Dev\Desktop\efm8-arduino-programmer-master>python flash27.py COM6 RF_Bridge.hex Once Connected x: 0x81 PI initiated Device erased 0x0 0x0 0210D6ED24F8FEEFD39E4015ED2408FDE433FCC3EF9DEC6480F874809850028001C32202 0FB7E4F5A922220213C87EFFEFD394004022EF9480501DE4FDED75F00EA42426F582E43419F583E4 93B50704AE0580040DBD06E5AF06220211ED1218C153D87853DBFE121882E4900085F022D2DE2202 141BD201121692C290C296D280E4FBFD7F1012186912064374A4F0D2AFE4F52FF530D2960530E530 7002052FB410F3E52FB427EEC2963001091215A98E328F338006753201753300E5337004E5326401 70409000CCE07007F52FF5300202870530E5307002052FD39410E52F94274002D296D3E5309430E5 2F947550 x: 0x43 x: 0x43 x: 0x43 x: 0x43 x: 0x43 x: 0x43 x: 0x43 x: 0x43 x: 0x43 x: 0x43 x: 0x43 x: 0x43 x: 0x43 x: 0x43 x: 0x43 Traceback (most recent call last): File "flash27.py", line 109, in programmers.prog(firmware) File "flash27.py", line 80, in prog self.conf() File "flash27.py", line 23, in conf while self.ser.read(1) != '': pass File "C:\Program Files\Python\lib\site-packages\serial\serialwin32.py", line 2 71, in read err = win32.GetOverlappedResult(self.hComPort, ctypes.byref(self._overlapped Read), ctypes.byref(rc), True) KeyboardInterrupt

clementchik0308 avatar Jun 17 '18 09:06 clementchik0308

Hello @clementchik0308 no need anymore to use extra hardware to program the efm. Programmer is now included in Tasmota https://github.com/arendst/Sonoff-Tasmota and https://github.com/arendst/Sonoff-Tasmota/pull/2886

Jason2866 avatar Jun 17 '18 09:06 Jason2866

@Jason2866

Great, will try. Thanks!

clementchik0308 avatar Jun 17 '18 09:06 clementchik0308

Which version of rf bridge do you have? With R1 you just have to connect the wires as described in the Rf Bridge and upload the Efm firmware over the webconsole -> menu firmware upgrade (file). As simple as it sounds 😃 For R2 you have to swap the wires and power the bridge over the pinheader with 3.3 Volt.

Jason2866 avatar Jun 17 '18 18:06 Jason2866

@Jason2866

I got error "Magic byte is not 0xE9" when upgrade.

clementchik0308 avatar Jun 17 '18 18:06 clementchik0308

Program Version 5.14.0 Build Date & Time 2018-05-15T15:29:54 Core/SDK Version 2_3_0/1.5.3(aec24ac9)

clementchik0308 avatar Jun 17 '18 19:06 clementchik0308

Did you use the version included with Tasmota?

Jason2866 avatar Jun 17 '18 19:06 Jason2866

Yes, i did but same.

clementchik0308 avatar Jun 17 '18 19:06 clementchik0308

You have to build Tasmota by your own! Branch development!!! No prebuilt version. You have to look in user_config.h for #define USE_RF_FLASH // Add support for flashing the EFM8BB1 chip on the Sonoff RF Bridge. C2CK must be connected to GPIO4, C2D to GPIO5 on the PCB that this is active

Jason2866 avatar Jun 17 '18 19:06 Jason2866

After re-build the tasmota have below complie error.

C:\Documents and Settings\DEv\Desktop\Sonoff-Tasmota-5.14.0\sonoff\xdrv_06_snfbridge.ino:49:17: fatal error: ihx.h: No such file or directory

#include "ihx.h"

             ^

compilation terminated.

exit status 1 Error compiling for board Generic ESP8266 Module.

clementchik0308 avatar Jun 17 '18 19:06 clementchik0308

Which ide do you use? I cant help with Arduino. I use Visual Studio Code with Platformio. Setup here is just copy downloaded and extracted Tasmota in a folder open that folder in Visual Studio Code and Hit compile Icon. Nothing else for a unmodified working version

Jason2866 avatar Jun 17 '18 19:06 Jason2866

Found lib location issue, fixed.

Thanks Jason2866

clementchik0308 avatar Jun 17 '18 19:06 clementchik0308

@Jason2866

Even using 6.0.0a, still "Magic byte is not 0xE9" error.

Program Version 6.0.0a Build Date & Time 2018-06-18T03:42:31 Core/SDK Version 2_4_1/2.2.1(cfd48f3)

clementchik0308 avatar Jun 17 '18 19:06 clementchik0308

Hmm, dont know why. This is the error when the efm part is not in the compiled version. Do you have the correct user_config.h? Not a old one that is used?

Jason2866 avatar Jun 17 '18 20:06 Jason2866

A other hint dont use SDK 2.4.1 it is buggy many issues.... With 2.3.0 for most users it works perfect

Jason2866 avatar Jun 17 '18 20:06 Jason2866

Problem solved, related to file formatting.

clementchik0308 avatar Jun 17 '18 20:06 clementchik0308

@Jason2866 Found wifi led always off. Any chance to control the wifi led on when wifi connected in tasmota?

clementchik0308 avatar Jun 18 '18 07:06 clementchik0308

@clementchik0308 Regarding: fatal error: ihx.h: No such file or directory

Found lib location issue, fixed.

Can you tell us how you fixed this?

mrohner avatar Oct 31 '19 08:10 mrohner