Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure build system to use Taskfile #217

Merged
merged 6 commits into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 52 additions & 58 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,148 +27,142 @@ workflows:
jobs:
- compile
- image
#TODO: Utilize CircleCI caching for at least the kernel tarball
jobs:
clean-code:
docker:
- image: cimg/go:1.16.5
- image: cimg/go:1.16.7
working_directory: ~/go/src/github.com/u-root/u-bmc
environment:
- CGO_ENABLED: 0
steps:
- checkout
- run:
name: Install dep
command: |
wget https://github.com/golang/dep/releases/download/v0.5.4/dep-linux-amd64
mv dep-linux-amd64 dep
chmod +x dep
- run:
name: Install ineffassign
command: go get github.com/gordonklaus/ineffassign
- run:
name: Install Task
command: sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
- run:
name: Create test key
command: |
ssh-keygen -t rsa -b 4096 -C "testkey" -N "testpass" -f ./ssh_keys
touch config/i_agree_to_the_acme_terms
go generate ./config/
ssh-keygen -t rsa -b 4096 -C "testkey" -N "testpass" -f config/ssh_keys
touch i_agree_to_the_acme_terms
echo quanta-f06-leopard-ddr3 > TARGET
task config:generate
- run:
name: vendor
command: go mod vendor
- run:
name: vet
command: |
make get
go vet $(go list ./... | grep -v /vendor/)
command: go vet $(go list ./... | grep -v vendor/)
- run:
name: gofmt
command: test -z "$(gofmt -s -l $(go list ./... | grep -v /vendor/ | cut -f 4- -d '/'))"
command: test -z "$(gofmt -s -l $(go list ./... | grep -v vendor/ | cut -f 4- -d '/'))"
- run:
name: ineffassign
command: ineffassign .
test:
docker:
- image: cimg/go:1.16.5
- image: cimg/go:1.16.7
working_directory: ~/go/src/github.com/u-root/u-bmc
environment:
- CGO_ENABLED: 0
steps:
- checkout
- run:
name: Install Task
command: sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
- run:
name: Create test key
command: |
ssh-keygen -t rsa -b 4096 -C "testkey" -N "testpass" -f ./ssh_keys
touch config/i_agree_to_the_acme_terms
go generate ./config/
ssh-keygen -t rsa -b 4096 -C "testkey" -N "testpass" -f config/ssh_keys
touch i_agree_to_the_acme_terms
echo quanta-f06-leopard-ddr3 > TARGET
task config:generate
- run:
name: Test all
command: |
make get
make test
command: task test
- run:
name: Test coverage
command: make test TESTFLAGS=-cover
command: task coverage
race:
docker:
- image: cimg/go:1.16.5
- image: cimg/go:1.16.7
working_directory: ~/go/src/github.com/u-root/u-bmc
environment:
- CGO_ENABLED: 1
steps:
- checkout
- run:
name: Install Task
command: sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
- run:
name: Create test key
command: |
ssh-keygen -t rsa -b 4096 -C "testkey" -N "testpass" -f ./ssh_keys
touch config/i_agree_to_the_acme_terms
go generate ./config/
ssh-keygen -t rsa -b 4096 -C "testkey" -N "testpass" -f config/ssh_keys
touch i_agree_to_the_acme_terms
echo quanta-f06-leopard-ddr3 > TARGET
task config:generate
- run:
name: Race detector
command: |
make get
make test TESTFLAGS=-race
command: task race
compile:
docker:
- image: cimg/go:1.16.5
- image: cimg/go:1.16.7
working_directory: ~/go/src/github.com/u-root/u-bmc
environment:
- CGO_ENABLED: 0
steps:
- checkout
- run:
name: Install Task
command: sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
- run:
name: Create test key
command: |
ssh-keygen -t rsa -b 4096 -C "testkey" -N "testpass" -f ./ssh_keys
touch config/i_agree_to_the_acme_terms
go generate ./config/
ssh-keygen -t rsa -b 4096 -C "testkey" -N "testpass" -f config/ssh_keys
touch i_agree_to_the_acme_terms
echo quanta-f06-leopard-ddr3 > TARGET
task config:generate
- run:
name: build all commands
command: |
make get
cd cmd
go install -a ./...
cd ../
go install -a ./platform/quanta-f06-leopard-ddr3/cmd/uinit
image:
docker:
- image: cimg/go:1.16.5
- image: cimg/go:1.16.7
working_directory: ~/go/src/github.com/u-root/u-bmc
environment:
- CGO_ENABLED: 0
steps:
- checkout
- run:
name: Install dependencies
# Workaround for u-root only needed until proper modules support is in place
command: |
sudo apt-get update
sudo apt-get install gcc-arm-none-eabi mtd-utils fakeroot flex bison device-tree-compiler bc libssl-dev zlib1g-dev libglib2.0-dev libpixman-1-dev unzip cpio patch libelf-dev qemu-kvm
go mod vendor
GO111MODULE=off go get github.com/u-root/u-root
sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
- run:
name: Create test key
command: |
ssh-keygen -t rsa -b 4096 -C "testkey" -N "testpass" -f ./ssh_keys
touch config/i_agree_to_the_acme_terms
# TODO(bluecmd): This step should probably be cached somehow
- run:
name: Update submodules
command: |
# Since linux is huge it would be good to cache the tar file
# from somewhere. No submodules necessary anymore.
ssh-keygen -t rsa -b 4096 -C "testkey" -N "testpass" -f config/ssh_keys
touch i_agree_to_the_acme_terms
echo quanta-f06-leopard-ddr3 > TARGET
- run:
name: Build image
command: |
go generate ./config/
make get
make
command: task build
- store_artifacts:
path: flash.img
path: build/flash.img
destination: flash.img
- run:
name: Prepare integration tests
command: |
make integration/bzImage
export UBMC_QEMU=qemu-system-arm
export UBMC_NATIVE_QEMU=qemu-system-x86_64
- run:
name: Run integration tests
command: |
cd integration/
go test
command: task integration
- store_artifacts:
path: integration/serial
- run:
Expand Down
45 changes: 13 additions & 32 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,32 +1,13 @@
boot/out
boot/keys
boot/loader.cpio.gz
boot/loader/loader
boot/signer/signer
boot/*.dtb.*
boot/zImage*
boot/modules
boot/boot.bin
boot/boot-config.auto.h
boot/kexec
*.img
.*.sw*
root/
integration/bzImage
integration/serial/
initramfs.cpio
initramfs.cpio.tmp
ssh_keys.pub
u-bmc
linux.config.old
module/.*.cmd
module/.tmp_versions
module/*.ko
module/*.mod.c
module/*.mod
module/*.o
module/modules.*
module/Module.symvers
vendor/**/.bb
*.tar.gz
linux-*
vendor/*
build/*
.task/*
i_agree_to_the_acme_terms
TARGET
config/ssh_keys.pub
config/ssh_keys.go
config/version.go
config/acme.go
config/sim_pebble.go
config/sim-pebble.crt
config/sim-pebble.key
**/.bb
1 change: 0 additions & 1 deletion .gitmodules

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BSD 3-Clause License

Copyright (c) 2012-2017, u-root Authors
Copyright (c) 2012-2021, u-root Authors
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
64 changes: 42 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Card](https://goreportcard.com/badge/github.com/u-root/u-bmc)](https://goreportc
u-bmc uses u-root to create a Linux OS distribution that is fully open-source.

u-bmc borrows and contributes to [OpenBMC](https://github.com/openbmc/openbmc) which has
similar high-level goals. The main difference is that u-bmc chooses to challenge the industry status quo.
E.g. where OpenBMC uses IPMI, u-bmc uses gRPC.
similar high-level goals. The main difference is that u-bmc chooses to challenge the industry status quo,
e.g. where OpenBMC uses IPMI, u-bmc uses gRPC.

# Demo

Expand All @@ -26,14 +26,15 @@ u-bmc sets out to improve this by offering an alternative built on modern techno
# Support

u-bmc is still in experimental stage and is currently only supporting
BMCs based on ASPEED AST2400. Other BMC SOCs are planned, and if you want
BMCs based on ASPEED AST2400 and AST2500. Other BMC SOCs are planned, and if you want
to contribute let us know.

Currently the supported boards are:
- Open Compute Project: Quanta F06 Leopard DDR3
- Aspeed AST2500 Evaluation Board

Planned boards are:
- ASRock Rack PAUL
- Nuvoton Poleg BMC NPCM7XX Evaluation Board
- Open Compute Project: Quanta F20 Yosemite
- Tyan Tempest CX S7106
Expand Down Expand Up @@ -61,8 +62,31 @@ To give you some sense of what we want to create:
# Usage

Prerequisites:

u-bmc uses the Taskfile build system, install it using their [official installation guide](https://taskfile.dev/#/installation).

Packages needed:
- gcc-arm-none-eabi
- mtd-utils
- go
- make
- fakeroot
- flex
- bison
- device-tree-compiler
- bc
- libssl-dev
- libelf-dev
- qemu-kvm

Get them via e.g.:
```
sudo apt install gcc-arm-none-eabi mtd-utils golang fakeroot flex bison device-tree-compiler bc libssl-dev libelf-dev qemu-kvm
```

Until u-root has proper go modules support install it with:
```
sudo apt install gcc-arm-none-eabi mtd-utils golang-1.12 fakeroot flex bison device-tree-compiler bc libssl-dev libelf-dev qemu-kvm
GO111MODULES=off go get github.com/u-root/u-root
```

Clone source code:
Expand All @@ -74,23 +98,26 @@ cd ~/go/src/github.com/u-root/u-bmc
Setup configuration:
```
# SSH ECDSA public keys does not work for now
cp ~/.ssh/id_rsa.pub ssh_keys.pub
cp ~/.ssh/id_rsa.pub config/ssh_keys.pub
# Agree to the terms of the configured ACME server
# By default it's just a toy ACME server so this is fine, but if you're
# using another ACME server like Let's Encrypt (LE) ensure you agree to their terms.
# For LE, you can find them at https://letsencrypt.org/repository/.
touch config/i_agree_to_the_acme_terms
go generate ./config/
touch i_agree_to_the_acme_terms
task config:generate
```

Build image:
```
make get
make
cp config/TARGET.tmpl TARGET
```
then uncomment the desired target platform in TARGET and run
```
task build
```

Since u-bmc uses signed binaries it is important that you back up the
contents of boot/keys/ after building as u-bmc will only accept updates
contents of build/boot/keys/ after building as u-bmc will only accept updates
signed with these keys.

# Hacking
Expand All @@ -105,12 +132,12 @@ Trying out u-bmc is easiest using the simulator. To launch it, run:

```
# Launch a local ACME server
make pebble &
task pebble &
# Launch u-bmc simulator
make sim
task sim
# (Optional, run in another terminal) Launch a local emulated BIOS to produce some data on the UART
# Needs to have u-bmc simulator above running for it to attach correctly.
make run-ovmf
task virtual-host
```

When simulating the following TCP/IP ports are set up:
Expand Down Expand Up @@ -138,16 +165,9 @@ If you restart pebble you need to update root.crt.

## Testing

The easiest way to run all unit tests is to run `make test`.
The easiest way to run all unit tests is to run `task test`.

To run the integration tests:
```
make integration/bzImage
export UBMC_QEMU=qemu-system-arm
export UBMC_NATIVE_QEMU=kvm
cd integration
go test
```
To run the integration tests: `task test`.

If you're using a supported platform and want to try it on your hardware you
can use socflash\_x64 provided by ASPEED like this:
Expand Down
3 changes: 3 additions & 0 deletions TARGET.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Uncomment only one target to build for!
#aspeed-ast2500evb
#quanta-f06-leopard-ddr3
Loading