From 544ea72d4c789eac77198b7d54b35db88ff54eeb Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Thu, 7 Jul 2016 13:46:12 +0200 Subject: [PATCH] Snapdragon: set CPUs scaling to performance mode Sdlog2 misses least updates when the CPU scaling governor is set at maximum performance. This is not optimal to save power but the best effort until there is a RT patched kernel on Snapdragon. --- src/platforms/posix/main.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/platforms/posix/main.cpp b/src/platforms/posix/main.cpp index ccb9aaf494d..34c879419fc 100644 --- a/src/platforms/posix/main.cpp +++ b/src/platforms/posix/main.cpp @@ -162,6 +162,21 @@ bool px4_exit_requested(void) return _ExitFlag; } +static void set_cpu_scaling() +{ +#ifdef __PX4_POSIX_EAGLE + // On Snapdragon we miss updates in sdlog2 unless all 4 CPUs are run + // at the maximum frequency all the time. + // Interestingely, cpu0 and cpu3 set the scaling for all 4 CPUs on Snapdragon. + system("echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"); + system("echo performance > /sys/devices/system/cpu/cpu3/cpufreq/scaling_governor"); + + // Alternatively we could also raise the minimum frequency to save some power, + // unfortunately this still lead to some drops. + //system("echo 1190400 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq"); +#endif +} + int main(int argc, char **argv) { bool daemon_mode = false; @@ -184,6 +199,8 @@ int main(int argc, char **argv) //sigaction(SIGTERM, &sig_int, NULL); sigaction(SIGFPE, &sig_fpe, NULL); + set_cpu_scaling(); + int index = 1; char *commands_file = nullptr;