This repository was archived by the owner on Aug 27, 2018. It is now read-only.
forked from timvideos/HDMI2USB-litex-firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-micropython.sh
executable file
·83 lines (69 loc) · 2.09 KB
/
build-micropython.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
78
79
80
81
82
83
#!/bin/bash
if [ "`whoami`" = "root" ]
then
echo "Running the script as root is not permitted"
exit 1
fi
CALLED=$_
[[ "${BASH_SOURCE[0]}" != "${0}" ]] && SOURCED=1 || SOURCED=0
SCRIPT_SRC=$(realpath ${BASH_SOURCE[0]})
SCRIPT_DIR=$(dirname $SCRIPT_SRC)
TOP_DIR=$(realpath $SCRIPT_DIR/..)
if [ $SOURCED = 1 ]; then
echo "You must run this script, rather then try to source it."
echo "$SCRIPT_SRC"
return
fi
if [ -z "$HDMI2USB_ENV" ]; then
echo "You appear to not be inside the HDMI2USB environment."
echo "Please enter environment with:"
echo " source scripts/enter-env.sh"
exit 1
fi
# Imports TARGET, PLATFORM, CPU and TARGET_BUILD_DIR from Makefile
eval $(make env)
make info
set -x
set -e
if [ "$FIRMWARE" != "micropython" ]; then
echo "When building MicroPython you should set FIRMWARE to 'micropython'."
exit 1
fi
# Install a toolchain with the newlib standard library
if ! $CPU-elf-newlib-gcc --version > /dev/null 2>&1; then
conda install gcc-$CPU-elf-newlib
fi
# Get micropython is needed
MPY_SRC_DIR=$TOP_DIR/third_party/micropython
if [ ! -d "$MPY_SRC_DIR" ]; then
(
cd $(dirname $MPY_SRC_DIR)
git clone https://github.com/fupy/micropython.git
cd $MPY_SRC_DIR
git submodule update --init
)
fi
# Generate the bios and local firmware
if [ ! -d $TARGET_BUILD_DIR/software/include/generated ]; then
make firmware
fi
# Setup the micropython build directory
TARGET_MPY_BUILD_DIR=$TARGET_BUILD_DIR/software/micropython
if [ ! -e "$TARGET_MPY_BUILD_DIR/generated" ]; then
mkdir -p $TARGET_MPY_BUILD_DIR
(
cd $TARGET_MPY_BUILD_DIR
ln -s $(realpath $PWD/../../software/include/generated) generated
)
fi
TARGET_MPY_BUILD_DIR="$(realpath $TARGET_BUILD_DIR/software/micropython)"
# Build micropython
export CROSS_COMPILE=$CPU-elf-newlib-
export BUILDINC_DIRECTORY="$(realpath $TARGET_BUILD_DIR/software/include)"
export BUILD="$(realpath $TARGET_MPY_BUILD_DIR)"
OLD_DIR=$PWD
cd $TARGET_MPY_BUILD_DIR
make V=1 -C $(realpath ../../../../third_party/micropython/litex/) -j$JOBS
cd $OLD_DIR
# Generate a firmware image suitable for flashing.
make image