Brainux for x1

This commit is contained in:
Takumi Sueda 2021-03-06 20:19:11 +09:00
parent 5689b3a04e
commit 2c89ef57d1
11 changed files with 269 additions and 22 deletions

View File

@ -87,6 +87,41 @@ jobs:
asset_name: listconfig
asset_content_type: text/plain
build-linux-x1:
runs-on: ubuntu-20.04
needs: [create_release]
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Workaround for apt update failure
run: sudo rm /etc/apt/sources.list.d/github_git-lfs.*
- name: Install deps
run: sudo apt update && sudo apt install build-essential bison flex libncurses5-dev gcc-arm-linux-gnueabihf libssl-dev lzop qemu-user-static debootstrap
- name: Configure for Linux
run: make ldefconfig-x1
- name: Build Linux
run: make lbuild
- name: Setup releases
id: release_name
run: |
mkdir release
cp ./linux-brain/arch/arm/boot/dts/imx7ulp-pwh*.dtb release/
cp ./linux-brain/arch/arm/boot/zImage release/zImage
zip -r release.zip release/
- name: Generate archive name
id: archive_name
run: echo ::set-output name=name::linux-x1-${GITHUB_REF/refs\/*s\//}
- name: Upload release.zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: release.zip
asset_name: ${{ steps.archive_name.outputs.name }}.zip
asset_content_type: application/zip
build-uboot:
runs-on: ubuntu-20.04
needs: [create_release]
@ -145,6 +180,45 @@ jobs:
asset_name: ${{ steps.archive_name.outputs.name }}.zip
asset_content_type: application/zip
build-uboot-x1:
runs-on: ubuntu-20.04
needs: [create_release]
strategy:
matrix:
include:
- model: h1
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Workaround for apt update failure
run: sudo rm /etc/apt/sources.list.d/github_git-lfs.*
- name: Install deps
run: sudo apt update && sudo apt install build-essential bison flex libncurses5-dev gcc-arm-linux-gnueabihf libssl-dev lzop qemu-user-static debootstrap
- name: Configure for U-Boot
run: make udefconfig-${{ matrix.model }}
- name: Build U-Boot
run: make ubuild
- name: Setup releases
id: release_name
run: |
mkdir release
cp ./u-boot-brain/u-boot.bin release/u-boot.bin
zip -r release.zip release/
- name: Generate archive name
id: archive_name
run: echo ::set-output name=name::uboot-${{ matrix.model }}-${GITHUB_REF/refs\/*s\//}
- name: Upload release.zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: release.zip
asset_name: ${{ steps.archive_name.outputs.name }}.zip
asset_content_type: application/zip
build-sd:
runs-on: ubuntu-20.04
needs: [create_release]
@ -181,3 +255,40 @@ jobs:
asset_name: ${{ steps.image_name.outputs.name }}.zip
asset_content_type: application/zip
build-sd-x1:
runs-on: ubuntu-20.04
needs: [create_release]
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Workaround for apt update failure
run: sudo rm /etc/apt/sources.list.d/github_git-lfs.*
- name: Install deps
run: sudo apt update && sudo apt install kpartx build-essential bison flex libncurses5-dev gcc-arm-linux-gnueabihf libssl-dev lzop qemu-user-static debootstrap
- name: Configure for U-Boot
run: make udefconfig-x1
- name: Build U-Boot
run: make ubuild
- name: Configure for Linux
run: make ldefconfig-x1
- name: Build Linux
run: make lbuild
- name: Build Debian Root
run: make brainux
- name: Generate image name
id: image_name
run: echo ::set-output name=name::sdimage-x1-${GITHUB_REF/refs\/*s\//}
- name: Build SD image
run: make image/sd_x1.img && mv image/sd_x1.img ${{ steps.image_name.outputs.name }}.img
- name: Compress
run: zip ${{ steps.image_name.outputs.name }}.zip ${{ steps.image_name.outputs.name }}.img
- name: Upload the image
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ${{ steps.image_name.outputs.name }}.zip
asset_name: ${{ steps.image_name.outputs.name }}.zip
asset_content_type: application/zip

3
.gitmodules vendored
View File

@ -7,3 +7,6 @@
[submodule "nkbin_maker"]
path = nkbin_maker
url = https://github.com/brain-hackers/nkbin_maker.git
[submodule "boot4u"]
path = boot4u
url = https://github.com/brain-hackers/boot4u

View File

@ -1,7 +1,9 @@
JOBS=$(shell grep -c '^processor' /proc/cpuinfo)
UBOOT_CROSS=$(shell ./tools/getcross u-boot)
LINUX_CROSS=$(shell ./tools/getcross linux)
ROOTFS_CROSS=$(shell ./tools/getcross rootfs)
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-
.PHONY:
setup:
@ -33,11 +35,11 @@ udefconfig-%:
.PHONY:
usavedefconfig:
make -C ./u-boot-brain savedefconfig
make CROSS_COMPILE=$(UBOOT_CROSS) -C ./u-boot-brain savedefconfig
.PHONY:
umenuconfig:
make -C ./u-boot-brain menuconfig
make CROSS_COMPILE=$(UBOOT_CROSS) -C ./u-boot-brain menuconfig
.PHONY:
uclean:
@ -45,28 +47,41 @@ uclean:
.PHONY:
ubuild:
make -j$(JOBS) -C ./u-boot-brain u-boot.sb
if [ "$(UBOOT_CROSS)" = "arm-linux-gnueabi-" ]; then \
make CROSS_COMPILE=$(UBOOT_CROSS) -j$(JOBS) -C ./u-boot-brain u-boot.sb; \
else \
make CROSS_COMPILE=$(UBOOT_CROSS) -j$(JOBS) -C ./u-boot-brain u-boot.imx; \
fi
.PHONY:
ldefconfig:
make -C ./linux-brain brain_defconfig
.PHONY:
ldefconfig-x1:
make -C ./linux-brain imx_v7_defconfig
.PHONY:
lmenuconfig:
make -C ./linux-brain menuconfig
make CROSS_COMPILE=$(LINUX_CROSS) -C ./linux-brain menuconfig
.PHONY:
lsavedefconfig:
make -C ./linux-brain savedefconfig
make CROSS_COMPILE=$(LINUX_CROSS) -C ./linux-brain savedefconfig
mv ./linux-brain/defconfig ./linux-brain/arch/arm/configs/brain_defconfig
.PHONY:
lsavedefconfig-x1:
make CROSS_COMPILE=$(LINUX_CROSS) -C ./linux-brain savedefconfig
mv ./linux-brain/defconfig ./linux-brain/arch/arm/configs/imx_v7_defconfig
.PHONY:
lclean:
make -C ./linux-brain distclean
.PHONY:
lbuild:
make -j$(JOBS) -C ./linux-brain
make CROSS_COMPILE=$(LINUX_CROSS) -j$(JOBS) -C ./linux-brain
.PHONY:
ldebpkg:
@ -104,6 +119,14 @@ nkbin-maker:
nk.bin:
./nkbin_maker/bsd-ce ./u-boot-brain/u-boot.bin
.PHONY:
boot4ubuild:
make -C ./boot4u
.PHONY:
boot4uclean:
make -C ./boot4u clean
brainux:
@if [ "$(shell uname)" != "Linux" ]; then \
echo "Debootstrap is only available in Linux!"; \
@ -112,9 +135,9 @@ brainux:
sudo mkdir -p brainux
@if [ "$(CI)" = "true" ]; then \
echo "I'm in CI and debootstrap without cache."; \
sudo debootstrap --arch=armel --foreign bullseye brainux/; \
sudo debootstrap --arch=$(ROOTFS_CROSS) --foreign buster brainux/; \
else \
sudo debootstrap --arch=armel --foreign bullseye brainux/ http://localhost:65432/debian/; \
sudo debootstrap --arch=$(ROOTFS_CROSS) --foreign buster brainux/ http://localhost:65432/debian/; \
fi
sudo cp /usr/bin/qemu-arm-static brainux/usr/bin/
sudo cp ./os-brainux/setup_brainux.sh brainux/
@ -125,6 +148,9 @@ brainux:
image/sd.img: clean_work
./image/build_image.sh
image/sd_x1.img: clean_work
./image/build_image_x1.sh
.PHONY:
clean_work:
sudo rm -rf image/work

View File

@ -3,7 +3,7 @@ buildbrain
This repository includes:
- linux-brain, u-boot-brain and nkbin_maker as submodules
- linux-brain, u-boot-brain, nkbin_maker and boot4u as submodules
- Useful build targets in Makefile
- r3build.toml to watch changes that occur in submodules
@ -21,7 +21,8 @@ Getting Started
1. Install dependencies.
```
$ sudo apt install build-essential bison flex libncurses5-dev gcc-arm-linux-gnueabi qemu-user-static debootstrap kpartx
$ sudo apt install build-essential bison flex libncurses5-dev gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf libssl-dev bc lzop qemu-user-static debootstrap kpartx
$ pip install pyelftools
```
1. Clone this repository with recursive clone enabled.
@ -42,34 +43,47 @@ Getting Started
- Put `uuu` where the PATH executable points to.
Build and inject U-Boot
Build U-Boot
-----------------------
1. Run `make udefconfig-sh*` to generate `.config`.
- For Sx1: `make udefconfig-sh1`
- For Sx6: `make udefconfig-sh6`
- For x1: `make udefconfig-h1`
2. Run `make ubuild` to build whole repository and generate `u-boot.sb`.
2. Run `make ubuild` to build whole repository and generate `u-boot.sb` or `u-boot.bin`.
- 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`.
Inject U-Boot into i.MX283 in recovery mode
-----------------------
1. Follow `Build U-Boot` procedure to make U-Boot binary.
1. Run `make uuu`
Build and make NK.bin
-----------------------
1. Run `make udefconfig` to generate `.config`.
1. Follow `Build U-Boot` procedure to make U-Boot binary.
2. Run `make ubuild` to build whole repository and generate `u-boot.bin`.
1. Run `make nkbin-maker`.
3. Run `make nkbin-maker`.
4. To make `nk.bin`, run `make nk.bin`.
1. To make `nk.bin`, run `make nk.bin`.
- nkbin_maker packs `u-boot.bin` into `nk.bin`.
Build and deploy boot4u
-----------------------
1. Run `make boot4u`
1. Create index.din and copy AppMain.bin
- `mkdir /path/to/your/sd/1st/partition/App/boot4u`
- `touch /path/to/your/sd/1st/partition/App/boot4u/index.din`
- `cp boot4u/AppMain.bin /path/to/your/sd/1st/partition/App/boot4u/`
Build Linux
-----------
@ -94,6 +108,11 @@ Bootstrap Debian 11 (bullseye)
1. Confirm that `image/sd.img` is built and burn it to an SD card.
Known issues
----------------------------------------
If you using gcc 10 for host compiler, `make ubuild` may fail.
To complete build, open `/u-boot-brain/scripts/dtc/dtc-lexer.lex.c` or `/u-boot-brain/scripts/dtc/dtc-parser.tab.c` then comment out `YYLTYPE yylloc;`
Watch changes in submodules & auto-build
----------------------------------------

1
boot4u Submodule

@ -0,0 +1 @@
Subproject commit 3f916a0cf7b2516e3eaa720a5c77efbe53527eeb

51
image/build_image_x1.sh Executable file
View File

@ -0,0 +1,51 @@
#!/bin/bash
set -uex -o pipefail
JOBS=$(nproc)
REPO=$(git rev-parse --show-toplevel)
WORK=${REPO}/image/work
LINUX=${REPO}/linux-brain
IMG=${REPO}/image/sd.img
mkdir -p ${WORK}
dd if=/dev/zero of=${IMG} bs=1M count=3072
START1=2048
SECTORS1=$((1024 * 1024 * 64 / 512))
START2=$((2048 + ${SECTORS1}))
cat <<EOF > ${WORK}/part.sfdisk
${IMG}1 : start=${START1}, size=${SECTORS1}, type=b
${IMG}2 : start=${START2}, type=83
EOF
sfdisk ${IMG} < ${WORK}/part.sfdisk
sudo kpartx -av ${IMG}
LOOPDEV=$(losetup -l | grep sd.img | grep -o 'loop.')
sudo mkfs.fat -F32 -v -I /dev/mapper/${LOOPDEV}p1
sudo mkfs.ext4 /dev/mapper/${LOOPDEV}p2
mkdir -p ${WORK}/p1 ${WORK}/p2
sudo mount /dev/mapper/${LOOPDEV}p1 ${WORK}/p1
sudo mount /dev/mapper/${LOOPDEV}p2 ${WORK}/p2
sudo cp ${LINUX}/arch/arm/boot/zImage ${WORK}/p1/
sudo cp ${LINUX}/arch/arm/boot/dts/imx7ulp-pwh*.dtb ${WORK}/p1/
sudo cp ${REPO}/u-boot-brain/u-boot.bin ${WORK}/p1/
mkdir -p ${WORK}/p1/App/boot4u
sudo cp ${REPO}/boot4u/AppMain.bin ${WORK}/p1/App/boot4u/
sudo touch ${WORK}/p1/App/boot4u/index.din
sudo cp -ra ${REPO}/brainux/* ${WORK}/p2/
sudo umount ${WORK}/p1 ${WORK}/p2
sudo kpartx -d ${IMG}
rmdir ${WORK}/p1 ${WORK}/p2

@ -1 +1 @@
Subproject commit 7738c0a9cea5981cee2ec4519e14bbd4c0787a95
Subproject commit fff05eea6877c4a93f1c289aa7ca11feb824389d

@ -1 +0,0 @@
Subproject commit 4a97a4e8074cec12ac8989bcfcab9b9f7d47156d

View File

@ -102,6 +102,7 @@ usermod -a -G video user
# Allow root login via UART
cat <<EOF >> /etc/securetty
ttymxc0
ttyLP0
EOF
# Get wild

36
tools/getcross Executable file
View File

@ -0,0 +1,36 @@
#!/bin/sh
set -e
uboot() {
. ./u-boot-brain/.config
case "${CONFIG_SYS_CPU}" in
arm926ejs) echo -n "arm-linux-gnueabi-"; return;;
armv7) echo -n "arm-linux-gnueabihf-"; return;;
*) exit 1;;
esac
}
linux() {
. ./linux-brain/.config
case "${CONFIG_CPU_ARM926T}_${CONFIG_ARCH_MULTI_V7}" in
y_) echo -n "arm-linux-gnueabi-"; return;;
_y) echo -n "arm-linux-gnueabihf-"; return;;
*) exit 1;;
esac
}
rootfs() {
. ./linux-brain/.config
case "${CONFIG_CPU_ARM926T}_${CONFIG_ARCH_MULTI_V7}" in
y_) echo -n "armel"; return;;
_y) echo -n "armhf"; return;;
*) exit 1;;
esac
}
case "$1" in
u-boot) uboot ;;
linux) linux ;;
rootfs) rootfs ;;
*) exit 1; ;;
esac

@ -1 +1 @@
Subproject commit 6390f0ed58a25b770523c81d8b1064fb4b556910
Subproject commit 4a52b35110e9017fdf2b608dbed3805750098463