diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9c9f9058bfc99..a451e6ec29a0c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -319,7 +319,7 @@ jobs: os: Linux boards: | [ - "arm-imx", "risc-v-01", "sim-01", "xtensa-01", "arm64-01", "x86_64-01", "tricore-01", "other", + "arm-imx", "risc-v-01", "sim-01", "xtensa-01", "arm64-01", "x86_64-01", "tricore-01", "rh850-01", "other", "arm-nrf", "risc-v-02", "sim-02", "xtensa-02", "arm-nxp", "risc-v-03", "sim-03", "xtensa-03", "arm-rp2xxx", "risc-v-04", diff --git a/Documentation/platforms/rh850/u2c/boards/qemu-rh850-u2c/index.rst b/Documentation/platforms/rh850/u2c/boards/qemu-rh850-u2c/index.rst index 6d915e281c6fc..1058a01cd04c9 100644 --- a/Documentation/platforms/rh850/u2c/boards/qemu-rh850-u2c/index.rst +++ b/Documentation/platforms/rh850/u2c/boards/qemu-rh850-u2c/index.rst @@ -49,6 +49,14 @@ nsh NuttShell on the RLIN311 console, ticked system timer. +citest +------ + +The ``nsh`` configuration with ``ostest``, a tmpfs at ``/tmp`` and the high +priority work queue, for the NTFC tests in CI. ``run.sh`` runs NTFC with +``config.yaml`` and ``session.json`` from this directory and fails when +``test_os`` did not pass, so a run where every test is skipped cannot pass. + Building ======== diff --git a/arch/rh850/src/common/rh850_internal.h b/arch/rh850/src/common/rh850_internal.h index cec185153b4d4..2d39dd115d6f0 100644 --- a/arch/rh850/src/common/rh850_internal.h +++ b/arch/rh850/src/common/rh850_internal.h @@ -100,7 +100,7 @@ void rh850_clockconfig(void); void rh850_lowsetup(void); void rh850_lowputc(int ch); void rh850_serialinit(void); -void u2c_rlin3_setup(uintptr_t base, uint32_t baud); +int u2c_rlin3_setup(uintptr_t base, uint32_t baud); void u2c_rlin3_putc(uintptr_t base, int ch); bool u2c_irq_pending(int irq); void u2c_irq_raise(int irq); diff --git a/arch/rh850/src/u2c/u2c_lowputc.c b/arch/rh850/src/u2c/u2c_lowputc.c index d1ca7f4ae4142..e9e2488095d64 100644 --- a/arch/rh850/src/u2c/u2c_lowputc.c +++ b/arch/rh850/src/u2c/u2c_lowputc.c @@ -26,6 +26,7 @@ #include +#include #include #include @@ -43,6 +44,28 @@ # define CONSOLE_BAUD CONFIG_UART0_BAUD #endif +/* LBRP01 = round(clock / (16 x baud)) - 1 with LWBR = 0. A rate whose + * divider is out of range, or that is more than RLIN3_BAUD_TOL percent off, + * is rejected. + */ + +#define RLIN3_CLK CONFIG_RH850_CLK_HSB_FREQUENCY +#define RLIN3_BAUD_TOL 3 +#define RLIN3_DIV(b) ((RLIN3_CLK + RLIN3_SAMPLES * (b) / 2) / \ + (RLIN3_SAMPLES * (b))) +#define RLIN3_REAL(b) (RLIN3_SAMPLES * (b) * RLIN3_DIV(b)) +#define RLIN3_DIFF(b) (RLIN3_REAL(b) > RLIN3_CLK ? \ + RLIN3_REAL(b) - RLIN3_CLK : \ + RLIN3_CLK - RLIN3_REAL(b)) +#define RLIN3_BAUD_OK(b) \ + ((b) > 0 && RLIN3_SAMPLES * (b) <= RLIN3_CLK && \ + RLIN3_DIV(b) <= 0x10000 && \ + RLIN3_DIFF(b) * 100 <= RLIN3_REAL(b) * RLIN3_BAUD_TOL) + +#if defined(CONSOLE_BAUD) && !RLIN3_BAUD_OK(CONSOLE_BAUD) +# error CONFIG_UART0_BAUD does not fit CONFIG_RH850_CLK_HSB_FREQUENCY +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -52,24 +75,27 @@ * * Description: * RLIN3 UART mode, 8N1, LSB first, no error detection. The unit clock - * and module stop are set up by rh850_clockconfig(). + * and module stop are set up by rh850_clockconfig(). Returns -EINVAL + * for a rate that RLIN3_BAUD_OK() rejects. * ****************************************************************************/ -void u2c_rlin3_setup(uintptr_t base, uint32_t baud) +int u2c_rlin3_setup(uintptr_t base, uint32_t baud) { - uint32_t samples = RLIN3_SAMPLES * baud; + uint64_t b = baud; + + if (!RLIN3_BAUD_OK(b)) + { + return -EINVAL; + } putreg8(0, base + RLIN3_LCUC_OFFSET); while ((getreg8(base + RLIN3_LMST_OFFSET) & RLIN3_LMST_OMM0) != 0) { } - /* LBRP01 = round(clock / (16 x baud)) - 1 */ - putreg8(0, base + RLIN3_LWBR_OFFSET); - putreg16((CONFIG_RH850_CLK_HSB_FREQUENCY + samples / 2) / samples - 1, - base + RLIN3_LBRP01_OFFSET); + putreg16((uint16_t)(RLIN3_DIV(b) - 1), base + RLIN3_LBRP01_OFFSET); putreg8(RLIN3_LMD_UART, base + RLIN3_LMD_OFFSET); putreg8(0, base + RLIN3_LBFC_OFFSET); putreg8(0, base + RLIN3_LEDE_OFFSET); @@ -81,6 +107,7 @@ void u2c_rlin3_setup(uintptr_t base, uint32_t baud) } putreg8(RLIN3_LUOER_UTOE | RLIN3_LUOER_UROE, base + RLIN3_LUOER_OFFSET); + return OK; } /**************************************************************************** diff --git a/arch/rh850/src/u2c/u2c_serial.c b/arch/rh850/src/u2c/u2c_serial.c index 5b62cb1d1c302..e5c2de5c49d27 100644 --- a/arch/rh850/src/u2c/u2c_serial.c +++ b/arch/rh850/src/u2c/u2c_serial.c @@ -148,7 +148,7 @@ static int u2c_setup(FAR struct uart_dev_s *dev) if (!dev->isconsole) { - u2c_rlin3_setup(priv->base, priv->baud); + return u2c_rlin3_setup(priv->base, priv->baud); } return OK; diff --git a/boards/rh850/u2c/qemu-rh850-u2c/configs/citest/config.yaml b/boards/rh850/u2c/qemu-rh850-u2c/configs/citest/config.yaml new file mode 100644 index 0000000000000..733cdf430173d --- /dev/null +++ b/boards/rh850/u2c/qemu-rh850-u2c/configs/citest/config.yaml @@ -0,0 +1,14 @@ +config: + cwd: './' + +product: + name: "qemu-rh850-u2c" + cores: + core0: + name: 'main' + device: 'qemu' + line_buffered: true + exec_path: 'qemu-system-rh850' + exec_args: '-M rh850-u2c,test-exit=on -icount shift=4,sleep=on -nographic' + conf_path: './build/.config' + elf_path: './build/nuttx' diff --git a/boards/rh850/u2c/qemu-rh850-u2c/configs/citest/defconfig b/boards/rh850/u2c/qemu-rh850-u2c/configs/citest/defconfig new file mode 100644 index 0000000000000..6648ac80e435a --- /dev/null +++ b/boards/rh850/u2c/qemu-rh850-u2c/configs/citest/defconfig @@ -0,0 +1,39 @@ +# +# This file is autogenerated: PLEASE DO NOT EDIT IT. +# +# You can use "make menuconfig" to make any modifications to the installed .config file. +# You can then do "make savedefconfig" to generate a new defconfig file that includes your +# modifications. +# +CONFIG_ARCH="rh850" +CONFIG_ARCH_BOARD="qemu-rh850-u2c" +CONFIG_ARCH_BOARD_QEMU_RH850_U2C=y +CONFIG_ARCH_CHIP="u2c" +CONFIG_ARCH_CHIP_R7F702600=y +CONFIG_ARCH_CHIP_U2C=y +CONFIG_ARCH_INTERRUPTSTACK=2048 +CONFIG_ARCH_RH850=y +CONFIG_BOARDCTL_RESET=y +CONFIG_BOARD_LOOPSPERMSEC=8906 +CONFIG_BUILTIN=y +CONFIG_DEBUG_FULLOPT=y +CONFIG_DEBUG_SYMBOLS=y +CONFIG_FS_PROCFS=y +CONFIG_FS_TMPFS=y +CONFIG_IDLETHREAD_STACKSIZE=2048 +CONFIG_INIT_ENTRYPOINT="nsh_main" +CONFIG_INIT_STACKSIZE=3072 +CONFIG_LIBC_MEMFD_ERROR=y +CONFIG_LIBM=y +CONFIG_LINE_MAX=256 +CONFIG_NSH_BUILTIN_APPS=y +CONFIG_NSH_READLINE=y +CONFIG_RAM_SIZE=131072 +CONFIG_RAM_START=0xfdc00000 +CONFIG_SCHED_HPWORK=y +CONFIG_SCHED_WAITPID=y +CONFIG_STACK_COLORATION=y +CONFIG_SYSTEM_NSH=y +CONFIG_SYSTEM_SETLOGMASK=y +CONFIG_TESTING_OSTEST=y +CONFIG_UART0_SERIAL_CONSOLE=y diff --git a/boards/rh850/u2c/qemu-rh850-u2c/configs/citest/run.sh b/boards/rh850/u2c/qemu-rh850-u2c/configs/citest/run.sh new file mode 100755 index 0000000000000..d80251ba61620 --- /dev/null +++ b/boards/rh850/u2c/qemu-rh850-u2c/configs/citest/run.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash +############################################################################ +# boards/rh850/u2c/qemu-rh850-u2c/configs/citest/run.sh +# +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. The +# ASF licenses this file to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the +# License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +############################################################################ + +set -o xtrace + +# start from nuttx dir +olddir=$(pwd) +nuttdir=${CURRENTCONFDIR}/../../../../../../ +cd ${nuttdir} + +# run NTFC +confpath=${CURRENTCONFDIR}/config.yaml +jsonconf=${CURRENTCONFDIR}/session.json +testpath=${NTFCDIR}/external/nuttx-testing +ntfc test --testpath=${testpath} --confpath=${confpath} --jsonconf=${jsonconf} + +ret="$?" +echo $ret + +# a run where every test is skipped also exits 0, so require test_os in +# the report of this session, the newest one under result/ + +if [ "$ret" -eq 0 ] && ! python3 - <<'EOF' +import glob +import os +import sys +import xml.etree.ElementTree as ET + +sessions = sorted(glob.glob("result/*/"), key=os.path.getmtime) +if not sessions: + sys.exit(1) + +last = sessions[-1] +for f in glob.glob(last + "report.xml") + glob.glob(last + "report/*.xml"): + for case in ET.parse(f).getroot().iter("testcase"): + bad = [c for c in case if c.tag in ("skipped", "failure", "error")] + if case.get("name", "").startswith("test_os") and not bad: + sys.exit(0) +sys.exit(1) +EOF +then + echo "test_os did not pass" + ret=1 +fi + +# export test results +artifacts=${ARTIFACTCONFDIR}/ntfc +mkdir -p ${artifacts} +mv result ${artifacts} + +# restore old dir +cd ${olddir} + +exit $ret diff --git a/boards/rh850/u2c/qemu-rh850-u2c/configs/citest/session.json b/boards/rh850/u2c/qemu-rh850-u2c/configs/citest/session.json new file mode 100644 index 0000000000000..3e71e22cf49c0 --- /dev/null +++ b/boards/rh850/u2c/qemu-rh850-u2c/configs/citest/session.json @@ -0,0 +1,10 @@ +{ + "module": { + "include_module": [], + "exclude_module": [], + "order": [] + }, + "args": { + "kv": [] + } +} diff --git a/boards/rh850/u2c/qemu-rh850-u2c/src/qemu_rh850_u2c_boardinit.c b/boards/rh850/u2c/qemu-rh850-u2c/src/qemu_rh850_u2c_boardinit.c index 4efe785d9fd78..0e867e2e0c63a 100644 --- a/boards/rh850/u2c/qemu-rh850-u2c/src/qemu_rh850_u2c_boardinit.c +++ b/boards/rh850/u2c/qemu-rh850-u2c/src/qemu_rh850_u2c_boardinit.c @@ -74,22 +74,32 @@ static void qemu_test_exit(int status, uint32_t zero) * Name: board_late_initialize * * Description: - * Board initialization after the OS is up: mount procfs. + * Board initialization after the OS is up: mount procfs and tmpfs. * ****************************************************************************/ #ifdef CONFIG_BOARD_LATE_INITIALIZE void board_late_initialize(void) { -#ifdef CONFIG_FS_PROCFS +#if defined(CONFIG_FS_PROCFS) || defined(CONFIG_FS_TMPFS) int ret; +#endif +#ifdef CONFIG_FS_PROCFS ret = nx_mount(NULL, "/proc", "procfs", 0, NULL); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to mount procfs: %d\n", ret); } #endif + +#ifdef CONFIG_FS_TMPFS + ret = nx_mount(NULL, CONFIG_LIBC_TMPDIR, "tmpfs", 0, NULL); + if (ret < 0) + { + syslog(LOG_ERR, "ERROR: Failed to mount tmpfs: %d\n", ret); + } +#endif } #endif diff --git a/tools/ci/testlist/other.dat b/tools/ci/testlist/other.dat index cd0aeac212f63..bb6d3d4838674 100644 --- a/tools/ci/testlist/other.dat +++ b/tools/ci/testlist/other.dat @@ -9,11 +9,6 @@ /renesas/rx65n/rx65n-grrose /renesas/rx65n/rx65n-rsk2mb -/rh850 - -# rh850 Boards build by CMake -CMake,qemu-rh850-u2c:nsh - /x86 # Sparc-gaisler-elf toolchain doesn't provide macOS binaries diff --git a/tools/ci/testlist/rh850-01.dat b/tools/ci/testlist/rh850-01.dat new file mode 100644 index 0000000000000..3bfac59db95e0 --- /dev/null +++ b/tools/ci/testlist/rh850-01.dat @@ -0,0 +1,5 @@ +/rh850 + +# rh850 Boards build by CMake +CMake,qemu-rh850-u2c:nsh +CMake,qemu-rh850-u2c:citest