From 619501c92172abfa317cf01bf1ef7a9883f98055 Mon Sep 17 00:00:00 2001 From: Takumi Sueda Date: Mon, 28 Sep 2020 00:49:26 +0900 Subject: [PATCH] Add files --- .gitignore | 1 + LICENSE | 5 ++- Makefile | 59 ++++++++++++++++++++++++++++++++++ README.md | 70 ++++++++++++++++++++++++++++++++++++++++- r3build.toml | 38 ++++++++++++++++++++++ scripts/setup_debian.sh | 51 ++++++++++++++++++++++++++++++ 6 files changed, 222 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 r3build.toml create mode 100755 scripts/setup_debian.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0a764a4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +env diff --git a/LICENSE b/LICENSE index 7d58dbb..43c6fd1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,9 @@ +# The copyright notice and the license agreement is applied to all portions +# in this repository except the ones in submodules. + MIT License -Copyright (c) 2020 Takumi Sueda +Copyright (c) 2020 Takumi Sueda Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..622d89f --- /dev/null +++ b/Makefile @@ -0,0 +1,59 @@ +export ARCH=arm +export CROSS_COMPILE=arm-linux-gnueabi- + +.PHONY: +setup: + @echo "Updating submodules" + @git submodule update --init --recursive + @echo "Creating venv" + @python3 -m venv env + @echo "Installing r3build" + @. ./env/bin/activate; \ + pip install r3build + +.PHONY: +watch: + @echo "Watching changes in linux-brain and u-boot-brain" + @. ./env/bin/activate; \ + @python3 -m r3build + +.PHONY: +udefconfig: + make -C ./u-boot-brain mx28evk_defconfig + +.PHONY: +umenuconfig: + make -C ./u-boot-brain menuconfig + +.PHONY: +ubuild: + make -j12 -C ./u-boot-brain u-boot.sb + +.PHONY: +ldefconfig: + make -C ./linux-brain mxs_defconfig + +.PHONY: +lmenuconfig: + make -C ./linux-brain menuconfig + +.PHONY: +lsavedefconfig: + make -C ./linux-brain savedefconfig + cp ./linux-brain/defconfig ./linux-brain/arch/arm/configs/mxs_defconfig + +.PHONY: +lbuild: + make -C ./linux-brain -j12 + +.PHONY: +uuu: + sudo uuu ./u-boot-brain/u-boot.sb + +debian: + mkdir debian + sudo debootstrap --arch=armel --foreign buster debian/ + sudo cp /usr/bin/qemu-arm-static debian/usr/bin/ + sudo cp setup_debian.sh debian/ + sudo chroot debian /setup_debian.sh + diff --git a/README.md b/README.md index 9ced0d1..73e4875 100644 --- a/README.md +++ b/README.md @@ -1 +1,69 @@ -# buildbrain \ No newline at end of file +buildbrain +========== + +This repository includes: + + - linux-brain and u-boot-brain as submodules + - Useful build targets in Makefile + - r3build.toml to watch changes that occur in submodules + + +Getting Started +--------------- + +1. Clone this repository with recursive clone enabled. + + ``` + $ git clone --recursive git@github.com:puhitaku/buildbrain.git + ``` + + - If you've cloned it without `--recursive`, run following command: + + ``` + $ git submodule update --init --recursive + ``` + +2. Then run `make setup` to prepare an build environment. Namely; + + - Python 3 venv in `env` + - r3build command in the env + +3. Install uuu. + + - Follow [the instruction](https://github.com/NXPmicro/mfgtools#linux) and build `uuu` executable. + - Put `uuu` where the PATH executable points to. + + +Build and inject U-Boot +----------------------- + +1. Run `make udefconfig` to generate `.config`. + +2. Run `make ubuild` to build whole repository and generate `u-boot.sb`. + + - i.MX283 loads a packed U-Boot executable called `u-boot.sb`. + +3. To inject the executable into i.MX283 in recovery mode, run `make uuu`. + + +Build Linux +----------- + +1. Run `make ldefconfig` to generate `.config`. + +1. Run `make lbuild` to generate `zImage`. + +1. Confirm that `linux-brain/arch/arm/boot/zImage` exists. + + +Watch changes in submodules & auto-build +---------------------------------------- + +1. Run `r3build`. It'll detect the changes you make and builds the corresponding executable automatically. + + +What's r3build? +--------------- + +[r3build](https://github.com/puhitaku/r3build) is a smart file watcher that aims to provide hot-reloading feature like Web frontend development. + diff --git a/r3build.toml b/r3build.toml new file mode 100644 index 0000000..2daa41f --- /dev/null +++ b/r3build.toml @@ -0,0 +1,38 @@ +[log] + time = true + +[[job]] + name = "U-Boot" + path = './u-boot-brain' + + type = "make" + directory = "u-boot-brain" + target = "u-boot.sb" + + when = "modified" + glob = [ + './u-boot-brain/*.c', + './u-boot-brain/*.h', + './u-boot-brain/*.dts', + './u-boot-brain/*config', + ] + + environment.ARCH = "arm" + environment.CROSS_COMPILE = "arm-linux-gnueabi-" + +[[job]] + name = "Linux" + path = "./linux-brain" + + type = "make" + target = "lbuild" + + when = "modified" + regex = [ + './linux-brain/.+\.[ch]$', + './linux-brain/.+\.dts$', + ] + + environment.ARCH = "arm" + environment.CROSS_COMPILE = "arm-linux-gnueabi-" + diff --git a/scripts/setup_debian.sh b/scripts/setup_debian.sh new file mode 100755 index 0000000..510570b --- /dev/null +++ b/scripts/setup_debian.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +TIMEZONE="Asia/Tokyo" + +/debootstrap/debootstrap --second-stage + +cat < /etc/apt/sources.list +deb http://ftp.jaist.ac.jp/debian buster main contrib non-free +deb-src http://ftp.jaist.ac.jp/debian buster main contrib non-free +deb http://ftp.jaist.ac.jp/debian buster-updates main contrib non-free +deb-src http://ftp.jaist.ac.jp/debian buster-updates main contrib non-free +deb http://security.debian.org/debian-security buster/updates main contrib non-free +deb-src http://security.debian.org/debian-security buster/updates main contrib non-free +EOF + +cat < /etc/apt/apt.conf.d/90-norecommend +APT::Install-Recommends "0"; +APT::Install-Suggests "0"; +EOF + +apt update -y +apt install -y locales + +echo "$TIMEZONE" > /etc/timezone && \ + dpkg-reconfigure -f noninteractive tzdata && \ + sed -i -e 's/# en_US.UTF-8 UTF-8/en_us.UTF-8 UTF-8/' /etc/locale.gen && \ + echo 'LANG="en_US.UTF-8"' > /etc/default/locale && \ + dpkg-reconfigure -f noninteractive locales && \ + update-locale LANG=en_US.UTF-8 + +echo "brain" > /etc/hostname + + +echo root:root | chpasswd + +cat <> /etc/securetty +ttymxc0 +EOF + +DEBIAN_FRONTEND=noninteractive \ + apt install -y dialog sudo \ + libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev \ + xserver-xorg xserver-xorg-video-fbdev xserver-xorg-dev xorg-dev x11-apps \ + openbox obconf obmenu \ + weston xwayland \ + bash tmux vim htop \ + midori pcmanfm lxterminal xterm gnome-terminal fonts-noto-cjk \ + dbus udev build-essential flex bison pkg-config autotools-dev libtool autoconf automake \ + python3 python3-dev python3-setuptools python3-wheel python3-pip \ + resolvconf net-tools ssh openssh-client avahi-daemon +