diff options
author | Thomas Van Iseghem <[email protected]> | 2023-05-23 18:04:55 +0200 |
---|---|---|
committer | Thomas Van Iseghem <[email protected]> | 2023-05-23 18:04:55 +0200 |
commit | a5a395cce2d24928b11735f315c231dd104acd71 (patch) | |
tree | 46895927ee7e3b15a181ac0678798e2d95d8b980 /CorOS-dev-environment | |
parent | 808a8a3cec2b75a3dcb658a2238f2998fcf38e54 (diff) | |
download | OpenCortex-a5a395cce2d24928b11735f315c231dd104acd71.tar.gz OpenCortex-a5a395cce2d24928b11735f315c231dd104acd71.zip |
Created a better slimmed down emulation container
Diffstat (limited to 'CorOS-dev-environment')
-rw-r--r-- | CorOS-dev-environment/.gitignore | 7 | ||||
-rw-r--r-- | CorOS-dev-environment/CorOS-emulation/Dockerfile | 22 | ||||
-rw-r--r-- | CorOS-dev-environment/CorOS-emulation/docker-compose.yaml | 21 | ||||
-rw-r--r-- | CorOS-dev-environment/README.md | 77 | ||||
-rw-r--r-- | CorOS-dev-environment/filesystems/README.md | 7 | ||||
-rw-r--r-- | CorOS-dev-environment/init_system.sh | 41 | ||||
-rw-r--r-- | CorOS-dev-environment/install_qt_compiled.sh | 8 | ||||
-rw-r--r-- | CorOS-dev-environment/install_qt_src.sh | 4 | ||||
-rw-r--r-- | CorOS-dev-environment/install_toolchain(broken).sh | 37 | ||||
-rw-r--r-- | CorOS-dev-environment/install_toolchain.sh | 6 | ||||
-rw-r--r-- | CorOS-dev-environment/qt-compiled-4.8.7.tar.gz | bin | 0 -> 29628859 bytes | |||
-rw-r--r-- | CorOS-dev-environment/update-builder.sh | 23 |
12 files changed, 253 insertions, 0 deletions
diff --git a/CorOS-dev-environment/.gitignore b/CorOS-dev-environment/.gitignore new file mode 100644 index 0000000..b631c5c --- /dev/null +++ b/CorOS-dev-environment/.gitignore @@ -0,0 +1,7 @@ +# ignore everything in the mount folder except the filesystems folder +# and the mount folder itself + +/mount/* +/filesystems/* +!/mount +!/filesystems/README.md diff --git a/CorOS-dev-environment/CorOS-emulation/Dockerfile b/CorOS-dev-environment/CorOS-emulation/Dockerfile new file mode 100644 index 0000000..1f24b79 --- /dev/null +++ b/CorOS-dev-environment/CorOS-emulation/Dockerfile @@ -0,0 +1,22 @@ +# Slim Debian image with QEMU and dos2unix +FROM debian:buster-slim + +# Add required packages in the noninteractive mode +RUN apt-get -y update && apt-get -y -q install dos2unix qemu qemu-user-static + +# # Set toolchain PATH for remote container +RUN mkdir -p /opt/ARM/sysroot +ENV QEMU_LD_PREFIX="/opt/ARM/sysroot" + +# Mounting the QC-rootfs +RUN mkdir qc-fs qc-fs-uncompressed qt_src + +WORKDIR /qt_src +# # Copy and run the installer +COPY qt-compiled-4.8.7.tar.gz install_qt_compiled.sh . + +WORKDIR / +COPY init_system.sh update-builder.sh . +RUN dos2unix init_system.sh update-builder.sh /qt_src/install_qt_compiled.sh + +ENTRYPOINT ["/bin/bash"] diff --git a/CorOS-dev-environment/CorOS-emulation/docker-compose.yaml b/CorOS-dev-environment/CorOS-emulation/docker-compose.yaml new file mode 100644 index 0000000..f83534c --- /dev/null +++ b/CorOS-dev-environment/CorOS-emulation/docker-compose.yaml @@ -0,0 +1,21 @@ +# Docker compose file for easy volume mounting and running of the container + +services: + coros-emu: + image: opencortex/coros-emu:latest + build: + context: ../ + dockerfile: CorOS-emulation/Dockerfile + tags: + - opencortex/coros-emu:latest + + volumes: + - ../filesystems:/qc-fs + - ../mount:/mnt + + environment: + # Edit this to your needs. This should be just the file name, not the path. + - UPDATE_FILE=verify.bin.gz + + privileged: true + entrypoint: /bin/bash -c "while true; do sleep 1; done"
\ No newline at end of file diff --git a/CorOS-dev-environment/README.md b/CorOS-dev-environment/README.md new file mode 100644 index 0000000..b236306 --- /dev/null +++ b/CorOS-dev-environment/README.md @@ -0,0 +1,77 @@ +# A safe development environment + +## Usage + +### Building the container + +Go into the QC-dev-environment directory and run: + +``` +docker build . -t <your-wanted-tag e.g. cortex-dev> +``` + +### Getting the update file + +The update process of the QC is done in 2 steps. First the download, after that the install. We can use this to our advantage to grab the actual update file. Once you downloaded the update **do not install it yet.** Get an SSH shell going and go to `/media/p4`. There you will find your update file. A registry of these file names is also available inside the `filesystems/README.md` of this folder. + +You can use the `scp` tool to send this update file over to your system. + +Once you've got the update file, you can put it inside the `filesystems` directory to mount to the docker container. Now you can use the update file to explore your QC (except for the user files), and even create custom update packages. + +### Running the container + +It needs to run privileged since we need to run the `mount` command inside it. You can run it without the `--privileged` path if you're not planning to mount the QC's file system and just want to compile something. + +The `mount` folder is optional. But it's an easy way to get files from to host inside the container and vice versa. + +``` +docker run --privileged -it -p 5900:5900 \ + -v <absolute-path-to-current-folder>/mount:/mnt \ + -v <absolute-path-to-current-folder>/filesystems:/qc-fs \ + -e UPDATE_FILE=<update-file-name> \ + cortex-dev +``` + +Another way is to use `docker compose`. In the `docker-compose.yaml` file, all volumes are already defined. This means you only have to define the update file in the `environment` section. + +To use this first run the service in detached mode + +``` +docker compose up -d +``` + +After that you can attach to the container using + +``` +docker compose exec cortex-dev /bin/bash +``` + +When attached to the docker container's shell, there is one post-install step left. Run the following command: + +``` +./init_system.sh +``` + +This will mount the QC filesystem and install a custom compiled version of QT inside it that has support for VNC. + +To link QT to the right fonts folder, run: + +```bash +export QT_QWS_FONTDIR=/etc/fonts +``` + +## Creating an update package + +You can create a custom update package based on the mounted filesystem, by running the `update-builder.sh` script. This can be found in the root of the docker container. This way you can patch your update to include all mods and ssh access, without opening the QC up everytime. + +The update file should be available on your host machine at `filesystems/update-opencortex.bin.gz`. You can validate the update file by mounting it as the actual update file using the `UPDATE_FILE` environment variable and running `init_system.sh`. + + +## Config for custom compiled QT + +For running GUI applications such as `ZenUI` it is possible to output the video to a virtual device. One of these posibilities is a simple VNC server. To enable this ability I have compiled QT from source using the following config: + +``` +./configure -embedded arm -xplatform qws/linux-arm-gnueabi-g++ -nomake examples -nomake demos -opensource -qt-libtiff -qt-zlib -qt-libpng -qt-libmng -qt-libjpeg -optimized-qmake -qt-freetype -qt-gfx-vnc -no-webkit -no-javascript-jit -optimized-qmake -no-cups && make +``` + diff --git a/CorOS-dev-environment/filesystems/README.md b/CorOS-dev-environment/filesystems/README.md new file mode 100644 index 0000000..fc4da30 --- /dev/null +++ b/CorOS-dev-environment/filesystems/README.md @@ -0,0 +1,7 @@ +# Update name registry + +Update download files are found inside `/media/p4/update-<update-name>.bin` + +**2.0.0:** update-vm44GCkrMujYR8o47OkF8UW.AdVYyu0U + +**2.0.1:** update-cIR97IrfvF4fKfO5_KIm_j_aP2zGiHp_
\ No newline at end of file diff --git a/CorOS-dev-environment/init_system.sh b/CorOS-dev-environment/init_system.sh new file mode 100644 index 0000000..8b931f9 --- /dev/null +++ b/CorOS-dev-environment/init_system.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# Decompress archive and mount rootfs.ext3 +gunzip -d -k /qc-fs/$UPDATE_FILE +# Run tar command on the decompressed file to extract the rootfs.ext3 file +# We need to remove the .gz extension from the file name +tar -xvf /qc-fs/${UPDATE_FILE::-3} -C /qc-fs-uncompressed +rm /qc-fs/${UPDATE_FILE::-3} + +echo "Mounting rootfs.ext3" +mount -t ext4 /qc-fs-uncompressed/rootfs.ext3 $QEMU_LD_PREFIX +echo "Mounting rootfs.ext3 finished" + +# Promt the user to install custom QT +# if the user types "y" or "Y" then install custom QT +echo "Do you want to install the custom compiled QT? (y/n)" +echo "" +read -n 1 -r +echo "" + +if [[ $REPLY =~ ^[Yy]$ ]] +then + echo "Installing QT" + cd /qt_src && ./install_qt_compiled.sh + echo "Installing QT finished" +fi + +# Prompt user to chroot into the $QEMU_LD_PREFIX directory +# if the user types "y" or "Y" then chroot into the $QEMU_LD_PREFIX directory +# otherwise exit the script +echo "Do you want to chroot into the created QC-filesystem? (y/n)" +echo "" +read -n 1 -r +echo "" + +if [[ $REPLY =~ ^[Yy]$ ]] +then + echo "" + echo "Chrooting into $QEMU_LD_PREFIX" + chroot $QEMU_LD_PREFIX +fi diff --git a/CorOS-dev-environment/install_qt_compiled.sh b/CorOS-dev-environment/install_qt_compiled.sh new file mode 100644 index 0000000..2094de0 --- /dev/null +++ b/CorOS-dev-environment/install_qt_compiled.sh @@ -0,0 +1,8 @@ +#!/bin/bash +tar -xf qt-compiled-4.8.7.tar.gz +rm qt-compiled-4.8.7.tar.gz +# Then install it +cp -a QtEmbedded-4.8.7-arm/lib/. $QEMU_LD_PREFIX/usr/lib/ +cp -a QtEmbedded-4.8.7-arm/bin/. $QEMU_LD_PREFIX/usr/bin/ + +QT_QWS_FONTDIR=/etc/fonts
\ No newline at end of file diff --git a/CorOS-dev-environment/install_qt_src.sh b/CorOS-dev-environment/install_qt_src.sh new file mode 100644 index 0000000..66a381b --- /dev/null +++ b/CorOS-dev-environment/install_qt_src.sh @@ -0,0 +1,4 @@ +# First download the package using wget +wget -LO https://src.fedoraproject.org/repo/pkgs/qt/qt-everywhere-opensource-src-4.8.7.tar.gz/d990ee66bf7ab0c785589776f35ba6ad/qt-everywhere-opensource-src-4.8.7.tar.gz +# Then extract it +tar -zxvf qt-everywhere-opensource-src-4.8.7.tar.gz diff --git a/CorOS-dev-environment/install_toolchain(broken).sh b/CorOS-dev-environment/install_toolchain(broken).sh new file mode 100644 index 0000000..c3b05fa --- /dev/null +++ b/CorOS-dev-environment/install_toolchain(broken).sh @@ -0,0 +1,37 @@ +#!/bin/sh +# Currently the latest addin .deb package is corrupted. It is unable to be unpacked. +# This script is used to download the latest addin .deb package and install it. + +##################################### Install Toolchain ############################# +linux_addin_version=$1 + +linux_addin_link="https://download.analog.com/tools/LinuxAddInForCCES/Releases/Release_$linux_addin_version/adi-LinuxAddinForCCES-linux-x86-$linux_addin_version.deb" + +echo "Start downloading linux-addin ($linux_addin_link)" +wget --quiet $linux_addin_link +echo "linux-addin download finished" +linux_addin_link=`basename $linux_addin_link` +linux_addin_name=`basename $linux_addin_link` + + +linux_addin_deb=$linux_addin_link +echo "Start to install $linux_addin_name, Installing..." +export DEBIAN_FRONTEND=noninteractive +ls +echo "dpkg -i $linux_addin_deb" +dpkg -i $linux_addin_deb +echo "Finished, $linux_addin_name installed into PATH=/opt/analog/cces-linux-add-in/${linux_addin_vesion}/ARM/arm-none-eabi/bin/" +########################################################################################## + +##################### Get source codes(u-boot & buildroot) form linu-add-in ############ +echo "Start to unzip the source-code to workspace, Installing..." +source_code_path=$2 +tar -zxvf /opt/analog/cces-linux-add-in/${linux_addin_version}/buildroot-sc5xx-${linux_addin_version}/src/buildroot-sc5xx-${linux_addin_version}.tar.gz -C ${source_code_path} +tar -zxvf /opt/analog/cces-linux-add-in/${linux_addin_version}/uboot-sc5xx-${linux_addin_version}/src/uboot-sc5xx-${linux_addin_version}.tar.gz -C ${source_code_path} +echo "Finished, source-code{uboot & buildroot} in the PATH=${source_code_path}" + +#Apply the patch for automake of buildroot +echo "Apply the patch for automake of buildroot" +patch=$3 +cp ${patch} ${source_code_path}/buildroot/package/automake/ +##########################################################################################
\ No newline at end of file diff --git a/CorOS-dev-environment/install_toolchain.sh b/CorOS-dev-environment/install_toolchain.sh new file mode 100644 index 0000000..d4a5465 --- /dev/null +++ b/CorOS-dev-environment/install_toolchain.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# Original toolchain download is broken, debian package can't be unpacked. +# This is the /opt/analog folder from the debian package. +curl -LO https://www.roelj.com/qc/qc-compiler-toolchain.tar.gz +cd / +tar axvf $1/qc-compiler-toolchain.tar.gz
\ No newline at end of file diff --git a/CorOS-dev-environment/qt-compiled-4.8.7.tar.gz b/CorOS-dev-environment/qt-compiled-4.8.7.tar.gz Binary files differnew file mode 100644 index 0000000..8b8658c --- /dev/null +++ b/CorOS-dev-environment/qt-compiled-4.8.7.tar.gz diff --git a/CorOS-dev-environment/update-builder.sh b/CorOS-dev-environment/update-builder.sh new file mode 100644 index 0000000..ab4e8b9 --- /dev/null +++ b/CorOS-dev-environment/update-builder.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +# This script can be used to apply OpenCortex patches to a mounted QC file system +# And create a new update file from it + +# This script is intended to be run from the QC-dev-environment directory +BLUE='\033[0;34m' +NC='\033[0m' # No Color + +echo "${BLUE}========= OpenCortex Update Builder =========${NC}" + +cd /qc-fs-uncompressed + +echo "" +echo "${BLUE}[+]${NC} Building update file..." +echo "" +tar cvf update-opencortex.bin rootfs.ext3 uImage zpu.dtb +echo "" +echo "This can take some seconds, please wait..." +gzip -k update-opencortex.bin +cp update-opencortex.bin.gz /qc-fs/update-opencortex.bin.gz +echo "" +echo "${BLUE}[+]${NC} Update file created: update-opencortex.bin.gz"
\ No newline at end of file |