arm-sdk

os build toolkit for various embedded devices
git clone https://git.parazyd.org/arm-sdk
Log | Files | Refs | Submodules | README | LICENSE

commit 85691537f95d0670eb2b32457a73ad3d0d137a3e
parent 7f12c8251b3f24ef155a067335fe65d8c6ca855f
Author: parazyd <parazyd@dyne.org>
Date:   Sat, 12 Nov 2016 14:37:52 +0100

Merge branch 'next'

Diffstat:
Aboards/raspberry-pi1.sh | 130+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mconfig | 8+++++++-
Aextra/blends/README | 1+
Minit.sh | 19+++++++++++++++++++
Msdk | 36++++++++++++++++++++++++++----------
5 files changed, 183 insertions(+), 11 deletions(-)

diff --git a/boards/raspberry-pi1.sh b/boards/raspberry-pi1.sh @@ -0,0 +1,130 @@ +#!/usr/bin/env zsh +# Copyright (c) 2016 Dyne.org Foundation +# arm-sdk is written and maintained by Ivan J. <parazyd@dyne.org> +# +# This file is part of arm-sdk +# +# This source code is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This software is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this source code. If not, see <http://www.gnu.org/licenses/>. + +## kernel build script for Raspberry Pi 2/3 boards + +## settings & config +vars+=(device_name arch size parted_type parted_boot parted_root inittab) +vars+=(gitkernel gitbranch rpifirmware) +arrs+=(custmodules) + +device_name="raspi1" +arch="armel" +size=1337 +inittab="T0:23:respawn:/sbin/agetty -L ttyAMA0 115200 vt100" + +parted_type="dos" +parted_boot="fat32 0 64" +parted_root="ext4 64 -1" + +extra_packages+=() +custmodules=(snd_bcm2835) + +gitkernel="https://github.com/raspberrypi/linux.git" +gitbranch="rpi-4.4.y" +rpifirmware="https://github.com/raspberrypi/firmware.git" + + +prebuild() { + fn prebuild + req=(device_name strapdir) + ckreq || return 1 + + notice "executing $device_name prebuild" + + enablessh + write-fstab + copy-zram-init + install-custom-packages + + mkdir -p $R/tmp/kernels/$device_name +} + +postbuild() { + fn postbuild + + notice "executing $device_name postbuild" + + ## {{{ boot txts + notice "creating cmdline.txt" + cat <<EOF | sudo tee ${strapdir}/boot/cmdline.txt +dwc_otg.fiq_fix_enable=2 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait rootflags=noload net.ifnames=0 quiet +EOF + + notice "creating config.txt" + cat <<EOF | sudo tee ${strapdir}/boot/config.txt +## memory shared with the GPU +gpu_mem=64 + +## always audio +dtparam=audio=on + +## maximum amps on usb ports +max_usb_current=1 +EOF + ## }}} + + ## TODO: remove systemd merda from raspi-config and add here + + postbuild-clean +} + +build_kernel_armel() { + fn build_kernel_armel + req=(R arch device_name gitkernel gitbranch MAKEOPTS rpifirmware) + req+=(strapdir) + ckreq || return 1 + + notice "building $arch kernel" + + prebuild || zerr + + get-kernel-sources + pushd $R/tmp/kernels/$device_name/${device_name}-linux + make bcm2709_defconfig + make $MAKEOPTS || zerr + sudo -E PATH="$PATH" \ + make INSTALL_MOD_PATH=$strapdir modules_install || zerr + popd + + clone-git $rpifirmware "$R/tmp/kernels/$device_name/${device_name}-firmware" + sudo cp $CPVERBOSE -rf $R/tmp/kernels/$device_name/${device_name}-firmware/boot/* $strapdir/boot/ + + pushd $R/tmp/kernels/$device_name/${device_name}-linux + sudo perl scripts/mkknlimg --dtok arch/arm/boot/zImage $strapdir/boot/kernel7.img + sudo cp $CPVERBOSE arch/arm/boot/dts/bcm*.dtb $strapdir/boot/ + sudo cp $CPVERBOSE arch/arm/boot/dts/overlays/*.dtbo $strapdir/boot/overlays/ + sudo cp $CPVERBOSE arch/arm/boot/dts/overlays/README $strapdir/boot/overlays/ + popd + + #sudo rm -rf $strapdir/lib/firmware + #get-kernel-firmware + #sudo cp $CPVERBOSE -ra $R/tmp/linux-firmware $strapdir/lib/firmware + + pushd $R/tmp/kernels/$device_name/${device_name}-linux + sudo -E PATH="$PATH" \ + make INSTALL_MOD_PATH=$strapdir firmware_install || zerr + make mrproper + make bcm2709_defconfig + sudo -E PATH="$PATH" \ + make modules_prepare || zerr + popd + + postbuild || zerr +} diff --git a/config b/config @@ -32,6 +32,12 @@ compiler="armv7-devuan-linux-gnueabihf-" export PATH="$R/gcc/armv7-devuan-linux-gnueabihf/bin:$PATH:/sbin" +## custom toolchain (armv6+armel; gcc 4.9.3) +## https://pub.parazyd.cf/mirror/ +#compiler="armv6-devuan-linux-gnueabi-" +#export PATH="$R/gcc/armv6-devuan-linux-gnueabi/bin:$PATH:/sbin" + + ## custom toolchain (aarch64+arm64; gcc 4.9.3) ## https://pub.parazyd.cf/mirror/ #compiler="aarch64-devuan-linux-gnueabi-" @@ -51,4 +57,4 @@ qemu_bin="/usr/bin/qemu-arm-static" # Devuan ## extra_packages for all images -extra_packages=() +extra_packages=(fake-hwclock) diff --git a/extra/blends/README b/extra/blends/README @@ -0,0 +1 @@ +see `doc/blends` for more info diff --git a/init.sh b/init.sh @@ -56,6 +56,25 @@ cd gcc cd - ## =============== +## armel toolchain +## =============== +armelurldl=http://pub.parazyd.cf/mirror/armv6-devuan-linux-gnueabi.txz +armelshahc=9aa5095f6587fea4e79e8894557044879e98917be5fa37000cf2f474c00d451f +armhfshadl=$(curl -s ${armelurldl}.sha | awk '{print $1}') + +test $armhfshahc = $armhfshadl || { + printf "(!!) armel sha256sum doesn't match with hardcoded one\n" + exit 1 +} + +cd gcc + curl -O ${armelurldl} && \ + curl -O ${armelurldl}.sha && \ + sha256sum -c $(basename $armelurldl).sha \ + && tar xfp $(basename $armelurldl) +cd - + +## =============== ## arm64 toolchain ## =============== arm64urldl=http://pub.parazyd.cf/mirror/aarch64-devuan-linux-gnueabi.txz diff --git a/sdk b/sdk @@ -27,7 +27,7 @@ QUIET=0 [[ $DEBUG = 1 ]] && { CPVERBOSE="-v" - LOG="armsdk.log" + #LOG="armsdk.log" } || [[ $DEBUG = 0 ]] && { CPVERBOSE="" setopt pushdsilent @@ -39,14 +39,14 @@ source $R/lib/zuper/zuper ## global vars vars+=(armsdk_version) vars+=(R workdir strapdir) -vars+=(os boardlib oslib) +vars+=(os boardlib oslib blendlib) vars+=(MAKEOPTS) ## global arrs arrs+=(extra_packages) ## global maps -maps+=(board_map os_map) +maps+=(board_map os_map blend_map) source $R/config source $R/lib/helpers @@ -58,6 +58,7 @@ load() { fn load "$@" os="$1" dev="$2" + blend="$3" req=(os dev) ckreq || return 1 @@ -81,32 +82,47 @@ load() { "n900" "$R/boards/nokia-n900.sh" "odroidxu" "$R/boards/odroid-xu.sh" "ouya" "$R/boards/ouya.sh" + "raspi1" "$R/boards/raspberry-pi1.sh" "raspi2" "$R/boards/raspberry-pi2.sh" "raspi3" "$R/boards/raspberry-pi3.sh" ) os_map=( - "devuan" "$R/lib/libdevuansdk/libdevuansdk" + "devuan" "$R/lib/libdevuansdk/libdevuansdk" + ) + + blend_map=( + "dowse" "https://github.com/dyne/dowse/raw/master/ops/dowse.blend" ) boardlib="${board_map[$dev]}" oslib="${os_map[$os]}" + blendlib="${blend_map[$blend]}" + + [[ $blendlib =~ '^http' ]] && { + notice "grabbing blend from the internetz" + pushd $R/extra/blends + curl -Ls -O $blendlib + popd + blendlib="$R/extra/blends/$(basename $blendlib)" + } [[ -f $boardlib ]] || { die "no valid boards specified"; exit 1 } - [[ -f $oslib ]] || { die "no valid distro specified"; exit 1 } + [[ -f $oslib ]] || { die "no valid distro specified"; exit 1 } + [[ -f $blendlib ]] || warn "no valid blend specified" - source $boardlib && act "$device_name build script loaded" - export OS=$os - source $oslib + [[ -f $boardlib ]] && source $boardlib && act "$device_name build script loaded" + [[ -f $oslib ]] && source $oslib + [[ -f $blendlib ]] && source $blendlib && act "$os blend loaded" && export BLEND=1 - workdir="$R/tmp/${device_name}-build" + workdir="$R/tmp/${os}-${arch}-build" strapdir="$workdir/bootstrap" mkdir -p $strapdir export LANG=C export LC_ALL=C export ARCH=arm - export CROSS_COMPILE=$compiler + export CROSS_COMPILE="$compiler" source $R/lib/zuper/zuper.init }