diff --git a/.gitignore b/.gitignore index a7ae7c8..1731038 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ *.dtbo **/.vscode **/__pycache__/** +image_builder/audiomini/DistroBlueprint.xml diff --git a/Jenkinsfile b/Jenkinsfile index c54a2bf..e61b762 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,6 +25,19 @@ pipeline build job: 'Frost_Edge' } } + stage ('Image Builder - Audio Mini') + { + when { + anyOf { + changeset "image_builder/frost_usd_card_blueprint.xml" + changeset "image_builder/audiomini/*" + } + } + steps + { + build job: 'audiomini-linux-image' + } + } stage('Frost Root File System') { when { changeset "rootfs/*"} diff --git a/ReadMe.md b/ReadMe.md index 2ae2e1b..62aa541 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -2,15 +2,25 @@ FrOST Utilities ## Folder Structure - |-- frost_edge # Frost Edge Packager - |-- packaging # Packaging Files - |-- debian # Debian Packaging Files - |-- scripts # Frost Edge Scripts - |-- frost_edge.service # Frost Edge Service that calls frost_edge.sh on boot - |-- frost_edge.sh # Bash Script that starts the web app and node server - |-- makefile # Makefile to build the package - |-- Jenkinsfile # Jenkins File to build the package - |-- Install.md # Installation Steps + |-- frost_edge # Frost Edge Packager + |-- packaging # Packaging Files + |-- debian # Debian Packaging Files + |-- scripts # Frost Edge Scripts + |-- frost_edge.service # Frost Edge Service that calls frost_edge.sh on boot + |-- frost_edge.sh # Bash Script that starts the web app and node server + |-- makefile # Makefile to build the package + |-- Jenkinsfile # Jenkins File to build the package + |-- Install.md # Installation Steps + + |-- image_builder # Files and Scripts required to build the FrOST Linux Images + |-- audiomini # Files specific to the Audio Mini + |-- build_audiomini_image.sh # Bash Script to build the Audio Mini Linux Image + |-- docker_build_audiomini.sh # Bash Script to build the Audio Mini Image with Docker + |-- Dockerfile # Dockerfile to define the Docker Container + |-- Jenkinsile # Jenkins Build Script + |-- ReadMe.md # Audio Mini Linux Image Build Instructions + |-- frost_usd_card_blueprint.xml # The FrOST uSD Card Partition Structure + |-- README.md # Image Builder Read Me |-- json # MATLAB Functions to Read and Write JSON Files |-- readjson.m diff --git a/image_builder/README.md b/image_builder/README.md new file mode 100644 index 0000000..1867062 --- /dev/null +++ b/image_builder/README.md @@ -0,0 +1,17 @@ +# FrOST Linux Image Builder +The FrOST Linux Image Builder utility provide a simple way to generate a new uSD Linux Image for the various FrOST Hardware. The build script will check the local system for the required files and download the missing files from the FrOST Release S3 Bucket. More details about the specific builds can be found in the hardware folders. + +## Generated Images + - [Audio Mini](https://frost-release.s3-us-west-2.amazonaws.com/linux-images/audio-mini-image.zip) + +## Image Builder Folder Structure + |-- audiomini # Files specific to the Audio Mini + |-- build_audiomini_image.sh # Bash Script to build the Audio Mini Linux Image + |-- docker_build_audiomini.sh # Bash Script to build the Audio Mini Image with Docker + |-- Dockerfile # Dockerfile to define the Docker Container + |-- Jenkinsile # Jenkins Build Script + |-- ReadMe.md # Audio Mini Linux Image Build Instructions + |-- frost_usd_card_blueprint.xml # The FrOST uSD Card Partition Structure + |-- README.md # Image Builder Read Me + + diff --git a/image_builder/audiomini/Dockerfile b/image_builder/audiomini/Dockerfile new file mode 100644 index 0000000..b97273e --- /dev/null +++ b/image_builder/audiomini/Dockerfile @@ -0,0 +1,22 @@ +# Define the Container - Ubuntu 20.04 +FROM ubuntu:focal +# Update the Packages +RUN apt-get update +# Install the required packages for the Audio Mini Build Script +RUN apt install \ + # WGET to download the artifcats from S3 + wget \ + # Sudo to run the build script + sudo \ + # Git to clone the Linux Builder Repo + git \ + # Python3 to run the Linux Builder Python Script + python3 \ + # dosfstools installs mkfs.vfat which is used in the image creation + dosfstools -y +# Copy the local files into the container +COPY * /tmp/ +# Set the working directory to the location of the files +WORKDIR /tmp +# Set the entry point as the Build Audio Mini Script +ENTRYPOINT ["/bin/bash","./build_audiomini_image.sh"] diff --git a/image_builder/audiomini/Jenkinsfile b/image_builder/audiomini/Jenkinsfile new file mode 100644 index 0000000..f490919 --- /dev/null +++ b/image_builder/audiomini/Jenkinsfile @@ -0,0 +1,88 @@ +pipeline +{ + agent none + stages + { + stage ('Ubuntu_20.04.1') + { + agent {label 'Ubuntu_20.04.1'} + stages + { + stage('Copy Audio Mini Passthrough RBF') + { + steps + { + copyArtifacts filter: 'soc_system.rbf', fingerprintArtifacts: true, projectName: 'DE10_AudioMini_Passthrough', selector: lastSuccessful(), target: 'image_builder/audiomini/' + } + } + + stage('Copy Frost Linux Kernel') + { + steps + { + copyArtifacts filter: 'zImage', fingerprintArtifacts: true, projectName: 'Linux_Kernel', selector: lastSuccessful(), target: 'image_builder/audiomini/' + } + } + + stage('Copy Audio Mini uBoot') + { + steps + { + copyArtifacts filter: 'u-boot.scr', fingerprintArtifacts: true, projectName: 'audiomini-uboot', selector: lastSuccessful(), target: 'image_builder/audiomini/' + copyArtifacts filter: 'u-boot.img', fingerprintArtifacts: true, projectName: 'audiomini-uboot', selector: lastSuccessful(), target: 'image_builder/audiomini/' + } + } + + stage('Copy Audio Mini Preloader') + { + steps + { + copyArtifacts filter: 'audiomini_preloader.bin', fingerprintArtifacts: true, projectName: 'audiomini-preloader', selector: lastSuccessful(), target: 'image_builder/audiomini/' + } + } + + stage('Copy Frost Root File System') + { + steps + { + copyArtifacts filter: 'frost_rootfs.tar.gz', fingerprintArtifacts: true, projectName: 'Frost_RootFS', selector: lastSuccessful(), target: 'image_builder/audiomini/' + } + } + + stage('Build Audio Mini Linux Image') + { + steps + { dir("image_builder/audiomini") + { + sh 'chmod +x docker_build_audiomini.sh;' + sh './docker_build_audiomini.sh;' + } + } + } + + stage('Archive') + { + steps + { + dir("image_builder/audiomini/") + { + sh 'zip audio-mini-image.zip audio-mini.img' + archiveArtifacts artifacts: 'audio-mini-image.zip', fingerprint: true + } + } + } + + stage('Cleanup') + { + steps + { + deleteDir() + dir("${workspace}@tmp") { + deleteDir() + } + } + } + } + } + } +} \ No newline at end of file diff --git a/image_builder/audiomini/ReadMe.md b/image_builder/audiomini/ReadMe.md new file mode 100644 index 0000000..27553d7 --- /dev/null +++ b/image_builder/audiomini/ReadMe.md @@ -0,0 +1,24 @@ +# Audio Mini Linux Image Builder +The Audio Mini Linux Image Builder generates the complete Audio Mini uSD Card Image using Docker and the [Linux Boot Image File Generator](https://github.com/fpga-open-speech-tools/LinuxBootImageFileGenerator) + +## Key Files +- `build_audiomini_image.sh` - The Audio Mini Image Build Script + - Checks for and downloads the required files from the FrOST Release S3 Bucket + - Runs the Linux Boot Image File Generator Python Script +- `docker_build_audiomini.sh` - The Docker Build Script + - Copies the `frost_usd_card_blueprint.xml` into the current folder + - Runs the Docker Container +- `Dockerfile` + - Defines the Docker Container + - Copies all of the files from the current folder in the Docker Container + - Run `build_audiomini_image.sh` +- `Jenkinsfile` + - Automation of the build process using Jenkins + +## Building the Audio Mini Linux Image with Docker +1. Install [Docker for Windows](https://docs.docker.com/docker-for-windows/install/) +2. Open Windows Subsystem for Linux and Navigate to `[FrOST Repos]\utils\image_builder\audiomini` +3. Make the Docker Build Script executable by running + - `chmod +x docker_build_audiomini.sh` +4. Run the Docker Build - Audio Mini Bash Script with + - `./docker_build_audiomini.sh` \ No newline at end of file diff --git a/image_builder/audiomini/build_audiomini_image.sh b/image_builder/audiomini/build_audiomini_image.sh new file mode 100644 index 0000000..f858248 --- /dev/null +++ b/image_builder/audiomini/build_audiomini_image.sh @@ -0,0 +1,87 @@ +#!/bin/bash +# Clone the LinuxBootImageFileGenerator Repo +git clone https://github.com/fpga-open-speech-tools/LinuxBootImageFileGenerator.git + +# Copy DistroBlueprint.xml into LinuxBootImageFileGenerator +cp DistroBlueprint.xml LinuxBootImageFileGenerator/; + +# Make the Image_partitions/Pat_1_vfat Folder +mkdir -p LinuxBootImageFileGenerator/Image_partitions/Pat_1_vfat/; + +# Check for the Audio Mini DTB +if [ -f soc_system.dtb ]; then + echo 'Using the local Audio Mini DTB.' +else + echo 'Downloading the Audio Mini DTB from S3 Archive' + wget https://frost-release.s3-us-west-2.amazonaws.com/linux-images/artifacts/audiomini/soc_system.dtb +fi +cp soc_system.dtb LinuxBootImageFileGenerator/Image_partitions/Pat_1_vfat/; + +# Check for the Audio Mini Raw Binary File +if [ -f soc_system.rbf ]; then + echo 'Using the local Audio Mini RBF.' +else + echo 'Downloading the Audio Mini RBF from S3 Archive' + wget https://frost-release.s3-us-west-2.amazonaws.com/linux-images/artifacts/audiomini/soc_system.rbf +fi +cp soc_system.rbf LinuxBootImageFileGenerator/Image_partitions/Pat_1_vfat/; + +# Check for the zImage +if [ -f zImage ]; then + echo 'Using the local zImage.' +else + echo 'Downloading the zImage from S3 Archive' + wget https://frost-release.s3-us-west-2.amazonaws.com/linux-images/artifacts/common/zImage +fi +cp zImage LinuxBootImageFileGenerator/Image_partitions/Pat_1_vfat/; + +# Check for the Audio Mini uBoot Source +if [ -f u-boot.scr ]; then + echo 'Using the local Audio Mini uBoot Source.' +else + echo 'Downloading the Audio Mini uBoot Source from S3 Archive' + wget https://frost-release.s3-us-west-2.amazonaws.com/linux-images/artifacts/audiomini/u-boot.scr +fi +cp u-boot.scr LinuxBootImageFileGenerator/Image_partitions/Pat_1_vfat/; + +# Check for the Audio Mini uBoot Image +if [ -f u-boot.img ]; then + echo 'Using the local Audio Mini uBoot Image.' +else + echo 'Downloading the Audio Mini uBoot Image from S3 Archive' + wget https://frost-release.s3-us-west-2.amazonaws.com/linux-images/artifacts/audiomini/u-boot.img +fi +cp u-boot.img LinuxBootImageFileGenerator/Image_partitions/Pat_1_vfat/; + +# Make the Image_partitions/Pat_3_raw Folder +mkdir -p LinuxBootImageFileGenerator/Image_partitions/Pat_3_raw; +# Check for the Audio Mini Preloader +if [ -f audiomini_preloader.bin ]; then + echo 'Using the local Audio Mini Preloader.' +else + echo 'Downloading the Audio Mini Preloader from S3 Archive.' + wget https://frost-release.s3-us-west-2.amazonaws.com/linux-images/artifacts/audiomini/audiomini_preloader.bin +fi +cp audiomini_preloader.bin LinuxBootImageFileGenerator/Image_partitions/Pat_3_raw; + +# Make the Image_partitions/Pat_2_ext3 Folder +mkdir -p LinuxBootImageFileGenerator/Image_partitions/Pat_2_ext3; +# Check for the Root File System +if [ -d ubuntu-base ]; then + echo 'Using the local extracted file system - ubuntu-base.' +else + if [ -f frost_rootfs.tar.gz ]; then + echo 'Using the local Root File System.' + tar -xhzvf frost_rootfs.tar.gz; + else + echo 'Downloading the FrOST Root File System from S3 Archive.' + wget https://frost-release.s3-us-west-2.amazonaws.com/linux-images/artifacts/common/frost_rootfs.tar.gz + tar -xhzvf frost_rootfs.tar.gz; + fi +fi +echo "Copying Root File System to LinuxBootImageFileGenerator/Image_partitions/Pat_2_ext3" +mv ubuntu-base/* LinuxBootImageFileGenerator/Image_partitions/Pat_2_ext3; + +cd LinuxBootImageFileGenerator; +python3 LinuxBootImageGenerator.py; +mv LinuxDistro*.img audio-mini.img; \ No newline at end of file diff --git a/image_builder/audiomini/docker_build_audiomini.sh b/image_builder/audiomini/docker_build_audiomini.sh new file mode 100644 index 0000000..7d37f27 --- /dev/null +++ b/image_builder/audiomini/docker_build_audiomini.sh @@ -0,0 +1,11 @@ +#!/bin/bash +cp ../frost_usd_card_blueprint.xml ./DistroBlueprint.xml + +# Build the Audio Mini Linux Image with Docker +project="build_audiomini_image" + +docker build -t $project . +docker run -v /dev:/dev --name $project --privileged $project +docker cp $project:/tmp/LinuxBootImageFileGenerator/audio-mini.img . +docker rm -f $project +docker rmi -f $project diff --git a/image_builder/frost_usd_card_blueprint.xml b/image_builder/frost_usd_card_blueprint.xml new file mode 100644 index 0000000..008cf22 --- /dev/null +++ b/image_builder/frost_usd_card_blueprint.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +