Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tambewilliam committed May 6, 2021
0 parents commit 46d7982
Show file tree
Hide file tree
Showing 10 changed files with 249 additions and 0 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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'
1 change: 1 addition & 0 deletions binutils
Submodule binutils added at a0ff65
1 change: 1 addition & 0 deletions buildroot
Submodule buildroot added at be9f4e
1 change: 1 addition & 0 deletions fontamsoc-sw
Submodule fontamsoc-sw added at 0b710e
1 change: 1 addition & 0 deletions gcc
Submodule gcc added at 74e85e
1 change: 1 addition & 0 deletions glibc
Submodule glibc added at bb25ba
1 change: 1 addition & 0 deletions linux
Submodule linux added at 5acc7a
103 changes: 103 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 46d7982

Please sign in to comment.