From 207306fa3191b5be3c41d38616a17a7a2f89fe66 Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Tue, 22 May 2018 08:06:32 +0100 Subject: [PATCH] gpio: move documentation to README, document that it broke on -M virt --- README.adoc | 30 ++++++++++++++++++++++++++++++ br2 | 6 ------ br2_gpio | 2 ++ build | 8 +++----- kernel_config_fragment/default | 11 ++++------- kernel_config_fragment/gpio | 4 ++++ rootfs_overlay/gpio.sh | 2 -- 7 files changed, 43 insertions(+), 20 deletions(-) create mode 100644 br2_gpio create mode 100644 kernel_config_fragment/gpio diff --git a/README.adoc b/README.adoc index f7e5d31..a1b0e86 100644 --- a/README.adoc +++ b/README.adoc @@ -3555,6 +3555,36 @@ Looks like a recompile is needed to modify the image... * https://superuser.com/questions/736423/changing-kernel-bootsplash-image * https://unix.stackexchange.com/questions/153975/how-to-change-boot-logo-in-linux-mint +=== 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. + +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 + +The best you can do is to hack our link:build[] script to add: + +.... +HOST_QEMU_OPTS='--extra-cflags=-DDEBUG_PL061=1' +.... + +where link:http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0190b/index.html[PL061] is the dominating ARM Holdings hardware that handles GPIO. + +Then compile with: + +.... +./build -aa -b br2_gpio -c kernel_config_fragment/gpio -l +.... + +then test it out with: + +.... +/gpio.sh +.... + +Buildroot's Linux tools package provides some GPIO CLI tools: `lsgpio`, `gpio-event-mon`, `gpio-hammer`, TODO document them here. + +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. + === 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/br2 b/br2 index ebeba8f..5114fd3 100644 --- a/br2 +++ b/br2 @@ -62,12 +62,6 @@ BR2_PTHREAD_DEBUG=y # ftrace BR2_PACKAGE_TRACE_CMD=y -# GPIO: lsgpio, gpio-event-mon, gpio-hammer -# Breask MIPS build in 2017-02: -# https://bugs.busybox.net/show_bug.cgi?id=10276 -BR2_PACKAGE_LINUX_TOOLS=y -BR2_PACKAGE_LINUX_TOOLS_GPIO=y - # DTC BR2_PACKAGE_DTC=y BR2_PACKAGE_DTC_PROGRAMS=y diff --git a/br2_gpio b/br2_gpio new file mode 100644 index 0000000..19a5b3e --- /dev/null +++ b/br2_gpio @@ -0,0 +1,2 @@ +BR2_PACKAGE_LINUX_TOOLS=y +BR2_PACKAGE_LINUX_TOOLS_GPIO=y diff --git a/build b/build index 33481ed..4474698 100755 --- a/build +++ b/build @@ -160,14 +160,12 @@ BR2_ROOTFS_POST_SCRIPT_ARGS=\"${post_script_args}\" touch "${kernel_config_fragment_dir}/min" fi if [ "$arch" = 'mips64' ]; then - # Workaround for: - # http://lists.busybox.net/pipermail/buildroot/2017-August/201053.html + # Workaround for: https://bugs.busybox.net/show_bug.cgi?id=10276 sed -Ei 's/^BR2_PACKAGE_LINUX_TOOLS_GPIO/BR2_PACKAGE_LINUX_TOOLS_GPIO=n/' "$config_file" fi make O="$buildroot_out_dir" olddefconfig if [ "$arch" = 'mips64' ]; then - # Workaround for: - # http://lists.busybox.net/pipermail/buildroot/2017-August/201053.html + # Workaround for: https://bugs.busybox.net/show_bug.cgi?id=10276 sed -Ei 's/^BR2_PACKAGE_LINUX_TOOLS_GPIO/BR2_PACKAGE_LINUX_TOOLS_GPIO=n/' "$config_file" fi make O="$buildroot_out_dir" olddefconfig @@ -192,7 +190,7 @@ env \\ -u LD_LIBRARY_PATH \\ make \\ O='${buildroot_out_dir}' \\ -HOST_QEMU_OPTS='--enable-debug --extra-cflags=-DDEBUG_PL061=1 --enable-trace-backends=simple ${qemu_sdl}' \\ +HOST_QEMU_OPTS='--enable-debug --enable-trace-backends=simple ${qemu_sdl}' \\ V='${v}' \\ ${extra_make_args} \ all \\ diff --git a/kernel_config_fragment/default b/kernel_config_fragment/default index 843cb7a..0d5e8c7 100644 --- a/kernel_config_fragment/default +++ b/kernel_config_fragment/default @@ -79,6 +79,8 @@ CONFIG_VIRTIO_NET=y # Misc CONFIG_DUMMY_IRQ=m CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y +# Requirement for LOGO. +CONFIG_FB=y CONFIG_LOGO=y ## Networking @@ -158,8 +160,9 @@ CONFIG_UIO_PCI_GENERIC=m # case 0x08: /* LED */ # printf("LED val = %llx\n", (unsigned long long)val); # -# to obeserve when the callback is made. But beware that one of the LEDs +# 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 @@ -173,12 +176,6 @@ CONFIG_LEDS_TRIGGER_ONESHOT=y CONFIG_LEDS_TRIGGER_TIMER=y CONFIG_NEW_LEDS=y -# GPIO -CONFIG_ARM_AMBA=y -CONFIG_GPIOLIB=y -CONFIG_GPIO_SYSFS=y -CONFIG_GPIO_PL061=y - # Like CONFIG_X86_PTDUMP for ARM. CONFIG_ARM64_PTDUMP=y diff --git a/kernel_config_fragment/gpio b/kernel_config_fragment/gpio new file mode 100644 index 0000000..fd753b5 --- /dev/null +++ b/kernel_config_fragment/gpio @@ -0,0 +1,4 @@ +CONFIG_ARM_AMBA=y +CONFIG_GPIOLIB=y +CONFIG_GPIO_SYSFS=y +CONFIG_GPIO_PL061=y diff --git a/rootfs_overlay/gpio.sh b/rootfs_overlay/gpio.sh index a71a6e8..ea060e5 100755 --- a/rootfs_overlay/gpio.sh +++ b/rootfs_overlay/gpio.sh @@ -1,6 +1,4 @@ #!/bin/sh -# ARM only. -# 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 set -e cd /sys/class/gpio echo 480 > export