Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a build script #54

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ git submodule update --init --recursive
3. Install [esp-open-sdk](https://github.com/pfalcon/esp-open-sdk), build it with `make toolchain esptool libhal STANDALONE=n`, then edit your PATH and add the generated toolchain bin directory. The path will be something like /path/to/esp-open-sdk/xtensa-lx106-elf/bin. (Despite the similar name esp-open-sdk has different maintainers - but we think it's fantastic!)

4. Install [esptool.py](https://github.com/themadinventor/esptool) and make it available on your PATH. If you used esp-open-sdk then this is done already.

From this point, you can either run the "build.sh" script that will guide you through the next steps, or otherwise just keep reading on.
Remember to make the script executable by running:
```shell
chmod -x /path/to/build.sh
```
5. Checkout [esp-open-rtos](https://github.com/SuperHouse/esp-open-rtos) and set SDK_PATH environment variable pointing to it.
6. Configure settings:
1. If you use ESP8266 with 4MB of flash (32m bit), then you're fine. If you have
Expand Down
69 changes: 69 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash
# Uncomment the next line to debug this script
# set -x
clear
echo "This script is a helper to make and upload esp-homekit-demo"
echo "Set the script as executable and run with syntax \"./build.sh [target] [tty]\""
echo "For example \"./build.sh examples/led /dev/ttyUSB0\""
echo "Remember to setup your SSID and password in wifi.h in the example directory."
# --------------------
# Set RAM size
read -t5 -n1 -r -p "Is your ESP8266 flash RAM size only 1MB? [Y or N] : " RAM_VAL
: "${RAM_VAL:=N}"
echo
if [ $RAM_VAL = "Y" ] || [ $RAM_VAL = "y" ]
then
export FLASH_SIZE=8
export HOMEKIT_SPI_FLASH_BASE_ADDR=0x7a000
echo "Flash size = $FLASH_SIZE address = $HOMEKIT_SPI_FLASH_BASE_ADDR"
else
unset FLASH_SIZE
unset HOMEKIT_SPI_FLASH_BASE_ADDR
echo "Using default flash RAM size"
fi
# --------------------
# Set debugging
read -t5 -n1 -r -p "Do you want debugging on? [Y or N] : " DEBUG_VAL
: "${DEBUG_VAL:=N}"
echo
if [ $DEBUG_VAL = "Y" ] || [ $DEBUG_VAL = "y" ]
then
export HOMEKIT_DEBUG=1
echo "Debug mode is on"
else
unset HOMEKIT_DEBUG
echo "Debug mode is off"
fi
# --------------------
# Set the SDK path
export SDK_PATH="$HOME/esp-open-rtos"
echo "SDK path set to $SDK_PATH"
# --------------------
# From this point exit the script on error
set -e
# --------------------
# Start the build
if [ -z "$1" ] || [ -z "$2" ]
then
echo "Nothing to build or incorrect parameters"
echo "Try again with syntax \"./build.sh [target] [tty]\""
echo "For example \"./build.sh examples/led /dev/ttyUSB0\""
exit 1
fi
echo "Commencing build of $1..."
make -C $1 all
# --------------------
# Upload to flash
export ESPPORT="$2"
# The next line is a workaround - refer to:
# https://askubuntu.com/questions/210177/serial-port-terminal-cannot-open-dev-ttys0-permission-denied
sudo chmod 666 "$2"
echo "ESP port set to $ESPPORT"
echo "Erasing previous firmware..."
make -C $1 erase_flash
echo "Uploading firmware to flash..."
make -C $1 flash
echo "All done. Press a key within 10 sec to monitor, or run \"make -C $1 monitor\"..."
read -t10 -n1 -r KEY_VAL
make -C $1 monitor
exit 0