From 46d7982c972ff8badb56a0d4078555328ba81a0d Mon Sep 17 00:00:00 2001 From: William Tambe Date: Sat, 2 May 2020 10:44:37 -0500 Subject: [PATCH] initial commit --- .github/workflows/release.yml | 92 ++++++++++++++++++++++++++++++ .gitmodules | 18 ++++++ README.md | 30 ++++++++++ binutils | 1 + buildroot | 1 + fontamsoc-sw | 1 + gcc | 1 + glibc | 1 + linux | 1 + makefile | 103 ++++++++++++++++++++++++++++++++++ 10 files changed, 249 insertions(+) create mode 100644 .github/workflows/release.yml create mode 100644 .gitmodules create mode 100644 README.md create mode 160000 binutils create mode 160000 buildroot create mode 160000 fontamsoc-sw create mode 160000 gcc create mode 160000 glibc create mode 160000 linux create mode 100644 makefile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..39d13b1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,92 @@ +on: + push: + tags: + - '*' + workflow_dispatch: + +name: pu32-toolchain + +jobs: + job0: + name: Release + runs-on: ubuntu-20.04 + steps: + - name: Checkout repository and submodules + uses: actions/checkout@v2 + with: + submodules: recursive + - name: Build project + working-directory: ../ + run: | + sudo ln -snf /bin/bash /bin/sh + PATH="${PATH}:/opt/pu32-toolchain/bin" make -f pu32-toolchain/makefile > pu32-toolchain/build.log + (cd pu32-toolchain-build/ && tar -caf pu32-vmlinux.xz vmlinux && rm -rf vmlinux) + (cd pu32-toolchain-build/ && tar -caf pu32-rootfs.ext2.xz rootfs.ext2 && rm -rf rootfs.ext?) + mv pu32-toolchain-build/*.xz pu32-toolchain/ + - name: Save build.log + uses: actions/upload-artifact@v2 + with: + path: build.log + name: build.log + - name: Create Release + if: startsWith(github.ref, 'refs/tags/') + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + - name: Save pu32-toolchain.tar.xz + if: startsWith(github.ref, 'refs/heads/') + uses: actions/upload-artifact@v2 + with: + path: pu32-toolchain.tar.xz + name: pu32-toolchain.tar.xz + - name: Upload pu32-toolchain.tar.xz + if: startsWith(github.ref, 'refs/tags/') + id: upload-pu32-toolchain-tar-xz + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: pu32-toolchain.tar.xz + asset_name: pu32-toolchain.tar.xz + asset_content_type: application/tar+xz + - name: Save pu32-vmlinux.xz + if: startsWith(github.ref, 'refs/heads/') + uses: actions/upload-artifact@v2 + with: + path: pu32-vmlinux.xz + name: pu32-vmlinux.xz + - name: Upload pu32-vmlinux.xz + if: startsWith(github.ref, 'refs/tags/') + id: upload-vmlinux-xz + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: pu32-vmlinux.xz + asset_name: pu32-vmlinux.xz + asset_content_type: application/tar+xz + - name: Save pu32-rootfs.ext2.xz + if: startsWith(github.ref, 'refs/heads/') + uses: actions/upload-artifact@v2 + with: + path: pu32-rootfs.ext2.xz + name: pu32-rootfs.ext2.xz + - name: Upload pu32-rootfs.ext2.xz + if: startsWith(github.ref, 'refs/tags/') + id: upload-rootfs-ext2-xz + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: pu32-rootfs.ext2.xz + asset_name: pu32-rootfs.ext2.xz + asset_content_type: application/tar+xz diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..0bf321b --- /dev/null +++ b/.gitmodules @@ -0,0 +1,18 @@ +[submodule "gcc"] + path = gcc + url = https://github.com/fontamsoc/gcc.git +[submodule "glibc"] + path = glibc + url = https://github.com/fontamsoc/glibc.git +[submodule "binutils"] + path = binutils + url = https://github.com/fontamsoc/binutils-gdb.git +[submodule "buildroot"] + path = buildroot + url = https://github.com/fontamsoc/buildroot.git +[submodule "linux"] + path = linux + url = https://github.com/fontamsoc/linux.git +[submodule "fontamsoc-sw"] + path = fontamsoc-sw + url = https://github.com/fontamsoc/sw.git diff --git a/README.md b/README.md new file mode 100644 index 0000000..9d03422 --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +# PU32 Toolchain +[![pu32-toolchain](https://github.com/fontamsoc/pu32-toolchain/actions/workflows/release.yml/badge.svg)](https://github.com/fontamsoc/pu32-toolchain/actions/workflows/release.yml) + +## Getting the sources + +This repository uses submodules. +We need the --recursive option to fetch the submodules automatically. + + git clone --recursive https://github.com/fontamsoc/pu32-toolchain.git + +## Building the sources (Or [download prebuilts](https://github.com/fontamsoc/pu32-toolchain/releases/latest)) + + sudo ln -snf /bin/bash /bin/sh + PATH="${PATH}:/opt/pu32-toolchain/bin" make -f pu32-toolchain/makefile + +Build artifacts get generated under `pu32-toolchain-build/` + +## Installing Toolchain + + sudo tar -xf pu32-toolchain-build/pu32-toolchain.tar.xz -C /opt/ + +Environment `PATH` must be updated as follow `PATH="${PATH}:/opt/pu32-toolchain/bin"` + +## Running Linux in the simulator + + pu32-elf-run --hdd buildroot-build/images/rootfs.ext4 linux-build/vmlinux root=/dev/hda earlyprintk=keep + +## Running Linux in GDB + + pu32-elf-gdb linux-build/vmlinux -ex 'target sim --hdd buildroot-build/images/rootfs.ext4' -ex 'load' -ex 'r root=/dev/hda earlyprintk=keep' diff --git a/binutils b/binutils new file mode 160000 index 0000000..a0ff656 --- /dev/null +++ b/binutils @@ -0,0 +1 @@ +Subproject commit a0ff656f9870eb9e8fd41eb1680486e59522058f diff --git a/buildroot b/buildroot new file mode 160000 index 0000000..be9f4e6 --- /dev/null +++ b/buildroot @@ -0,0 +1 @@ +Subproject commit be9f4e6ebe136932eca2e00b58b24f4512e2efc4 diff --git a/fontamsoc-sw b/fontamsoc-sw new file mode 160000 index 0000000..0b710e1 --- /dev/null +++ b/fontamsoc-sw @@ -0,0 +1 @@ +Subproject commit 0b710e1a38e396c62f12eede746d5b91b8d6c853 diff --git a/gcc b/gcc new file mode 160000 index 0000000..74e85e4 --- /dev/null +++ b/gcc @@ -0,0 +1 @@ +Subproject commit 74e85e40088581130fc8725a1f48f9f83f02a23a diff --git a/glibc b/glibc new file mode 160000 index 0000000..bb25bac --- /dev/null +++ b/glibc @@ -0,0 +1 @@ +Subproject commit bb25bac6e42cf78dd0335c803d0c16fcd020fe03 diff --git a/linux b/linux new file mode 160000 index 0000000..5acc7af --- /dev/null +++ b/linux @@ -0,0 +1 @@ +Subproject commit 5acc7af2053e94a6001d0ed72c057193b2748106 diff --git a/makefile b/makefile new file mode 100644 index 0000000..9dfafbf --- /dev/null +++ b/makefile @@ -0,0 +1,103 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Contributed by William Fonkou Tambe + +.PHONY: all clean + +NPROC ?= $(shell nproc) + +all: pu32-toolchain-build/pu32-toolchain.tar.xz + +pu32-toolchain-build: pu32-toolchain + echo - $@: NPROC == ${NPROC} >&2 + sudo apt install -y build-essential texinfo bison flex gawk dejagnu libncurses-dev python-is-python3 libelf-dev zlib1g-dev + sudo mkdir -p /opt/pu32-toolchain + sudo chown "${USER}" /opt/pu32-toolchain + mkdir -p pu32-toolchain-build + touch $@ + +pu32-toolchain-build/.binutils: pu32-toolchain/binutils + echo - $@: NPROC == ${NPROC} >&2 + if [ ! -e binutils-build ]; then mkdir -p binutils-build && cd binutils-build && \ + ${PWD}/pu32-toolchain/binutils/configure --target=pu32-elf --prefix=/opt/pu32-toolchain; fi + if [ -e binutils-build ]; then cd binutils-build && make -j${NPROC} && make install; fi + ln -snf ../include /opt/pu32-toolchain/pu32-elf/include + touch $@ + +gcc-build: pu32-toolchain/gcc + echo - $@: NPROC == ${NPROC} >&2 + if [ ! -e gcc-build ]; then cd pu32-toolchain/gcc && ./contrib/download_prerequisites && cd - && \ + mkdir -p gcc-build && cd gcc-build && \ + ${PWD}/pu32-toolchain/gcc/configure --target=pu32-elf --prefix=/opt/pu32-toolchain --libexecdir=/opt/pu32-toolchain/lib --without-headers --disable-libssp --enable-languages=c && \ + make -j${NPROC} && make install; fi + touch $@ + +pu32-toolchain-build/.linux: pu32-toolchain/linux + echo - $@: NPROC == ${NPROC} >&2 + $(eval KERNEL_BUILD := "${PWD}/linux-build/") + $(eval KERNEL_SOURCE := "${PWD}/pu32-toolchain/linux/") + if [ ! -e ${KERNEL_BUILD} ]; then mkdir -p ${KERNEL_BUILD} && cd ${KERNEL_BUILD} && \ + make -C ${KERNEL_SOURCE} O=${KERNEL_BUILD} ARCH=pu32 defconfig && \ + make ARCH=pu32 CROSS_COMPILE=pu32-elf- V=1 INSTALL_HDR_PATH=/opt/pu32-toolchain headers_install; fi + if [ -e ${KERNEL_BUILD} ]; then cd ${KERNEL_BUILD} && make ARCH=pu32 CROSS_COMPILE=pu32-elf- V=1 vmlinux.bin && \ + cp -a vmlinux ../pu32-toolchain-build/; fi + touch $@ + +pu32-toolchain-build/.glibc: pu32-toolchain/glibc + echo - $@: NPROC == ${NPROC} >&2 + if [ ! -e glibc-build ]; then mkdir -p glibc-build && cd glibc-build && \ + CXX=no libc_cv_with_fp=no libc_cv_ssp=no libc_cv_ssp_all=no libc_cv_ssp_strong=no ${PWD}/pu32-toolchain/glibc/configure --host=pu32-elf --target=pu32-elf --prefix=/opt/pu32-toolchain/pu32-elf --libexecdir=/opt/pu32-toolchain/pu32-elf/lib --disable-profile --enable-kernel=5.0 --with-headers=/opt/pu32-toolchain/include --enable-static-nss && \ + make update-syscall-lists; fi + if [ -e glibc-build ]; then cd glibc-build && make -j${NPROC} && make install; fi + touch $@ + +pu32-toolchain-build/.gcc: pu32-toolchain/gcc + echo - $@: NPROC == ${NPROC} >&2 + if [ ! -e $@ ]; then cd gcc-build && \ + ${PWD}/pu32-toolchain/gcc/configure --target=pu32-elf --prefix=/opt/pu32-toolchain --libexecdir=/opt/pu32-toolchain/lib --without-headers --disable-libssp --enable-languages=c,c++; fi + if [ -e gcc-build ]; then cd gcc-build && make -j${NPROC} && make install; fi + touch $@ + +pu32-toolchain-build/.buildroot: pu32-toolchain/buildroot + echo - $@: NPROC == ${NPROC} >&2 + $(eval BUILDROOT_BUILD := "${PWD}/buildroot-build/") + $(eval BUILDROOT_SOURCE := "${PWD}/pu32-toolchain/buildroot/") + if [ ! -e ${BUILDROOT_BUILD} ]; then mkdir -p ${BUILDROOT_BUILD} && cd ${BUILDROOT_BUILD} && \ + make -C ${BUILDROOT_SOURCE} O=${BUILDROOT_BUILD} pu32_defconfig; fi + if [ -e ${BUILDROOT_BUILD} ]; then cd ${BUILDROOT_BUILD} && make -j${NPROC} V=1 && \ + cp -a images/rootfs.* ../pu32-toolchain-build/; fi + touch $@ + +pu32-toolchain-build/.fontamsoc-sw: pu32-toolchain/fontamsoc-sw + echo - $@: NPROC == ${NPROC} >&2 + cd pu32-toolchain/fontamsoc-sw/bios && make -j${NPROC} install; + touch $@ + +pu32-toolchain-build/pu32-toolchain.tar.xz: \ + pu32-toolchain-build \ + pu32-toolchain-build/.binutils \ + gcc-build \ + pu32-toolchain-build/.linux \ + pu32-toolchain-build/.glibc \ + pu32-toolchain-build/.gcc \ + pu32-toolchain-build/.buildroot \ + pu32-toolchain-build/.fontamsoc-sw + echo - $@: NPROC == ${NPROC} >&2 + cd pu32-toolchain-build/ && \ + tar -caf pu32-toolchain.tar.xz -C /opt/ --exclude pu32-toolchain/.git pu32-toolchain && \ + ls -lha >&2 + +touch-binutils: + touch pu32-toolchain/binutils +touch-gcc: + touch pu32-toolchain/gcc +touch-linux: + touch pu32-toolchain/linux +touch-glibc: + touch pu32-toolchain/glibc +touch-buildroot: + touch pu32-toolchain/buildroot +touch-fontamsoc-sw: + touch pu32-toolchain/fontamsoc-sw + +clean: + rm -rf pu32-toolchain-build binutils-build linux-build glibc-build gcc-build buildroot-build