Commit Graph

6765 Commits

Author SHA1 Message Date
Lwazi Dube 1349dcfc1f drivers/usbhost: Add a USB bluetooth driver.
This change adds support for the USB Transport Layer as described
in the bluetooth spec. Isochronous endpoints are not yet supported.
Because of limitations in the NuttX bluetooth stack, only one USB
device can be used. This driver will only allow one USB dongle to
use bluetooth.

A Laird USB BT4.2 dongle (from Mouser) was used for testing:
M/N BT851 1.0 1829, FCC ID:SQGBT850
lsusb: 04b4:f901 Cypress Semiconductor Corp. CYW20704A2

The following commands were used to test from the nsh prompt:
bt bnep0 scan start
bt bnep0 scan stop
bt bnep0 scan get
bt bnep0 info

The Linux gatttool was used to connect over wireless.

With the BDAddr found by "bt bnep0 info", start gatttool using:
gatttool -b BDAddr -I

Connect to the device using:
connect

Read the device name using the GAP device name UUID:
char-read-uuid 2a00

Part of the response is:
value: 41 70 61 63 68 65 20 4e 75 74 74 58
which is the string "Apache NuttX"
2024-01-16 16:02:15 +01:00
wangyongrong 7508a10e20 rptun: Strip rpmsg and rptun
nuttx/driver/rpmsg: new folder, extract common rpmsg api in rptun.c to rpmsg.c.
rpmsg provide rpmsg_ops to each backend for specific implementation.

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-01-16 15:58:32 +01:00
wangyongrong df147406db rptun_ping: decoupling rptun ping and rptun.
ping is not only rptun support, so move it to public part.

Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-01-14 23:06:51 -08:00
fangxinyong c479ccb8aa sched: move etc romfs mount from nsh to sched/init
Usually the startup script is placed under /etc. The contents of the etc directory
are compiled and linked with Nuttx binary in the form of romfs. After startup,
it will be  mounted by Nsh.

etc is generated by the different boards, that use genromfs and xxd tools to generate
and compile it into the Nuttx, for example: boards/arm/at32/at32f437-mini/tool/mkromfs.sh
The more common method is etc image generated from the content in the corresponding
board/arch/board/board/src/etc directory, and added by Makefile for example:
boards/sim/sim/sim/src/etc.

But in kernel/protected mode, Nuttx kernel and apps are run in different privileged/
non-privileged mode or the isolated binarys, so as that nsh should use syscall to
access Nuttx kernel by exported API. In this scenario, nsh can not mount the etc image
content, because that is generated in board and as a part of Nuttx kernel.

changes:

- move etc romfs mount from nsh to Nuttx, but keep the script to parse and execute.
- move and rename the related CONFIG, move customized nsh_romfsimg.h to etc_romfs.c
  in boards, and no need declaration for romfs_img/romfs_img_len.

This commit changes and updates all configurations in Nuttx arch/board as much as possible,
but if any missing, please refer to the following simple guide:

- rename CONFIG_NSH_ROMFSETC to CONFIG_ETC_ROMFS, and delete CONFIG_NSH_ARCHROMFS in defconfig
- rename the etc romfs mount configs, for example CONFIG_NSH_FATDEVNO to CONFIG_ETC_FATDEVNO
- move customized nsh_romfsimg.h to etc_romfs.c in board/arch/board/board/src and no need
  declaration for romfs_img/romfs_img_len.
- delete default nsh_romfsimg.h, if ROMFSETC is enabled, should generate and compile etc_romfs.c
  in board/arch/board/board/src.

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
2024-01-09 21:29:46 -03:00
wyr8899 df09e40e3a rptun ping: support data checksum and data transfer rate calculation
Signed-off-by: wangyongrong <wangyongrong@xiaomi.com>
2024-01-09 06:06:40 -08:00
Zhe Weng 3b74cfecc2 net/route: Support longest prefix match for routing
Support longest prefix match routing described as "Longest Match" in
RFC 1812, Section 5.2.4.3, Page 75.

Introduced `prefixlen` to indicate the prefix length of currently
founded route, and only looks up for longer prefix in all later steps.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2024-01-09 05:58:10 -08:00
David Sidrane 93f37ab1da net:Add support for multi PHY
Support runtime phy selection based on a list
   supplied by board.h
   For Example:

   #define BOARD_ETH0_PHY_LIST                   \
	{                                        \
		"LAN8742A",                      \
		MII_PHYID1_LAN8742A,             \
		MII_PHYID2_LAN8742A,             \
		MII_LAN8740_SCSR,                \
		0,                               \
		0xffff,                          \
		MII_LAN8720_SPSCR_10MBPS,        \
		MII_LAN8720_SPSCR_100MBPS,       \
		MII_LAN8720_SPSCR_DUPLEX,        \
		22,                              \
	},                                       \
	{                                        \
		"TJA1103",                       \
		MII_PHYID1_TJA1103,              \
		MII_PHYID2_TJA1103,              \
		0xffff,                          \
		18,                              \
		0xffff,                          \
		0,                               \
		MII_LAN8720_SPSCR_100MBPS,       \
		MII_LAN8720_SPSCR_DUPLEX,        \
		45,                              \
	},                                       \
2024-01-06 04:26:12 -08:00
TimJTi 222ca5b040 Add MTD for AT25 eeprom 2024-01-04 09:25:52 -08:00
YAMAMOTO Takashi 1ec63e1701 make 64-bit time_t back to unsigned
it has been changed by https://github.com/apache/nuttx/pull/10303
without any explicit mentions. i suppose it was a mistake.

see https://github.com/apache/nuttx/pull/8201 and referenced PRs
for previous discussions.
2023-12-30 08:48:43 -08:00
yinshengkai 9852428953 fs: procfs add poll support
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-12-26 19:23:13 -08:00
yinshengkai ca99e69c28 fs: update hostfs structure definition
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-12-26 17:41:12 -08:00
yinshengkai 9b10255088 fs: fix structure layout inconsistency in hostfs
Use the following command to view the structure layout:
pahole nuttx > struct_size.h

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-12-26 17:41:12 -08:00
YAMAMOTO Takashi 992719730f Fix hostfs after uid/gid changes
This fixes a regression in https://github.com/apache/nuttx/pull/10869
2023-12-25 19:40:47 -08:00
yinshengkai 81fccf96db libc/stream: add file out stream
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-12-25 16:54:16 -03:00
yinshengkai 0c95bf73dc libc/stream: provide lowerout_stream default initialization function
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-12-25 16:54:16 -03:00
Tiago Medicci Serrano d1326e81bc drivers/leds/ws2812: Fix WS2812 pixel size
Although the LED might be RGB-only, the LED data is packed in a
32-bit long variable and, then, this is the default size of a LED
pixel to define the 'WS2812_RW_PIXEL_SIZE' macro. Please note that
the lower-half driver will deal with the case of the addressable
LED being 3 or 4-pixel sized.
2023-12-24 16:38:06 -08:00
Tiago Medicci Serrano fcff5d43b7 drivers/rmt: Implement an upper-half RMT character driver
The RMT (Remote Control) character driver allows to use the RMT
peripheral (usually, a one-wire peripheral dedicated to driving
IR remote control) as a character driver.

Please note that this perpiheral depends on the lower-half specific
driver implementation.
2023-12-24 16:38:06 -08:00
Jukka Laitinen ebe961df9e drivers/net/ksz9477: Add simple port-based static VLAN configuration
Add a static port-based VLAN configuration for KSZ9477 switch. This doesn't
use the VLAN tagging, but is a switch's internal mechanism to simply configure
if the packet forwarding is allowed from one port to another.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2023-12-20 01:30:54 -08:00
jianglianfang 2a92748c42 drivers/goldfish_fb: optimize goldfish fb register
The Goldfish FB register should be optimized by considering the need to pass in parameters for base and irq.

Signed-off-by: jianglianfang <jianglianfang@xiaomi.com>
2023-12-18 09:08:32 -08:00
jianglianfang f4c8a17837 sim_lcd: add open & close
The opening and closing of the window has been associated with the opening and closing of fb, but the LCD has not yet been optimized. The window will only open when sim_x11openwindow is called, and similarly, the window will only close when sim_x11closewindow is called.

Signed-off-by: jianglianfang <jianglianfang@xiaomi.com>
2023-12-18 09:06:29 -08:00
guoshichao b3867d5230 libs/libc/wchar: add ungetwc implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-12-17 01:39:06 -08:00
guoshichao 0b2f7f7f3c libs/libc/wchar: add getwc implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-12-17 01:39:06 -08:00
guoshichao 8c37c3841b libs/libc/wchar: add fgetwc implementation
Signed-off-by: guoshichao <guoshichao@xiaomi.com>
2023-12-17 01:39:06 -08:00
liqinhui 98e3615b60 net/netdev: Modify the logic for setting the IFF_RUNNING status of interfaces.
Refer to the logic of the `netif_carrier_on` on linux.
https://github.com/torvalds/linux/blob/master/net/sched/sch_generic.c#L575

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2023-12-15 18:24:23 -08:00
liqinhui 6a8c638d57 qemu/wifi: Add the virtual wifi function on the emulator.
-The qemu wifi fucntion only supports the STA mode and the following
 operations:
 wapi mode wlan0 2
 wapi scan wlan0
 wapi psk wlan0 password 3
 wapi essid wlan0 wifi_name 1
 wapi show wlan0
 wapi disconnect wlan0
-Eanble the virtual wifi function with the MACRO `CONFIG_DRIVERS_WIFI_SIM`.

Signed-off-by: liqinhui <liqinhui@xiaomi.com>
2023-12-14 20:22:12 -08:00
Ville Juven e03599d9ae libs/log2ceil: Move implementation of log2ceil to a common place
Move log2ceil from riscv_pmp to libc. Also, implement log2floor for
completeness.

These are the run-time alternative to the compile-time macros.
2023-12-14 08:46:12 -08:00
simbit18 9d50d180b1 Fix nuttx coding style
Remove spaces
Remove extra */
2023-12-13 17:29:08 +01:00
Petteri Aimonen c3a234fe99 ipv6: Fix source address with many addresses in same network
Previously ipv6 multi-address support decided packet source
address based on its destination. This doesn't work if NuttX
device has multiple addresses within same subnet.

Instead when a packet is a response to existing connection,
the source address should be based on the destination address
used in the received packet.
2023-12-13 06:13:25 -08:00
Ville Juven 996625ec58 riscv/arch_elf.c: Handle PCREL_HI20/LO12_I/S relocations correctly
There is a problem with the current elf loader for risc-v: when a pair of
PCREL_HI20 / LO12 relocations are encountered, it is assumed that these
will follow each other immediately, as follows:

label:
	auipc      a0, %pcrel_hi(symbol)    // R_RISCV_PCREL_HI20
	load/store a0, %pcrel_lo(label)(a0) // R_RISCV_PCREL_LO12_I/S

With this assumption, the hi/lo relocations are both done when a hi20
relocation entry is encountered, first to the current instruction (addr)
and to the next instruction (addr + 4).

However, this assumption is wrong. There is nothing in the elf relocation
specification[1] that mandates this. Thus, the hi/lo relocation always
needs to first fixup the hi-part, and when the lo-part is encountered, it
needs to find the corresponding hi relocation entry, via the given "label".
This necessitates (re-)visiting the relocation entries for the current
section as well as looking for "label" in the symbol table.

The NuttX elf loader does not allow such operations to be done in the
machine specific part, so this patch fixes the relocation issue by
introducing an architecture specific cache for the hi20 relocation and
symbol table entries. When a lo12 relocation is encountered, the cache
can be consulted to find the hi20 part.

[1] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc
2023-12-12 17:32:36 -08:00
Xiang Xiao ca5a9c711a Remove @ and % tag from all comments
and format the multiple line comments

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-12-11 17:00:10 -03:00
anjiahao bf03bb557f support gdbstub use serial.
we can use uart to debug nuttx,like debugger:

1. read/write memory
2. Use watchpoint,breakpoint,single step.
    use up_debugpoint api

3. Ctrl+c to stop, continue, or single step.
    hold uart send and receive

4. register a panic event, when crash or assert/panic, we use uart to
   debug.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-12-11 08:43:26 -08:00
anjiahao bb0a706bdc arch/arm:add up_debugpoint api
on armv8-m/armv7-m,implement breakpoint & watchpoint using FBP & DWT

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-12-11 08:43:26 -08:00
anjiahao 94d449e722 arch:Mark key functions to prohibit instrumentation to prevent recursive calls
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-12-11 02:06:51 -08:00
anjiahao d932e0af2a sched/procfs:use instrument to statistics run time max stack
Usage:
1. CONFIG_FS_PROCFS_MAX_STACK_RECORD > 0, such as 32,
2. add '-finstrument-functions' to CFLAGS for What you want to check
   stack.
3. mount porcfs
4. cat /proc/<pid>/stack will print backtace & size

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-12-11 02:06:51 -08:00
anjiahao 7dfbd14eba libc: add instrument api support
Add registration function instrumentation API,
which can achieve instrumentation of entering and
exiting functions through the compiler's functionality.

We can use CONFIG_ARCH_INSTRUMENT_ALL to add instrumentation for all
source, or add '-finstrument-functions' to CFLAGS for Part of the
source.

Notice:
1. use CONFIG_ARCH_INSTRUMENT_ALL must mark _start or entry noinstrument_function,
   becuase bss not set.
2. Make sure your callbacks are not instrumented recursively.

use instrument_register to register entry function and exit function.
They will be called by the instrumented function

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-12-11 02:06:51 -08:00
Bowen Wang 449197c188 virtio.h: add virtio_has_feature api for virtio driver
Virtio driver can used this api to judge whether the this feature
is supported by both virtio driver and device.

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
2023-12-10 21:54:56 -08:00
anjiahao 35051dd715 coredump: support coredump save to block device when crash
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-12-10 07:02:03 -08:00
anjiahao 542a5555d3 libc:add parse_memory_range to parse memory string
Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2023-12-10 07:02:03 -08:00
Petteri Aimonen 99a8c00807 usbdev: Add callback for CONFIG_USBDEV_SOFINTERRUPT
Previously CONFIG_USBDEV_SOFINTERRUPT existed in many platform
drivers but did nothing. This commit adds a callback function
usbdev_sof_irq() that can be used to take action on this interrupt.
2023-12-08 21:27:36 -03:00
Dong Heng bf54a5ae50 driver/net/lan9250: Add LAN9250 driver(SPI and QSPI mode) 2023-12-07 19:53:05 -08:00
Zhe Weng bffe858e47 fs/proc: Fix groupfd to get fd by group instead of current tcb
/proc/<pid>/group/fd should read the fds of <pid>, not current tcb.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
2023-12-04 21:37:28 -08:00
Petro Karashchenko a3cd8f921a arch/arm/samv7/sam_emac: Implement errata workaround for KSZ8061 PHY
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
2023-12-04 00:37:43 -08:00
shizhenghui 49398d32aa move userspace interface from video.h to sys/videoio.h
Signed-off-by: shizhenghui <shizhenghui@xiaomi.com>
2023-12-02 19:44:39 -08:00
wangzhaofeng 1967b8432a copy part of linux videodev2.h which is used in v4l2m2m
Signed-off-by: wangzhaofeng <wangzhaofeng@xiaomi.com>
2023-12-02 19:44:39 -08:00
chenrun1 a6dc4412ba misc/rwlock:Implementing read/write locks.
A new locking mechanism: read/write locks
When there is a writer it is not possible to put on a read lock or a write lock; when there is a reader it is possible to reenter the read lock but not the write lock.
Writers are exclusive locks, readers are shared locks.
At the same time through the waiter count to determine whether there is currently a blocked task, if there is then in the unlock time to wake up all the waiter, through the priority of the competition to complete the blocked lock execution.
For example:
When we have a reader blocking two waiter writers, when the reader is unlocked it wakes up both writers. The writer with higher priority wakes up and checks for a successful condition and locks the lock, the second writer wakes up and fails to check for a condition and continues to block the lock.

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2023-12-02 19:43:19 -08:00
chenwen@espressif.com 53beaf1a67 xtensa/esp32s3: Add SPIRAM high memory support
1. Configurable mapping of virtual address to psram physical address
  2. Access SPIRAM memory at high physical address through bank switching

Signed-off-by: chenwen@espressif.com <chenwen@espressif.com>
2023-11-29 06:33:51 -08:00
Michal Lenc eea7db24f3 libc: add support for open_memstream
Adds support for POSIX interface open_memstream() that allows writing
to dynamic memory buffer stream. The stream is dynamically reallocated
as the buffer grows with initial size set to zero.

The caller has to free the buffer after the stream is closed.

The implementation uses fopencookie() for custom stream operations and
callbacks.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2023-11-29 02:13:19 -08:00
yaojingwei a57e3f365a video.c: modify set_buf call seqence in start_capture function.
To avoid losing the first frame, the set_buf needs to excute first. At the same time, imgdata->start_capture should excuted before the imgsensor->start_capture.

Signed-off-by: yaojingwei <yaojingwei@xiaomi.com>
2023-11-29 02:01:34 -08:00
Takumi Ando 3353bd3ced sensors: mx5611: Add support for MS5607
MS5607 has few differences between MS5611.

Signed-off-by: Takumi Ando <t-ando@advaly.co.jp>
2023-11-28 16:48:50 -03:00
Ville Juven e39ef8563e semaphore/_SEM_XX: Remove the _SEM redirection macros as unnecessary 2023-11-27 04:52:54 -08:00