Commit Graph

221 Commits

Author SHA1 Message Date
Daniel Agar 1d66f2cf83 posix: HRT hrt_lock() sem_wait try again if error returned 2022-04-12 12:46:29 -04:00
CUAVmengxiao f540335998 spi: get the correct version revision 2022-03-29 17:09:34 -04:00
Jacob Schloss 5ae4cae073
orb_advertise_multi: might return nullptr (#19387) 2022-03-24 07:47:48 +01:00
Jukka Laitinen 56c6120e83 Use IOCTL for board_read_VBUS_state in NuttX protected builds
Direct gpio read is not possible from user side applications, so use boardctl
interface instead.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2022-03-17 08:01:51 +01:00
wangwwno1 746c16400a Typo Fix: ChangeWorkQeue
Fix the typo of 'WorkItem::ChangeWorkQeue' to 'WorkItem::ChangeWorkQueue'
2022-03-15 13:31:52 -04:00
Jukka Laitinen caaa13ddc0 uORB performance updates
Move some logic from Subscriber into uORBManager. This reduces calls from the
modules to the uORB manager, improving performance in protected build.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2022-02-24 11:50:05 -05:00
Jukka Laitinen 6071b87afc platforms/common/uORB: Separate IOCTLs going through boardctl interface from the original ones
It was a mistake to mix these two together, it is simpler to implement the boardctl interface
for the protected build, if the boardctl ioctls are different

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2022-02-18 07:53:13 +01:00
Jukka Laitinen 36d440f895 Add IOCTL interface to uORBManager for nuttx protected/kernel build split
When building uORB for NuttX flat build, or for some other target, everything
works as before.

When building uORB for NuttX protected or kernel build, this does the following:
- The kernel side uORB library reigsters a boardctl handler for calls from userspace
  and services the boardctl_ioctls by calling the actual uORB functions
- For user mode binaries, the uORBManager acts as a proxy, making boardctl_ioctl calls to the
  kernel side

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2022-02-14 09:10:49 +01:00
Beat Küng b6607a7b78 battery_status: do not publish if no voltage channel is defined
This is the case for boards with digital readout, like v5x, but still
enable the battery_status module for external analog driver options.

An alternative would be to not run battery_status depending on config.
2022-02-09 16:54:45 -05:00
Daniel Agar be3da5089c uORB: uORBDeviceNode use px4_cache_aligned_alloc 2022-02-08 10:20:50 -05:00
Peter van der Perk 9f97793491 Generate C/C++ header to expose px4board kconfig symbols to the preprocessor 2022-02-02 13:23:21 -05:00
Jukka Laitinen 7bb33e65ae Remove px4_work_queue linking to px4_platform
Remove linking to px4_plaform in here; this breaks linking for nuttx protected build

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2022-01-27 12:42:40 -05:00
Jukka Laitinen 98906c224b Don't link px4_platform directly to uORB
Since uORB is split into kernel and userspace parts, it is no longer possible to just
link uORB into px4_platform, which is used in both kernel and user side.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2022-01-27 12:42:40 -05:00
Beat Küng bcd057ac3e uORB: fix copy-paste mistake in orb_print_message_internal
Could have led to invalid memory access.
2022-01-20 12:58:20 -05:00
Daniel Agar 8067207ea6 px4_work_queue: rename serial port WQs 2022-01-18 14:56:15 -05:00
Daniel Agar 6d0339ba0c I2CSPIDriverBase: sensor start failure ERROR if internal, WARN if external 2021-12-28 11:05:35 -05:00
Beat Küng fe1b726b62 ScheduledWorkItem: do not call ScheduleClear() if not init in destructor
This avoids that unit tests trying to access a wq hang.
It still fails with an error currently.
2021-12-24 20:06:13 -05:00
Beat Küng 590239dedb work_queue: increase rate_ctrl stack size by 150 B
WARN  [load_mon] wq:rate_ctrl low on stack! (172 bytes left)
2021-12-24 20:06:13 -05:00
Daniel Agar 38731662c6 parameters use bitset for mark_unsaved 2021-12-24 14:32:40 -05:00
Beat Küng e29759d877 WorkQueueManager: explicitly convert PTHREAD_STACK_MIN to int
fixes a compiler error on GCC 11.2.1:
error: no matching function for call to ‘max(long int, int)’
2021-12-22 08:47:33 -05:00
Jukka Laitinen ce6147f570 uORB: Remove transfer of memory allocation ownership to CDev
- Allocate and free the node name in uORBDeviceNode.
- Add protected build support by de-allocating the name with kmm_free, when
  running in kernel side. strdup allocates from the kernel heap in NuttX kernel
  space.
- Remove the CDev::unregister_driver_and_memory(), it is no longer used

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-12-13 22:52:36 -05:00
Jukka Laitinen 77af102cab px4_work_queue: Use px4_task_spawn_cmd for WorkQueueRunner in NuttX protected
In NuttX protected build there are separate work queues in kernel and user sides.

pthreads are only available in user side, so use tasks and kthreads for
memory protected builds.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-12-09 20:42:28 -05:00
Jukka Laitinen d0d7f29422 platforms/common/shutdown.cpp: Enable boardctl functions for shutdown and poweroff
Shutdown and poweroff must go through boardctl in NuttX protected build

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-12-07 09:24:53 -05:00
Jukka Laitinen 929820136a Move sw_crypto and stub_keystore under src/drivers
This is more logical place for the "backend" implementation than
directly under platform.

This also allows making other implementations as "real" drivers, as well as proper configuration via Kconfigs

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-11-29 11:09:51 -05:00
Jukka Laitinen b66270f8a8 Inline uORBDeviceNode::copy for performance improvement
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-11-24 09:11:45 +01:00
Jukka Laitinen 3f884c5d24 Inline deviceNodeExists and getDeviceNode in uORB DeviceMaster
This gives a small performance improvement

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-11-24 09:11:45 +01:00
Jukka Laitinen bb307cd462 Fix comparing orb_metadata in uORB::DeviceNode::publish
Don't compare pointers to metadata, but the metadata contents.

In protected/kernel build there are two sets of metadata, on on kernel
side and another in user side. Thus the comparison of pointers would just
always fail. Compare orb_id instead

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-11-24 09:11:45 +01:00
Jukka Laitinen 0b9505453d Clean up interfaces towards uORB
Proxy all calls to the DeviceNode through Manager;
- This hides the DeviceNode from publishers and subscribers
- Manager can be made an interface class between user and kernel spaces in protected build
- This doesn't increase code size or harm the performance on flat build

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-11-24 09:11:45 +01:00
Beat Küng bcba3dfe52 control_allocator,angular_velocity_controller: run on rate_ctrl wq 2021-11-23 12:40:22 -05:00
Jani Paalijarvi 02336acd61 Improve SPI bus implementation
Make possible to define chip-select pin for internal SPI.
By defining chip-select pin, it's possible to start specific SPI device only.
This allows to have several same type of sensors on the same bus with different orientation.
2021-11-19 07:47:18 +01:00
Daniel Agar 7b7b7acd36 i2c_spi_buses: respect CONFIG_I2C and CONFIG_SPI
- bmp280, dps310, and ms5611 barometers support boards without I2C
2021-11-15 15:57:33 -05:00
Beat Küng 8a2b310b83 topic_listener: avoid code generation, use existing metadata at runtime
This reduces flash size for v5 by ~110KB, the topic listener now only adds
about 1.2KB.
2021-10-20 08:10:05 +02:00
Beat Küng 4c73ac3805 uorb: use single byte for internal types in o_fields metadata
Reduces flash usage by ~9KB.
2021-10-20 08:10:05 +02:00
Beat Küng 15daded6b0 refactor output_limit: split output_limit_calc_single into separate function 2021-10-18 18:45:19 -04:00
Daniel Agar beb358a344 px4_work_queue: adjust status formatting to accommodate longer names (eg mc_autotune_attitude_control) 2021-10-05 18:09:00 -04:00
Jukka Laitinen 3db76d88fe Add crypto key generation functions
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-09-27 17:45:07 +02:00
Jukka Laitinen 4c6779812d Add keystore_put_key interface function for storing keys permanently
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-09-27 17:45:07 +02:00
Jukka Laitinen fc2668cba1 Add encryption function for the crypto_backend and px4_crypto
Take into use libtomcrypt library to add RSA and some other algorithms
for SW ecnryption use case

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-09-27 17:45:07 +02:00
Jukka Laitinen d36a91ceaf Add generic px4 interface for crypto features
Add common functions, implemented for nuttx, and link to architecture specific libraries

Make a separate library to wrap nuttx random number generator as "os_random".

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-09-27 17:45:07 +02:00
Jukka Laitinen aa61bc4942 Add functions for initializing empty crypto backend handles
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-09-27 17:45:07 +02:00
Daniel Agar 9a3fa6199b uorb top report total publication rate 2021-09-26 12:29:11 -04:00
Daniel Agar 089c962d92 px4io: moving mixing to FMU side
Using mixers on the IO side had a remote benefit of being able to
override all control surfaces with a radio remote on a fixed wing.
This ended up not being used that much and since the original design
10 years ago (2011) we have been able to convince ourselves that the
overall system stability is at a level where this marginal benefit,
which is not present on multicopters, is not worth the hazzle.

Co-authored-by: Beat Küng <beat-kueng@gmx.net>
Co-authored-by: Daniel Agar <daniel@agar.ca>
2021-09-25 19:15:05 -04:00
Beat Küng e73172b537 hrt: remove hrt_elapsed_time_atomic
There's no protection on posix
2021-09-23 09:23:08 +02:00
Beat Küng 810d2e9497 ModuleParams: remove parent in destructor
This allows for dynamic deletion of children objects (in most cases this
is not used).

Uses ~100B memory.
2021-09-11 15:07:49 -04:00
Beat Küng c5c80e31b6 boards: remove DIRECT_INPUT_TIMER_CHANNELS from board_config.h 2021-09-08 16:10:24 -04:00
Daniel Agar 65b1a9648d Tools/HIL/run_nsh_cmd.py: fail if ERROR printed in output 2021-09-01 15:16:00 -04:00
Jukka Laitinen c3c30e5d4f Fix memory corruption when work queue is being deleted
When the last WorkItem is deleted, it is removed from a work queue and the
queue is being stopped. But, the queue itself might get deleted in the middle,
in a higher priority thread than where the WorkItem deletion was performed from

If the WorkQueue::Detach accesses the member variables after this, there is memory
corruption

This happens in particular when launching i2c or spi devices in
I2CSPIDriverBase::module_start:

- The "initializer" is deleted when the instance is not found and the iterator
  while loop continues.
- The workqueue is deleted in the middle of "initializer" deletion when the
  WorkQueueRunner returns.

This prevents deletion of the WorkQueue before the Detach has been finished,
in the specific case that the ::Detach triggers the deletion

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-08-27 10:43:45 +02:00
Jukka Laitinen 523578d2ce Increase stack size of wq:manager and worker threads for 64 bit targets
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-08-24 10:16:27 -04:00
David Sidrane 78b76cb636 i2c_spi_buses:Support devices that may change address 2021-08-20 10:15:57 -04:00
David Sidrane bb913ae11a system_load:Track Dynamic PID hash 2021-08-13 14:22:00 -04:00