Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
========

Expand Down
2 changes: 1 addition & 1 deletion arch/rh850/src/common/rh850_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
41 changes: 34 additions & 7 deletions arch/rh850/src/u2c/u2c_lowputc.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include <nuttx/config.h>

#include <errno.h>
#include <stdint.h>

#include <nuttx/arch.h>
Expand All @@ -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
****************************************************************************/
Expand All @@ -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);
Expand All @@ -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;
}

/****************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion arch/rh850/src/u2c/u2c_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions boards/rh850/u2c/qemu-rh850-u2c/configs/citest/config.yaml
Original file line number Diff line number Diff line change
@@ -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'
39 changes: 39 additions & 0 deletions boards/rh850/u2c/qemu-rh850-u2c/configs/citest/defconfig
Original file line number Diff line number Diff line change
@@ -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
74 changes: 74 additions & 0 deletions boards/rh850/u2c/qemu-rh850-u2c/configs/citest/run.sh
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions boards/rh850/u2c/qemu-rh850-u2c/configs/citest/session.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"module": {
"include_module": [],
"exclude_module": [],
"order": []
},
"args": {
"kv": []
}
}
14 changes: 12 additions & 2 deletions boards/rh850/u2c/qemu-rh850-u2c/src/qemu_rh850_u2c_boardinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 0 additions & 5 deletions tools/ci/testlist/other.dat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions tools/ci/testlist/rh850-01.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/rh850

# rh850 Boards build by CMake
CMake,qemu-rh850-u2c:nsh
CMake,qemu-rh850-u2c:citest
Loading