Post topics, source code that relate to the Arduino Platform

User avatar
By M0ebius
#2009 Good ideas!
I would prefer the one with the modified bootloader, cause it does not depend on a working sketch on the Arduino. So it 's more failsafe (for me, this is important, cause some of my modules will be integrated)

Why you need the transistor in the 2nd solution? I think you can directly jump to the bootloader from the main program.

And if i remember correctly, the esp firmware also listens to magic bytes in the transparent mode (+++) - so this could lead to a nice debugging session...
User avatar
By sistemasorp
#2018 Well, here is a video I have recorded with the proof of concept: http://youtu.be/22URkgl6G1U and it works!!!

I have tested it with an ATMEGA168 in a protoboard, doing reset by hand when programming. You can see how the program is loaded using avrdude. The module has been previously connected to python script by hand.

Next step is to configure the sketch to connect the module to python script and do the reset with the transistor.

M0ebius wrote:Good ideas!
I would prefer the one with the modified bootloader, cause it does not depend on a working sketch on the Arduino. So it 's more failsafe (for me, this is important, cause some of my modules will be integrated)



Both solutions will work, but I prefer to leave the Arduino bootloader intact.

M0ebius wrote:Why you need the transistor in the 2nd solution? I think you can directly jump to the bootloader from the main program.


Reading the source code of optiboot and original bootloader, I watched they ask to MCUSR register what was the reset cause, and if one of them is equal to WDRF, then they jump directly to the begining of application.

When I will finish this, I will try to implement STK500 protocol in python script to avoid the use of avrdude.
User avatar
By villTech
#2140 here's what i have to support wifi (tcp) uploading from arduino ide:

1. Added new board type named "Arduino ESP8266" to boards.txt file
2. Modified Arduino source file AvrdudeUploader.java lines
from:
commandDownloader.add("-c" + protocol);
commandDownloader.add("-P" + (Base.isWindows() ? "\\\\.\\" : "")+ uploadPort);
commandDownloader.add("-b" + Integer.parseInt(boardPreferences.get("upload.speed")));

to:
commandDownloader.add("-c" + protocol);
if("Arduino ESP8266".equals(boardPreferences.get("name"))){
commandDownloader.add("-Pnet:192.168.1.99:80");
}else{
commandDownloader.add("-P" + (Base.isWindows() ? "\\\\.\\" : "") + uploadPort);
commandDownloader.add("-b" + Integer.parseInt(boardPreferences.get("upload.speed")));
}

3. Compiled Arduino IDE source file: https://code.google.com/p/arduino/wiki/BuildingArduino

Now, when i click "Upload" on my ide and "Arduino ESP8266" board is selected, IDE will issue avrdude:
avrdude.conf -v -patmega328p -carduino -Pnet:192.168.1.99:80 -D -Uflash:w:/var/folders/kn/dcd57_2d14l_45701j75qjl40000gn/T/build8407200708082014503.tmp/SerialEvent.cpp.hex:i

using 192.168.1.99:80 TCP port to upload sketch.

Also added on my arduino sketch:
asm volatile("jmp 0x3E00")

on serial receive "0 ", to auto reset the arduino (mega328p) when uplaoding sketch.

Image

Image

console from arduino ide:
Binary sketch size: 3,648 bytes (of a 30,720 byte maximum)
/Users/evillanueva/Arduino/build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C/Users/evillanueva/Arduino/build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -Pnet:192.168.1.99:80 -D -Uflash:w:/var/folders/kn/dcd57_2d14l_45701j75qjl40000gn/T/build8407200708082014503.tmp/SerialEvent.cpp.hex:i

avrdude: Version 5.11, compiled on Sep 2 2011 at 18:52:52
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is "/Users/evillanueva/Arduino/build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf"
User configuration file is "/Users/evillanueva/.avrduderc"
User configuration file does not exist or is not a regular file, skipping

Using Port : net:192.168.1.99:80
Using Programmer : arduino
ioctl("TIOCMGET"): Operation not supported on socket
ioctl("TIOCMGET"): Operation not supported on socket
AVR Part : ATMEGA328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :

Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00

Programmer Type : Arduino
Description : Arduino
Hardware Version: 2
Firmware Version: 1.16
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.50s

avrdude: Device signature = 0x1e950f
avrdude: reading input file "/var/folders/kn/dcd57_2d14l_45701j75qjl40000gn/T/build8407200708082014503.tmp/SerialEvent.cpp.hex"
avrdude: writing flash (3648 bytes):

Writing | ################################################## | 100% 29.00s

avrdude: 3648 bytes of flash written
avrdude: verifying flash memory against /var/folders/kn/dcd57_2d14l_45701j75qjl40000gn/T/build8407200708082014503.tmp/SerialEvent.cpp.hex:
avrdude: load data flash data from input file /var/folders/kn/dcd57_2d14l_45701j75qjl40000gn/T/build8407200708082014503.tmp/SerialEvent.cpp.hex:
avrdude: input file /var/folders/kn/dcd57_2d14l_45701j75qjl40000gn/T/build8407200708082014503.tmp/SerialEvent.cpp.hex contains 3648 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 30.01s

avrdude: verifying ...
avrdude: 3648 bytes of flash verified
ioctl("TIOCMGET"): Operation not supported on socket

avrdude done. Thank you.
User avatar
By bjpirt
#2145 That's a fantastic approach - nice work @villTech and thanks for introducing me to the net: avrdude configuration - I'd been looking for something to do this for a long time and even ended up writing my own TCP based programmer in Node (https://github.com/bjpirt/mirobot-js/bl ... tk500v1.js). This looks a lot simpler :-)

I just wish it was easier to extend the Arduino IDE than having to recompile it. If you build a product around Arduino but you do anything different from how they normally do things, then you're a bit stuck.