{"id":16357817,"url":"https://github.com/rsta2/uspi","last_synced_at":"2025-07-01T15:09:23.114Z","repository":{"id":22834564,"uuid":"26181706","full_name":"rsta2/uspi","owner":"rsta2","description":"A bare metal USB driver for Raspberry Pi 1-3 written in C","archived":false,"fork":false,"pushed_at":"2023-03-16T10:38:45.000Z","size":317,"stargazers_count":291,"open_issues_count":2,"forks_count":52,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-05-19T17:14:36.747Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","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/rsta2.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-11-04T18:09:08.000Z","updated_at":"2025-04-29T14:26:51.000Z","dependencies_parsed_at":"2024-12-31T07:20:47.130Z","dependency_job_id":null,"html_url":"https://github.com/rsta2/uspi","commit_stats":{"total_commits":65,"total_committers":4,"mean_commits":16.25,"dds":0.09230769230769231,"last_synced_commit":"80146e0c434d6a2111924af31dff3cfccdded20e"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/rsta2/uspi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsta2%2Fuspi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsta2%2Fuspi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsta2%2Fuspi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsta2%2Fuspi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rsta2","download_url":"https://codeload.github.com/rsta2/uspi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rsta2%2Fuspi/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262986747,"owners_count":23395389,"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":[],"created_at":"2024-10-11T02:04:11.662Z","updated_at":"2025-07-01T15:09:23.087Z","avatar_url":"https://github.com/rsta2.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"USPi\n====\n\n\u003e Raspberry Pi is a trademark of the Raspberry Pi Foundation.\n\n\u003e If you read this file in an editor you should switch line wrapping on.\n\nOverview\n--------\n\nUSPi is a bare metal USB driver for the Raspberry Pi written in C. It was ported from the Circle USB library. Using C allows it to be used from bare metal C code for the Raspberry Pi. Like the Circle USB library it supports control (synchronous), bulk and interrupt (synchronous and asynchronous) transfers. Function drivers are available for USB keyboards, mice, MIDI instruments, gamepads, mass storage devices (e.g. USB flash devices) and the on-board Ethernet controller. USPi should run on all existing Raspberry Pi models.\n\nUSPi comes with an environment library (in the *env/* subdirectory) which provides all required functions to get USPi running. Furthermore there are some sample programs (in the *sample/* subdirectory) which demonstrate the use of USPi and which rely on the environment library. If you provide your own application and environment both are not needed.\n\nPlease note that this USB library was developed in a hobby project. There are known issues with it (e.g. no dynamic attachments, no error recovery, limited split support). For me it works well but that need not be the case with any device and in any situation. Also the focus for development was function not performance.\n\nUSPi was \"mechanically\" ported from the Circle USB library which is written in C++. That's why the source code may look a little bit strange. But it was faster to do so.\n\nDirectories\n-----------\n\n* include: USPi header files\n* lib: USPi source code\n* sample: Some sample programs\n* env: The environment used by the sample programs (not needed by the USPi library itself)\n* doc: Additional documentation files\n\nInterface\n---------\n\nThe USPi library provides functions to be used by the bare metal environment to access USB devices. There are eight groups of functions which are declared in *include/uspi.h*:\n\n* USPi initialization\n* Keyboard\n* Mouse\n* GamePad/Joystick\n* USB Mass storage device\n* Ethernet controller\n* MIDI (input only)\n* USB device information\n\nThe bare metal environment has to provide some functions to the USPi library which are declared in *include/uspios.h*. There are the six groups of functions:\n\n* Memory allocation\n* Timer\n* Interrupt handling\n* Property tags\n* Logging\n* Debug support\n\nConfiguration\n-------------\n\nBefore you build the USPi library you have to configure it to meet your system configuration in the file *include/uspios.h* (top section).\n\nAnother option (NDEBUG) can be defined in Rules.mk to build the release version. In the test phase it is better to use the debug version which contains many additional checks.\n\nBuilding\n--------\n\n\u003e For AArch64 support go to the end of this file.\n\nBuilding is normally done on PC Linux. If building for the Raspberry Pi 1 you need a [toolchain](http://elinux.org/Rpi_Software#ARM) for the ARM1176JZF core. For Raspberry Pi 2/3 you need a toolchain with Cortex-A7/-A53 support. A toolchain, which works for all of these, can be downloaded [here](https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads). USPi has been tested with the version *7-2018-q2-update* from this website. You can also build USPi on the Raspberry Pi itself on Raspbian.\n\nFirst edit the file *Rules.mk* and set the Raspberry Pi version (*RASPPI*, 1, 2 or 3) and the *PREFIX* of your toolchain commands. Alternatively you can create a *Config.mk* file (which is ignored by git) and set the Raspberry Pi version and the *PREFIX* variable to the prefix of your compiler like this (don't forget the dash at the end):\n\n`RASPPI = 1`  \n`PREFIX = arm-none-eabi-`\n\nThen go to the lib/ directory of USPi and do:\n\n`make clean`  \n`make`\n\nThe ready build *libuspi.a* file should be in the lib/ directory.\n\nUsing\n-----\n\nAdd the USPi include/ directory to the include path in your Makefile and specify the *libuspi.a* library to *ld*. Include the file *uspi.h* where you want to access USPi functions.\n\nSamples\n-------\n\nThe sample programs in the *sample/* subdirectory and all required libraries can be build from USPi root by:\n\n`./makeall clean`  \n`./makeall`\n\nThe ready build *kernel.img* image file is in the same directory where its source code is. Copy it on a SD(HC) card along with the firmware files *bootcode.bin*, *fixup.dat* and *start.elf* which can be get [here](https://github.com/raspberrypi/firmware/tree/master/boot). Put the SD(HC) card into your Raspberry Pi and start it.\n\nAArch64\n-------\n\nThe USPi library can be built so that it can be used in an AArch64 (64-bit) environment. You have to define the following in the file *Rules.mk* or *Config.mk* before build to do this:\n\n\tAARCH64 = 1\n\nThe AArch64 support does not come with an environment library. Therefore it can be used only together with your own provided OS environment. The sample programs in the *sample/* subdirectory cannot be built out-of-the-box.\n\nTo build the USPi library do the following:\n\n\tcd lib\n\tmake clean\n\tmake\n\nYou should add `-DAARCH64=1` to the compiler options in your OS environment when using the USPi library in AArch64 mode there.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsta2%2Fuspi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frsta2%2Fuspi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frsta2%2Fuspi/lists"}