diff --git a/README.md b/README.md index 587194e..a5c9216 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,8 @@ Open a terminal and follow the steps below: ```bash git clone https://github.com/neuronalmotion/qtrpi.git cd qtrpi -export QTRPI_QT_VERSION='5.7.0' -export QTRPI_TARGET_DEVICE='linux-rpi3-g++' +export QTRPI_QT_VERSION='5.12.9' +export QTRPI_TARGET_DEVICE='linux-rasp-pi3-g++' export QTRPI_TARGET_HOST='pi@192.168.1.12' ./init-qtrpi-minimal.sh ./deploy-qtrpi.sh --prepare-rpi @@ -98,4 +98,10 @@ By default the image automatically executes `qmake` and `make` in the current wo ``` shell docker pull arose/qtrpi:rpi3-qt5.6.2 docker run -v /someqtprojectfolder/:/source arose/qtrpi:rpi3-qt5.6.2 -``` \ No newline at end of file +``` + +### Errors during compile + +#### Undefined reference error _dl_stack_flags with gcc and pthreads + +Run sysroot-relativelinks.py again \ No newline at end of file diff --git a/docker/rpi3/qt5.12.9/Dockerfile b/docker/rpi3/qt5.12.9/Dockerfile new file mode 100644 index 0000000..4c5cb7b --- /dev/null +++ b/docker/rpi3/qt5.12.9/Dockerfile @@ -0,0 +1,38 @@ +FROM debian:stable-slim +LABEL maintainer="Alexander Rose " + +# install necessary packages +RUN apt-get update -q && apt-get install -yq --no-install-recommends \ + build-essential \ + ca-certificates \ + curl \ + git \ + unzip \ + && rm -rf /var/lib/apt/lists/* + +# Clone Qtrpi and additional scripts +RUN git clone https://github.com/MoJo2600/qtrpi.git -b 5.12.9 + +# Setup Qtrpi environment +ENV QTRPI_QT_VERSION='5.12.9' \ + QTRPI_TARGET_DEVICE='linux-rasp-pi3-g++' \ + QTRPI_TARGET_HOST='pi@localhost' \ + QTRPI_DOCKER='True' + +# Change workdir +WORKDIR /qtrpi + +# Execute init script and clean up after it +RUN ./init-qtrpi-full.sh && \ + rm /opt/qtrpi/*.img && \ + rm -rf /opt/qtrpi/raspi/*.tar.xz + +# Extend path +ENV PATH=/opt/qtrpi/bin:$PATH + +# Create path for source files +RUN mkdir /source +WORKDIR /source + +# Execute build commands on run +CMD /qtrpi/docker/scripts/build.sh diff --git a/docker/scripts/build.sh b/docker/scripts/build.sh old mode 100644 new mode 100755 diff --git a/init-qtrpi-full.sh b/init-qtrpi-full.sh index d70a340..c828963 100755 --- a/init-qtrpi-full.sh +++ b/init-qtrpi-full.sh @@ -1,5 +1,8 @@ #!/bin/bash +# DEBUG +set -e + source ${0%/*}/utils/common.sh function usage() { @@ -47,4 +50,3 @@ cd utils ./switch-sysroot.sh full ./synchronize-qt-modules.sh ./compile-qt-modules.sh --clean-output --clean-modules-repo - diff --git a/qt-modules.txt b/qt-modules.txt index 6dd0387..b1bcbfe 100644 --- a/qt-modules.txt +++ b/qt-modules.txt @@ -6,4 +6,4 @@ qtquickcontrols qtquickcontrols2 qtserialport qtsvg -qtgraphicaleffects +qtgraphicaleffects \ No newline at end of file diff --git a/utils/common.sh b/utils/common.sh index 5aaa598..60bd145 100644 --- a/utils/common.sh +++ b/utils/common.sh @@ -24,19 +24,20 @@ function device_name() { 'linux-rasp-pi-g++') NAME='rpi1' ;; 'linux-rasp-pi2-g++') NAME='rpi2' ;; 'linux-rpi3-g++') NAME='rpi3' ;; + 'linux-rasp-pi3-g++') NAME='rpi3' ;; esac echo $NAME } validate_var_qtrpi_qt_version() { - for VERSION in '5.6.2' '5.7.0'; do + for VERSION in '5.6.2' '5.7.0' '5.12.9'; do if [[ "$QTRPI_QT_VERSION" == "$VERSION" ]]; then VALID=true fi done if [[ ! $VALID ]]; then - exit_error "Invalid QTRPI_QT_VERSION value ($QTRPI_QT_VERSION). Supported values: \n- 5.6.2 \n- 5.7.0" + exit_error "Invalid QTRPI_QT_VERSION value ($QTRPI_QT_VERSION). Supported values: \n- 5.6.2 \n- 5.7.0 \n- 5.12.9" fi } @@ -44,7 +45,7 @@ validate_var_qtrpi_target_device() { NAME=$(device_name $QTRPI_TARGET_DEVICE) if [[ ! $NAME ]]; then - exit_error "Invalid QTRPI_TARGET_DEVICE value ($QTRPI_TARGET_DEVICE). Supported values: \n- linux-rasp-pi-g++ \n- linux-rasp-pi2-g++ \n- linux-rpi3-g++" + exit_error "Invalid QTRPI_TARGET_DEVICE value ($QTRPI_TARGET_DEVICE). Supported values: \n- linux-rasp-pi-g++ \n- linux-rasp-pi2-g++ \n- linux-rasp-pi3-g++" fi } @@ -69,10 +70,11 @@ check_env_vars() { ROOT=${QTRPI_ROOT-/opt/qtrpi} -TARGET_DEVICE=${QTRPI_TARGET_DEVICE-'linux-rasp-pi2-g++'} -QT_VERSION=${QTRPI_QT_VERSION-'5.7.0'} +TARGET_DEVICE=${QTRPI_TARGET_DEVICE-'linux-rasp-pi3-g++'} +QT_VERSION=${QTRPI_QT_VERSION-'5.12.9'} TARGET_HOST=$QTRPI_TARGET_HOST RASPBIAN_BASENAME='raspbian_latest' +LINARO_BASENAME='linaro_latest' DEVICE_NAME=$(device_name $TARGET_DEVICE) @@ -109,18 +111,22 @@ function cd_root() { function clean_git_and_compilation() { git reset --hard HEAD git clean -fd - make clean -j 10 - make distclean -j 10 + make clean + make distclean } function qmake_cmd() { LOG_FILE=${1:-'default'} - $ROOT/raspi/qt5/bin/qmake -r |& tee $ROOT/logs/$LOG_FILE.log + $ROOT/raspi/qt5/bin/qmake |& tee $ROOT/logs/$LOG_FILE.log + + # Got a lot of errors like `qtdeclarative - Could not find feature qml-network` + # Removing `-r` fixed this and modules are still working + # https://stackoverflow.com/questions/47443971/project-error-could-not-find-feature-when-running-qmake-on-any-qt-module } function make_cmd() { LOG_FILE=${1:-'default'} - make -j 10 |& tee --append $ROOT/logs/$LOG_FILE.log + make |& tee --append $ROOT/logs/$LOG_FILE.log } function download_sysroot_minimal() { diff --git a/utils/compile-qt-modules.sh b/utils/compile-qt-modules.sh index 7749c81..8080dd6 100755 --- a/utils/compile-qt-modules.sh +++ b/utils/compile-qt-modules.sh @@ -32,6 +32,10 @@ function build_module() { function fix_qmake() { QMAKE_FILE=mkspecs/devices/$TARGET_DEVICE/qmake.conf + echo "PATH" + echo $PWD + echo $QMAKE_FILE + # Add missing INCLUDEPATH in qmake conf grep -q 'INCLUDEPATH' $QMAKE_FILE || cat>>$QMAKE_FILE << EOL INCLUDEPATH += \$\$[QT_SYSROOT]/opt/vc/include @@ -46,7 +50,7 @@ EOL } function build_qtbase() { - export CROSS_COMPILE=$ROOT/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf- + export CROSS_COMPILE=$ROOT/raspi/${LINARO_BASENAME}/bin/arm-linux-gnueabihf- export SYSROOT=$ROOT/raspbian/sysroot MODULE='qtbase' diff --git a/utils/download-raspbian.sh b/utils/download-raspbian.sh index 334bc48..8cdcd9c 100755 --- a/utils/download-raspbian.sh +++ b/utils/download-raspbian.sh @@ -53,8 +53,10 @@ function download_raspbian() { message 'Downloading Raspbian latest image' wget --output-document=${RASPBIAN_BASENAME}.zip \ --content-disposition \ - https://downloads.raspberrypi.org/raspbian/images/raspbian-2017-03-03/2017-03-02-raspbian-jessie.zip + https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2021-01-12/2021-01-11-raspios-buster-armhf-lite.zip + #https://downloads.raspberrypi.org/raspios_full_armhf/images/raspios_full_armhf-2021-01-12/2021-01-11-raspios-buster-armhf-full.zip +# https://downloads.raspberrypi.org/raspbian/images/raspbian-2017-03-03/2017-03-02-raspbian-jessie.zip unzip -p ${RASPBIAN_BASENAME}.zip > ${RASPBIAN_BASENAME}.img } diff --git a/utils/init-common.sh b/utils/init-common.sh index c4486c3..7d6d464 100755 --- a/utils/init-common.sh +++ b/utils/init-common.sh @@ -12,15 +12,17 @@ if [[ ! $DOCKER_BUILD ]]; then sudo umount $ROOT/raspbian/sysroot-full/proc sudo mkdir -p $ROOT - sudo chown -R $USER:$USER $ROOT + GROUP=$(id -g -n) + sudo chown -R $USER:$GROUP $ROOT else # === Docker-Mode === # umount is not allowed in a docker image, besides we use a fresh linux image => skipping sanity checks # sudo is also not needed/installed by default => creating directory structure without use of sudo mkdir -p $ROOT - chown -R $USER:$USER $ROOT + GROUP=$(id -g -n) + chown -R $USER:$GROUP $ROOT fi cd_root -mkdir raspi raspbian bin logs +mkdir raspi -p raspbian bin logs diff --git a/utils/prepare-sysroot-full.sh b/utils/prepare-sysroot-full.sh index a78a9f9..1be656a 100755 --- a/utils/prepare-sysroot-full.sh +++ b/utils/prepare-sysroot-full.sh @@ -29,7 +29,8 @@ sudo mount -o bind /sys sysroot-full/sys # comment preload conf to avoid the following error during apt-get build-dep command # qemu: uncaught target signal 4 (Illegal instruction) - core dumped # Illegal instruction -sudo sed -i '/./s/^/#/g' sysroot-full/etc/ld.so.preload +# TODO It is now working without this - remove when properly tested +# sudo sed -i '/./s/^/#/g' sysroot-full/etc/ld.so.preload # Uncomment deb-src to have access to dev packages sudo sed -i '/deb-src/s/^#//g' sysroot-full/etc/apt/sources.list @@ -44,7 +45,8 @@ sudo umount sysroot-full/sys sudo umount sysroot-full/dev sudo umount sysroot-full/proc -sudo chown -R $USER:$USER sysroot-full +GROUP=$(id -g -n) +sudo chown -R $USER:$GROUP sysroot-full $UTILS_DIR/sysroot-relativelinks.py sysroot-full diff --git a/utils/synchronize-toolchain.sh b/utils/synchronize-toolchain.sh index 85ff5e1..4867b13 100755 --- a/utils/synchronize-toolchain.sh +++ b/utils/synchronize-toolchain.sh @@ -6,6 +6,7 @@ function usage() { Usage: $0 [options] -h| --help Display help text. +-n| --no-download If the toolchain file is present, do not download it again. -d| --directory Destination directory where the toolchain is downloaded. EOF } @@ -16,6 +17,9 @@ while [[ $# -gt 0 ]]; do -h|--help) DISPLAY_HELP=true ;; + -n|--no-download) + NO_DOWNLOAD=true + ;; -d|--directory) DIRECTORY_ARG="$2" ;; @@ -41,17 +45,32 @@ fi cd raspi +export LINARO_RELEASE="gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf" + message 'Downloading Raspberry Pi toolchain' -if [[ ! $DOCKER_BUILD ]]; then - if [[ ! -d 'tools' ]]; then - git clone https://github.com/raspberrypi/tools - fi +function download_toolchain() { + # Download and unzip the latest raspbian image (~1.4Go zipped) + message "Downloading linaro ${LINARO_RELEASE}" + wget --output-document=${LINARO_BASENAME}.tar.xz \ + --content-disposition \ + https://releases.linaro.org/components/toolchain/binaries/latest-7/arm-linux-gnueabihf/${LINARO_RELEASE}.tar.xz + mkdir ${LINARO_BASENAME} && tar xfv ${LINARO_BASENAME}.tar.xz -C ${LINARO_BASENAME} --strip-components 1 +} - pushd tools - git pull origin master - popd +if [[ -d "./${LINARO_BASENAME}" ]]; then + if [[ ! $NO_DOWNLOAD ]]; then + while true; do + read -p "You already have the current toolchain, do you want to download the lastest version [y/n]? " yn + case $yn in + [Yy]* ) download_toolchain; break;; + [Nn]* ) break;; + esac + done + else + echo "Using existing toolchain" + fi else - # create shallow copy, which is a lot faster - git clone --depth=1 -b master https://github.com/raspberrypi/tools + download_toolchain; fi +