You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
3561
-
3562
-
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
3563
-
3564
-
The best you can do is to hack our link:build[] script to add:
3565
-
3566
-
....
3567
-
HOST_QEMU_OPTS='--extra-cflags=-DDEBUG_PL061=1'
3568
-
....
3569
-
3570
-
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.
* it is possible to restore snapshots across boots, since they stay on the same image the entire time
3837
3735
* it is not possible to use snapshots with <<initrd>> in our setup, since we don't pass `-drive` at all when initrd is enabled
3838
3736
3839
-
=== Educational hardware models
3737
+
=== Hardware models
3840
3738
3841
-
We have added and interacted with a few educational hardware models in QEMU.
3739
+
This section documents some interesting peripheral hardware models, specially simpler ones that are fun to learn.
3842
3740
3843
-
This is useful to learn:
3741
+
Studying them can teach you:
3844
3742
3845
3743
* how to create new hardware models for QEMU. Overview: https://stackoverflow.com/questions/28315265/how-to-add-a-new-device-in-qemu-source-code
3846
3744
* how the Linux kernel interacts with hardware
3847
3745
3848
3746
To get started, have a look at the "Hardware device drivers" section under link:kernel_module/README.adoc[], and try to run those modules, and then grep the QEMU source code.
3849
3747
3850
-
==== platform_device
3748
+
==== Mainline hardware models
3749
+
3750
+
This section documents hardware models present in the QEMU upstream.
3751
+
3752
+
===== GPIO
3753
+
3754
+
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.
3755
+
3756
+
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
3757
+
3758
+
The best you can do is to hack our link:build[] script to add:
3759
+
3760
+
....
3761
+
HOST_QEMU_OPTS='--extra-cflags=-DDEBUG_PL061=1'
3762
+
....
3763
+
3764
+
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.
printf("LED val = %llx\n", (unsigned long long)val);
3797
+
....
3798
+
3799
+
and then rebuild with:
3800
+
3801
+
....
3802
+
./build -aa -c kernel_config_fragment/leds -lq
3803
+
....
3804
+
3805
+
But beware that one of the LEDs has a heartbeat trigger by default (specified on dts), so it will produce a lot of output.
3806
+
3807
+
And then activate it with:
3808
+
3809
+
....
3810
+
cd /sys/class/leds/versatile:0
3811
+
cat max_brightness
3812
+
echo 255 >brightness
3813
+
....
3814
+
3815
+
Relevant QEMU files:
3816
+
3817
+
* `hw/arm/versatilepb.c`
3818
+
* `hw/misc/arm_sysctl.c`
3819
+
3820
+
Relevant kernel files:
3821
+
3822
+
* `arch/arm/boot/dts/versatile-pb.dts`
3823
+
* `drivers/leds/led-class.c`
3824
+
* `drivers/leds/leds-sysctl.c`
3825
+
3826
+
==== Fork hardware models
3827
+
3828
+
This section documents hardware models added on link:https://github.com/cirosantilli/qemu[our fork of QEMU].
3829
+
3830
+
These have been explicitly designed to be educational rather than model real existing hardware.
3831
+
3832
+
===== platform_device
3851
3833
3852
3834
This is an example of hardware coded into an ARM `-M versatilepb` SoC.
3853
3835
3854
-
Using this device now requires checking out to: https://github.com/cirosantilli/linux-kernel-module-cheat/tree/platform-device before building, it does not work on master.
3836
+
Using this device now requires checking out to the branch:
3837
+
3838
+
....
3839
+
git checkout platform-device
3840
+
....
3841
+
3842
+
before building, it does not work on master.
3855
3843
3856
3844
The module itself can be found at: https://github.com/cirosantilli/linux-kernel-module-cheat/blob/platform-device/kernel_module/platform_device.c
0 commit comments