Skip to content
This repository was archived by the owner on Mar 5, 2026. It is now read-only.

Commit 29595a7

Browse files
authored
Fix Travis builds and add build for ESP8266 (me-no-dev#586)
* Fix Travis builds and add build for ESP8266
1 parent b0c6144 commit 29595a7

5 files changed

Lines changed: 266 additions & 27 deletions

File tree

.travis.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
sudo: false
22

33
language: python
4-
python:
5-
- "2.7"
64

75
os:
86
- linux
97

10-
dist:
11-
- xenial
8+
git:
9+
depth: false
1210

13-
script:
14-
- bash $TRAVIS_BUILD_DIR/travis/build.sh
11+
stages:
12+
- build
13+
14+
jobs:
15+
include:
16+
17+
- name: "Build Arduino ESP32"
18+
if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
19+
stage: build
20+
script: bash $TRAVIS_BUILD_DIR/travis/build.sh esp32
21+
22+
- name: "Build Arduino ESP8266"
23+
if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
24+
stage: build
25+
script: bash $TRAVIS_BUILD_DIR/travis/build.sh esp8266
1526

1627
notifications:
1728
email:

examples/CaptivePortal/CaptivePortal.ino

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
#include <DNSServer.h>
2+
#ifdef ESP32
13
#include <WiFi.h>
24
#include <AsyncTCP.h>
3-
#include <DNSServer.h>
5+
#elif defined(ESP8266)
6+
#include <ESP8266WiFi.h>
7+
#include <ESPAsyncTCP.h>
8+
#endif
49
#include "ESPAsyncWebServer.h"
510

611
DNSServer dnsServer;

examples/ESP_AsyncFSBrowser/ESP_AsyncFSBrowser.ino

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
#include <WiFi.h>
2-
#include <ESPmDNS.h>
31
#include <ArduinoOTA.h>
2+
#ifdef ESP32
43
#include <FS.h>
54
#include <SPIFFS.h>
5+
#include <ESPmDNS.h>
6+
#include <WiFi.h>
67
#include <AsyncTCP.h>
8+
#elif defined(ESP8266)
9+
#include <ESP8266WiFi.h>
10+
#include <ESPAsyncTCP.h>
11+
#include <ESP8266mDNS.h>
12+
#endif
713
#include <ESPAsyncWebServer.h>
814
#include <SPIFFSEditor.h>
915

@@ -134,8 +140,12 @@ void setup(){
134140
});
135141
server.addHandler(&events);
136142

143+
#ifdef ESP32
137144
server.addHandler(new SPIFFSEditor(SPIFFS, http_username,http_password));
138-
145+
#elif defined(ESP8266)
146+
server.addHandler(new SPIFFSEditor(http_username,http_password));
147+
#endif
148+
139149
server.on("/heap", HTTP_GET, [](AsyncWebServerRequest *request){
140150
request->send(200, "text/plain", String(ESP.getFreeHeap()));
141151
});

examples/simple_server/simple_server.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@
66
//
77

88
#include <Arduino.h>
9+
#ifdef ESP32
910
#include <WiFi.h>
1011
#include <AsyncTCP.h>
12+
#elif defined(ESP8266)
13+
#include <ESP8266WiFi.h>
14+
#include <ESPAsyncTCP.h>
15+
#endif
1116
#include <ESPAsyncWebServer.h>
1217

1318
AsyncWebServer server(80);

travis/build.sh

Lines changed: 225 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,237 @@
11
#!/bin/bash
22

3-
echo -e "travis_fold:start:sketch_test_env_prepare"
4-
pip install pyserial
3+
PLATFORM=$1
4+
CHUNK_INDEX=$2
5+
CHUNKS_CNT=$3
6+
if [ "$#" -lt 3 ]; then
7+
echo "Building all sketches"
8+
CHUNK_INDEX=0
9+
CHUNKS_CNT=1
10+
fi
11+
if [ "$CHUNKS_CNT" -le 0 ]; then
12+
echo "Chunks count must be positive number"
13+
exit 1
14+
fi
15+
if [ "$CHUNK_INDEX" -ge "$CHUNKS_CNT" ]; then
16+
echo "Chunk index must be less than chunks count"
17+
exit 1
18+
fi
19+
20+
if [ $PLATFORM == "esp32" ]; then
21+
echo "BUILDING ESP32 EXAMPLES"
22+
elif [ $PLATFORM == "esp8266" ]; then
23+
echo "BUILDING ESP8266 EXAMPLES"
24+
else
25+
echo "UNKNOWN PLATFORM $PLATFORM"
26+
exit 1
27+
fi
28+
29+
echo -e "travis_fold:start:prep_arduino_ide"
30+
# Install Arduino IDE
531
wget -O arduino.tar.xz https://www.arduino.cc/download.php?f=/arduino-nightly-linux64.tar.xz
632
tar xf arduino.tar.xz
733
mv arduino-nightly $HOME/arduino_ide
834
mkdir -p $HOME/Arduino/libraries
35+
mkdir -p $HOME/Arduino/hardware
36+
echo -e "travis_fold:end:prep_arduino_ide"
37+
38+
echo -e "travis_fold:start:sketch_test_env_prepare"
939
cd $HOME/Arduino/libraries
1040
cp -rf $TRAVIS_BUILD_DIR ESPAsyncWebServer
1141
git clone https://github.com/bblanchon/ArduinoJson
12-
git clone https://github.com/me-no-dev/AsyncTCP
13-
cd $HOME/arduino_ide/hardware
14-
mkdir espressif
15-
cd espressif
16-
git clone https://github.com/espressif/arduino-esp32.git esp32
17-
cd esp32
18-
git submodule update --init --recursive
19-
cd tools
20-
python get.py
21-
cd $TRAVIS_BUILD_DIR
22-
export PATH="$HOME/arduino_ide:$HOME/arduino_ide/hardware/espressif/esp32/tools/xtensa-esp32-elf/bin:$PATH"
23-
source travis/common.sh
42+
#wget https://github.com/bblanchon/ArduinoJson/releases/download/v6.11.0/ArduinoJson-v6.11.0.zip && unzip ArduinoJson-v6.11.0.zip
43+
PLATFORM_EXAMPLES=$TRAVIS_BUILD_DIR/examples
44+
45+
if [ $PLATFORM == "esp32" ]; then
46+
# ESP32
47+
cd $HOME/Arduino/libraries
48+
git clone https://github.com/me-no-dev/AsyncTCP
49+
cd $HOME/Arduino/hardware
50+
pip install pyserial
51+
mkdir espressif
52+
cd espressif
53+
git clone https://github.com/espressif/arduino-esp32.git esp32
54+
cd esp32
55+
git submodule update --init --recursive
56+
cd tools
57+
python get.py
58+
PLATFORM_FQBN="espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none"
59+
PLATFORM_SIZE_BIN=$HOME/Arduino/hardware/espressif/esp32/tools/xtensa-esp32-elf/bin/xtensa-esp32-elf-size
60+
elif [ $PLATFORM == "esp8266" ]; then
61+
# ESP8266
62+
cd $HOME/Arduino/libraries
63+
git clone https://github.com/me-no-dev/ESPAsyncTCP
64+
cd $HOME/Arduino/hardware
65+
mkdir esp8266com
66+
cd esp8266com
67+
git clone https://github.com/esp8266/Arduino.git esp8266
68+
cd esp8266
69+
git submodule update --init --recursive
70+
cd tools
71+
python get.py
72+
PLATFORM_FQBN="esp8266com:esp8266:generic:xtal=80,FlashFreq=40,FlashMode=qio,baud=921600,eesz=4M1M,ip=lm2f,ResetMethod=nodemcu"
73+
PLATFORM_SIZE_BIN=$HOME/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/bin/xtensa-lx106-elf-size
74+
fi
2475
echo -e "travis_fold:end:sketch_test_env_prepare"
2576

26-
echo -e "travis_fold:start:sketch_test"
27-
build_sketches $HOME/arduino_ide $HOME/Arduino/libraries/ESPAsyncWebServer/examples "-l $HOME/Arduino/libraries"
77+
cd $TRAVIS_BUILD_DIR
78+
79+
ARDUINO_IDE_PATH=$HOME/arduino_ide
80+
ARDUINO_USR_PATH=$HOME/Arduino
81+
ARDUINO_BUILD_DIR=$HOME/build.tmp
82+
ARDUINO_CACHE_DIR=$HOME/cache.tmp
83+
ARDUINO_BUILD_CMD="$ARDUINO_IDE_PATH/arduino-builder -compile -logger=human -core-api-version=10810 -hardware \"$ARDUINO_IDE_PATH/hardware\" -hardware \"$ARDUINO_USR_PATH/hardware\" -tools \"$ARDUINO_IDE_PATH/tools-builder\" -built-in-libraries \"$ARDUINO_IDE_PATH/libraries\" -libraries \"$ARDUINO_USR_PATH/libraries\" -fqbn=$PLATFORM_FQBN -warnings=\"all\" -build-cache \"$ARDUINO_CACHE_DIR\" -build-path \"$ARDUINO_BUILD_DIR\" -verbose"
84+
85+
function print_size_info()
86+
{
87+
elf_file=$1
88+
89+
if [ -z "$elf_file" ]; then
90+
if [ $PLATFORM == "esp32" ]; then
91+
printf "sketch iram0.text flash.text flash.rodata dram0.data dram0.bss dram flash\n"
92+
elif [ $PLATFORM == "esp8266" ]; then
93+
printf "sketch data rodata bss text irom0.text dram flash\n"
94+
fi
95+
return 0
96+
fi
97+
98+
elf_name=$(basename $elf_file)
99+
sketch_name="${elf_name%.*}"
100+
declare -A segments
101+
while read -a tokens; do
102+
seg=${tokens[0]}
103+
seg=${seg//./}
104+
size=${tokens[1]}
105+
addr=${tokens[2]}
106+
if [ "$addr" -eq "$addr" -a "$addr" -ne "0" ] 2>/dev/null; then
107+
segments[$seg]=$size
108+
fi
109+
done < <($PLATFORM_SIZE_BIN --format=sysv $elf_file)
110+
111+
if [ $PLATFORM == "esp32" ]; then
112+
total_ram=$((${segments[dram0data]} + ${segments[dram0bss]}))
113+
total_flash=$((${segments[iram0text]} + ${segments[flashtext]} + ${segments[dram0data]} + ${segments[flashrodata]}))
114+
printf "%-32s %-8d %-8d %-8d %-8d %-8d %-8d %-8d\n" $sketch_name ${segments[iram0text]} ${segments[flashtext]} ${segments[flashrodata]} ${segments[dram0data]} ${segments[dram0bss]} $total_ram $total_flash
115+
elif [ $PLATFORM == "esp8266" ]; then
116+
total_ram=$((${segments[data]} + ${segments[rodata]} + ${segments[bss]}))
117+
total_flash=$((${segments[data]} + ${segments[rodata]} + ${segments[text]} + ${segments[irom0text]}))
118+
printf "%-28s %-8d %-8d %-8d %-8d %-8d %-8d %-8d\n" $sketch_name ${segments[data]} ${segments[rodata]} ${segments[bss]} ${segments[text]} ${segments[irom0text]} $total_ram $total_flash
119+
fi
120+
return 0
121+
}
122+
123+
function build_sketch()
124+
{
125+
local sketch=$1
126+
echo -e "\n------------ Building $sketch ------------\n";
127+
rm -rf $ARDUINO_BUILD_DIR/*
128+
time ($ARDUINO_BUILD_CMD $sketch >build.log)
129+
local result=$?
130+
if [ $result -ne 0 ]; then
131+
echo "Build failed ($1)"
132+
echo "Build log:"
133+
cat build.log
134+
return $result
135+
fi
136+
rm build.log
137+
return 0
138+
}
139+
140+
function count_sketches()
141+
{
142+
local sketches=$(find $PLATFORM_EXAMPLES -name *.ino)
143+
local sketchnum=0
144+
rm -rf sketches.txt
145+
for sketch in $sketches; do
146+
local sketchdir=$(dirname $sketch)
147+
local sketchdirname=$(basename $sketchdir)
148+
local sketchname=$(basename $sketch)
149+
if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then
150+
continue
151+
fi
152+
echo $sketch >> sketches.txt
153+
sketchnum=$(($sketchnum + 1))
154+
done
155+
return $sketchnum
156+
}
157+
158+
function build_sketches()
159+
{
160+
mkdir -p $ARDUINO_BUILD_DIR
161+
mkdir -p $ARDUINO_CACHE_DIR
162+
mkdir -p $ARDUINO_USR_PATH/libraries
163+
mkdir -p $ARDUINO_USR_PATH/hardware
164+
165+
local chunk_idex=$1
166+
local chunks_num=$2
167+
count_sketches
168+
local sketchcount=$?
169+
local sketches=$(cat sketches.txt)
170+
171+
local chunk_size=$(( $sketchcount / $chunks_num ))
172+
local all_chunks=$(( $chunks_num * $chunk_size ))
173+
if [ "$all_chunks" -lt "$sketchcount" ]; then
174+
chunk_size=$(( $chunk_size + 1 ))
175+
fi
176+
177+
local start_index=$(( $chunk_idex * $chunk_size ))
178+
if [ "$sketchcount" -le "$start_index" ]; then
179+
echo "Skipping job"
180+
return 0
181+
fi
182+
183+
local end_index=$(( $(( $chunk_idex + 1 )) * $chunk_size ))
184+
if [ "$end_index" -gt "$sketchcount" ]; then
185+
end_index=$sketchcount
186+
fi
187+
188+
local start_num=$(( $start_index + 1 ))
189+
#echo -e "Sketches: \n$sketches\n"
190+
echo "Found $sketchcount Sketches";
191+
echo "Chunk Count : $chunks_num"
192+
echo "Chunk Size : $chunk_size"
193+
echo "Start Sketch: $start_num"
194+
echo "End Sketch : $end_index"
195+
196+
local sketchnum=0
197+
print_size_info >size.log
198+
for sketch in $sketches; do
199+
local sketchdir=$(dirname $sketch)
200+
local sketchdirname=$(basename $sketchdir)
201+
local sketchname=$(basename $sketch)
202+
if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then
203+
#echo "Skipping $sketch, beacause it is not the main sketch file";
204+
continue
205+
fi;
206+
if [[ -f "$sketchdir/.test.skip" ]]; then
207+
#echo "Skipping $sketch marked";
208+
continue
209+
fi
210+
sketchnum=$(($sketchnum + 1))
211+
if [ "$sketchnum" -le "$start_index" ]; then
212+
#echo "Skipping $sketch index low"
213+
continue
214+
fi
215+
if [ "$sketchnum" -gt "$end_index" ]; then
216+
#echo "Skipping $sketch index high"
217+
continue
218+
fi
219+
build_sketch $sketch
220+
local result=$?
221+
if [ $result -ne 0 ]; then
222+
return $result
223+
fi
224+
print_size_info $ARDUINO_BUILD_DIR/*.elf >>size.log
225+
done
226+
return 0
227+
}
228+
229+
echo -e "travis_fold:start:test_arduino_ide"
230+
# Build Examples
231+
build_sketches $CHUNK_INDEX $CHUNKS_CNT
28232
if [ $? -ne 0 ]; then exit 1; fi
29-
echo -e "travis_fold:end:sketch_test"
233+
echo -e "travis_fold:end:test_arduino_ide"
234+
235+
echo -e "travis_fold:start:size_report"
236+
cat size.log
237+
echo -e "travis_fold:end:size_report"

0 commit comments

Comments
 (0)