{"id":14978048,"url":"https://github.com/berdav/qemu-rpi-gpio","last_synced_at":"2025-10-28T07:31:17.837Z","repository":{"id":43071307,"uuid":"317525562","full_name":"berdav/qemu-rpi-gpio","owner":"berdav","description":"Simulate GPIOs in qemu-based Raspberry PI","archived":false,"fork":false,"pushed_at":"2022-12-01T10:49:35.000Z","size":25,"stargazers_count":28,"open_issues_count":5,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T12:44:13.164Z","etag":null,"topics":["gpio","qemu","raspberry-pi","virtualization"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/berdav.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-01T11:53:00.000Z","updated_at":"2024-10-30T20:09:36.000Z","dependencies_parsed_at":"2023-01-23T20:00:47.257Z","dependency_job_id":null,"html_url":"https://github.com/berdav/qemu-rpi-gpio","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berdav%2Fqemu-rpi-gpio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berdav%2Fqemu-rpi-gpio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berdav%2Fqemu-rpi-gpio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/berdav%2Fqemu-rpi-gpio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/berdav","download_url":"https://codeload.github.com/berdav/qemu-rpi-gpio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238614445,"owners_count":19501458,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gpio","qemu","raspberry-pi","virtualization"],"created_at":"2024-09-24T13:56:46.876Z","updated_at":"2025-10-28T07:31:12.546Z","avatar_url":"https://github.com/berdav.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# QEMU RPI GPIO\nSimulate GPIO in qemu-based Raspberry Pi\n\n## How it works\nThe script (`qemu-rpi-gpio`) present in this repository interacts with qemu \nusing the built-in `qtest` protocol.\n\nWrapping the protocol and interacting with the memory of the guest operating\nsystem, it can set or reset the various GPIOs.\n\n**Note:** Vanilla qemu (5.1.93) will not handle GPIO interrupts, therefore\nloading `/sys/class/gpio/gpio$N/direction` and waiting for an interrupt\nwill not do anything.\n\nTo enable interrupt support you'll need to download and compile\n[this qemu fork](https://github.com/berdav/qemu).\n\n## Installation\nYou can install the script via pip with\n```\npip install qemu-rpi-gpio\n```\n\n## Prereqisites\nYou need `socat`, `python3` and `pexpect` library to use this\nscript.\n\nThese can be installed under ubuntu with:\n```\nsudo apt install python3-pexpect socat\n```\n\nTo download raspbian images you'll need 7zip\n```\nsudo apt install p7zip-full\n```\n\n## Setup\nDownload a raspbian image using\n```\n./qemu-pi-setup/setup.sh\n```\n\nAfter this operation, execute the script to load the unix socket and make it\navailable to qemu\n```\n./qemu-rpi-gpio\n```\n\nYou will be prompted to an interactive shell, you can find the commands available\nin the *Interacting with gpios* section.\n\nIn another terminal execute the `./qemu-pi-setup/run.sh` script, this will execute a virtual\nraspberry pi and attach it to the gpio application.\n\nIf you close the raspberry pi you can reload the socket using the command\n`reload` in the qemu-rpi-gpio prompt.\n\n## Interacting with gpios\n\nFirst of all, you need to export GPIOs in your guest Linux.\nIn a shell on your raspberry pi do:\n```\n$ sudo su -\n# echo 4 \u003e/sys/class/gpio/export\n# echo in \u003e/sys/class/gpio/direction\n```\n\nThe main commands in the `qemu-rpi-gpio` application are:\n\n| command     | description                             | example |\n|-------------|-----------------------------------------|---------|\n| `get $N`    | get the value of GPIO $N                | get 4   |\n| `set $N $V` | set the value of GPIO $N to $V (1 or 0) | set 4 1 |\n\nYou can get the full list of commands using `help`\n\nFor instance, let us set the value of the pre-exported gpio 4\n```\n(gpio)\u003e set 4 1\n```\n\nNow you can read the value of your gpio \n\n```\n# cat /sys/class/gpio/value\n1\n```\n\nIf we set it to zero, it will be immediately reflected in the guest system\n```\n(gpio)\u003e set 4 0\n```\n```\n# cat /sys/class/gpio/value\n0\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fberdav%2Fqemu-rpi-gpio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fberdav%2Fqemu-rpi-gpio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fberdav%2Fqemu-rpi-gpio/lists"}