Skip to content

Commit

Permalink
Add machine-emulator-tools on buildroot build
Browse files Browse the repository at this point in the history
remove tools submodule
  • Loading branch information
vfusco committed Nov 26, 2020
1 parent fc8e8f8 commit 28015e7
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 19 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "tools"]
path = tools
url = ../machine-emulator-tools.git
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ COPY skel $BUILD_BASE/buildroot/skel
COPY cartesi-buildroot-config $BUILD_BASE/buildroot
COPY cartesi-busybox-fragment $BUILD_BASE/buildroot
COPY patches $BUILD_BASE/buildroot/patches
COPY tools/linux/htif/yield $BUILD_BASE/buildroot/skel/opt/cartesi/bin/
COPY tools/linux/utils $BUILD_BASE/buildroot/skel/opt/cartesi/bin

# Never use -jN with buildroot
RUN \
Expand Down
12 changes: 1 addition & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,14 @@ IMG_REPO:=cartesi/rootfs
IMG:=$(IMG_REPO):$(TAG)
BASE:=/opt/riscv
ART:=$(BASE)/rootfs/artifacts/rootfs.ext2
YIELD_BIN:=tools/linux/htif/yield

ifneq ($(TOOLCHAIN_TAG),)
BUILD_ARGS := --build-arg TOOLCHAIN_VERSION=$(TOOLCHAIN_TAG)
endif

all: copy

submodules:
git submodule update --init --recursive

$(YIELD_BIN):
$(MAKE) -C tools/linux/htif TOOLCHAIN_TAG=$(TOOLCHAIN_TAG)

yield: $(YIELD_BIN)

build: $(YIELD_BIN) cartesi-buildroot-config cartesi-busybox-fragment
build: cartesi-buildroot-config cartesi-busybox-fragment
docker build -t $(IMG) $(BUILD_ARGS) .

push:
Expand Down Expand Up @@ -79,7 +70,6 @@ clean-config:
rm -f ./cartesi-buildroot-config ./cartesi-busybox-fragment

clean: clean-config
$(MAKE) -C tools/linux/htif TOOLCHAIN_TAG=$(TOOLCHAIN_TAG) clean
rm -f rootfs.ext2

copy: build
Expand Down
8 changes: 7 additions & 1 deletion configs/default-buildroot-config
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_5=y
# BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_1 is not set
# BR2_TOOLCHAIN_EXTERNAL_HEADERS_3_0 is not set
# BR2_TOOLCHAIN_EXTERNAL_HEADERS_REALLY_OLD is not set
BR2_TOOLCHAIN_EXTERNAL_HAS_CARTESI_KERNEL_HEADERS=y
# BR2_TOOLCHAIN_EXTERNAL_CUSTOM_UCLIBC is not set
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
# BR2_TOOLCHAIN_EXTERNAL_CUSTOM_MUSL is not set
Expand Down Expand Up @@ -2298,7 +2299,7 @@ BR2_PACKAGE_GNUPG2=y
#
# System tools
#
# BR2_PACKAGE_ACL is not set
BR2_PACKAGE_ACL=y
# BR2_PACKAGE_ANDROID_TOOLS is not set
# BR2_PACKAGE_ATOP is not set
BR2_PACKAGE_ATTR=y
Expand Down Expand Up @@ -2436,6 +2437,11 @@ BR2_PACKAGE_UTIL_LINUX_WDCTL=y
BR2_PACKAGE_UTIL_LINUX_WRITE=y
BR2_PACKAGE_UTIL_LINUX_ZRAMCTL=y
# BR2_PACKAGE_XDG_DBUS_PROXY is not set
BR2_PACKAGE_MACHINE_EMULATOR_TOOLS=y
BR2_PACKAGE_MACHINE_EMULATOR_TOOLS_YIELD=y
BR2_PACKAGE_MACHINE_EMULATOR_TOOLS_FLASHDRIVE=y
BR2_PACKAGE_MACHINE_EMULATOR_TOOLS_READBE64=y
BR2_PACKAGE_MACHINE_EMULATOR_TOOLS_WRITEBE64=y

#
# Text editors and viewers
Expand Down
7 changes: 6 additions & 1 deletion configs/min-buildroot-config
Original file line number Diff line number Diff line change
Expand Up @@ -2297,7 +2297,7 @@ BR2_PACKAGE_GNUPG2=y
#
# System tools
#
# BR2_PACKAGE_ACL is not set
BR2_PACKAGE_ACL=y
# BR2_PACKAGE_ANDROID_TOOLS is not set
# BR2_PACKAGE_ATOP is not set
BR2_PACKAGE_ATTR=y
Expand Down Expand Up @@ -2435,6 +2435,11 @@ BR2_PACKAGE_UTIL_LINUX_WDCTL=y
BR2_PACKAGE_UTIL_LINUX_WRITE=y
BR2_PACKAGE_UTIL_LINUX_ZRAMCTL=y
# BR2_PACKAGE_XDG_DBUS_PROXY is not set
BR2_PACKAGE_MACHINE_EMULATOR_TOOLS=y
BR2_PACKAGE_MACHINE_EMULATOR_TOOLS_YIELD=y
BR2_PACKAGE_MACHINE_EMULATOR_TOOLS_FLASHDRIVE=y
BR2_PACKAGE_MACHINE_EMULATOR_TOOLS_READBE64=y
BR2_PACKAGE_MACHINE_EMULATOR_TOOLS_WRITEBE64=y

#
# Text editors and viewers
Expand Down
130 changes: 130 additions & 0 deletions patches/0007-add-machine-emulator-tools.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
diff --git a/package/Config.in b/package/Config.in
--- a/package/Config.in
+++ b/package/Config.in
@@ -2424,6 +2427,7 @@ menu "System tools"
source "package/xdg-dbus-proxy/Config.in"
source "package/xen/Config.in"
source "package/xvisor/Config.in"
+ source "package/machine-emulator-tools/Config.in"
endmenu

menu "Text editors and viewers"
diff --git a/package/machine-emulator-tools/Config.in b/package/machine-emulator-tools/Config.in
new file mode 100644
--- /dev/null
+++ b/package/machine-emulator-tools/Config.in
@@ -0,0 +1,35 @@
+menuconfig BR2_PACKAGE_MACHINE_EMULATOR_TOOLS
+ bool "Cartesi machine-emulator-tools"
+ help
+ Various useful Cartesi machine libraries and utilities.
+
+ Things like yield, flashdrive, readbe64, writebe64, etc...
+
+ https://github.com/cartesi/machine-emulator-tools/
+
+if BR2_PACKAGE_MACHINE_EMULATOR_TOOLS
+
+config BR2_PACKAGE_MACHINE_EMULATOR_TOOLS_YIELD
+ bool "yield"
+ depends on BR2_TOOLCHAIN_EXTERNAL_HAS_CARTESI_KERNEL_HEADERS
+ help
+ Install yield command line utility.
+
+config BR2_PACKAGE_MACHINE_EMULATOR_TOOLS_FLASHDRIVE
+ bool "flashdrive"
+ help
+ Install flashdrive command line utility.
+
+config BR2_PACKAGE_MACHINE_EMULATOR_TOOLS_READBE64
+ bool "readbe64"
+ depends on BR2_PACKAGE_LUA_5_3
+ help
+ Install readbe64 command line utility.
+
+config BR2_PACKAGE_MACHINE_EMULATOR_TOOLS_WRITEBE64
+ bool "writebe64"
+ depends on BR2_PACKAGE_LUA_5_3
+ help
+ Install writebe64 command line utility.
+
+endif
diff --git a/package/machine-emulator-tools/machine-emulator-tools.hash b/package/machine-emulator-tools/machine-emulator-tools.hash
new file mode 100644
--- /dev/null
+++ b/package/machine-emulator-tools/machine-emulator-tools.hash
@@ -0,0 +1 @@
+sha256 11d50c4cffe8e1191ca0427e3fde62a79dc8df93cce2048312690d7c484f7111 v0.2.0.tar.gz
diff --git a/package/machine-emulator-tools/machine-emulator-tools.mk b/package/machine-emulator-tools/machine-emulator-tools.mk
new file mode 100644
--- /dev/null
+++ b/package/machine-emulator-tools/machine-emulator-tools.mk
@@ -0,0 +1,54 @@
+################################################################################
+#
+# machine-emulator-tools
+#
+################################################################################
+
+MACHINE_EMULATOR_TOOLS_VERSION = v0.2.0
+MACHINE_EMULATOR_TOOLS_SOURCE = $(MACHINE_EMULATOR_TOOLS_VERSION).tar.gz
+MACHINE_EMULATOR_TOOLS_SITE = https://github.com/cartesi/machine-emulator-tools/archive
+MACHINE_EMULATOR_TOOLS_LICENSE = Apache-2.0
+MACHINE_EMULATOR_TOOLS_LICENSE_FILES = LICENSE
+MACHINE_EMULATOR_TOOLS_INSTALL_STAGING = NO
+
+ifeq ($(BR2_PACKAGE_MACHINE_EMULATOR_TOOLS_YIELD),y)
+define BUILD_MACHINE_EMULATOR_TOOLS_YIELD
+ $(MAKE) RVCC=$(TARGET_CC) -C $(@D)/linux/htif yield.toolchain
+endef
+define INSTALL_MACHINE_EMULATOR_TOOLS_YIELD
+ $(INSTALL) -D -m 0755 $(@D)/linux/htif/yield $(TARGET_DIR)/opt/cartesi/bin/yield
+endef
+endif
+
+MACHINE_EMULATOR_TOOLS_UTILS =
+
+ifeq ($(BR2_PACKAGE_MACHINE_EMULATOR_TOOLS_FLASHDRIVE),y)
+MACHINE_EMULATOR_TOOLS_UTILS += flashdrive
+endif
+
+ifeq ($(BR2_PACKAGE_MACHINE_EMULATOR_TOOLS_READBE64),y)
+MACHINE_EMULATOR_TOOLS_UTILS += readbe64
+endif
+
+ifeq ($(BR2_PACKAGE_MACHINE_EMULATOR_TOOLS_WRITEBE64),y)
+MACHINE_EMULATOR_TOOLS_UTILS += writebe64
+endif
+
+ifneq ($(MACHINE_EMULATOR_TOOLS_UTILS),)
+define INSTALL_MACHINE_EMULATOR_UTILS
+ for f in $(MACHINE_EMULATOR_TOOLS_UTILS); do \
+ $(INSTALL) -D -m 0755 $(@D)/linux/utils/$$f $(TARGET_DIR)/opt/cartesi/bin/$$f ; \
+ done
+endef
+endif
+
+define MACHINE_EMULATOR_TOOLS_BUILD_CMDS
+ $(BUILD_MACHINE_EMULATOR_TOOLS_YIELD)
+endef
+
+define MACHINE_EMULATOR_TOOLS_INSTALL_TARGET_CMDS
+ $(INSTALL_MACHINE_EMULATOR_TOOLS_YIELD)
+ $(INSTALL_MACHINE_EMULATOR_UTILS)
+endef
+
+$(eval $(generic-package))
diff --git a/toolchain/toolchain-external/toolchain-external-custom/Config.in.options b/toolchain/toolchain-external/toolchain-external-custom/Config.in.options
--- a/toolchain/toolchain-external/toolchain-external-custom/Config.in.options
+++ b/toolchain/toolchain-external/toolchain-external-custom/Config.in.options
@@ -323,6 +323,10 @@ endchoice
comment "Kernel headers older than 3.13 is not tested by Buildroot. Use at your own risk."
depends on !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_13

+config BR2_TOOLCHAIN_EXTERNAL_HAS_CARTESI_KERNEL_HEADERS
+ bool "External toolchain has Cartesi kernel headers?"
+ depends on (BR2_riscv && BR2_RISCV_64)
+
choice
prompt "External toolchain C library"
default BR2_TOOLCHAIN_EXTERNAL_CUSTOM_UCLIBC
1 change: 0 additions & 1 deletion tools
Submodule tools deleted from 3e7757

0 comments on commit 28015e7

Please sign in to comment.