diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..0fc4755 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,206 @@ +name: build + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + schedule: + - cron: "0 0 * * 5" + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +jobs: + prepare_container: + runs-on: self-hosted + outputs: + uid: ${{ steps.uid_step.outputs.userid }} + gid: ${{ steps.uid_step.outputs.groupid }} + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v4 + + - name: Get user id/group + id: uid_step + run: | + echo "userid=$(id -u)" >> "$GITHUB_OUTPUT" + echo "groupid=$(id -g)" >> "$GITHUB_OUTPUT" + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + buildkitd-config: /etc/docker/cibuilder.toml + + - name: Login to Docker Registry + uses: docker/login-action@v3 + with: + registry: ciserver.ci:5000 + username: ${{ secrets.CI_CACHE_REGISTRY_LOGIN }} + password: ${{ secrets.CI_CACHE_REGISTRY_PASSWORD }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: docker + push: true + tags: ciserver.ci:5000/${{ github.repository_id }}:latest + cache-from: type=registry,ref=ciserver.ci:5000/${{ github.repository_id }}:cache + cache-to: type=registry,ref=ciserver.ci:5000/${{ github.repository_id }}:cache,mode=max + file: docker/Dockerfile + + build_images: + needs: prepare_container + runs-on: self-hosted + container: + image: ciserver.ci:5000/${{ github.repository_id }}:latest + credentials: + username: ${{ secrets.CI_CACHE_REGISTRY_LOGIN }} + password: ${{ secrets.CI_CACHE_REGISTRY_PASSWORD }} + options: --user "${{ needs.prepare_container.outputs.uid }}:${{ needs.prepare_container.outputs.gid }}" + outputs: + build_tag: ${{ steps.tag_step.outputs.build_tag }} + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + submodules: true + + - name: Fetch cache from server + uses: tespkg/actions-cache/restore@v1 + with: + endpoint: ciserver.ci + port: 9000 + insecure: true + accessKey: ${{ secrets.CI_CACHE_MINIO_ACCESS }} + secretKey: ${{ secrets.CI_CACHE_MINIO_SECRET }} + bucket: cicache + use-fallback: false + key: ${{ github.repository }} + path: build/cache/cicache + + - name: Get build tag + id: tag_step + run: | + build_tag=$(date +%Y-%m-%d)_$(git rev-parse --short HEAD) + echo "build_tag=$build_tag" >> "$GITHUB_OUTPUT" + + - name: Register buildroot mirror + run: echo 'BR2_PRIMARY_SITE="http://ciserver.ci:8000/cimirror/buildroot_mirror"' >> configs/buildroot/rz-solidrun_defconfig + + - name: Build for RZ/G2LC + shell: bash + run: | + COMPRESSION_FORMAT=xz MACHINE=rzg2lc-solidrun ./runme.sh + COMPRESSION_FORMAT=xz DISTRO=debian MACHINE=rzg2lc-solidrun ./runme.sh + + - name: Build for RZ/G2L + shell: bash + run: | + COMPRESSION_FORMAT=xz MACHINE=rzg2l-solidrun ./runme.sh + COMPRESSION_FORMAT=xz DISTRO=debian MACHINE=rzg2l-solidrun ./runme.sh + + - name: Build for RZ/V2L + shell: bash + run: | + COMPRESSION_FORMAT=xz MACHINE=rzv2l-solidrun ./runme.sh + COMPRESSION_FORMAT=xz DISTRO=debian MACHINE=rzv2l-solidrun ./runme.sh + + - name: Copy deploy artifacts + shell: bash + run: | + mkdir deploy + cp images/*-bootloader-*.img deploy + cp images/*.img.xz deploy + cp images/*.img.bmap deploy + + - name: Deploy to the local minio storage + uses: yakubique/minio-upload@v1.1.3 + with: + endpoint: http://ciserver.ci:9000 + insecure: true + access_key: ${{ secrets.CI_CACHE_MINIO_ACCESS }} + secret_key: ${{ secrets.CI_CACHE_MINIO_SECRET }} + bucket: cipublish + source: ./deploy + target: "/${{ github.repository_id }}/${{ steps.tag_step.outputs.build_tag }}" + recursive: true + + - name: Update cache on the server + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + uses: tespkg/actions-cache/save@v1 + with: + endpoint: ciserver.ci + port: 9000 + insecure: true + accessKey: ${{ secrets.CI_CACHE_MINIO_ACCESS }} + secretKey: ${{ secrets.CI_CACHE_MINIO_SECRET }} + bucket: cicache + use-fallback: false + key: ${{ github.repository }} + path: build/cache/cicache + + - name: Prepare mirror + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + shell: bash + run: | + mkdir buildroot_mirror + cp -r build/cache/buildroot_dl/* buildroot_mirror + + - name: Update download mirror + uses: yakubique/minio-upload@v1.1.3 + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + with: + endpoint: http://ciserver.ci:9000 + insecure: true + access_key: ${{ secrets.CI_CACHE_MINIO_ACCESS }} + secret_key: ${{ secrets.CI_CACHE_MINIO_SECRET }} + bucket: cimirror + source: buildroot_mirror + target: "/" + recursive: true + + publish_images: + needs: build_images + runs-on: self-hosted + if: github.event_name == 'push' + steps: + - name: Download an artifacts from MinIO + uses: yakubique/minio-download@v1.1.1 + with: + endpoint: http://ciserver.ci:9000 + insecure: true + access_key: ${{ secrets.CI_CACHE_MINIO_ACCESS }} + secret_key: ${{ secrets.CI_CACHE_MINIO_SECRET }} + bucket: cipublish + source: "/${{ github.repository_id }}/${{ needs.build_images.outputs.build_tag }}/" + target: "." + recursive: true + + - name: Assign a build tag + run: | + mkdir -p debian + mkdir -p buildroot + cp deploy/*-bootloader-*.img debian + cp deploy/*-bootloader-*.img buildroot + cp deploy/*-debian-*.img.* debian + cp deploy/*-buildroot-*.img.* buildroot + + - name: Upload Debian to S3 + uses: shallwefootball/upload-s3-action@v1.3.3 + with: + aws_key_id: ${{ secrets.IMAGES_S3_ACCESS }} + aws_secret_access_key: ${{ secrets.IMAGES_S3_SECRET }} + aws_bucket: ${{ secrets.IMAGES_S3_BUCKET }} + endpoint: ${{ secrets.IMAGES_S3_HOST }} + source_dir: debian + destination_dir: RZ/Debian/${{ needs.build_images.outputs.build_tag }} + + - name: Upload Debian to S3 + uses: shallwefootball/upload-s3-action@v1.3.3 + with: + aws_key_id: ${{ secrets.IMAGES_S3_ACCESS }} + aws_secret_access_key: ${{ secrets.IMAGES_S3_SECRET }} + aws_bucket: ${{ secrets.IMAGES_S3_BUCKET }} + endpoint: ${{ secrets.IMAGES_S3_HOST }} + source_dir: debian + destination_dir: RZ/Buildroot/${{ needs.build_images.outputs.build_tag }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2da3e58..426b538 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,9 @@ -build/ +build/tmp +build/output +build/cache +build/toolchain images/ *.swp .vscode-ctags -ccache/ \ No newline at end of file +.vscode +ccache/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..d6bf56f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,16 @@ +[submodule "build/buildroot"] + path = build/buildroot + url = https://github.com/buildroot/buildroot.git +[submodule "build/linux-stable"] + path = build/linux-stable + url = https://github.com/SolidRun/linux-stable.git + shallow = true +[submodule "build/rswlan"] + path = build/rswlan + url = https://github.com/SolidRun/rswlan.git +[submodule "build/rzg_trusted-firmware-a"] + path = build/rzg_trusted-firmware-a + url = https://github.com/SolidRun/arm-trusted-firmware +[submodule "build/u-boot"] + path = build/u-boot + url = https://github.com/SolidRun/u-boot.git diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..9a9e2e5 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 SolidRun Ltd. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 0c83076..9f940b7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # build_rz -# SolidRun's RZ/G2 and RZ/V2 based build scripts +# SolidRun's RZ/G2LC, RZ/G2 and RZ/V2 based build scripts ## Introduction @@ -11,12 +11,73 @@ The build script can support two Linux distrebutions **Debian/Buildroot**. ## Source code versions - [U-boot 2021.10](https://github.com/renesas-rz/renesas-u-boot-cip/commits/v2021.10/rz) -- [Linux kernel 5.10](https://github.com/renesas-rz/rz_linux-cip/commits/rz-5.10-cip36) -- [Buildroot 2022.02.4](https://github.com/buildroot/buildroot/tree/2022.02.4) -- [Debian bullseye](https://deb.debian.org/debian) +- [Linux kernel 5.10](https://github.com/SolidRun/u-boot/tree/v2021.10/rz-sr-cip41) +- [Buildroot 2024.02.7](https://github.com/buildroot/buildroot/tree/2024.02.7) +- [Debian bookworm](https://deb.debian.org/debian) ## Get Started +### Install developement dependencies +For Debian/Ubuntu +``` +apt install git bc bison build-essential coccinelle ccache \ + device-tree-compiler dfu-util efitools flex gdisk graphviz imagemagick \ + liblz4-tool libgnutls28-dev libguestfs-tools libncurses-dev \ + libpython3-dev libsdl2-dev libssl-dev lz4 lzma lzma-alone openssl \ + pkg-config python3 python3-asteval python3-coverage python3-filelock \ + python3-pkg-resources python3-pycryptodome python3-pyelftools \ + python3-pytest python3-pytest-xdist python3-sphinxcontrib.apidoc \ + python3-sphinx-rtd-theme python3-subunit python3-testtools python3-tqdm \ + python3-virtualenv python3-libfdt swig uuid-dev u-boot-tools dosfstools \ + qemu-system-arm e2tools bmap-tools patch fakeroot debootstrap unzip rsync +``` +For Fedora +``` +dnf install git bc bison gcc gcc-c++ coccinelle ccache \ + dtc dfu-util flex gdisk graphviz ImageMagick \ + lz4 lzma xz openssl-devel openssl-devel-engine \ + pkgconfig python3 python3-asteval patch fakeroot debootstrap \ + python3-coverage python3-filelock python3-pkg-resources python3-pyelftools \ + python3-pytest python3-pytest-xdist python3-sphinxcontrib-apidoc \ + python3-sphinx_rtd_theme python3-subunit python3-testtools \ + python3-virtualenv swig uuid-devel uboot-tools e2fsprogs dosfstools \ + qemu-system-aarch64 e2tools bmap-tools python3-libfdt python3-tqdm \ + perl-open perl-English perl-ExtUtils-MakeMaker perl-Thread-Queue \ + perl-FindBin perl-IPC-Cmd unzip rsync +``` + +### Clone repo and it's submodules +``` +git clone --recurse-submodules https://github.com/SolidRun/build_rzg2lc.git +cd build_rzg2lc +``` + +### Build image +``` +MACHINE=rzg2lc-solidrun ./runme.sh +``` +Available options: +``` +Usage: MACHINE=[machine] DISTRO=[distro] ./runme.sh [build|clean] [target] +Targets: uboot atf kernel bootimage rswlan buildroot flashwriter image +Examples: + ./runme.sh # Build all targets + ./runme.sh build uboot # Build uboot only + ./runme.sh clean kernel # Clean kernel only + ./runme.sh --help # Show this help message +Available machines: +rzg2lc-solidrun (default), rzg2l-solidrun, rzv2l-solidrun +Available distros: +buildroot (default), debian +Available env vars: +MACHINE=rzg2l-solidrun - Machine name (default: rzg2lc-solidrun) +DISTRO=debian - Distro to build (default: buildroot) +CROSS_TOOLCHAIN=aarch64-linux-gnu- - Toolchain to use (default: download arm-gnu-toolchain-13.3) +ROOTFS_FREE_SIZE=1G - Extra rootfs free size (default: 100M) +COMPRESSION_FORMAT=zstd - if specified, image will be commpressed (zstd, xz, gzip) +``` +Resulted images will be located in images/ directory + ### Deploy to microSD To get started the latest binary release under the link above can be used for creating a bootable microSD card: @@ -24,13 +85,31 @@ Plug in a micro SD into your machine and run the following, where sdX is the loc ``` umount /media/ -sudo dd if=images/rzg2l*-.img of=/dev/sdX +sudo bmaptool copy images/rzg2lc*-solidrun-sd--.img /dev/sdX ``` ### Login - **username:** root - **password:** root + +### Build with Docker +A docker image providing a consistent build environment can be used as below: + +1. build container image (first time only) + ``` + docker build -t rzg2lc_build docker + # optional with an apt proxy, e.g. apt-cacher-ng + # docker build --build-arg APTPROXY=http://127.0.0.1:3142 -t rzg2lc_build docker + ``` + +2. invoke build script in working directory + ``` + docker run --rm -i -t -v "$PWD":/work rzg2lc_build -u $(id -u):$(id -g) + ./runme.sh + ``` + + --- ### Boot from SD and flash eMMC If you use **HummingBoard** Carrier board: @@ -38,23 +117,19 @@ If you use **HummingBoard** Carrier board: - install same above image on USB-DISK (for mounting the Root-FS) - connect the USB-DISK ``` -sudo dd if=images/rzxxxx_solidrun_buildroot-sd-xxxxxxx.img of=/dev/sdX bs=1M +sudo bmaptool copy images/rzxxxx_solidrun_buildroot-sd-xxxxxxx.img /dev/sdX ``` - stop it in U-Boot and run the commands below: ``` setenv bootargs 'rw rootwait earlycon root=/dev/sda2' -usb start -load usb 0:1 $kernel_addr_r boot/Image -load usb 0:1 $fdt_addr_r boot/rzxxx-hummingboard.dtb ``` -**Note:** make sure to choose the correct dtb file according to your device. - enable/select eMMC to have access in Linux ``` setenv sdio_select emmc ``` - run the U-Boot command below to boot ``` -booti $kernel_addr_r - $fdt_addr_r +run usb_boot ``` **Note:** After that step, the board will boot using the rootfs placed on the second USB drive partition. - follow the instructions in [here](https://solidrun.atlassian.net/wiki/spaces/developer/pages/476741633/HummingBoard+RZ+family+Boot+options#Flashing-bootloaders-and-rootfs-from-Linux) to flash the eMMC. @@ -165,81 +240,23 @@ tftpboot rzg2lc-hummingboard.dtb boot ``` -## Compiling Image from Source - -### Configuration Options - -The build script supports several customisation options that can be applied through environment variables: - -- INCLUDE_KERNEL_MODULES: include kernel modules in rootfs - - true (default) - - false -- DISTRO: Choose Linux distribution for rootfs - - buildroot (default) - - debian -- BUILDROOT_VERSION - - 2020.02.4 (default) -- MACHINE: Choose specific cmachine name - - rzg2lc-solidrun (default) - - rzg2l-solidrun -- BUILDROOT_DEFCONFIG: Choose specific config file name from `config/` folder - - rzg2lc-solidrun_defconfig (default) - - rzg2l-solidrun_defconfig -- BR2_PRIMARY_SITE: Use specific (local) buildroot mirror -- DEBIAN_VERSION - - bullseye (default) -- DEBIAN_ROOTFS_SIZE - - 936M (default) -- RAMFS: Choose RAMFS or normal FS - - true - - false (default) -#### Example - generating buildroot image for RZ/G2L Based platform - ``` - MACHINE=rzg2l-solidrun ./runme.sh - ``` - generating debian image for RZ/G2L Based platform - ``` - MACHINE=rzg2l-solidrun DISTRO=debian ./runme.sh - ``` - generating buildroot image for RZ/G2LC Based platform with RAMFS - ``` - MACHINE=rzg2lc-solidrun RAMFS=true ./runme.sh - ``` - -### Build with Docker -A docker image providing a consistent build environment can be used as below: - -1. build container image (first time only) - ``` - docker build -t rzg2lc_build docker - # optional with an apt proxy, e.g. apt-cacher-ng - # docker build --build-arg APTPROXY=http://127.0.0.1:3142 -t rzg2lc_build docker - ``` - -2. invoke build script in working directory - ``` - docker run --rm -i -t -v "$PWD":/work rzg2lc_build -u $(id -u) -g $(id -g) - # optional with local buildroot mirror - # docker run --rm -i -t -v "$PWD":/work -e BR2_PRIMARY_SITE=http://127.0.0.1/buildroot rzg2lc_build -u $(id -u) -g $(id -g) - ``` - -#### rootless Podman - -Due to the way podman performs user-id mapping, the root user inside the container (uid=0, gid=0) will be mapped to the user running podman (e.g. 1000:100). -Therefore in order for the build directory to be owned by current user, `-u 0 -g 0` have to be passed to *docker run*. - -### Build with host tools (on Host OS) - -Simply running `./runme.sh`, it will check for required tools, clone and build images and place results in images/ directory. -- ```MACHINE=rzg2l-solidrun DISTRO=debian ./runme.sh``` -- ```MACHINE=rzg2lc-solidrun DISTRO=buildroot ./runme.sh``` - -**Note:** This can only work on Debian-based host, and has been tested only on Ubuntu 20.04. - -## Build-Time Configuration Options - -several options influencing the build are supported by the runme script, and can be specified as environment variables for a native build, or by using the `-e` option with docker: - -- BUILDROOT_VERSION: Download and compile a specific release of buildroot -- BR2_PRIMARY_SITE: Use specific (local) buildroot mirror +## Image layout +SD card layout: +| Offset | Content | +|---------|------------------| +| 0x200 | bootparams.bin | +| 0x1000 | bl2.bin | +| 0x10000 | fip.bin | +| 0x30000 | DTS overlays | +| 0x3c000 | u-boot env | +| 8MB | fat32 boot part | +| ... | ext4 rootfs part | + +eMMC boot partition layout: +| Offset | Content | +|---------|----------------| +| 0x200 | bootparams.bin | +| ... | bl2.bin | +| 0x20000 | fip.bin | +| 0x30000 | DTS overlays | +| 0x3c000 | u-boot env | diff --git a/build/buildroot b/build/buildroot new file mode 160000 index 0000000..71f36ef --- /dev/null +++ b/build/buildroot @@ -0,0 +1 @@ +Subproject commit 71f36ef9385f860683b5c39a2c3af9f821833c5a diff --git a/build/linux-stable b/build/linux-stable new file mode 160000 index 0000000..317d77a --- /dev/null +++ b/build/linux-stable @@ -0,0 +1 @@ +Subproject commit 317d77ac69547338c57536678b8005ebcce98c76 diff --git a/build/rswlan b/build/rswlan new file mode 160000 index 0000000..c3e1759 --- /dev/null +++ b/build/rswlan @@ -0,0 +1 @@ +Subproject commit c3e175908c9cac4e7685f6851649e192b7e5c5a1 diff --git a/build/rzg_trusted-firmware-a b/build/rzg_trusted-firmware-a new file mode 160000 index 0000000..060cf08 --- /dev/null +++ b/build/rzg_trusted-firmware-a @@ -0,0 +1 @@ +Subproject commit 060cf0824eb1482427c630eb39bb1e2a30ddfc6b diff --git a/build/u-boot b/build/u-boot new file mode 160000 index 0000000..ba7618f --- /dev/null +++ b/build/u-boot @@ -0,0 +1 @@ +Subproject commit ba7618f65fdf48aa6d59a4b8f34d6d20c5371d23 diff --git a/build_scripts/assemble_bootloaders.sh b/build_scripts/assemble_bootloaders.sh new file mode 100644 index 0000000..00d9603 --- /dev/null +++ b/build_scripts/assemble_bootloaders.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +source "${ROOTDIR}/build_scripts/build_common.sh" + +do_bootloaders_configure() { + mkdir -p "${BUILDDIR_TMP_BOOT_IMAGE}" + mkdir -p "${OUTPUT_DIR_BOOT_IMAGE}" +} + +do_bootloaders_overlays_fit() { + cp ${ROOTDIR}/configs/image/overlays-fit.its ${BUILDDIR_TMP_BOOT_IMAGE} + cp ${OUTPUT_DIR_KERNEL}/sd-overlay.dtbo ${BUILDDIR_TMP_BOOT_IMAGE} + cp ${OUTPUT_DIR_KERNEL}/mmc-overlay.dtbo ${BUILDDIR_TMP_BOOT_IMAGE} + cd ${BUILDDIR_TMP_BOOT_IMAGE} + mkimage -f overlays-fit.its overlays.itb +} + +do_bootloaders_binman() { + mkdir -p ${BUILDDIR_TMP_BOOT_IMAGE}/${MACHINE} + dtc -I dts -O dtb -o ${BUILDDIR_TMP_BOOT_IMAGE}/${MACHINE}/u-boot.dtb $ROOTDIR/configs/image/binman-boot-image.dts + ${SRC_DIR_UBOOT}/tools/binman/binman -B ${BUILDDIR_TMP_BOOT_IMAGE} build \ + -I "${BUILDDIR_TMP_BOOT_IMAGE}" -I "${OUTPUT_DIR_TFA}" -O "${BUILDDIR_TMP_BOOT_IMAGE}" -b "${MACHINE}" +} + +do_bootloaders_install() { + cp "${BUILDDIR_TMP_BOOT_IMAGE}/boot_image_sd.bin" "${OUTPUT_DIR_BOOT_IMAGE}" + cp "${BUILDDIR_TMP_BOOT_IMAGE}/boot_image_mmc.bin" "${OUTPUT_DIR_BOOT_IMAGE}" + cp "${BUILDDIR_TMP_BOOT_IMAGE}/overlays.itb" "${OUTPUT_DIR_BOOT_IMAGE}" +} + +do_bootloaders_deploy() { + mkdir -p ${DEPLOY_DIR}/${MACHINE} + cp "${OUTPUT_DIR_BOOT_IMAGE}/boot_image_sd.bin" "${DEPLOY_DIR}/${MACHINE}-sd-bootloader-${REPO_PREFIX}.img" + cp "${OUTPUT_DIR_BOOT_IMAGE}/boot_image_mmc.bin" "${DEPLOY_DIR}/${MACHINE}-mmc-bootloader-${REPO_PREFIX}.img" + cp "${BUILDDIR_TMP_BOOT_IMAGE}/overlays.itb" "${DEPLOY_DIR}/${MACHINE}" + echo "Created bootloader image images/${MACHINE}-sd-bootloader-${REPO_PREFIX}.img" + echo "Created bootloader image images/${MACHINE}-mmc-bootloader-${REPO_PREFIX}.img" +} + +bootimage_clean() { + rm "${BUILDDIR_TMP_BOOT_IMAGE}"/* + rm "${OUTPUT_DIR_BOOT_IMAGE}"/* +} + +bootimage_build() { + echo "=================================" + echo "Generating Bootloader Images...." + echo "=================================" + do_bootloaders_configure + do_bootloaders_overlays_fit + do_bootloaders_binman + do_bootloaders_install + do_bootloaders_deploy +} \ No newline at end of file diff --git a/build_scripts/assemble_image.sh b/build_scripts/assemble_image.sh new file mode 100644 index 0000000..ccb1b5a --- /dev/null +++ b/build_scripts/assemble_image.sh @@ -0,0 +1,165 @@ +#!/bin/bash + +source "${ROOTDIR}/build_scripts/build_common.sh" + +IMAGE_NAME="${MACHINE}-sd-${DISTRO}-${REPO_PREFIX}.img" + +do_image_configure() { + mkdir -p "${BUILDDIR_TMP_IMAGE}" + mkdir -p "${OUTPUT_DIR_IMAGE}" +} + +do_image_clean() { + rm -rf ${BUILDDIR_TMP_IMAGE:?}/* + rm -rf ${OUTPUT_DIR_IMAGE:?}/* +} + +do_image_prepare_partitions() { + cd "${BUILDDIR_TMP_IMAGE}" + cp ${OUTPUT_DIR_BOOT_IMAGE}/boot_image_sd.bin bootloader.img + mkdir -p boot/dtb/renesas + mkdir -p boot/extlinux + cp ${OUTPUT_DIR_KERNEL}/Image.gz boot + cp ${OUTPUT_DIR_KERNEL}/dtbs/* boot/dtb/renesas + if [ -f "${OUTPUT_DIR}/${DISTRO}/initrd.img" ]; then + cp "${OUTPUT_DIR}/${DISTRO}/initrd.img" boot + fi + mkdir -p root + fakeroot tar --same-owner --exclude='./dev/*' -xpf ${OUTPUT_DIR}/${DISTRO}/rootfs.tar.gz -C root + fakeroot mkdir -p root/boot +} + +get_needed_size() { + local dir="$1" + local total_size=$(du -sb "$dir" | cut -f1) + # Calculate 30% extra space + local extra_space=$(echo "$total_size * 0.2" | bc) + # Calculate the total required size (in bytes) + local total_required_size=$(echo "$total_size + $extra_space" | bc) + # Align to 4MB blocks (4 * 1024 * 1024 bytes = 4194304 bytes) + local aligned_size=$(echo "((($total_required_size + 4194303) / 4194304)) * 4194304" | bc) + echo "$aligned_size" +} + +apply_overlay_to_rootfs() { + local overlay_path="$1" + local rootfs="$2" + find "${overlay_path}" -type f -name "*" -printf "%P\n" | e2cp -G 0 -O 0 -P 644 -s "${overlay_path}" -d "${rootfs}:/" -a +} + +set_host_name() { + echo "${MACHINE}" > ${BUILDDIR_TMP_IMAGE}/hostname + echo "127.0.0.1 localhost ${MACHINE}" > ${BUILDDIR_TMP_IMAGE}/hosts + e2cp -G 0 -O 0 ${BUILDDIR_TMP_IMAGE}/hosts ${BUILDDIR_TMP_IMAGE}/root.img:/etc/hosts + e2cp -G 0 -O 0 ${BUILDDIR_TMP_IMAGE}/hostname ${BUILDDIR_TMP_IMAGE}/root.img:/etc/hostname +} + +do_rootfs_install_additions() { + if test -d ${ROOTDIR}/overlay/${DISTRO}; then + apply_overlay_to_rootfs ${ROOTDIR}/overlay/${DISTRO} ${BUILDDIR_TMP_IMAGE}/root.img + fi + apply_overlay_to_rootfs ${ROOTDIR}/overlay/common ${BUILDDIR_TMP_IMAGE}/root.img + apply_overlay_to_rootfs ${OUTPUT_DIR_KERNEL}/modules ${BUILDDIR_TMP_IMAGE}/root.img + set_host_name +} + +do_create_root_part() { + local ROOT_PART_SIZE=$(get_needed_size "${BUILDDIR_TMP_IMAGE}/root") + local extra_size=$(numfmt --from=iec ${ROOTFS_FREE_SIZE}) + local total_size=$((ROOT_PART_SIZE+extra_size)) + truncate -s "${total_size}" "${BUILDDIR_TMP_IMAGE}/root.img" + fakeroot mkfs.ext4 -L rootfs -F -d "${BUILDDIR_TMP_IMAGE}/root" "${BUILDDIR_TMP_IMAGE}/root.img" + do_rootfs_install_additions +} + +do_create_boot_part() { + local BOOT_PART_SIZE=$(get_needed_size "${BUILDDIR_TMP_IMAGE}/boot") + truncate -s "${BOOT_PART_SIZE}" "${BUILDDIR_TMP_IMAGE}/boot.img" + mkfs.vfat -n BOOT "${BUILDDIR_TMP_IMAGE}/boot.img" + mcopy -s -i "${BUILDDIR_TMP_IMAGE}/boot.img" boot/* ::/ +} + +do_generate_extlinux() { + local PARTNUMBER=2 + local PARTUUID=$(blkid -s PTUUID -o value ${BUILDDIR_TMP_IMAGE}/${IMAGE_NAME}) + cp "${ROOTDIR}/configs/image/extlinux.conf.tmpl" ${BUILDDIR_TMP_IMAGE}/extlinux.conf + PARTUUID=${PARTUUID}'-0'${PARTNUMBER} + sed -i "s/%PARTUUID%/${PARTUUID}/g" "${BUILDDIR_TMP_IMAGE}/extlinux.conf" +} + +do_image_assemble() { + do_create_root_part + do_create_boot_part + cd ${BUILDDIR_TMP_IMAGE} + + # define partition offsets + # note: partition start and end sectors are inclusive, add/subtract 1 where appropriate + IMAGE_BOOTPART_START=8 # partition start aligned to 8MiB + IMAGE_BOOTPART_SIZE=$(stat -c "%s" boot.img) + IMAGE_BOOTPART_SIZE_M=$((IMAGE_BOOTPART_SIZE/1024/1024)) + IMAGE_BOOTPART_END=$((IMAGE_BOOTPART_START+IMAGE_BOOTPART_SIZE_M)) + IMAGE_ROOTPART_SIZE=$(stat -c "%s" root.img) + IMAGE_ROOTPART_SIZE_M=$((IMAGE_ROOTPART_SIZE/1024/1024)) + IMAGE_ROOTPART_START=${IMAGE_BOOTPART_END} + IMAGE_SIZE=$((IMAGE_BOOTPART_START+IMAGE_BOOTPART_SIZE_M+IMAGE_ROOTPART_SIZE_M+1)) + + # Create the output image, 2 partitions: 1 boot partition and one root partition + truncate -s ${IMAGE_SIZE}M $IMAGE_NAME + parted -s $IMAGE_NAME -- mklabel msdos mkpart primary fat32 ${IMAGE_BOOTPART_START}M ${IMAGE_BOOTPART_END}M mkpart primary ext4 ${IMAGE_ROOTPART_START}M 100% + do_generate_extlinux + + dd if=bootloader.img of=$IMAGE_NAME bs=512 seek=0 conv=notrunc,sparse + + # mark both partitions bootable: + sfdisk -A ${IMAGE_NAME} 1 2 + + mcopy -s -i "${BUILDDIR_TMP_IMAGE}/boot.img" extlinux.conf ::/extlinux/extlinux.conf + + + # Now find offsets in output image + FIRST_PARTITION_OFFSET=$(fdisk $IMAGE_NAME -l | grep img1 | awk '{print $3}') + SECOND_PARTITION_OFFSET=$(fdisk $IMAGE_NAME -l | grep img2 | awk '{print $3}') + + # Write boot partition into output partition + dd if=boot.img bs=512 of=$IMAGE_NAME seek=$FIRST_PARTITION_OFFSET conv=notrunc + + # write rootfs into second partition + dd if=root.img bs=512 of=$IMAGE_NAME seek=$SECOND_PARTITION_OFFSET conv=notrunc,sparse + bmaptool create ${IMAGE_NAME} > ${IMAGE_NAME}.bmap + do_image_compress +} + +do_image_compress() { + cd "${BUILDDIR_TMP_IMAGE}" + if [ -n "${COMPRESSION_FORMAT}" ]; then + if [[ ${COMPRESSION_FORMATS[*]} =~ ${COMPRESSION_FORMAT} ]]; then + echo "Compressing ${IMAGE_NAME} with ${COMPRESSION_FORMAT}" + zstd -T0 --format=${COMPRESSION_FORMAT} -k "${BUILDDIR_TMP_IMAGE}/${IMAGE_NAME}" + fi + fi +} + +do_image_install() { + cp "${BUILDDIR_TMP_IMAGE}/${IMAGE_NAME}"* "${OUTPUT_DIR_IMAGE}" +} + +do_image_deploy() { + cp "${OUTPUT_DIR_IMAGE}/${IMAGE_NAME}"* "${DEPLOY_DIR}/" + echo "Created image images/${MACHINE}-sd-${DISTRO}-${REPO_PREFIX}.img" +} + +image_clean() { + do_image_clean +} + +image_build() { + echo "=================================" + echo "Generating Images...." + echo "=================================" + do_image_configure + do_image_clean + do_image_prepare_partitions + do_image_assemble + do_image_install + do_image_deploy +} diff --git a/build_scripts/bootparams/bootparameter.c b/build_scripts/bootparams/bootparameter.c new file mode 100644 index 0000000..8df5a37 --- /dev/null +++ b/build_scripts/bootparams/bootparameter.c @@ -0,0 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2021 Renesas Electronics Corp. + * Author: Biju Das +*/ + +#include +#include +#include +#include + +off_t fsize(const char *filename) +{ + struct stat st; + if (stat(filename, &st) == 0) + return st.st_size; + return -1; +} + +int main(int argc, char *argv[]) +{ + int size, i = 0; + char val = 0xff; + if (argc <= 2) { /* argc should be 2 for correct execution */ + /* We print argv[0] assuming it is the program name */ + printf("usage: %s bl2_filename output_file_name\n", argv[0]); + return -1; + } else { + // We assume argv[1] is a filename to open + FILE *fptr; + fptr = fopen(argv[2], "wb"); + /* fopen returns 0, the NULL pointer, on failure */ + if (fptr == 0) { + printf("Could not open file\n"); + } + + size = fsize(argv[1]); + printf("size is %x\n",size); + size = (size + 3) & (~0x3); + printf("Aligned size is %x\n",size); + + fwrite(&size, 4, 1, fptr); + for(i=0;i<506; i++) + fwrite(&val, 1, 1, fptr); + val = 0x55; + fwrite(&val, 1, 1, fptr); + val = 0xAA; + fwrite(&val, 1, 1, fptr); + + fclose(fptr); + } + return 0; +} diff --git a/build_scripts/build.sh b/build_scripts/build.sh deleted file mode 100755 index 605ac7c..0000000 --- a/build_scripts/build.sh +++ /dev/null @@ -1,236 +0,0 @@ -#!/bin/bash - -#--------------------------------------------------------------------------- -# Please read the README.md file first for proper setup -#--------------------------------------------------------------------------- - -# This build script can be used to build -# * Trusted Firmware-A -# * u-boot -# * Renesas Flash Writer -# * Linux Kernel - -# Please read "Repository Installs.txt" to install the toolchains. - -# Please read "Toolchain Installs.txt" to install the toolchains. - -# The output files you need will be copied to the 'output_xxxxx' directory. xxx will be the name of your board. - -# Supported Boards -# MACHINE=smarc-rzg2lc # Renesas RZ/G2LC EVK -# MACHINE=rzg2lc-solidrun # solidrun RZ/G2LC platform - - - -#---------------------------------------------- -# Default Settings -#---------------------------------------------- -TFA_DIR_DEFAULT=rzg_trusted-firmware-a -UBOOT_DIR_DEFAULT=renesas-u-boot-cip -FW_DIR_DEFAULT=rzg2_flash_writer -KERNEL_DIR_DEFAULT=rz_linux-cip -OUT_DIR=output_${MACHINE} - -# Read in functions from build_common.sh -if [ ! -e build_common.sh ] ; then - echo -e "\n ERROR: File \"build_common.sh\" not found\n." - exit -else - source build_common.sh -fi - - -# Toolchain Selection GUI -# Since each sub-script will want to ask the user what toolchain to use, we will keep a common interface in this file. -if [ "$1" == "toolchain_select" ] ; then - - SELECT=$(whiptail --title "Toolchain setup" --menu "You may use ESC+ESC to cancel.\nEnter the command line you want to run before build.\n" 0 0 0 \ - "1 ARM gcc-arm-11.2-2022.02" " /opt/arm/gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf" \ - "0 (none)" " default -> ROOTDIR/build/toolchain/gcc-arm*" \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - case "$SELECT" in - 1\ *) - x_TOOLCHAIN_SETUP_NAME="ARM gcc-arm-10.3-2021.1" - x_TOOLCHAIN_SETUP="PATH=/opt/arm/gcc-arm-none-eabi-10.3-2021.1/bin:\$PATH ; export CROSS_COMPILE=aarch64-none-elf-" ;; - 0\ *) - x_TOOLCHAIN_SETUP_NAME="(none)" - x_TOOLCHAIN_SETUP= ;; - *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; - esac || whiptail --msgbox "There was an error running option $SELECT" 20 60 1 - fi - - # Save our replies to some tmp file so other scripts can read it - echo "x_TOOLCHAIN_SETUP_NAME=\"$x_TOOLCHAIN_SETUP_NAME\"" > /tmp/toolchain_reply.txt - echo "x_TOOLCHAIN_SETUP=\"$x_TOOLCHAIN_SETUP\"" >> /tmp/toolchain_reply.txt - - exit -fi - -# $1 = env variable to save -# $2 = value -# Remember, we we share this file with other scripts, so we only want to change -# the lines used by this script -save_setting() { - - - if [ ! -e $SETTINGS_FILE ] ; then - touch $SETTINGS_FILE # create file if does not exit - fi - - # Do not change the file if we did not make any changes - grep -q "^$1=$2$" $SETTINGS_FILE - if [ "$?" == "0" ] ; then - return - fi - - sed '/^'"$1"'=/d' -i $SETTINGS_FILE - echo "$1=$2" >> $SETTINGS_FILE - - # Delete empty or blank lines - sed '/^$/d' -i $SETTINGS_FILE - - # Sort the file to keep the same order - sort -o $SETTINGS_FILE $SETTINGS_FILE -} - - -# Save Settings to file -# Since each sub-script will want to save their settings, we will keep a common interface in this file. -if [ "$1" == "save_setting" ] ; then - - if [ "$SETTINGS_FILE" == "" ] ; then - echo -e "\nERROR: SETTINGS_FILE not set\n" - exit - fi - - # Call the function in this file - save_setting "$2" "$3" - - exit -fi - -# Setting are kept in a board.ini file. -# If you want to use a different board.in file, you can define it before you run this script -# $ export SETTINGS_FILE=my_board.ini -# $ ./build.sh - -if [ "$SETTINGS_FILE" == "" ] ; then - # If not set, use default file name - SETTINGS_FILE=board.ini - export SETTINGS_FILE=$SETTINGS_FILE - - # Read in our settings - if [ -e "$SETTINGS_FILE" ] ; then - source $SETTINGS_FILE - fi -fi - -if [ "$MACHINE" == "" ] && [ "$1" != "s" ] ; then - echo -e "\nERROR: No board selected. Please run \"./build.sh s\"\n" - exit -fi - - -#---------------------------------------------- -# Help Menu -#---------------------------------------------- -if [ "$1" == "" ] ; then - - if [ "$BOARD_VERSION" != "" ] ; then - BOARD_VERSION_TEXT="($BOARD_VERSION)" - fi - - echo "\ - -Board: $MACHINE $BOARD_VERSION_TEXT - -Please select what you want to build: - - ./build.sh f # Build Renesas Flash Writer - ./build.sh t # Build Trusted Firmware-A - ./build.sh u # Build u-boot - ./build.sh k # Build Linux Kernel - ./build.sh m # Build Linux Kernel multimedia modules - - ./build.sh s # Setup - Choose board and build options -" - exit -fi - -if [ "$1" == "t" ] ; then - ./build_tfa.sh $2 $3 $4 - exit -fi -if [ "$1" == "u" ] ; then - ./build_uboot.sh $2 $3 $4 - exit -fi -if [ "$1" == "f" ] ; then - ./build_flashwriter.sh $2 $3 $4 - exit -fi -if [ "$1" == "k" ] ; then - ./build_kernel.sh $2 $3 $4 - exit -fi -if [ "$1" == "m" ] ; then - ./build_mm.sh $2 $3 $4 - exit -fi - - -if [ "$1" == "s" ] ; then - - # Check for required Host packages - check_packages - - SELECT=$(whiptail --title "Board Selection" --menu "You may use ESC+ESC to cancel." 0 0 0 \ - "1 rzg2lc-solidrun" "Solidrun RZ/G2LC" \ - "2 smarc-rzg2lc" "Renesas SMARC RZ/G2LC" \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - BOARD_VERSION="" # Clear out BOARD_VERSION in case there is not one - case "$SELECT" in - 1\ *) FW_BOARD=RZG2LC_SOLIDRUN ; MACHINE=rzg2lc-solidrun ;; - 2\ *) FW_BOARD=RZG2LC_SMARC ; MACHINE=smarc-rzg2lc ;; - *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; - esac || whiptail --msgbox "There was an error running option $SELECT" 20 60 1 - else - # canceled - exit - fi - - # Clear out the current settings file - echo "" > $SETTINGS_FILE - - # Select common toolchain - whiptail --msgbox "Please select a Toolchain" 0 0 0 - select_toolchain "COMMON_TOOLCHAIN_SETUP_NAME" "COMMON_TOOLCHAIN_SETUP" - save_setting COMMON_TOOLCHAIN_SETUP_NAME "\"$COMMON_TOOLCHAIN_SETUP_NAME\"" - save_setting COMMON_TOOLCHAIN_SETUP "\"$COMMON_TOOLCHAIN_SETUP\"" - - # Save our default directories - save_setting TFA_DIR $TFA_DIR_DEFAULT - save_setting UBOOT_DIR $UBOOT_DIR_DEFAULT - save_setting FW_DIR $FW_DIR_DEFAULT - save_setting KERNEL_DIR $KERNEL_DIR_DEFAULT - - # The board - save_setting MACHINE $MACHINE - save_setting OUT_DIR output_${MACHINE} - save_setting BOARD_VERSION $BOARD_VERSION - - # Set defaults for Flash Writer script - save_setting FW_BOARD $FW_BOARD - - # Set defaults for Flash Writer script - if [ "$MACHINE" == "smarc-rzg2lc" ] || [ "$MACHINE" == "rzg2lc-solidrun" ]; then - save_setting TFA_FIP 1 - else - save_setting TFA_FIP 0 - fi - -fi diff --git a/build_scripts/build_atf.sh b/build_scripts/build_atf.sh new file mode 100755 index 0000000..0935228 --- /dev/null +++ b/build_scripts/build_atf.sh @@ -0,0 +1,59 @@ +#!/bin/bash +source "${ROOTDIR}/build_scripts/build_common.sh" + +TFA_BUILD_TYPE="release" +# TFA_BUILD_TYPE="debug" + +TFA_UBOOT_BIN="${OUTPUT_DIR_UBOOT}/u-boot.bin" + +atf_do_configure() { + set_ccache atf + mkdir -p "${BUILDDIR_TMP_TFA}" + mkdir -p "${OUTPUT_DIR_TFA}" +} + +atf_do_compile() { + cd "${SRC_DIR_TFA}" + local debug=0 + if [ $TFA_BUILD_TYPE = "debug" ]; then + debug=1 + fi + CROSS_COMPILE=${CROSS_TOOLCHAIN} BUILD_BASE=${BUILDDIR_TMP_TFA} make -j "${MAKE_JOBS}" bl2 bl31 fip \ + PLAT="${TFA_PLATFORM}" BOARD="${TFA_BOARD}" BL33=${TFA_UBOOT_BIN} FIP_ALIGN=16 \ + RZG_DRAM_ECC_FULL=0 DEBUG=$debug +} + +atf_create_bootparams() { + gcc "${BUILDSCRIPT_DIR}/bootparams/bootparameter.c" -o "${BUILDDIR_TMP_TFA}/bootparameter" + chmod +x "${BUILDDIR_TMP_TFA}/bootparameter" + ${BUILDDIR_TMP_TFA}/bootparameter ${BUILDDIR_TMP_TFA}/${TFA_PLATFORM}/${TFA_BUILD_TYPE}/bl2.bin ${BUILDDIR_TMP_TFA}/${TFA_PLATFORM}/${TFA_BUILD_TYPE}/bootparams.bin + cat ${BUILDDIR_TMP_TFA}/${TFA_PLATFORM}/${TFA_BUILD_TYPE}/bootparams.bin ${BUILDDIR_TMP_TFA}/${TFA_PLATFORM}/${TFA_BUILD_TYPE}/bl2.bin > ${BUILDDIR_TMP_TFA}/${TFA_PLATFORM}/${TFA_BUILD_TYPE}/bl2_bp.bin +} + +atf_do_install() { + cp "${BUILDDIR_TMP_TFA}/${TFA_PLATFORM}/${TFA_BUILD_TYPE}/bl2.bin" "${OUTPUT_DIR_TFA}" + cp "${BUILDDIR_TMP_TFA}/${TFA_PLATFORM}/${TFA_BUILD_TYPE}/fip.bin" "${OUTPUT_DIR_TFA}" + cp "${BUILDDIR_TMP_TFA}/${TFA_PLATFORM}/${TFA_BUILD_TYPE}/bootparams.bin" "${OUTPUT_DIR_TFA}" + cp "${BUILDDIR_TMP_TFA}/${TFA_PLATFORM}/${TFA_BUILD_TYPE}/bl2_bp.bin" "${OUTPUT_DIR_TFA}" +} + +atf_do_deploy() { + mkdir -p ${DEPLOY_DIR}/${MACHINE} + cp "${OUTPUT_DIR_TFA}"/* ${DEPLOY_DIR}/${MACHINE} +} + +atf_clean() { + rm -rf "${BUILDDIR_TMP_TFA}"/* + rm -rf -p "${OUTPUT_DIR_TFA}"/* +} + +atf_build() { + echo "=================================" + echo "Generating TF-A...." + echo "=================================" + atf_do_configure + atf_do_compile + atf_create_bootparams + atf_do_install + atf_do_deploy +} diff --git a/build_scripts/build_buildroot.sh b/build_scripts/build_buildroot.sh new file mode 100644 index 0000000..4ebf148 --- /dev/null +++ b/build_scripts/build_buildroot.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +source "${ROOTDIR}/build_scripts/build_common.sh" + +BUILDROOT_DEFCONFIG="rz-solidrun_defconfig" +BUILDROOT_DEFCONFIG_PATH="${ROOTDIR}/configs/buildroot" +BUILDROOT_CACHE_FILE="${BUILDDIR_TMP_BUILDROOT}/buildroot.hash" +BUILDROOT_DL_DIR="${CACHE_DIR}/buildroot_dl" + +buildroot_do_configure() { + set_ccache buildroot + mkdir -p "${BUILDDIR_TMP_BUILDROOT}" + mkdir -p "${OUTPUT_DIR_BUILDROOT}" + cp "${BUILDROOT_DEFCONFIG_PATH}/${BUILDROOT_DEFCONFIG}" "${SRC_DIR_BUILDROOT}/configs" + if [ "$USE_CCACHE" == "true" ]; then + echo "BR2_CCACHE=y" >> ${SRC_DIR_BUILDROOT}/configs/${BUILDROOT_DEFCONFIG} + echo "BR2_CCACHE_DIR=$CCACHE_DIR" >> ${SRC_DIR_BUILDROOT}/configs/${BUILDROOT_DEFCONFIG} + fi +} + +buildroot_calc_hash() { + local sha + sha="$( (cat "${BUILDROOT_DEFCONFIG_PATH}/${BUILDROOT_DEFCONFIG}"; echo -n "${CROSS_TOOLCHAIN}") | sha256sum | awk '{print $1}')" + echo "$sha" +} + +buildroot_check_cache() { + if [[ ! -f "${BUILDDIR_TMP_BUILDROOT}/images/rootfs.tar.gz" || ! -f "${BUILDDIR_TMP_BUILDROOT}/images/initrd.img" || ! -f "${BUILDROOT_CACHE_FILE}" ]]; then + echo "false" + return + elif [[ "$(buildroot_calc_hash)" == "$(cat ${BUILDROOT_CACHE_FILE})" ]]; then + echo "true" + return + fi + echo "false" +} + +buildroot_store_cache() { + buildroot_calc_hash > "${BUILDROOT_CACHE_FILE}" +} + +buildroot_do_compile() { + cd "${SRC_DIR_BUILDROOT}" + export BR2_DL_DIR=${BUILDROOT_DL_DIR} + make O="${BUILDDIR_TMP_BUILDROOT}" "${BUILDROOT_DEFCONFIG}" --silent + make O="${BUILDDIR_TMP_BUILDROOT}" -j "${MAKE_JOBS}" --silent +} + +buildroot_make_initramfs() { + mkimage -A arm64 -O linux -T ramdisk -C gzip -d "${BUILDDIR_TMP_BUILDROOT}/images/rootfs.cpio.gz" "${BUILDDIR_TMP_BUILDROOT}/images/initrd.img" +} + +buildroot_do_install() { + cp "${BUILDDIR_TMP_BUILDROOT}/images/rootfs.tar.gz" "${OUTPUT_DIR_BUILDROOT}" + cp "${BUILDDIR_TMP_BUILDROOT}/images/initrd.img" "${OUTPUT_DIR_BUILDROOT}" + buildroot_store_cache +} + +buildroot_clean() { + rm -rf "${OUTPUT_DIR_BUILDROOT}" + rm -rf "${BUILDDIR_TMP_BUILDROOT}" + rm -rf ${BUILDROOT_DL_DIR} + buildroot_do_configure +} + +buildroot_build() { + echo "=================================" + echo "Generating Buildroot...." + echo "=================================" + buildroot_do_configure + # Only rebuild rootfs if defconfig or toolchain were changed + if [[ "$(buildroot_check_cache)" == "true" ]]; then + echo "Skipping cached buildroot" + else + buildroot_do_compile + buildroot_make_initramfs + fi + buildroot_do_install +} diff --git a/build_scripts/build_common.sh b/build_scripts/build_common.sh index 581b6fe..ea9985e 100755 --- a/build_scripts/build_common.sh +++ b/build_scripts/build_common.sh @@ -1,115 +1,47 @@ #!/bin/bash -######################################################### -# This file contains functions common to all the scripts -# Each script sour 'source' this file at the beginning. -######################################################### +BUILDDIR="${ROOTDIR}/build" +BUILDDIR_TMP="${BUILDDIR}/tmp" +OUTPUT_DIR="${BUILDDIR}/output/${MACHINE}" +DEPLOY_DIR="${ROOTDIR}/images" +CACHE_DIR="${BUILDDIR}/cache" +MAKE_JOBS=$(getconf _NPROCESSORS_ONLN) -# Toolchain Selection GUI -# Since each sub-script will want to ask the user what toolchain to use, we will keep a common interface in this file. -# $1 = env variable to save TOOLCHAIN_SETUP_NAME -# $2 = env variable to save TOOLCHAIN_SETUP -select_toolchain() { +SRC_DIR_UBOOT="${BUILDDIR}/u-boot" +BUILDDIR_TMP_UBOOT="${BUILDDIR_TMP}/u-boot/${MACHINE}" +OUTPUT_DIR_UBOOT="${OUTPUT_DIR}/u-boot" - SELECT=$(whiptail --title "Toolchain setup" --menu "You may use ESC+ESC to cancel.\nEnter the command line you want to run before build.\n" 0 0 0 \ - "1 ARM gcc-arm-11.2-2022.02" " /opt/arm/gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf" \ - "0 (none)" " default -> ROOTDIR/build/toolchain/gcc-arm*" \ - 3>&1 1>&2 2>&3) +SRC_DIR_TFA="${BUILDDIR}/rzg_trusted-firmware-a" +BUILDDIR_TMP_TFA="${BUILDDIR_TMP}/tfa/${MACHINE}" +OUTPUT_DIR_TFA="${OUTPUT_DIR}/tfa" - RET=$? - if [ $RET -eq 0 ] ; then - case "$SELECT" in - 1\ *) - x_TOOLCHAIN_SETUP_NAME="ARM gcc-arm-10.3-2021.1" - x_TOOLCHAIN_SETUP="PATH=/opt/arm/gcc-arm-none-eabi-10.3-2021.1/bin:\$PATH ; export CROSS_COMPILE=aarch64-none-elf-" ;; - 0\ *) - x_TOOLCHAIN_SETUP_NAME="(none)" - x_TOOLCHAIN_SETUP= ;; - *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; - esac || whiptail --msgbox "There was an error running option $SELECT" 20 60 1 - fi +SRC_DIR_KERNEL="${BUILDDIR}/linux-stable" +BUILDDIR_TMP_KERNEL="${BUILDDIR_TMP}/kernel" +OUTPUT_DIR_KERNEL="${OUTPUT_DIR}/kernel" - DO_SET="export $1=\"$x_TOOLCHAIN_SETUP_NAME\"" - eval "$DO_SET" +SRC_DIR_RSWLAN="${BUILDDIR}/rswlan" +BUILDDIR_TMP_RSWLAN="${BUILDDIR_TMP}/rswlan" +OUTPUT_DIR_RSWLAN="${OUTPUT_DIR}/rswlan" - DO_SET="export $2=\"$x_TOOLCHAIN_SETUP\"" - DO_SET=$(echo "$DO_SET" | sed s/\$PATH/\\\\\$PATH/) # Keep $PATH from being expanded - eval "$DO_SET" -} - - -read_setting() { - if [ -e "$SETTINGS_FILE" ] ; then - source "$SETTINGS_FILE" - else - echo -e "\nERROR: Settings file ($SETTINGS_FILE) not found." - exit - fi -} - -# $1 = env variable to save -# $2 = value -# Remember, we we share this file with other scripts, so we only want to change -# the lines used by this script -save_setting() { - - - if [ ! -e $SETTINGS_FILE ] ; then - touch $SETTINGS_FILE # create file if does not exit - fi - - # Do not change the file if we did not make any changes - grep -q "^$1=$2$" $SETTINGS_FILE - if [ "$?" == "0" ] ; then - return - fi - - sed '/^'"$1"'=/d' -i $SETTINGS_FILE - echo "$1=$2" >> $SETTINGS_FILE - - # Delete empty or blank lines - sed '/^$/d' -i $SETTINGS_FILE - - # Sort the file to keep the same order - sort -o $SETTINGS_FILE $SETTINGS_FILE -} +BUILDDIR_TMP_BOOT_IMAGE="${BUILDDIR_TMP}/boot_image/${MACHINE}" +OUTPUT_DIR_BOOT_IMAGE="${OUTPUT_DIR}/boot_image" -# Check for required Host packages -# If a package is missing, then kill the script (exit) -check_packages() { +SRC_DIR_BUILDROOT="${BUILDDIR}/buildroot" +BUILDDIR_TMP_BUILDROOT="${BUILDDIR_TMP}/buildroot" +OUTPUT_DIR_BUILDROOT="${OUTPUT_DIR}/buildroot" - MISSING_A_PACKAGE=0 - PACKAGE_LIST=(git make gcc g++ python3 bison flex) +BUILDDIR_TMP_DEBIAN="${BUILDDIR_TMP}/debian" +OUTPUT_DIR_DEBIAN="${OUTPUT_DIR}/debian" - for i in ${PACKAGE_LIST[@]} ; do - CHECK=$(which $i) - if [ "$CHECK" == "" ] ; then - echo "ERROR: Missing host package: $i" - MISSING_A_PACKAGE=1 - fi - done - CHECK=$(dpkg -l 'libncurses5-dev' | grep '^ii') - if [ "$CHECK" == "" ] ; then - MISSING_A_PACKAGE=1 - fi +BUILDDIR_TMP_IMAGE="${BUILDDIR_TMP}/image/${MACHINE}" +OUTPUT_DIR_IMAGE="${OUTPUT_DIR}/image" - # File /usr/include/openssl/sha.h is required to build Trusted Firmware-A - CHECK=$(dpkg -l 'libssl-dev' | grep '^ii') - if [ "$CHECK" == "" ] ; then - MISSING_A_PACKAGE=1 - fi +OUTPUT_DIR_FLASHWRITER="${BUILDDIR}/output/flashwriter" - if [ "$MISSING_A_PACKAGE" != "0" ] ; then - echo "ERROR: Missing mandatory host packages" - echo "Please make sure the following packages are installed on your machine." - echo " ${PACKAGE_LIST[@]} libncurses5-dev libncursesw5-dev libssl-dev" - echo "" - echo "The following command line will ensure all packages are installed." - echo "" - echo " sudo apt-get install ${PACKAGE_LIST[@]} libncurses5-dev libncursesw5-dev" - echo "" - exit 1 - fi +set_ccache() { + local ccache_dir="${CACHE_DIR}/ccache/$1" + mkdir -p $ccache_dir + export CCACHE_DIR=$ccache_dir } diff --git a/build_scripts/build_debian.sh b/build_scripts/build_debian.sh new file mode 100644 index 0000000..bc45893 --- /dev/null +++ b/build_scripts/build_debian.sh @@ -0,0 +1,104 @@ +#!/bin/bash +source "${ROOTDIR}/build_scripts/build_common.sh" + +DEBIAN_CACHE_FILE="${BUILDDIR_TMP_DEBIAN}/debian.hash" +DEBIAN_ROOT_CONF="${ROOTDIR}/configs/debian/config.sh" +DEBIAN_ROOT_STAGE2="${ROOTDIR}/configs/debian/stage2.sh" + +debian_do_configure() { + mkdir -p "${BUILDDIR_TMP_DEBIAN}" + mkdir -p "${OUTPUT_DIR_DEBIAN}" +} + +debian_calc_hash() { + local sha + sha1="$(sha256sum ${DEBIAN_ROOT_CONF} | awk '{print $1}')" + echo "$sha1$sha2" +} + +debian_check_cache() { + if [[ ! -f "${BUILDDIR_TMP_DEBIAN}/rootfs.tar.gz" || ! -f "${DEBIAN_CACHE_FILE}" ]]; then + echo "false" + return + elif [[ "$(debian_calc_hash)" == "$(cat ${DEBIAN_CACHE_FILE})" ]]; then + echo "true" + return + fi + echo "false" +} + +debian_store_cache() { + debian_calc_hash > "${DEBIAN_CACHE_FILE}" +} + +debian_do_debootstrap() { + cd "${BUILDDIR_TMP_DEBIAN}" + source ${DEBIAN_ROOT_CONF} + fakeroot debootstrap --variant=minbase \ + --arch=arm64 --components=main,contrib,non-free \ + --foreign \ + --include=${DEBIAN_PACKAGES} \ + ${DEBIAN_RELEASE} \ + rootfs \ + ${DEBIAN_MIRROR} + cp ${DEBIAN_ROOT_STAGE2} rootfs/stage2.sh + chmod +x rootfs/stage2.sh +} + +debian_do_stage2() { + cd "${BUILDDIR_TMP_DEBIAN}" + truncate -s 2G "${BUILDDIR_TMP_DEBIAN}/rootfs.img" + mkfs.ext2 -F -d "${BUILDDIR_TMP_DEBIAN}/rootfs" "${BUILDDIR_TMP_DEBIAN}/rootfs.img" + qemu-system-aarch64 \ + -m 1G \ + -M virt \ + -cpu cortex-a57 \ + -smp 4 \ + -netdev user,id=eth0 \ + -device virtio-net-device,netdev=eth0 \ + -drive file=rootfs.img,if=none,format=raw,id=hd0 \ + -device virtio-blk-device,drive=hd0 \ + -nographic \ + -no-reboot \ + -kernel "${OUTPUT_DIR_KERNEL}/Image" \ + -append "console=ttyAMA0 root=/dev/vda rootfstype=ext2 ip=dhcp rw init=/stage2.sh" + +} + +debian_do_pack() { + cd "${BUILDDIR_TMP_DEBIAN}" + mkdir -p "${BUILDDIR_TMP_DEBIAN}/rootfs_tmp" + fakeroot debugfs -R "rdump / ${BUILDDIR_TMP_DEBIAN}/rootfs_tmp" rootfs.img + tar -czf "${BUILDDIR_TMP_DEBIAN}/rootfs.tar.gz" -C "${BUILDDIR_TMP_DEBIAN}/rootfs_tmp" . +} + +debian_do_install() { + cp "${BUILDDIR_TMP_DEBIAN}/rootfs.tar.gz" "${OUTPUT_DIR_DEBIAN}" + debian_store_cache +} + +debian_do_clean() { + rm -rf "${BUILDDIR_TMP_DEBIAN:?}"/* + rm -rf "${OUTPUT_DIR_DEBIAN:?}"/* +} + +debian_clean() { + debian_do_clean +} + +debian_build() { + echo "=================================" + echo "Generating Debian...." + echo "=================================" + # Only rebuild rootfs if defconfig or toolchain were changed + debian_do_configure + if [[ "$(debian_check_cache)" == "true" ]]; then + echo "Skipping cached debian" + else + debian_do_clean + debian_do_debootstrap + debian_do_stage2 + debian_do_pack + fi + debian_do_install +} diff --git a/build_scripts/build_flashwriter.sh b/build_scripts/build_flashwriter.sh new file mode 100644 index 0000000..316a4e3 --- /dev/null +++ b/build_scripts/build_flashwriter.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +source "${ROOTDIR}/build_scripts/build_common.sh" + +FW_SR_IMAGES_URI="https://images.solid-run.com/RZ/FlashWriter" + +fw_devices=("RZG2LC" "RZG2UL" "RZG2L" "RZV2L") +fw_mem=("512MB_1PCS" "1GB_1PCS" "2GB_1PCS") + +fw_configure() { + mkdir -p "${OUTPUT_DIR_FLASHWRITER}" +} + +fw_fetch() { + cd "${OUTPUT_DIR_FLASHWRITER}" + local filename + for fw_device in "${fw_devices[@]}"; do + for fw_mem_size in "${fw_mem[@]}"; do + filename="Flash_Writer_SCIF_${fw_device}_HUMMINGBOARD_DDR4_${fw_mem_size}.mot" + if [[ ! -f "$filename" ]]; then + echo "Fetching $filename" + wget -q "${FW_SR_IMAGES_URI}/$filename" -O "$filename" & + fi + done + done + wait +} + +fw_deploy() { + mkdir -p ${DEPLOY_DIR}/flashwriter + cp "${OUTPUT_DIR_FLASHWRITER}"/*.mot ${DEPLOY_DIR}/flashwriter +} + + +flashwriter_clean() { + rm "${OUTPUT_DIR_FLASHWRITER}"/* +} + +flashwriter_build() { + echo "=================================" + echo "Fetching flashwriter...." + echo "=================================" + fw_configure + fw_fetch + fw_deploy +} + diff --git a/build_scripts/build_kernel.sh b/build_scripts/build_kernel.sh new file mode 100644 index 0000000..94ac8dd --- /dev/null +++ b/build_scripts/build_kernel.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +source "${ROOTDIR}/build_scripts/build_common.sh" + +KERNEL_DEFCONFIG="rz-solidrun_defconfig" +KERNEL_DEFCONFIG_PATH="${ROOTDIR}/configs/linux" + +kernel_do_configure() { + set_ccache kernel + mkdir -p "${BUILDDIR_TMP_KERNEL}" + mkdir -p "${OUTPUT_DIR_KERNEL}" + cp "${KERNEL_DEFCONFIG_PATH}/${KERNEL_DEFCONFIG}" "${SRC_DIR_KERNEL}/arch/arm64/configs" +} + +kernel_do_compile() { + cd "${SRC_DIR_KERNEL}" + CROSS_COMPILE=${CROSS_TOOLCHAIN} ARCH=arm64 make O="${BUILDDIR_TMP_KERNEL}" "${KERNEL_DEFCONFIG}" + CROSS_COMPILE=${CROSS_TOOLCHAIN} ARCH=arm64 DTC_FLAGS="-@" make O="${BUILDDIR_TMP_KERNEL}" -j "${MAKE_JOBS}" Image Image.gz dtbs modules +} + +kernel_do_install() { + mkdir -p "${OUTPUT_DIR_KERNEL}/dtbs" + cp "${BUILDDIR_TMP_KERNEL}/arch/arm64/boot/Image" "${OUTPUT_DIR_KERNEL}" + cp "${BUILDDIR_TMP_KERNEL}/arch/arm64/boot/Image.gz" "${OUTPUT_DIR_KERNEL}" + cp ${BUILDDIR_TMP_KERNEL}/arch/arm64/boot/dts/renesas/rz*hummingboard*.dtb "${OUTPUT_DIR_KERNEL}/dtbs" + cp ${BUILDDIR_TMP_KERNEL}/arch/arm64/boot/dts/renesas/rz*overlay*.dtbo "${OUTPUT_DIR_KERNEL}/dtbs" + + cd ${OUTPUT_DIR_KERNEL} + ln -sf ${OUTPUT_DIR_KERNEL}/dtbs/${KERNEL_OVERLAYS_PREFIX}-solidrun-sd-overlay.dtbo sd-overlay.dtbo + ln -sf ${OUTPUT_DIR_KERNEL}/dtbs/${KERNEL_OVERLAYS_PREFIX}-solidrun-mmc-overlay.dtbo mmc-overlay.dtbo + rm -rf ${OUTPUT_DIR_KERNEL}/modules + mkdir -p ${OUTPUT_DIR_KERNEL}/modules + cd "${SRC_DIR_KERNEL}" + CROSS_COMPILE=${CROSS_TOOLCHAIN} ARCH=arm64 make O="${BUILDDIR_TMP_KERNEL}" -j "${MAKE_JOBS}" INSTALL_MOD_PATH="${OUTPUT_DIR_KERNEL}/modules" modules_install + KRELEASE=$(make --silent O="${BUILDDIR_TMP_KERNEL}" kernelrelease) + echo "${KRELEASE}" > ${OUTPUT_DIR_KERNEL}/kernelrelease +} + +kernel_do_deploy() { + mkdir -p ${DEPLOY_DIR}/${MACHINE} + cp "${OUTPUT_DIR_KERNEL}/Image.gz" "${DEPLOY_DIR}/${MACHINE}" + cp -r "${OUTPUT_DIR_KERNEL}/dtbs" "${DEPLOY_DIR}/${MACHINE}" +} + +kernel_clean() { + rm -rf "${OUTPUT_DIR_KERNEL}"/* + cd ${SRC_DIR_KERNEL} + CROSS_COMPILE=${CROSS_TOOLCHAIN} ARCH=arm64 make O="${BUILDDIR_TMP_KERNEL}" -j "${MAKE_JOBS}" mrproper +} + +kernel_build() { + echo "=================================" + echo "Generating Kernel...." + echo "=================================" + kernel_do_configure + kernel_do_compile + kernel_do_install + kernel_do_deploy +} diff --git a/build_scripts/build_rswlan.sh b/build_scripts/build_rswlan.sh new file mode 100755 index 0000000..b3ec5b4 --- /dev/null +++ b/build_scripts/build_rswlan.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +source "${ROOTDIR}/build_scripts/build_common.sh" + +rswlan_do_compile() { + cd "${SRC_DIR_RSWLAN}" + CROSS_COMPILE=${CROSS_TOOLCHAIN} ARCH=arm64 make -j ${MAKE_JOBS} KDIR="${BUILDDIR_TMP_KERNEL}" CONFIG_MODULE_TYPE=spi +} + +rswlan_do_install() { + local kernelrel=$(cat ${OUTPUT_DIR_KERNEL}/kernelrelease) + install -v -m644 -D ${SRC_DIR_RSWLAN}/rswlan.ko "${OUTPUT_DIR_KERNEL}/modules/lib/modules/${kernelrel}/extra/rswlan.ko" + depmod -b "${OUTPUT_DIR_KERNEL}/modules" -F "${BUILDDIR_TMP_KERNEL}/System.map" ${kernelrel} +} + +rswlan_clean() { + cd "${SRC_DIR_RSWLAN}" + CROSS_COMPILE=${CROSS_TOOLCHAIN} ARCH=arm64 make -j ${MAKE_JOBS} KDIR="${BUILDDIR_TMP_KERNEL}" clean +} + + + +rswlan_build() { + echo "=================================" + echo "Generating RSWLAN...." + echo "=================================" + rswlan_do_compile + rswlan_do_install +} diff --git a/build_scripts/build_tfa.sh b/build_scripts/build_tfa.sh deleted file mode 100755 index 60e93bb..0000000 --- a/build_scripts/build_tfa.sh +++ /dev/null @@ -1,565 +0,0 @@ -#!/bin/bash - -#--------------------------------------------------------------------------- -# Please read the README.md file first for proper setup -#--------------------------------------------------------------------------- - -# MACHINE=rzg2lc-solidrun -# MACHINE=smarc-rzg2lc - -#TFA_BOOT: 0=SPI Flash, 1=eMMC -#TFA_ECC_FULL: 0=no ECC, 1=ECC dual channel, 2=ECC single channel -#TFA_FIP: 0=no FIP, 1= yes FIP - -# Read in functions from build_common.sh -if [ ! -e build_common.sh ] ; then - echo -e "\n ERROR: File \"build_common.sh\" not found\n." - exit -else - source build_common.sh -fi - -# Read our settings (board.ini) or whatever file SETTINGS_FILE was set to -read_setting - -if [ "$MACHINE" == "" ] ; then - echo "You need to set MACHINE first" - exit -fi - -############################## -# Defaults -############################## -if [ "$TFA_BOOT" == "" ] ; then - TFA_BOOT=0 -fi -if [ "$TFA_ECC_FULL" == "" ] ; then - TFA_ECC_FULL=0 -fi -if [ "$TFA_LOG_LEVEL" == "" ] ; then - TFA_LOG_LEVEL=20 -fi -if [ "$TFA_DEBUG" == "" ] ; then - TFA_DEBUG=0 -fi -if [ "$TFA_FIP" == "" ] ; then - - if [ "$MACHINE" == "smarc-rzg2lc" ] || [ "$MACHINE" == "rzg2lc-solidrun" ] ; then - TFA_FIP=1 - else - TFA_FIP=0 - fi -fi - - -############################### -# Trusted Firmware Version -############################## - -# Get version number from Makefile -TFA_VERSION_MAJOR=`grep "^VERSION_MAJOR" $TFA_DIR/Makefile | awk '{print $3}'` -TFA_VERSION_MINOR=`grep "^VERSION_MINOR" $TFA_DIR/Makefile | awk '{print $3}'` -TFA_VERSION="$TFA_VERSION_MAJOR.$TFA_VERSION_MINOR" -#echo TFA_VERSION=$TFA_VERSION - -# Some setting names switched from RZG_xx to RCAR_xxx after the code mainlined for release 2.5 since the -# same code alrady exists for R-Car in mainline, so they just used the same names -if [ "$TFA_VERSION" \< "2.5" ] ; then - TFA_BEFORE_2_5="1" -fi - -############################### -# Text strings -############################## -BOOT_TEXT_STR=("SPI Flash" "eMMC Flash") -ECC_TEXT_STR=("no ECC" "ECC dual channel" "ECC single channel") -DEBUG_STR=("Release Build" "Debug Build") - - -############################## -do_toolchain_menu() { - select_toolchain "TFA_TOOLCHAIN_SETUP_NAME" "TFA_TOOLCHAIN_SETUP" -} - - -############################## -do_boot_menu() { - SELECT=$(whiptail --title "Boot Flash Selection" --menu "You may use ESC+ESC to cancel.\n\nA Blank entry means use default board settings." 0 0 0 \ - "1 ${BOOT_TEXT_STR[0]}" "" \ - "2 ${BOOT_TEXT_STR[1]}" "" \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - case "$SELECT" in - 1\ *) TFA_BOOT=0 ;; - 2\ *) TFA_BOOT=1 ;; - *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; - esac || whiptail --msgbox "There was an error running option $SELECT" 20 60 1 - fi -} - -############################## -do_ecc_menu() { - SELECT=$(whiptail --title "ECC Selection" --menu "You may use ESC+ESC to cancel.\n\nA Blank entry means use default board settings." 0 0 0 \ - "1 ${ECC_TEXT_STR[0]}" "" \ - "2 ${ECC_TEXT_STR[1]}" "" \ - "3 ${ECC_TEXT_STR[2]}" "" \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - case "$SELECT" in - 1\ *) TFA_ECC_FULL=0 ;; - 2\ *) TFA_ECC_FULL=1 ;; - 3\ *) TFA_ECC_FULL=2 ;; - *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; - esac || whiptail --msgbox "There was an error running option $SELECT" 20 60 1 - fi -} - -############################## -do_log_menu() { - SELECT=$(whiptail --title "Log Level Selection" --menu "You may use ESC+ESC to cancel.\n\nA Blank entry means use default board settings." 0 0 0 \ - "0" " No functions output logs" \ - "10" "ERROR()" \ - "20" "ERROR(), NOTICE()" \ - "30" "ERROR(), NOTICE(), WARN()" \ - "40" "ERROR(), NOTICE(), WARN(), INFO()" \ - "50" "ERROR(), NOTICE(), WARN(), INFO(), VERBOSE()" \ - "default" "Use Makefile default" \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - case "$SELECT" in - 0) TFA_LOG_LEVEL=0 ;; - 10) TFA_LOG_LEVEL=10 ;; - 20) TFA_LOG_LEVEL=20 ;; - 30) TFA_LOG_LEVEL=30 ;; - 40) TFA_LOG_LEVEL=40 ;; - 50) TFA_LOG_LEVEL=50 ;; - default) TFA_LOG_LEVEL=20 ;; - *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; - esac || whiptail --msgbox "There was an error running option $SELECT" 20 60 1 - fi -} - -############################## -do_debug_menu() { - SELECT=$(whiptail --title "Debug Selection" --menu "You may use ESC+ESC to cancel.\n\nA Blank entry means use default board settings." 0 0 0 \ - "1 ${DEBUG_STR[0]}" "" \ - "2 ${DEBUG_STR[1]}" "(Add debug symbols to build)" \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - case "$SELECT" in - 1\ *) TFA_DEBUG=0 ;; - 2\ *) TFA_DEBUG=1 ;; - *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; - esac || whiptail --msgbox "There was an error running option $SELECT" 20 60 1 - fi -} - - -############################## -create_bootparams() { - - # Create bootparams.bin - # - bootparams.bin totls size is 512 bytes - # - First 4 bytes is the size of bl2.bin (4-byte aligned) - # - Last 2 bytes are 0x55, 0xAA - # - Middle of the file is 0xFF - - if [ "$TFA_DEBUG" == "1" ] ; then - cd build/${PLATFORM}/debug - else - cd build/${PLATFORM}/release - fi - - echo -e "\n[Creating bootparams.bin]" - SIZE=$(stat -L --printf="%s" bl2.bin) - SIZE_ALIGNED=$(expr $SIZE + 3) - SIZE_ALIGNED2=$((SIZE_ALIGNED & 0xFFFFFFFC)) - SIZE_HEX=$(printf '%08x\n' $SIZE_ALIGNED2) - echo " bl2.bin size=$SIZE, Aligned size=$SIZE_ALIGNED2 (0x${SIZE_HEX})" - STRING=$(echo \\x${SIZE_HEX:6:2}\\x${SIZE_HEX:4:2}\\x${SIZE_HEX:2:2}\\x${SIZE_HEX:0:2}) - printf "$STRING" > bootparams.bin - for i in `seq 1 506` ; do printf '\xff' >> bootparams.bin ; done - printf '\x55\xaa' >> bootparams.bin - - # Combine bootparams.bin and bl2.bin into single binary - # Only if a new version of bl2.bin is created - if [ "bl2.bin" -nt "bl2_bp.bin" ] || [ ! -e "bl2_bp.bin" ] ; then - echo -e "\n[Adding bootparams.bin to bl2.bin]" - cat bootparams.bin bl2.bin > bl2_bp.bin - fi - - cd ../../.. -} - -############################## -create_fip_and_copy() { - - if [ "$TFA_DEBUG" == "1" ] ; then - BUILD_DIR=debug - else - BUILD_DIR=release - fi - - # Build the Fip Tool - echo -e "\n[Building FIP tool]" - cd tools/fiptool - make PLAT=${PLATFORM} - cd ../.. - - EXTRA="" - - # RZ/G2L PMIC board have _pmic at the end of the filename - if [ "$MACHINE" == "rzg2l-som" ] && [ "$BOARD_VERSION" == "PMIC" ] ; then - EXTRA="_pmic" - fi - - echo -e "[Create fip.bin]" - tools/fiptool/fiptool create --align 16 --soc-fw build/${PLATFORM}/$BUILD_DIR/bl31.bin --nt-fw ../$OUT_DIR/u-boot.bin fip.bin - cp fip.bin ../$OUT_DIR/fip-${MACHINE}${EXTRA}.bin - - echo -e "[Copy BIN file]" - cp -v build/${PLATFORM}/$BUILD_DIR/bl2_bp.bin ../$OUT_DIR/bl2_bp-${MACHINE}${EXTRA}.bin - - echo -e "[Copy BIN file (no boot parameters)]" - cp -v build/${PLATFORM}/$BUILD_DIR/bl2.bin ../$OUT_DIR/bl2-${MACHINE}${EXTRA}.bin - - echo -e "[Copy boot parameters]" - cp -v build/${PLATFORM}/$BUILD_DIR/bootparams.bin ../$OUT_DIR/bootparams-${MACHINE}${EXTRA}.bin - - echo -e "[Convert BIN to SREC format]" - # - ${CROSS_COMPILE}objcopy -I binary -O srec --adjust-vma=0x00011E00 --srec-forceS3 build/${PLATFORM}/$BUILD_DIR/bl2_bp.bin ../$OUT_DIR/bl2_bp-${MACHINE}${EXTRA}.srec - - # - ${CROSS_COMPILE}objcopy -I binary -O srec --adjust-vma=0x00000000 --srec-forceS3 fip.bin ../$OUT_DIR/fip-${MACHINE}${EXTRA}.srec -} - - -# Use common toolchain if specific toolchain not set -if [ "$TFA_TOOLCHAIN_SETUP_NAME" == "" ] ; then - if [ "$COMMON_TOOLCHAIN_SETUP_NAME" != "" ] ; then - TFA_TOOLCHAIN_SETUP_NAME=$COMMON_TOOLCHAIN_SETUP_NAME - TFA_TOOLCHAIN_SETUP=$COMMON_TOOLCHAIN_SETUP - else - whiptail --msgbox "Please select a Toolchain" 0 0 0 - do_toolchain_menu - fi -fi - -############################## -# GUI -############################## -# If no arguments passed, use GUI interface -if [ "$1" == "" ] ; then - - while true ; do - - # In case of no setting, display as 'default' - if [ "$TFA_BOOT" == "" ] ; then BOOT_TEXT="(default)" ; else BOOT_TEXT="${BOOT_TEXT_STR[$TFA_BOOT]}" ; fi - if [ "$TFA_LOG_LEVEL" == "" ] ; then LOG_TEXT="(default)" ; else LOG_TEXT="$TFA_LOG_LEVEL" ; fi - if [ "$TFA_ECC_FULL" == "" ] ; then ECC_TEXT="(default)" ; else ECC_TEXT="${ECC_TEXT_STR[$TFA_ECC_FULL]}" ; fi - - if [ "$BOARD_VERSION" != "" ] ; then - BOARD_VERSION_TEXT="($BOARD_VERSION)" - else - BOARD_VERSION_TEXT="" - fi - - SELECT=$(whiptail --title "Trusted Firmware-A Configuration" --menu "Select your build options.\nYou may use [ESC]+[ESC] to cancel/exit.\nUse [Tab] key to select buttons at the bottom.\n\nUse the button (or enter) to make changes.\nUse the button to start the build." 0 0 0 --cancel-button Build --ok-button Change \ - "1. Select your board:" " $MACHINE $BOARD_VERSION_TEXT"\ - "2. Boot Device:" " $BOOT_TEXT" \ - "3. TFA_ECC_FULL:" " $ECC_TEXT" \ - "4. Log Level:" " $TFA_LOG_LEVEL" \ - "5. Build:" " ${DEBUG_STR[$TFA_DEBUG]}" \ - "6. Toolchain setup:" " $TFA_TOOLCHAIN_SETUP_NAME" \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 1 ] ; then - # Save to our settings file - save_setting TFA_BOOT "$TFA_BOOT" - save_setting TFA_ECC_FULL "$TFA_ECC_FULL" - save_setting TFA_LOG_LEVEL "$TFA_LOG_LEVEL" - save_setting TFA_DEBUG "$TFA_DEBUG" - save_setting TFA_FIP "$TFA_FIP" - if [ "$TFA_TOOLCHAIN_SETUP_NAME" != "$COMMON_TOOLCHAIN_SETUP_NAME" ] ; then - save_setting TFA_TOOLCHAIN_SETUP_NAME "\"$TFA_TOOLCHAIN_SETUP_NAME\"" - save_setting TFA_TOOLCHAIN_SETUP "\"$TFA_TOOLCHAIN_SETUP\"" - fi - break; - elif [ $RET -eq 0 ] ; then - case "$SELECT" in - 1.\ *) echo "" ;; - 2.\ *) do_boot_menu ;; - 3.\ *) do_ecc_menu ;; - 4.\ *) do_log_menu ;; - 5.\ *) do_debug_menu ;; - 6.\ *) do_toolchain_menu ;; - *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; - esac || whiptail --msgbox "There was an error running option $SELECT" 20 60 1 - else - exit 1 - fi - - done -fi - - -# As for GCC 4.9, you can get a colorized output -export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' - -# Find out how many CPU processor cores we have on this machine -# so we can build faster by using multithreaded builds -NPROC=2 -if [ "$(which nproc)" != "" ] ; then # make sure nproc is installed - NPROC=$(nproc) -fi -BUILD_THREADS=$(expr $NPROC + $NPROC) - - -echo "cd $TFA_DIR" -cd $TFA_DIR - -if [ "$TFA_FIP" == "1" ] && [ ! -e "../$OUT_DIR/u-boot.bin" ] ; then - echo -e "\nERROR: You must build u-boot first since it is added to the BL31/FIP image". - exit -fi - - -# ECC and video decompression settings -if [ "$TFA_ECC_FULL" != "0" ] ; then - G2E_ECC="LIFEC_DBSC_PROTECT_ENABLE=0 RZG_DRAM_ECC=1" - G2M_ECC="LIFEC_DBSC_PROTECT_ENABLE=0 RCAR_DRAM_SPLIT=0 RZG_DRAM_ECC=1" - G2N_ECC="LIFEC_DBSC_PROTECT_ENABLE=0 RZG_DRAM_ECC=1" - G2H_ECC="LIFEC_DBSC_PROTECT_ENABLE=0 RCAR_DRAM_SPLIT=0 RZG_DRAM_ECC=1" -else - # If ECC is not set, we will assume that we want to reserve a - # Lossy Decompression area for multimedia. - G2E_LOSSY="" # not needed for RZ/G2E - G2M_LOSSY="RCAR_LOSSY_ENABLE=1" - G2N_LOSSY="RCAR_LOSSY_ENABLE=1" - G2H_LOSSY="RCAR_LOSSY_ENABLE=1" -fi - -# Board Settings -case "$MACHINE" in - - "rzg2lc-solidrun"|"rzg2lc-som"|"rzg2lc-hummingboard") - PLATFORM=g2l - TFA_OPT="BOARD=smarc_1" - - TOOL= - ;; - - "smarc-rzg2lc") - PLATFORM=g2l - TFA_OPT="BOARD=smarc_1" - - TOOL= - ;; - - "smarc-rzg2l") - - # Old directory structure - if [ -e plat/renesas/rzg2l/platform.mk ] ; then - PLATFORM=rzg2l - # "BOARD_RZG2L_EVA" was renamed to "RZG2L_SMARC_EVK" - # "BOARD_RZG2L_15MMSQ" was renamed to "RZG2L_DEVELOPMENT_BOARD" - # "BOARD_RZG2LC_13MMSQ" was renamed to "RZG2LC_DEVELOPMENT_BOARD" - grep -q "BOARD_RZG2L_EVA" plat/renesas/rzg2l/platform.mk - if [ "$?" == "0" ] ; then - # old - TFA_OPT="BOARD_TYPE=BOARD_RZG2L_EVA" - #TFA_OPT="BOARD_TYPE=BOARD_RZG2L_15MMSQ" - #TFA_OPT="BOARD_TYPE=BOARD_RZG2LC_13MMSQ" - else - # new - TFA_OPT="BOARD_TYPE=RZG2L_SMARC_EVK" - #TFA_OPT=BOARD_TYPE=RZG2L_DEVELOPMENT_BOARD" - #TFA_OPT=BOARD_TYPE=RZG2LC_DEVELOPMENT_BOARD" - fi - fi - - # New directory structure - if [ -e plat/renesas/rz ] ; then - PLATFORM=g2l - if [ "$BOARD_VERSION" == "PMIC" ] ; then - TFA_OPT="BOARD=smarc_pmic_2" - else - TFA_OPT="BOARD=smarc_2" - fi - - # Internal Renesas Boards - #TFA_OPT="BOARD=dev15_4" #rzg2l-dev - #TFA_OPT="BOARD=dev13_1" #rzg2lc-dev - fi - - #PLATFORM=g2l - TOOL= - ;; - -esac - -# For eMMC boot, you need to set RCAR_SA6_TYPE=1 -if [ "$TFA_BOOT" == "1" ] ; then - TFA_OPT="$TFA_OPT RCAR_SA6_TYPE=1" -fi - -# MBED is required for VLP v1.0.5+ -if [ "$PLATFORM" == "rzg" ] && [ "$MBEDTLS_DIR" == "" ] ; then - if [ -e mbedtls ] ; then - MBEDTLS_DIR=mbedtls - elif [ -e ../mbedtls ] ; then - MBEDTLS_DIR=../mbedtls - else - echo "ERROR: You need to have the mbed TLS repo to build" - exit - fi -fi - -# For versions before v2.5, RZG_ was used for some settings instead of RCAR_ -if [ "${TFA_BEFORE_2_5}" ] ; then - - # RCAR_SA6_TYPE -> RZG_SA6_TYPE - TFA_OPT_NEW=$(echo $TFA_OPT | sed 's/RCAR_SA6_TYPE/RZG_SA6_TYPE/') - TFA_OPT="$TFA_OPT_NEW" - - # RCAR_SA0_SIZE -> RZG_SA0_SIZE - TFA_OPT_NEW=$(echo $TFA_OPT | sed 's/RCAR_SA0_SIZE/RZG_SA0_SIZE/') - TFA_OPT="$TFA_OPT_NEW" - - # RCAR_DRAM_DDR3L_MEMCONF -> RZG_DRAM_DDR3L_MEMCONF - TFA_OPT_NEW=$(echo $TFA_OPT | sed 's/RCAR_DRAM_DDR3L_MEMCONF/RZG_DRAM_DDR3L_MEMCONF/') - TFA_OPT="$TFA_OPT_NEW" - - # RCAR_DRAM_DDR3L_MEMDUAL -> RZG_DRAM_DDR3L_MEMDUAL - TFA_OPT_NEW=$(echo $TFA_OPT | sed 's/RCAR_DRAM_DDR3L_MEMDUAL/RZG_DRAM_DDR3L_MEMDUAL/') - TFA_OPT="$TFA_OPT_NEW" - - # RCAR_DRAM_SPLIT -> RZG_DRAM_SPLIT - TFA_OPT_NEW=$(echo $TFA_OPT | sed 's/RCAR_DRAM_SPLIT/RZG_DRAM_SPLIT/') - TFA_OPT="$TFA_OPT_NEW" - - # RCAR_DRAM_CHANNEL -> RZG_DRAM_CHANNEL - TFA_OPT_NEW=$(echo $TFA_OPT | sed 's/RCAR_DRAM_CHANNEL/RZG_DRAM_CHANNEL/') - TFA_OPT="$TFA_OPT_NEW" - - # RCAR_RPC_HYPERFLASH_LOCKED -> RZG_RPC_HYPERFLASH_LOCKED - TFA_OPT_NEW=$(echo $TFA_OPT | sed 's/RCAR_RPC_HYPERFLASH_LOCKED/RZG_RPC_HYPERFLASH_LOCKED/') - TFA_OPT="$TFA_OPT_NEW" -fi - -# Set up Toolchain in current environment -echo "$TFA_TOOLCHAIN_SETUP" -eval $TFA_TOOLCHAIN_SETUP -if [ "$TARGET_PREFIX" == "" ] ; then - # Not using SDK (poky) toolchain (assuming Linaro) - # We need to set these before calling make (that's why makefile.linaro exists, but we don't need to use it) - export CC=${CROSS_COMPILE}gcc - export AS=${CROSS_COMPILE}as - export LD=${CROSS_COMPILE}ld - export AR=${CROSS_COMPILE}ar - export OBJDUMP=${CROSS_COMPILE}objdump - export OBJCOPY=${CROSS_COMPILE}objcopy -fi - -# Let the Makefile handle setting up the CFLAGS and LDFLAGS as it is a standalone application -unset CFLAGS -unset LDFLAGS -unset AS -unset LD - -# distclean -if [ "$1" == "" ] ; then - echo "make distclean" - make distclean -fi - -if [ "$TFA_DEBUG" == "1" ] ; then - ADD_DEBUG="DEBUG=1" - BUILD_DIR=debug -else - ADD_DEBUG= - BUILD_DIR=release -fi - -# make -CMD="make -j $BUILD_THREADS bl2 bl31 ${TOOL} PLAT=${PLATFORM} ${TFA_OPT} RZG_DRAM_ECC_FULL=${TFA_ECC_FULL} LOG_LEVEL=$TFA_LOG_LEVEL ${ADD_DEBUG} \ - MBEDTLS_DIR=$MBEDTLS_DIR \ - $1 $2 $3" -echo "$CMD" -$CMD - -# If this was just a clean, exit now -if [ ! -e "build/${PLATFORM}/$BUILD_DIR/bl2/bl2.elf" ] ; then - exit -fi - -# FIP build -if [ "$TFA_FIP" == "1" ] ; then - create_bootparams - create_fip_and_copy - - #### STOP HERE for FIP Builds #### - exit -fi - - -# Copy files to deploy folder -DEPLOYDIR=z_deploy -mkdir -p $DEPLOYDIR -cp build/${PLATFORM}/release/bl2/bl2.elf ${DEPLOYDIR}/bl2-${MACHINE}.elf -cp build/${PLATFORM}/release/bl2.bin ${DEPLOYDIR}/bl2-${MACHINE}.bin -cp build/${PLATFORM}/release/bl2.srec ${DEPLOYDIR}/bl2-${MACHINE}.srec -cp build/${PLATFORM}/release/bl31/bl31.elf ${DEPLOYDIR}/bl31-${MACHINE}.elf -cp build/${PLATFORM}/release/bl31.bin ${DEPLOYDIR}/bl31-${MACHINE}.bin -cp build/${PLATFORM}/release/bl31.srec ${DEPLOYDIR}/bl31-${MACHINE}.srec -# VLP 1.0.4 -if [ -e tools/dummy_create/bootparam_sa0.srec ] ; then - cp tools/dummy_create/bootparam_sa0.srec ${DEPLOYDIR}/bootparam_sa0.srec - cp tools/dummy_create/cert_header_sa6.srec ${DEPLOYDIR}/cert_header_sa6.srec -fi -# VLP 1.0.5+ -if [ -e tools/renesas/rzg_layout_create/bootparam_sa0.srec ] ; then - cp tools/renesas/rzg_layout_create/bootparam_sa0.srec ${DEPLOYDIR}/bootparam_sa0.srec - cp tools/renesas/rzg_layout_create/cert_header_sa6.srec ${DEPLOYDIR}/cert_header_sa6.srec -fi - -# Save what build this was -CURRENT_BRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') -echo "Built from branch \"$CURRENT_BRANCH\"" > ${DEPLOYDIR}/build_version.txt -echo -e "\nOutput files copied to directory $TFA_DIR_DEFAULT/$DEPLOYDIR\n" - -# copy to output directory -if [ -e build/${PLATFORM}/release/bl2.bin ] && [ "$OUT_DIR" != "" ] ; then - - mkdir -p ../$OUT_DIR - cp build/${PLATFORM}/release/bl2/bl2.elf ../$OUT_DIR/bl2-${MACHINE}.elf - cp build/${PLATFORM}/release/bl2.bin ../$OUT_DIR/bl2-${MACHINE}.bin - cp build/${PLATFORM}/release/bl2.srec ../$OUT_DIR/bl2-${MACHINE}.srec - cp build/${PLATFORM}/release/bl31/bl31.elf ../$OUT_DIR/bl31-${MACHINE}.elf - cp build/${PLATFORM}/release/bl31.bin ../$OUT_DIR/bl31-${MACHINE}.bin - cp build/${PLATFORM}/release/bl31.srec ../$OUT_DIR/bl31-${MACHINE}.srec - cp tools/renesas/rzg_layout_create/bootparam_sa0.srec ../$OUT_DIR/bootparam_sa0.srec - cp tools/renesas/rzg_layout_create/cert_header_sa6.srec ../$OUT_DIR/cert_header_sa6.srec - - echo -e "\nOutput files copied to output directory $OUT_DIR\n" - - # Save what this was build with - echo "MACHINE=$MACHINE" > ../$OUT_DIR/manifest_tfa.txt - echo "BOARD_VERSION=$BOARD_VERSION" > ../$OUT_DIR/manifest_tfa.txt - echo "TFA_BOOT=$TFA_BOOT" >> ../$OUT_DIR/manifest_tfa.txt - echo "TFA_LOG_LEVEL=$TFA_LOG_LEVEL" >> ../$OUT_DIR/manifest_tfa.txt - echo "TFA_ECC_FULL=$TFA_ECC_FULL" >> ../$OUT_DIR/manifest_tfa.txt - echo "TFA_TOOLCHAIN_SETUP_NAME=$TFA_TOOLCHAIN_SETUP_NAME" >> ../$OUT_DIR/manifest_tfa.txt - CURRENT_BRANCH=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p') - echo "Built from branch \"$CURRENT_BRANCH\"" >> ../$OUT_DIR/manifest_tfa.txt - - - # Use the same filenames as the Yocto output - #cp -v $OUT/u-boot.bin ../$OUT_DIR/u-boot-${MACHINE}.bin - #cp -v $OUT/u-boot.srec ../$OUT_DIR//u-boot-${MACHINE}.srec -fi diff --git a/build_scripts/build_uboot.sh b/build_scripts/build_uboot.sh index a8001cb..7be474e 100755 --- a/build_scripts/build_uboot.sh +++ b/build_scripts/build_uboot.sh @@ -1,157 +1,35 @@ #!/bin/bash -#--------------------------------------------------------------------------- -# Please read the README.md file first for proper setup -#--------------------------------------------------------------------------- +source "${ROOTDIR}/build_scripts/build_common.sh" -# PLEASE CHOOSE YOU BOARD -#MACHINE=smarc-rzg2lc # Renesas SMARC RZ/G2LC -#MACHINE=rzg2lc-solidrun # solidrun RZ/G2LC platform - -# Read in functions from build_common.sh -if [ ! -e build_common.sh ] ; then - echo -e "\n ERROR: File \"build_common.sh\" not found\n." - exit -else - source build_common.sh -fi - -# Read our settings (board.ini) or whatever file SETTINGS_FILE was set to -read_setting - -# Define the defconfigs for Renesas boards -if [ "$MACHINE" == "rzg2lc-solidrun" ] ; then DEFCONFIG=rzg2lc-solidrun_defconfig ; fi -if [ "$MACHINE" == "smarc-rzg2lc" ] ; then DEFCONFIG=smarc-rzg2lc_defconfig ; fi - -# Set the output directory (because I like all my build files separate from the source code) -OUT=.out - -# Check for MACHINE setting -if [ "$MACHINE" == "" ] ; then - echo "" - echo "ERROR: Please set MACHINE in settings file ($SETTINGS_FILE)" - echo "" - exit -fi - -do_toolchain_menu() { - select_toolchain "UBOOT_TOOLCHAIN_SETUP_NAME" "UBOOT_TOOLCHAIN_SETUP" +u_boot_do_configure() { + set_ccache uboot + mkdir -p "${BUILDDIR_TMP_UBOOT}" + mkdir -p "${OUTPUT_DIR_UBOOT}" } -# Use common toolchain if specific toolchain not set -if [ "$UBOOT_TOOLCHAIN_SETUP_NAME" == "" ] ; then - if [ "$COMMON_TOOLCHAIN_SETUP_NAME" != "" ] ; then - UBOOT_TOOLCHAIN_SETUP_NAME=$COMMON_TOOLCHAIN_SETUP_NAME - UBOOT_TOOLCHAIN_SETUP=$COMMON_TOOLCHAIN_SETUP - else - whiptail --msgbox "Please select a Toolchain" 0 0 0 - do_toolchain_menu - save_setting UBOOT_TOOLCHAIN_SETUP_NAME "\"$UBOOT_TOOLCHAIN_SETUP_NAME\"" - save_setting UBOOT_TOOLCHAIN_SETUP "\"$UBOOT_TOOLCHAIN_SETUP\"" - fi -fi - -# NOTE: You will get many warnings such as -# "warning: ISO C does not support the ‘_Float32’ type" -# "warning: ISO C does not support the ‘_Float64’ type" -# because '_GNU_SOURCE' is defined. -# tools/Makefile:# Define _GNU_SOURCE to obtain the getline prototype from stdio.h -# When '_GNU_SOURCE' is defined, '__USE_GNU' gets defined in "features.h" and "regex.h" -# When '__USE_GNU' is defined, __GLIBC_USE_IEC_60559_TYPES_EXT gets defined to 1 in "libc-header-start.h" -# When '__GLIBC_USE_IEC_60559_TYPES_EXT' is defined, _Float32 is used in "stdlib.h" - - -#PATH=/opt/linaro/gcc-linaro-7.5.0-2019.12-x86_64_aarch64-linux-gnu/bin:$PATH -#export CROSS_COMPILE="aarch64-linux-gnu-" -#export ARCH=arm64 - -# Check for Yocto SDK setup -#if [ "$TARGET_PREFIX" == "" ] && [ "$CROSS_COMPILE" == "" ] ; then -# echo "Yocto SDK environment not set up" -# echo "source /opt/poky/2.4.3/environment-setup-aarch64-poky-linux" -# exit -#fi - -echo "$UBOOT_TOOLCHAIN_SETUP" -eval $UBOOT_TOOLCHAIN_SETUP - -# As for GCC 4.9, you can get a colorized output -export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' - -# Find out how many CPU processor cores we have on this machine -# so we can build faster by using multithreaded builds -NPROC=2 -if [ "$(which nproc)" != "" ] ; then # make sure nproc is installed - NPROC=$(nproc) -fi -BUILD_THREADS=$(expr $NPROC + $NPROC) - -# Let the Makefile handle setting up the CFLAGS and LDFLAGS as it is a standalone application -unset CFLAGS -unset CPPFLAGS -unset LDFLAGS -unset AS -unset LD - -# Having these set (by the Yocto SDK) will break "menuconfig" -unset PKG_CONFIG_PATH -unset HOST_EXTRACFLAGS - -# Add '-s' for silent Build -MAKE="make -j$BUILD_THREADS O=$OUT" - -# While the Yocto SDK setup script (environment-setup-aarch64-poky-linux) sets CC, and includes -# the --sysroot parameter, we have to explictly put CC= on the make command line because of how -# the u-boot Makefile was written and looks for thigns like libgcc.a -if [ "$TARGET_PREFIX" != "" ] ; then - # Yocto SDK Toolchain build - MAKE="make CC=\""$CC"\" -j$BUILD_THREADS O=$OUT" -fi - -echo "cd $UBOOT_DIR" -cd $UBOOT_DIR - -# If this is the first time building, we need to configure first -if [ ! -e "$OUT/.config" ] ; then - - if [ "$DEFCONFIG" == "" ] ; then - echo "" - echo "ERROR: Please set DEFCONFIG in settings file ($SETTINGS_FILE)" - echo "" - exit - fi - - echo $MAKE $DEFCONFIG - eval $MAKE $DEFCONFIG -fi - -CMD="$MAKE $1 $2 $3" -echo $CMD -eval $CMD - -# Note: -# u-boot.bin is u-boot-dtb.bin (u-boot.bin + u-boot.dtb) renamed to u-boot.bin -# u-boot.srec is just u-boot (no dtb). -# u-boot-elf.srec is u-boot + dtb - -# copy to output directory -if [ -e $OUT/u-boot.bin ] && [ "$OUT_DIR" != "" ] ; then +u_boot_do_compile() { + cd "${SRC_DIR_UBOOT}" + CROSS_COMPILE=${CROSS_TOOLCHAIN} ARCH=arm64 make O="${BUILDDIR_TMP_UBOOT}" "${UBOOT_DEFCONFIG}" + CROSS_COMPILE=${CROSS_TOOLCHAIN} ARCH=arm64 make O="${BUILDDIR_TMP_UBOOT}" -j ${MAKE_JOBS} +} - echo -e "\nCopying files to output directory" - mkdir -p ../$OUT_DIR - cp -v $OUT/u-boot.bin ../$OUT_DIR - cp -v $OUT/u-boot.srec ../$OUT_DIR +u_boot_do_install() { + cp "${BUILDDIR_TMP_UBOOT}/u-boot.bin" "${OUTPUT_DIR_UBOOT}" +} - # Use the same filenames as the Yocto output - #cp -v $OUT/u-boot.bin ../$OUT_DIR/u-boot-${MACHINE}.bin - #cp -v $OUT/u-boot.srec ../$OUT_DIR//u-boot-${MACHINE}.srec -fi +uboot_clean() { + rm -rf "${OUTPUT_DIR_UBOOT}"/* + cd ${SRC_DIR_UBOOT} + CROSS_COMPILE=${CROSS_TOOLCHAIN} ARCH=arm64 make O="${BUILDDIR_TMP_UBOOT}" -j ${MAKE_JOBS} mrproper +} -# The "TFA_FIP" value comes from the settings for the Trusted Firmware-A build -if [ -e u-boot.bin ] && [ "$TFA_FIP" == "1" ] ; then - echo -e "\n\n" - echo -e "\t*****************************************************************" - echo -e "\t Please rebuild Trusted Firmware-A to package u-boot with BL31 " - echo -e "\t*****************************************************************\n" -fi +uboot_build() { + echo "=================================" + echo "Generating U-Boot...." + echo "=================================" + u_boot_do_configure + u_boot_do_compile + u_boot_do_install +} diff --git a/build_scripts/flash-writer/config_g2l.ini b/build_scripts/flash-writer/config_g2l.ini deleted file mode 100644 index 426e821..0000000 --- a/build_scripts/flash-writer/config_g2l.ini +++ /dev/null @@ -1,14 +0,0 @@ -BOARD=hummingboard-rzg2l -SERIAL_DEVICE_INTERFACE=/dev/ttyUSB0 -SERIAL_DEVICE_SPEED=115200 - -FW_PREBUILT=0 -FIP=1 -FLASH=1 -EMMC_4BIT=1 - -IMAGE_DIR=../../images - -FLASHWRITER=${IMAGE_DIR}/Flash_Writer_SCIF_RZG2L_HUMMINGBOARD_DDR4_1GB_1PCS.mot -BL2_FILE=${IMAGE_DIR}/tmp/bl2_bp-rzg2l-solidrun.bin -FIP_FILE=${IMAGE_DIR}/tmp/fip-rzg2l-solidrun.bin diff --git a/build_scripts/flash-writer/config_g2lc.ini b/build_scripts/flash-writer/config_g2lc.ini deleted file mode 100644 index 47a4bfd..0000000 --- a/build_scripts/flash-writer/config_g2lc.ini +++ /dev/null @@ -1,14 +0,0 @@ -BOARD=hummingboard-rzg2l -SERIAL_DEVICE_INTERFACE=/dev/ttyUSB0 -SERIAL_DEVICE_SPEED=115200 - -FW_PREBUILT=0 -FIP=1 -FLASH=1 -EMMC_4BIT=1 - -IMAGE_DIR=../../images - -FLASHWRITER=${IMAGE_DIR}/Flash_Writer_SCIF_RZG2LC_HUMMINGBOARD_DDR4_1GB_1PCS.mot -BL2_FILE=${IMAGE_DIR}/tmp/bl2_bp-rzg2lc-solidrun.bin -FIP_FILE=${IMAGE_DIR}/tmp/fip-rzg2lc-solidrun.bin diff --git a/build_scripts/flash-writer/flash_writer_tool.py b/build_scripts/flash-writer/flash_writer_tool.py new file mode 100755 index 0000000..dcb2853 --- /dev/null +++ b/build_scripts/flash-writer/flash_writer_tool.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python3 + +import serial +import argparse +import time +import sys +from tqdm import tqdm +import os + +def parse_args(): + parser = argparse.ArgumentParser(description='Firmware flashing tool') + parser.add_argument('--port', default='/dev/ttyUSB0', help='Serial port device') + parser.add_argument('--fw', required=True, help='Path to flashwriter .mot file') + parser.add_argument('--bl2', help='Path to bl2_bp.bin') + parser.add_argument('--fip', help='Path to fip image') + parser.add_argument('--overlays', help='Path to fit image with dts overlays') + + args = parser.parse_args() + + if not (args.bl2 or args.fip or args.overlays): + parser.error('At least one of --bl2, --fip, or --overlays must be specified') + + return args + +def open_serial(port, baudrate, timeout=1): + ser = serial.Serial(port, baudrate=baudrate, timeout=timeout) + return ser + +def send_command(ser, command, expect=None, timeout=5): + ser.write((command + '\r').encode()) + if expect: + return wait_for_prompt(ser, expect, timeout) + else: + return True + +def wait_for_prompt(ser, expect, timeout=5): + end_time = time.time() + timeout + buffer = '' + while time.time() < end_time: + data = ser.read(ser.in_waiting or 1) + if data: + decoded = data.decode(errors='ignore') + buffer += decoded + sys.stdout.write(decoded) + sys.stdout.flush() + # Clean buffer to remove carriage returns and newlines + clean_buffer = buffer.replace('\r', '').replace('\n', '') + if expect in clean_buffer: + return True + else: + time.sleep(0.1) + print(f"\nBuffer received: {repr(buffer)}") + raise Exception(f"Timeout waiting for '{expect}'") + +def send_file(ser, file_path): + file_size = os.path.getsize(file_path) + with open(file_path, 'rb') as f: + bytes_sent = 0 + with tqdm(total=file_size, unit='B', unit_scale=True, desc='Sending file') as pbar: + while True: + chunk = f.read(1024) + if not chunk: + break + ser.write(chunk) + ser.flush() + bytes_sent += len(chunk) + pbar.update(len(chunk)) + print("File transfer complete.") + +def main(): + args = parse_args() + + ser = open_serial(args.port, 115200) + + print("Please reset the board") + wait_for_prompt(ser, "please send !", timeout=30) + start_time = time.time() + print(f"Sending firmware: {args.fw}") + send_file(ser, args.fw) + send_command(ser, "", ">") + + print("Increasing baudrate to 921600") + send_command(ser, "SUP") + ser.close() + time.sleep(0.1) + ser = open_serial(args.port, 921600) + # Send newline and check for '>' + send_command(ser, "", ">") + # wait_for_prompt(ser, ">", timeout=5) + + # Function to flash binary to eMMC + def flash_binary(file_path, sector_number): + send_command(ser, "EM_WB", expect="Select area(0-2)>") + send_command(ser, "1", expect="Please Input Start Address in sector :") + sector_hex = format(sector_number, 'X') + send_command(ser, sector_hex, expect="Please Input File size(byte) : ") + file_size = os.path.getsize(file_path) + file_size_hex = format(file_size, 'X') + send_command(ser, file_size_hex, expect="please send binary file!") + print(f"Sending binary file: {file_path}") + send_file(ser, file_path) + wait_for_prompt(ser, ">", timeout=10) + + flashed = False + + if args.bl2: + print(f"\nFlashing bl2: {args.bl2}") + flash_binary(args.bl2, sector_number=1) + flashed = True + + if args.fip: + print(f"\nFlashing fip: {args.fip}") + flash_binary(args.fip, sector_number=0x100) + flashed = True + + if args.overlays: + print(f"\nFlashing overlays: {args.overlays}") + flash_binary(args.overlays, sector_number=0x1800) + flashed = True + + if flashed: + # Enable eMMC boot + send_command(ser, "EM_SECSD", expect="Please Input EXT_CSD Index(H'00 - H'1FF) :") + send_command(ser, "b3", expect="Please Input Value(H'00 - H'FF) :") + send_command(ser, "08", expect=">") + + ser.close() + print(f"\nFlashing complete in {int(time.time() - start_time)} seconds.") + +if __name__ == "__main__": + main() diff --git a/build_scripts/flash-writer/flash_writer_tool.sh b/build_scripts/flash-writer/flash_writer_tool.sh deleted file mode 100755 index 7993178..0000000 --- a/build_scripts/flash-writer/flash_writer_tool.sh +++ /dev/null @@ -1,1509 +0,0 @@ -#!/bin/bash - -# Most of this script is made of functions. -# You can search for "Script Start GUI" to find the start of execution for GUI menu -# You can search for "Script Start OPP" to find the start of execution of programming operations - -if [ "$1" == "" ] ; then - export FW_GUI_MODE=1 -fi - -# Global Settings -FIP=0 # TF-A uses FIP instead of BL31 -EMMC_4BIT=0 # eMMC uses 4-bit data, not 8-bit - -# Set BOARD_NAME and SW_SETTINGS -switch_settings() { - if [ "$BOARD" == "ek874" ] ; then - BOARD_NAME="EK874 RZ/G2E by Silicon Linux" - SW_SETTINGS="Please TURN OFF board power when changing switch settings. -Switch settings for SW12 which is placed near the micro SD card slot. - - SPI Flash boot eMMC boot - -------------- --------- - 1 = ON 1 = OFF - 2 = ON 2 = ON - 3 = ON 3 = OFF - 4 = OFF 4 = OFF - 5 = ON 5 = ON - 6 = ON 6 = ON - - SCIF Download mode USB Download mode - ------------------ ----------------- - 1 = OFF 1 = OFF - 2 = OFF 2 = OFF - 3 = OFF 3 = ON - 4 = OFF 4 = OFF - 5 = ON 5 = ON - 6 = ON 6 = ON -" - fi - - if [ "$BOARD" == "hihope-rzg2m" ] || [ "$BOARD" == "hihope-rzg2n" ] || \ - [ "$BOARD" == "hihope-rzg2h" ] ; then - - if [ "$BOARD" == "hihope-rzg2m" ] ; then BOARD_NAME="HiHope RZ/G2M by Hoperun Technology" ; fi - if [ "$BOARD" == "hihope-rzg2n" ] ; then BOARD_NAME="HiHope RZ/G2N by Hoperun Technology" ; fi - if [ "$BOARD" == "hihope-rzg2h" ] ; then BOARD_NAME="HiHope RZ/G2H by Hoperun Technology" ; fi - - SW_SETTINGS="Please TURN OFF board power when changing switch settings. -Switch settings for SW1002. - ---------- ---------- - | SW1003 | | SW1002 | << this one - ---------- ---------- - ---------- - | SW1001 | - ---------- - - SPI Flash boot eMMC boot - -------------- --------- - 1 = ON 1 = ON - 2 = ON 2 = ON - 3 = ON 3 = ON - 4 = ON 4 = ON - 5 = ON 5 = OFF - 6 = OFF 6 = OFF - 7 = ON 7 = ON - 8 = ON 8 = OFF - - SCIF Download mode USB Download mode - ------------------ ----------------- - 1 = ON 1 = ON - 2 = ON 2 = ON - 3 = ON 3 = ON - 4 = ON 4 = ON - 5 = OFF 5 = OFF - 6 = OFF 6 = OFF - 7 = OFF 7 = OFF - 8 = OFF 8 = ON -" - fi - - if [ "$BOARD" == "smarc-rzg2l" ] || [ "$BOARD" == "smarc-rzg2lc" ] || [ "$BOARD" == "smarc-rzg2ul" ] || [ "$BOARD" == "smarc-rzv2l" ] ; then - if [ "$BOARD" == "smarc-rzg2l" ] ; then - BOARD_NAME="RZ/G2L SMARC Board by Renesas" - if [ "$BOARD_VERSION" == "PMIC" ] ; then - BOARD_NAME="$BOARD (PMIC Version)" - fi - if [ "$BOARD_VERSION" == "DISCRETE" ] ; then - BOARD_NAME="$BOARD (Discrete Version)" - fi - if [ "$BOARD_VERSION" == "WS1" ] ; then - BOARD_NAME="$BOARD (WS1)" - fi - fi - if [ "$BOARD" == "smarc-rzg2lc" ] ; then - BOARD_NAME="RZ/G2LC SMARC Board by Renesas" - fi - if [ "$BOARD" == "smarc-rzg2ul" ] ; then - BOARD_NAME="RZ/G2UL SMARC Board by Renesas" - fi - if [ "$BOARD" == "smarc-rzv2l" ] ; then - BOARD_NAME="RZ/V2L SMARC Board by Renesas" - if [ "$BOARD_VERSION" == "PMIC" ] ; then - BOARD_NAME="$BOARD (PMIC Version)" - fi - if [ "$BOARD_VERSION" == "DISCRETE" ] ; then - BOARD_NAME="$BOARD (Discrete Version)" - fi - fi - - SW_SETTINGS=" - -Use switches SW11 on Carrier board to set the boot mode. - - SCIF Download Mode SPI Boot Mode eMMC Boot Mode ----------------------------------------------------------------- - SW11-1 = OFF SW11-1 = OFF SW11-1 = ON - SW11-2 = ON SW11-2 = OFF SW11-2 = OFF - SW11-3 = OFF SW11-3 = OFF SW11-3 = OFF - SW11-4 = ON SW11-4 = ON SW11-4 = ON - - +---------+ +---------+ +---------+ - | ON | | ON | | ON | - SW11 | = = | SW11 | = | SW11 | = = | - | = = | | = = = | | = = | - | 1 2 3 4 | | 1 2 3 4 | | 1 2 3 4 | - +---------+ +---------+ +---------+ -" - fi -} - -clear_filenames() { - unset FLASHWRITER - unset SA0_FILE - unset BL2_FILE - unset SA6_FILE - unset BL31_FILE - unset FIP_FILE - unset UBOOT_FILE -} - -# Use this function to determine if any config settings have changed -config_hash() { - CONFIG_HASH_RESULT=$(echo "$BOARD" \ - "$BOARD_VERSION" \ - "$FLASH" \ - "$SERIAL_DEVICE_INTERFACE" \ - "$SERIAL_DEVICE_SPEED" \ - "$FILES_DIR" \ - "$FLASHWRITER" \ - "$FW_PREBUILT" \ - "$SA0_FILE" \ - "$BL2_FILE" \ - "$SA6_FILE" \ - "$BL31_FILE" \ - "$FIP_FILE" \ - "$UBOOT_FILE" \ - | md5sum) -} - -# Use this function to determine if any app settings have changed -settings_hash() { - SETTINGS_HASH_RESULT=$(echo "$CONFIG_FILE" \ - "$NEWT_COLORS" \ - | md5sum) -} - -# Check if flash_writer binary has already been downloaded -check_fw_first() { - - unset CMD_ABORT - - if [ "$FW_NOT_DL_YET" == "1" ] ; then - ANSWER=$(whiptail --yesno --defaultno "WARNING !\n\nThe Flash writer binary has not been downloaded yet.\ -\n\nThe Flash Writer program must be downloaded and running for programming to work.\n\nContinue anyway?" 0 0 3>&1 1>&2 2>&3; echo $?) - # 0=yes, 1=no - if [ "$ANSWER" != "0" ] ; then - CMD_ABORT=1 - else - # Set to "2" so we only warn once - export FW_NOT_DL_YET=2 - fi - fi -} - -# Common settings for Renesas boards -set_filenames() { - - if [ "$BOARD" == "ek874" ] || [ "$BOARD" == "hihope-rzg2m" ] || \ - [ "$BOARD" == "hihope-rzg2n" ] || [ "$BOARD" == "hihope-rzg2h" ] ; then - - if [ "$FILES_DIR" == "" ] ; then - FILES_DIR="." - fi - if [ "$FLASHWRITER" == "" ] ; then - if [ "$BOARD" == "hihope-rzg2m" ] || [ "$BOARD" == "hihope-rzg2n" ] || [ "$BOARD" == "hihope-rzg2h" ] ; then - FLASHWRITER=$FILES_DIR/AArch64_Flash_writer_SCIF_DUMMY_CERT_E6300400_hihope.mot - else - FLASHWRITER=$FILES_DIR/AArch64_Flash_writer_SCIF_DUMMY_CERT_E6300400_${BOARD}.mot - fi - fi - if [ "$SA0_FILE" == "" ] ; then - SA0_FILE=$FILES_DIR/bootparam_sa0.srec - fi - if [ "$BL2_FILE" == "" ] ; then - BL2_FILE=$FILES_DIR/bl2-${BOARD}.bin - fi - if [ "$SA6_FILE" == "" ] ; then - SA6_FILE=$FILES_DIR/cert_header_sa6.srec - fi - if [ "$BL31_FILE" == "" ] ; then - BL31_FILE=$FILES_DIR/bl31-${BOARD}.bin - fi - if [ "$UBOOT_FILE" == "" ] ; then - #UBOOT_FILE=$FILES_DIR/u-boot-elf-${BOARD}.srec - UBOOT_FILE=$FILES_DIR/u-boot.bin - fi - fi - - if [ "$BOARD" == "smarc-rzg2l" ] || [ "$BOARD" == "smarc-rzg2lc" ] || [ "$BOARD" == "smarc-rzg2ul" ] || [ "$BOARD" == "smarc-rzv2l" ]; then - - FIP=1 - EMMC_4BIT=1 - - if [ "$FILES_DIR" == "" ] ; then - FILES_DIR="." - fi - if [ "$FLASHWRITER" == "" ] && [ "$BOARD" == "smarc-rzg2l" ]; then - if [ "$BOARD_VERSION" == "PMIC" ] ; then - FLASHWRITER="$FILES_DIR/Flash_Writer_SCIF_RZG2L_SMARC_PMIC_DDR4_2GB_1PCS.mot" - BL2_FILE=$FILES_DIR/bl2_bp-${BOARD}_pmic.srec - FIP_FILE=$FILES_DIR/fip-${BOARD}_pmic.srec - else - FLASHWRITER="$FILES_DIR/Flash_Writer_SCIF_RZG2L_SMARC_DDR4_2GB.mot" - fi - fi - if [ "$FLASHWRITER" == "" ] && [ "$BOARD" == "smarc-rzg2lc" ]; then - FLASHWRITER="$FILES_DIR/Flash_Writer_SCIF_RZG2LC_SMARC_DDR4_1GB_1PCS.mot" - fi - if [ "$FLASHWRITER" == "" ] && [ "$BOARD" == "smarc-rzg2ul" ]; then - FLASHWRITER="$FILES_DIR/Flash_Writer_SCIF_RZG2UL_SMARC_DDR4_1GB_1PCS.mot" - fi - if [ "$FLASHWRITER" == "" ] && [ "$BOARD" == "smarc-rzv2l" ]; then - if [ "$BOARD_VERSION" == "PMIC" ] ; then - FLASHWRITER="$FILES_DIR/Flash_Writer_SCIF_RZV2L_SMARC_PMIC_DDR4_2GB_1PCS.mot" - BL2_FILE=$FILES_DIR/bl2_bp-${BOARD}_pmic.srec - FIP_FILE=$FILES_DIR/fip-${BOARD}_pmic.srec - else - FLASHWRITER="$FILES_DIR/Flash_Writer_SCIF_RZV2L_SMARC_DDR4_4GB.mot" - fi - fi - - if [ "$BL2_FILE" == "" ] ; then - BL2_FILE=$FILES_DIR/bl2_bp-${BOARD}.bin - fi - if [ "$FIP_FILE" == "" ] ; then - FIP_FILE=$FILES_DIR/fip-${BOARD}.bin - fi - - # Clear file settings we do not use - SA0_FILE="" - SA6_FILE="" - BL31_FILE="" - UBOOT_FILE="" - fi -} - -set_fw_binary() { - if [ "$FW_PREBUILT" == "1" ] ; then - if [ "${BOARD:0:6}" == "hihope" ] ; then - B_NAME="hihope" - fi - if [ "$BOARD" == "ek874" ] ; then - B_NAME="ek874" - fi - if [ "$FLASH" == "0" ] ; then - F_NAME="SPI" - else - F_NAME="eMMC" - fi - if [ "${SERIAL_DEVICE_INTERFACE:8:3}" == "ACM" ] ; then - S_NAME="USB" - else - S_NAME="SCIF" - fi - - FLASHWRITER="./binaries/Flash_writer_${B_NAME}_${S_NAME}_${F_NAME}.mot" - - if [ "$BOARD" == "smarc-rzg2l" ] ; then - FLASHWRITER="./binaries/Flash_Writer_SCIF_RZG2L_SMARC_DDR4_2GB.mot" - fi - if [ "$BOARD" == "smarc-rzg2lc" ] ; then - FLASHWRITER="./binaries/Flash_Writer_SCIF_RZG2LC_SMARC_DDR4_1GB_1PCS.mot" - fi - if [ "$BOARD" == "smarc-rzg2ul" ] ; then - FLASHWRITER="./binaries/Flash_Writer_SCIF_RZG2UL_SMARC_DDR4_1GB_1PCS.mot" - fi - - fi -} - -do_menu_config() { - SELECT=$(whiptail --title "Config File Selection" --menu "You may use ESC+ESC to cancel.\n\nHow do you want to select the file?" 0 0 0 \ - "1 File Browse" " Use a GUI File broswer " \ - "2 Enter" " Manual enter the filename." \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - case "$SELECT" in - 1\ *) - which zenity > /dev/null - if [ "$?" != "0" ] ; then - whiptail --yesno "ERROR: You need the (small) \"zenity\" dialog box utility installed.\nYou can install by running:\n\n$ sudo apt-get install zenity\n\nRun that command now to install?" 0 0 0 - if [ "$?" == "0" ] ; then - echo "sudo apt-get install zenity" - sudo apt-get install zenity - echo "--------------------------" - echo " Install complete" - echo "--------------------------" - sleep 2 - do_menu_config - fi - else - FILE=`zenity --file-selection --filename="$CONFIG_FILE" --file-filter=*.ini --title="Select your config file (*.ini)"` - case $? in - 0) - # Strip out the full path if it is in the same directory - PWD="$(pwd)/" - SELECT=$(echo $FILE | sed "s:$PWD::") - CONFIG_FILE="$SELECT" - source "$CONFIG_FILE" - config_hash - CONFIG_HASH=$CONFIG_HASH_RESULT - ;; - -1) - whiptail --msgbox "An unexpected error has occurred." 0 0 0 - ;; - esac - fi - ;; - 2\ *) - SELECT=$(whiptail --title "Config File Selection" --inputbox "You may use ESC+ESC to cancel.\n\n Enter the filename to your config file." 0 100 \ - "config.ini" \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - - if [ ! -e "$SELECT" ] ; then - whiptail --msgbox "New file?\n\nFile \"$SELECT\" does not exist.\nThis file will be created if you save and exit.\n" 0 0 0 - fi - CONFIG_FILE="$SELECT" - source "$CONFIG_FILE" - config_hash - CONFIG_HASH=$CONFIG_HASH_RESULT - fi - ;; - *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; - esac || whiptail --msgbox "There was an error running option $SELECT" 20 60 1 - fi -} - -do_menu_board() { - SELECT=$(whiptail --title "Board Selection" --menu "You may use ESC+ESC to cancel." 0 0 0 \ - "1 ek874" " EK874 RZ/G2E by Silicon Linux" \ - "2 hihope-rzg2m" " HiHope RZ/G2M by Hoperun Technology" \ - "3 hihope-rzg2n" " HiHope RZ/G2N by Hoperun Technology" \ - "4 hihope-rzg2h" " HiHope RZ/G2H by Hoperun Technology" \ - "5 smarc-rzg2l " " SMARC RZ/G2L by Renesas Electronics" \ - "6 smarc-rzg2lc " " SMARC RZ/G2LC by Renesas Electronics" \ - "7 smarc-rzg2ul " " SMARC RZ/G2UL by Renesas Electronics" \ - "8 smarc-rzv2l " " SMARC RZ/V2L by Renesas Electronics" \ - "0 CUSTOM" " (manually edit ini file)" \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - FIP=0 - EMMC_4BIT=0 - case "$SELECT" in - 1\ *) BOARD=ek874 ;; - 2\ *) BOARD=hihope-rzg2m ;; - 3\ *) BOARD=hihope-rzg2n ;; - 4\ *) BOARD=hihope-rzg2h ;; - 5\ *) BOARD=smarc-rzg2l ; FIP=1 ; EMMC_4BIT=1 - whiptail --yesno --yes-button PMIC_Power --no-button Discrete_Power "Board Version:\n\nIs the board 'PMIC Power' version or the 'Discrete Power' version?\n\nThe PMIC version has \"Reneas\" printed in the middle of the SOM board.\nThe Discrete version has \"Renesas\" printed at the edge of the SOM baord. " 0 0 0 - if [ "$?" == "0" ] ; then - BOARD_VERSION="PMIC" - else - BOARD_VERSION="DISCRETE" - fi - ;; - 6\ *) BOARD=smarc-rzg2lc ; FIP=1 ; EMMC_4BIT=1 ;; - 7\ *) BOARD=smarc-rzg2ul ; FIP=1 ; EMMC_4BIT=1 ;; - 8\ *) BOARD=smarc-rzv2l ; FIP=1 ; EMMC_4BIT=1 - whiptail --yesno --yes-button PMIC_Power --no-button Discrete_Power "Board Version:\n\nIs the board 'PMIC Power' version or the 'Discrete Power' version?" 0 0 0 - if [ "$?" == "0" ] ; then - BOARD_VERSION="PMIC" - else - BOARD_VERSION="DISCRETE" - fi - ;; - 0\ *) BOARD=CUSTOM ;; - *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; - esac || whiptail --msgbox "There was an error running option $SELECT" 20 60 1 - - unset FILES_DIR - switch_settings - clear_filenames - set_filenames - set_fw_binary - - fi -} - -do_menu_target_flash() { - SELECT=$(whiptail --title "Target Flash Selection" --menu "You may use ESC+ESC to cancel." 0 0 0 \ - "1 SPI Flash" " " \ - "2 eMMC Flash" " " \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - case "$SELECT" in - 1\ *) FLASH=0 ; - # If building outside of Yocto, and we have the wrong directory selected, we need to update file paths - echo $SA0_FILE | grep -q z_deploy_emmc ; if [ "$?" == "0" ] ; then clear_filenames ; set_filenames ; fi - ;; - 2\ *) FLASH=1 - # If building outside of Yocto, and we have the wrong directory selected, we need to update file paths - echo $SA0_FILE | grep -q z_deploy_spi ; if [ "$?" == "0" ] ; then clear_filenames ; set_filenames ; fi - ;; - *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; - esac || whiptail --msgbox "There was an error running option $SELECT" 20 60 1 - fi - - set_fw_binary -} - -do_menu_dev() { - SELECT=$(whiptail --title "Interface Selection" --menu "You may use ESC+ESC to cancel." 0 0 0 \ - "1 /dev/ttyUSB0" " SCIF Download mode" \ - "2 /dev/ttyACM0" " USB Download mode" \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - case "$SELECT" in - 1\ *) SERIAL_DEVICE_INTERFACE="/dev/ttyUSB0" ;; - 2\ *) SERIAL_DEVICE_INTERFACE="/dev/ttyACM0" ;; - *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; - esac || whiptail --msgbox "There was an error running option $SELECT" 20 60 1 - fi - - set_fw_binary -} - -do_menu_speed() { - SELECT=$(whiptail --title "Interface Speed Selection" --menu "You may use ESC+ESC to cancel." 0 0 0 \ - "1 115200" " Default for all devices" \ - "2 921600" " Issue SUP command before downloads" \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - case "$SELECT" in - 1\ *) SERIAL_DEVICE_SPEED="115200" ;; - 2\ *) SERIAL_DEVICE_SPEED="921600" ;; - *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; - esac || whiptail --msgbox "There was an error running option $SELECT" 20 60 1 - fi -} - - -do_menu_colors() { - SELECT=$(whiptail --title "GUI menu colors" --menu "You may use ESC+ESC to cancel.\n\nSelect the color theme you want to use" 0 0 0 \ - "1 Default" " " \ - "2 Black and Green" " " \ - "3 Black and White" " " \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - case "$SELECT" in - 1\ *) -export NEWT_COLORS=' -root=,blue -' -;; - 2\ *) -export NEWT_COLORS=' - root=green,black - border=green,black - title=green,black - roottext=white,black - window=green,black - textbox=white,black - button=black,green - compactbutton=white,black - listbox=white,black - actlistbox=black,white - actsellistbox=black,green - checkbox=green,black - actcheckbox=black,green -' -;; - 3\ *) -export NEWT_COLORS=' - root=white,black - border=black,lightgray - window=lightgray,lightgray - shadow=black,gray - title=black,lightgray - button=black,cyan - actbutton=white,cyan - compactbutton=black,lightgray - checkbox=black,lightgray - actcheckbox=lightgray,cyan - entry=black,lightgray - disentry=gray,lightgray - label=black,lightgray - listbox=black,lightgray - actlistbox=black,cyan - sellistbox=lightgray,black - actsellistbox=lightgray,black - textbox=black,lightgray - acttextbox=black,cyan - emptyscale=,gray - fullscale=,cyan - helpline=white,black - roottext=lightgrey,black -' -;; - *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; - esac || whiptail --msgbox "There was an error running option $SELECT" 20 60 1 - fi -} - -do_menu_extra() { - SELECT=$(whiptail --title "Extra menu" --menu "You may use ESC+ESC to cancel." 0 0 0 \ - "1 Change GUI Colors" " " \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - case "$SELECT" in - 1\ *) do_menu_colors ;; - *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; - esac || whiptail --msgbox "There was an error running option $SELECT" 20 60 1 - fi -} - -do_menu_file_dir() { - - # Save to check later - ORIG_FILES_DIR=$FILES_DIR - - SELECT=$(whiptail --title "File Directory Selection" --menu "You may use ESC+ESC to cancel.\n\nHow do you want to select the directory?" 0 0 0 \ - "1 File Browse" " Use a GUI File broswer " \ - "2 Enter" " Manual enter the directory." \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - case "$SELECT" in - 1\ *) - which zenity > /dev/null - if [ "$?" != "0" ] ; then - whiptail --yesno "ERROR: You need the (small) \"zenity\" dialog box utility installed.\nYou can install by running:\n\n$ sudo apt-get install zenity\n\nRun that command now to install?" 0 0 0 - if [ "$?" == "0" ] ; then - echo "sudo apt-get install zenity" - sudo apt-get install zenity - echo "--------------------------" - echo " Install complete" - echo "--------------------------" - sleep 2 - do_menu_file_dir - fi - else - FILE=`zenity --directory --file-selection --filename=".." --title="Select your base directory"` - case $? in - 0) - FILES_DIR="$FILE" - ;; - -1) - whiptail --msgbox "An unexpected error has occurred." 0 0 0 - ;; - esac - fi - ;; - 2\ *) - SELECT=$(whiptail --title "File Direcotry Selection" --inputbox "You may use ESC+ESC to cancel.\n\n Enter the base directory you want to use." 0 100 \ - "$FILES_DIR" \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - - if [ ! -e "$SELECT" ] ; then - whiptail --msgbox "Warning: Directory does not exist\n" 0 0 0 - fi - FILES_DIR="$SELECT" - fi - ;; - *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; - esac || whiptail --msgbox "There was an error running option $SELECT" 20 60 1 - fi - - # If we changed the value, then update all the other files - if [ "$ORIG_FILES_DIR" != "$FILES_DIR" ] ; then - clear_filenames - set_filenames - fi -} - -do_menu_file_fw() { - SELECT=$(whiptail --title "Flash Writer Selection" --menu "You may use ESC+ESC to cancel." 0 0 0 \ - "1. Enter filename" " " \ - "2. Use included prebuilt binaries (auto select)" " " \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - case "$SELECT" in - 1.\ *) FW_PREBUILT=0 ;; - 2.\ *) FW_PREBUILT=1 ; set_fw_binary ; return ;; - *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; - esac || whiptail --msgbox "There was an error running option $SELECT" 20 60 1 - fi - - SELECT=$(whiptail --title "Flash Writer File Selection" --inputbox "You may use ESC+ESC to cancel.\n\n Enter file path to Flash Writer File." 0 100 \ - "AArch64_Flash_writer_SCIF_DUMMY_CERT_E6300400_${BOARD}.mot" \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - FLASHWRITER="$SELECT" - fi -} - -do_menu_file_sa0() { - SELECT=$(whiptail --title "SA0 File Selection" --inputbox "You may use ESC+ESC to cancel.\n\n Enter file path to SA0 File." 0 100 \ - "${SA0_FILE}" \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - SA0_FILE="$SELECT" - fi -} - -do_menu_file_bl2() { - SELECT=$(whiptail --title "BL2 File Selection" --inputbox "You may use ESC+ESC to cancel.\n\n Enter file path to BL2 File." 0 100 \ - "${BL2_FILE}" \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - BL2_FILE="$SELECT" - fi -} - -do_menu_file_sa6() { - SELECT=$(whiptail --title "SA6 File Selection" --inputbox "You may use ESC+ESC to cancel.\n\n Enter file path to SA6 File." 0 100 \ - "${SA6_FILE}" \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - SA6_FILE="$SELECT" - fi -} - -do_menu_file_bl31() { - SELECT=$(whiptail --title "BL31 File Selection" --inputbox "You may use ESC+ESC to cancel.\n\n Enter file path to BL31 File." 0 100 \ - "${BL31_FILE}" \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - BL31_FILE="$SELECT" - fi -} - -do_menu_file_fip() { - SELECT=$(whiptail --title "FIP File Selection" --inputbox "You may use ESC+ESC to cancel.\n\n Enter file path to FIP File." 0 100 \ - "${FIP_FILE}" \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - FIP_FILE="$SELECT" - fi -} - -do_menu_file_uboot() { - SELECT=$(whiptail --title "u-boot File Selection" --inputbox "You may use ESC+ESC to cancel.\n\n Enter file path to u-boot File." 0 100 \ - "${UBOOT_FILE}" \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 0 ] ; then - UBOOT_FILE="$SELECT" - fi -} - -do_cmd_atf() { - FW_GUI_MODE=2 - echo "./flash_writer_tool.sh atf" - ./flash_writer_tool.sh atf - FW_GUI_MODE=1 -} - -do_cmd_all() { - FW_GUI_MODE=2 - echo "./flash_writer_tool.sh all" - ./flash_writer_tool.sh all - FW_GUI_MODE=1 -} - -do_cmd_sw() { - #printf '%s\n' "$SW_SETTINGS" - #read dummy - whiptail --title "$BOARD_NAME" --msgbox "$SW_SETTINGS" 0 0 -} - -do_cmd() { - export SERIAL_DEVICE_SPEED=$SERIAL_DEVICE_SPEED - - echo "BOARD=$BOARD FLASH=$FLASH SERIAL_DEVICE_INTERFACE=$SERIAL_DEVICE_INTERFACE ./flash_writer_tool.sh $CMD $FILE_TO_SEND" - BOARD=$BOARD FLASH=$FLASH SERIAL_DEVICE_INTERFACE=$SERIAL_DEVICE_INTERFACE FW_GUI_MODE=2 ./flash_writer_tool.sh $CMD $FILE_TO_SEND -} - -################################################################# -# Script Start GUI -################################################################# -if [ "$FW_GUI_MODE" == "1" ] ; then - - # Set Default Whiptail color (blue looks better than purple) - export NEWT_COLORS=' - root=,blue - ' - - # Default board file - CONFIG_FILE=config.ini - - # Change Terminal size (because I like to double-click in the file manager to run this this) - # Do not do this if you are in a SSH or docker session - if [ "$DISPLAY" != "" ] ; then - #printf '\033[8;40;120t' - resize -s 40 120 > /dev/null - fi - - # Read what we used last time - if [ -e "settings.txt" ] ; then - source settings.txt - source "$CONFIG_FILE" - fi - - # Some default entries if first use - if [ "$BOARD" == "" ] ; then - # Check for Yocto output files - if [ -e ../../build/tmp/deploy/images/hihope-rzg2h ] ; then - BOARD="hihope-rzg2h" - FILES_DIR=../../build/tmp/deploy/images/${BOARD} - DETECTED=1 - elif [ -e ../../build/tmp/deploy/images/hihope-rzg2m ] ; then - BOARD="hihope-rzg2m" - FILES_DIR=../../build/tmp/deploy/images/${BOARD} - DETECTED=1 - elif [ -e ../../build/tmp/deploy/images/hihope-rzg2n ] ; then - BOARD="hihope-rzg2n" - FILES_DIR=../../build/tmp/deploy/images/${BOARD} - DETECTED=1 - elif [ -e ../../build/tmp/deploy/images/ek874 ] ; then - BOARD="ek874" - FILES_DIR=../../build/tmp/deploy/images/${BOARD} - DETECTED=1 - elif [ -e ../../build/tmp/deploy/images/smarc-rzg2l ] ; then - BOARD="smarc-rzg2l" - FIP=1 - EMMC_4BIT=1 - FILES_DIR=../../build/tmp/deploy/images/${BOARD} - DETECTED=1 - # Select PMIC version as default - BOARD_VERSION="PMIC" - elif [ -e ../../build/tmp/deploy/images/smarc-rzg2lc ] ; then - BOARD="smarc-rzg2lc" - FIP=1 - EMMC_4BIT=1 - FILES_DIR=../../build/tmp/deploy/images/${BOARD} - DETECTED=1 - elif [ -e ../../build/tmp/deploy/images/smarc-rzg2ul ] ; then - BOARD="smarc-rzg2ul" - FIP=1 - EMMC_4BIT=1 - FILES_DIR=../../build/tmp/deploy/images/${BOARD} - DETECTED=1 - elif [ -e ../../build/tmp/deploy/images/smarc-rzv2l ] ; then - BOARD="smarc-rzv2l" - FIP=1 - EMMC_4BIT=1 - FILES_DIR=../../build/tmp/deploy/images/${BOARD} - DETECTED=1 - # Select PMIC version as default - BOARD_VERSION="PMIC" - else - # default to RZ/G2M - BOARD="hihope-rzg2m" - FILES_DIR=~/yocto/rzg2_bsp_eva_v106/build/tmp/deploy/images/${BOARD} - fi - - if [ "$DETECTED" == "1" ] ; then - whiptail --msgbox "Detected Yocto output files for board \"$BOARD\"" 0 0 1 - fi - - # default values - SERIAL_DEVICE_INTERFACE="/dev/ttyUSB0" - SERIAL_DEVICE_SPEED=115200 - FLASH="0" - CONFIG_FILE="config.ini" - fi - - config_hash - CONFIG_HASH=$CONFIG_HASH_RESULT - settings_hash - SETTINGS_HASH=$SETTINGS_HASH_RESULT - - export FW_NOT_DL_YET=1 - - while true ; do - - # Set BOARD_NAME and SW_SETTINGS - switch_settings - - # Set files for Renesas boards - set_filenames - - # change the text that is displayed on the screen - FLASH_TEXT=("SPI Flash" "eMMC Flash") - if [ "${FLASHWRITER:0:6}" != "binaries" ] && [ "${FLASHWRITER:2:8}" != "binaries" ] ; then - FLASHWRITER_TEXT=$(echo $FLASHWRITER | sed "s:$FILES_DIR:\$(FILES_DIR):") - else - if [ "$FW_PREBUILT" == "1" ] ; then - FLASHWRITER_TEXT="$FLASHWRITER (auto select)" - else - FLASHWRITER_TEXT="$FLASHWRITER" - fi - fi - SA0_FILE_TEXT=$(echo $SA0_FILE | sed "s:$FILES_DIR:\$(FILES_DIR):") - BL2_FILE_TEXT=$(echo $BL2_FILE | sed "s:$FILES_DIR:\$(FILES_DIR):") - SA6_FILE_TEXT=$(echo $SA6_FILE | sed "s:$FILES_DIR:\$(FILES_DIR):") - BL31_FILE_TEXT=$(echo $BL31_FILE | sed "s:$FILES_DIR:\$(FILES_DIR):") - FIP_FILE_TEXT=$(echo $FIP_FILE | sed "s:$FILES_DIR:\$(FILES_DIR):") - UBOOT_FILE_TEXT=$(echo $UBOOT_FILE | sed "s:$FILES_DIR:\$(FILES_DIR):") - - # check if files exits - if [ -e "$FILES_DIR" ] ; then FD_EXIST="✓" ; else FD_EXIST="x" ; fi - if [ -e "$FLASHWRITER" ] ; then FW_EXIST="✓" ; else FW_EXIST="x" ; fi - if [ -e "$SA0_FILE" ] ; then SA0_EXIST="✓" ; else SA0_EXIST="x" ; fi - if [ -e "$BL2_FILE" ] ; then BL2_EXIST="✓" ; else BL2_EXIST="x" ; fi - if [ -e "$SA6_FILE" ] ; then SA6_EXIST="✓" ; else SA6_EXIST="x" ; fi - if [ -e "$BL31_FILE" ] ; then BL31_EXIST="✓" ; else BL31_EXIST="x" ; fi - if [ -e "$FIP_FILE" ] ; then FIP_EXIST="✓" ; else FIP_EXIST="x" ; fi - if [ -e "$UBOOT_FILE" ] ; then UBOOT_EXIST="✓" ; else UBOOT_EXIST="x" ; fi - - # Remove entries based on FIP - if [ "$FIP" == "0" ] ; then - FIP_EXIST=" " ; FIP_FILE_TEXT="" - else - SA0_EXIST=" " ; SA0_FILE_TEXT="" - SA6_EXIST=" " ; SA6_FILE_TEXT="" - BL31_EXIST=" " ; BL31_FILE_TEXT="" - UBOOT_EXIST=" " ; UBOOT_FILE_TEXT="" - fi - - # Remind users to run flash writer first (FWR =Flash Writer Reminder) - # Show what operations the user can choose - OP1=" " # SA0, SA6, BL31, u-boot, ALL - OP2=" " # BL2, ATF - OP3=" " # FIP - OP4=" " # eMMC - - if [ "$FW_NOT_DL_YET" == "1" ] ; then - FWR="★" - else - FWR=" " - if [ "$FLASH" == "1" ] ; then - OP4="★" - fi - if [ "$FIP" == "0" ] ; then - OP1="★" - OP2="★" - else - OP2="★" - OP3="★" - fi - fi - - # Files directory does not exist, remind user to set(FDR = FILES DIR Reminder) - if [ ! -e "$FILES_DIR" ] ; then FDR="★" ; else FDR=" " ; fi - - # check if any settings have changed - config_hash - settings_hash - if [ "$CONFIG_HASH" != "$CONFIG_HASH_RESULT" ] || [ "$SETTINGS_HASH" != "$SETTINGS_HASH_RESULT" ] ; then - CHANGE_TEXT="\n !!!! WARNING: Changes not saved yet !!!!!" - OK_TEXT="SAVE-and-EXIT" - else - CHANGE_TEXT="" - OK_TEXT="EXIT" - fi - - if [ "${SERIAL_DEVICE_INTERFACE:8:3}" == "ACM" ] ; then DL_TYPE="USB Download Mode" ; else DL_TYPE="SCIF Download Mode" ; fi - - SELECT=$(whiptail --title "RZ/G2 Flash Writer Tool" --menu \ - "Select your programming options.\nYou may use [ESC]+[ESC] to Cancel/Exit (no save). Use [Tab] key to select buttons.\n\nUse the button (or enter) to make changes.\n$CHANGE_TEXT" 0 0 0 --cancel-button $OK_TEXT --ok-button Change \ - --default-item "$LAST_SELECT" \ - " Board:" " $BOARD_NAME" \ - " Target Flash:" " ${FLASH_TEXT[$FLASH]}" \ - " Interface:" " $SERIAL_DEVICE_INTERFACE ($DL_TYPE)" \ - " Speed:" " $SERIAL_DEVICE_SPEED" \ - " Config File:" " $CONFIG_FILE" \ - " Extra Settings:" " GUI Colors, windows size, etc..." \ - "_______Files_________" "" \ - " $FDR FILES_DIR:" "$FD_EXIST $FILES_DIR" \ - " FLASHWRITER:" "$FW_EXIST $FLASHWRITER_TEXT" \ - " SA0_FILE:" "$SA0_EXIST $SA0_FILE_TEXT" \ - " BL2_FILE:" "$BL2_EXIST $BL2_FILE_TEXT" \ - " SA6_FILE:" "$SA6_EXIST $SA6_FILE_TEXT" \ - " BL31_FILE:" "$BL31_EXIST $BL31_FILE_TEXT" \ - " FIP_FILE:" "$FIP_EXIST $FIP_FILE_TEXT" \ - " UBOOT_FILE:" "$UBOOT_EXIST $UBOOT_FILE_TEXT" \ - "______Operations_____" "" \ - "a. $FWR Download F.W. " " Downloads the Flash Writer binary (must be run first)" \ - "b. $OP1 Program SA0 " " SA0 (Boot Parameters)" \ - "c. $OP2 Program BL2 " " BL2 (Trusted Boot Firmware)" \ - "d. $OP1 Program SA6 " " SA6 (Cert Header)" \ - "e. $OP1 Program BL31 " " BL31 (EL3 Runtime Software)" \ - "f. $OP3 Program FIP " " FIP (Firmware Image Package)" \ - "g. $OP1 Program u-boot " " u-boot (BL33, Non-trusted Firmware)" \ - "h. $OP2 Program ATF " " Program all arm-trusted-firmware files (SA0,BL2,SA6,BL31,FIP)" \ - "i. $OP1 Program All " " Programs all files (SA0,BL2,SA66,BL31 and u-boot)" \ - "j. $OP4 eMMC boot setup " " Configure an eMMC device for booting (only needed once)" \ - "s. $FWR Show switches " " Show the switch settings for Renesas boards (in case you forgot)" \ - 3>&1 1>&2 2>&3) - RET=$? - if [ $RET -eq 1 ] ; then - # save if changes - config_hash - if [ "$CONFIG_HASH" != "$CONFIG_HASH_RESULT" ] || [ ! -e "$CONFIG_FILE" ] ; then - echo "# This file was created by the flash_writer_tool.sh" > $CONFIG_FILE - echo "BOARD=$BOARD" >> $CONFIG_FILE - echo "BOARD_VERSION=$BOARD_VERSION" >> $CONFIG_FILE - echo "FLASH=$FLASH" >> $CONFIG_FILE - echo "SERIAL_DEVICE_INTERFACE=$SERIAL_DEVICE_INTERFACE" >> $CONFIG_FILE - echo "SERIAL_DEVICE_SPEED=$SERIAL_DEVICE_SPEED" >> $CONFIG_FILE - - echo "FILES_DIR=$FILES_DIR" >> $CONFIG_FILE - echo "FW_PREBUILT=$FW_PREBUILT" >> $CONFIG_FILE - echo "FLASHWRITER=$FLASHWRITER" >> $CONFIG_FILE - echo "FIP=$FIP" >> $CONFIG_FILE - echo "EMMC_4BIT=$EMMC_4BIT" >> $CONFIG_FILE - echo "SA0_FILE=$SA0_FILE" >> $CONFIG_FILE - echo "BL2_FILE=$BL2_FILE" >> $CONFIG_FILE - echo "SA6_FILE=$SA6_FILE" >> $CONFIG_FILE - echo "BL31_FILE=$BL31_FILE" >> $CONFIG_FILE - echo "FIP_FILE=$FIP_FILE" >> $CONFIG_FILE - echo "UBOOT_FILE=$UBOOT_FILE" >> $CONFIG_FILE - fi - - # Global Settings - settings_hash - if [ "$SETTINGS_HASH" != "$SETTINGS_HASH_RESULT" ] || [ ! -e settings.txt ] ; then - echo "CONFIG_FILE=$CONFIG_FILE" > settings.txt - echo -e "\n# Whiptail colors\nexport NEWT_COLORS='""$NEWT_COLORS""'" >> settings.txt - fi - - if [ "$SERIAL_DEVICE_SPEED" == "921600" ] ; then - # Put baud rate back to default - stty -F $SERIAL_DEVICE_INTERFACE 115200 - fi - - break; - elif [ $RET -eq 0 ] ; then - LAST_SELECT="$SELECT" - case "$SELECT" in - *Board:*) do_menu_board ;; - *Target\ Flash:*) do_menu_target_flash ;; - *Interface:*) do_menu_dev ;; - *Speed:*) do_menu_speed ;; - *Config\ File:*) do_menu_config ;; - *Extra\ Settings:*) do_menu_extra ;; - - *Files*) ;; - - *FILES_DIR:*) do_menu_file_dir ;; - *FLASHWRITER:*) do_menu_file_fw ;; - *SA0_FILE:*) if [ "$FIP" == "1" ] ; then continue ; fi ; do_menu_file_sa0 ;; - *BL2_FILE:*) do_menu_file_bl2 ;; - *SA6_FILE:*) if [ "$FIP" == "1" ] ; then continue ; fi ; do_menu_file_sa6 ;; - *BL31_FILE:*) if [ "$FIP" == "1" ] ; then continue ; fi ; do_menu_file_bl31 ;; - *FIP_FILE:*) if [ "$FIP" == "0" ] ; then continue ; fi ; do_menu_file_fip ;; - *UBOOT_FILE:*) if [ "$FIP" == "1" ] ; then continue ; fi ; do_menu_file_uboot ;; - - *Operations*) ;; - - *Download\ F.W.*) whiptail --title "Download mode" --msgbox "Make sure the board is configured for \"SCIF Download mode\" or \"USB Download mode\"\n\nPower on the board and press the RESET button.\n\nThen, press ENTER on the keyboard to continue." 0 0 ; - CMD=fw FILE_TO_SEND=$FLASHWRITER ; do_cmd ; export FW_NOT_DL_YET=0 ;; - *Program\ SA0*) if [ "$FIP" == "1" ] ; then continue ; fi ; check_fw_first ; if [ "$CMD_ABORT" != "1" ] ; then CMD=sa0 ; FILE_TO_SEND=$SA0_FILE ; do_cmd ; fi ;; - *Program\ BL2*) check_fw_first ; if [ "$CMD_ABORT" != "1" ] ; then CMD=bl2 ; FILE_TO_SEND=$BL2_FILE ; do_cmd ; fi ;; - *Program\ SA6*) if [ "$FIP" == "1" ] ; then continue ; fi ; check_fw_first ; if [ "$CMD_ABORT" != "1" ] ; then CMD=sa6 ; FILE_TO_SEND=$SA6_FILE ; do_cmd ; fi ;; - *Program\ BL31*) if [ "$FIP" == "1" ] ; then continue ; fi ; check_fw_first ; if [ "$CMD_ABORT" != "1" ] ; then CMD=bl31 ; FILE_TO_SEND=$BL31_FILE ; do_cmd ; fi ;; - *Program\ FIP*) if [ "$FIP" == "0" ] ; then continue ; fi ; check_fw_first ; if [ "$CMD_ABORT" != "1" ] ; then CMD=fip ; FILE_TO_SEND=$FIP_FILE ; do_cmd ; fi ;; - *Program\ u-boot*) if [ "$FIP" == "1" ] ; then continue ; fi ; check_fw_first ; if [ "$CMD_ABORT" != "1" ] ; then CMD=uboot ; FILE_TO_SEND=$UBOOT_FILE ; do_cmd ; fi ;; - *Program\ ATF*) check_fw_first ; if [ "$CMD_ABORT" != "1" ] ; then - if [ "$FIP" == "0" ] ; then - CMD=sa0 ; FILE_TO_SEND=$SA0_FILE ; do_cmd ; sleep 1 ; - CMD=bl2 ; FILE_TO_SEND=$BL2_FILE ; do_cmd ; sleep 2 ; - CMD=sa6 ; FILE_TO_SEND=$SA6_FILE ; do_cmd ; sleep 1 ; - CMD=bl31 ; FILE_TO_SEND=$BL31_FILE ; do_cmd ; sleep 2 ; - else - CMD=bl2 ; FILE_TO_SEND=$BL2_FILE ; do_cmd ; sleep 2 ; - CMD=fip ; FILE_TO_SEND=$FIP_FILE ; do_cmd ; sleep 2 ; - fi - fi ;; - *Program\ All*) if [ "$FIP" == "1" ] ; then continue ; fi ; check_fw_first ; if [ "$CMD_ABORT" != "1" ] ; then - CMD=sa0 ; FILE_TO_SEND=$SA0_FILE ; do_cmd ; sleep 1 ; - CMD=bl2 ; FILE_TO_SEND=$BL2_FILE ; do_cmd ; sleep 2 ; - CMD=sa6 ; FILE_TO_SEND=$SA6_FILE ; do_cmd ; sleep 1 ; - CMD=bl31 ; FILE_TO_SEND=$BL31_FILE ; do_cmd ; sleep 2 ; - CMD=uboot ; FILE_TO_SEND=$UBOOT_FILE ; do_cmd ; sleep 2 ; - fi ;; - *eMMC*) CMD=emmc_config ; FILE_TO_SEND= ; do_cmd ;; - *switches*) do_cmd_sw ;; - *) whiptail --msgbox "Programmer error: unrecognized option" 20 60 1 ;; - esac || whiptail --msgbox "There was an error running option $SELECT" 20 60 1 - else - exit 1 - fi - done - exit -fi - -# do_xls2 -# $1 = string -# $2 = RAM address to download to -# $3 = SPI address to write to -# $4 = filename -do_xls2() { - # Flash writer just looks for CR. If it see LF, it ignores it. - echo "Writting $1 ($4)" - echo "Sending XLS2 command..." - echo -en "XLS2\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY - echo -en "$2\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY - echo -en "$3\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY - echo "Sending file..." - #cat $4 > $SERIAL_DEVICE_INTERFACE - stat -L --printf="%s bytes\n" $4 - dd if=$4 of=$SERIAL_DEVICE_INTERFACE bs=1k status=progress - sleep $CMD_DELAY - - # You only need to send a 'y', not the 'y' + CR. But, if the flash is already - # blank, flash writer will not ask you to confirm, so we send y + CR - # just in case. So if the flash is already blank you will just see an - # extra 'command not found' message which does not hurt anything. - echo -en "y\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY - echo "" -} - -# do_xls3 -# $1 = string -# $2 = SPI address to write to -# $3 = filename -do_xls3() { - # Flash writer just looks for CR. It ignores LF characters. - echo "Writting $1 ($3)" - echo "Sending XLS3 command..." - echo -en "XLS3\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY - - # get the file size of our binary - SIZE_DEC=$(stat -L --printf="%s" $3) - SIZE_HEX=$(printf '%X' $SIZE_DEC) - echo -en "$SIZE_HEX\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY - - echo -en "$2\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY - - echo "Sending file..." - #cat $3 > $SERIAL_DEVICE_INTERFACE - stat -L --printf="%s bytes\n" $3 - dd if=$3 of=$SERIAL_DEVICE_INTERFACE bs=1k status=progress - sleep $CMD_DELAY - - # You only need to send a 'y', not the 'y' + CR. But, if the flash is already - # blank, flash writer will not ask you to confirm, so we send y + CR - # just in case. So if the flash is already blank you will just see an - # extra 'command not found' message which does not hurt anything. - echo -en "y\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY - echo "" -} - -# do_em_w -# $1 = string -# $2 = partition number -# $3 = eMMC block address to write to -# $4 = RAM address to download to -# $5 = filename -do_em_w() { - # Flash writer just looks for CR. It ignores LF characters. - echo "Writting $1 ($5)" - echo "Sending EM_W command..." - echo -en "EM_W\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY - echo -en "$2\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY - echo -en "$3\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY - echo -en "$4\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY - echo "Sending file..." - #cat $5 > $SERIAL_DEVICE_INTERFACE - stat -L --printf="%s bytes\n" $5 - dd if=$5 of=$SERIAL_DEVICE_INTERFACE bs=1k status=progress - sleep $CMD_DELAY - echo "" -} - -# do_em_wb -# $1 = string -# $2 = partition number -# $3 = eMMC block address to write to -# $4 = filename -do_em_wb() { - # Flash writer just looks for CR. It ignores LF characters. - echo "Writting $1 ($4)" - echo "Sending EM_WB command..." - echo -en "EM_WB\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY - echo -en "$2\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY - echo -en "$3\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY - - # get the file size of our binary - SIZE_DEC=$(stat -L --printf="%s" $4) - SIZE_HEX=$(printf '%X' $SIZE_DEC) - echo -en "$SIZE_HEX\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY - - echo "Sending file..." - #cat $4 > $SERIAL_DEVICE_INTERFACE - stat -L --printf="%s bytes\n" $4 - dd if=$4 of=$SERIAL_DEVICE_INTERFACE bs=1k status=progress - sleep $CMD_DELAY - echo "" -} - -# do_spi_write -# $1 = string -# $2 = RAM address to download to -# $3 = SPI address to write to -# $4 = filename -do_spi_write() { - - # Send a CR (\r) just to make sure there are not extra characters left over from the last transfer - #echo -en "\r" > $SERIAL_DEVICE_INTERFACE - - # Check if file is SREC or bin - FILENAME=$(basename $4) - FILENAME_EXT=`echo ${FILENAME: -5}` - if [ "$FILENAME_EXT" == ".srec" ] ; then - # S-Record Write - do_xls2 "$1" $2 $3 $4 - else - # Binary Write (RAM address not needed) - do_xls3 "$1" $3 $4 - fi -} - -# do_emmc_write -# $1 = string -# $2 = partition number -# $3 = eMMC starting block to write -# $4 = RAM address to download to -# $5 = filename -do_emmc_write() { - # Send a CR (\r) just to make sure there are not extra characters left over from the last transfer - #echo -en "\r" > $SERIAL_DEVICE_INTERFACE - - # Check if file is SREC or bin - FILENAME=$(basename $5) - FILENAME_EXT=`echo ${FILENAME: -5}` - if [ "$FILENAME_EXT" == ".srec" ] ; then - # S-Record Write - do_em_w "$1" $2 $3 $4 $5 - else - # Binary Write - do_em_wb "$1" $2 $3 $5 - fi -} - -print_usage() { - echo "Usage: [config file] [operation] [file name]" \ - "config file" - echo "config file" - echo "$0 fw # Downloads the flash writer program after RESET (must be run first)" - echo "" - echo "$0 sa0 # programs SA0 (Boot Parameters)" - echo "$0 bl2 # programs BL2 (Trusted Boot Firmware)" - echo "$0 sa6 # programs SA6 (Cert Header)" - echo "$0 bl31 # programs BL31 (EL3 Runtime Software)" - echo "$0 fip # programs FIP (Firmware Image Package)" - echo "$0 uboot # programs u-boot (BL33, Non-trusted Firmware)" - echo "$0 atf # programs sa0+bl2+sa6+bl31 or bl2+fip all at once" - echo "$0 all # programs sa0+bl2+sa6+bl31+uboot or bl2+fip all at once" - echo "" - echo "$0 emmc_config # Configure an eMMC for booting (only needed once)" - echo "" - echo "$0 sw # Show the switch settings for Renesas boards (in case you forgot)" - echo "" - echo "$0 h # Show this help menu" - echo "" - echo " Note: You can also pass a filename on the command line." - echo " Example: $ $0 sa0 ../../arm-trusted-firmware/tools/dummy_create/bootparam_sa0.srec" -} - -################################################################# -# Script Start OPP -################################################################# - -# If the first argument is a filename, assume it is the config file. -if [ -e "$1" ] ; then - # Read in our settings - source $1 - CONFIG_FILE=$1 - - # The 2nd argument is the command - CMD=$2 -else - # The 1st argument is the command - CMD=$1 - - # If BOARD is not already set, assume config.ini as default - if [ "$BOARD" == "" ] && [ -e "config.ini" ] ; then - source config.ini - CONFIG_FILE=config.ini - else - if [ "$FW_GUI_MODE" != "2" ] ; then - echo "ERROR: Default file \"config.ini\" does not exit." - echo " Please make a copy the example_config.ini file" - echo " $ cp example_config.ini config.ini" - echo "" - echo " or pass a config filename on the command line as the first argument" - echo " $ cp my_config.ini help" - echo " " - echo " Please see Readme.md." - fi - fi -fi - - # RZ/G2L and RZ/V2L uses FIP instead of BL31 - if [ "$BOARD" == "smarc-rzg2l" ] || [ "$BOARD" == "smarc-rzg2lc" ] || [ "$BOARD" == "smarc-rzg2ul" ] || [ "$BOARD" == "smarc-rzv2l" ] ; then - FIP=1 - EMMC_4BIT=1 - fi - -# Usage is displayed when no arguments on command line -if [ "$CMD" == "h" ] ; then - print_usage - exit -fi - -if [ "$BOARD" == "" ] ; then - echo "ERROR: Board not selected in config.ini" - echo "Please edit config.ini in a text editor before continuing" - exit -fi - - -# Set BOARD_NAME and SW_SETTINGS -switch_settings - -# 0 = SPI Flash -# 1 = eMMC -if [ "$FLASH" == "" ] ; then - echo "ERROR: FLASH not selected in config.ini" - echo "Please edit config.ini in a text editor before continuing" - exit -fi - -# Set default tty interface if not set -if [ "$SERIAL_DEVICE_INTERFACE" == "" ] ; then - SERIAL_DEVICE_INTERFACE=/dev/ttyUSB0 - #SERIAL_DEVICE_INTERFACE=/dev/ttyACM0 -fi - -# Turn off some conversions that disrupt sending binary files over tty connections. -# These are already the defaults for /dev/ttyUSB0, so this requirement is really only for -# when using /dev/ttyACM0 -stty -icrnl -onlcr -isig -icanon -echoe -opost -F $SERIAL_DEVICE_INTERFACE - -# Change the inter-command delay times based on the interface and flash type -if [ "${SERIAL_DEVICE_INTERFACE:8:3}" == "ACM" ] ; then - # USB is so fast, almost no delay is needed. - CMD_DELAY="0.2" -elif [ "$FLASH" == "1" ] ; then - # eMMC commands over SPI flash seem to need more time because more - # text is output for each entry - CMD_DELAY="1" -else - # Programming SPI Flash over SCIF seems to only need a short delay - CMD_DELAY="0.5" - - if [ "$BOARD" == "smarc-rzg2l" ] || [ "$BOARD" == "smarc-rzg2lc" ] || [ "$BOARD" == "smarc-rzg2ul" ] || [ "$BOARD" == "smarc-rzv2l" ] ; then - CMD_DELAY="1.5" - fi -fi - -# Print current selected board -if [ "$FLASH" == "0" ] ; then - FLASH_TEXT="SPI Flash" # 0 = SPI Flash -else - FLASH_TEXT="eMMC Flash" # 1 = eMMC -fi - -echo "----------------------------------------------------" -echo " Board: $BOARD_NAME" -echo " Target: $FLASH_TEXT" -if [ "$CONFIG_FILE" != "" ] ; then -echo " Config: $CONFIG_FILE" -fi -echo "----------------------------------------------------" - -if [ "$CMD" == "fw" ] ; then - - if [ "$FLASHWRITER" == "" ] && [ "$2" != "" ] ; then - FLASHWRITER=$2 - fi - - if [ "$FW_GUI_MODE" != "2" ] ; then - echo "-----------------------------------------------------------------" - echo " Make sure the board is configured for \"SCIF Download mode"\" - echo " Power on the board and press the RESET button." - echo " Then, press ENTER on the keyboard to continue." - echo "-----------------------------------------------------------------" - read dummy - fi - echo "Sending Flash Writter Binary ($FLASHWRITER)" - stat -L --printf="%s bytes\n" $FLASHWRITER - #cat $FLASHWRITER > $SERIAL_DEVICE_INTERFACE - dd if=$FLASHWRITER of=$SERIAL_DEVICE_INTERFACE bs=1k status=progress - sleep 0.5 - # Clear out the extra left over characters - echo -en "\r" > $SERIAL_DEVICE_INTERFACE - echo "Complete" - exit -fi - -if [ "$CMD" == "sw" ] ; then - switch_settings - printf '%s\n' "$SW_SETTINGS" - exit -fi - -############################################ -echo "SERIAL_DEVICE_SPEED = $SERIAL_DEVICE_SPEED" -# Change to faster baud rate if needed -if [ "$SERIAL_DEVICE_SPEED" == "921600" ] ; then - # Check if already running fast - stty -F $SERIAL_DEVICE_INTERFACE | grep -q 921600 - if [ "$?" != "0" ] ; then - # send SUP command - echo -en "SUP\r" > $SERIAL_DEVICE_INTERFACE - sleep 1 - # Switch to high speed - stty -F $SERIAL_DEVICE_INTERFACE 921600 - sleep 0.5 - fi -fi - -if [ "$CMD" == "emmc_config" ] ; then - - # Set the EXT_CSD register 177 (0xB1) BOOT_BUS_CONDITIONS: - # RZ/G2E, RZ/G2N, RZ/G2M, RZ/G2H - # * BOOT_MODE bit[4:3] = 0x1 (Use single data rate + High Speed timings in boot operation mode)(50MHz SDR) - # * BOOT_BUS_WIDTH bit[1:0] = 0x2 (x8 bus width in boot operation mode) - # RZ/G2L, RZ/V2L - # * BOOT_MODE bit[4:3] = 0x0 (Use single data rate + backward compatible timings in boot operation (50MHz SDR) (default) - # * BOOT_BUS_WIDTH bit[1:0] = 0x1 (x4 bus width in boot operation mode) - echo "Setting EXT_CSD regiser 177..." - echo -en "EM_SECSD\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY - echo -en "b1\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY - if [ "$EMMC_4BIT" == "1" ] ; then - echo -en "02\r" > $SERIAL_DEVICE_INTERFACE - else - echo -en "0a\r" > $SERIAL_DEVICE_INTERFACE - fi - sleep $CMD_DELAY - - # Set the EXT_CSD register 179 (0xB3) PARTITION_CONFIG: - # * BOOT_ACK bit[6] = 0x0 (No boot acknowledge sent) - # * BOOT_PARTITION_ENABLE bit[5:3] = 0x1 (Boot partition 1 enabled for boot) - echo "Setting EXT_CSD regiser 179..." - echo -en "EM_SECSD\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY - echo -en "b3\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY - echo -en "08\r" > $SERIAL_DEVICE_INTERFACE - sleep $CMD_DELAY -fi - - -if [ "$CMD" == "sa0" ] || [ "$CMD" == "atf" ] || [ "$CMD" == "all" ] && [ "$FIP" == "0" ] ; then - if [ "$SA0_FILE" == "" ] && [ "$2" != "" ] ; then - SA0_FILE=$2 - fi - - if [ "$FLASH" == "0" ] ; then - do_spi_write "bootparam SA0" E6320000 000000 $SA0_FILE - else - do_emmc_write "bootparam SA0" 1 000000 E6320000 $SA0_FILE - fi - - if [ "$CMD" == "atf" ] || [ "$CMD" == "all" ] ; then - # We need extra time before starting the next operation - sleep 1 - fi -fi - -if [ "$CMD" == "bl2" ] || [ "$CMD" == "atf" ] || [ "$CMD" == "all" ] ; then - if [ "$BL2_FILE" == "" ] && [ "$2" != "" ] ; then - BL2_FILE=$2 - fi - if [ "$FLASH" == "0" ] ; then - if [ "$FIP" == "0" ] ; then - do_spi_write "BL2" E6304000 040000 $BL2_FILE - else - do_spi_write "BL2" 11E00 000000 $BL2_FILE - fi - else - if [ "$FIP" == "0" ] ; then - do_emmc_write "BL2" 1 00001E E6304000 $BL2_FILE - else - do_emmc_write "BL2" 1 000001 00011E00 $BL2_FILE - fi - fi - - if [ "$CMD" == "atf" ] || [ "$CMD" == "all" ] ; then - # We need extra time before starting the next operation - sleep 3 - fi -fi - -if [ "$CMD" == "sa6" ] || [ "$CMD" == "atf" ] || [ "$CMD" == "all" ] && [ "$FIP" == "0" ] ; then - if [ "$SA6_FILE" == "" ] && [ "$2" != "" ] ; then - SA6_FILE=$2 - fi - if [ "$FLASH" == "0" ] ; then - do_spi_write "Cert Header SA6" E6320000 180000 $SA6_FILE - else - do_emmc_write "Cert Header SA6" 1 000180 E6320000 $SA6_FILE - fi - - if [ "$CMD" == "atf" ] || [ "$CMD" == "all" ] ; then - # We need extra time before starting the next operation - sleep 1 - fi -fi - -if [ "$CMD" == "bl31" ] || [ "$CMD" == "atf" ] || [ "$CMD" == "all" ] && [ "$FIP" == "0" ] ; then - if [ "$BL31_FILE" == "" ] && [ "$2" != "" ] ; then - BL31_FILE=$2 - fi - if [ "$FLASH" == "0" ] ; then - do_spi_write "BL31" 44000000 1C0000 $BL31_FILE - else - do_emmc_write "BL31" 1 000200 44000000 $BL31_FILE - fi - - if [ "$CMD" == "atf" ] || [ "$CMD" == "all" ] ; then - # We need extra time before starting the next operation - sleep 3 - fi -fi - -if [ "$CMD" == "uboot" ] || [ "$CMD" == "all" ] && [ "$FIP" == "0" ] ; then - if [ "$UBOOT_FILE" == "" ] && [ "$2" != "" ] ; then - UBOOT_FILE=$2 - fi - if [ "$FLASH" == "0" ] ; then - do_spi_write "u-boot" 50000000 300000 $UBOOT_FILE - else - do_emmc_write "u-boot" 2 000000 50000000 $UBOOT_FILE - fi - - if [ "$CMD" == "all" ] ; then - # We need extra time before starting the next operation - sleep 3 - fi -fi - -if [ "$CMD" == "fip" ] || [ "$CMD" == "atf" ] || [ "$CMD" == "all" ] && [ "$FIP" == "1" ] ; then - if [ "$FIP_FILE" == "" ] && [ "$2" != "" ] ; then - FIP_FILE=$2 - fi - if [ "$FLASH" == "0" ] ; then - do_spi_write "FIP" 00000 1D200 $FIP_FILE - else - do_emmc_write "FIP" 1 100 00000000 $FIP_FILE - fi - - if [ "$CMD" == "atf" ] || [ "$CMD" == "all" ] ; then - # We need extra time before starting the next operation - sleep 3 - fi -fi diff --git a/build_scripts/usb_sd_partition.sh b/build_scripts/usb_sd_partition.sh deleted file mode 100755 index e7cbaf0..0000000 --- a/build_scripts/usb_sd_partition.sh +++ /dev/null @@ -1,234 +0,0 @@ -#!/bin/bash - -# This script will erase and reformat a 'USB Flash drive', a 'USB SD Card reader', -# or a 'SD Card reader' (plugged directly into a laptop) to be used for RZ/G Linux systems. -# It will have 2 partitions: -# 1. FAT16 partition (that can be access by Windows) -# 2. ext partition that can hold a Linux file system. - -# This script must run as root -if [[ $EUID -ne 0 ]]; then - echo -e "This script must be run as root. \nRestarting as root...\n" - echo -e "sudo $0\n" - sudo $0 - exit 1 -fi - -which whiptail > /dev/null -if [ "$?" != "0" ] ; then - echo "Whiptail not installed" - exit -fi - -function Find_Drives { - # Attached USB Drives show as /dev/sd# - # Laptops have SD card slots that show up as /dev/mmcblk - TEXT= - for i in sda sdb sdc sdd mmcblk0 - do - if [ -e /dev/${i} ] ; then - - if [ "${i:0:1}" == "s" ] ; then - dmesg | grep "${i}] Attached SCSI removable disk" > /dev/null - if [ "$?" != "0" ] ; then - continue - fi - fi - if [ "${i:0:1}" == "m" ] ; then - dmesg | grep "mmc0" | grep "card" > /dev/null - if [ "$?" != "0" ] ; then - continue - fi - fi - - ITEM="/dev/${i}" - DESC=`sudo fdisk -l /dev/${i} | grep -m1 ${i} | sed "s:Disk /dev/${i}::"` - - # add to end of array - TEXT=("${TEXT[@]}" "$ITEM" "$DESC") - fi - done -} - -# Discover our drives -Find_Drives - -# Add exit at the end of the array -TEXT=("${TEXT[@]}" "EXIT" "Cancel and exit the script") - -if [ "${TEXT[7]}" != "" ] ; then - DISK=$( - whiptail --title "Select your Drive" --menu "Below is a list of Removable Media found on your system" 0 0 0 \ - "${TEXT[1]}" "${TEXT[2]}"\ - "${TEXT[3]}" "${TEXT[4]}"\ - "${TEXT[5]}" "${TEXT[6]}"\ - "${TEXT[7]}" "${TEXT[8]}"\ - 3>&2 2>&1 1>&3 - ) -elif [ "${TEXT[5]}" != "" ] ; then - DISK=$( - whiptail --title "Select your Drive" --menu "Below is a list of Removable Media found on your system" 0 0 0 \ - "${TEXT[1]}" "${TEXT[2]}"\ - "${TEXT[3]}" "${TEXT[4]}"\ - "${TEXT[5]}" "${TEXT[6]}"\ - 3>&2 2>&1 1>&3 - ) -elif [ "${TEXT[3]}" != "" ] ; then - DISK=$( - whiptail --title "Select your Drive" --menu "Below is a list of Removable Media found on your system" 0 0 0 \ - "${TEXT[1]}" "${TEXT[2]}"\ - "${TEXT[3]}" "${TEXT[4]}"\ - 3>&2 2>&1 1>&3 - ) -else - DISK=$( - whiptail --title "Select your Drive" --menu "Below is a list of Removable Media found on your system" 0 0 0 \ - "${TEXT[1]}" "${TEXT[2]}"\ - 3>&2 2>&1 1>&3 - ) -fi - -if [ "$DISK" == "" ] || [ "$DISK" == "EXIT" ] ; then - echo "script canceled" - exit -else - echo DISK=$DISK -fi - - -FAT_SZ=$( -whiptail --title "Select Size of FAT Partition" --default-item "500M" --menu "What would you like the size of the FAT partition to be?\nThis will hold the kernel and Device Tree" 0 0 0 \ - "250M" ""\ - "500M" "(recomended)"\ - "750M" ""\ - "1G" ""\ - "EXIT" "Cancel and exit the script" \ - 3>&2 2>&1 1>&3 -) -if [ "$FAT_SZ" == "" ] || [ "$FAT_SZ" == "EXIT" ] ; then - echo "script canceled" - exit -else - # add in the + sign - FAT_SZ="+${FAT_SZ}" - echo FAT_SZ=$FAT_SZ -fi - -EXT_SZ=$( -whiptail --title "Select Size of EXT Partition" --default-item "max" --menu "What would you like the size of the EXT partition to be?\n\ -This will hold the entire file system.\n\ -You can select only a portion (2GB) of the remaining space in case you would\n\ -like to keep multiple images on this disk.\n\ -FYI: The larger the partition size, the longer it takes to format." 0 0 0 \ - "1G" ""\ - "2G" ""\ - "3G" ""\ - "4G" ""\ - "5G" ""\ - "6G" ""\ - "max" "(recomended) Use whatever is left"\ - "EXIT" "Cancel and exit the script" \ - 3>&2 2>&1 1>&3 -) -if [ "$EXT_SZ" == "" ] || [ "$EXT_SZ" == "EXIT" ] ; then - echo "script canceled" - exit -else - if [ "$EXT_SZ" == "max" ] ; then - # leave blank - EXT_SZ= - else - # add in the + sign - EXT_SZ="+${EXT_SZ}" - fi - echo EXT_SZ=$EXT_SZ -fi - -EXT_VER=$( -whiptail --title "Select EXT Partition filesystem" --default-item ext4 --menu "What filesystem would you like the EXT partition to be?\n\ -" 0 0 0 \ - "ext2" ""\ - "ext3" ""\ - "ext4" "(recomended) "\ - "EXIT" "Cancel and exit the script" \ - 3>&2 2>&1 1>&3 -) -if [ "$EXT_VER" == "" ] || [ "$EXT_VER" == "EXIT" ] ; then - echo "script canceled" - exit -fi - -BEGIN=$( -whiptail --title "Confirm" --yesno "Begin formatting?" 0 0 \ - 3>&2 2>&1 1>&3 -) -if [ "$?" != "0" ] ; then - echo "script canceled" - exit -fi - -sleep 1 - -echo -e "\nFormatting Flash Device ${DISK}" -echo -en "3" ; sleep 1 ; echo -en "\b2" ; sleep 1 ; echo -en "\b1" ; sleep 1 ; echo -e "\b " - -echo -e "\n== Unmounting current partitions ==" -sleep 1 -for i in 1 2 3 4 -do - if [ "${DISK}" == "/dev/mmcblk0" ] ; then - i="p${i}" - fi - - CHECK=`mount | grep ${DISK}${i}` - if [ "$CHECK" != "" ] ; then - echo "Unmounting ${DISK}${i} : umount ${DISK}${i}" - umount ${DISK}${i} - sleep 1 - fi -done - -echo -e "\n== Destroying Master Boot Record (sector 0) ==" -sleep 1 -echo dd if=/dev/zero of=${DISK} bs=512 count=1 -dd if=/dev/zero of=${DISK} bs=512 count=1 -sync - - -# Create 2 primary partitions -# 500MB (FAT16) + 6GB (ext3) -echo -e "\n== Creating partitions ==" -sleep 1 -echo -e "n\np\n1\n\n${FAT_SZ}\n"\ - "n\np\n2\n\n${EXT_SZ}\n"\ - "t\n1\n6\n"\ - "p\nw\n" | fdisk -u ${DISK} - -echo -e "\n== Formatting FAT16 partition ==" -if [ "${DISK}" == "/dev/mmcblk0" ] ; then - PART_NUMBER="p1" -else - PART_NUMBER="1" -fi - -mkfs.vfat -F16 -n RZ_FAT ${DISK}${PART_NUMBER} -sleep 1 - -echo -e "\n== Formatting $EXT_VER partition ==" -if [ "${DISK}" == "/dev/mmcblk0" ] ; then - PART_NUMBER="p2" -else - PART_NUMBER="2" -fi -mkfs.${EXT_VER} -F -L RZ_ext ${DISK}${PART_NUMBER} -sleep 1 - -if [ "${DISK}" == "/dev/mmcblk0" ] ; then - whiptail --title "== Finished ==" --msgbox "Please remove the SD Card from the system, then plug it back in" 0 0 -else - whiptail --title "== Finished ==" --msgbox "Please unplug the USB drive from the system, then plug it back in" 0 0 -fi -#fdisk -l ${DISK} - -#notify-send -t 2000 "Done" - diff --git a/configs/buildroot/rz-solidrun_defconfig b/configs/buildroot/rz-solidrun_defconfig index aad0562..2065f57 100644 --- a/configs/buildroot/rz-solidrun_defconfig +++ b/configs/buildroot/rz-solidrun_defconfig @@ -8,7 +8,6 @@ BR2_GCC_ENABLE_LTO=y BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y BR2_TARGET_GENERIC_ROOT_PASSWD="root" BR2_TARGET_GENERIC_GETTY_PORT="ttySC0" -BR2_ROOTFS_OVERLAY="../../overlay/buildroot" BR2_PACKAGE_BLUEZ_ALSA=y BR2_PACKAGE_BLUEZ_ALSA_HCITOP=y BR2_PACKAGE_XZ=y @@ -67,7 +66,7 @@ BR2_PACKAGE_IPSET=y BR2_PACKAGE_IPUTILS=y BR2_PACKAGE_IW=y BR2_PACKAGE_NET_TOOLS=y -BR2_PACKAGE_NETSTAT_NAT=y +# BR2_PACKAGE_NETSTAT_NAT=y BR2_PACKAGE_NTP=y BR2_PACKAGE_OPENSSH=y BR2_PACKAGE_PHYTOOL=y @@ -78,9 +77,19 @@ BR2_PACKAGE_WPA_SUPPLICANT_AUTOSCAN=y BR2_PACKAGE_WPA_SUPPLICANT_PASSPHRASE=y BR2_PACKAGE_HTOP=y BR2_PACKAGE_KMOD_TOOLS=y +BR2_PACKAGE_DOSFSTOOLS=y +BR2_PACKAGE_UTIL_LINUX=y +BR2_PACKAGE_UTIL_LINUX_BINARIES=y +BR2_PACKAGE_UTIL_LINUX_LIBMOUNT=y +BR2_PACKAGE_UTIL_LINUX_MOUNT=y BR2_PACKAGE_UTIL_LINUX_RFKILL=y +BR2_PACKAGE_UTIL_LINUX_HWCLOCK=y +BR2_PACKAGE_UTIL_LINUX_ZRAMCTL=y +BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y +BR2_PACKAGE_COREUTILS=y +BR2_PACKAGE_EVTEST=y BR2_TARGET_ROOTFS_CPIO=y BR2_TARGET_ROOTFS_CPIO_GZIP=y -BR2_TARGET_ROOTFS_EXT2=y -BR2_TARGET_ROOTFS_EXT2_4=y -BR2_TARGET_ROOTFS_EXT2_SIZE="150M" +BR2_TARGET_ROOTFS_TAR=y +BR2_TARGET_ROOTFS_TAR_GZIP=y +BR2_PER_PACKAGE_DIRECTORIES=y diff --git a/configs/debian/config.sh b/configs/debian/config.sh new file mode 100644 index 0000000..3696534 --- /dev/null +++ b/configs/debian/config.sh @@ -0,0 +1,7 @@ +DEBIAN_RELEASE="bookworm" +DEBIAN_MIRROR="https://deb.debian.org/debian" +DEBIAN_PACKAGES="apt-transport-https,busybox,ca-certificates,can-utils,\ +command-not-found,chrony,curl,e2fsprogs,ethtool,fdisk,gpiod,haveged,\ +i2c-tools,ifupdown,iputils-ping,isc-dhcp-client,initramfs-tools,libiio-utils,\ +lm-sensors,locales,nano,net-tools,ntpdate,openssh-server,psmisc,rfkill,sudo,\ +systemd,systemd-sysv,dbus,tio,usbutils,wget,xterm,xz-utils,zram-tools" diff --git a/configs/debian/stage2.sh b/configs/debian/stage2.sh new file mode 100755 index 0000000..5147ab6 --- /dev/null +++ b/configs/debian/stage2.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# run second-stage bootstrap +/debootstrap/debootstrap --second-stage + +# set empty root password +passwd -d root + +# delete self +rm -f /stage2.sh + +# flush disk +sync + +# power-off +reboot -f \ No newline at end of file diff --git a/configs/image/binman-boot-image.dts b/configs/image/binman-boot-image.dts new file mode 100644 index 0000000..a16c2a6 --- /dev/null +++ b/configs/image/binman-boot-image.dts @@ -0,0 +1,90 @@ +/dts-v1/; + +/ { + description = "Bootloader Images"; + #address-cells = <1>; + binman { + multiple-images; + image-sd { + description = "SD boot image"; + filename = "boot_image_sd.bin"; + size = <0x400000>; // 4MB total size + pad-byte = <0x00>; // Padding byte + + bootparams { + description = "Bootbarams"; + type = "blob"; + filename = "bootparams.bin"; + offset = <0x200>; + }; + + bl2 { + description = "BL2 Bootloader"; + type = "blob"; + filename = "bl2.bin"; + offset = <0x1000>; + }; + + fip { + description = "Firmware Image Package (FIP)"; + type = "blob"; + filename = "fip.bin"; + offset = <0x10000>; + }; + + fit { + description = "Flattened Image Tree (FIT)"; + type = "blob"; + filename = "overlays.itb"; + offset = <0x300000>; + }; + + // ubootenv { + // description = "U-Boot Environment"; + // type = "blob"; + // filename = "uboot.env"; // U-Boot environment file + // offset = <0x3c0000>; + // }; + }; + image-mmc { + description = "MMC boot image"; + filename = "boot_image_mmc.bin"; + size = <0x400000>; // 4MB total size + pad-byte = <0x00>; // Padding byte + + bootparams { + description = "Bootparams"; + type = "blob"; + filename = "bootparams.bin"; + offset = <0x200>; + }; + + bl2 { + description = "BL2 Bootloader"; + type = "blob"; + filename = "bl2.bin"; + }; + + fip { + description = "Firmware Image Package (FIP)"; + type = "blob"; + filename = "fip.bin"; + offset = <0x20000>; + }; + + fit { + description = "Flattened Image Tree (FIT)"; + type = "blob"; + filename = "overlays.itb"; + offset = <0x300000>; + }; + + // ubootenv { + // description = "U-Boot Environment"; + // type = "blob"; + // filename = "uboot.env"; // U-Boot environment file + // offset = <0x3c0000>; + // }; + }; + }; +}; diff --git a/configs/image/extlinux.conf.tmpl b/configs/image/extlinux.conf.tmpl new file mode 100644 index 0000000..97d368a --- /dev/null +++ b/configs/image/extlinux.conf.tmpl @@ -0,0 +1,16 @@ +timeout 1 +prompt 1 +default primary +menu title RZ/G2* boot options +label primary + menu label mmc boot + linux /Image.gz + fdtdir /dtb + APPEND root=PARTUUID=%PARTUUID% rw rootwait + +label secondary + menu label initrd boot + linux /Image.gz + fdtdir /dtb + initrd /initrd.img + APPEND root=/dev/ram0 rw rootwait diff --git a/configs/image/overlays-fit.its b/configs/image/overlays-fit.its new file mode 100644 index 0000000..fdf1515 --- /dev/null +++ b/configs/image/overlays-fit.its @@ -0,0 +1,24 @@ +/dts-v1/; + +/ { + description = "Device Tree Overlays Image"; + #address-cells = <1>; + + images { + sd_overlay { + description = "SD Card Overlay"; + data = /incbin/("sd-overlay.dtbo"); + type = "flat_dt"; + arch = "arm"; + compression = "none"; + }; + + mmc_overlay { + description = "MMC Overlay"; + data = /incbin/("mmc-overlay.dtbo"); + type = "flat_dt"; + arch = "arm"; + compression = "none"; + }; + }; +}; diff --git a/configs/linux/rz-solidrun_defconfig b/configs/linux/rz-solidrun_defconfig index 79d946b..e4df06a 100644 --- a/configs/linux/rz-solidrun_defconfig +++ b/configs/linux/rz-solidrun_defconfig @@ -75,6 +75,10 @@ CONFIG_CRYPTO_CHACHA20_NEON=y CONFIG_CRYPTO_POLY1305_NEON=y CONFIG_CRYPTO_NHPOLY1305_NEON=y CONFIG_CRYPTO_AES_ARM64_BS=y +CONFIG_CRYPTO_LZO=y +CONFIG_CRYPTO_LZ4=y +CONFIG_CRYPTO_LZ4HC=y +CONFIG_CRYPTO_ZSTD=y CONFIG_JUMP_LABEL=y CONFIG_MODULES=y CONFIG_MODULE_UNLOAD=y @@ -543,7 +547,7 @@ CONFIG_MTD_SPI_NOR=m CONFIG_ZRAM=y CONFIG_BLK_DEV_LOOP=y CONFIG_BLK_DEV_NBD=m -CONFIG_BLK_DEV_RAM=m +CONFIG_BLK_DEV_RAM=y # CONFIG_XEN_BLKDEV_FRONTEND is not set CONFIG_VIRTIO_BLK=y CONFIG_SRAM=y @@ -638,12 +642,13 @@ CONFIG_INPUT_UINPUT=m CONFIG_SERIAL_AMBA_PL011=y CONFIG_SERIAL_AMBA_PL011_CONSOLE=y CONFIG_SERIAL_SH_SCI=y +CONFIG_SERIAL_SH_SCI_DMA=n CONFIG_SERIAL_DEV_BUS=y CONFIG_VIRTIO_CONSOLE=y # CONFIG_HW_RANDOM is not set CONFIG_I2C_CHARDEV=y -CONFIG_I2C_MUX=y -CONFIG_I2C_MUX_PCA954x=y +# CONFIG_I2C_MUX=y +# CONFIG_I2C_MUX_PCA954x=y CONFIG_I2C_DESIGNWARE_PLATFORM=y CONFIG_I2C_RIIC=y CONFIG_I2C_SH_MOBILE=y @@ -827,7 +832,7 @@ CONFIG_EXT4_FS_POSIX_ACL=y CONFIG_FANOTIFY=y CONFIG_QUOTA=y CONFIG_AUTOFS4_FS=y -CONFIG_FUSE_FS=m +CONFIG_FUSE_FS=y CONFIG_OVERLAY_FS=m CONFIG_VFAT_FS=y CONFIG_TMPFS=y @@ -858,3 +863,31 @@ CONFIG_DEBUG_FS=y # CONFIG_FTRACE is not set CONFIG_BT_HCIUART_RENESAS=y CONFIG_MAC80211=y +CONFIG_REGULATOR_RAA215300=y +CONFIG_VIDEO_AR0521=m + +CONFIG_MULTIPLXER=y +CONFIG_MUX_GPIO=y +CONFIG_SPI_MUX=y + +CONFIG_I2C_MUX_GPIO=m +CONFIG_I2C_MUX_GPMUX=m +CONFIG_I2C_MUX=m +CONFIG_I2C_MUX_PCA954x=m + +CONFIG_BACKLIGHT_LED=m +CONFIG_LEDS_CLASS_MULTICOLOR=m +CONFIG_LEDS_LP55XX_COMMON=m +# CONFIG_LEDS_LP5521 is not set +# CONFIG_LEDS_LP5523 is not set +CONFIG_LEDS_LP5562=m +# CONFIG_LEDS_LP8501 is not set +CONFIG_DRM_PANEL_RONBO_RB070D30=m +CONFIG_BACKLIGHT_GPIO=m + +CONFIG_TCG_TPM=m +CONFIG_TCG_TIS=m +CONFIG_TCG_TIS_SPI=m + +CONFIG_TOUCHSCREEN_PROPERTIES=m +CONFIG_TOUCHSCREEN_ILITEK=m diff --git a/docker/Dockerfile b/docker/Dockerfile index bdc1856..8ee277d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,5 @@ # use ubuntu base -FROM ubuntu:focal +FROM ubuntu:24.04 # retry at least 3 times to succeed on sketchy connections RUN printf 'Acquire::http { Proxy "%s"; };\n' $APTPROXY | tee -a /etc/apt/apt.conf.d/proxy @@ -11,21 +11,17 @@ RUN printf 'Acquire::Retries 3;\n' | tee -a /etc/apt/apt.conf.d/retry || true # prevent dpkg interactive dialogues ENV DEBIAN_FRONTEND=noninteractive -# update -RUN set -e; \ - apt-get update; \ - apt-get -y upgrade; \ - : - -RUN set -e; \ - apt-get update; \ - apt-get --no-install-recommends -y install bash bc binutils bison build-essential chrpath coreutils cpio \ - device-tree-compiler diffstat dosfstools e2fsprogs e2tools file flex g++ gawk gcc git kmod \ - libncurses5-dev libncursesw5-dev libssl-dev make meson mtools ninja-build p7zip p7zip-full \ - parted patch python python2 python3 python3-pip python3-pyelftools rsync sed sudo tar texinfo \ - u-boot-tools udev unzip util-linux wget genext2fs debootstrap fakeroot qemu-system-aarch64 \ - ccache; \ - : +RUN apt-get update && apt-get --no-install-recommends -y install bash git \ + bc bison build-essential coccinelle ccache \ + device-tree-compiler dfu-util efitools flex gdisk graphviz imagemagick \ + liblz4-tool libgnutls28-dev libguestfs-tools libncurses-dev \ + libpython3-dev libsdl2-dev libssl-dev lz4 lzma lzma-alone openssl \ + pkg-config python3 python3-asteval python3-coverage python3-filelock \ + python3-pkg-resources python3-pycryptodome python3-pyelftools \ + python3-pytest python3-pytest-xdist python3-sphinxcontrib.apidoc \ + python3-sphinx-rtd-theme python3-subunit python3-testtools \ + python3-virtualenv swig uuid-dev u-boot-tools dosfstools python3-libfdt \ + qemu-system-arm e2tools bmap-tools patch fakeroot debootstrap unzip rsync # build environment WORKDIR /work diff --git a/docker/entry.sh b/docker/entry.sh index 7771c37..b580797 100644 --- a/docker/entry.sh +++ b/docker/entry.sh @@ -13,27 +13,29 @@ # declare flags DEFINE_integer 'uid' 1000 'User ID to run as' 'u' -DEFINE_integer 'gid' 100 'Group ID to run as' 'g' +DEFINE_integer 'gid' 1000 'Group ID to run as' 'g' # parse flags FLAGS "$@" || exit 1 eval set -- "${FLAGS_ARGV}" # create build-user and group if not root -user=root -HOME=/root -if [ "x${FLAGS_uid}" != "x0" ]; then - user=build - HOME=/home/build - groupadd -g ${FLAGS_gid} build 2>/dev/null || true - useradd -s /bin/bash -u ${FLAGS_uid} -g ${FLAGS_gid} -m -d ${HOME} -G sudo build - echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers -fi +# user=root +# HOME=/root +# if [ "x${FLAGS_uid}" != "x0" ]; then +# user=build +# HOME=/home/build +# groupadd -g ${FLAGS_gid} build 2>/dev/null || true +# useradd -s /bin/bash -u ${FLAGS_uid} -g ${FLAGS_gid} -m -d ${HOME} -G sudo build +# echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers +# fi # preconfigure git identity -GIT_DIR=/dev/null git config --system user.name "RZG2L Toolchain Container" -GIT_DIR=/dev/null git config --system user.email "support@solid-run.com" +# GIT_DIR=/dev/null git config --system user.name "RZG2L Toolchain Container" +# GIT_DIR=/dev/null git config --system user.email "support@solid-run.com" cd /work # now run the build script as the build user -sudo -u $user -E ./runme.sh +# sudo -u $user -E ./runme.sh +# ./runme.sh +bash \ No newline at end of file diff --git a/overlay/buildroot/etc/init.d/rcS b/overlay/buildroot/etc/init.d/rcS deleted file mode 100755 index bd11d5a..0000000 --- a/overlay/buildroot/etc/init.d/rcS +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh - - -# Start all init scripts in /etc/init.d -# executing them in numerical order. -# -for i in /etc/init.d/S??* ;do - - # Ignore dangling symlinks (if any). - [ ! -f "$i" ] && continue - - case "$i" in - *.sh) - # Source shell script for speed. - ( - trap - INT QUIT TSTP - set start - . $i - ) - ;; - *) - # No sh extension, so fork subprocess. - $i start - ;; - esac -done diff --git a/overlay/buildroot/etc/environment b/overlay/common/etc/environment similarity index 100% rename from overlay/buildroot/etc/environment rename to overlay/common/etc/environment diff --git a/overlay/common/etc/fstab b/overlay/common/etc/fstab new file mode 100644 index 0000000..f863561 --- /dev/null +++ b/overlay/common/etc/fstab @@ -0,0 +1,10 @@ +# +/dev/root / ext4 rw,noauto 0 1 +proc /proc proc defaults 0 0 +devpts /dev/pts devpts defaults,gid=5,mode=620,ptmxmode=0666 0 0 +tmpfs /dev/shm tmpfs mode=1777 0 0 +tmpfs /tmp tmpfs mode=1777 0 0 +tmpfs /run tmpfs mode=0755,nosuid,nodev 0 0 +sysfs /sys sysfs defaults 0 0 +debugfs /sys/kernel/debug debugfs defaults 0 0 +/dev/mmcblk0p1 /boot vfat defaults 0 0 diff --git a/overlay/buildroot/etc/ssh/sshd_config b/overlay/common/etc/ssh/sshd_config similarity index 100% rename from overlay/buildroot/etc/ssh/sshd_config rename to overlay/common/etc/ssh/sshd_config diff --git a/overlay/buildroot/lib/firmware/brcm/BCM.hcd b/overlay/common/lib/firmware/brcm/BCM.hcd similarity index 100% rename from overlay/buildroot/lib/firmware/brcm/BCM.hcd rename to overlay/common/lib/firmware/brcm/BCM.hcd diff --git a/overlay/buildroot/lib/firmware/brcm/BCM4343A2.hcd b/overlay/common/lib/firmware/brcm/BCM4343A2.hcd similarity index 100% rename from overlay/buildroot/lib/firmware/brcm/BCM4343A2.hcd rename to overlay/common/lib/firmware/brcm/BCM4343A2.hcd diff --git a/overlay/buildroot/lib/firmware/brcm/BCM4345C0.hcd b/overlay/common/lib/firmware/brcm/BCM4345C0.hcd similarity index 100% rename from overlay/buildroot/lib/firmware/brcm/BCM4345C0.hcd rename to overlay/common/lib/firmware/brcm/BCM4345C0.hcd diff --git a/overlay/buildroot/lib/firmware/brcm/CYW4343A2.hcd b/overlay/common/lib/firmware/brcm/CYW4343A2.hcd similarity index 100% rename from overlay/buildroot/lib/firmware/brcm/CYW4343A2.hcd rename to overlay/common/lib/firmware/brcm/CYW4343A2.hcd diff --git a/overlay/buildroot/lib/firmware/brcm/brcmfmac43439-sdio.1YN.clm_blob b/overlay/common/lib/firmware/brcm/brcmfmac43439-sdio.1YN.clm_blob similarity index 100% rename from overlay/buildroot/lib/firmware/brcm/brcmfmac43439-sdio.1YN.clm_blob rename to overlay/common/lib/firmware/brcm/brcmfmac43439-sdio.1YN.clm_blob diff --git a/overlay/buildroot/lib/firmware/brcm/brcmfmac43439-sdio.bin b/overlay/common/lib/firmware/brcm/brcmfmac43439-sdio.bin similarity index 100% rename from overlay/buildroot/lib/firmware/brcm/brcmfmac43439-sdio.bin rename to overlay/common/lib/firmware/brcm/brcmfmac43439-sdio.bin diff --git a/overlay/buildroot/lib/firmware/brcm/brcmfmac43439-sdio.clm_blob b/overlay/common/lib/firmware/brcm/brcmfmac43439-sdio.clm_blob similarity index 100% rename from overlay/buildroot/lib/firmware/brcm/brcmfmac43439-sdio.clm_blob rename to overlay/common/lib/firmware/brcm/brcmfmac43439-sdio.clm_blob diff --git a/overlay/buildroot/lib/firmware/brcm/brcmfmac43439-sdio.renesas,r9a07g044c2.bin b/overlay/common/lib/firmware/brcm/brcmfmac43439-sdio.renesas,r9a07g044c2.bin similarity index 100% rename from overlay/buildroot/lib/firmware/brcm/brcmfmac43439-sdio.renesas,r9a07g044c2.bin rename to overlay/common/lib/firmware/brcm/brcmfmac43439-sdio.renesas,r9a07g044c2.bin diff --git a/overlay/buildroot/lib/firmware/brcm/brcmfmac43439-sdio.renesas,r9a07g044c2.clm_blob b/overlay/common/lib/firmware/brcm/brcmfmac43439-sdio.renesas,r9a07g044c2.clm_blob similarity index 100% rename from overlay/buildroot/lib/firmware/brcm/brcmfmac43439-sdio.renesas,r9a07g044c2.clm_blob rename to overlay/common/lib/firmware/brcm/brcmfmac43439-sdio.renesas,r9a07g044c2.clm_blob diff --git a/overlay/buildroot/lib/firmware/brcm/brcmfmac43439-sdio.renesas,r9a07g044c2.txt b/overlay/common/lib/firmware/brcm/brcmfmac43439-sdio.renesas,r9a07g044c2.txt similarity index 100% rename from overlay/buildroot/lib/firmware/brcm/brcmfmac43439-sdio.renesas,r9a07g044c2.txt rename to overlay/common/lib/firmware/brcm/brcmfmac43439-sdio.renesas,r9a07g044c2.txt diff --git a/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.renesas,r9a07g044c2.txt b/overlay/common/lib/firmware/brcm/brcmfmac43439-sdio.renesas,rzg2lc-sr-som.txt similarity index 100% rename from overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.renesas,r9a07g044c2.txt rename to overlay/common/lib/firmware/brcm/brcmfmac43439-sdio.renesas,rzg2lc-sr-som.txt diff --git a/overlay/buildroot/lib/firmware/brcm/brcmfmac43439-sdio.renesas,smarc-evk.bin b/overlay/common/lib/firmware/brcm/brcmfmac43439-sdio.renesas,smarc-evk.bin similarity index 100% rename from overlay/buildroot/lib/firmware/brcm/brcmfmac43439-sdio.renesas,smarc-evk.bin rename to overlay/common/lib/firmware/brcm/brcmfmac43439-sdio.renesas,smarc-evk.bin diff --git a/overlay/buildroot/lib/firmware/brcm/brcmfmac43439-sdio.txt b/overlay/common/lib/firmware/brcm/brcmfmac43439-sdio.txt similarity index 100% rename from overlay/buildroot/lib/firmware/brcm/brcmfmac43439-sdio.txt rename to overlay/common/lib/firmware/brcm/brcmfmac43439-sdio.txt diff --git a/overlay/buildroot/lib/firmware/brcm/brcmfmac43455-sdio.bin b/overlay/common/lib/firmware/brcm/brcmfmac43455-sdio.bin similarity index 100% rename from overlay/buildroot/lib/firmware/brcm/brcmfmac43455-sdio.bin rename to overlay/common/lib/firmware/brcm/brcmfmac43455-sdio.bin diff --git a/overlay/buildroot/lib/firmware/brcm/brcmfmac43455-sdio.clm_blob b/overlay/common/lib/firmware/brcm/brcmfmac43455-sdio.clm_blob similarity index 100% rename from overlay/buildroot/lib/firmware/brcm/brcmfmac43455-sdio.clm_blob rename to overlay/common/lib/firmware/brcm/brcmfmac43455-sdio.clm_blob diff --git a/overlay/buildroot/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.bin b/overlay/common/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.bin similarity index 100% rename from overlay/buildroot/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.bin rename to overlay/common/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.bin diff --git a/overlay/buildroot/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.clm_blob b/overlay/common/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.clm_blob similarity index 100% rename from overlay/buildroot/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.clm_blob rename to overlay/common/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.clm_blob diff --git a/overlay/buildroot/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.txt b/overlay/common/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.txt similarity index 100% rename from overlay/buildroot/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.txt rename to overlay/common/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.txt diff --git a/overlay/buildroot/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.bin b/overlay/common/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.bin similarity index 100% rename from overlay/buildroot/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.bin rename to overlay/common/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.bin diff --git a/overlay/buildroot/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.clm_blob b/overlay/common/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.clm_blob similarity index 100% rename from overlay/buildroot/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.clm_blob rename to overlay/common/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.clm_blob diff --git a/overlay/buildroot/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.txt b/overlay/common/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.txt similarity index 99% rename from overlay/buildroot/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.txt rename to overlay/common/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.txt index 0cffd27..ff4a2f5 100755 --- a/overlay/buildroot/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.txt +++ b/overlay/common/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.txt @@ -15,7 +15,7 @@ xtalfreq=37400 #xtal_swcapio=0x6644 boardflags=0x00080201 boardflags2=0x40000000 -boardflags3=0x48200100 +boardflags3=0x44200100 rxchain=1 txchain=1 aa2g=1 diff --git a/overlay/buildroot/lib/firmware/brcm/brcmfmac43455-sdio.txt b/overlay/common/lib/firmware/brcm/brcmfmac43455-sdio.txt similarity index 100% rename from overlay/buildroot/lib/firmware/brcm/brcmfmac43455-sdio.txt rename to overlay/common/lib/firmware/brcm/brcmfmac43455-sdio.txt diff --git a/overlay/buildroot/lib/firmware/cypress/cyfmac43439-sdio.1YN.clm_blob b/overlay/common/lib/firmware/cypress/cyfmac43439-sdio.1YN.clm_blob similarity index 100% rename from overlay/buildroot/lib/firmware/cypress/cyfmac43439-sdio.1YN.clm_blob rename to overlay/common/lib/firmware/cypress/cyfmac43439-sdio.1YN.clm_blob diff --git a/overlay/buildroot/lib/firmware/cypress/cyfmac43439-sdio.bin b/overlay/common/lib/firmware/cypress/cyfmac43439-sdio.bin similarity index 100% rename from overlay/buildroot/lib/firmware/cypress/cyfmac43439-sdio.bin rename to overlay/common/lib/firmware/cypress/cyfmac43439-sdio.bin diff --git a/overlay/buildroot/lib/firmware/lmacfw_spi.bin b/overlay/common/lib/firmware/lmacfw_spi.bin similarity index 100% rename from overlay/buildroot/lib/firmware/lmacfw_spi.bin rename to overlay/common/lib/firmware/lmacfw_spi.bin diff --git a/overlay/buildroot/lib/firmware/renesas/hci_531.bin b/overlay/common/lib/firmware/renesas/hci_531.bin similarity index 100% rename from overlay/buildroot/lib/firmware/renesas/hci_531.bin rename to overlay/common/lib/firmware/renesas/hci_531.bin diff --git a/overlay/debian/etc/environment b/overlay/debian/etc/environment deleted file mode 100644 index 3116e87..0000000 --- a/overlay/debian/etc/environment +++ /dev/null @@ -1 +0,0 @@ -PAN_MESA_DEBUG="noafbc" diff --git a/overlay/debian/etc/network/interfaces.d/eth0 b/overlay/debian/etc/network/interfaces.d/eth0 deleted file mode 100644 index 3fb30ea..0000000 --- a/overlay/debian/etc/network/interfaces.d/eth0 +++ /dev/null @@ -1,3 +0,0 @@ -allow-hotplug eth0 -iface eth0 inet dhcp -iface eth0 inet6 auto diff --git a/overlay/debian/lib/firmware/brcm/BCM.hcd b/overlay/debian/lib/firmware/brcm/BCM.hcd deleted file mode 100644 index cf117cc..0000000 Binary files a/overlay/debian/lib/firmware/brcm/BCM.hcd and /dev/null differ diff --git a/overlay/debian/lib/firmware/brcm/BCM4343A2.hcd b/overlay/debian/lib/firmware/brcm/BCM4343A2.hcd deleted file mode 120000 index 668029e..0000000 --- a/overlay/debian/lib/firmware/brcm/BCM4343A2.hcd +++ /dev/null @@ -1 +0,0 @@ -CYW4343A2.hcd \ No newline at end of file diff --git a/overlay/debian/lib/firmware/brcm/BCM4345C0.hcd b/overlay/debian/lib/firmware/brcm/BCM4345C0.hcd deleted file mode 100644 index ee7c32a..0000000 Binary files a/overlay/debian/lib/firmware/brcm/BCM4345C0.hcd and /dev/null differ diff --git a/overlay/debian/lib/firmware/brcm/CYW4343A2.hcd b/overlay/debian/lib/firmware/brcm/CYW4343A2.hcd deleted file mode 100644 index cf117cc..0000000 Binary files a/overlay/debian/lib/firmware/brcm/CYW4343A2.hcd and /dev/null differ diff --git a/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.1YN.clm_blob b/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.1YN.clm_blob deleted file mode 100644 index 9691ba5..0000000 Binary files a/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.1YN.clm_blob and /dev/null differ diff --git a/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.bin b/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.bin deleted file mode 100644 index 650d427..0000000 Binary files a/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.bin and /dev/null differ diff --git a/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.clm_blob b/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.clm_blob deleted file mode 100644 index 9691ba5..0000000 Binary files a/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.clm_blob and /dev/null differ diff --git a/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.renesas,r9a07g044c2.bin b/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.renesas,r9a07g044c2.bin deleted file mode 120000 index 5f91377..0000000 --- a/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.renesas,r9a07g044c2.bin +++ /dev/null @@ -1 +0,0 @@ -brcmfmac43439-sdio.bin \ No newline at end of file diff --git a/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.renesas,r9a07g044c2.clm_blob b/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.renesas,r9a07g044c2.clm_blob deleted file mode 120000 index a2c3f77..0000000 --- a/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.renesas,r9a07g044c2.clm_blob +++ /dev/null @@ -1 +0,0 @@ -brcmfmac43439-sdio.clm_blob \ No newline at end of file diff --git a/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.renesas,smarc-evk.bin b/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.renesas,smarc-evk.bin deleted file mode 100644 index 650d427..0000000 Binary files a/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.renesas,smarc-evk.bin and /dev/null differ diff --git a/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.txt b/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.txt deleted file mode 100644 index ada5fff..0000000 --- a/overlay/debian/lib/firmware/brcm/brcmfmac43439-sdio.txt +++ /dev/null @@ -1,81 +0,0 @@ -# NVRAM file for CYW943439WLPTH -# 2.4 GHz, 20 MHz BW mode - -# The following parameter values are just placeholders, need to be updated. -NVRAMRev=$Rev: 726808 $ -manfid=0x2d0 -prodid=0x0727 -vendid=0x14e4 -devid=0x43e2 -boardtype=0x0887 -boardrev=0x1101 -boardnum=22 -macaddr=00:90:4c:2d:a0:05 -sromrev=11 -#boardflags=0x00404201 -boardflags=0x00404001 -boardflags3=0x08000000 -xtalfreq=37400 -nocrc=1 -ag0=255 -aa2g=1 -ccode=ALL - -pa0itssit=0x20 -extpagain2g=0 -#PA parameters for 2.4GHz, measured at CHIP OUTPUT -pa2ga0=-168,6777,-789 -AvVmid_c0=0x0,0xc8 -AvVmidIQcal=0x2,0xa8 -cckpwroffset0=5 - -# PPR params -maxp2ga0=74 -txpwrbckof=6 -cckbw202gpo=0 -legofdmbw202gpo=0x88888888 -mcsbw202gpo=0xaaaaaaaa -propbw202gpo=0xdd - -# OFDM IIR : -ofdmdigfilttype=18 -ofdmdigfilttypebe=18 -# PAPD mode: -papdmode=1 -papdvalidtest=1 -pacalidx2g=45 -papdepsoffset=-30 -papdendidx=58 - -# LTECX flags -ltecxmux=0 -ltecxpadnum=0x0102 -ltecxfnsel=0x44 -ltecxgcigpio=0x01 - -il0macaddr=00:90:4c:c5:12:38 -wl0id=0x431b - -deadman_to=0xffffffff -# muxenab: 0x1 for UART enable, 0x10 for HOST WAKE INT enable, 0x11 for both enable -# Power cycle required if change -muxenab=0x1 -# CLDO PWM voltage settings - 0x4 - 1.1 volt -#cldo_pwm=0x4 - -#VCO freq 326.4MHz -spurconfig=0x3 - -#SW based desense - Enable by default -#i.e using glitich statistcs as critria to change crsmin -glitch_based_crsmin=1 - -# Default btc_mode -btc_mode=0 -bt_default_ant=0 - -#Antenna diversity -#swdiv_en=1 -#swdiv_gpio=2 - -tempbased_duty_cycle_en=0 diff --git a/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.bin b/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.bin deleted file mode 100755 index 720dfdf..0000000 Binary files a/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.bin and /dev/null differ diff --git a/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.clm_blob b/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.clm_blob deleted file mode 100755 index 4e047a5..0000000 Binary files a/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.clm_blob and /dev/null differ diff --git a/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.bin b/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.bin deleted file mode 100755 index 720dfdf..0000000 Binary files a/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.bin and /dev/null differ diff --git a/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.clm_blob b/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.clm_blob deleted file mode 100755 index 4e047a5..0000000 Binary files a/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.clm_blob and /dev/null differ diff --git a/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.txt b/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.txt deleted file mode 100755 index 325ca98..0000000 --- a/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzg2l-sr-som.txt +++ /dev/null @@ -1,115 +0,0 @@ -# Cloned from bcm94345wlpagb.txt -NVRAMRev=$Rev: 498373 $ -sromrev=11 -vendid=0x14e4 -devid=0x43ab -manfid=0x2d0 -prodid=0x06e4 -macaddr=00:90:4c:c5:12:38 -nocrc=1 -boardtype=0x6e4 -##boardrev - superseded by the one in OTP -boardrev=0x1100 -xtalfreq=37400 -## tune where necessary -#xtal_swcapio=0x6644 -boardflags=0x00080201 -boardflags2=0x40000000 -# digit 7=4: use internal lpo -boardflags3=0x44200100 -rxchain=1 -txchain=1 -aa2g=1 -aa5g=1 -tssipos5g=1 -tssipos2g=1 -AvVmid_c0=0,157,1,126,1,126,1,126,1,126 -pa2ga0=-152,5969,-666 -pa2ga1=-143,4076,-546 -pa5ga0=-165,5736,-689,-169,5710,-692,-171,5713,-688,-173,5732,-689 -#pa5ga1=-161,3672,-510,-166,3671,-508,-169,3697,-508,-171,3854,-520 -itrsw=1 -pdoffset40ma0=0x9999 -pdoffset80ma0=0x8888 -extpagain5g=2 -extpagain2g=2 -maxp2ga0=74 -cckbw202gpo=0x0000 -ofdmlrbw202gpo=0x0022 -dot11agofdmhrbw202gpo=0x8888 -mcsbw202gpo=0xaaaaa666 -maxp5ga0=76,76,76,76 -mcsbw205glpo=0x99999955 -mcsbw205gmpo=0x99999955 -mcsbw205ghpo=0x99999955 -mcsbw405glpo=0xff999555 -mcsbw405gmpo=0xff999555 -mcsbw405ghpo=0xff999555 -mcsbw805glpo=0xfffffbbb -mcsbw805gmpo=0xfffffbbb -mcsbw805ghpo=0xfffffbbb -swctrlmap_2g=0x00040004,0x00020002,0x00040004,0x010a02,0x1ff -swctrlmap_5g=0x00100010,0x00200020,0x00200020,0x010a02,0x2f4 -swctrlmapext_5g=0x00000000,0x00000000,0x00000000,0x000000,0x000 -swctrlmapext_2g=0x00000000,0x00000000,0x00000000,0x000000,0x000 -vcodivmode=1 -##filter parameters -- tune where necessary -cckdigfilttype=6 -fdss_level_2g=2 -fdss_level_5g=2 -## added by apps -aga0=0x1 -agbg0=0x1 -ccode=0 -ed_thresh2g=-65 -ed_thresh5g=-65 -ltecxmux=0 -ltecxpadnum=0x0504 -ltecxfnsel=0x22 -ltecxgcigpio=0x32 -pdoffsetcckma0=0x0000 -powoffs2gtna0=0,0,0,0,0,0,0,0,0,0,0,0,0,0 -tempthresh=120 -temps_hysteresis=15 -rawtempsense=0x1ff -tworangetssi2g=1 -tworangetssi5g=0 -lowpowerrange2g=0 -lowpowerrange5g=0 -ag0=1 -ag1=1 -#subband5gver=0x4 -mcslr5glpo=0x0000 -mcslr5gmpo=0x0000 -mcslr5ghpo=0x0000 -sb20in40hrpo=0x0 -sb20in80and160hr5glpo=0x0 -sb40and80hr5glpo=0x0 -sb20in80and160hr5gmpo=0x0 -sb40and80hr5gmpo=0x0 -sb20in80and160hr5ghpo=0x0 -sb40and80hr5ghpo=0x0 -sb20in40lrpo=0x0 -sb20in80and160lr5glpo=0x0 -sb40and80lr5glpo=0x0 -sb20in80and160lr5gmpo=0x0 -sb40and80lr5gmpo=0x0 -sb20in80and160lr5ghpo=0x0 -sb40and80lr5ghpo=0x0 -dot11agduphrpo=0x0 -dot11agduplrpo=0x0 -phycal_tempdelta=25 -temps_period=15 -btc_mode=1 -sbpowoffs5g20mtna0=0,0,0,0 -sbpowoffs5g40mtna0=0,0,0,0 -sbpowoffs5g80mtna0=0,0,0,0 -powoffs5g20mtna0=0,0,0,0,0,0,0 -powoffs5g40mtna0=0,0,0,0,0 -powoffs5g80mtna0=0,0,0,0,0 -ldo1=5 -cbfilttype=2 -xtal_swcapio=0x8855 -fdss_level_ch13=1,1 -# muxenab defined to enable OOB IRQ. Level sensitive interrupt via WL_HOST_WAKE line. -muxenab=0x10 diff --git a/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.bin b/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.bin deleted file mode 100755 index 720dfdf..0000000 Binary files a/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.bin and /dev/null differ diff --git a/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.clm_blob b/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.clm_blob deleted file mode 100755 index 4e047a5..0000000 Binary files a/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.clm_blob and /dev/null differ diff --git a/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.txt b/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.txt deleted file mode 100755 index 0cffd27..0000000 --- a/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.renesas,rzv2l-sr-som.txt +++ /dev/null @@ -1,114 +0,0 @@ -# Cloned from bcm94345wlpagb.txt -NVRAMRev=$Rev: 498373 $ -sromrev=11 -vendid=0x14e4 -devid=0x43ab -manfid=0x2d0 -prodid=0x06e4 -macaddr=00:90:4c:c5:12:38 -nocrc=1 -boardtype=0x6e4 -##boardrev - superseded by the one in OTP -boardrev=0x1100 -xtalfreq=37400 -## tune where necessary -#xtal_swcapio=0x6644 -boardflags=0x00080201 -boardflags2=0x40000000 -boardflags3=0x48200100 -rxchain=1 -txchain=1 -aa2g=1 -aa5g=1 -tssipos5g=1 -tssipos2g=1 -AvVmid_c0=0,157,1,126,1,126,1,126,1,126 -pa2ga0=-152,5969,-666 -pa2ga1=-143,4076,-546 -pa5ga0=-165,5736,-689,-169,5710,-692,-171,5713,-688,-173,5732,-689 -#pa5ga1=-161,3672,-510,-166,3671,-508,-169,3697,-508,-171,3854,-520 -itrsw=1 -pdoffset40ma0=0x9999 -pdoffset80ma0=0x8888 -extpagain5g=2 -extpagain2g=2 -maxp2ga0=74 -cckbw202gpo=0x0000 -ofdmlrbw202gpo=0x0022 -dot11agofdmhrbw202gpo=0x8888 -mcsbw202gpo=0xaaaaa666 -maxp5ga0=76,76,76,76 -mcsbw205glpo=0x99999955 -mcsbw205gmpo=0x99999955 -mcsbw205ghpo=0x99999955 -mcsbw405glpo=0xff999555 -mcsbw405gmpo=0xff999555 -mcsbw405ghpo=0xff999555 -mcsbw805glpo=0xfffffbbb -mcsbw805gmpo=0xfffffbbb -mcsbw805ghpo=0xfffffbbb -swctrlmap_2g=0x00040004,0x00020002,0x00040004,0x010a02,0x1ff -swctrlmap_5g=0x00100010,0x00200020,0x00200020,0x010a02,0x2f4 -swctrlmapext_5g=0x00000000,0x00000000,0x00000000,0x000000,0x000 -swctrlmapext_2g=0x00000000,0x00000000,0x00000000,0x000000,0x000 -vcodivmode=1 -##filter parameters -- tune where necessary -cckdigfilttype=6 -fdss_level_2g=2 -fdss_level_5g=2 -## added by apps -aga0=0x1 -agbg0=0x1 -ccode=0 -ed_thresh2g=-65 -ed_thresh5g=-65 -ltecxmux=0 -ltecxpadnum=0x0504 -ltecxfnsel=0x22 -ltecxgcigpio=0x32 -pdoffsetcckma0=0x0000 -powoffs2gtna0=0,0,0,0,0,0,0,0,0,0,0,0,0,0 -tempthresh=120 -temps_hysteresis=15 -rawtempsense=0x1ff -tworangetssi2g=1 -tworangetssi5g=0 -lowpowerrange2g=0 -lowpowerrange5g=0 -ag0=1 -ag1=1 -#subband5gver=0x4 -mcslr5glpo=0x0000 -mcslr5gmpo=0x0000 -mcslr5ghpo=0x0000 -sb20in40hrpo=0x0 -sb20in80and160hr5glpo=0x0 -sb40and80hr5glpo=0x0 -sb20in80and160hr5gmpo=0x0 -sb40and80hr5gmpo=0x0 -sb20in80and160hr5ghpo=0x0 -sb40and80hr5ghpo=0x0 -sb20in40lrpo=0x0 -sb20in80and160lr5glpo=0x0 -sb40and80lr5glpo=0x0 -sb20in80and160lr5gmpo=0x0 -sb40and80lr5gmpo=0x0 -sb20in80and160lr5ghpo=0x0 -sb40and80lr5ghpo=0x0 -dot11agduphrpo=0x0 -dot11agduplrpo=0x0 -phycal_tempdelta=25 -temps_period=15 -btc_mode=1 -sbpowoffs5g20mtna0=0,0,0,0 -sbpowoffs5g40mtna0=0,0,0,0 -sbpowoffs5g80mtna0=0,0,0,0 -powoffs5g20mtna0=0,0,0,0,0,0,0 -powoffs5g40mtna0=0,0,0,0,0 -powoffs5g80mtna0=0,0,0,0,0 -ldo1=5 -cbfilttype=2 -xtal_swcapio=0x8855 -fdss_level_ch13=1,1 -# muxenab defined to enable OOB IRQ. Level sensitive interrupt via WL_HOST_WAKE line. -muxenab=0x10 diff --git a/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.txt b/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.txt deleted file mode 100755 index 0cffd27..0000000 --- a/overlay/debian/lib/firmware/brcm/brcmfmac43455-sdio.txt +++ /dev/null @@ -1,114 +0,0 @@ -# Cloned from bcm94345wlpagb.txt -NVRAMRev=$Rev: 498373 $ -sromrev=11 -vendid=0x14e4 -devid=0x43ab -manfid=0x2d0 -prodid=0x06e4 -macaddr=00:90:4c:c5:12:38 -nocrc=1 -boardtype=0x6e4 -##boardrev - superseded by the one in OTP -boardrev=0x1100 -xtalfreq=37400 -## tune where necessary -#xtal_swcapio=0x6644 -boardflags=0x00080201 -boardflags2=0x40000000 -boardflags3=0x48200100 -rxchain=1 -txchain=1 -aa2g=1 -aa5g=1 -tssipos5g=1 -tssipos2g=1 -AvVmid_c0=0,157,1,126,1,126,1,126,1,126 -pa2ga0=-152,5969,-666 -pa2ga1=-143,4076,-546 -pa5ga0=-165,5736,-689,-169,5710,-692,-171,5713,-688,-173,5732,-689 -#pa5ga1=-161,3672,-510,-166,3671,-508,-169,3697,-508,-171,3854,-520 -itrsw=1 -pdoffset40ma0=0x9999 -pdoffset80ma0=0x8888 -extpagain5g=2 -extpagain2g=2 -maxp2ga0=74 -cckbw202gpo=0x0000 -ofdmlrbw202gpo=0x0022 -dot11agofdmhrbw202gpo=0x8888 -mcsbw202gpo=0xaaaaa666 -maxp5ga0=76,76,76,76 -mcsbw205glpo=0x99999955 -mcsbw205gmpo=0x99999955 -mcsbw205ghpo=0x99999955 -mcsbw405glpo=0xff999555 -mcsbw405gmpo=0xff999555 -mcsbw405ghpo=0xff999555 -mcsbw805glpo=0xfffffbbb -mcsbw805gmpo=0xfffffbbb -mcsbw805ghpo=0xfffffbbb -swctrlmap_2g=0x00040004,0x00020002,0x00040004,0x010a02,0x1ff -swctrlmap_5g=0x00100010,0x00200020,0x00200020,0x010a02,0x2f4 -swctrlmapext_5g=0x00000000,0x00000000,0x00000000,0x000000,0x000 -swctrlmapext_2g=0x00000000,0x00000000,0x00000000,0x000000,0x000 -vcodivmode=1 -##filter parameters -- tune where necessary -cckdigfilttype=6 -fdss_level_2g=2 -fdss_level_5g=2 -## added by apps -aga0=0x1 -agbg0=0x1 -ccode=0 -ed_thresh2g=-65 -ed_thresh5g=-65 -ltecxmux=0 -ltecxpadnum=0x0504 -ltecxfnsel=0x22 -ltecxgcigpio=0x32 -pdoffsetcckma0=0x0000 -powoffs2gtna0=0,0,0,0,0,0,0,0,0,0,0,0,0,0 -tempthresh=120 -temps_hysteresis=15 -rawtempsense=0x1ff -tworangetssi2g=1 -tworangetssi5g=0 -lowpowerrange2g=0 -lowpowerrange5g=0 -ag0=1 -ag1=1 -#subband5gver=0x4 -mcslr5glpo=0x0000 -mcslr5gmpo=0x0000 -mcslr5ghpo=0x0000 -sb20in40hrpo=0x0 -sb20in80and160hr5glpo=0x0 -sb40and80hr5glpo=0x0 -sb20in80and160hr5gmpo=0x0 -sb40and80hr5gmpo=0x0 -sb20in80and160hr5ghpo=0x0 -sb40and80hr5ghpo=0x0 -sb20in40lrpo=0x0 -sb20in80and160lr5glpo=0x0 -sb40and80lr5glpo=0x0 -sb20in80and160lr5gmpo=0x0 -sb40and80lr5gmpo=0x0 -sb20in80and160lr5ghpo=0x0 -sb40and80lr5ghpo=0x0 -dot11agduphrpo=0x0 -dot11agduplrpo=0x0 -phycal_tempdelta=25 -temps_period=15 -btc_mode=1 -sbpowoffs5g20mtna0=0,0,0,0 -sbpowoffs5g40mtna0=0,0,0,0 -sbpowoffs5g80mtna0=0,0,0,0 -powoffs5g20mtna0=0,0,0,0,0,0,0 -powoffs5g40mtna0=0,0,0,0,0 -powoffs5g80mtna0=0,0,0,0,0 -ldo1=5 -cbfilttype=2 -xtal_swcapio=0x8855 -fdss_level_ch13=1,1 -# muxenab defined to enable OOB IRQ. Level sensitive interrupt via WL_HOST_WAKE line. -muxenab=0x10 diff --git a/overlay/debian/lib/firmware/cypress/cyfmac43439-sdio.1YN.clm_blob b/overlay/debian/lib/firmware/cypress/cyfmac43439-sdio.1YN.clm_blob deleted file mode 100644 index 9691ba5..0000000 Binary files a/overlay/debian/lib/firmware/cypress/cyfmac43439-sdio.1YN.clm_blob and /dev/null differ diff --git a/overlay/debian/lib/firmware/cypress/cyfmac43439-sdio.bin b/overlay/debian/lib/firmware/cypress/cyfmac43439-sdio.bin deleted file mode 100644 index 650d427..0000000 Binary files a/overlay/debian/lib/firmware/cypress/cyfmac43439-sdio.bin and /dev/null differ diff --git a/overlay/debian/lib/firmware/lmacfw_spi.bin b/overlay/debian/lib/firmware/lmacfw_spi.bin deleted file mode 100644 index be14478..0000000 Binary files a/overlay/debian/lib/firmware/lmacfw_spi.bin and /dev/null differ diff --git a/overlay/debian/lib/firmware/renesas/hci_531.bin b/overlay/debian/lib/firmware/renesas/hci_531.bin deleted file mode 100644 index 16d9d79..0000000 Binary files a/overlay/debian/lib/firmware/renesas/hci_531.bin and /dev/null differ diff --git a/runme.sh b/runme.sh index 9922518..2da69eb 100755 --- a/runme.sh +++ b/runme.sh @@ -1,167 +1,5 @@ #!/bin/bash -set -o pipefail -set +x -############################################################################### -# General configurations -############################################################################### - -ATF_COMMIT_HASH=6d212fffd11a22aebe18a8fa924541b2513d6f68 -UBOOT_COMMIT_HASH=cb93dca45a88885af31f0cd23903b0a06f63da41 -KERNEL_COMMIT_HASH=8772d496cb1c6cc15d762fb942fc510dbc4db3d4 - -: ${BOOTLOADER_MENU:=false} -: ${SHALLOW:=true} -# Choose machine RZ/G2LC rzg2lc-solidrun | rzg2l-solidrun | rzv2l-solidrun -: ${MACHINE:=rzg2lc-solidrun} -: ${RAMFS:=false} -REPO_PREFIX=`git log -1 --pretty=format:%h` - -TFA_DIR_DEFAULT='rzg_trusted-firmware-a' -UBOOT_DIR_DEFAULT='u-boot' -KERNEL_DIR_DEFAULT='linux-stable' - -# Distribution for rootfs -# - buildroot -# - debian -: ${DISTRO:=buildroot} - -## Buildroot Options -: ${BUILDROOT_VERSION:=2022.02.4} -: ${BUILDROOT_DEFCONFIG:=rz-solidrun_defconfig} -: ${BR2_PRIMARY_SITE:=} # custom buildroot mirror - -## Debian Options -: ${DEBIAN_VERSION:=bullseye} -: ${DEBIAN_ROOTFS_SIZE:=936M} -: ${DEBIAN_PACKAGES:="apt-transport-https,busybox,ca-certificates,can-utils,command-not-found,chrony,curl,e2fsprogs,ethtool,fdisk,gpiod,haveged,i2c-tools,ifupdown,iputils-ping,isc-dhcp-client,initramfs-tools,libiio-utils,lm-sensors,locales,nano,net-tools,ntpdate,openssh-server,psmisc,rfkill,sudo,systemd,systemd-sysv,dbus,tio,usbutils,wget,xterm,xz-utils"} -# Kernel Options: -: ${INCLUDE_KERNEL_MODULES:=true} -: ${LINUX_DEFCONFIG:=rz-solidrun_defconfig} - -: ${USE_CCACHE:=false} - -ROOTDIR=`pwd` -#\rm -rf $ROOTDIR/images/tmp -mkdir -p build images/tmp/boot -PARALLEL=$(getconf _NPROCESSORS_ONLN) # Amount of parallel jobs for the builds - -export PATH=$ROOTDIR/build/toolchain/gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf/bin:$PATH -export CROSS_COMPILE=aarch64-none-elf- -export ARCH=arm64 - -# Check if git is configured -GIT_CONF=`git config user.name || true` -if [ "x$GIT_CONF" == "x" ]; then - echo "git is not configured! using fake email and username ..." - export GIT_AUTHOR_NAME="SolidRun rzg2l_build Script" - export GIT_AUTHOR_EMAIL="support@solid-run.com" - export GIT_COMMITTER_NAME="${GIT_AUTHOR_NAME}" - export GIT_COMMITTER_EMAIL="${GIT_AUTHOR_EMAIL}" -fi - -if [[ ! -d $ROOTDIR/build/toolchain ]]; then - mkdir -p $ROOTDIR/build/toolchain - cd $ROOTDIR/build/toolchain - wget https://developer.arm.com/-/media/Files/downloads/gnu/11.2-2022.02/binrel/gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf.tar.xz - tar -xvf gcc-arm-11.2-2022.02-x86_64-aarch64-none-elf.tar.xz -fi - -if [ "x$USE_CCACHE" == "xtrue" ]; then - mkdir -p $ROOTDIR/ccache - export CCACHE_DIR=$ROOTDIR/ccache - mkdir -p $ROOTDIR/build/ccache_symlinks - ln -sf $(which ccache) $ROOTDIR/build/ccache_symlinks/aarch64-none-elf-gcc - ln -sf $(which ccache) $ROOTDIR/build/ccache_symlinks/aarch64-none-elf-g++ - export PATH="$ROOTDIR/build/ccache_symlinks:$PATH" -fi - -cd $ROOTDIR -############################################################################### -# Source code clonig -############################################################################### - -#QORIQ_COMPONENTS="${TFA_DIR_DEFAULT} ${UBOOT_DIR_DEFAULT} ${KERNEL_DIR_DEFAULT} buildroot" -QORIQ_COMPONENTS="u-boot rzg_trusted-firmware-a linux-stable buildroot rzg2_flash_writer rswlan" -UBOOT_REPO='https://github.com/SolidRun/u-boot.git -b v2021.10/rz-sr' -ATF_REPO='https://github.com/SolidRun/arm-trusted-firmware -b v2.9/rz-sr rzg_trusted-firmware-a' -LINUX_REPO='https://github.com/SolidRun/linux-stable.git -b rz-5.10-cip36-sr' -BUILDROOT_REPO="https://github.com/buildroot/buildroot.git -b $BUILDROOT_VERSION" -FLASH_WRITER_REPO='https://github.com/renesas-rz/rzg2_flash_writer -b rz_g2l' -RSWLAN_REPO='https://github.com/SolidRun/rswlan.git' - -#├── build_dir -#│ ├── u-boot/ <<<<<< -#│ ├── rzg_trusted-firmware-a/ <<<<<< -#│ ├── linux-stable/ <<<<<< -#│ ├── buildroot/ <<<<<< -#│ ├── build.sh -#│ ├── build_xxxx.sh -#│ ├── build_xxxx.sh - -if [ "x$SHALLOW" == "xtrue" ]; then - SHALLOW_FLAG="--depth 100" -fi - -for i in $QORIQ_COMPONENTS; do - if [[ ! -d $ROOTDIR/build/$i ]]; then - echo "$i source code clonig ..." - cd $ROOTDIR/build - # ================ Clone U-Boot =========== # - if [ "x$i" == "xu-boot" ]; then - git clone $SHALLOW_FLAG $UBOOT_REPO - cd $ROOTDIR/build/u-boot && git checkout $UBOOT_COMMIT_HASH - cd $ROOTDIR/build/ - fi - # ================ Clone ATF ============= # - if [ "x$i" == "xrzg_trusted-firmware-a" ]; then - git clone $SHALLOW_FLAG $ATF_REPO - cd $ROOTDIR/build/rzg_trusted-firmware-a && git checkout $ATF_COMMIT_HASH - fi - # ================ Clone Linux =========== # - if [ "x$i" == "xlinux-stable" ]; then - git clone $SHALLOW_FLAG $LINUX_REPO - cd $ROOTDIR/build/linux-stable && git checkout $KERNEL_COMMIT_HASH - cd $ROOTDIR/build/ - fi - # Clone Buildroot - if [ "x$i" == "xbuildroot" ]; then - git clone $SHALLOW_FLAG $BUILDROOT_REPO - fi - # Clone Flash writer - if [ "x$i" == "xrzg2_flash_writer" ]; then - git clone $SHALLOW_FLAG $FLASH_WRITER_REPO - fi - # Clone rswlan - if [ "x$i" == "xrswlan" ]; then - git clone $SHALLOW_FLAG $RSWLAN_REPO - fi - - # Apply patches... - echo "Checking patches for ${i}" - if [ -d "${ROOTDIR}/patches/${i}" ]; then - cd ${ROOTDIR}/build/${i} - for patch in "${ROOTDIR}/patches/${i}"/*.patch; do - echo "Applying $patch ..." - test -e .git && git am "$patch" - test -e .git || patch -p1 < $patch - - if [ $? -ne 0 ]; then - echo "Error: Failed to apply $patch!" - exit 1 - fi - done - fi - fi -done - -# Creating symolinks for ATF/U-Boo t/Linux -# cd ${ROOTDIR}/build/ -# ln -sn renesas-u-boot-cip u-boot -# ln -sn rzg_trusted-firmware-a atf -# ln -sn rz_linux-cip linux -# cd ${ROOTDIR}/ - # we don't have status code checks for each step - use "-e" with a trap instead function error() { status=$? @@ -171,381 +9,171 @@ function error() { trap error ERR set -e -############################################################################### -# Building bootloader -############################################################################### -echo "=================================" -echo "*** Generating Bootloader...." -echo "=================================" -cd $ROOTDIR/build/ -if [ "x$BOOTLOADER_MENU" == "xtrue" ]; then - # ================ Install build scripts ====== # - cp $ROOTDIR/build_scripts/*.sh $ROOTDIR/build/ - chmod +x $ROOTDIR/build/*.sh - \rm -rf output_* - # Clean U-Boot Code - # cd $ROOTDIR/build/renesas-u-boot-cip && make mrproper && make -j$(nproc) O=.out && cd - - cd $ROOTDIR/build/*u-boot* && make mrproper && cd - - # Select toolchain that you have: - ./build.sh s - # build u-boot: - ./build.sh u - # build ATF - ./build.sh t - # copy output files - \cp -r output_*/* $ROOTDIR/images/tmp/ -else - # Select machine configuration - case "$MACHINE" in - "rzg2lc-hummingboard" | "rzg2lc-solidrun") - UBOOT_DEFCONFIG=rzg2lc-solidrun_defconfig - PLATFORM=g2l - BOARD=sr_rzg2lc - ;; - "rzg2l-hummingboard" | "rzg2l-solidrun") - UBOOT_DEFCONFIG=rzg2l-solidrun_defconfig - PLATFORM=g2l - BOARD=sr_rzg2l - ;; - "rzv2l-hummingboard" | "rzv2l-solidrun") - UBOOT_DEFCONFIG=rzv2l-solidrun_defconfig - PLATFORM=v2l - BOARD=sr_rzv2l - ;; - *) - echo "Unknown Machine=$MACHINE -> default=rzg2lc-solidrun" - UBOOT_DEFCONFIG=rzg2lc-solidrun_defconfig - PLATFORM=g2l - BOARD=sr_rzg2lc - ;; - esac - - echo "UBOOT_DEFCONFIG=${UBOOT_DEFCONFIG} PLATFORM=${PLATFORM} BOARD=${BOARD}" - - OUTPUT_BOOTLOADER_DIR=$ROOTDIR/build/output_${MACHINE} - rm -rf ${OUTPUT_BOOTLOADER_DIR} - mkdir -p ${OUTPUT_BOOTLOADER_DIR} - echo "=================================" - echo "Generating U-Boot...." - echo "=================================" - # Generate U-Boot (u-boot.bin) - cd $ROOTDIR/build/${UBOOT_DIR_DEFAULT} - echo "U-Boot config: $UBOOT_DEFCONFIG" - make mrproper - make $UBOOT_DEFCONFIG - make -j${PARALLEL} - # Generate ATF (BL2 & FIP & BOOTPARMS) - echo "=================================" - echo "Generating ATF...." - echo "=================================" - - cd $ROOTDIR/build/${TFA_DIR_DEFAULT} - rm -rf $ROOTDIR/build/${TFA_DIR_DEFAULT}/build - # create the fip file by combining the bl31.bin and u-boot.bin (copy the u-boot.bin in the ATF root folder) - # cp $ROOTDIR/build/${UBOOT_DIR_DEFAULT}/.out/u-boot.bin $ROOTDIR/build/${TFA_DIR_DEFAULT} - U_BOOT_BIN=$(find $ROOTDIR/build/${UBOOT_DIR_DEFAULT} -iname u-boot.bin) - cp $U_BOOT_BIN $ROOTDIR/build/${TFA_DIR_DEFAULT}/ - make -j${PARALLEL} bl2 bl31 PLAT=${PLATFORM} BOARD=${BOARD} RZG_DRAM_ECC_FULL=0 LOG_LEVEL=20 MBEDTLS_DIR=../mbedtls - # Binaries (bl2.bin and bl31.bin) are located in the build/g2l/release|debug folder. - cp create_bl2_with_bootparam.sh build/${PLATFORM}/release/ - cd build/${PLATFORM}/release - chmod +x create_bl2_with_bootparam.sh - # We have to combine bl2.bin with boot parameters, we can use this simple bash script to do that: - ./create_bl2_with_bootparam.sh - cd $ROOTDIR/build/${TFA_DIR_DEFAULT} - # Make the fip creation tool: - cd tools/fiptool && make clean && make -j${PARALLEL} plat=${PLATFORM} && cd - - tools/fiptool/fiptool create --align 16 --soc-fw build/${PLATFORM}/release/bl31.bin --nt-fw u-boot.bin fip.bin - # Copy output files BL2|FIP|BOOTPARMS to ${OUTPUT_BOOTLOADER_DIR} - cp fip.bin ${OUTPUT_BOOTLOADER_DIR}/fip-${MACHINE}.bin - cp build/${PLATFORM}/release/bl2.bin ${OUTPUT_BOOTLOADER_DIR}/bl2-${MACHINE}.bin - cp build/${PLATFORM}/release/bootparams.bin ${OUTPUT_BOOTLOADER_DIR}/bootparams-${MACHINE}.bin - cp build/${PLATFORM}/release/bl2_bp.bin ${OUTPUT_BOOTLOADER_DIR}/bl2_bp-${MACHINE}.bin - cp -r ${OUTPUT_BOOTLOADER_DIR}/* $ROOTDIR/images/tmp/ - echo "bootloader binaries are here ${OUTPUT_BOOTLOADER_DIR}... " - ls -la ${OUTPUT_BOOTLOADER_DIR}/ -fi - -# make the SD-Image -cd $ROOTDIR/images/ -BOOT_IMG_SD=${MACHINE}-sd-bootloader-${REPO_PREFIX}.img -BOOT_IMG_EMMC=${MACHINE}-mmc-bootloader-${REPO_PREFIX}.img -rm -rf $ROOTDIR/images/${BOOT_IMG_SD} $ROOTDIR/images/${BOOT_IMG_EMMC} -dd if=/dev/zero of=${BOOT_IMG_SD} bs=1M count=2 -dd if=/dev/zero of=${BOOT_IMG_EMMC} bs=1M count=2 - -# eMMC/SD Bootloader -if [ -f tmp/bootparams-${MACHINE}.bin ] && [ -f tmp/bl2-${MACHINE}.bin ] && [ -f tmp/fip-${MACHINE}.bin ]; then - echo "Find Solidrun boot files..."; sleep 1 - # SD Card - dd if=$ROOTDIR/images/tmp/bootparams-${MACHINE}.bin of=$BOOT_IMG_SD bs=512 seek=1 count=1 conv=notrunc - dd if=$ROOTDIR/images/tmp/bl2-${MACHINE}.bin of=$BOOT_IMG_SD bs=512 seek=8 conv=notrunc - dd if=$ROOTDIR/images/tmp/fip-${MACHINE}.bin of=$BOOT_IMG_SD bs=512 seek=128 conv=notrunc - # eMMC - dd if=$ROOTDIR/images/tmp/bl2_bp-${MACHINE}.bin of=$BOOT_IMG_EMMC bs=512 seek=1 conv=notrunc - dd if=$ROOTDIR/images/tmp/fip-${MACHINE}.bin of=$BOOT_IMG_EMMC bs=512 seek=256 conv=notrunc -fi -echo "SD bootloader image is ready -> images/$BOOT_IMG_SD" -echo "eMMC bootloader image is ready -> images/$BOOT_IMG_EMMC" - -############################################################################### -# Building Linux -############################################################################### -echo "=================================" -echo "*** Building Linux kernel..." -echo "=================================" -cd $ROOTDIR/build/linux-stable -cp $ROOTDIR/configs/linux/$LINUX_DEFCONFIG arch/arm64/configs -make $LINUX_DEFCONFIG -make -j${PARALLEL} Image dtbs modules -cp $ROOTDIR/build/linux-stable/arch/arm64/boot/Image $ROOTDIR/images/tmp/ -cp $ROOTDIR/build/linux-stable/arch/arm64/boot/dts/renesas/rzg2l*hummingboard*.dtb $ROOTDIR/images/tmp/ -cp $ROOTDIR/build/linux-stable/arch/arm64/boot/dts/renesas/rzv2l*hummingboard*.dtb $ROOTDIR/images/tmp/ -rm -rf ${ROOTDIR}/images/tmp/modules # remove old modules -make -j${PARALLEL} INSTALL_MOD_PATH="${ROOTDIR}/images/tmp/modules" modules_install -KRELEASE=`make kernelrelease` - -############################################################################### -# Building Kernel Modules -############################################################################### -echo "=================================" -echo "*** Building Kernel Modules..." -echo "=================================" -do_build_rswlan() { - cd $ROOTDIR/build/rswlan - make KDIR="${ROOTDIR}/build/linux-stable" clean - make KDIR="${ROOTDIR}/build/linux-stable" CONFIG_MODULE_TYPE=spi - install -v -m644 -D rswlan.ko "${ROOTDIR}/images/tmp/modules/lib/modules/${KRELEASE}/extra/rswlan.ko" +# set -x + +ROOTDIR=$(pwd) +BUILDSCRIPT_DIR="${ROOTDIR}/build_scripts" +REPO_PREFIX=$(git log -1 --pretty=format:%h) + + +: "${MACHINE:=rzg2lc-solidrun}" +: "${DISTRO:=buildroot}" +: "${CROSS_TOOLCHAIN:=""}" +: "${USE_CCACHE:=true}" +: "${ROOTFS_FREE_SIZE:=100M}" +: "${COMPRESSION_FORMAT:=""}" + +COMPRESSION_FORMATS=("gzip" "xz" "zstd") + +source "${BUILDSCRIPT_DIR}/build_uboot.sh" +source "${BUILDSCRIPT_DIR}/build_atf.sh" +source "${BUILDSCRIPT_DIR}/build_kernel.sh" +source "${BUILDSCRIPT_DIR}/build_rswlan.sh" +source "${BUILDSCRIPT_DIR}/assemble_bootloaders.sh" +source "${BUILDSCRIPT_DIR}/build_${DISTRO}.sh" +source "${BUILDSCRIPT_DIR}/build_flashwriter.sh" +source "${BUILDSCRIPT_DIR}/assemble_image.sh" + +TARGETS=("uboot" "atf" "kernel" "bootimage" "rswlan" "${DISTRO}" "flashwriter" "image") + +declare -A DEPENDENCIES +DEPENDENCIES["atf"]="uboot" +DEPENDENCIES["rswlan"]="kernel" +DEPENDENCIES["bootimage"]="uboot atf kernel" +DEPENDENCIES["image"]="uboot atf kernel bootimage rswlan distro" + +is_valid_target() { + for t in "${TARGETS[@]}"; do + if [[ "$1" == "$t" ]]; then + return 0 + fi + done + return 1 } -do_build_rswlan -depmod -b "${ROOTDIR}/images/tmp/modules" -F "${ROOTDIR}/build/linux-stable/System.map" ${KRELEASE} -############################################################################### -# Building FS Builroot/Debian -############################################################################### +resolve_dependencies() { + local target="$1" -do_build_buildroot() { - echo "=================================" - echo "*** Building Buildroot FS..." - echo "=================================" - cd $ROOTDIR/build/buildroot - cp $ROOTDIR/configs/buildroot/${BUILDROOT_DEFCONFIG} $ROOTDIR/build/buildroot/configs - if [ "x$USE_CCACHE" == "xtrue" ]; then - echo "BR2_CCACHE=y" >> $ROOTDIR/build/buildroot/configs/${BUILDROOT_DEFCONFIG} - echo "BR2_CCACHE_DIR=$ROOTDIR/ccache" >> $ROOTDIR/build/buildroot/configs/${BUILDROOT_DEFCONFIG} - fi - make ${BUILDROOT_DEFCONFIG} - #make menuconfig - make savedefconfig BR2_DEFCONFIG="${ROOTDIR}/build/buildroot/defconfig" - make -j${PARALLEL} - cp $ROOTDIR/build/buildroot/output/images/rootfs* $ROOTDIR/images/tmp/ - # Preparing initrd - mkimage -A arm64 -O linux -T ramdisk -C gzip -d $ROOTDIR/images/tmp/rootfs.cpio.gz $ROOTDIR/images/tmp/initrd.img + # Check if the target has any dependencies + if [[ -n "${DEPENDENCIES[$target]}" ]]; then + for dep in ${DEPENDENCIES[$target]}; do + echo "Resolving dependency: $target depends on $dep" + ${dep}_build # Build each dependency first + done + fi } -do_build_debian() { - echo "=================================" - echo "*** Building Debian FS..." - echo "=================================" - mkdir -p $ROOTDIR/build/debian - cd $ROOTDIR/build/debian - -# (re-)generate only if rootfs doesn't exist or runme script has changed - if [ ! -f rootfs.e2.orig ] || [[ ${ROOTDIR}/${BASH_SOURCE[0]} -nt rootfs.e2.orig ]]; then - rm -f rootfs.e2.orig - - # bootstrap a first-stage rootfs - rm -rf stage1 - fakeroot debootstrap --variant=minbase \ - --arch=arm64 --components=main,contrib,non-free \ - --foreign \ - --include=${DEBIAN_PACKAGES} \ - ${DEBIAN_VERSION} \ - stage1 \ - https://deb.debian.org/debian - - # prepare init-script for second stage inside VM - cat > stage1/stage2.sh << EOF -#!/bin/sh - -# run second-stage bootstrap -/debootstrap/debootstrap --second-stage - -# set empty root password -passwd -d root - -# delete self -rm -f /stage2.sh - -# flush disk -sync - -# power-off -reboot -f -EOF - chmod +x stage1/stage2.sh - - # create empty partition image - dd if=/dev/zero of=rootfs.e2.orig bs=1 count=0 seek=${DEBIAN_ROOTFS_SIZE} - - # create filesystem from first stage - mkfs.ext2 -L rootfs -E root_owner=0:0 -d stage1 rootfs.e2.orig - - # bootstrap second stage within qemu - qemu-system-aarch64 \ - -m 1G \ - -M virt \ - -cpu cortex-a57 \ - -smp 4 \ - -netdev user,id=eth0 \ - -device virtio-net-device,netdev=eth0 \ - -drive file=rootfs.e2.orig,if=none,format=raw,id=hd0 \ - -device virtio-blk-device,drive=hd0 \ - -nographic \ - -no-reboot \ - -kernel "${ROOTDIR}/images/tmp/Image" \ - -append "console=ttyAMA0 root=/dev/vda rootfstype=ext2 ip=dhcp rw init=/stage2.sh" \ - - : - - # convert to ext4 - tune2fs -O extents,uninit_bg,dir_index,has_journal rootfs.e2.orig - fi; - - - local ROOTFS=${ROOTDIR}/images/tmp/rootfs.ext4 - - echo "${MACHINE}" > hostname - echo "127.0.0.1 localhost ${MACHINE}" > hosts - - cp rootfs.e2.orig ${ROOTFS} - e2cp -G 0 -O 0 hosts ${ROOTFS}:/etc/hosts - e2cp -G 0 -O 0 hostname ${ROOTFS}:/etc/hostname - - # apply overlay (configuration + data files only - can't "chmod +x") - find "${ROOTDIR}/overlay/${DISTRO}" -type f -printf "%P\n" | e2cp -G 0 -O 0 -s "${ROOTDIR}/overlay/${DISTRO}" -d "${ROOTFS}:" -a +set_machine_settings() { + case "$MACHINE" in + "rzg2lc-solidrun") + UBOOT_DEFCONFIG=rzg2lc-solidrun_defconfig + TFA_PLATFORM=g2l + TFA_BOARD=sr_rzg2lc + KERNEL_OVERLAYS_PREFIX=rzg2lc + ;; + "rzg2l-solidrun") + UBOOT_DEFCONFIG=rzg2l-solidrun_defconfig + TFA_PLATFORM=g2l + TFA_BOARD=sr_rzg2l + KERNEL_OVERLAYS_PREFIX=rzg2l + ;; + "rzv2l-solidrun") + UBOOT_DEFCONFIG=rzv2l-solidrun_defconfig + TFA_PLATFORM=v2l + TFA_BOARD=sr_rzv2l + KERNEL_OVERLAYS_PREFIX=rzg2l + ;; + *) + echo "Unknown Machine=$MACHINE -> default=rzg2lc-solidrun" + UBOOT_DEFCONFIG=rzg2lc-solidrun_defconfig + TFA_PLATFORM=g2l + TFA_BOARD=sr_rzg2lc + KERNEL_OVERLAYS_PREFIX=rzg2lc + ;; + esac } -# BUILD selected Distro buildroot/debian -do_build_${DISTRO} - -############################################################################### -# Building Flash Writer -############################################################################### -echo "=================================" -echo "*** Building Flash Writer" -echo "=================================" -cd $ROOTDIR/build/rzg2_flash_writer -# RZ/G2LC -make clean -FLASH_WRITER_BUILD_ARGS="DEVICE=RZG2LC DDR_TYPE=DDR4 DDR_SIZE=1GB_1PCS SWIZZLE=T3BC FILENAME_ADD=_RZG2LC_HUMMINGBOARD" -make $FLASH_WRITER_BUILD_ARGS -f makefile.linaro -cp ./AArch64_output/Flash_Writer_SCIF_RZG2LC_HUMMINGBOARD_DDR4_1GB_1PCS.mot $ROOTDIR/images -# RZ/G2L -make clean -FLASH_WRITER_BUILD_ARGS="DEVICE=RZG2L DDR_TYPE=DDR4 DDR_SIZE=1GB_1PCS SWIZZLE=T1BC FILENAME_ADD=_RZG2L_HUMMINGBOARD" -make $FLASH_WRITER_BUILD_ARGS -f makefile.linaro -cp ./AArch64_output/Flash_Writer_SCIF_RZG2L_HUMMINGBOARD_DDR4_1GB_1PCS.mot $ROOTDIR/images -# RZ/V2L -make clean -FLASH_WRITER_BUILD_ARGS="DEVICE=RZV2L DDR_TYPE=DDR4 DDR_SIZE=2GB_1PCS SWIZZLE=T1BC FILENAME_ADD=_RZV2L_HUMMINGBOARD" -make $FLASH_WRITER_BUILD_ARGS -f makefile.linaro -cp ./AArch64_output/Flash_Writer_SCIF_RZV2L_HUMMINGBOARD_DDR4_2GB_1PCS.mot $ROOTDIR/images - -if [ "x$USE_CCACHE" == "xtrue" ]; then - ccache --show-stats -fi - -############################################################################### -# Assembling Boot Image -############################################################################### -echo "=================================" -echo "Assembling Boot Image" -echo "=================================" -cd $ROOTDIR/images/ -IMG=${MACHINE}-sd-${DISTRO}-${REPO_PREFIX}.img -rm -rf $ROOTDIR/images/${IMG} -IMAGE_BOOTPART_SIZE_MB=150 # bootpart size = 150MiB -IMAGE_BOOTPART_SIZE=$((IMAGE_BOOTPART_SIZE_MB*1024*1024)) # Convert megabytes to bytes -IMAGE_ROOTPART_SIZE=`stat -c "%s" tmp/rootfs.ext4` -IMAGE_ROOTPART_SIZE_MB=$(($IMAGE_ROOTPART_SIZE / (1024 * 1024) )) # Convert bytes to megabytes -IMAGE_SIZE=$((IMAGE_BOOTPART_SIZE+IMAGE_ROOTPART_SIZE+2*1024*1024)) # additional 2M at the end -IMAGE_SIZE_MB=$(echo "$IMAGE_SIZE / (1024 * 1024)" | bc) # Convert bytes to megabytes -dd if=/dev/zero of=${IMG} bs=1M count=${IMAGE_SIZE_MB} - -if [ "x$RAMFS" == "xtrue" ]; then -# Make extlinux configuration file -cat > $ROOTDIR/images/tmp/extlinux.conf << EOF -timeout 3 -prompt 1 -default primary -menu title RZ/G2* boot options -label primary - menu label initrd boot - linux /boot/Image.gz - fdtdir /boot/ - initrd /boot/initrd.img - APPEND console=serial0,115200 console=ttySC0 - -label secondary - menu label mmc boot - linux /boot/Image - fdtdir /boot/ - APPEND console=serial0,115200 console=ttySC0 root=/dev/mmcblk0p2 rw rootwait -EOF - -else - -cat > $ROOTDIR/images/tmp/extlinux.conf << EOF -timeout 3 -default primary -label primary - menu label primary kernel - linux /boot/Image.gz - fdtdir /boot/ - APPEND \${bootargs} -EOF -fi - -gzip -9 -k -f $ROOTDIR/images/tmp/Image - -# FAT Partion -dd if=/dev/zero of=tmp/part1.fat32 bs=1M count=148 -env PATH="$PATH:/sbin:/usr/sbin" mkdosfs tmp/part1.fat32 -mmd -i tmp/part1.fat32 ::/extlinux -mmd -i tmp/part1.fat32 ::/boot -mcopy -i tmp/part1.fat32 $ROOTDIR/images/tmp/Image.gz ::/boot/Image.gz -mcopy -i tmp/part1.fat32 $ROOTDIR/images/tmp/Image ::/boot/Image -mcopy -s -i tmp/part1.fat32 $ROOTDIR/images/tmp/*.dtb ::/boot/ -if [ "$DISTRO" == "buildroot" ]; then -mcopy -s -i tmp/part1.fat32 $ROOTDIR/images/tmp/initrd.img ::/boot/initrd.img -fi -mcopy -i tmp/part1.fat32 $ROOTDIR/images/tmp/extlinux.conf ::/extlinux/extlinux.conf +set_toolchain() { + if [ -z "${CROSS_TOOLCHAIN}" ]; then + if [[ ! -d ${ROOTDIR}/build/toolchain/arm-gnu-toolchain-13.3.rel1-x86_64-aarch64-none-linux-gnu/bin ]]; then + mkdir -p ${ROOTDIR}/build/toolchain + cd ${ROOTDIR}/build/toolchain + wget https://developer.arm.com/-/media/Files/downloads/gnu/13.3.rel1/binrel/arm-gnu-toolchain-13.3.rel1-x86_64-aarch64-none-linux-gnu.tar.xz + tar -xf arm-gnu-toolchain-13.3.rel1-x86_64-aarch64-none-linux-gnu.tar.xz + fi + export PATH=${ROOTDIR}/build/toolchain/arm-gnu-toolchain-13.3.rel1-x86_64-aarch64-none-linux-gnu/bin:$PATH + if [ "$USE_CCACHE" == "true" ]; then + mkdir -p $ROOTDIR/build/toolchain/ccache_symlinks + ln -sf $(which ccache) $ROOTDIR/build/toolchain/ccache_symlinks/aarch64-none-linux-gnu-gcc + ln -sf $(which ccache) $ROOTDIR/build/toolchain/ccache_symlinks/aarch64-none-linux-gnu-g++ + export PATH="$ROOTDIR/build/toolchain/ccache_symlinks:$PATH" + fi + CROSS_TOOLCHAIN=aarch64-none-linux-gnu- + fi +} -# EXT4 Partion -ROOTFS=$ROOTDIR/images/tmp/rootfs.ext4 -e2mkdir -G 0 -O 0 ${ROOTFS}:extlinux -#e2cp -G 0 -O 0 $ROOTDIR/images/tmp/extlinux.conf ${ROOTFS}:extlinux/ -e2mkdir -G 0 -O 0 ${ROOTFS}:boot -e2cp -G 0 -O 0 $ROOTDIR/images/tmp/Image ${ROOTFS}:/boot/ -e2cp -G 0 -O 0 $ROOTDIR/images/tmp/*.dtb ${ROOTFS}:/boot/ +show_help() { + echo "Usage: MACHINE=[machine] DISTRO=[distro] $0 [build|clean] [target]" + echo "Targets: ${TARGETS[*]}" + echo "Examples:" + echo " $0 # Build all targets" + echo " $0 build uboot # Build uboot only" + echo " $0 clean kernel # Clean kernel only" + echo " $0 --help # Show this help message" + echo "Available machines:" + echo "rzg2lc-solidrun (default), rzg2l-solidrun, rzv2l-solidrun" + echo "Available distros:" + echo "buildroot (default), debian" + echo "Available env vars:" + echo "MACHINE=rzg2l-solidrun - Machine name (default: rzg2lc-solidrun)" + echo "DISTRO=debian - Distro to build (default: buildroot)" + echo "CROSS_TOOLCHAIN=aarch64-linux-gnu- - Toolchain to use (default: download arm-gnu-toolchain-13.3)" + echo "ROOTFS_FREE_SIZE=1G - Extra rootfs free size (default: 100M)" + echo "COMPRESSION_FORMAT=zstd - if specified, image will be commpressed (zstd, xz, gzip)" +} -if [ "x${INCLUDE_KERNEL_MODULES}" = "xtrue" ]; then - echo "copying kernel modules ..." - find "${ROOTDIR}/images/tmp/modules/lib/modules" -type f -not -name "*.ko*" -printf "%P\n" | e2cp -G 0 -O 0 -P 644 -s "${ROOTDIR}/images/tmp/modules/lib/modules" -d "${ROOTDIR}/images/tmp/rootfs.ext4:lib/modules" -a - find "${ROOTDIR}/images/tmp/modules/lib/modules" -type f -name "*.ko*" -printf "%P\n" | e2cp -G 0 -O 0 -P 644 -s "${ROOTDIR}/images/tmp/modules/lib/modules" -d "${ROOTDIR}/images/tmp/rootfs.ext4:lib/modules" -a -v -fi +main() { + local action="$1" + local target="$2" + + if [[ "$action" == "--help" ]]; then + show_help + exit 0 + fi + + if [[ "$DISTRO" != "debian" && "$DISTRO" != "buildroot" ]]; then + echo "Error: DISTRO environment variable must be set to either 'debian' or 'buildroot'." + exit 1 + fi + + set_machine_settings + set_toolchain + + # Default behavior: if no arguments are provided, build all targets + if [[ -z "$action" ]]; then + echo "Building all targets..." + for t in "${TARGETS[@]}"; do + ${t}_build + done + exit 0 + fi + + if ! is_valid_target "$target"; then + echo "Invalid target: $target" + show_help + exit 1 + fi + + if [[ "$action" == "build" ]]; then + resolve_dependencies "$target" + ${target}_build + elif [[ "$action" == "clean" ]]; then + ${target}_clean + else + echo "Unknown action: $action" + show_help + exit 1 + fi +} -# EXT partion -env PATH="$PATH:/sbin:/usr/sbin" parted --script ${IMG} mklabel msdos mkpart primary 4MiB ${IMAGE_BOOTPART_SIZE_MB}MiB mkpart primary ${IMAGE_BOOTPART_SIZE_MB}MiB $((IMAGE_SIZE_MB - 1))MiB -dd if=tmp/part1.fat32 of=${IMG} bs=1M seek=4 conv=notrunc -dd if=${ROOTFS} of=${IMG} bs=1M seek=${IMAGE_BOOTPART_SIZE_MB} conv=notrunc -# Boot loader -if [ -f tmp/bootparams-${MACHINE}.bin ] && [ -f tmp/bl2-${MACHINE}.bin ] && [ -f tmp/fip-${MACHINE}.bin ]; then - echo "Find Solidrun boot files..."; sleep 1 - dd if=$ROOTDIR/images/tmp/bootparams-${MACHINE}.bin of=$IMG bs=512 seek=1 count=1 conv=notrunc - dd if=$ROOTDIR/images/tmp/bl2-${MACHINE}.bin of=$IMG bs=512 seek=8 conv=notrunc - dd if=$ROOTDIR/images/tmp/fip-${MACHINE}.bin of=$IMG bs=512 seek=128 conv=notrunc -fi -sync -echo -e "\n\n*** Image is ready - images/${IMG}" +main "$@"