From 891626232789f1722935f084c3f8b61eb507abb1 Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Tue, 22 May 2018 08:16:33 +0100 Subject: [PATCH] leds: move documentation to readme, broken on -M virt --- README.adoc | 46 +++++++++++++++++++++++++++++++++- kernel_config_fragment/default | 46 ---------------------------------- kernel_config_fragment/leds | 12 +++++++++ 3 files changed, 57 insertions(+), 47 deletions(-) create mode 100644 kernel_config_fragment/leds diff --git a/README.adoc b/README.adoc index a1b0e86..8aff96b 100644 --- a/README.adoc +++ b/README.adoc @@ -3557,7 +3557,7 @@ Looks like a recompile is needed to modify the image... === GPIO -TODO: this was working before we moved `arm` from `-M versatilepb` to `-M virt` around af210a76711b7fa4554dcc2abd0ddacfc810dfd4. Either make it work on `-M virt` if that is possible, or document precisely how to make it work with `versatilepb`, or hopefully `vexpress` which is newer. +TODO: broken. Was working before we moved `arm` from `-M versatilepb` to `-M virt` around af210a76711b7fa4554dcc2abd0ddacfc810dfd4. Either make it work on `-M virt` if that is possible, or document precisely how to make it work with `versatilepb`, or hopefully `vexpress` which is newer. QEMU does not have a very nice mechanism to observe GPIO activity: https://raspberrypi.stackexchange.com/questions/56373/is-it-possible-to-get-the-state-of-the-leds-and-gpios-in-a-qemu-emulation-like-t/69267#69267 @@ -3585,6 +3585,50 @@ Buildroot's Linux tools package provides some GPIO CLI tools: `lsgpio`, `gpio-ev Those broke MIPS build in 2017-02: https://bugs.busybox.net/show_bug.cgi?id=10276 and so we force disable them in our MIPS build currently. +=== LEDs + +TODO: broken when `arm` moved to `-M virt`, same as <>. + +Try hacking QEMU's `hw/misc/arm_sysctl.c` with a printf: + +.... +static void arm_sysctl_write(void *opaque, hwaddr offset, + uint64_t val, unsigned size) +{ + arm_sysctl_state *s = (arm_sysctl_state *)opaque; + + switch (offset) { + case 0x08: /* LED */ + printf("LED val = %llx\n", (unsigned long long)val); +.... + +and then rebuild with: + +.... +./build -aa -c kernel_config_fragment/leds -lq +.... + +But beware that one of the LEDs has a heartbeat trigger by default (specified on dts), so it will produce a lot of output. + +And then activate it with: + +.... +cd /sys/class/leds/versatile:0 +cat max_brightness +echo 255 >brightness +.... + +Relevant QEMU files: + +* `hw/arm/versatilepb.c` +* `hw/misc/arm_sysctl.c` + +Relevant kernel files: + +* `arch/arm/boot/dts/versatile-pb.dts` +* `drivers/leds/led-class.c` +* `drivers/leds/leds-sysctl.c` + === Linux kernel hardening Make it harder to get hacked and easier to notice that you were, at the cost of some (small?) runtime overhead. diff --git a/kernel_config_fragment/default b/kernel_config_fragment/default index 0d5e8c7..c612924 100644 --- a/kernel_config_fragment/default +++ b/kernel_config_fragment/default @@ -130,52 +130,6 @@ CONFIG_UIO_PCI_GENERIC=m ## ARM -# LEDs: -# -# cd /sys/class/leds/versatile:0 -# cat max_brightness -# echo 255 >brightness -# -# https://raspberrypi.stackexchange.com/questions/697/how-do-i-control-the-system-leds-using-my-software -# -# Relevant QEMU files: -# -# - hw/arm/versatilepb.c -# - hw/misc/arm_sysctl.c -# -# Relevant kernel files: -# -# - arch/arm/boot/dts/versatile-pb.dts -# - drivers/leds/led-class.c -# - drivers/leds/leds-sysctl.c -# -# Try hacking QEMU's `hw/misc/arm_sysctl.c` with a printf: -# -# static void arm_sysctl_write(void *opaque, hwaddr offset, -# uint64_t val, unsigned size) -# { -# arm_sysctl_state *s = (arm_sysctl_state *)opaque; -# -# switch (offset) { -# case 0x08: /* LED */ -# printf("LED val = %llx\n", (unsigned long long)val); -# -# to observe when the callback is made. But beware that one of the LEDs -# has a heartbeat trigger by default (specified on dts), so it will produce a lot of output. -# -CONFIG_LEDS_CLASS=y -CONFIG_LEDS_CLASS_FLASH=y -CONFIG_LEDS_SYSCON=y -CONFIG_LEDS_TRIGGERS=y -CONFIG_LEDS_TRIGGER_BACKLIGHT=y -CONFIG_LEDS_TRIGGER_CPU=y -CONFIG_LEDS_TRIGGER_DEFAULT_ON=y -CONFIG_LEDS_TRIGGER_GPIO=y -CONFIG_LEDS_TRIGGER_HEARTBEAT=y -CONFIG_LEDS_TRIGGER_ONESHOT=y -CONFIG_LEDS_TRIGGER_TIMER=y -CONFIG_NEW_LEDS=y - # Like CONFIG_X86_PTDUMP for ARM. CONFIG_ARM64_PTDUMP=y diff --git a/kernel_config_fragment/leds b/kernel_config_fragment/leds new file mode 100644 index 0000000..023eca0 --- /dev/null +++ b/kernel_config_fragment/leds @@ -0,0 +1,12 @@ +CONFIG_LEDS_CLASS=y +CONFIG_LEDS_CLASS_FLASH=y +CONFIG_LEDS_SYSCON=y +CONFIG_LEDS_TRIGGERS=y +CONFIG_LEDS_TRIGGER_BACKLIGHT=y +CONFIG_LEDS_TRIGGER_CPU=y +CONFIG_LEDS_TRIGGER_DEFAULT_ON=y +CONFIG_LEDS_TRIGGER_GPIO=y +CONFIG_LEDS_TRIGGER_HEARTBEAT=y +CONFIG_LEDS_TRIGGER_ONESHOT=y +CONFIG_LEDS_TRIGGER_TIMER=y +CONFIG_NEW_LEDS=y