Commit Graph

601 Commits

Author SHA1 Message Date
Beat Küng e75f5a4642 perf_counter: add perf_print_counter_buffer & perf_iterate_all
These can be used to print the perf counters to a buffer.
2017-04-01 20:19:52 +02:00
Beat Küng 446c734edc perf_counter: use a mutex to protect concurrent access to the perf_counters linked list
perf_counters is read from and written to by different threads and thus
requires synchronization. Without it we risk accessing invalid memory.

There are still remaining issues (see comment in code), they will not lead
to a crash however.
2017-04-01 20:19:52 +02:00
Beat Küng 4b01e5b6b6 printload: add print_load_buffer() method
Instead of printing to an fd, this prints to a buffer and calls a callback
for each line. To avoid code duplication, the print_load has been refactored
to print to a buffer first, then print to an fd. The overhead is not
noticable, and the behavior of print_load is unchanged.
2017-04-01 20:19:52 +02:00
Beat Küng 9f3043f9ca printload: store total_runtime in a separate loop
Because during the printf, the total_runtime could be changed by another
task. This is still not entirely race-free though.
2017-04-01 20:19:52 +02:00
Beat Küng 23d0355979 printload: reduce memory usage of print_load_s
assuming CONFIG_MAX_TASKS = 32, this saves 256B of RAM
2017-04-01 20:19:52 +02:00
Beat Küng c46274043f printload: use sched_lock to protect access to tcb
what could have gone wrong before? A scheduling switch during the printload
could have led to a task exit, rendering the tcb invalid. After switching
back, printload would access invalid memory.

This keeps the sched_lock() section as small as possible, just grabbing the
tcb variables we need.
2017-04-01 20:19:52 +02:00
Beat Küng 4a7e02c640 systemlib/visibility.h: remove this file
This is duplicated in src/include/visibility and is directly included via
compiler flag '-include'
2017-03-29 23:02:09 +02:00
Beat Küng f60dfbbb40 perf: remove unused event_overruns, reduce type of delta times to 32bits
32 bits are still enough to measure elapsed times up to 1 hour.

Testing on Pixracer: I counted 73 allocations and 39 frees during bootup,
resulting in 2kB RAM usage after boot. This patch reduce this by ~0.5kB.
2017-03-20 09:11:34 +01:00
Beat Küng f6d9d77f60 param_notify_changes: set unsaved to true
This will make sure that commmander will save the params.
2017-03-14 21:43:30 +01:00
Beat Küng 0e650638e4 param: implement RW locking
This allows concurrent read access, which are much more common; reducing
potential lock contention and increasing concurrency.

Taking a lock is expensive, and the reader lock is now even more expensive.
An RCU synchronization scheme would reduce the overhead of the readers to
increasing/decreasing an atomic counter.
Thus this should only be an intermediate step until we move towards RCU.

Tested on SITL & Pixracer.
2017-03-14 21:30:53 +01:00
Beat Küng b4290b6b52 params: make param_t uint16_t on NuttX
param_t is only used as an offset and we have <1000 params, so an uint16_t
is enough.
This saves roughly 1KB of RAM. We only do that on NuttX because normal
integers have better performance in general.
Previously on amd64, this was even 64bits because it was an uintptr_t.
2017-03-14 21:30:53 +01:00
José Roberto de Souza 75e7cfcbe8 modules: flashparams: Change size to uint32_t
So flash sector of 64Kbyes and 128Kbytes can also be used.
2017-03-10 11:31:07 +01:00
Julian Oes 0c926106f1 param_shmem.c: comment out locking on Snappy
The param locking doesn't seem to be working on Snapdragon, so let's
just comment it out again.
2017-03-08 15:44:31 +01:00
Lorenz Meier 5c524e15f8 Battery params: Enforce system reboot 2017-02-27 16:37:08 +01:00
Lorenz Meier 029c6de4a9 Battery estimator: Warn on dangerously low levels.
We need to differentiate between a level where the user should act and where we are about to fall out of the sky (emergency). This helps performing more suitable failsafe actions.
2017-02-27 09:03:20 +01:00
Beat Küng cfa84954ea param_get: add null-pointer check
If param_find() returned PARAM_INVALID, and this was directly passed to
param_get(), param_get_value_ptr() returned null and we read garbage data
(or segfaulted on systems with virtual memory).
On px4fmu-v2, this happened for the param ATT_VIBE_THRESH in sensors.
Because of the recently added parameter scoping, this param got pruned, as
it's defined in attitude_estimator_q.

credits for finding this go to Jeyong Shin (jeyong).
2017-02-25 11:02:15 +01:00
Beat Küng a4050db766 param: comment what the lock is needed for 2017-02-17 11:27:08 +01:00
Beat Küng df8f0da70c param & param_shmem: enable locking
We need to protect access to the param_values array. This is dynamically
allocated and resized (utarray_reserve() calls realloc). If some thread
was iterating the array while another was resizing the array, the first one
would iterate on a freed array, thus accessing invalid memory.

On NuttX this could lead to hardfaults in rare conditions.

Unfortunately we need to initialize the semaphore on startup, by calling
sem_init(). This adds a param_init() method called by every board/config
that uses the params (at least I think I've found all of them)
2017-02-17 11:27:08 +01:00
Beat Küng fa3a6b890c param & flashparam param_export: use value directly instead of calling param_get
This call is not needed, and will avoid deadlocks when locking is enabled.
2017-02-17 11:27:08 +01:00
Beat Küng 42967df63f param command: use param_* calls even if flash-based params are enabled
This will ensure proper locking.
2017-02-17 11:27:08 +01:00
Beat Küng 68bee1b847 flashparams: remove the locking stubs
locking will be done in the params module
2017-02-17 11:27:08 +01:00
Kabir Mohammed 569251dc2e mavlink_receiver : Add external estimator interface 2017-02-15 21:47:51 +01:00
Paul Riseborough 22c8c59829 Thermal Calibration - add parameter required to control max starting temperature 2017-02-12 09:21:37 +01:00
Paul Riseborough 93a70c2d0b systemlib: Fix parameter name error 2017-02-12 09:21:37 +01:00
Paul Riseborough c901c4b39e Thermal Calibration - add parameter required to control minimum starting temperature 2017-02-12 09:21:37 +01:00
Paul Riseborough 693cc4a533 Update SYS_CAL_TEMP parameter name and description
We will be adding another parameter to set min starting temp, so this name needs to be made less generic.
Fixes typographical errors in the description
2017-02-12 09:21:37 +01:00
Daniel Agar 317595cff3 SYS_COMPANION add 115200 normal telem 2017-02-08 08:35:29 +01:00
David Sidrane 3668047e6c board_serial uses simpler common bord indentity api 2017-02-04 22:27:04 +01:00
Beat Küng ffacc6f64a param SYS_STCK_EN: enable stack checking by default 2017-02-04 12:15:59 +01:00
Beat Küng 32ed939ea4 param_shmem: readd dropped static to function definition 2017-02-03 13:57:48 +01:00
Beat Küng a802caca87 param: add param_notify_changes() method
Can be used for example after several calls to
param_set_no_notification() to avoid unnecessary system notifications,
as it is an expensive change.
2017-02-03 13:57:48 +01:00
Paul Riseborough 4ff5e7c5ab systemlib 2017-02-02 23:54:06 +01:00
Paul Riseborough 8aa91512e9 systemlib: Add parameters to control thermal calibration startup behaviour 2017-02-02 23:54:06 +01:00
Daniel Agar 96e51f7c59 clang-tidy remove redundant 2017-02-01 22:15:50 -05:00
Daniel Agar e927f3e040 clang-tidy modernize-use-nullptr 2017-02-01 22:15:50 -05:00
Daniel Agar 0bc3c8dfc4 astyle src/modules/systemlib 2017-01-29 01:18:32 +01:00
David Sidrane 242f563d44 Adds a board common API for retriving the SoC' Silicon revision data/errata
This abstraction will support mcu's other than the stm32 family.
    It moves the systemlib/mcu_version.c functionality to
    common/stm32/board_mcu_version.c
2017-01-26 08:39:12 +01:00
David Sidrane 5a5cfdbbe3 mcu_version remove mcu_unique_id
Using board cvommon UUID api thefore Removed mcu_unique_id
2017-01-25 07:43:11 +01:00
David Sidrane 24f5461402 systemlib/board_serial uses common board api for UUID 2017-01-25 07:43:11 +01:00
David Sidrane 1abd629461 Move common macros to systemlib/px4_macros.h 2017-01-24 21:18:28 +01:00
David Sidrane 9665db3efc Use px4_config.h not board_config.h 2017-01-21 11:45:36 +01:00
Lorenz Meier 084e714f62 Mixer: Fix yaw throttle adjustment
When a motor hits a limit we only want to lower the collective throttle as much as the total limit, not per motor hitting the limit.
2017-01-21 08:33:51 +01:00
Lorenz Meier fc2970b309 Helicopter mixer: Fix out of bounds checks 2017-01-14 07:47:03 -08:00
Stephan Brown 67a484ac34 Make parameter generation also depend on the scripts that run. Address some review comments. 2017-01-06 09:58:58 +01:00
Stephan Brown 92b2395ff6 param: Fix another off by 1 error and a formatting issue. 2017-01-06 09:58:58 +01:00
Stephan Brown bf57e86dc2 param: Fix an off by 1 issue and some style fixes. 2017-01-06 09:58:58 +01:00
Stephan Brown 99228bdeb1 param: Use utarray_find when looking for changed parameters and use a binary search for finding param handles by name. 2017-01-06 09:58:58 +01:00
Lorenz Meier b3ce3cbaff Simple mixer: Remove incorrect pre-parser and replace with fixed central implementation 2017-01-03 20:32:33 -05:00
Lorenz Meier dd05ff5156 Multirotor mixer: Remove incorrect pre-parser and replace with fixed central implementation 2017-01-03 20:32:33 -05:00
Lorenz Meier ff18140cf4 Mixer: add string wconditioning check.
This introduces a correctly designed pre-check for the input parsers. This fixes the mixer unit test and should fix all issues occuring on real hardware.
;
2017-01-03 20:32:33 -05:00