Commit Graph

54599 Commits

Author SHA1 Message Date
Shoukui Zhang
43223124ec vfs/file: add reference counting to prevent accidental close during reading writing...
Signed-off-by: Shoukui Zhang <zhangshoukui@xiaomi.com>
2024-09-17 12:01:53 +08:00
Karel Kočí
f2fd0bc148 libs/libc/obstack: revert invalid null byte append to obstack_vprintf
The commit c4d8d937d5 added null byte for
obstack_vprintf and thus to obstack_printf. I probably lost my marbles
but the same test I run previously now won't append null byte at the end
and this "fix" now causes regressions in code using obstack.

For the reference this is the testing code:

  #define _GNU_SOURCE
  #include <obstack.h>
  #include <stdarg.h>
  #include <stdio.h>
  #include <stdlib.h>

  #define obstack_chunk_alloc malloc
  #define obstack_chunk_free free

  static void print(struct obstack *obs, const char *fmt, ...) {
    va_list arg;
    va_start(arg, fmt);
    obstack_vprintf(obs, fmt, arg);
    va_end(arg);
  }

  int main(int argc, char *argv[]) {
    struct obstack obs;
    obstack_init(&obs);

    obstack_printf(&obs, "this %s", "text ");
    obstack_printf(&obs, "is appended");
    print(&obs, " as well as %s", "vprintf text");
    obstack_1grow(&obs, '\0');

    printf("%s\n", (char *)obstack_finish(&obs));

    obstack_free(&obs, NULL);
    return 0;
  }

The output on NuttX without this patch:

  > obstest
  this text

The output on NuttX with this patch:

  > obstest
  this text is appended as well as vprintf text

The output with GlibC:

  $ gcc test.c && ./a.out
  this text is appended as well as vprintf text
  $ ldd a.out
  	linux-vdso.so.1 (0x00007ffff7fc5000)
  	libc.so.6 => /nix/store/3dyw8dzj9ab4m8hv5dpyx7zii8d0w6fi-glibc-2.39-52/lib/libc.so.6 (0x00007ffff7dc8000)
  	/nix/store/3dyw8dzj9ab4m8hv5dpyx7zii8d0w6fi-glibc-2.39-52/lib/ld-linux-x86-64.so.2 => /nix/store/3dyw8dzj9ab4m8hv5dpyx7zii8d0w6fi-glibc-2.39-52/lib64/ld-linux-x86-64.so.2 (0x00007ffff7fc7000)

The output with Musl (and obstack_vprintf removed):

  $ gcc -lobstack test-musl.c && ./a.out
  this text is appended
  $ ldd a.out
  	/nix/store/00w9nz0343pxk7hbsjzq9bzaby65hk4g-musl-1.2.3/lib/ld-musl-x86_64.so.1 (0x7ffff7f4b000)
  	libobstack.so.1 => /nix/store/qvv16dqn85qwz9vz9wvpnv435z0n5msr-musl-obstack-1.2.3/lib/libobstack.so.1 (0x7ffff7f3b000)
  	libc.so => /nix/store/00w9nz0343pxk7hbsjzq9bzaby65hk4g-musl-1.2.3/lib/ld-musl-x86_64.so.1 (0x7ffff7f4b000)
2024-09-17 11:32:48 +08:00
p-szafonimateusz
92cbb63fc8 arch/x86_64: add basic support for R_X86_64_REX_GOTPCRELX relocation
GOTPCRELX reloc available only for CONFIG_ARCH_ADDRENV=y

when CONFIG_ARCH_ADDRENV is not set, CONFIG_ARCH_TEXT_VBASE is not specified
so we can't relocate

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2024-09-17 03:20:03 +08:00
Huang Qi
3a677e3268 libc/netdb: Remove unnecessary CONFIG_LIBC_NETDB checks
Since it already checked by Make.defs and CMakeLists.txt

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2024-09-17 03:19:47 +08:00
Zhe Weng
f8bd93575c sched/wqueue: Fix unexpected dq entry status
When we do not drop notifier from g_notifier_pending, we need an
isolated dq entry for this queue, otherwise the queued work_s's dq entry
may be modified by the work queue and breaks the chain of
g_notifier_pending.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-09-17 02:56:39 +08:00
ligd
4d6203d4c6 wqueue: teardown should cancel the work already in wqueue
Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-17 02:56:39 +08:00
ligd
42b6dd0ff1 wqueue: extend the work_cancel_sync() return value
Return 1 to indicate the work was not cancelled.
Because it is currently being processed by work thread,
but wait for it to finish.

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-17 02:56:39 +08:00
ligd
f3ada4b666 wqueue: workaound g_notifier_pending list unsafe
Situation:

thread1                             thread2
work_notifier_signal
enter_critical_section
dq_peek(&g_notifier_pending)
    dq_rem(&g_notifier_pending)
    work_queue()
      // switch -->                 work_notifier_teardown
                                    enter_critical_section
                                    dq_rem(&g_notifier_pending)
                                    leave_critical_section
                                    <--- switch back
    error occured
leave_critical_section

Workaound:
used sched_lock() to prevent the switch

Signed-off-by: ligd <liguiding1@xiaomi.com>
2024-09-17 02:56:39 +08:00
dongjiuzhu1
1d5f43664d driver/pinctl: add pinctrl framework
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-17 02:25:47 +08:00
wanggang26
f6d378e528 enable O_CLOEXEC explicitly to avoid fd leak
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-09-17 02:07:34 +08:00
Karel Kočí
b04da1892e libs/libc/obstack: implement ptr and int growing functions
The new API is defined by GNU and implemented in other LibCs, such as
Musl.

This also modifies API of obstack_blank_fast and obstack_1grow_fast.
These are defined as returning void and thus return value here is
incompatibility with other implementations.
2024-09-17 02:00:46 +08:00
liaoao
4d35c60ba6 rpmsg_port_spi: set mreq to high to trigger next transmission
rpmsg_port_spi_connect can not be used here because peer may have not finished
the last transmission which will keep the sreq gpio in high level, and it will
read an error data frame.

Signed-off-by: liaoao <liaoao@xiaomi.com>
2024-09-17 01:55:51 +08:00
liaoao
88e0aeaad4 rpmsg_port_spi/slave: reorder rpmsg_port_initialize and rpmsg_port_spi_init hardware
Because the data transmision may has been started before
rpmsg_port_initialize(), this should be not allowed.

Signed-off-by: liaoao <liaoao@xiaomi.com>
2024-09-17 01:55:51 +08:00
liaoao
1f6ba6c7a7 rpmsg_port_spi: add pending logic for rpmsg port spi
To handle the situation that there is a req from peer side when
current transfer is not finished.

Signed-off-by: liaoao <liaoao@xiaomi.com>
2024-09-17 01:55:51 +08:00
liaoao
896f02bd67 rpmsg_port_spi: add nbits to spicfg
Support more spi config paramters for Rpmsg Port SPI/SPI Slave

Signed-off-by: liaoao <liaoao@xiaomi.com>
2024-09-17 01:55:51 +08:00
liaoao
d724ddce0b rpmsg_port_spi: discard messages when disconnected
Disconnected logic optimization

Signed-off-by: liaoao <liaoao@xiaomi.com>
2024-09-17 01:55:51 +08:00
yintao
968da8b781 drivers/rpmsg: Add edge_create and edge_destroy for router
use cmd to notify the other cpu to destroy router edge device,
and dont destroy the other cpu's "router:ept"

Signed-off-by: yintao <yintao@xiaomi.com>
2024-09-17 01:55:51 +08:00
Bowen Wang
76572f9892 rpmsg/rpmsg_port_uart: add rpmsg uart port driver
Rpmsg Port Uart is a new rpmsg transport layer.
Just like the rpmsg port spi, the difference is that the physical
communication method changed from SPI to UART.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-09-17 01:55:51 +08:00
liaoao
4827063958 rpmsg_port_spi: add spi slave support
The rpmsg port spi slave version support

Signed-off-by: liaoao <liaoao@xiaomi.com>
2024-09-17 01:55:51 +08:00
liaoao
89ce5d5e02 rpmsg_port_spi: add get_local_cpuname api
add get_local_cpuname ops for rpmsg_port_spi

Signed-off-by: liaoao <liaoao@xiaomi.com>
2024-09-17 01:55:51 +08:00
liaoao
6a6fc8d883 rpmsg_port_spi:init cs gpio to be low
Transfer will be failure when the cs gpio status is low before
the first transfer.

Signed-off-by: liaoao <liaoao@xiaomi.com>
2024-09-17 01:55:51 +08:00
yintao
6e55812e59 drivers/rpmsg: Add get_local_cpuname in router
get_local_cpuname ops support for rpmsg router

Signed-off-by: yintao <yintao@xiaomi.com>
2024-09-17 01:55:51 +08:00
liaoao
4a356f6f6d rpmsg_port_spi: do not decrease when rx avail is already 0
Bug fix about the rpmsg port spi

Signed-off-by: liaoao <liaoao@xiaomi.com>
2024-09-17 01:55:51 +08:00
yintao
3fb39c6fc9 drivers/rpmsg: Use optimal rx size and tx size
Use the minimal tx and rx size form two edge cpu to maintain
the transmit buffer size not exceed the edge cpus' buffer size.

[edg0] tx <---> rx0 [hub] rx1 <---> tx [edge1]
       rx <---> tx0       tx1 <---> rx

edge0_tx = min(rx0, tx1);
edge0_rx = min(tx0, rx1);

edge1_tx = min(rx1, tx0);
edge1_rx = min(tx1, rx0);

Signed-off-by: yintao <yintao@xiaomi.com>
2024-09-17 01:55:51 +08:00
Bowen Wang
ab47465dd5 drivers/rpmsg: add get_local_cpuname to rpmsg ops
Add get_local_cpuname to the rpmsg framework ops to support communicate
with the same remote core with multi rpmsg transport.

Some rpmsg services will send local cpu name to remote core and then let
remote core to connect local core by using this cpu name, when there are
multi rpmsg channels with same remote core, the remote core may connect
to incorrect core, so use the error rpmsg channel.

For example, there are two rpmsg channels between ap and audio:

ap core                     audio core
 [ap1] <-- rpmsg virtio1 --> [audio1]
 [ap2] <-- rpmsg virtio2 --> [audio2]

When we want to use the rpmsg virtio1 to communicate, ap core may send
local cpuname "ap2" to audio, so the audio core use remote cpu "ap2" to
connect with ap, and resulting in the use of incorrect rpmsg channel.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-09-17 01:55:51 +08:00
yintao
7bc7369102 drivers/rpmsg: Use tx buffer size as payload length
Directly use tx length received from hub as the tx payload length.

Signed-off-by: yintao <yintao@xiaomi.com>
2024-09-17 01:55:51 +08:00
yintao
7c933874e8 drivers/rpmsg: add rpmsg router support
Rpmsg Router is new rpmsg transport layer, it can router the rpmsg
messages to a cpu that not directly connected with local cpu by Rpmsg,
For the rpmsg services, it is as if there is a real Rpmsg Channel between
the local cpu and the remote cpu.

For examples, there are three cpus: ap, cp and audio.
ap and cp, ap and audio has share memory and be connected by Rpmsg VirtIO,
so ap and cp, ap and audio can communicate with each other by Rpmsg, but
cp can not communicate with audio direclty.

[cp] <-- rpmsg virtio --> [ap] <-- rpmsg virtio --> [audio]

With rpmsg router, the cp can communicate with audip by Rpmsg dereclty because
the router in ap will forward the rpmsg message from cp/audio to audio/cp, like
this:

 +<----- rpmsg router --> hub  <-- rpmsg router ------>+
 |                         |                           |
[cp] <-- rpmsg virtio --> [ap] <-- rpmsg virtio --> [audio]

Signed-off-by: yintao <yintao@xiaomi.com>
2024-09-17 01:55:51 +08:00
Bowen Wang
a662c7aab3 rpmsg/rpmsg_port: judge notify_rx_free and notify_tx_ready before calling
Some lower layers do not need implement these two operations, so judge
them before calling.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-09-17 01:55:51 +08:00
Bowen Wang
d27a9c516f rpmsg/Kconfig: move RPMSG_PORT outside RPMSG and select RPMSG direclty
All the RPMSG transport should direcly select the RPMSG like RPMSG_VIRTIO
does.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2024-09-17 01:55:51 +08:00
liaoao
f7939a8081 rpmsg_port_spi: add spi transport layer
Add Rpmsg-Port-SPI transport layer.
Rpmsg Port SPI is a new rpmsg transport layer based on the Rpmsg Port,
it provides the capability for two SPI-connected (and two extra GPIO)
chips to communicate with each other using Rpmsg.

All already implemented Rpmsg Services can be used with this new transport
layer without any modifications.

Signed-off-by: liaoao <liaoao@xiaomi.com>
2024-09-17 01:55:51 +08:00
liaoao
dd66a6b203 rpmsg_port:reduce len and avail of rpmsg_port_header_s to uint16_t
uint16_t is enough and more suitable

Signed-off-by: liaoao <liaoao@xiaomi.com>
2024-09-17 01:55:51 +08:00
liaoao
3d6abb1d86 rpmsg_port:add rpmsg_port_queue_nused api
Add nused api for lower layer to get the used buffer number

Signed-off-by: liaoao <liaoao@xiaomi.com>
2024-09-17 01:55:51 +08:00
liaoao
6d604ec487 rpmsg: add physical transport layer support
Rpmsg Physical Transport Layer is a new rpmsg transport, it's a
common part for the physical communication based rpmsg transport
layers such as Rpmsg-SPI and Rpmsg-Uart.

It implements three common parts:
1. Implement the NuttX and OpenAMP rpmsg frameworks' ops and the
rpmsg name service;
2. The buffer management and provide some APIs to lower layer to use;

Signed-off-by: liaoao <liaoao@xiaomi.com>
2024-09-17 01:55:51 +08:00
p-szafonimateusz
1e212981b9 drivers/net: add support for Intel I225 network card
add support for Intel I225 network card

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2024-09-17 01:42:38 +08:00
p-szafonimateusz
bc0c7b0db3 drivers/net: add Intel e1000 network card support
add Intel e1000 network card support

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2024-09-17 01:42:38 +08:00
Jorge Guzman
e3dabcd999 boards/esp32s3: add support to esp32s3-lhcbit board
The esp32s3-lhcbit is a board with lora, sdcard, display TFT, etc.

Signed-off-by: Jorge Guzman jorge.gzm@gmail.com
2024-09-17 01:30:44 +08:00
p-szafonimateusz
8723aa7125 drivers: fix gcc14 errors for virtio
fix gcc14 errors for virtio

Signed-off-by: p-szafonimateusz <p-szafonimateusz@xiaomi.com>
2024-09-16 11:25:40 -03:00
wanggang26
584931aa0d fix two typos
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-09-16 11:25:10 -03:00
wanggang26
89e5ceb51e vfs:fix a type mismatch issue and a typo
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-09-16 11:24:56 -03:00
wanggang26
0a8b6404d8 rwbuffer: fix a typo
Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-09-16 09:22:23 -03:00
wanggang26
872208fdf8 boardctl: add board control api to start slave core
This interface may be used by application specific logic to start
specified slave cpu core under the pseudo AMP case which is different
with armv7-a/armv8-a SMP. Support for this function is required by
board-level logic if CONFIG_BOARDCTL_START_CPU is selected.

Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-09-16 13:03:33 +08:00
dongjiuzhu1
d2591380ae Revert "fs/mount and fs/romfs: Add support to mount a ROMFS volume using an MTD driver interface using the standard mount() operation."
This reverts commit 5708a1ac73.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-16 12:27:40 +08:00
dongjiuzhu1
ace2683492 fs/mount: add ftl proxy to mount block filesystem on mtd device
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-16 12:27:40 +08:00
Matteo Golin
9d1e7a0510 docs: Update Raspberry Pi Pico and Pico W docs to include the new SDK version and picotool instructions. 2024-09-16 12:22:17 +08:00
wanggang26
a4883d8fa6 nucleo-h745zi: fix potential bl jump to app failed issue
After changing sp, following functions calling will result
in unpredictable behavior in case of jumping

Signed-off-by: wanggang26 <wanggang26@xiaomi.com>
2024-09-16 12:20:47 +08:00
dongjiuzhu1
7f99a15ccf libc/time: add g_lcl_lock to protect local context in localsub
0x0c1561f8 in localsub (tmp=0x3c887088, offset=0, timep=0x3c887078) at time/lib_localtime.c:1993
localtime_r (timep=0x3c887078, timep@entry=0x3c887088, tmp=0x3c887088, tmp@entry=0x3c887098) at time/lib_localtime.c:2819
0x0c1225c8 in nx_vsyslog (priority=7, fmt=0x2c6d9700 <error: Cannot access memory at address 0x2c6d9700>,
ap=0x3c887170, ap@entry=0x3c887178) at syslog/vsyslog.c:135
0x0c152068 in vsyslog (priority=priority@entry=7,
fmt=fmt@entry=0x2c6d9700 <error: Cannot access memory at address 0x2c6d9700>, ap=ap@entry=...) at syslog/lib_syslog.c:68
0x0c152098 in syslog (priority=priority@entry=7, fmt=0x2c6d9700 <error: Cannot access memory at address 0x2c6d9700>) at syslog/lib_syslog.c:100

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-16 10:35:17 +08:00
dongjiuzhu1
a9bc198bc3 composite.c warning
usbdev/composite.c:649:36: warning: implicit declaration of function 'board_usbdev_pid' [-Wimplicit-function-declaration]
649 | uint16_t pid = board_usbdev_pid(); usbdev/composite.c:650:36: warning: implicit declaration of function 'board_usbdev_vid'
[-Wimplicit-function-declaration] 650 | uint16_t vid = board_usbdev_vid();

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-16 10:33:01 +08:00
dongjiuzhu1
e0d82fdf3a drivers/usedev: remove unnecessary mdelay because remain req info had beed push to serial buffer
this mdelay causes cpu busy wait, affects other process running.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-16 10:33:01 +08:00
dongjiuzhu1
1a69d3c6ee cdcacm: Add cdcacm bulkout request buffer config
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2024-09-16 10:33:01 +08:00
hujun5
c16fd8c911 gicv2:g_gic_init_done need to be protect
Signed-off-by: hujun5 <hujun5@xiaomi.com>
2024-09-16 10:30:41 +08:00