-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-with-options.sh
77 lines (64 loc) · 2.35 KB
/
build-with-options.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
POSITIONAL=()
PORT=/dev/cu.usbserial-1410
MEMORY=1
FLASH_SIZE=8
ADDR=0x8c000
ACTION=$1
if [ -z "$ACTION" ];
then
echo "usage: $0 <build|clean|erase|flash|debug>";
exit 1;
fi
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-p|--port)
PORT="$2"
shift # past argument
shift # past value
;;
-m|--memory)
MEMORY="$2MB" && FLASH_SIZE=$((8 * $2))
shift # past argument
shift # past value
;;
--default)
ADDR="$2"
shift # past argument
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
echo "SERIAL PORT = ${PORT}"
echo "MEMORY SIZE = ${MEMORY}"
echo "MEMORY SIZE IN = ${MEMORY}"
echo "FLASH ADDRESS = ${ADDR}"
# echo "$1"
# if [[ -n $1 ]]; then
# echo "Start $ACTION using port $PORT to address $ADDR having $MEMORY MB"
# fi
echo "Start $ACTION using port $PORT to address $ADDR having ESP8266 with $MEMORY($FLASH_SIZE) flash size"
# Build
_build() {
echo docker run -it --rm -v $(pwd):/project -w /project "$@" esp-rtos make -C . ESPPORT=$PORT FLASH_SIZE=$FLASH_SIZE HOMEKIT_SPI_FLASH_BASE_ADDR=$ADDR HOMEKIT_DEBUG=1 clean
docker run -it --rm -v $(pwd):/project -w /project "$@" esp-rtos make -C . ESPPORT=$PORT FLASH_SIZE=$FLASH_SIZE HOMEKIT_SPI_FLASH_BASE_ADDR=$ADDR HOMEKIT_DEBUG=1 clean
}
# Build
_clean() {
# docker run -it --rm -v $(pwd):/project -w /project "$@" esp-rtos make -C . ESPPORT="$PORT" FLASH_SIZE=8 HOMEKIT_SPI_FLASH_BASE_ADDR=0x8c000 HOMEKIT_DEBUG=1 all
docker run -it --rm -v $(pwd):/project -w /project "$@" esp-rtos make -C . ESPPORT=/dev/cu.usbserial-1410 FLASH_SIZE=8 HOMEKIT_SPI_FLASH_BASE_ADDR=0x8c000 HOMEKIT_DEBUG=1 all
}
_flash() {
printf "\nesptool.py -p $PORT --baud 115200 write_flash -fs $MEMORY -fm dout -ff 40m 0x0 firmware_prebuilt/rboot.bin 0x1000 firmware_prebuilt/blank_config.bin 0x2000 firmware_prebuilt/otaboot.bin;\n"
esptool.py -p $PORT --baud 115200 write_flash -fs $MEMORY -fm dout -ff 40m 0x0 firmware_prebuilt/rboot.bin 0x1000 firmware_prebuilt/blank_config.bin 0x2000 firmware_prebuilt/otaboot.bin;
}
_debug() {
printf "\ndocker run -it --rm -v $(pwd):/project -w /project "$@" esp-rtos make -C . ESPPORT=$PORT FLASH_SIZE=$FLASH_SIZE HOMEKIT_SPI_FLASH_BASE_ADDR=$ADDR HOMEKIT_DEBUG=1 clean\n"
}
eval _$ACTION