LED failed attempt, GPIO working

This commit is contained in:
Ciro Santilli
2017-07-02 15:00:04 +01:00
parent b5cafc8481
commit 8823f45d40
6 changed files with 75 additions and 4 deletions

View File

@@ -47,10 +47,12 @@ If you are feeling fancy, you can also insert modules with:
modprobe hello modprobe hello
and if you are feeling raw, you can use: If you are feeling raw, you can use:
/myinsmod.out /hello.ko /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: 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 dmesg -n 1

View File

@@ -57,3 +57,38 @@ CONFIG_TRACER_SNAPSHOT=y
# https://stackoverflow.com/questions/20069620/print-kernels-page-table-entries # https://stackoverflow.com/questions/20069620/print-kernels-page-table-entries
# cat /sys/kernel/debug/kernel_page_tables # cat /sys/kernel/debug/kernel_page_tables
CONFIG_X86_PTDUMP=y 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

View File

@@ -22,7 +22,9 @@
1. [work_from_work](work_from_work.c) 1. [work_from_work](work_from_work.c)
1. [irq](irq.c) 1. [irq](irq.c)
1. Module dependencies 1. Module dependencies
1. [dep.c](dep.c) 1. [dep](dep.c)
1. [dep2.c](dep2.c) 1. [dep2](dep2.c)
1. [character_device](character_device.c) 1. [character_device](character_device.c)
1. Hardware device drivers
1. [pci](pci.c)
1. [user](user/) 1. [user](user/)

View File

@@ -6,3 +6,7 @@ We use it to for things like:
- customized configuration files - customized configuration files
- userland module test scripts - 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)

27
rootfs_overlay/gpio.sh Executable file
View File

@@ -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

3
run
View File

@@ -40,7 +40,8 @@ env \
make \ make \
O="$outdir" \ O="$outdir" \
BR2_JLEVEL="$(($(nproc) - 2))" \ 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 \ host-qemu-rebuild \
kernel_module-rebuild \ kernel_module-rebuild \
all \ all \