Browse Source

Merge branch 'starfive-kirkstone' into 'starfive-kirkstone'

JH8100 November Release

See merge request starfive-tech/meta-starfive!43
tienhock.loh 5 months ago
parent
commit
7913f9bfec

+ 2 - 0
conf/machine/starfive-jh8100.conf

@@ -69,5 +69,7 @@ WKS_FILE_DEPENDS ?= " \
 IMAGE_BOOT_FILES ?= " \
         jh8100-fpga.dtb \
 	Image \
+	uboot.env \
+	u-boot.itb \
 "
 WKS_FILE ?= "starfive-jh8100.wks"

+ 2 - 2
recipes-bsp/opensbi/opensbi_%.bbappend

@@ -7,8 +7,8 @@ BRANCH:starfive-visionfive2 = "master"
 SRCREV:starfive-visionfive2 = "c6a092cd80112529cb2e92e180767ff5341b22a3"
 
 FORK:starfive-jh8100 = "starfive-tech"
-BRANCH:starfive-jh8100 = "fpga-starfive-v1.2-jh8100"
-SRCREV:starfive-jh8100 = "06c3d05b7f5f1e0aa24141e4de487313b620cea9"
+BRANCH:starfive-jh8100 = "fpga-starfive-v1.2-jh8100-bmc-30Nov"
+SRCREV:starfive-jh8100 = "7cbdf359bb9d2f4c79c736fa92952a06a7740657"
 
 SRC_URI:starfive-dubhe = "\
 	git://github.com/${FORK}/opensbi.git;protocol=https;branch=${BRANCH} \

BIN
recipes-bsp/starfive-tool/files/jh8100_cst.tar.gz


+ 27 - 8
recipes-bsp/starfive-tool/starfive-tool.bb

@@ -1,19 +1,38 @@
-DESCRIPTION = "Starfive Visionfive2 Tools"
+DESCRIPTION = "Starfive Tools"
 
-LICENSE = "GPL-2.0"
-LIC_FILES_CHKSUM = "file://LICENSE;md5=e6dc25dc2418b8831c906d43809d8336"
+LICENSE = "CLOSED"
+LIC_FILES_CHKSUM = ""
 
-SRC_URI = "git://github.com/starfive-tech/tools.git;protocol=https;nobranch=1"
-SRCREV = "6067c32c4cc11749a503b0708d98d6d45022cc0c"
+LICENSE:starfive-visionfive2 = "GPL-2.0"
+LIC_FILES_CHKSUM:starfive-visionfive2 = "file://LICENSE;md5=e6dc25dc2418b8831c906d43809d8336"
 
-S = "${WORKDIR}/git/spl_tool"
+LICENSE:starfive-jh8100 = "CLOSED"
+LIC_FILES_CHKSUM:starfive-jh8100 = ""
 
-do_compile() {
+FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
+
+SRC_URI:starfive-visionfive2 = "git://git@192.168.110.45/sdk/soft_3rdpart;protocol=ssh;branch=jh7110-devel"
+SRC_URI:starfive-jh8100 = "file://jh8100_cst.tar.gz \
+			"
+
+SRCREV:starfive-visionfive2 = "10f543ca35e14809a9b4e9df814b798aa4362d14"
+
+S:starfive-visionfive2 = "${WORKDIR}/git/spl_tool"
+
+do_compile:starfive-visionfive2() {
 	oe_runmake -C ${S}
 }
 
-do_install() {
+do_compile:starfive-jh8100() {
+	oe_runmake -C ${WORKDIR}/jh8100_cst
+}
+
+do_install:starfive-visionfive2() {
 	install -Dm 0755 ${S}/spl_tool ${D}/${bindir}/spl_tool
 }
 
+do_install:starfive-jh8100() {
+	cp -r  ${WORKDIR}/jh8100_cst ${DEPLOY_DIR_IMAGE}/jh8100_cst
+}
+
 BBCLASSEXTEND = "native"

BIN
recipes-bsp/u-boot/files/bootloader.bin.normal.out


BIN
recipes-bsp/u-boot/files/firmware_merak.bin.normal.out


BIN
recipes-bsp/u-boot/files/uboot.env


+ 20 - 3
recipes-bsp/u-boot/u-boot-starfive.bb

@@ -18,8 +18,8 @@ BRANCH:starfive-visionfive2 = "JH7110_VisionFive2_devel"
 SRCREV:starfive-visionfive2 = "b6e2b0e85c774a18ae668223a6e5f7d335895243"
 
 FORK:starfive-jh8100 = "starfive-tech"
-BRANCH:starfive-jh8100 = "jh8100_fpga_dev_v2023.01_bmc"
-SRCREV:starfive-jh8100 = "94b4b620567e8b87fe9002b5b623043830aff8a8"
+BRANCH:starfive-jh8100 = "jh8100_fpga_dev_v2023.01-bmc-30Nov"
+SRCREV:starfive-jh8100 = "c1a4c841e01fbcd3f6d5e894e726e9f50abc6938"
 
 SRC_URI:starfive-dubhe = "\
 	git://github.com/${FORK}/u-boot.git;protocol=https;branch=${BRANCH} \
@@ -40,11 +40,14 @@ SRC_URI:starfive-jh8100 = "\
 	git://git@192.168.110.45/${FORK}/u-boot.git;protocol=ssh;branch=${BRANCH} \
 	file://tftp-mmc-boot.txt \
 	file://run_qemu_virt.dtb \
+	file://bootloader.bin.normal.out \
+	file://firmware_merak.bin.normal.out \
+	file://uboot.env \
 	"
 
 DEPENDS:append:starfive-dubhe = " u-boot-tools-native bmap-tools-native opensbi"
 DEPENDS:append:starfive-visionfive2 = " u-boot-tools-native starfive-tool-native"
-DEPENDS:append:starfive-jh8100 = " u-boot-tools-native bmap-tools-native opensbi"
+DEPENDS:append:starfive-jh8100 = " u-boot-tools-native bmap-tools-native opensbi starfive-tool"
 
 # Overwrite this for your server
 TFTP_SERVER_IP ?= "127.0.0.1"
@@ -87,9 +90,23 @@ do_deploy:append:starfive-dubhe() {
 }
 
 do_deploy:append:starfive-jh8100() {
+    install -m 644 ${WORKDIR}/uboot.env ${DEPLOYDIR}/uboot.env
+    install -m 644 ${WORKDIR}/bootloader.bin.normal.out ${DEPLOYDIR}/bootloader.bin.normal.out
+    install -m 644 ${WORKDIR}/firmware_merak.bin.normal.out ${DEPLOYDIR}/firmware_merak.bin.normal.out
     install -m 644 ${WORKDIR}/build/u-boot.itb ${DEPLOYDIR}/u-boot.itb
     rm ${WORKDIR}/build/fw_dynamic.bin
     install -m 644 ${WORKDIR}/run_qemu_virt.dtb ${DEPLOYDIR}/run_qemu_virt.dtb
+
+    ${DEPLOY_DIR_IMAGE}/jh8100_cst/mkbif ${DEPLOYDIR}/${SPL_BINARYNAME}
+
+    dd if=${WORKDIR}/bootloader.bin.normal.out of=${DEPLOY_DIR_IMAGE}/scp_raw.img count=1 bs=512k conv=sync
+    dd if=${WORKDIR}/bootloader.bin.normal.out of=${DEPLOY_DIR_IMAGE}/scp_raw.img seek=1 count=1 bs=512k conv=sync
+
+    dd if=${WORKDIR}/firmware_merak.bin.normal.out of=${DEPLOY_DIR_IMAGE}/scp_raw.img seek=2 count=1 bs=512k conv=sync
+    dd if=${WORKDIR}/firmware_merak.bin.normal.out of=${DEPLOY_DIR_IMAGE}/scp_raw.img seek=3 count=1 bs=512k conv=sync
+
+    dd if=${DEPLOYDIR}/${SPL_BINARYNAME}.normal.out of=${DEPLOY_DIR_IMAGE}/scp_raw.img seek=4 count=1 bs=512k conv=sync
+    dd if=${DEPLOYDIR}/${SPL_BINARYNAME}.normal.out of=${DEPLOY_DIR_IMAGE}/scp_raw.img seek=5 count=1 bs=512k conv=sync
 }
 
 TOOLCHAIN = "gcc"

+ 1 - 0
recipes-core/images/core-image-minimal.bbappend

@@ -10,6 +10,7 @@ IMAGE_INSTALL += " \
 	systemd-analyze \
 	e2fsprogs-resize2fs \
 	parted \
+	i3c-tools \
         "
 
 TOOLCHAIN_TARGET_TASK += "packagegroup-starfive-toolchain"

+ 1 - 0
recipes-core/images/core-image-starfive-extra.bb

@@ -21,6 +21,7 @@ IMAGE_INSTALL = "\
 	packagegroup-starfive-essentials \
 	nodejs \
 	nodejs-npm \
+	i3c-tools \
 	"
 
 TOOLCHAIN_TARGET_TASK += "packagegroup-starfive-toolchain"

+ 0 - 2
recipes-devtools/openocd/openocd_riscv.bbappend

@@ -1,5 +1,3 @@
-require recipes-devtools/openocd/openocd_git.bb
-
 #FILESEXTRAPATHS:prepend := "${THISDIR}/openocd:"
 
 LIC_FILES_CHKSUM = "file://COPYING;md5=599d2d1ee7fc84c0467b3d19801db870"

+ 2 - 2
recipes-kernel/linux/linux-starfive-dev_6.1.20.bb

@@ -13,8 +13,8 @@ BRANCH:starfive-dubhe = "starfive-6.1-dubhe"
 SRCREV:starfive-dubhe = "c888e193d4662be1943b79172f0f5780dab87b72"
 
 FORK:starfive-jh8100 = "starfive-tech"
-BRANCH:starfive-jh8100 = "starfive-6.1-dev-jh8100-bmc"
-SRCREV:starfive-jh8100 ="602adfee5440add362c13535b9f7d4d2647e2526"
+BRANCH:starfive-jh8100 = "starfive-6.1-dev-jh8100-bmc-30Nov"
+SRCREV:starfive-jh8100 = "d3c89a346ad56faa46713019ba82ade5ace25651"
 
 LINUX_VERSION ?= "6.1.20"
 LINUX_VERSION:starfive-dubhe = "6.1.20"

+ 212 - 0
recipes-support/i3c-tools/files/i3c-tools/i3ctransfer.c

@@ -0,0 +1,212 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2019 Synopsys, Inc. and/or its affiliates.
+ *
+ * Author: Vitor Soares <vitor.soares@synopsys.com>
+ */
+
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <getopt.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+
+#include <i3cdev.h>
+
+const char *sopts = "d:r:w:vh";
+static const struct option lopts[] = {
+	{"device",		required_argument,	NULL,	'd' },
+	{"read",		required_argument,	NULL,	'r' },
+	{"write",		required_argument,	NULL,	'w' },
+	{"command",		required_argument,	NULL,	'c' },
+	{"help",		no_argument,		NULL,	'h' },
+	{"version",		no_argument,		NULL,	'v' },
+	{0, 0, 0, 0}
+};
+
+static void print_usage(const char *name)
+{
+	fprintf(stderr, "usage: %s options...\n", name);
+	fprintf(stderr, "  options:\n");
+	fprintf(stderr, "    -d --device       <dev>          device to use.\n");
+	fprintf(stderr, "    -r --read         <data length>  read data.\n");
+	fprintf(stderr, "    -w --write        <data block>   Write data block.\n");
+	fprintf(stderr, "    -h --help                        Output usage message and exit.\n");
+	fprintf(stderr, "    -v --version                     Output the version number and exit\n");
+}
+
+static int rx_args_to_xfer(struct i3c_priv_xfer *xfer, char *arg)
+{
+	int len = strtol(optarg, NULL, 0);
+	uint8_t *tmp;
+
+	tmp = (uint8_t *)calloc(len, sizeof(uint8_t));
+	if (!tmp)
+		return -1;
+
+	xfer->rnw = 1;
+	xfer->len = len;
+	xfer->data.in = (void *)tmp;
+
+	return 0;
+}
+
+static int w_args_to_xfer(struct i3c_priv_xfer *xfer, char *arg)
+{
+	char *data_ptrs[256];
+	int len, i = 0;
+	uint8_t *tmp;
+
+	data_ptrs[i] = strtok(arg, ",");
+
+	while (data_ptrs[i] && i < 255)
+		data_ptrs[++i] = strtok(NULL, ",");
+
+	tmp = (uint8_t *)calloc(i, sizeof(uint8_t));
+	if (!tmp)
+		return -1;
+
+	for (len = 0; len < i; len++)
+		tmp[len] = (uint8_t)strtol(data_ptrs[len], NULL, 0);
+
+	xfer->len = len;
+	xfer->data.in = (void *)tmp;
+
+	return 0;
+}
+
+static void print_rx_data(struct i3c_priv_xfer *xfer)
+{
+	uint8_t *tmp;
+	int i;
+
+	tmp = (uint8_t *)calloc(xfer->len, sizeof(uint8_t));
+	if (!tmp)
+		return;
+
+	memcpy(tmp, (void *)(uintptr_t)xfer->data.out, xfer->len * sizeof(uint8_t));
+
+	for (i = 0; i < xfer->len; i++) {
+		fprintf(stdout, "  0x%02x", tmp[i]);
+		if ((i + 1) % 8 == 0 && (i + 1) < xfer->len)
+			fprintf(stdout, "\n");
+	}
+	fprintf(stdout, "\n");
+
+	free(tmp);
+}
+
+int main(int argc, char *argv[])
+{
+	struct i3c_ioc_priv_xfer *xfers;
+	int file, ret, opt, i;
+	int nxfers = 0;
+	char *device = NULL;
+
+	if (argc < 2) {
+		print_usage(argv[0]);
+		exit(EXIT_SUCCESS);
+	}
+
+	while ((opt = getopt_long(argc, argv,  sopts, lopts, NULL)) != EOF) {
+		switch (opt) {
+		case 'h':
+			print_usage(argv[0]);
+			exit(EXIT_SUCCESS);
+		case 'v':
+			fprintf(stderr, "%s - %s\n", argv[0], VERSION);
+			exit(EXIT_SUCCESS);
+		case 'd':
+			device = optarg;
+			break;
+		case 'r':
+		case 'w':
+			nxfers++;
+			break;
+		default:
+			print_usage(argv[0]);
+			exit(EXIT_FAILURE);
+		}
+	}
+
+
+
+	if (device == NULL) {
+		fprintf(stderr, "No device selected\n");
+		exit(EXIT_FAILURE);
+	}
+
+	file = open(device, O_RDWR);
+	if (file < 0)
+		exit(EXIT_FAILURE);
+
+	xfers = (struct i3c_ioc_priv_xfer *)calloc(nxfers, sizeof(*xfers));
+	if (!xfers)
+		exit(EXIT_FAILURE);
+
+	xfers->xfers = (struct i3c_priv_xfer *)calloc(I3C_IOC_PRIV_XFER_MAX_MSGS,
+			sizeof(struct i3c_priv_xfer));
+	if (!xfers->xfers)
+		goto err_free_xfer;
+
+	optind = 1;
+	nxfers = 0;
+
+	while ((opt = getopt_long(argc, argv, sopts, lopts, NULL)) != EOF) {
+		switch (opt) {
+		case 'h':
+		case 'v':
+		case 'd':
+			break;
+		case 'r':
+			if (rx_args_to_xfer(&xfers->xfers[nxfers], optarg)) {
+				ret = EXIT_FAILURE;
+				goto err_free_xfer_xfer;
+			}
+
+			nxfers++;
+			break;
+		case 'w':
+			if (w_args_to_xfer(&xfers->xfers[nxfers], optarg)) {
+				ret = EXIT_FAILURE;
+				goto err_free_xfer_xfer;
+			}
+
+			nxfers++;
+			break;
+		}
+	}
+
+	xfers->nxfers = nxfers;
+
+	if (ioctl(file, I3C_IOC_PRIV_XFER, xfers) < 0) {
+		fprintf(stderr, "Error: transfer failed: %s\n", strerror(errno));
+		ret = EXIT_FAILURE;
+		goto err_free_xfer_xfer;
+	}
+
+	for (i = 0; i < nxfers; i++) {
+		if (xfers->xfers[i].rnw) {
+			fprintf(stdout, "Receive message for transaction %d\n", i+1);
+			print_rx_data(&xfers->xfers[i]);
+		}
+	}
+
+	ret = EXIT_SUCCESS;
+
+err_free_xfer_xfer:
+	for (i = 0; i < nxfers; i++)
+		free(xfers->xfers[i].data.in);
+
+	free(xfers->xfers);
+
+err_free_xfer:
+	free(xfers);
+
+	return ret;
+}

+ 66 - 0
recipes-support/i3c-tools/files/i3c-tools/include/i3c/device.h

@@ -0,0 +1,66 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2019 Synopsys, Inc. and/or its affiliates.
+ *
+ * Author: Vitor Soares <vitor.soares@synopsys.com>
+ */
+
+#ifndef _UAPI_LINUX_I3C_DEVICE_H
+#define _UAPI_LINUX_I3C_DEVICE_H
+
+#include <linux/types.h>
+
+/**
+ * enum i3c_error_code - I3C error codes
+ *
+ * These are the standard error codes as defined by the I3C specification.
+ * When -EIO is returned by the i3c_device_do_priv_xfers() or
+ * i3c_device_send_hdr_cmds() one can check the error code in
+ * &struct_i3c_priv_xfer.err or &struct i3c_hdr_cmd.err to get a better idea of
+ * what went wrong.
+ *
+ * @I3C_ERROR_UNKNOWN: unknown error, usually means the error is not I3C
+ *		       related
+ * @I3C_ERROR_M0: M0 error
+ * @I3C_ERROR_M1: M1 error
+ * @I3C_ERROR_M2: M2 error
+ */
+enum i3c_error_code {
+	I3C_ERROR_UNKNOWN = 0,
+	I3C_ERROR_M0 = 1,
+	I3C_ERROR_M1,
+	I3C_ERROR_M2,
+};
+
+/**
+ * enum i3c_hdr_mode - HDR mode ids
+ * @I3C_HDR_DDR: DDR mode
+ * @I3C_HDR_TSP: TSP mode
+ * @I3C_HDR_TSL: TSL mode
+ */
+enum i3c_hdr_mode {
+	I3C_HDR_DDR,
+	I3C_HDR_TSP,
+	I3C_HDR_TSL,
+};
+
+/**
+ * struct i3c_priv_xfer - I3C SDR private transfer
+ * @rnw: encodes the transfer direction. true for a read, false for a write
+ * @len: transfer length in bytes of the transfer
+ * @data: input/output buffer
+ * @data.in: input buffer. Must point to a DMA-able buffer
+ * @data.out: output buffer. Must point to a DMA-able buffer
+ * @err: I3C error code
+ */
+struct i3c_priv_xfer {
+	__u8 rnw;
+	__u16 len;
+	union {
+		void *in;
+		const void *out;
+	} data;
+	enum i3c_error_code err;
+};
+
+#endif /* _UAPI_LINUX_I3C_DEVICE_H */

+ 46 - 0
recipes-support/i3c-tools/files/i3c-tools/include/i3c/i3cdev.h

@@ -0,0 +1,46 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2019 Synopsys, Inc. and/or its affiliates.
+ *
+ * Author: Vitor Soares <vitor.soares@synopsys.com>
+ */
+
+#ifndef _UAPI_I3C_DEV_H_
+#define _UAPI_I3C_DEV_H_
+
+#include <linux/types.h>
+#include <linux/ioctl.h>
+
+#define VERSION "0.2"
+
+/* IOCTL commands */
+#define I3C_DEV_IOC_MAGIC	0x07
+
+enum i3c_error_code {
+	I3C_ERROR_UNKNOWN = 0,
+	I3C_ERROR_M0 = 1,
+	I3C_ERROR_M1,
+	I3C_ERROR_M2,
+};
+
+struct i3c_priv_xfer {
+	char rnw;
+	uint16_t len;
+	union {
+		void *in;
+		const void *out;
+	} data;
+	enum i3c_error_code err;
+};
+
+struct i3c_ioc_priv_xfer {
+	struct i3c_priv_xfer *xfers;	/* pointers to i3c_priv_xfer */
+	__u32 nxfers;				/* number of i3c_priv_xfer */
+};
+
+#define I3C_IOC_PRIV_XFER	\
+	_IOWR(I3C_DEV_IOC_MAGIC, 30, struct i3c_ioc_priv_xfer)
+
+#define  I3C_IOC_PRIV_XFER_MAX_MSGS	42
+
+#endif

+ 19 - 0
recipes-support/i3c-tools/i3c-tools_0.1.bb

@@ -0,0 +1,19 @@
+DESCRIPTION = "Set of i3c tools"
+LICENSE = "CLOSED"
+LIC_FILES_CHKSUM = ""
+
+FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
+
+SRC_URI = "file://i3c-tools \
+	"
+
+S = "${WORKDIR}"
+
+do_compile(){
+	${CC} ${LDFLAGS} -I ${WORKDIR}/i3c-tools/include/i3c ${WORKDIR}/i3c-tools/i3ctransfer.c -o i3ctransfer
+}
+
+do_install(){
+	install -d ${D}${bindir}
+	install -m 0755 i3ctransfer ${D}${bindir}
+}

+ 3 - 1
wic/starfive-jh8100.wks

@@ -1,10 +1,12 @@
 #short-description: Create SD card image for Starfive Duhbe
 # long-description: Creates a partitioned SD card image for Starfive Dubhe.
 
+part spl --source rawcopy  --sourceparams="file=scp_raw.img" --part-name spl --offset 2M --size 5M --part-type 2E54B353-1271-4842-806F-E436D6AF6985
+
 #boot partition
 part /boot --source bootimg-partition --ondisk mmcblk0 --fstype=vfat --label boot --active --align 1024 --size=200M --use-uuid
 
 #root partition
 part / --source rootfs --ondisk mmcblk0 --fstype=ext4 --label root --align 1024 --size=2G --use-uuid
 
-bootloader --append "rootwait console=ttyS0,115200"
+bootloader --append "rootwait console=ttyS0,115200" --ptable gpt