Skip to content

Instantly share code, notes, and snippets.

@douglasresende
Forked from probonopd/platformio.txt
Created September 6, 2016 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save douglasresende/a19b3013fb7784873cd0dc5d1f32f433 to your computer and use it in GitHub Desktop.
Save douglasresende/a19b3013fb7784873cd0dc5d1f32f433 to your computer and use it in GitHub Desktop.
Using PlatformIO
sudo apt-get -y install python-pip git
sudo pip install -U platformio
platformio -f init --ide clion --board esp12e
sudo chmod 777 /dev/tty*
platformio serialports list
cp ~/.platformio/packages/framework-arduinoespressif/libraries/ArduinoOTA/examples/BasicOTA/BasicOTA.ino src/
# Set upload speed from 115200 to 921600
echo "upload_speed=921600" >> platformio.ini
# Compile and upload the sketch:
sudo chmod 777 /dev/ttyUSB*
platformio run --target upload
# If you want the latest esp8266/Arduino version from git:
git clone https://github.com/esp8266/Arduino.git ~/.platformio/packages/framework-arduinoespressif/
echo "2.0.0" > .platformio/packages/framework-arduinoespressif/version.txt
rm -rf ~/.platformio/packages/ldscripts/
git clone https://github.com/platformio/platformio-pkg-ldscripts.git --branch esp8266_stage --single-branch ~/.platformio/packages/ldscripts/
# If you want to make it advertise all services on mDNS (NO LONGER NEEDED IN ESP GIT SINCE MERGED TO ESP GIT)
cd .platformio/packages/framework-arduinoespressif/
wget https://patch-diff.githubusercontent.com/raw/esp8266/Arduino/pull/1451.diff
patch -p1 < 1451.diff
cd -
platformio run --target clean
platformio run --target upload
# Look for suitable devices to upload to
avahi-browse -t -r "_arduino._tcp"
# Alternatively, just get the IP address of a known hostname
avahi-resolve -h -n esp8266-f1cc73.local
# If there is only one device in the network you can just do:
IP=$(avahi-browse -t -v -r "_arduino._tcp" 2>/dev/null | grep address | head -n 1 | cut -d "[" -f 2 | cut -d "]" -f 1)
echo $IP
echo "upload_port=$IP" >> platformio.ini
# When I upload now, then it is using OTA!
# Now can import the whole thing into an IDE for editing (supposedly with code completion)
# Install clang (needed for code completion)
# Install Atom and 2 plugins:
# autocomplete-clang
# platformio
# Strangely, syntax highlighting and autocompletion works only for .cpp and not .ino files :-(
# Renaming the ino sketch to cpp does work though it is not clean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment