From 3d91ea1db49c42e7024513e8113a0a193fec06a8 Mon Sep 17 00:00:00 2001 From: Trevor Woerner Date: Mon, 30 Oct 2023 09:57:53 -0400 Subject: [PATCH] rock-pi-s: add ROCK Pi S is a Rockchip RK3308 based SBC from Radxa. It contains a 64-bit quad core processor, USB, ethernet, wireless connectivity, and voice detection engine in 1.7-inches square. The ROCK Pi S comes in two RAM sizes 256MB or 512MB DDR3, and uses an sdmmc card for OS and storage. Optionally, some versions of the ROCK Pi S provide on-board storage via 1Gb/2Gb/4Gb/8Gb of SLC NAND flash. "S" stands for "small square" since the total board size of the rock-pi-s is 1.7-inches square. This BSP assumes booting from sdmmc, and using ttyS0 for the serial console (similar to Raspberry Pi). The latest version of the binary ddr initializer code from rkbin does not provide a uart0 option, therefore all diagnostic output from rkbin and u-boot is lost on the console (and replaced with a stream of gibberish until the Linux kernel starts). Therefore, by default, the build assumes the user would prefer to see this information and have the option to interact with U-Boot, which means an older version of rkbin is used. The user can override this decision by setting: RKBIN_RK3308_LATEST = "1" Signed-off-by: Trevor Woerner --- README | 22 +++++++++++ conf/machine/include/rk3308.inc | 18 +++++++++ conf/machine/rock-pi-s.conf | 11 ++++++ recipes-bsp/rkbin/rk3308-rkbin_git.bb | 41 +++++++++++++++++++++ recipes-bsp/rkbin/rockchip-rkbin_git.bb | 10 +++++ recipes-bsp/u-boot/u-boot%.bbappend | 8 ++++ recipes-kernel/linux/linux-yocto_%.bbappend | 1 + 7 files changed, 111 insertions(+) create mode 100644 conf/machine/include/rk3308.inc create mode 100644 conf/machine/rock-pi-s.conf create mode 100644 recipes-bsp/rkbin/rk3308-rkbin_git.bb diff --git a/README b/README index bcf1e0b..e5beaa0 100644 --- a/README +++ b/README @@ -33,11 +33,33 @@ Status of supported boards: rock-5b nanopi-r2s nanopi-m4b + rock-pi-s builds: marsboard-rk3066 radxarock rock2-square +Notes: +----- + The latest ddr initializer for the rk3308 platform (currently only + used by the rock-pi-s machine) does not output diagnostic messages + to uart0. This causes a bunch of gibberish to be printed to the + console window which only becomes legible once the linux kernel + starts. I.e. the console output of the ddr initialization routine, + as well as u-boot is lost. An older version of this same binary + blob does, however, support output to uart0 (making its diagnostic + messages as well as u-boot available on the console). By default + the build assumes the user would like to see these message and be + able to have the option to interact with u-boot. Iow: for the + rock-pi-s an older version of rkbin is used. + + If, however, the user would prefer to use the latest binary ddr + initializer from rkbin, simply set: + + RKBIN_RK3308_LATEST = "1" + + in the configuration (e.g. conf/local.conf). + Maintenance: ----------- Please send pull requests, patches, comments, or questions to the diff --git a/conf/machine/include/rk3308.inc b/conf/machine/include/rk3308.inc new file mode 100644 index 0000000..19cabaf --- /dev/null +++ b/conf/machine/include/rk3308.inc @@ -0,0 +1,18 @@ +SOC_FAMILY = "rk3308" + +DEFAULTTUNE ?= "cortexa35-crypto" + +require conf/machine/include/soc-family.inc +require conf/machine/include/arm/armv8a/tune-cortexa35.inc +require conf/machine/include/rockchip-defaults.inc +require conf/machine/include/rockchip-wic.inc + +SERIAL_CONSOLES = "1500000;ttyS0" + +KBUILD_DEFCONFIG ?= "defconfig" +KERNEL_FEATURES:append:rk3308 = " bsp/rockchip/remove-non-rockchip-arch-arm64.scc" +KERNEL_CLASSES = "kernel-fitimage" +KERNEL_IMAGETYPE = "fitImage" + +UBOOT_SUFFIX ?= "itb" +UBOOT_ENTRYPOINT ?= "0x06000000" diff --git a/conf/machine/rock-pi-s.conf b/conf/machine/rock-pi-s.conf new file mode 100644 index 0000000..79ea73c --- /dev/null +++ b/conf/machine/rock-pi-s.conf @@ -0,0 +1,11 @@ +#@TYPE: Machine +#@NAME: Radxa Rock Pi S +#@DESCRIPTION: ROCK Pi S is a Rockchip RK3308 based SBC by Radxa. "S" stands for "small square" +#https://wiki.radxa.com/RockpiS + +require conf/machine/include/rk3308.inc + +KERNEL_DEVICETREE = "rockchip/rk3308-rock-pi-s.dtb" +MACHINE_EXTRA_RRECOMMENDS += "kernel-modules" + +UBOOT_MACHINE = "rock-pi-s-rk3308_defconfig" diff --git a/recipes-bsp/rkbin/rk3308-rkbin_git.bb b/recipes-bsp/rkbin/rk3308-rkbin_git.bb new file mode 100644 index 0000000..c6b05b2 --- /dev/null +++ b/recipes-bsp/rkbin/rk3308-rkbin_git.bb @@ -0,0 +1,41 @@ +DESCRIPTION = "Rockchip Firmware and Tool Binaries" +LICENSE = "CLOSED" +LIC_FILES_CHKSUM:rk3308 = "file://README;md5=39cc9df955478b8df26158d489fdcc95" + +SRC_URI = "git://github.com/rockchip-linux/rkbin;protocol=https;branch=master" +SRCREV = "e65b97b511f1349156702db40694454c141d8fe2" + +PROVIDES += "trusted-firmware-a" +PROVIDES += "optee-os" + +inherit bin_package deploy + +S = "${WORKDIR}/git" + +COMPATIBLE_MACHINE = "^$" +COMPATIBLE_MACHINE:rk3308 = "rk3308" + +PACKAGE_ARCH = "${MACHINE_ARCH}" + +do_install() { + # Nothing in this recipe is useful in a filesystem + : +} + +PACKAGES = "${PN}" +ALLOW_EMPTY:${PN} = "1" + +do_deploy:rk3308() { + # Prebuilt TF-A + install -m 644 ${S}/bin/rk33/rk3308_bl31_v*.elf ${DEPLOYDIR}/bl31-rk3308.elf + # Prebuilt OPTEE-OS + install -m 644 ${S}/bin/rk33/rk3308_bl32_v*.bin ${DEPLOYDIR}/tee-rk3308.bin + # Prebuilt U-Boot TPL (DDR init) + install -m 644 ${S}/bin/rk33/rk3308_ddr_589MHz_uart0_m0_v*.bin ${DEPLOYDIR}/ddr-rk3308.bin +} + +do_deploy() { + bbfatal "COMPATIBLE_MACHINE requires a corresponding do_deploy:() override" +} + +addtask deploy after do_install diff --git a/recipes-bsp/rkbin/rockchip-rkbin_git.bb b/recipes-bsp/rkbin/rockchip-rkbin_git.bb index a3ab341..f1609c7 100644 --- a/recipes-bsp/rkbin/rockchip-rkbin_git.bb +++ b/recipes-bsp/rkbin/rockchip-rkbin_git.bb @@ -13,6 +13,7 @@ inherit bin_package deploy S = "${WORKDIR}/git" COMPATIBLE_MACHINE = "^$" +COMPATIBLE_MACHINE:rk3308 = "rk3308" COMPATIBLE_MACHINE:rk3588s = "rk3588s" PACKAGE_ARCH = "${MACHINE_ARCH}" @@ -25,6 +26,15 @@ do_install() { PACKAGES = "${PN}" ALLOW_EMPTY:${PN} = "1" +do_deploy:rk3308() { + # Prebuilt TF-A + install -m 644 ${S}/bin/rk33/rk3308_bl31_v*.elf ${DEPLOYDIR}/bl31-rk3308.elf + # Prebuilt OPTEE-OS + install -m 644 ${S}/bin/rk33/rk3308_bl32_v*.bin ${DEPLOYDIR}/tee-rk3308.bin + # Prebuilt U-Boot TPL (DDR init) + install -m 644 ${S}/bin/rk33/rk3308_ddr_589MHz_uart?_m0_v*.bin ${DEPLOYDIR}/ddr-rk3308.bin +} + do_deploy:rk3588s() { # Prebuilt TF-A install -m 644 ${S}/bin/rk35/rk3588_bl31_v*.elf ${DEPLOYDIR}/bl31-rk3588.elf diff --git a/recipes-bsp/u-boot/u-boot%.bbappend b/recipes-bsp/u-boot/u-boot%.bbappend index e79c471..d902c9a 100644 --- a/recipes-bsp/u-boot/u-boot%.bbappend +++ b/recipes-bsp/u-boot/u-boot%.bbappend @@ -1,8 +1,10 @@ # various machines require the pyelftools library for parsing dtb files DEPENDS:append = " python3-pyelftools-native" +DEPENDS:append:rock-pi-s = " u-boot-tools-native" DEPENDS:append:rock-pi-4 = " gnutls-native" EXTRA_OEMAKE:append:px30 = " BL31=${DEPLOY_DIR_IMAGE}/bl31-px30.elf" +EXTRA_OEMAKE:append:rk3308 = " BL31=${DEPLOY_DIR_IMAGE}/bl31-rk3308.elf" EXTRA_OEMAKE:append:rk3328 = " BL31=${DEPLOY_DIR_IMAGE}/bl31-rk3328.elf" EXTRA_OEMAKE:append:rk3399 = " BL31=${DEPLOY_DIR_IMAGE}/bl31-rk3399.elf" EXTRA_OEMAKE:append:rk3588s = " \ @@ -12,6 +14,7 @@ EXTRA_OEMAKE:append:rk3588s = " \ INIT_FIRMWARE_DEPENDS ??= "" INIT_FIRMWARE_DEPENDS:px30 = " trusted-firmware-a:do_deploy" +INIT_FIRMWARE_DEPENDS:rk3308 = " ${@bb.utils.contains('RKBIN_RK3308_LATEST', '1', 'rockchip-rkbin', 'rk3308-rkbin', d)}:do_deploy" INIT_FIRMWARE_DEPENDS:rk3328 = " trusted-firmware-a:do_deploy" INIT_FIRMWARE_DEPENDS:rk3399 = " trusted-firmware-a:do_deploy" INIT_FIRMWARE_DEPENDS:rk3588s = " rockchip-rkbin:do_deploy" @@ -23,3 +26,8 @@ do_compile:append:rock2-square () { cp ${B}/spl/${SPL_BINARY} ${B} fi } + +do_compile:append:rk3308() { + mkimage -n rk3308 -T rksd -d ${DEPLOY_DIR_IMAGE}/ddr-rk3308.bin ${B}/idbloader.img + cat ${B}/spl/u-boot-spl.bin >> ${B}/idbloader.img +} diff --git a/recipes-kernel/linux/linux-yocto_%.bbappend b/recipes-kernel/linux/linux-yocto_%.bbappend index 7da92db..7d8fb8b 100644 --- a/recipes-kernel/linux/linux-yocto_%.bbappend +++ b/recipes-kernel/linux/linux-yocto_%.bbappend @@ -15,6 +15,7 @@ COMPATIBLE_MACHINE:rock-pi-e = "rock-pi-e" COMPATIBLE_MACHINE:nanopi-r4s = "nanopi-r4s" COMPATIBLE_MACHINE:nanopi-r2s = "nanopi-r2s" COMPATIBLE_MACHINE:nanopi-m4b = "nanopi-m4b" +COMPATIBLE_MACHINE:rock-pi-s = "rock-pi-s" SRC_URI:append = " file://rockchip-kmeta;type=kmeta;name=rockchip-kmeta;destsuffix=rockchip-kmeta" SRC_URI:append:nanopi-r4s = " file://nanopi-r4s.scc"