Skip to content

Commit 8abbe13

Browse files
hathachladyada
authored andcommitted
Add nrf5x to build platform (espressif#41)
* adding nrf5x platform * minor clean up * remove comment code
1 parent f3f08dd commit 8abbe13

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

install.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export ARCADA_PLATFORMS='declare -A arcada_platforms=( [pybadge]="adafruit:samd:
2525

2626
export IO_PLATFORMS='declare -A io_platforms=( [zero]="arduino:samd:arduino_zero_native", [m4wifi]="adafruit:samd:adafruit_metro_m4_airliftlite:speed=120", [esp8266]="esp8266:esp8266:huzzah:eesz=4M3M,xtal=80" [esp32]="esp32:esp32:featheresp32:FlashFreq=80" )'
2727

28+
export NRF5X_PLATFORMS='declare -A nrf5x_platforms=( [nrf52840]="adafruit:nrf52:feather52840:softdevice=s140v6,debug=l0")'
29+
2830
# make display available for arduino CLI
2931
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16
3032
sleep 3
@@ -115,6 +117,10 @@ echo -n "ADAFRUIT SAMD: "
115117
DEPENDENCY_OUTPUT=$(arduino --install-boards adafruit:samd 2>&1)
116118
if [ $? -ne 0 ]; then echo -e "\xe2\x9c\x96 OR CACHED"; else echo -e """$GREEN""\xe2\x9c\x93"; fi
117119

120+
echo -n "ADAFRUIT NRF5X: "
121+
DEPENDENCY_OUTPUT=$(arduino --install-boards adafruit:nrf52 2>&1)
122+
if [ $? -ne 0 ]; then echo -e "\xe2\x9c\x96 OR CACHED"; else echo -e """$GREEN""\xe2\x9c\x93"; fi
123+
118124
# install random lib so the arduino IDE grabs a new library index
119125
# see: https://github.com/arduino/Arduino/issues/3535
120126
echo -n "UPDATE LIBRARY INDEX: "
@@ -146,6 +152,7 @@ function build_platform()
146152
eval $M4_PLATFORMS
147153
eval $ARCADA_PLATFORMS
148154
eval $IO_PLATFORMS
155+
eval $NRF5X_PLATFORMS
149156

150157
# reset platform json var
151158
PLATFORM_JSON=""
@@ -193,6 +200,8 @@ function build_platform()
193200
platform=${arcada_platforms[$platform_key]}
194201
elif [[ ${io_platforms[$platform_key]} ]]; then
195202
platform=${io_platforms[$platform_key]}
203+
elif [[ ${nrf5x_platforms[$platform_key]} ]]; then
204+
platform=${nrf5x_platforms[$platform_key]}
196205
else
197206
echo "NON-STANDARD PLATFORM KEY: $platform_key"
198207
platform=$platform_key
@@ -698,6 +707,55 @@ function build_arcada_platforms()
698707
}
699708

700709

710+
function build_nrf5x_platforms()
711+
{
712+
713+
# arrays can't be exported, so we have to eval
714+
eval $NRF5X_PLATFORMS
715+
716+
# track the build status all platforms
717+
local exit_code=0
718+
719+
# var to hold platforms
720+
local platforms_json=""
721+
722+
# get the last element in the array
723+
local last="${nrf5x_platforms[@]:(-1)}"
724+
725+
# loop through platforms in main platforms assoc array
726+
for p_key in "${!nrf5x_platforms[@]}"; do
727+
728+
# is this the last platform in the loop
729+
local last_platform=0
730+
if [ "$last" == "${nrf5x_platforms[$p_key]}" ]; then
731+
last_platform=1
732+
fi
733+
734+
# build all examples for this platform
735+
build_platform $p_key
736+
737+
# check if build failed
738+
if [ $? -ne 0 ]; then
739+
platforms_json="${platforms_json}$(json_platform $p_key 0 "$PLATFORM_JSON" $last_platform)"
740+
exit_code=1
741+
else
742+
platforms_json="${platforms_json}$(json_platform $p_key 1 "$PLATFORM_JSON" $last_platform)"
743+
fi
744+
745+
done
746+
747+
# exit code is opposite of json build status
748+
if [ $exit_code -eq 0 ]; then
749+
json_main_platforms 1 "$platforms_json"
750+
else
751+
json_main_platforms 0 "$platforms_json"
752+
fi
753+
754+
return $exit_code
755+
756+
}
757+
758+
701759
# generate json string for a sketch
702760
function json_sketch()
703761
{

0 commit comments

Comments
 (0)