diff --git a/.travis.yml b/.travis.yml
index a5df0d6..ca9ff59 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,6 +8,8 @@ env:
   ESPTOOL2_COMMIT=ec0e2c7
   ESPTOOL2_DIR="${HOME}/esptool2-${ESPTOOL2_COMMIT}"
   PATH=${PATH}:${CROSS_BINDIR}:${ESPTOOL2_DIR}
+  CROSS="ccache xtensa-lx106-elf-"
+  MAKE_CMD="make WARNINGS_AS_ERRORS=1 -C examples/ build-examples"
 cache:
   directories:
     - ${CROSS_ROOT}
@@ -35,27 +37,12 @@ addons:
     - git
 
 before_install:
-  # Install a toolchain using esp-open-sdk (parts we need for this are the GNU toolchain and libhal)
-  #
-  # Adds hack of "{$HAS_TC} || -Buildstep-" to avoid rebuilding toolchain if it's already
-  # installed from the cache. If this gets any more complex it should be spun out to a standalone shell script.
-  - export HAS_TC="test -d ${CROSS_BINDIR}"
-  - unset CC # Travis sets this due to "language: c", but it confuses autotools configure when cross-building
-  - ${HAS_TC} || git clone --recursive https://github.com/pfalcon/esp-open-sdk.git
-  - ${HAS_TC} || cd esp-open-sdk
-  - ${HAS_TC} || git reset --hard ${OPENSDK_COMMIT}
-  - ${HAS_TC} || git submodule update
-  - ${HAS_TC} || sed -i "s/2.69/2.68/" lx106-hal/configure.ac # this is a nasty hack as Ubuntu Precise only has autoconf 2.68 not 2.69...
-  - ${HAS_TC} || sed -r -i 's%TOOLCHAIN ?=.*%TOOLCHAIN=${CROSS_ROOT}%' Makefile
-  - ${HAS_TC} || make toolchain esptool libhal STANDALONE=n
-  - export HAS_ET2="test -f ${ESPTOOL2_DIR}/esptool2"
-  - ${HAS_ET2} || git clone https://github.com/raburton/esptool2 ${ESPTOOL2_DIR}
-  - ${HAS_ET2} || cd ${ESPTOOL2_DIR}
-  - ${HAS_ET2} || git reset --hard ${ESPTOOL2_COMMIT}
-  - ${HAS_ET2} || make
+  - utils/travis_build/install_esptool2.sh
+  - travis_wait 30 utils/travis_build/install_toolchain.sh
 
 script:
   - cd ${TRAVIS_BUILD_DIR}
   # Remove ssid_config requirement for examples
   - sed -i "s%#error%//#error%" include/ssid_config.h
-  - make WARNINGS_AS_ERRORS=1 -C examples/ build-examples CROSS="ccache xtensa-lx106-elf-" V=1
+  # Don't verbose-build all examples (too much output), only verbose-build errors
+  - ( ${MAKE_CMD} ) || ( ${MAKE_CMD} V=1 )
diff --git a/extras/mbedtls/mbedtls b/extras/mbedtls/mbedtls
index a7ffc8f..0a0c22e 160000
--- a/extras/mbedtls/mbedtls
+++ b/extras/mbedtls/mbedtls
@@ -1 +1 @@
-Subproject commit a7ffc8f7396573bec401e0afcc073137522d5305
+Subproject commit 0a0c22e0efcf2f8f71d7e16712f80b8f77326f72
diff --git a/utils/travis_build/install_esptool2.sh b/utils/travis_build/install_esptool2.sh
new file mode 100755
index 0000000..102fd6f
--- /dev/null
+++ b/utils/travis_build/install_esptool2.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+set -uv
+
+# Called by Travis to install esptool2 to generate OTA-compatible build
+# images
+
+if test -f ${ESPTOOL2_DIR}/esptool2; then
+	echo "Using cached esptool2"
+	exit 0
+fi
+
+git clone https://github.com/raburton/esptool2 ${ESPTOOL2_DIR}
+cd ${ESPTOOL2_DIR}
+git reset --hard ${ESPTOOL2_COMMIT}
+make
diff --git a/utils/travis_build/install_toolchain.sh b/utils/travis_build/install_toolchain.sh
new file mode 100755
index 0000000..905df90
--- /dev/null
+++ b/utils/travis_build/install_toolchain.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+set -euv
+
+# Called by Travis to install a toolchain using esp-open-sdk (parts we
+# ne for esp-open-rtos are the GNU toolchain, libhal, and esptool.py.)
+
+if test -d ${CROSS_BINDIR}; then
+	echo "Using cached toolchain in ${CROSS_BINDIR}"
+	exit 0
+fi
+
+# Travis sets this due to "language: c", but it confuses autotools configure when cross-building
+unset CC
+
+git clone --recursive https://github.com/pfalcon/esp-open-sdk.git
+cd esp-open-sdk
+git reset --hard ${OPENSDK_COMMIT}
+git submodule update --init
+
+# this is a nasty hack as Ubuntu Precise only has autoconf 2.68 not 2.69...
+sed -i "s/2.69/2.68/" lx106-hal/configure.ac
+
+# build the toolchain relative to the CROSS_ROOT directory
+sed -r -i 's%TOOLCHAIN ?=.*%TOOLCHAIN=${CROSS_ROOT}%' Makefile
+
+# will dump log on failure
+echo "Building toolchain without live progress, as progress spinner fills up log..."
+
+if !( make toolchain esptool libhal STANDALONE=n 2>&1 > make.log ); then
+	cat make.log
+	echo "Exiting due to failed toolchain build"
+	exit 3
+fi
+
+echo "Toolchain build completed in ${CROSS_ROOT}."