Commit Graph

5255 Commits

Author SHA1 Message Date
dongjiuzhu1 e88a36fa92 libs/modlib: Adding architecture-specific memory allocator for dynamic data loading
Arch can specific the memory allocator for data to optimize access speed.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
2023-10-26 01:53:38 +08:00
Ville Juven ab78e3817a sched/task_[posix]spawn: Simplify how spawn attributes are handled
Handle task spawn attributes as task spawn file actions are handled.

Why? This removes the need for sched_lock() when the task is being
spawned. When loading the new task from a file the scheduler can be
locked for a VERY LONG time, in the order of hundreds of milliseconds!

This is unacceptable for real time operation.

Also fixes a latent bug in exec_module, spawn_file_actions is executed
at a bad location; when CONFIG_ARCH_ADDRENV=y actions will point to the
new process's address environment (as it is temporarily instantiated at
that point). Fix this by moving it to after addrenv_restore.
2023-10-25 11:55:44 -03:00
jinxiuxu cd851b3144 audio: add amr format support
Signed-off-by: jinxiuxu <jinxiuxu@xiaomi.com>
2023-10-25 13:33:21 +08:00
Stuart Ianna ac5800386c arch/risc-v/litex/litex_emac: Add support for KSZ8061 ethernet PHY.
Adds support for using the microchip KSZ8061 ethernet PHY instead of the default DP83848C.
2023-10-25 13:33:03 +08:00
Xiang Xiao 66db15437d libc/stdio: Change FILE buffer field from "unsigned char *" to "char *"
to avoid the unnecessary casting

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-22 21:18:46 +03:00
zhanghongyu 3ad28c28aa usrsock: Make the field of usrsock_request native alignment
There is a risk that interfaces such as psock_ioctl/psock_setsockopt
will cause paramete to be not four-byte aligned after calculating the
offset, so align the length of the structure with parameters by four
bytes.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
2023-10-21 10:55:30 +08:00
Michal Lenc 0a107ca6d9 libc: add support for custom streams with fopencookie()
This commit adds support for custom stream via fopencookie function.
The function allows the programmer the create his own custom stream
for IO operations and hook his custom functions to it.

This is a non POSIX interface defined in Standard C library and implemented
according to it. The only difference is in usage of off_t instead of
off64_t. Programmer can use 64 bits offset if CONFIG_FS_LARGEFILE is
enabled. In that case off_t is defined as int64_t (int32_t otherwise).

Field fs_fd is removed from file_struct and fs_cookie is used instead
as a shared variable for file descriptor or user defined cookie.

The interface will be useful for future fmemopen implementation.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2023-10-18 21:13:01 +08:00
zhangyuan21 34412349e9 sched: add smp function call
Support smp function call, calling smp_call_function allows
a specific core to execute a function. It should be noted
that there should be no waiting operations in the executed
function.

Signed-off-by: zhangyuan21 <zhangyuan21@xiaomi.com>
2023-10-18 09:57:50 +08:00
makejian be72a6e26f math/mpi: add mpi driver in math
add interface for MPI(Multiple Precision Integer) registration in /math/mpi
Signed-off-by: makejian <makejian@xiaomi.com>
2023-10-17 13:43:43 +08:00
Xiang Xiao b1c8c84e81 stdio: Merge fs_fdopen into fdopen to simplify the code logi
since fs_fdopen could avoid call the kernel specific function now

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-17 13:34:00 +08:00
Xiang Xiao b0d197534f stdio: Move lib_stream_[initialize|release] from libc/stdio to sched/tls
both functions aren't suitable to be put into libc,
because they call the kernel internal functions directly.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-17 13:34:00 +08:00
yinshengkai 58c6b60df5 note: remove remaining event code
Some event-related codes were missed in the previous modification and have not been deleted.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-10-17 09:07:06 +08:00
Simon Filgis 882afc885e channel gain switching in aefc by ioctl
Update arch/arm/include/samv7/sam_afec.h

remove "offset may be uninitialized" warning

Update arch/arm/include/samv7/sam_afec.h

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

Update arch/arm/include/samv7/sam_afec.h

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

Update arch/arm/src/samv7/sam_afec.c

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

Update arch/arm/src/samv7/sam_afec.c

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

Update arch/arm/include/samv7/sam_afec.h

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

Update arch/arm/include/samv7/sam_afec.h

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

remove blank line
2023-10-16 21:55:40 +08:00
Philippe Leduc 98b15b1409 Cleanup interface and a4988 implementation
Change step frequency from step/ms to step/s
Add DRV8825 stepper driver
2023-10-16 08:55:53 +08:00
TaiJu Wu e28fcbd777 fix: Mac sim-02 compiler issue
This path just for modify Mac sim-02 issue.
The compiler require the firt paramter of atomic_compare_exchange_strong
is atomic type and second parameter is int type.

Signed-off-by: TaiJu Wu <tjwu1217@gmail.com>
2023-10-16 08:55:01 +08:00
TaiJu Wu 68a4d3df7e spinlock: implement read writer spinlock
spinlock.c:
Implement read write spinlock.
Readers can take lock simultaneously but only one writer can take lock.

irq_spinlock.c:
Align g_irq_spin_count.
If the lock is NULL, the caller will get global lock (e.g. g_irq_spin) and spin_lock_irqsave() support nest on the same CPU.
If the CPU can write lock, it can call write_lock_irqsave() again (e.g. support nest).

Signed-off-by: TaiJu Wu <tjwu1217@gmail.com>

Co-authored-by: David Sidrane <David.Sidrane@Nscdg.com>
2023-10-16 08:55:01 +08:00
Philippe Leduc 095c32b0eb Add a stepper generic upperhalf driver
Add a stepper A4988 lowerhalf driver
2023-10-14 12:28:41 -04:00
hujun5 061be5f18e refine: move BIT Macro to nuttx/bits.h
The BIT macro is widely used in NuttX,
and to achieve a unified strategy,
we have placed the implementation of the BIT macro
in bits.h to simplify code implementation.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
2023-10-12 14:52:56 +08:00
yinshengkai 9c59ee7c58 note: optimize note performance and reduce lib_sprintf calls
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-10-12 00:15:14 +08:00
yinshengkai 8ddaa3460d note: simplify the shced_note header file
This is to simplify the header file. It uses too many macros, and many of them are unnecessary.

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-10-12 00:15:14 +08:00
Ville Juven d199264dca kmm_map: Fix incorrect function name field 2023-10-09 18:59:43 +03:00
Xiang Xiao 28dee592a3 video/fb: Add fb_register_device
so the user could register fb device directly instead
go through the sequence of up_fbinitialize/up_fbgetvplane

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-09 13:18:36 +03:00
Xiang Xiao c775ee1002 spinlock: Add spin_lock_init macro like Linux
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-06 20:03:19 -04:00
Xiang Xiao dfa0283d83 spinlock: Rename spin_islocked to spin_is_locked
align with Linux naming style

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-06 20:03:19 -04:00
TaiJu Wu ffba0d15a5 Feature: implement ticket spinlock
test config: ./tools/configure.sh -l qemu-armv8a:nsh_smp

Pass ostest

No matter big-endian or little-endian, ticket spinlock only check the
next and the owner is equal or not.

If they are equal, it means there is a task hold the lock or lock is
free.

Signed-off-by: TaiJu Wu <tjwu1217@gmail.com>

Co-authored-by: Xiang Xiao <xiaoxiang781216@gmail.com>
2023-10-07 01:38:37 +08:00
laoniaokkk aec0271e48 max31865:RTD-to-Digital Converter 2023-10-06 21:15:21 +08:00
yinshengkai ddb87d3b86 clock: replace all up_perf_xx with perf_xx
Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-10-02 16:11:43 +02:00
yinshengkai b99820744c timer: handle perf count overflow
clock_getcycle always returns an incremented cycle value
If the hardware does not support perf event it will use arch_alarm's up_perf_gettime

Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
2023-10-02 16:11:43 +02:00
Ville Juven 51f8611fc0 mm/kmap: Change kmm_user_map to kmm_map_user
Naming consistency wrt kmm_map_user_page
2023-09-29 21:06:16 +08:00
Xiang Xiao a37759a6a9 drivers/ioexpander: Add const to the value array of multiwritepin
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-09-28 10:09:51 +08:00
xucheng5 366628bf5a dma: support source/destination address auto step
Signed-off-by: xucheng5 <xucheng5@xiaomi.com>
2023-09-27 00:47:02 +08:00
likun17 f99b1a41a3 nuttx/drivers: add regmap subsystems support.
regmap: add i2c and spi bus support.

Signed-off-by: likun17 <likun17@xiaomi.com>
2023-09-27 00:46:51 +08:00
ligd dc096f951e list: update list.h
The function name comes from list.h inside Linux,
but rewrite from scratch to avoid the copyright issue.
Since many developers are familiar with Linux list API.

Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-09-26 00:15:21 +08:00
Jiuzhu Dong 032a5c75a4 drivers/sensors/: Add coordinate conversion function
convert from body coordinate system to right-hand
coordinate system.

Example:
Compared to the standard coordinate system,
the x-axis and y-axis are interchanged and have opposite directions,
the z-axis remains normal.

  body coordinate   ---->     right-hand coordinate
              +x               +y
               |                |
               |                |
               |                |
               |                |
     -y<-------.                .------>+x
              /                /
             /                /
            /                /
           /                /
         +z                +z

So for the above conversion, using "P3" to represent transformation relationships
The front is 1 0 2, which represents the y x z axis.
The standard order is 0 1 2, so y and x are interchanged.

The following -1 1 1 indicates the direction of the axis.
The standard is 1 1 1. Because the current y-axis is opposite to
the standard x-axis, it is -1.

static const struct sensor_axis_map_s g_remap_tbl[] =
{
  { 0, 1, 2,  1,  1,  1 }, /* P0 */
  { 1, 0, 2,  1, -1,  1 }, /* P1 */
  { 0, 1, 2, -1, -1,  1 }, /* P2 */
  { 1, 0, 2, -1,  1,  1 }, /* P3 */
  { 0, 1, 2, -1,  1, -1 }, /* P4 */
  { 1, 0, 2, -1, -1, -1 }, /* P5 */
  { 0, 1, 2,  1, -1, -1 }, /* P6 */
  { 1, 0, 2,  1,  1, -1 }, /* P7 */
};

you can call the function sensor_remap_vector_raw16 and pass P3 parameters
to perform the conversion.

Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
2023-09-24 11:01:08 +08:00
ligd 13f0051747 mm: rewrite the memdump code for more readable
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-09-24 10:39:18 +08:00
ligd cb94f825af kasan: add builtin_return_address(0) to kasan
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-09-24 03:48:39 +08:00
guohao15 2bce0f404c fs:add syncfs api for sync whole fs data
Signed-off-by: guohao15 <guohao15@xiaomi.com>
2023-09-23 15:58:00 +08:00
Shanmin Zhang 582e0ab51f goldfish: add goldfish sensors driver
Implemented Goldfish Sensors:
Accelerometer
Gyroscope
MagneticField
AmbientTemperature
Proximity
Light
Pressure
RelativeHumidity
MagneticFieldUncalibrated
GyroscopeFieldUncalibrated
HeartRate

Unimplemented Goldfish Sensors:
(sensor type is not defined nuttx)
Orientation
HingeAngle0
HingeAngle1
HingeAngle2
WristTilt

Verification:
uorb_listener -r 1 sensor_accel
uorb_listener -r 1 sensor_mag
uorb_listener -r 1 sensor_gyro
uorb_listener -r 1 sensor_prox
uorb_listener -r 1 sensor_light
uorb_listener -r 1 sensor_humi
uorb_listener -r 1 sensor_baro
uorb_listener -r 1 sensor_temp
uorb_listener -r 1 sensor_hrate

Signed-off-by: Shanmin Zhang <zhangshanmin@xiaomi.com>
2023-09-23 15:20:25 +08:00
dulibo1 b57e43b4d0 clk:fix some issues when use rpmsg clk
1.check the rpmsg name when clk_register.
2.clk_get rpmsg clk print error:
clk/clk.c:1231:3: runtime error: null pointer passed as argument 2, which is declared to never be null
3.fix some function miss keyword FAR.
4.clk_disable_unused may disable rpmsg clk which disable the clk that maybe used by others

Signed-off-by: dulibo1 <dulibo1@xiaomi.com>
2023-09-22 08:47:23 +08:00
simbit18 34bb0b6544 Fix nuttx coding style
Remove TABs
Remove spaces
Fix indentation
2023-09-21 10:03:13 -04:00
SPRESENSE a1f26ab24b include: nuttx: Re-allocate SIOCDENYINETSOCK
The SIOCDENYINETSOCK definition is duplicate with SIOCSIFMTU.
So, re-allocate SIOCDENYINETSOCK command number.
2023-09-21 01:08:11 +08:00
Shanmin Zhang 9b68971853 goldfish: add goldfish gps driver
Verification:

uorb_listener -r 1 sensor_gps

[   18.240000] [13] [  INFO] [ap]
Mointor objects num:2
[   18.240000] [13] [  INFO] [ap] object_name:sensor_gps, object_instance:0
[   18.240000] [13] [  INFO] [ap] object_name:sensor_gps, object_instance:1
[   18.240000] [13] [ ALERT] [ap] period_us = 1000000
[   19.010000] [13] [  INFO] [ap] sensor_gps:	timestamp: 19010000 (0 us ago) time_utc: 1689601925 latitude: 37.4210 longitude: -121.9150
[   19.010000] [13] [  INFO] [ap] sensor_gps:	altitude: 0.0000 altitude_ellipsoid: 0.0000 ground_speed: 145.3254 course: 166.2700
[   19.010000] [13] [  INFO] [ap] sensor_gps:	eph: nan epv: nan hdop: nan vdop: nan
[   20.020000] [13] [  INFO] [ap] sensor_gps:	timestamp: 20020000 (0 us ago) time_utc: 1689601926 latitude: 37.4210 longitude: -121.9150
[   20.020000] [13] [  INFO] [ap] sensor_gps:	altitude: 0.0000 altitude_ellipsoid: 0.0000 ground_speed: 145.3254 course: 166.2700
[   20.020000] [13] [  INFO] [ap] sensor_gps:	eph: nan epv: nan hdop: nan vdop: nan
[   21.010000] [13] [  INFO] [ap] sensor_gps:	timestamp: 21010000 (0 us ago) time_utc: 1689601927 latitude: 37.4210 longitude: -121.9150
[   21.010000] [13] [  INFO] [ap] sensor_gps:	altitude: 0.0000 altitude_ellipsoid: 0.0000 ground_speed: 145.3254 course: 166.2700
[   21.010000] [13] [  INFO] [ap] sensor_gps:	eph: nan epv: nan hdop: nan vdop: nan
[   22.020000] [13] [  INFO] [ap] sensor_gps:	timestamp: 22020000 (0 us ago) time_utc: 1689601928 latitude: 37.4210 longitude: -121.9150
[   22.020000] [13] [  INFO] [ap] sensor_gps:	altitude: 0.0000 altitude_ellipsoid: 0.0000 ground_speed: 145.3254 course: 166.2700
[   22.020000] [13] [  INFO] [ap] sensor_gps:	eph: nan epv: nan hdop: nan vdop: nan
[   23.010000] [13] [  INFO] [ap] sensor_gps:	timestamp: 23010000 (0 us ago) time_utc: 1689601929 latitude: 37.4210 longitude: -121.9150
[   23.010000] [13] [  INFO] [ap] sensor_gps:	altitude: 0.0000 altitude_ellipsoid: 0.0000 ground_speed: 145.3254 course: 166.2700
[   23.010000] [13] [  INFO] [ap] sensor_gps:	eph: nan epv: nan hdop: nan vdop: nan
...

Signed-off-by: Shanmin Zhang <zhangshanmin@xiaomi.com>
2023-09-21 00:38:14 +08:00
Neale Ferguson 5d7f2fdf16 Fix loading of ET_DYN type of shared objects
* build-globals.sh
  - Only look in the nuttx for external symbols used when loading
    dynamic shared objects

* include/elf64.h
  - Correct the type of fields in the Elf64_Phdr structure

* libs/libc/dlfcn/lib_dlclose.c
  - Distinguish between ET_DYN and other objects as the former
    has both text and data in a single allocation to reserve
    GOT offsets

* libs/libc/dlfcn/lib_dlopen.c
  - Code formatting

* libs/libc/modlib/modlib_bind.c
  - Distinguish between relocation entry sizes by section type
  - Handle RELA style relocations

* libs/libc/modlib/modlib_globals.S
  - Formatting fixes
  - Symbols should not be weak - they exist or they don't

* include/nuttx/lib/modlib.h
  - Add an inidcator to module_s to distinguish between ET_DYN and other

* libs/libc/modlib/modlib_load.c
  - ET_DYN objects need to keep the relative displacement between the text
    and data sections due to GOT references from the former to the latter.
    This also implies that linking may require modification from the default
    for the shared objects being produced. For example, default alignment may
    mean nearly 64K of wasted space.

* libs/libc/modlib/modlib_unload.c
  sched/module/mod_rmmod.c
  - Distingusih between freeing of ET_DYN storage and other as the former
    is a single allocation.

* libs/libc/modlib/mod_insmod.c
  - Cater for ET_DYN objects having init and preinit sections
2023-09-20 09:35:28 -04:00
Xiang Xiao 9bd6c70339 input/touchscreen: Bring up TSIOC_[SET|GET]CALIB macro
which is removed accidently in:
https://github.com/apache/nuttx/pull/9398

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2023-09-20 20:51:38 +08:00
yangyalei 3017cc4402 Exec: Support run exec in current task
There is a problem when vfork() calls execv() (or execl()) to start a new application:
When the parent thread calls vfork() it receives and gets the pid of the vforked task,
and not the pid of the desired execv'ed application.
see issue #3334

Signed-off-by: yangyalei <yangyalei@xiaomi.com>
2023-09-20 16:53:30 +08:00
chao an 6b070b2b00 libs/libc: currect usage of getpid/gettid in library
Signed-off-by: chao an <anchao@xiaomi.com>
2023-09-20 10:08:24 +08:00
yintao f3c9a8643b nuttx: change RPTUNIOC_START and RPTUNIOC_STOP to synchronous
Support quit remote when server poweroff

Signed-off-by: yintao <yintao@xiaomi.com>
2023-09-20 00:42:02 +08:00
Xu Xingliang 3cd5e20f74 sched: return 0 from clock_systime_ticks if failed
Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
2023-09-19 16:17:08 +08:00
ligd 61ef7eb3dc wqueue: add work_cancel_sync() support
Signed-off-by: ligd <liguiding1@xiaomi.com>
2023-09-19 15:52:48 +08:00
zhengshaobo1 6e6ba062fd clock flags add CLK_OPS_PARENT_ENABLE, parents need enable during gate/ungate, set rate and re-parent
Signed-off-by: zhengshaobo1 <zhengshaobo1@xiaomi.com>
2023-09-19 10:34:48 +08:00