Skip to content

riscv/bl602: Implement SPI Cmd/Data#5898

Merged
xiaoxiang781216 merged 1 commit intoapache:masterfrom
lupyuen:spi_cmddata_upstream
Mar 29, 2022
Merged

riscv/bl602: Implement SPI Cmd/Data#5898
xiaoxiang781216 merged 1 commit intoapache:masterfrom
lupyuen:spi_cmddata_upstream

Conversation

@lupyuen
Copy link
Copy Markdown
Member

@lupyuen lupyuen commented Mar 29, 2022

Summary

To control the Data/Command Pin on ST7789 SPI Display, the SPI Driver flips the MISO Pin as though it was a GPIO.

To implement this on BL602, we reconfigure MISO from SPI Pin to GPIO Pin on the fly inside bl602_spi_cmddata().

When the SPI Port is deselected (after the SPI operation), we revert MISO back from GPIO Pin to SPI Pin. We implement this inside bl602_spi_select().

More Details Here

Impact

This change impacts 3 LCD drivers that call SPI_CMDDATA(): ST7735, ST7789, GC9A01.

Previously the BL602 SPI Driver would fail with "SPI cmddata not supported" when the above drivers are used.

After the change, the above drivers will set the LCD Data/Command Pin correctly.

Testing

We tested this implementation of SPI Cmd/Data with NuttX ST7789 Driver and a Logic Analyser on PineCone BL602:

We also tested LVGL with ST7789 on PineCone BL602:

As for regular SPI Devices that don't require SPI Cmd/Data, we tested CONFIG_SPI_CMDDATA=y with Semtech SX1262 SPI Transceiver on PineCone BL602:

## Summary

To control the Data/Command Pin on ST7789 SPI Display, the SPI Driver flips the MISO Pin as though it was a GPIO.

To implement this on BL602, we reconfigure MISO from SPI Pin to GPIO Pin on the fly inside `bl602_spi_cmddata()`.

When the SPI Port is deselected (after the SPI operation), we revert MISO back from GPIO Pin to SPI Pin. We implement this inside `bl602_spi_select()`.

[More Details Here](https://github.com/lupyuen/st7789-nuttx#spi-cmddata)

## Impact

This change impacts 3 LCD drivers that call `SPI_CMDDATA()`: ST7735, ST7789, GC9A01.

Previously the BL602 SPI Driver would fail with "SPI cmddata not supported" when the above drivers are used.

After the change, the above drivers will set the LCD Data/Command Pin correctly.

## Testing

We tested this implementation of SPI Cmd/Data with NuttX ST7789 Driver and a Logic Analyser on PineCone BL602:

-   [Testing with Logic Analyser](https://github.com/lupyuen/st7789-nuttx#spi-cmddata)

We also tested LVGL with ST7789 on PineCone BL602:

-   [Testing with LVGL](https://github.com/lupyuen/st7789-nuttx#run-lvgl-demo)

As for regular SPI Devices that don't require SPI Cmd/Data, we tested `CONFIG_SPI_CMDDATA=y` with Semtech SX1262 SPI Transceiver on PineCone BL602:

-   [Testing Cmd/Data](https://github.com/lupyuen/incubator-nuttx/releases/tag/release-2022-03-29)
Comment thread arch/risc-v/src/bl602/bl602_spi.c
@xiaoxiang781216 xiaoxiang781216 merged commit 4f885fe into apache:master Mar 29, 2022
lupyuen added a commit to lupyuen/nuttx-bl602 that referenced this pull request Mar 29, 2022
## Summary

`bl602_spi_cmddata()` implements SPI Cmd/Data `SPI_CMDDATA()` for only 3 LCD drivers: ST7735, ST7789 and GC9A01.

This patch removes the check for LCD drivers, so that SPI Cmd/Data will work for all LCD drivers.

More details: apache#5898

## Impact

This change impacts LCD drivers that call `SPI_CMDDATA()`.

Previously `SPI_CMDDATA()` would fail with `ENODEV` for LCD drivers other than ST7735, ST7789 and GC9A01.

After patching, `SPI_CMDDATA()` will work correctly with all LCD drivers.

## Testing

We tested with LVGL and ST7789 on PineCone BL602:

-   [Testing with LVGL](https://github.com/lupyuen/st7789-nuttx#run-lvgl-demo)

As for regular SPI Devices that don't require SPI Cmd/Data, we tested `CONFIG_SPI_CMDDATA=y` with Semtech SX1262 SPI Transceiver on PineCone BL602:

-   [Testing Cmd/Data](https://github.com/lupyuen/incubator-nuttx/releases/tag/release-2022-03-30)
lupyuen added a commit to lupyuen/nuttx-bl602 that referenced this pull request Mar 30, 2022
## Summary

`esp32c3_spi2_cmddata()` implements SPI Cmd/Data `SPI_CMDDATA()` for only 3 LCD drivers: ST7735, ST7789 and GC9A01.

This patch removes the check for LCD drivers, so that SPI Cmd/Data will work for all LCD drivers.

More details: apache#5898

## Impact

This change impacts LCD drivers that call `SPI_CMDDATA()`.

Previously `SPI_CMDDATA()` would fail with `ENODEV` for LCD drivers other than ST7735, ST7789 and GC9A01.

After patching, `SPI_CMDDATA()` will work correctly with all LCD drivers.

## Testing

This is a minor patch so no testing is needed.
gustavonihei pushed a commit that referenced this pull request Mar 30, 2022
## Summary

`bl602_spi_cmddata()` implements SPI Cmd/Data `SPI_CMDDATA()` for only 3 LCD drivers: ST7735, ST7789 and GC9A01.

This patch removes the check for LCD drivers, so that SPI Cmd/Data will work for all LCD drivers.

More details: #5898

## Impact

This change impacts LCD drivers that call `SPI_CMDDATA()`.

Previously `SPI_CMDDATA()` would fail with `ENODEV` for LCD drivers other than ST7735, ST7789 and GC9A01.

After patching, `SPI_CMDDATA()` will work correctly with all LCD drivers.

## Testing

We tested with LVGL and ST7789 on PineCone BL602:

-   [Testing with LVGL](https://github.com/lupyuen/st7789-nuttx#run-lvgl-demo)

As for regular SPI Devices that don't require SPI Cmd/Data, we tested `CONFIG_SPI_CMDDATA=y` with Semtech SX1262 SPI Transceiver on PineCone BL602:

-   [Testing Cmd/Data](https://github.com/lupyuen/incubator-nuttx/releases/tag/release-2022-03-30)
gustavonihei pushed a commit that referenced this pull request Mar 30, 2022
## Summary

`esp32c3_spi2_cmddata()` implements SPI Cmd/Data `SPI_CMDDATA()` for only 3 LCD drivers: ST7735, ST7789 and GC9A01.

This patch removes the check for LCD drivers, so that SPI Cmd/Data will work for all LCD drivers.

More details: #5898

## Impact

This change impacts LCD drivers that call `SPI_CMDDATA()`.

Previously `SPI_CMDDATA()` would fail with `ENODEV` for LCD drivers other than ST7735, ST7789 and GC9A01.

After patching, `SPI_CMDDATA()` will work correctly with all LCD drivers.

## Testing

This is a minor patch so no testing is needed.
SimonFilgis pushed a commit to SimonFilgis/incubator-nuttx that referenced this pull request May 3, 2022
Signed-off-by: 田昕 <tianxin7@xiaomi.com>

workqueue: add work_foreach support

Signed-off-by: ligd <liguiding1@xiaomi.com>

arch/risc-v: Rename up_fpuconfig to riscv_fpuconfig

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/risc-v: Use riscv_fpuconfig to enable FPU

Use common function instead of chip specified code.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

riscv/bl602: Implement SPI Cmd/Data

To control the Data/Command Pin on ST7789 SPI Display, the SPI Driver flips the MISO Pin as though it was a GPIO.

To implement this on BL602, we reconfigure MISO from SPI Pin to GPIO Pin on the fly inside `bl602_spi_cmddata()`.

When the SPI Port is deselected (after the SPI operation), we revert MISO back from GPIO Pin to SPI Pin. We implement this inside `bl602_spi_select()`.

[More Details Here](https://github.com/lupyuen/st7789-nuttx#spi-cmddata)

This change impacts 3 LCD drivers that call `SPI_CMDDATA()`: ST7735, ST7789, GC9A01.

Previously the BL602 SPI Driver would fail with "SPI cmddata not supported" when the above drivers are used.

After the change, the above drivers will set the LCD Data/Command Pin correctly.

We tested this implementation of SPI Cmd/Data with NuttX ST7789 Driver and a Logic Analyser on PineCone BL602:

-   [Testing with Logic Analyser](https://github.com/lupyuen/st7789-nuttx#spi-cmddata)

We also tested LVGL with ST7789 on PineCone BL602:

-   [Testing with LVGL](https://github.com/lupyuen/st7789-nuttx#run-lvgl-demo)

As for regular SPI Devices that don't require SPI Cmd/Data, we tested `CONFIG_SPI_CMDDATA=y` with Semtech SX1262 SPI Transceiver on PineCone BL602:

-   [Testing Cmd/Data](https://github.com/lupyuen/incubator-nuttx/releases/tag/release-2022-03-29)

arch/risc-v/litex: add cache_invalidate

driver/mmcsd: add option to support SD/MMC PHYs that only run in 4-bit mode

arch/risc-v/src/litex/litex_sdio: add litesdcard peripheral driver

See the following for details on the pepheral:
https://github.com/enjoy-digital/litesdcard

boards/risc-v/litex/arty_a7: add SDCARD support for the Arty_A7 board

boards/risc-v/litex/arty_a7: update README to include building in LITESDCARD peripheral

opendir: use inode_find() instead when opendir()

Signed-off-by: ligd <liguiding1@xiaomi.com>

arm/cortex-[a|r]: IRQ Switch return should with shadow SPSR

The SPSR is used to store the current value of the CPSR when an exception
is taken so that it can be restored after handling the exception.
Each exception handling mode can access its own SPSR.

User mode and System mode do not have an SPSR because they are not
exception handling modes.

Signed-off-by: chao.an <anchao@xiaomi.com>

signal: Don't do schedule_sigaction when there is no action

Signed-off-by: ligd <liguiding1@xiaomi.com>

task: don't set default signal in kernal thread

Signed-off-by: ligd <liguiding1@xiaomi.com>

riscv/bl602: Remove check for LCD driver

`bl602_spi_cmddata()` implements SPI Cmd/Data `SPI_CMDDATA()` for only 3 LCD drivers: ST7735, ST7789 and GC9A01.

This patch removes the check for LCD drivers, so that SPI Cmd/Data will work for all LCD drivers.

More details: https://github.com/apache/incubator-nuttx/pull/5898

This change impacts LCD drivers that call `SPI_CMDDATA()`.

Previously `SPI_CMDDATA()` would fail with `ENODEV` for LCD drivers other than ST7735, ST7789 and GC9A01.

After patching, `SPI_CMDDATA()` will work correctly with all LCD drivers.

We tested with LVGL and ST7789 on PineCone BL602:

-   [Testing with LVGL](https://github.com/lupyuen/st7789-nuttx#run-lvgl-demo)

As for regular SPI Devices that don't require SPI Cmd/Data, we tested `CONFIG_SPI_CMDDATA=y` with Semtech SX1262 SPI Transceiver on PineCone BL602:

-   [Testing Cmd/Data](https://github.com/lupyuen/incubator-nuttx/releases/tag/release-2022-03-30)

riscv/esp32c3: Remove check for LCD driver

`esp32c3_spi2_cmddata()` implements SPI Cmd/Data `SPI_CMDDATA()` for only 3 LCD drivers: ST7735, ST7789 and GC9A01.

This patch removes the check for LCD drivers, so that SPI Cmd/Data will work for all LCD drivers.

More details: https://github.com/apache/incubator-nuttx/pull/5898

This change impacts LCD drivers that call `SPI_CMDDATA()`.

Previously `SPI_CMDDATA()` would fail with `ENODEV` for LCD drivers other than ST7735, ST7789 and GC9A01.

After patching, `SPI_CMDDATA()` will work correctly with all LCD drivers.

This is a minor patch so no testing is needed.

xtensa: Move XCHAL_SWINT_CALL definition into syscall header

This is required to avoid the interface header (syscall.h) depending on
the xtensa_swi.h header from the implementation

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

xtensa: Build OS-assisted atomic operations on ESP32-S2

ESP32-S2 lacks support for conditional load/store instructions.

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

risc-v/esp32c3: Fix inclusion of C++ constructors/destructors table

RISC-V GCC is configured with --enable-initfini-array so it emits an
.init_array section instead of .ctors

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

xtensa|risc-v: Make CXX exception and RTTI depend on Kconfig options

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

libcxx: Add patch for preventing redefinition of PS macro on Xtensa

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

libcxx: Fix libc++ for archs without conditional load/store support

This commit brings a patch already merged to upstream LLVM project:
https://reviews.llvm.org/D118391

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

esp32[s2/s3/c3]: Add defconfigs for testing C++

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

arch/arm: Make CXX exception and RTTI depend on Kconfig options

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

documentation: Add release notes for 10.3.0 release

This is a local copy taken from the confluence notes
https://cwiki.apache.org/confluence/display/NUTTX/NuttX+10.3

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

fs/romfs: fix bug about compare path with same prefix

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

boards/boardctl:common boardctl to read reset cause.

Signed-off-by: 田昕 <tianxin7@xiaomi.com>

rptun: set rptun thread default stack size to 4K

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: add rptun_force_panic support

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: add rptun_reset support

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: use HPWORK instead of thread

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: add rptun_panic for both master & salve

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: add rpmsg_wait/post support for recursive dispatch

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: divide shram to TX & RX

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: add rptun dump support

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: pm_stay when send msg & pm_relax when all tx buffer returned

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: enable rx interrupts for virtq

use wait_tx_buffer method need enable rx interrupts

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: add ping rpmsg support

Signed-off-by: ligd <liguiding1@xiaomi.com>

openamp: add openamp patches

0006-openamp-fix-scenario-case.patch
0007-openamp-divide-shram-to-TX-shram-RX-shram.patch
0008-rpmsg_virtio-don-t-need-check-status-when-get_tx_pay.patch

Signed-off-by: ligd <liguiding1@xiaomi.com>

rptun: forward panic/reset to lowerhalf

Signed-off-by: ligd <liguiding1@xiaomi.com>

remove DISCLAIMER-WIP

most licenses have been converted to Apache and the non Apache
licenses have been documented.
We can assume that now it should be the time to remove DISCLAIMER-WIP

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

arch/risc-v/mpfs: Remove duplicated riscv_restorefpu

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

ioe_rpmsg: use rptun_wait/post to resolve deadlock with usrsock

Signed-off-by: ligd <liguiding1@xiaomi.com>

arch/risc-v: Store/Restore FPU register in exception_common

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/risc-v: Rename up_doirq to riscv_doirq

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/risc-v: Remove deprecated logic from riscv_doirq

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/risc-v: Merge duplicated logic by riscv_doirq

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/risc-v: Dont' disable/enable irq in riscv_doirq

Since these codes added to all chips but not fully tested,
so we should changd this behavior.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/risc-v: Remove unneeded group_addrenv call which handled by riscv_doirq

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/risc-v: move REGLOAD/REGSTORE macro to riscv_internal.h

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

arch/risc-v: include csr.h indirectly through nuttx/irq.h

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

arch/risc-v: fix ARCH_RV32 offset for the stub lookup table calculation

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

mm/mm_heap: place alloc-bit at the LSB of node->preceeding.

Heap always allocate the memory at least 2bytes alignment.

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>

mm_heap: heapsize align with MM_MIN_CHUNK.

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>

driver/syslog: Add microseconds after date time

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

ARCH_ADDRENV: Add guard against mis-configuration

When process a is switched to process b, the address environment is
swapped with a call to group_addrenv(). The stack upon entry will be
a's, and upon exit b's. This will fail, so a neutral stack is required,
either a kernel stack or an IRQ stack.

Infrastructure for an IRQ stack is already in place, so give a hint
that an interrupt stack should be provided if address environments
are enabled.

arch/risc-v: get wider visibility for arch instruction macros

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

rpmsgfs: add wait ready to rpmsgfs

Signed-off-by: ligd <liguiding1@xiaomi.com>

rpmsgfs: add timeout when mount in rpmsgfs

Signed-off-by: ligd <liguiding1@xiaomi.com>

rpmsgfs: use rptun_wait/post to resolve deadlock with usrsock

Signed-off-by: ligd <liguiding1@xiaomi.com>

sigact: get free sigact from freelist always successful

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

netdev_file_ioctl: Fix fcntl F_SETFL O_NONBLOCK regression

This fixes a regression caused by the following commit,
which prevents the file flag from being updated.

```
commit 28860b5242dd5efd86b5da8a089e5d898cd8a9a1
Author: chao.an <anchao@xiaomi.com>
Date:   Sat Mar 19 14:47:37 2022 +0800

    net/netdev: fix switch case missing break

    Signed-off-by: chao.an <anchao@xiaomi.com>
```

Note: some applications like mbedtls uses F_GETFL to confirm
the nonblock-ness of the socket. This is critical for such
applications.

nuttx: Add "#include <nuttx/fs/ioctl.h>" to tioctl.h

Signed-off-by: zhouliang3 <zhouliang3@xiaomi.com>

fs/unionfs: fix bug about use after free about ui

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

fs/unionfs: check return value to avoid unused value

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

fs/unionfs: add sanity check for parameter

if relpath is NULL, it will cause system crash:
unionfs_opendir with relpath NULL
    ->	unionfs_tryopendir
	    ->	unionfs_offsetpath
		->  strncmp(prefix, relpath, pfxlen

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

SEGGER_RTT: solve compile error when enable segger rtt in armv7m.

1. SEGGER_RTT_ASM_ARMv7M include SEGGER_RTT.h, and SEGGER_RTT.h
include SEGGER_RTT_Conf.h, so add __ASSEMBLY__ in
SEGGER_RTT_Conf.h;
2. AFLAG add segger/config because SEGGER_RTT_ASM_ARMv7M.S
include SEGGER_RTT_Conf.h;

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>

fs/procfstcbinfo: minor bug about print address

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

fs/romfs: fix string overflow when the length of rn_name exceeds NAME_MAX + 1

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

fs and unistd: increase OPEN_MAX by claiming a Kconfig.

Signed-off-by: 田昕 <tianxin7@xiaomi.com>

rpmsgfs: do NOT access the pointer when do remote ioctl

Signed-off-by: ligd <liguiding1@xiaomi.com>

fs/rpmsgfs: fix bug about using uninit variable "times"

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

arch/xtensa: add syscall note support in the flat build

Signed-off-by: chao.an <anchao@xiaomi.com>

sched/note: unify the data format

Signed-off-by: chao.an <anchao@xiaomi.com>

sched/trace: correct the note print format

note print should with Instruction pointer.

e.g:

        trace_printk("hello NuttX");

trace dump:

hello-6  [000] .... 23080.367994: 0xc044a005: hello NuttX

Signed-off-by: chao.an <anchao@xiaomi.com>

sched/note: add support of trace section mark

The implementation of this feature is based on android systrace:

https://source.android.com/devices/tech/debug/ftrace

Application developers are more concerned about the performance of
the specified application section,
added two APIs to implement performance measurement:

void sched_note_begin(uintptr_t ip, FAR const char *buf);
void sched_note_end(uintptr_t ip, FAR const char *buf);
or
SCHED_NOTE_BEGIN();  /* defined to sched_note_begin(_THIS_IP_, __FUNCTION__) */
SCHED_NOTE_END();    /* defined to sched_note_end(_THIS_IP_, __FUNCTION__) */

Signed-off-by: chao.an <anchao@xiaomi.com>

unistd:rename CONFIG_OPEN_MAX to CONFIG_LIBC_OPEN_MAX

Signed-off-by: 田昕 <tianxin7@xiaomi.com>

sim: Fix init of static C++ constructors when using glibc >= 2.34

glibc 2.34 changed the dynamic linker behavior during the startup
process, which makes the previous "__init_array_start" replacement trick
non-effective.
Now the dynamic linker parses the constructors/destructors information
from the DYNAMIC segment of the program.

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

libs/libc/lib_err.c:add va_end to vwarn

call va_copy,after need call va_end
Signed-off-by: anjiahao <anjiahao@xiaomi.com>

local socket: cancel assert about backlog exceed 255

Signed-off-by: zhanghu6 <zhanghu6@xiaomi.com>

net/local: change 255 to UINT8_MAX

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

power: unify lock states

unify critical_section and nxsem with pm_lock/pm_unlock

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>

power:driver: move pm_auto_update to outer dir

Pm_auto_update maybe called by outter PM users

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>

lib_chdir:use change ret judgment method

Signed-off-by: anjiahao <anjiahao@xiaomi.com>

modlib/modlib_bind:fix unsigned_compare with zero

Signed-off-by: anjiahao <anjiahao@xiaomi.com>

Update libs/libc/modlib/modlib_bind.c

u are right

Co-authored-by: Petro Karashchenko <petro.karashchenko@gmail.com>

Update libs/libc/modlib/modlib_bind.c

Co-authored-by: Petro Karashchenko <petro.karashchenko@gmail.com>

mmcsd: Add gotextcsd callback to sdio_dev_s

so the driver implementation could get critical EXTCSD info

Signed-off-by: anjianjun <anjianjun@xiaomi.com>

mmcsd: Move SDIO_GOTEXTCSD after SDIO_DMASENDSETUP

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

mmcsd: Fix mmc card error but system can not catch it

Signed-off-by: anjianjun <anjianjun@xiaomi.com>

risc-v/esp32c3: Fix regression on IRQ handling for ECALL instruction

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

RISC-V: Implement option to run NuttX in supervisor mode (S-mode)

- Add config "ARCH_USE_S_MODE" which controls whether the kernel
  runs in M-mode or S-mode
- Add more MSTATUS and most of the SSTATUS register definitions
- Add more MIP flags for interrupt delegation
- Add handling of interrupts from S-mode
- Add handling of FPU from S-mode
- Add new context handling functions that are not dependent on the trap
  handlers / ecall

NOTE: S-mode requires a companion SW (SBI) which is not yet implemented,
      thus S-mode is not usable as is, yet.

RISC-V: Implement skeleton for a per CPU structure

It might be useful to store things in memory per CPU. The tricky part
is that all CPUs run the same code and see the same memory, so some
kind of centralized access is required.

For now, the structure contains the hart id.

Access to the structure elements is provided via sscratch, which is
unique for every hart!

Fix ESP32-C3 toolchain download link

arch/xtensa: Add xtensa_tcbinfo struct that contains helpful offsets.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

fix:Temporarily remove udp send large pkt assert

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>

net: tcp/udp/icmp/icmpv6 add FIONSPACE support

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>

timerexpiration:fix DEADCODE when RR_INTERVAL or SCHED_SPORADIC not select

tmp is always true for CONFIG_RR_INTERVAL > 0
and CONFIG_SCHED_SPORADIC not select

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>

arch/riscv: Align the macro definition in csr.h

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/riscv: Rename riscv_syscall_dispatch to riscv_dispatch_syscall

follow other function naming(e.g. riscv_dispatch_irq)

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/riscv: Remove riscv_sbi.c since it doesn't exist

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/riscv: Rename riscv_exception_macros.S to riscv_macros.S

since macro defined in this file is also used in the normal context

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/riscv: Access [m|s]scratch through CSR_SCRATCH macro

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/riscv: Rename g_scratch to g_percpu

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

sched_note: fix buffer size warning in coverity

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>

mod_insmod: fix coverity warning

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>

stm32: add support for up_perf

boards/nucleo-f446re: initialize up_perf

note_sysview.c: fix compilation for CONFIG_TASK_NAME_SIZE == 0

note_sysview.c: fix compilation if CONFIG_SCHED_INSTRUMENTATION_FILTER not defined

arm/chip: add backtrace support for all chips that support thumb instruction set.

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>

usrsock: Move event field to usrsock_message_common_s

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>

net:fix coverity warning

Signed-off-by: hejianliang3 <hejianliang3@xiaomi.com>

stm32u5: stm32_stdclockconfig fixes

Fix stm32_stdclockconfig for stm32u585xx to the extend that the
B-U585I-IOT02A board's clock tree can be configured.  This board uses
the MSIS as PLL1's input clock and the LSE to autotrim the MSIS.

b-u585i-iot02a: Fix stdclock initialization

Correct the respective defines to initialize the B-U585I-IOT02A clock
tree correctly by means of stm32_stdclockconfig().

b-u585i-iot02a:nsh: Drop TrustedFirmware-M dependency

Make the nsh defconfig for the b-u585i-iot02a run stand-alone (i.e. not
as a companion that relies on TF-M doing low-level board
initialization).

net/utils: fix IPv4 checksum calculation

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

arch/risc-v: use STACK_FRAME_SIZE for in S-mode syscall asm

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

arch/riscv: Rename SCRATCH_HARTID_OFFSET to RISCV_PERCPU_HARTID_OFFSET

and fix the typo error

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

modlib_bind.c: Restore "Relocation address out of range" checks

Restore the checks which got completely broken by the following change.
```
commit 15142a8b106bee8db6ac744b963969feba5c8289
Author: anjiahao <anjiahao@xiaomi.com>
Date:   Fri Apr 1 16:20:03 2022 +0800

    modlib/modlib_bind:fix unsigned_compare with zero

    Signed-off-by: anjiahao <anjiahao@xiaomi.com>
```

syscall: Fix Makefile:69: target 'syscall_names.o' given more than once in the same rule

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

libc/netdb: Support the recursive lock

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

libc/netdb: Remove the temporary unlock in dns_foreach_nameserver

since netdb support the recursive lock

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

libc/netdb: Hold dns lock when operating with resolv.conf

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/xtensa: Build the xtensa_tcbinfo.c file for S2 and S3.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

nuttx: unify FAR attribute usage across the code

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

RISC-V: Fix file name of riscv_dispatch_syscall

RISC-V: Fix usage of static_assert in riscv_percpu.c

There is no alias for struct riscv_percu_s

Update cpp_cmake.rst

update CMAKE_C_FLAGS when compile C file

Update cpp_cmake.rst

openamp: Change the dependence from OPENAMP to RPTUN

since all rpmsg driver need the extension api exposed by rptun driver

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

libc/string: Fix the minor style issue

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

libc: Avoid the compiler generate code call self(memcpy/memmove/memset/memcmp) recursively

please reference the similar change done by other libc implementation:
https://reviews.llvm.org/D68028?id=224286
https://github.com/bminor/glibc/commit/85c2e6110c9a01ec817c30f1b7e20549d7229987
https://github.com/bminor/musl/commit/4a1f55e92fa74ee382909baa96302231f566b5e1
https://github.com/bminor/newlib/commit/82dfae9ab0734b9946321590162dc6021057fec1

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch:tcbinfo: update tcbinfo as xcpcontext update

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>

jlink-nuttx: update regs as nuttx regs save path change

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>

include/nuttx: remove double definitions of UNUSED macro

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

fix uinput rpmsg logic error

xtensa/esp32: Add support to TWAI/CANBus controller

esp32: Add board support to TWAI/CANBus

arch/sim: support simulator keyboard devices

arch/risc-v: Replace riscv_fault with riscv_exception

Remove riscv_fault since its code is duplicated with riscv_exception,
and there are textual excpetion reason in riscv_exception.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

fs/epoll: change type of eventset from uint8_t to uint32_t

to support EPOLLONESHOT and so on.

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

fs/poll: change format for type pollevent_t

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

lib_lib_vsprintf/backtrace: fix the type issue

using 't': For integer types, causes printf to expect
a ptrdiff_t-sized integer argument.

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

fs/poll: change format for type pollevent_t

complete the following commits:

commit d87cf8d4ca5fe69c71c131015a7b64b68c917593
Author: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Date:   Fri Apr 1 20:59:55 2022 +0800

    fs/poll: change format for type pollevent_t

    Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

commit d535943a69f03033b077cb95cce162bb28b40b56
Author: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
Date:   Fri Apr 1 17:49:10 2022 +0800

    fs/epoll: change type of eventset from uint8_t to uint32_t

    to support EPOLLONESHOT and so on.

    Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/risc-v: Remove the unnecessary inclusion of board header files

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

MPFS: Prepare support for S-mode

- Access to PLIC via S-mode registers
- Access to IRQs via S-mode registers / definitions
- Initialize S-mode registers upon boot
- Initialize per CPU area before nx_start

NOTE: S-mode requires a companion SW (SBI) which is not yet implemented,
thus S-mode is not usable as is, yet.

esp32c3: Simplify irq dispatch logic

ESP32C3 use customized irq encoding so it's hard to share further code
with other risc-v based chips, in this patch, we keep the exception
number definition with risc-v spec.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

Documentation/guides/pysimcoder.rst: update pysimCoder dependencies

CONFIG_LIBM option may be required by some toolchains that do not include
standard math library. Morover CONFIG_PTHREAD_STACK_MIN was listed twice
in the list.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>

arch/riscv: Minor style change and text correction

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

sched/pthread:need check pthread is DETACHED

pthread_join need check thread is DETACHED,
Whether to wait according to the result.And,
if a thread is DETACHED,it will not set a new
attr.
Signed-off-by: anjiahao <anjiahao@xiaomi.com>

sched/note: add dummy definition if CONFIG_SCHED_INSTRUMENTATION disabled

Signed-off-by: chao.an <anchao@xiaomi.com>

sched/note: correct flatten format

Signed-off-by: chao.an <anchao@xiaomi.com>

arm/armv[7|8]-m: skip the fpu save/restore if stack frame is integer-only

Signed-off-by: chao.an <anchao@xiaomi.com>

fs/vfs: fix st_mode mask check

The full mask for st_mode is 0177777
Now modify any file permissions in hostfs and all will fail

arch/risc-v: Add handler for misaligned load/store

Some risc-v based chips don't support unaligned data access,
it will trigger a exception and then lead to crash.

In this patch, we handle the misaligned access by software to make
system run continue.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

tools/checkrelease.sh: Don't check DISCLAIMER-WIP anymore

since all license is clean up now

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

sched/wqueue: Simplify CALL_WORKER dispatch condition

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

sched/irq: Remove CONFIG_SCHED_IRQMONITOR when define CALL_VECTOR

since up_perf_ API doesn't couple with CONFIG_SCHED_IRQMONITOR

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

sched/irq: Fix array overrun in coverity check

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

boards/nucleo-h743zi2: Enable up_perf API

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

boards/lx_cpu: Enable up_perf API

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/risc-v: Align prototype of riscv_exception with xcpt_t

Thus we can attach it to irq handler without any cast.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/risc-v: Attach exception handler in common place

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/risc-v: Move epc adjustment to riscv_doirq

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

checkpatch.sh: add -m option to enable/disable Change-Id check

Defaultly disable Change-Id check in commit message.

Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>

.github/workflows/check.yml: Enable Change-ID check explicitly

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

Make top Make.defs symlink to board Make.defs instead

Symlink to board Make.defs for top Make.defs, so top Make.defs
syncs in realtime.

Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>

riscv/riscv_exception_commin.S: Don't call riscv_hartid in single core
mode.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

riscv/riscv_exception_common.S: Allow chips to define the exception
section.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

riscv/esp32c3: Use the common exception handler.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

riscv/bl602/chip.h: Add assembly guards for standard includes.

tools/mkdeps: Extend MAX_SHQUOTE to 3072

Signed-off-by: nietingting <nietingting@xiaomi.com>

audio: Return audio_lowerhalf_s pointer instead error code in audio_comp_initialize

audio: Don't register audio device if name isn't given in audio_comp_initialize

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

Fixes some issues with the implementation of the balance
functionality. In function "wm8904_hw_reset" the priv->balance
is initialized with b16HALF, indicating a range from
0 to b16ONE. In function "wm8904_setvolume" the assumed
range for priv->balance is between 0 and 1000. The changes
now make this consistent for 0 to b16ONE-1. Furthermore,
in wm8904_configure the change of balance was not implemented.

Minor fix, function name was wm8994_setvolume instead of
wm8904_setvolume.

Fixed source code format errors.

Revert "mm_heap: heapsize align with MM_MIN_CHUNK."

This reverts commit 69e69740b5f578e035befc762538b282d91ed1ba.

mm_initialize: malloc() return aligend pointer.

malloc() should return aligned (with MM_MIN_CHUNK) pointer, but
pr #5906 destroy that, this pr find a better method to solve
these questions.

Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
and
Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>

arch/riscv: Add mtimer driver

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

sched/note: include-able from C++ files

Signed-off-by: chao.an <anchao@xiaomi.com>

drivers/sensors: Add new driver for scd41 sensor module

Add Sensirion's SCD41 CO2, temperature and humidity sensor driver.

drivers/sensors/scd30: Fix invalid parameter check

Fix invalid parameter check and redundant conditions.

drivers/sensors/sgp30: Fix redundant parameter check

Fix redundant conditions.

littelfs: deal with block devices w/o ioctl

Note: Some block devices has ioctl == NULL. eg. drivers/loop

netdb/lib_dnsaddserver.c: Do not insert the duplicate DNS address

Signed-off-by: songlinzhang <songlinzhang@xiaomi.com>

graphics/nxterm: Avoid accessing freed memory

Fix accessing freed priv data.

drivers/syslog: update description if Kconfig

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

libc/lib_localtime:fix deadcode

isdst always is false

Signed-off-by: anjiahao <anjiahao@xiaomi.com>

RISC-V: Combine 3 variables that depend on CPU amount into one

IRQ_NSTACKS, ARCH_CPU_COUNT, CONFIG_SMP_NCPUS all relate to each
other. However, a bit of clean up can be done and everything can
be merged into SMP_NCPUS.

The MPFS bootloader case works also as it requires only 1 IRQ stack
for the hart that executes as bootloader.

RISC-V: Remove riscv_cpuindex.c from platforms that don't need it

riscv_mhartid is no longer called by exception_common, so can remove
this file from platforms that don't need it.

Also fixes make warning:
Makefile:123: target 'riscv_cpuindex.o' given more than once in the same rule

RISC-V: Add setintstack for k210 and qemu

This fixes CI issue, and I think the old implementation with SMP
shared 1 IRQ stack for multiple CPUs.

sched/init: drivers_initialize() should be late than up_initialize()

up_initialize
|
 ->up_serialinit
   |
    ->uart_register  /* ("/dev/console", &CONSOLE_DEV); */

drivers_initialize
|
 ->syslog_console_init
   |
    ->register_driver /* ("/dev/console", &g_consoleops, 0666, NULL); */

Signed-off-by: chao.an <anchao@xiaomi.com>

arch: cxd56xx: update loader and gnssfw version

Update loader and gnssfw to version 2.2.20585

cxd56xx/cxd56_emmc.c: Fix compile warning

Add necessary include header named debug.h for using ferr and
finfo.

arch: cxd56xx: Fix critical section in scu driver

Add critical section to scu one-shot sequencer.

boards: cxd56xx: Fix an issue i2c tool not working

It caused i2c tool not to work due to i2c uninitializing processing.
Since this process is not necessary in the normal case, we will
move it to the error case.

boards: cxd56xx: Make board_late_initialize a weak function

Add a weak_function to the board_late_initialize function so that
it can be replaced by another file, such as a user application.

board/spresense: Add pin selection of ILI934x

Add Kconfig choice for selecting RST and DC pins on ILI934x LCD.

boards: cxd56xx: Add board function for scd41 sensor driver

Add board function for SCD41 CO2, temperature and humidity sensor driver.

cxd56/spresense: Add callback mechanism to notice SDCard injection

Add a mechanism to callback to an application to notice the SDCard
status is changed (inserted or ejected).

.github/gcc.json: Fix space/tab inconsistency

sim: bt: Add specific bluetooth HCI number id

Add option for attached the local bluetooth device use
specific bluetooth HCI number id.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>

lib_localtime:fix unsigned compare with zero

Signed-off-by: anjiahao <anjiahao@xiaomi.com>

arch/risc-v: Apply common mtime driver to mtime based chps

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

risc-v/c906: fix build break

chip/c906_timerisr.c: In function 'up_timer_initialize':
Error: chip/c906_timerisr.c:71:3: error: implicit declaration of function 'DEBUGASSERT' [-Werror=implicit-function-declaration]
   DEBUGASSERT(lower);
   ^~~~~~~~~~~
cc1: all warnings being treated as errors

Signed-off-by: chao.an <anchao@xiaomi.com>

libc/lib_glob:use strlcpy instead of memcpy

Signed-off-by: anjiahao <anjiahao@xiaomi.com>

libc/net:use strlcpy instead of strncpy

Signed-off-by: anjiahao <anjiahao@xiaomi.com>

arch/risc-v: Add missing DMB to mtimer / setmtimecmp

The memory mapped mtimecmp lives in I/O space so must add barrier
to make sure the value sticks. Otherwise a new IRQ might fire
at once.

arch/risc-v: Apply misaligned access handler for k210/bl602

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/riscv: Move toolchain config to arch/risc-v/Kconfig like xtensa

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

riscv/riscv_schedulesigaction.c: Remove the duplicate state saving.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

arch/arm: Move FPU initialization to common place

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/stack_color: correct the end address of stack color

The different optimization of compilers will cause ambiguity in
obtaining sp through up_getsp() in arm_stack_color(), if compile
with clang and enable the optimization flag (-Ofast), up_getsp()
call will be earlier than push {r0-r9,lr}, the end address of color
stack will overlap with saved registers.

Compile line:
clang --target=arm-none-eabi -c "-Ofast" -fno-builtin -march=armv8.1-m.main+mve.fp+fp.dp \
-mtune=cortex-m55 -mthumb -mfpu=fpv5-d16 -mfloat-abi=hard -D__NuttX__ -common/arm_checkstack.c -o  arm_checkstack.o

Assembler code:
llvm-objdump -aS arm_checkstack.o
------------------------------------
|00000000 <arm_stack_color>:
|;   start = INT32_ALIGN_UP((uintptr_t)stackbase);
|       0: c2 1c         adds  r2, r0, #3
|       2: 22 f0 03 02   bic r2, r2, #3
|;   end   = nbytes ? INT32_ALIGN_DOWN((uintptr_t)stackbase + nbytes) :
|       6: 19 b1         cbz r1, 0x10 <arm_stack_color+0x10> @ imm = #6
|       8: 08 44         add r0, r1
|       a: 20 f0 03 00   bic r0, r0, #3
|       e: 00 e0         b 0x12 <arm_stack_color+0x12> @ imm = #0
|;   __asm__
|      10: 68 46         mov r0, sp                               <--- fetch the sp before push {r7 lr}
|      12: 80 b5         push  {r7, lr}                           <--- sp changed
|;   nwords = (end - start) >> 2;
|      14: 80 1a         subs  r0, r0, r2
|      16: 80 08         lsrs  r0, r0, #2
|; }
|      18: 08 bf         it  eq
|      1a: 80 bd         popeq {r7, pc}
|      1c: 4b f6 ef 63   movw  r3, #48879
|      20: cd f6 ad 63   movt  r3, #57005
|      24: a0 ee 10 3b   vdup.32 q0, r3
|;   while (nwords-- > 0)
|      28: 20 f0 01 e0   dlstp.32  lr, r0
|;       *ptr++ = STACK_COLOR;                                    <--- overwrite
|      2c: a2 ec 04 1f   vstrw.32  q0, [r2], #16
|      30: 1f f0 05 c0   letp  lr, 0x2c <arm_stack_color+0x2c> @ imm = #-8
|; }
|      34: 80 bd         pop {r7, pc}
------------------------------------

Signed-off-by: chao.an <anchao@xiaomi.com>

arm/armv8-m: indicating no low-overhead-loop predication by default

Fix usage fault on clang version 13.0.0 (-Ofast):
------------------------------------------------------------------
| arm_hardfault: Hard Fault escalation:
| arm_usagefault: PANIC!!! Usage Fault:
| arm_usagefault:  IRQ: 3 regs: 0x3c58c510
| arm_usagefault:  BASEPRI: 00000080 PRIMASK: 00000000 IPSR: 00000003 CONTROL: 00000004
| arm_usagefault:  CFSR: 00020000 HFSR: 40000000 DFSR: 00000000 BFAR: 01608050 AFSR: 00000000
| arm_usagefault: Usage Fault Reason:
| arm_usagefault:  Invalid state
| up_assert: Assertion failed at file:armv8-m/arm_usagefault.c line: 113 task: lpwork
| backtrace:
| [ 2] [<0x2c58124a>] up_backtrace+0xa/0x2e2
| [ 2] [<0x2c56f7cc>] sched_dumpstack+0x28/0x66
| [ 2] [<0x2c580cd0>] up_assert+0x62/0x254
| [ 2] [<0x2c56ab8a>] _assert+0/0xa
| [ 2] [<0x2c55575a>] nxsched_add_prioritized+0x38/0xa2
| [ 2] [<0x2c555894>] nxsched_add_blocked+0x2e/0x44
| [ 2] [<0x2c580748>] up_block_task+0x2a/0x96
| [ 2] [<0x2c5569ea>] nxsem_wait+0x64/0xb4
| [ 2] [<0x2c556a40>] nxsem_wait_uninterruptible+0x6/0x10
| [ 2] [<0x2c559b9a>] work_thread+0x1c/0x48
-------------------------------------------------------------------

usage fault on 0x2c55575a:

------------------------------------
|2c555722 <nxsched_add_prioritized>:
|; {
|2c555722: 80 b5         push  {r7, lr}
|...
|2c55575a: 2f f0 17 c0   le  0x2c555732 <nxsched_add_prioritized+0x10> @ imm = #-44
|...
------------------------------------

Arm v8-M Architecture Reference Manual:

C2.4.103 LE, LETP

B3.28 Low overhead loops:

An INVSTATE UsageFault is raised if a LE instruction is executed and FPSCR.LTPSIZE does not read as four.
When a new floating-point context is created and FPCCR.ASPEN is set to zero it is the responsibility of software
to correctly initialize FPSCR.LTPSIZE.

Signed-off-by: chao.an <anchao@xiaomi.com>

fs/vfs/fs_truncate.c: Use ioctl to truncate on non-mountpoint inode

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>

libc/time: add strptime porting support

lib_strptime.c copies from android bionic/libc/tzcode.

Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>
Signed-off-by: anjiahao <anjiahao@xiaomi.com>

libc/strptime:_conv_num skip space

Signed-off-by: anjiahao <anjiahao@xiaomi.com>

libc/strptime: fix warning unused-value

warning: value computed is not used [-Wunused-value]
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Signed-off-by: anjiahao <anjiahao@xiaomi.com>

libc/lib_strptime:change code format & add notes

Signed-off-by: anjiahao <anjiahao@xiaomi.com>

RISC-V: Move mhartid to own assembly macro+function

Hartid and cpuindex are not the same thing. Hartid is needed regardless
of SMP, for external interrupt handling etc.

SMP needs cpuindex which might not be index == hartid, so both are
needed. IMO it is clearer to provide separate API for both.

Currently the implementation of up_cpu_index is done a bit lazily,
because it assumes hartid == cpu index, but this is not 100% accurate,
so it is still missing some logic.

arch/risc-v/riscv_misaligned: Correct sw source register

If source register of sw instruction is x0, we must point it to a constant zero
since in NuttX's context,
value of index 0 is EPC.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/risc-v: Correct format of 32-bit insn in misaligned handler

FIx:
Format specifies type 'unsigned long' but the argument has type 'uint32_t' (aka 'unsigned int')

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

power/governor: Remove the duplicated function prototype

since they are declared include/nuttx/power/pm.h by:
commit 5ce181e6b702cedbd79790fbe40aab7d29dae7c0
Author: zhuyanlin <zhuyanlin1@xiaomi.com>
Date:   Mon Feb 14 15:32:40 2022 +0800

    power:govorner: add govorner to per domain.

    For mult domains scene,,
    activity and greety can be used at same time.
    Let user to select domain governor.

    Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>

and add static const to g_pmgovernor

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>

drivers/power: Remove activity_governor.h and greedy_governor.h

since they aren't really used anymore

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

MPFS: Fix mtimecmp address

MTIMECMP0 was incorrect

MPFS: Use riscv_exception_attach like the others do

Exception / fault handling goes to unexpected ISR, fix by setting the
common ISR handlers like all other RISC-V platforms do.

arch: Fix compile error when enabling CONFIG_DUMP_ON_EXIT

"error: incompatible types when assigning to type 'struct filelist *' from type 'struct filelist'
   filelist = tcb->group->tg_filelist;"

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

arch: Move the DUMP_ON_EXIT logic after nxtask_exit.

Otherwise we will try to dump the state of the current task, however the
exit handler has already started doing some cleanup and invalidated its
group.  Accessing the group from dumponexit will crash.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

arch/Kconfig: Move the DUMP_ON_EXIT option out of the Bring-up group.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

sched/pthread_create:fix bug,delete data_sem

if a pthread set attr is detach,and when call pthread_create,
new thread exit quikly,new thread's tcb be free,then pthread_create
use new thread's tcb will crash.
Signed-off-by: anjiahao <anjiahao@xiaomi.com>

rpmsg_usrsock: Support the wireless ioctl which contain pointer 1/2

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>

fix: usrsock iovec_do skip empty iov

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>

sched/environ: Ensure tg_envp terminated by double '\0'

so we can compute the whole environ string length from it

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

RISC-V: Add SBI glue logic

Currently only stubs for mtime handling added, with a gentle reminder
that the actual implementation is still missing.

RISC-V: mtimer register via SBI when S-mode is in use

Cannot access the memory mapped registers directly when the kernel
runs in S-mode, must forward the access to SBI.

arch/[arm|sparc]: replace INT32_ALIGN_* to STACK_ALIGN_*

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/stack_color: correct the stack top of running task

This PR to ensure the stack pointer is locate to the stack top

Signed-off-by: chao.an <anchao@xiaomi.com>

arm/rtl8720c: Remove up_getsp which is already implemented in arch/arm/arch.h

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

MPFS: Set correct interrupt per mode (M-/S-mode) for mtimer

libc/string: Use Byte-Shift algorithm for very long needles

Reference here:
https://github.com/taleinat/byteshift_strstr

Signed-off-by: chao.an <anchao@xiaomi.com>
Signed-off-by: anjiahao <anjiahao@xiaomi.com>

libc/string:delete small to big endian marco

avoid byte alignment
Signed-off-by: haopengxiang <haopengxiang@xiaomi.com>
Signed-off-by: anjiahao <anjiahao@xiaomi.com>

libc/string:add LICENSE info

Signed-off-by: anjiahao <anjiahao@xiaomi.com>

Add SPIRAM to ESP32-S2

driver/mmcsdio: do not hold the semaphore on interrupt context

so we can do the full dump to mmc/sd card in the panic case

Signed-off-by: chao.an <anchao@xiaomi.com>

driver/mmcsdio: do not hold the semaphore in idle thread too

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

fs/fcntl: add O_APPEND flag judge in fcntl

Signed-off-by: liuhaitao <liuhaitao@xiaomi.com>

vfs/fcntl: Minor style fix

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arm/armv7-[a|r]: move fpu save/restore to assembly handler

Save/Restore FPU registers in C environment is dangerous practive,
which cannot guarantee the compiler won't generate the assembly code
with float point registers, especially in interrupt handling

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/arm/src/sam34/sam_hsmci.c: delay required after sending command

arch/arm/src/sam34/sam_hsmci.c: DMA setup before write is required

arch/arm/src/sam34/sam_hsmci: DMA also present on SAM3X chips

arch/arm/src/sam34/sam_hsmci.c: SAM3X GPIO setup

arch/arm/src/sam34/Kconfig: fix typo in device name

boards/arm/a1x: Remove the check CONFIG_ARCH_FPU around arm_fpuconfig

forget in below change:
commit df5a8a53ae92606e2d65149c6b5159b82dfc5d76
Author: Xiang Xiao <xiaoxiang@xiaomi.com>
Date:   Tue Apr 12 03:18:46 2022 +0800

    arch/arm: Move FPU initialization to common place

    Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

boards/esp32_twai: Remove arm_arch.h from comment

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

drivers: remove unimplemented open/close/ioctl interfaces

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

arch/risc-v: Use fs status definition from csr.h

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/riscv/esp32c3: esp32c3_twai.h TWAI (CAN) controller registers provided by Espressif.

File provided by Abdelatif Guettouche

Signed-off-by: Jan Charvat <jancharvat.charvat@gmail.com>

arch/riscv/esp32c3: ESP32C3 TWAI (CAN) controller driver.

Signed-off-by: Jan Charvat <jancharvat.charvat@gmail.com>

arch/riscv/esp32c3: ESP32C3 TWAI (CAN) controller included into Kconfig.

Signed-off-by: Jan Charvat <jancharvat.charvat@gmail.com>

boards/risc-v/esp32c3: ESP32C3 TWAI (CAN) controller bringup for DevKitM-1.

Signed-off-by: Jan Charvat <jancharvat.charvat@gmail.com>

boards/risc-v/esp32c3: ESP32C3 TWAI (CAN) controller config for DevKitM-1.

Signed-off-by: Jan Charvat <jancharvat.charvat@gmail.com>

Fixed a compile error, presumably caused by C&P error.

arch/armv[7|8]m: enhance the clang support

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/Toolchain.defs: replace all ${/$} with $(/$)

Signed-off-by: chao.an <anchao@xiaomi.com>

semaphore: fix usage of NXSEM_INITIALIZER

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

arch/xtensa: Remove FAR from chip and board folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/ceva: Remove FAR from chip folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/sim: Remove FAR from chip and board folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/x86_64: Remove FAR from chip folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/or1k: Remove FAR from chip folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/misoc: Remove FAR from chip folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/mips: Remove FAR from chip and board folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/sparc: Remove FAR from chip and board folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arm/arch: using __builtin_frame_address(0) implement up_getsp().

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>

arch/arm: Move arm_signal_dispatch.c to common folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

Remove the unneeded worker_t cast

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

Remove the unneeded void cast

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arm/a1x: fix compile break

Signed-off-by: chao.an <anchao@xiaomi.com>

wireless/80211: update the 80211 header

Upstream from:
https://github.com/freebsd/freebsd-src/blob/main/sys/net80211/ieee80211.h

Signed-off-by: chao.an <anchao@xiaomi.com>

sched/environ: Refine the environment variables storage layout

to confirm the standard and then implement get_environ_ptr correctly

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

libc: Don't duplicate string in chdir and lib_restoredir

since the new layout doesn't reallocate the unchanged environ variable anymore

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

tools/cibuild.sh: Migrate risc-v toolchian from 8.3.0 to 10.2.0

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

tools/cibuild.sh: Download risc-v toolchain with --no-check-certificate

untils SiFive update their certification

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/arm: export arm_saveusercontext()

rename arm_saveusercontext() -> up_arm_saveusercontext()

Signed-off-by: chao.an <anchao@xiaomi.com>

boards/ostest: remove board ostest implement

Signed-off-by: chao.an <anchao@xiaomi.com>

board/arch_fpu*: move arch_[get|cmp]fpu to common arch

rename the arch api:
arch_getfpu  -> up_saveusercontext
arch_cmpfpu  -> up_cmpfpu

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/mips: Remove unneeded group_addrenv call which handled by mips_doirq

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/misoc: Remove unneeded group_addrenv call which handled by [lm32|minerva]_doirq

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/xtensa: Remove unneeded group_addrenv call which handled by xtensa_irq_dispatch

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/sparc: Remove unneeded group_addrenv call which handled by up_doirq

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

libc/blockstream: add block out stream backend

Signed-off-by: chao.an <anchao@xiaomi.com>

libc/blkoutstream: Minor style fix

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/arm: Remove unneeded group_addrenv call which handled by arm_doirq

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/risc-v: Remove FAR from chip and board folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/arm: Remove FAR and CODE from common/ and arm*/ folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

Revert "tools/cibuild.sh: Download risc-v toolchain with --no-check-certificate"

This reverts commit 3b97e37b525d50d8a78765f85276f900129dade5.

arch/arm: Remove all lazy fpu related code

since it is broken and inefficient, and then removed by:
commit dc961baaea17107109d94575e9bb5d9fb725b801
Author: chao.an <anchao@xiaomi.com>
Date:   Thu Apr 14 18:07:14 2022 +0800

    arm/armv7-[a|r]: move fpu save/restore to assembly handler

    Save/Restore FPU registers in C environment is dangerous practive,
    which cannot guarantee the compiler won't generate the assembly code
    with float point registers, especially in interrupt handling

    Signed-off-by: chao.an <anchao@xiaomi.com>

commit 8d66dbc0680cb81f91674ace814b2b8a94c49cd2
Author: chao.an <anchao@xiaomi.com>
Date:   Thu Apr 7 13:48:04 2022 +0800

    arm/armv[7|8]-m: skip the fpu save/restore if stack frame is integer-only

    Signed-off-by: chao.an <anchao@xiaomi.com>

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/armv[7|8]-m: Compare all FPU registers in up_fpucmp

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/armv7-[a|r]: correct the handing of group env switch

This PR resolved 2 issues:
1. CURRENT_REGS is not set correctly on swint handling
2. group env is not changed properly

Signed-off-by: chao.an <anchao@xiaomi.com>

fs:oflag need consistent with psock

if don't consistent with psock,call fcntl will have differet flag
Signed-off-by: anjiahao <anjiahao@xiaomi.com>

arm/arm_assert.c Fix dumping of status from ISR

The status dump did not work if the first fault triggers before
the first context switch (during nx_start()).

risc-v/riscv_assert.c Fix dumping of status from ISR

The status dump did not work if the first fault triggers before
the first context switch (during nx_start()).

fs:fs_getfilep changes fd judgment method

if a fd was closed,need return EBADF
Signed-off-by: anjiahao <anjiahao@xiaomi.com>

arch/armv8-m: Unify the toolchain definition of eabi/clang for linux and windows

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/armv7-m: Unify the toolchain definition of eabi/clang/iar for linux and windows

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/arm/armv6-m: Unify the toolchain definition of eabi for linux and windows

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/armv7-a/r: Unify the toolchain definition of eabi for linux and windows

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/risc-v: Unify the toolchain definition of RVG for linux and windows

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/misoc: Unify the toolchain definition of GNU for linux and windows

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/z80: Unify the toolchain definition of SDCC for linux and windows

Signed-off-by: chao.an <anchao@xiaomi.com>

armv7/r:cp15_cache_all: fix error in LineSize 'r5' mask

r5 = r3 & r1

Signed-off-by: zhuyanlin <zhuyanlin1@xiaomi.com>

arch/sparc,xtensa: Control output by $(Q) as other arch

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

LICENSE: document missing armv7-x files

add missing armv7-a/armv7-r files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing lpc files

add missing lpc files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing samdxxx files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing am335x files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

arch: arm: cxd56xx: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

arch: arm: imxrt: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

arch: arm: lpc43xx: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

arch: arm: phy62xx: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

arch: arm: stm32l4: remove empty files

during contribution empty files have been pushed.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing tiva files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

arch: arm: mor1kx: remove empty files

during contribution empty files have been pushed.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing mor1k files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

arch: arm: sama5: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

arch: arm: stm32: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

boards: sim: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

drivers: leds: ncp5623c: migrate the license to Apache

Gregory Nutt is the copyright holder for those files and he has submitted the
SGA as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing mtd files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

drivers: mtd: gd5f: migrate the license to Apache

Xiaomi has submitted the SGA
as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

drivers: sensors: mlx90614: migrate the license to Apache

Gregory Nutt is the copyright holder for those files and he has submitted the
SGA as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing bcm43xxx files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing nfs files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

include: himem: Add Apache license to files

In the initial contribution those files were missing the license

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

include: leds: ncp5623c: migrate the license to Apache

Gregory Nutt is the copyright holder for those files and he has submitted the
SGA as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing uIP files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing bluetooth files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

include: wireless: bluetooth: migrate the license to Apache

Gregory Nutt is the copyright holder for those files and he has submitted the
SGA as a result we can migrate the licenses to Apache.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing sixlowpan files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing igmp files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing wireless files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

LICENSE: document missing libc files

add missing files to the LICENSE file.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>

arch/risc-v: Change riscv_savefpu/riscv_loadfpu to macro

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch/armv6-m: add support of LLVM Clang

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/clang: add support for Clang LTO

add support of Clang's Link Time Optimization (LTO) on NuttX build system

Reference:
https://gcc.gnu.org/onlinedocs/gccint/LTO-Overview.html
https://llvm.org/docs/LinkTimeOptimization.html

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/xtensa: Use syscall interface for xtensa_save/restore_context.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

arch.h: Fix up_exit prototype.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

arch/xtensa: Move xtensa_save_context to up_saveusercontext for
consistency with other archs.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

arm/armv[7|8]m: compare of hardware fp registers should skip REG_FP_RESERVED

Fix fpu test break

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/risc-v: Don't clear reserved bits in fcsr in riscv_fpuconfig

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

pipe: Increase buffer size by one byte to ompensate the full indicator

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

boards/sim: support rc.sysinit

Follow: http://glennastory.net/boot/sysinit.html

This is first script that init runs is rc.sysinit. This
script does serval initialization tasks about basic service.

The boot sequence currently provided to the board level is:
board_earlyinitialize->
    board_lateinitialize(Peripherals driver, core driver, ...)->
	run rcS script(mount fs, run service) ->
	    board_appinitialize->

After this patch:
The boot sequence currently provided to the board level is:
board_earlyinitialize->
    board_lateinitialize(core driver,...)->
	run rc.sysinit script(mount fs, run core service) ->
	    board_appinitialize(Peripherals driver)->
		run rcS script(run other service)->

So, Peripheral drivers can do more with the file system and
core services.

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>

arch/arm: Switch the context of save and restore from assembler to c

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/arm: Move the duplicated assembly code to common folder

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

binfmt_execmodule: add errout_with_args exit point

Ensures that when errout_xx is taken, args are freed

env_dup: Fix copying of env between address environments

If address environments are in use, it is not possible to simply
memcpy from from one process to another. The current implementation
of env_dup does precisely this and thus, it fails at once when it is
attempted between two user processes.

The solution is to use the kernel's heap as an intermediate buffer.
This is a simple, effective and common way to do a fork().

Obviously this is not needed for kernel processes.

syscall: Add call gate for get_environ_ptr

Now that the environment strings are stored as an array of strings,
they can be passed from the application via char **environ, which
is really defined as a function call to get_environ_ptr().

This works as is for flat build, but protected mode and kernel mode
require a call gate, which is added here.

binfmt_execmodule: If incoming envp is NULL get parent envp

This keeps backwards compatibility with apps that do not provide
envp. The old implementation passes NULL always and this change fixes
any regression caused by it.

assert: static_assert is not support in c standard C89,C99.

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>

arch/xtensa: Color the other CPUs task when they are created.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

compile/opt: add config DEBUG_OPT_UNUSED_SECTIONS

Enable this option to optimization the unused input sections with the
linker by compiling with " -ffunction-sections -fdata-sections ", and
linking with " --gc-sections ".

Signed-off-by: chao.an <anchao@xiaomi.com>

compile/opt: add config DEBUG_LINK_MAP

Selecting this option will pass "-Map=$(TOPDIR)$(DELIM)nuttx.map" to ld
when linking NuttX ELF. That file can be useful for verifying
and debugging magic section games, and for seeing which
pieces of code get eliminated with DEBUG_OPT_UNUSED_SECTIONS.

Signed-off-by: chao.an <anchao@xiaomi.com>

arch/risc-v: Enable FPU for K210

K210 support rv64gc ISA, now we enable F/D extension for it.

Note: QEMU for K210 don't support FPU now.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

sched/task: Correct the comment about environment variable

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

sched/environ: Remove the unneeded cast in env_dup

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

sched/environ: Replace get_environ_ptr with environ

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

environ: Don't expose get_environ_ptr in csdlib

since it isn't defined in c/c++ standard

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

arch/risc-v/riscv_misaligned: Implement float load/store support

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>

arch: risc-v: Do not enable FPU for K210 with QEMU

Summary:
- I noticed that maix-bit:smp does not work with QEMU.
- Actually, QEMU supports sifive_u (not K210) but it works
  if FPU is disabled.
- This commit fixes this issue.

Impact:
- K210 with QEMU only

Testing:
- Tested with qemu-5.2

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>

sched/task: Implement execle and execve

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

libc: Implement execvp, execlp and execvpe as macro

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

libc: Fix typo error in execle

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

syscall: Fix prototype of exec() to syscall.csv

pm: Move pm_initialize call from driver_initialize to xxx_pminitialize

since it's too late with the below commit:
ommit a594a5d7a8dcd756884ca7d3449f37ba77f96af3
Author: chao.an <anchao@xiaomi.com>
Date:   Mon Apr 11 19:44:26 2022 +0800

    sched/init: drivers_initialize() should be late than up_initialize()

    up_initialize
    |
     ->up_serialinit
       |
        ->uart_register  /* ("/dev/console", &CONSOLE_DEV); */

    drivers_initialize
    |
     ->syslog_console_init
       |
        ->register_driver /* ("/dev/console", &g_consoleops, 0666, NULL); */

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>

sched: remove DEBUGASSERT from nx_waitpid

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

xtensa_user_handler.S: Use the `ps_setup` macro when dealing with an
exception.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

xtensa_user_handler.S: Fix backtrace.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

arch/xtensa: No need to save SP in EXCSAVE_1 when linking the interrupt
frame with the previous frame.  The SP is already saved in A12.

Signed-off-by: Abdelatif Guettouche <abdelatif.guettouche@espressif.com>

boards/boardctl: correct boarctl return value

Summary:
- Correct boardctl function's return value
- In case of BOARDIOC_TESTSET, `ret' has 0 or 1 or an error,
  but `ret' is ignored except error.

Impact:
- boardctl return value except errors

Testing:
- custom Cortex-A9 board

Signed-off-by: Oki Minabe <minabe.oki@gmail.com>

libc/string: strcmp/strncmp cast unsigned char

Summary:
- Cast to unsigned char for strcmp and strncmp
- strcmp and strncmp are described following by opengroup.org

  The sign of a non-zero return value shall be determined by the sign
  of the difference between the values of the first pair of bytes
  (both interpreted as type unsigned char) that differ in the strings
  being compared.

  https://pubs.opengroup.org/onlinepubs/9699919799/functions/strcmp.html
  https://pubs.opengroup.org/onlinepubs/9699919799/functions/strncmp.html

Impact:
- strcmp and strncmp return value

Testing:
- ostest on sabre-6quad:smp w/ qemu

Signed-off-by: Oki Minabe <minabe.oki@gmail.com>

compiler.h: optimization option is not supported before GCC 4.6

-fno-tree-loop-distribute-patterns is not supported before
GCC 4.6

Signed-off-by: wangbowen6 <wangbowen6@xiaomi.com>

libs/libc/string: unify implementation across the functions

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>

tools:fix parsememdump.py match error

Signed-off-by: anjiahao <anjiahao@xiaomi.com>

libc/fixedmatch: Avoid "divide by zero" error

Signed-off-by: Xia…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants