Skip to content

Commit 8916262

Browse files
committed
leds: move documentation to readme, broken on -M virt
1 parent 207306f commit 8916262

File tree

3 files changed

+57
-47
lines changed

3 files changed

+57
-47
lines changed

README.adoc

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3557,7 +3557,7 @@ Looks like a recompile is needed to modify the image...
35573557

35583558
=== GPIO
35593559

3560-
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.
3560+
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.
35613561

35623562
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
35633563

@@ -3585,6 +3585,50 @@ Buildroot's Linux tools package provides some GPIO CLI tools: `lsgpio`, `gpio-ev
35853585

35863586
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.
35873587

3588+
=== LEDs
3589+
3590+
TODO: broken when `arm` moved to `-M virt`, same as <<gpio>>.
3591+
3592+
Try hacking QEMU's `hw/misc/arm_sysctl.c` with a printf:
3593+
3594+
....
3595+
static void arm_sysctl_write(void *opaque, hwaddr offset,
3596+
uint64_t val, unsigned size)
3597+
{
3598+
arm_sysctl_state *s = (arm_sysctl_state *)opaque;
3599+
3600+
switch (offset) {
3601+
case 0x08: /* LED */
3602+
printf("LED val = %llx\n", (unsigned long long)val);
3603+
....
3604+
3605+
and then rebuild with:
3606+
3607+
....
3608+
./build -aa -c kernel_config_fragment/leds -lq
3609+
....
3610+
3611+
But beware that one of the LEDs has a heartbeat trigger by default (specified on dts), so it will produce a lot of output.
3612+
3613+
And then activate it with:
3614+
3615+
....
3616+
cd /sys/class/leds/versatile:0
3617+
cat max_brightness
3618+
echo 255 >brightness
3619+
....
3620+
3621+
Relevant QEMU files:
3622+
3623+
* `hw/arm/versatilepb.c`
3624+
* `hw/misc/arm_sysctl.c`
3625+
3626+
Relevant kernel files:
3627+
3628+
* `arch/arm/boot/dts/versatile-pb.dts`
3629+
* `drivers/leds/led-class.c`
3630+
* `drivers/leds/leds-sysctl.c`
3631+
35883632
=== Linux kernel hardening
35893633

35903634
Make it harder to get hacked and easier to notice that you were, at the cost of some (small?) runtime overhead.

kernel_config_fragment/default

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -130,52 +130,6 @@ CONFIG_UIO_PCI_GENERIC=m
130130

131131
## ARM
132132

133-
# LEDs:
134-
#
135-
# cd /sys/class/leds/versatile:0
136-
# cat max_brightness
137-
# echo 255 >brightness
138-
#
139-
# https://raspberrypi.stackexchange.com/questions/697/how-do-i-control-the-system-leds-using-my-software
140-
#
141-
# Relevant QEMU files:
142-
#
143-
# - hw/arm/versatilepb.c
144-
# - hw/misc/arm_sysctl.c
145-
#
146-
# Relevant kernel files:
147-
#
148-
# - arch/arm/boot/dts/versatile-pb.dts
149-
# - drivers/leds/led-class.c
150-
# - drivers/leds/leds-sysctl.c
151-
#
152-
# Try hacking QEMU's `hw/misc/arm_sysctl.c` with a printf:
153-
#
154-
# static void arm_sysctl_write(void *opaque, hwaddr offset,
155-
# uint64_t val, unsigned size)
156-
# {
157-
# arm_sysctl_state *s = (arm_sysctl_state *)opaque;
158-
#
159-
# switch (offset) {
160-
# case 0x08: /* LED */
161-
# printf("LED val = %llx\n", (unsigned long long)val);
162-
#
163-
# to observe when the callback is made. But beware that one of the LEDs
164-
# has a heartbeat trigger by default (specified on dts), so it will produce a lot of output.
165-
#
166-
CONFIG_LEDS_CLASS=y
167-
CONFIG_LEDS_CLASS_FLASH=y
168-
CONFIG_LEDS_SYSCON=y
169-
CONFIG_LEDS_TRIGGERS=y
170-
CONFIG_LEDS_TRIGGER_BACKLIGHT=y
171-
CONFIG_LEDS_TRIGGER_CPU=y
172-
CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
173-
CONFIG_LEDS_TRIGGER_GPIO=y
174-
CONFIG_LEDS_TRIGGER_HEARTBEAT=y
175-
CONFIG_LEDS_TRIGGER_ONESHOT=y
176-
CONFIG_LEDS_TRIGGER_TIMER=y
177-
CONFIG_NEW_LEDS=y
178-
179133
# Like CONFIG_X86_PTDUMP for ARM.
180134
CONFIG_ARM64_PTDUMP=y
181135

kernel_config_fragment/leds

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CONFIG_LEDS_CLASS=y
2+
CONFIG_LEDS_CLASS_FLASH=y
3+
CONFIG_LEDS_SYSCON=y
4+
CONFIG_LEDS_TRIGGERS=y
5+
CONFIG_LEDS_TRIGGER_BACKLIGHT=y
6+
CONFIG_LEDS_TRIGGER_CPU=y
7+
CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
8+
CONFIG_LEDS_TRIGGER_GPIO=y
9+
CONFIG_LEDS_TRIGGER_HEARTBEAT=y
10+
CONFIG_LEDS_TRIGGER_ONESHOT=y
11+
CONFIG_LEDS_TRIGGER_TIMER=y
12+
CONFIG_NEW_LEDS=y

0 commit comments

Comments
 (0)