Add initial build infrastructure

This commit is contained in:
Albert Ou 2016-06-17 11:38:33 -07:00
commit 869273a2a3
8 changed files with 153 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
work/

9
.gitmodules vendored Normal file
View File

@ -0,0 +1,9 @@
[submodule "linux"]
path = linux
url = https://github.com/riscv/riscv-linux.git
[submodule "buildroot"]
path = buildroot
url = https://github.com/a0u/buildroot.git
[submodule "riscv-pk"]
path = riscv-pk
url = git@bitbucket.org:sifive/riscv-pk.git

82
Makefile Normal file
View File

@ -0,0 +1,82 @@
srcdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
srcdir := $(srcdir:/=)
confdir := $(srcdir)/conf
wrkdir := $(CURDIR)/work
buildroot_srcdir := $(srcdir)/buildroot
buildroot_wrkdir := $(wrkdir)/buildroot
buildroot_tar := $(buildroot_wrkdir)/images/rootfs.tar
sysroot_stamp := $(wrkdir)/.sysroot
sysroot := $(wrkdir)/sysroot
linux_srcdir := $(srcdir)/linux
linux_wrkdir := $(wrkdir)/linux
linux_defconfig := $(confdir)/linux_defconfig
vmlinux := $(linux_wrkdir)/vmlinux
vmlinux_stripped := $(linux_wrkdir)/vmlinux-stripped
pk_srcdir := $(srcdir)/riscv-pk
pk_wrkdir := $(wrkdir)/riscv-pk
bbl := $(pk_wrkdir)/bbl
bin := $(wrkdir)/bbl.bin
target := riscv64-unknown-linux-gnu
.PHONY: all
all: $(bin)
$(buildroot_tar): $(buildroot_srcdir)
$(MAKE) -C $< O=$(buildroot_wrkdir) riscv64_defconfig
$(MAKE) -C $< O=$(buildroot_wrkdir)
.PHONY: buildroot-menuconfig
buildroot-menuconfig: $(buildroot_srcdir)
$(MAKE) -C $< O=$(buildroot_wrkdir) menuconfig
$(sysroot_stamp): $(buildroot_tar)
mkdir -p $(sysroot)
tar -xpf $< -C $(sysroot) --exclude ./dev
touch $@
$(linux_wrkdir)/.config: $(linux_defconfig) $(linux_srcdir)
mkdir -p $(dir $@)
cp -p $< $@
$(MAKE) -C $(linux_srcdir) O=$(linux_wrkdir) ARCH=riscv olddefconfig
$(vmlinux): $(linux_srcdir) $(linux_wrkdir)/.config $(sysroot_stamp)
$(MAKE) -C $< O=$(linux_wrkdir) \
CONFIG_INITRAMFS_SOURCE="$(confdir)/initramfs.txt $(sysroot)" \
CONFIG_INITRAMFS_ROOT_UID=$(shell id -u) \
CONFIG_INITRAMFS_ROOT_GID=$(shell id -g) \
ARCH=riscv \
vmlinux
$(vmlinux_stripped): $(vmlinux)
$(target)-strip -o $@ $<
.PHONY: linux-menuconfig
linux-menuconfig: $(linux_wrkdir)/.config
$(MAKE) -C $(linux_srcdir) O=$(dir $<) ARCH=riscv menuconfig savedefconfig
$(bbl): $(pk_srcdir) $(vmlinux_stripped)
rm -rf $(pk_wrkdir)
mkdir -p $(pk_wrkdir)
cd $(pk_wrkdir) && $</configure \
--host=$(target) \
--with-payload=$(vmlinux_stripped)
$(MAKE) -C $(pk_wrkdir)
$(bin): $(bbl)
$(target)-objcopy -S -O binary --change-addresses -0x80000000 $< $@
.PHONY: sysroot vmlinux bbl
sysroot: $(sysroot)
vmlinux: $(vmlinux)
bbl: $(bbl)
.PHONY: clean
clean:
rm -rf -- $(wrkdir)

1
buildroot Submodule

@ -0,0 +1 @@
Subproject commit 8dd56de89c1fe51fcee14f8d873d7b3a1f0e2d80

4
conf/initramfs.txt Normal file
View File

@ -0,0 +1,4 @@
dir /dev 755 0 0
nod /dev/console 644 0 0 c 5 1
nod /dev/null 644 0 0 c 1 3
slink /init /bin/busybox 755 0 0

54
conf/linux_defconfig Normal file
View File

@ -0,0 +1,54 @@
# CONFIG_COMPACTION is not set
CONFIG_HZ_100=y
CONFIG_CROSS_COMPILE="riscv64-unknown-linux-gnu-"
CONFIG_DEFAULT_HOSTNAME="ucbvax"
# CONFIG_CROSS_MEMORY_ATTACH is not set
CONFIG_NAMESPACES=y
CONFIG_BLK_DEV_INITRD=y
# CONFIG_RD_BZIP2 is not set
# CONFIG_RD_LZMA is not set
# CONFIG_RD_XZ is not set
# CONFIG_RD_LZO is not set
# CONFIG_RD_LZ4 is not set
CONFIG_EMBEDDED=y
# CONFIG_BLK_DEV_BSG is not set
CONFIG_PARTITION_ADVANCED=y
# CONFIG_EFI_PARTITION is not set
# CONFIG_IOSCHED_DEADLINE is not set
CONFIG_NET=y
CONFIG_UNIX=y
CONFIG_INET=y
# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
# CONFIG_INET_XFRM_MODE_TUNNEL is not set
# CONFIG_INET_XFRM_MODE_BEET is not set
# CONFIG_INET_LRO is not set
# CONFIG_INET_DIAG is not set
# CONFIG_IPV6 is not set
# CONFIG_WIRELESS is not set
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
# CONFIG_FIRMWARE_IN_KERNEL is not set
# CONFIG_BLK_DEV is not set
# CONFIG_INPUT_MOUSEDEV is not set
# CONFIG_INPUT_KEYBOARD is not set
# CONFIG_INPUT_MOUSE is not set
# CONFIG_VT is not set
# CONFIG_HW_RANDOM is not set
# CONFIG_HWMON is not set
# CONFIG_USB_SUPPORT is not set
# CONFIG_IOMMU_SUPPORT is not set
CONFIG_EXT2_FS=y
# CONFIG_FILE_LOCKING is not set
# CONFIG_DNOTIFY is not set
# CONFIG_INOTIFY_USER is not set
# CONFIG_PROC_PAGE_MONITOR is not set
CONFIG_TMPFS=y
# CONFIG_MISC_FILESYSTEMS is not set
# CONFIG_NETWORK_FILESYSTEMS is not set
CONFIG_EARLY_PRINTK=y
CONFIG_PRINTK_TIME=y
CONFIG_STRIP_ASM_SYMS=y
CONFIG_DEBUG_SECTION_MISMATCH=y
# CONFIG_FRAME_POINTER is not set
# CONFIG_CRYPTO_ANSI_CPRNG is not set
# CONFIG_CRYPTO_HW is not set

1
linux Submodule

@ -0,0 +1 @@
Subproject commit 67628e091e461e0851f2a98120fcbdc1fa2a7ebb

1
riscv-pk Submodule

@ -0,0 +1 @@
Subproject commit 67983fdf1228f714169d49c8761842757933f01c