summaryrefslogtreecommitdiff
path: root/scripts/make.inc.sh
blob: 598e30667aa7d8bb46feed1d8dc00e663a064ba8 (plain)
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
# intended to be included from shell-script

PORT=${PORT:-/dev/ttyUSB0}
_PROJECT_DIR=${0%/*}
_SCRIPTS_DIR=${0%/*}/../scripts

if test -z "$PY_SOURCES"; then
    echo "PY_SOURCES variable must be set"
    exit 1
fi

testport() {
        if test -c $PORT; then
            true
        else
            echo "$PORT not connected" >&2
            exit 1
        fi
}

case "$1" in
    console)
        testport
        screen $PORT 115200
        ;;
    flash)
        testport
        $_SCRIPTS_DIR/flash.sh "${PORT}"
        ;;
    setup)
        testport
        $_SCRIPTS_DIR/setup_wlan.sh "${PORT}" "${_PROJECT_DIR}/.config"
        ;;
    copy)
        testport
        for file in $PY_SOURCES; do
            $_SCRIPTS_DIR/transfer.sh "${PORT}" "${_PROJECT_DIR}/$file" "$file"
        done
        ;;
    format)
        testport
        $_SCRIPTS_DIR/format.sh "${PORT}"
        ;;
    reset)
        testport
        echo -e -n "\003\004" > "${PORT}"
        sleep 3
        ;;
    config)
        export srctree="${_PROJECT_DIR}"
        export KCONFIG_CONFIG="${_PROJECT_DIR}/.config"
        python3 "$_SCRIPTS_DIR/menuconfig.py" "${_PROJECT_DIR}/Kconfig"
        ;;
    *)
        echo "Command '$1' not supported" >&2
        exit 1
        ;;
esac