diff --git a/.gitignore b/.gitignore index 6b844c97..6260aefc 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ build *~ *.png third_party/qemu-litex +third_party/micropython diff --git a/firmware/fx2.c b/firmware/fx2.c index 0d25fb8b..1ffd0410 100644 --- a/firmware/fx2.c +++ b/firmware/fx2.c @@ -127,9 +127,9 @@ void fx2_reboot(enum fx2_fw_version fw) void fx2_debug(void) { wprintf("Possible FX2 Firmware:\r\n"); - wprintf(" [%s] usbjtag (%02X) (IXO USB JTAG Mode)\r\n", fx2_fw_active == FX2FW_USBJTAG ? "*" : " ", FX2_MBFW_USBJTAG_END); + wprintf(" [%s] usbjtag (%02X) (IXO USB JTAG Mode)\r\n", fx2_fw_active == FX2FW_USBJTAG ? "*" : " ", (unsigned int)FX2_MBFW_USBJTAG_END); #ifdef ENCODER_BASE - wprintf(" [%s] hdmi2usb (%02X) (HDMI2USB Video Capture Mode)\r\n", fx2_fw_active == FX2FW_HDMI2USB ? "*" : " ", FX2_MBFW_HDMI2USB_END); + wprintf(" [%s] hdmi2usb (%02X) (HDMI2USB Video Capture Mode)\r\n", fx2_fw_active == FX2FW_HDMI2USB ? "*" : " ", (unsigned int)FX2_MBFW_HDMI2USB_END); #endif } diff --git a/scripts/build-micropython.sh b/scripts/build-micropython.sh new file mode 100755 index 00000000..e8579988 --- /dev/null +++ b/scripts/build-micropython.sh @@ -0,0 +1,81 @@ +#!/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 "$PLATFORM" ]; then + echo "Please set PLATFORM" + exit 1 +fi +if [ -z "$TARGET" ]; then + echo "Please set TARGET" + exit 1 +fi +if [ -z "$CPU" ]; then + echo "Please set CPU" + exit 1 +fi + +set -x +set -e + +# 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/upy-fpga/micropython.git + cd $MPY_SRC_DIR + git submodule update --init + ) +fi + +# Generate the bios and local firmware +TARGET_BUILD_DIR=$(realpath build)/${PLATFORM}_${TARGET}_${CPU}/ +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) $TARGET_MPY_BUILD_DIR/generated + ) +fi + +# Build micropython +OLD_DIR=$PWD +cd $TARGET_MPY_BUILD_DIR +export CROSS_COMPILE=$CPU-elf-newlib- +export BUILDINC_DIRECTORY=$TARGET_BUILD_DIR/software/include +export BUILD=$TARGET_MPY_BUILD_DIR +make -C ../../../../third_party/micropython/litex/ +cd $OLD_DIR + +# Generate a firmware image suitable for flashing. +python -m litex.soc.tools.mkmscimg -f $TARGET_MPY_BUILD_DIR/firmware.bin -o $TARGET_MPY_BUILD_DIR/firmware.fbi +/usr/bin/env python mkimage.py --output-file=$TARGET_BUILD_DIR/micropython.bin --override-firmware=$TARGET_MPY_BUILD_DIR/firmware.fbi diff --git a/scripts/download-env.sh b/scripts/download-env.sh index 0ba66290..d93a8352 100755 --- a/scripts/download-env.sh +++ b/scripts/download-env.sh @@ -202,9 +202,9 @@ check_exists flterm ) check_version ${CPU}-elf-ld $BINUTILS_VERSION -# gcc+binutils for the target +# gcc for the target ( - conda install gcc-${CPU}-elf=$GCC_VERSION + conda install gcc-${CPU}-elf-nostdc=$GCC_VERSION ) check_version ${CPU}-elf-gcc $GCC_VERSION diff --git a/scripts/settings.sh b/scripts/settings.sh index 74672318..3a608757 100644 --- a/scripts/settings.sh +++ b/scripts/settings.sh @@ -14,8 +14,8 @@ HDMI2USB_MODESWITCH_VERSION=0.0.0 HEXFILE_VERSION=0.1 # Conda package versions -BINUTILS_VERSION=2.26 -GCC_VERSION=4.9.3 +BINUTILS_VERSION=2.28 +GCC_VERSION=5.4.0 SDCC_VERSION=3.5.0 OPENOCD_VERSION=0.10.0-dev