From 8823f45d402f157ed194755473dfd3b9d6fdb4fb Mon Sep 17 00:00:00 2001 From: Ciro Santilli Date: Sun, 2 Jul 2017 15:00:04 +0100 Subject: [PATCH] LED failed attempt, GPIO working --- README.md | 4 +++- kernel_config_fragment | 35 +++++++++++++++++++++++++++++++++++ kernel_module/README.md | 6 ++++-- rootfs_overlay/README.md | 4 ++++ rootfs_overlay/gpio.sh | 27 +++++++++++++++++++++++++++ run | 3 ++- 6 files changed, 75 insertions(+), 4 deletions(-) create mode 100755 rootfs_overlay/gpio.sh diff --git a/README.md b/README.md index 6def6fe..d6c4cd7 100644 --- a/README.md +++ b/README.md @@ -47,10 +47,12 @@ If you are feeling fancy, you can also insert modules with: modprobe hello -and if you are feeling raw, you can use: +If you are feeling raw, you can use: /myinsmod.out /hello.ko +Kernel modules built in-tree with `CONFIG_SOME_MOD=m`, are available via `modprobe`. + We use `printk` a lot, and it shows on the QEMU terminal by default. If that annoys you (e.g. you want to see stdout separately), do: dmesg -n 1 diff --git a/kernel_config_fragment b/kernel_config_fragment index f330ecd..79c0d61 100644 --- a/kernel_config_fragment +++ b/kernel_config_fragment @@ -57,3 +57,38 @@ CONFIG_TRACER_SNAPSHOT=y # https://stackoverflow.com/questions/20069620/print-kernels-page-table-entries # cat /sys/kernel/debug/kernel_page_tables CONFIG_X86_PTDUMP=y + +# LEDs. +# +# modprobe led-class +# modprobe leds-versatile +# ls /sys/class/leds +# +# TODO: the LEDs don't appear there. There are some entires under: +# +# /sys/devices/platform/10000000.core-module/10000000.core-module:led@08.0/ +# +# but they don't have brightness file. +# +# 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-versatile.c +# +CONFIG_LEDS_CLASS=y +CONFIG_LEDS_VERSATILE=y +CONFIG_NEW_LEDS=y + +# GPIO. +CONFIG_ARM_AMBA=y +CONFIG_GPIOLIB=y +CONFIG_GPIO_SYSFS=y +CONFIG_GPIO_PL061=y diff --git a/kernel_module/README.md b/kernel_module/README.md index fd44afd..a527dc3 100644 --- a/kernel_module/README.md +++ b/kernel_module/README.md @@ -22,7 +22,9 @@ 1. [work_from_work](work_from_work.c) 1. [irq](irq.c) 1. Module dependencies - 1. [dep.c](dep.c) - 1. [dep2.c](dep2.c) + 1. [dep](dep.c) + 1. [dep2](dep2.c) 1. [character_device](character_device.c) + 1. Hardware device drivers + 1. [pci](pci.c) 1. [user](user/) diff --git a/rootfs_overlay/README.md b/rootfs_overlay/README.md index 1bdc972..0137cad 100644 --- a/rootfs_overlay/README.md +++ b/rootfs_overlay/README.md @@ -6,3 +6,7 @@ We use it to for things like: - customized configuration files - userland module test scripts + +Most tests correspond clearly to a given kernel module, but the following ones don't, e.g. they correspond to mainline tree features: + +- [gpio](gpio.sh) diff --git a/rootfs_overlay/gpio.sh b/rootfs_overlay/gpio.sh new file mode 100755 index 0000000..ea060e5 --- /dev/null +++ b/rootfs_overlay/gpio.sh @@ -0,0 +1,27 @@ +#!/bin/sh +set -e +cd /sys/class/gpio +echo 480 > export +echo 481 > export +echo 482 > export +echo 488 > export +echo 496 > export +echo out > gpio480/direction +echo out > gpio481/direction +echo out > gpio482/direction +echo out > gpio488/direction +echo out > gpio496/direction +v=1 +while true; do + echo $v > gpio480/value + echo $v > gpio481/value + echo $v > gpio482/value + echo $v > gpio488/value + echo $v > gpio496/value + if [ $v -eq 1 ]; then + v=0 + else + v=1 + fi + sleep 1 +done diff --git a/run b/run index f51e38d..a555297 100755 --- a/run +++ b/run @@ -40,7 +40,8 @@ env \ make \ O="$outdir" \ BR2_JLEVEL="$(($(nproc) - 2))" \ - HOST_QEMU_OPTS="--enable-debug --enable-sdl --with-sdlabi=2.0" \ + HOST_QEMU_OPTS="--enable-debug --enable-sdl --extra-cflags='-DDEBUG_PL061=1' --with-sdlabi=2.0" \ + host-qemu-reconfigure \ host-qemu-rebuild \ kernel_module-rebuild \ all \