41 Commits

Author SHA1 Message Date
Ville Juven
59e86c490d Remove include <log.h> from defines.h
The reason for this is that log.h includes drv_hrt.h which sucks in
half the project's include files with it, which causes strange build
issues
2022-09-29 07:56:24 +02:00
Beat Küng
8d36ba6727 log_writer_file: fix corner case when mission log is enabled
Normally _should_run for mission is only ever true if _should_run for the
normal log is. There are exceptions though:
- the log buffer fails to allocate
- there was a write failure (e.g. due to SD card removal)
In that situation, the writer would not wait anymore but busy-loop.
2022-05-11 10:06:35 -04:00
Beat Küng
ebbe08bc86 log_writer_file: protect access to _should_run, use px4::atomicbool for _exit_thread 2022-05-11 10:06:35 -04:00
Jukka Laitinen
a2dc6e63cf Fix sdcard logging when crypto is used but algorithm is set to NONE
If the board supports encrypting logfiles, but the parameter SDCARD_ALGORITHM is set to NONE,
the log should be written to the sdcard in plaintext format. This fixes a bug which caused
logger to hang in mutex instead.

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2022-01-28 17:29:51 -05:00
Daniel Agar
177fe4bade logger: log write file allow single retry on write failure 2021-11-13 20:32:29 +01:00
David Sidrane
25a27d26e0 logger:log_writer_file Do not try to store ulog name on systems without hardfault logging 2021-09-29 23:51:25 -04:00
Jukka Laitinen
6cae4c92e7 Add a header to logfile encryption key exchange file
Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-09-27 17:45:07 +02:00
Jukka Laitinen
9a4ef709ca Add parameters for configuring the logfile encryption
SDLOG_ALGORITHM for selecting the crypto algorithm
SDLOG_KEY for selecting the key in keystore to use with the algorithm.
  for symmetric algorithms which are currently supported, this is just a free
  slot to be used, the key is generated at logging start
SDLOG_EXCH_KEY for selecting an RSA2048 key for encrypting the SDLOG_KEY

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-09-27 17:45:07 +02:00
Jukka Laitinen
9472f79307 Take crypto interfaces into use in logger, to encrypt ulog data
- Generate a symmetric encryption key and a nonce value
- Use a public key in keystore to encrypt the symmteric key
- Write the encrypted key and the nonce value to disk into .ulgk, name matching with the encrypted log file
- use quick stream encryption to crypt the .ulg file contents

Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
2021-09-27 17:45:07 +02:00
Beat Küng
e77b4418a5 fix logger: use free() instead of 'delete[]' for _buffer
The allocation got changed to px4_cache_aligned_alloc
2021-05-11 18:12:56 +02:00
David Sidrane
ccee36bb68 sd_bench and logger use aligned buffers 2021-03-17 05:27:53 +01:00
Daniel Agar
5c2cc53134 Revert "logger: log_writer_file increase stack 1170 -> 1472 bytes (#15765)"
This reverts commit d676e65294b27b592e06381a12b0f3b40b6139f0.
2020-10-12 20:58:35 -04:00
Daniel Agar
d676e65294
logger: log_writer_file increase stack 1170 -> 1472 bytes (#15765) 2020-09-21 22:17:31 -04:00
Dusan Zivkovic
d7a9b123e6 logger: fix thread deadlock 2020-03-06 13:37:34 +01:00
Beat Küng
3198610f85 src/platforms: move all headers to platforms/common/include/px4_platform_common
and remove the px4_ prefix, except for px4_config.h.

command to update includes:
for k in app.h atomic.h cli.h console_buffer.h defines.h getopt.h i2c.h init.h log.h micro_hal.h module.h module_params.h param.h param_macros.h posix.h sem.h sem.hpp shmem.h shutdown.h tasks.h time.h workqueue.h; do for i in $(grep -rl 'include <px4_'$k src platforms boards); do sed -i 's/#include <px4_'$k'/#include <px4_platform_common\/'$k/ $i; done; done
for in $(grep -rl 'include <px4_config.h' src platforms boards); do sed -i 's/#include <px4_config.h/#include <px4_platform_common\/px4_config.h'/ $i; done

Transitional headers for submodules are added (px4_{defines,log,time}.h)
2019-10-30 11:48:47 +01:00
Daniel Agar
4192414576 clang-tidy: partially fix cppcoreguidelines-pro-type-reinterpret-cast 2019-10-28 10:50:31 -04:00
Beat Küng
d68dcb9cf7 log_writer_file: increase stack size by 20 bytes
Seems to be due to the console buffer.
2019-06-04 11:57:54 +02:00
Beat Küng
721f9f901f log_writer_file: fix race condition for fast consecutive stop & start calls 2019-05-29 11:41:22 +02:00
Daniel Agar
2ffb49b734 delete px4_includes.h header and update boards/ to use syslog 2019-01-23 18:25:18 -05:00
Julian Oes
5b9dea5604 Replacing usleep with px4_usleep
This is a step towards isolating time from the system.
2018-12-22 10:32:18 +01:00
Beat Küng
df559f3042 logger: unlock the mutex for fsync & call fsync only when backend is running
- fsync can be a long blocking operation, so we need to make sure the main
  logger thread does not block during this time, when it tries to aquire
  the mutex
- fixes calling fsync on an invalid file descriptor
2018-11-07 00:08:23 +08:00
Beat Küng
c5d8abff00 log_writer_file: rename argument to avoid shadowing warning 2018-10-26 08:02:42 +02:00
Beat Küng
4fc1c5c4f5 LogWriterFile: split long header messages that exceed the buffer length
Some message formats are longer than the 300 bytes. We can split the writes
because we have to wait until they are written anyway.
2018-10-26 08:02:42 +02:00
Beat Küng
d6e820fe67 logger: add mission file to LogWriterFile backend
Not used yet, it should not affect anything, except for slight RAM
increase.
2018-10-26 08:02:42 +02:00
Daniel Agar
9551dcb497 logger increase log_writer_file stack 1072 -> 1150 2018-08-07 17:21:15 +02:00
Beat Küng
bda237b368 logger: ensure that fsync is called at least every second
In case a log ends abruptly, we will know that we have everything up to the
last second.

A test showed that CPU load and the amount of logging drops are unaffected
by this.
2018-05-18 22:23:32 +02:00
Beat Küng
ebafa5698d log_writer_file: register hardfault handler before opening the log file
hardfault_store_filename() opens and closes a file descriptor, so if we do
it before opening the log file, we need one file descriptor less
2017-08-16 16:46:56 +02:00
Julien Lecoeur
71136dcedf Log_writer_file: Increase stack size
Test flights reported the warning `[load_mon] log_writer_file low on stack! (292 bytes left)`

Increase stack size from 1060  to 1072 (=8 + 1060 rounded to next multiple of 8).
2017-07-18 08:24:37 +02:00
Beat Küng
209f220288 hardfault_log: move hardfault_store_ulog_filename to logger module 2017-07-07 17:06:48 +02:00
Beat Küng
1be089cf0c BBSRAM: add another partition and store the last ulog path 2017-07-07 17:06:48 +02:00
Beat Küng
8bfa84f73f log_writer_file: make sure to close the file
and avoid doing a loop iteration when the thread is requested to exit
(as it could access _buffer).
2017-05-04 08:44:11 +02:00
Lorenz Meier
65baf99832 Logger hotfix: Allocate buffer on logging
This enables to use the RAM normally consumed by the log buffer to be used for calibration and other memory-intense tasks.
These run typically only disarmed when logging is not enabled.
2017-05-03 21:52:04 +02:00
Beat Küng
bfcbe4b6c3 log_writer_file: rename perf counters
To be more consistent with the rest of the system
2017-04-01 20:19:52 +02:00
Matthias Grob
bb3b26e00f logger: adjusted log_writer_file stack size
because of messages in the logs
2017-03-16 14:05:15 +01:00
Beat Küng
03dc991188 log_writer_file: adjust stack size
Stack size was below threshold of 300 by 8 bytes.
2017-02-04 12:15:59 +01:00
Daniel Agar
e927f3e040 clang-tidy modernize-use-nullptr 2017-02-01 22:15:50 -05:00
Mark Whitehorn
257e236c92 add errno to error message 2016-12-10 12:56:39 +01:00
Beat Küng
cbbee30e48 log_writer_file: add include px4_posix.h (needed for stack size macro)
Failed with GCC 6.0.1, don't know why it worked before...
2016-10-24 10:22:48 +02:00
Beat Küng
12ded377d1 refactor logger: add need_reliable_transfer flag, remove write_wait 2016-10-19 13:13:47 +02:00
Beat Küng
1ddddccb81 logger: move thread start/stop logic into LogWriterFile 2016-10-19 13:13:47 +02:00
Beat Küng
ccdaabc7fb refactor logger: prepare for multiple write backends 2016-10-19 13:13:47 +02:00