代码拉取完成,页面将自动刷新
同步操作将从 ipads/Penglai-Enclave 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
# The main Makefile for Penglai-enclave
# This repo will compose riscv-qemu, linux, penglai's monitor,
# enclave driver/SDK and demo apps into a runnable one.
# The Makefile is modified from SiFive's freedom-u-sdk.
# -- Dong Du
# RISCV must set to point to a directory that contains
# a toolchain install tree that was built via other means.
ifndef RISCV
$(error RISCV is not set, no riscv toolchain for build)
endif
PATH := $(RISCV)/bin:$(PATH)
ISA ?= rv64imafdc
ABI ?= lp64d
srcdir := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
srcdir := $(srcdir:/=)
confdir := $(srcdir)/conf
wrkdir := $(CURDIR)/work
copy_dir := $(CURDIR)/copy-files
buildroot_srcdir := $(srcdir)/buildroot
buildroot_initramfs_wrkdir := $(wrkdir)/buildroot_initramfs
buildroot_initramfs_tar := $(buildroot_initramfs_wrkdir)/images/rootfs.tar
buildroot_initramfs_config := $(confdir)/buildroot_initramfs_config
buildroot_initramfs_sysroot_stamp := $(wrkdir)/.buildroot_initramfs_sysroot
buildroot_initramfs_sysroot := $(wrkdir)/buildroot_initramfs_sysroot
buildroot_rootfs_wrkdir := $(wrkdir)/buildroot_rootfs
buildroot_rootfs_ext := $(buildroot_rootfs_wrkdir)/images/rootfs.ext4
buildroot_rootfs_config := $(confdir)/buildroot_rootfs_config
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)/monitor
pk_wrkdir := $(wrkdir)/monitor
bbl := $(pk_wrkdir)/bbl
bin := $(wrkdir)/bbl.bin
hex := $(wrkdir)/bbl.hex
target_platform := spmp
qemu_srcdir := $(srcdir)/riscv-qemu
qemu_wrkdir := $(wrkdir)/riscv-qemu
qemu := $(qemu_wrkdir)/prefix/bin/qemu-system-riscv64
rootfs := $(wrkdir)/rootfs.bin
target := riscv64-unknown-linux-gnu
.PHONY: all
all: $(hex) $(qemu) $(bbl) $(rootfs)
@echo
@echo "This image for Penglai has been generated for an ISA of $(ISA) and an ABI of $(ABI)"
@echo "Type make qemu -j8 to run the image"
@echo
$(buildroot_initramfs_wrkdir)/.config: $(buildroot_srcdir)
#rm -rf $(dir $@)
mkdir -p $(dir $@)
cp $(buildroot_initramfs_config) $@
$(MAKE) -C $< RISCV=$(RISCV) PATH=$(PATH) O=$(buildroot_initramfs_wrkdir) olddefconfig CROSS_COMPILE=riscv64-unknown-linux-gnu-
$(buildroot_initramfs_tar): $(buildroot_srcdir) $(buildroot_initramfs_wrkdir)/.config $(buildroot_initramfs_config) force
$(MAKE) -C $< RISCV=$(RISCV) PATH=$(PATH) O=$(buildroot_initramfs_wrkdir)
.PHONY: buildroot_initramfs-menuconfig
buildroot_initramfs-menuconfig: $(buildroot_initramfs_wrkdir)/.config $(buildroot_srcdir)
$(MAKE) -C $(dir $<) O=$(buildroot_initramfs_wrkdir) menuconfig
$(MAKE) -C $(dir $<) O=$(buildroot_initramfs_wrkdir) savedefconfig
cp $(dir $<)/defconfig conf/buildroot_initramfs_config
$(buildroot_rootfs_wrkdir)/.config: $(buildroot_srcdir)
#rm -rf $(dir $@)
mkdir -p $(dir $@)
cp $(buildroot_rootfs_config) $@
$(MAKE) -C $< RISCV=$(RISCV) PATH=$(PATH) O=$(buildroot_rootfs_wrkdir) olddefconfig
$(buildroot_rootfs_ext): $(buildroot_srcdir) $(buildroot_rootfs_wrkdir)/.config $(buildroot_rootfs_config) $(copy_dir)
$(MAKE) -C $< RISCV=$(RISCV) PATH=$(PATH) O=$(buildroot_rootfs_wrkdir)
$(buildroot_initramfs_sysroot_stamp): $(buildroot_initramfs_tar)
mkdir -p $(buildroot_initramfs_sysroot)
tar -xpf $< -C $(buildroot_initramfs_sysroot) --exclude ./dev --exclude ./usr/share/locale
touch $@
$(linux_wrkdir)/.config: $(linux_defconfig) $(linux_srcdir)
mkdir -p $(dir $@)
cp -p $< $@
$(MAKE) -C $(linux_srcdir) O=$(linux_wrkdir) ARCH=riscv olddefconfig
echo $(ISA)
echo $(filter rv32%,$(ISA))
ifeq (,$(filter rv%c,$(ISA)))
sed 's/^.*CONFIG_RISCV_ISA_C.*$$/CONFIG_RISCV_ISA_C=n/' -i $@
$(MAKE) -C $(linux_srcdir) O=$(linux_wrkdir) ARCH=riscv olddefconfig
endif
ifeq ($(ISA),$(filter rv32%,$(ISA)))
sed 's/^.*CONFIG_ARCH_RV32I.*$$/CONFIG_ARCH_RV32I=y/' -i $@
sed 's/^.*CONFIG_ARCH_RV64I.*$$/CONFIG_ARCH_RV64I=n/' -i $@
$(MAKE) -C $(linux_srcdir) O=$(linux_wrkdir) ARCH=riscv olddefconfig
endif
$(vmlinux): $(linux_srcdir) $(linux_wrkdir)/.config $(buildroot_initramfs_sysroot_stamp)
$(MAKE) -C $< O=$(linux_wrkdir) \
CONFIG_INITRAMFS_SOURCE="$(confdir)/initramfs.txt $(buildroot_initramfs_sysroot)" \
CONFIG_INITRAMFS_ROOT_UID=$(shell id -u) \
CONFIG_INITRAMFS_ROOT_GID=$(shell id -g) \
CROSS_COMPILE=riscv64-unknown-linux-gnu- \
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
$(MAKE) -C $(linux_srcdir) O=$(dir $<) ARCH=riscv savedefconfig
cp $(dir $<)/defconfig conf/linux_defconfig
$(bbl): $(pk_srcdir) $(vmlinux_stripped)
rm -rf $(pk_wrkdir)
mkdir -p $(pk_wrkdir)
cd $(pk_wrkdir) && $</configure \
--host=$(target) \
--with-payload=$(vmlinux_stripped) \
--with-target-platform=$(target_platform) \
--enable-logo \
--with-logo=$(abspath conf/penglai_logo_zh.txt)
CFLAGS="-mabi=$(ABI) -march=$(ISA)" $(MAKE) -C $(pk_wrkdir)
$(bin): $(bbl)
$(target)-objcopy -S -O binary --change-addresses -0x80000000 $< $@
$(hex): $(bin)
xxd -c1 -p $< > $@
$(qemu): $(qemu_srcdir)
rm -rf $(qemu_wrkdir)
mkdir -p $(qemu_wrkdir)
mkdir -p $(dir $@)
cd $(qemu_wrkdir) && $</configure \
--prefix=$(dir $(abspath $(dir $@))) \
--target-list=riscv64-softmmu
$(MAKE) -C $(qemu_wrkdir)
$(MAKE) -C $(qemu_wrkdir) install
touch -c $@
$(rootfs): $(buildroot_rootfs_ext)
cp $< $@
.PHONY: buildroot_initramfs_sysroot vmlinux bbl
buildroot_initramfs_sysroot: $(buildroot_initramfs_sysroot)
vmlinux: $(vmlinux)
bbl: $(bbl)
.PHONY: clean
clean:
# rm -rf -- $(linux_wrkdir)/vmlinux
rm -rf -- $(pk_wrkdir) $(linux_wrkdir)/vmlinux
# rm -rf -- $(wrkdir) $(linux_wrkdir)/vmlinux
# rm -rf -- $(wrkdir)
# rm -rf -- $(wrkdir) $(toolchain_dest)
# FIXME: Here we always re-compile sdk using the force target
.PHONY: force
sdk := $(srcdir)/sdk/enclave-driver/penglai.ko
$(sdk): $(vmlinux) force
cd $(srcdir)/sdk/enclave-driver && make
cd -
cd $(srcdir)/sdk && PENGLAI_SDK=$(srcdir)/sdk make
cd -
# Copy the compiled files to copy-files
cp $(srcdir)/sdk/enclave-driver/penglai.ko $(copy_dir)
cp $(srcdir)/sdk/demo/host/host $(copy_dir)
cp $(srcdir)/sdk/demo/prime/prime $(copy_dir)
sdk: $(sdk)
.PHONY: qemu
qemu:
sudo $(qemu) -nographic -machine virt -smp 8 -m 4096M -kernel $(bbl) \
-drive file=$(rootfs),format=raw,id=hd0 -device virtio-blk-device,drive=hd0 \
-netdev user,id=net0 -device virtio-net-device,netdev=net0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。