flipperdevices / flipperzero-firmware

Flipper Zero firmware source code
https://flipperzero.one
GNU General Public License v3.0
12.15k stars 2.65k forks source link

Expose a USB-GPIO bridge #1240

Closed fx-chun closed 2 years ago

fx-chun commented 2 years ago

Is your feature request related to a problem? Please describe. It would be useful for the Flipper Zero to have a mode that exposes GPIO pins over USB.

Describe the solution you'd like If the Zero is able to emulate a USB interface for a device that already exposes GPIO (like an FT245R), this would allow PCs to interface with the Zero using existing GPIO libraries.

Describe alternatives you've considered Currently kludging a project using the USB-UART interface, but it would be nice to have access to the GPIOs directly.

Additional context n/a

BJamin99 commented 2 years ago

Might be possible to do this by exposing it through an additional USB interface along side the USB-to-UART? Might be interesting to also add support for this interface as an additional board to the Adafruit Blinka project similar to the FT232/FT2232/MCP2221/GreatFET One.

SamuelYvon commented 2 years ago

I'm also looking for this feature and working on implementing it. There already is a start of GPIO feature through the CLI bridge provided by the flipper; I was thinking of extending it to allow binary read/write. A small client interface could be written in python. I also saw a beginning of a RPC interface; maybe it would be possible to control the GPIO pins through that but I haven't looked into it.

BJamin99 commented 2 years ago

Also saw that there may be work on a BusPirate Mode too.

fx-chun commented 2 years ago

I'm also looking for this feature and working on implementing it. There already is a start of GPIO feature through the CLI bridge provided by the flipper; I was thinking of extending it to allow binary read/write. A small client interface could be written in python. I also saw a beginning of a RPC interface; maybe it would be possible to control the GPIO pins through that but I haven't looked into it.

Fantastic @SamuelYvon! Looking forward to it :)

aprosvetova commented 2 years ago

I'm also looking for this feature and working on implementing it. There already is a start of GPIO feature through the CLI bridge provided by the flipper; I was thinking of extending it to allow binary read/write. A small client interface could be written in python. I also saw a beginning of a RPC interface; maybe it would be possible to control the GPIO pins through that but I haven't looked into it.

These enhancements might be useful for humans interacting with CLI, but I strongly advise against using CLI in automated software.

CLI is meant to be used by people and we're trying to keep it as user-friendly as possible.

RPC is the perfect way to go if you want to control your Flipper with software. Maybe our protobuf schema needs a GPIO subsystem?..

SamuelYvon commented 2 years ago

These enhancements might be useful for humans interacting with CLI, but I strongly advise against using CLI in automated software.

I agree, my principal interest right now is GPIO through CLI (for humans). If someone can guide me towards the protobuf format and how I could add such a subsys. I'd gladly make a PR later

SamuelYvon commented 2 years ago

Ok; I figured out the whole RPC thing, so I'm going to implement that as well. I'll link the PR when it's done / in a draft-worthy state

SamuelYvon commented 2 years ago

Maybe our protobuf schema needs a GPIO subsystem?..

See https://github.com/flipperdevices/flipperzero-protobuf/pull/30

I added python bindings in https://github.com/flipperdevices/flipperzero_protobuf_py/pull/5 and the PR for the firmware is here https://github.com/flipperdevices/flipperzero-firmware/pull/1282

skotopes commented 2 years ago

PRs by @SamuelYvon are merged. Please check.

mjsir911 commented 6 months ago

Did this end up exposing a usb gpio device, or is it only accessible through the cli?

This doesn't really solve the issue of interfacing with the flipper's gpio pins through standard gpio libraries.