From f4a3cf20582dec08fd2b02b62ce864fcae7bb038 Mon Sep 17 00:00:00 2001 From: Marcelo Politzer Date: Thu, 16 Sep 2021 14:33:17 -0300 Subject: [PATCH 2/2] RISC-V: cartesi: Initial port --- arch/riscv/Kconfig.socs | 7 +++++ arch/riscv/boards/Makefile | 1 + arch/riscv/boards/cartesi/Makefile | 2 ++ arch/riscv/boards/cartesi/board.c | 28 +++++++++++++++++++ .../cartesi/defaultenv-cartesi/boot/cartesi | 3 ++ .../cartesi/defaultenv-cartesi/init/automount | 6 ++++ .../defaultenv-cartesi/nv/autoboot_timeout | 1 + .../defaultenv-cartesi/nv/boot.default | 1 + arch/riscv/configs/cartesi_defconfig | 15 ++++++++++ 9 files changed, 64 insertions(+) create mode 100644 arch/riscv/boards/cartesi/Makefile create mode 100644 arch/riscv/boards/cartesi/board.c create mode 100755 arch/riscv/boards/cartesi/defaultenv-cartesi/boot/cartesi create mode 100644 arch/riscv/boards/cartesi/defaultenv-cartesi/init/automount create mode 100644 arch/riscv/boards/cartesi/defaultenv-cartesi/nv/autoboot_timeout create mode 100644 arch/riscv/boards/cartesi/defaultenv-cartesi/nv/boot.default create mode 100644 arch/riscv/configs/cartesi_defconfig diff --git a/arch/riscv/Kconfig.socs b/arch/riscv/Kconfig.socs index 221ea133d..12e8e04fc 100644 --- a/arch/riscv/Kconfig.socs +++ b/arch/riscv/Kconfig.socs @@ -22,6 +22,13 @@ config SOC_VIRT Generates an image tht can be be booted by QEMU. The image is called barebox-dt-2nd.img +config BOARD_CARTESI + bool "Cartesi Machine" + select SOC_VIRT + help + Generates an image tht can be be booted by a cartesi-machine. The + image is called barebox-dt-2nd.img + config CPU_SIFIVE bool select HAS_CACHE diff --git a/arch/riscv/boards/Makefile b/arch/riscv/boards/Makefile index cb28a25d8..cee3d2e27 100644 --- a/arch/riscv/boards/Makefile +++ b/arch/riscv/boards/Makefile @@ -2,3 +2,4 @@ obj-$(CONFIG_BOARD_ERIZO_GENERIC) += erizo/ obj-$(CONFIG_BOARD_HIFIVE) += hifive/ obj-$(CONFIG_BOARD_BEAGLEV) += beaglev/ +obj-$(CONFIG_BOARD_CARTESI) += cartesi/ diff --git a/arch/riscv/boards/cartesi/Makefile b/arch/riscv/boards/cartesi/Makefile new file mode 100644 index 000000000..0e3453178 --- /dev/null +++ b/arch/riscv/boards/cartesi/Makefile @@ -0,0 +1,2 @@ +obj-$(CONFIG_BOARD_CARTESI) += board.o +bbenv-$(CONFIG_BOARD_CARTESI) += defaultenv-cartesi diff --git a/arch/riscv/boards/cartesi/board.c b/arch/riscv/boards/cartesi/board.c new file mode 100644 index 000000000..a1a33c8d8 --- /dev/null +++ b/arch/riscv/boards/cartesi/board.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2021 Marcelo Politzer, Cartesi + */ + +#include +#include +#include +#include + +static int cartesi_probe(struct device_d *dev) +{ + barebox_set_hostname("cartesi"); + defaultenv_append_directory(defaultenv_cartesi); + return 0; +} + +static const struct of_device_id cartesi_of_match[] = { + { .compatible = "ucbbar,riscvemu-bar_dev" }, + { /* sentinel */ }, +}; + +static struct driver_d cartesi_board_driver = { + .name = "board-cartesi", + .probe = cartesi_probe, + .of_compatible = cartesi_of_match, +}; +device_platform_driver(cartesi_board_driver); diff --git a/arch/riscv/boards/cartesi/defaultenv-cartesi/boot/cartesi b/arch/riscv/boards/cartesi/defaultenv-cartesi/boot/cartesi new file mode 100755 index 000000000..b175ff556 --- /dev/null +++ b/arch/riscv/boards/cartesi/defaultenv-cartesi/boot/cartesi @@ -0,0 +1,3 @@ +#!/bin/sh + +global.bootm.image=/mnt/rootfs/boot/Image diff --git a/arch/riscv/boards/cartesi/defaultenv-cartesi/init/automount b/arch/riscv/boards/cartesi/defaultenv-cartesi/init/automount new file mode 100644 index 000000000..362ec68ed --- /dev/null +++ b/arch/riscv/boards/cartesi/defaultenv-cartesi/init/automount @@ -0,0 +1,6 @@ +#!/bin/sh + +# mtdram0 +mkdir -p /mnt/rootfs +automount -d /mnt/rootfs 'mount -t ext4 /dev/mtdram0 /mnt/rootfs' + diff --git a/arch/riscv/boards/cartesi/defaultenv-cartesi/nv/autoboot_timeout b/arch/riscv/boards/cartesi/defaultenv-cartesi/nv/autoboot_timeout new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/arch/riscv/boards/cartesi/defaultenv-cartesi/nv/autoboot_timeout @@ -0,0 +1 @@ +0 diff --git a/arch/riscv/boards/cartesi/defaultenv-cartesi/nv/boot.default b/arch/riscv/boards/cartesi/defaultenv-cartesi/nv/boot.default new file mode 100644 index 000000000..98698769f --- /dev/null +++ b/arch/riscv/boards/cartesi/defaultenv-cartesi/nv/boot.default @@ -0,0 +1 @@ +cartesi net diff --git a/arch/riscv/configs/cartesi_defconfig b/arch/riscv/configs/cartesi_defconfig new file mode 100644 index 000000000..79a7a9b42 --- /dev/null +++ b/arch/riscv/configs/cartesi_defconfig @@ -0,0 +1,15 @@ +# minimal +CONFIG_ARCH_RV64I=y +CONFIG_BOARD_CARTESI=y +CONFIG_BOOTM_ELF=y +CONFIG_CMD_AUTOMOUNT=y +CONFIG_CMD_BOOT=y +CONFIG_FS_EXT4=y +CONFIG_MTD=y +CONFIG_MTD_MTDRAM=y +CONFIG_SERIAL_SBI=y +CONFIG_SOC_VIRT=y + +# convenience +CONFIG_CMD_READLINE=y +CONFIG_HUSH_FANCY_PROMPT=y -- 2.32.0