Re: [TECH TOPIC] Rust for Linux

Geert Uytterhoeven
2021-07-09T07:24:29Z

Hi Linus,

On Fri, Jul 9, 2021 at 12:13 AM Linus Walleij <linus.walleij@linaro.org> wrote:
> On Thu, Jul 8, 2021 at 10:34 PM Miguel Ojeda
> <miguel.ojeda.sandonis@gmail.com> wrote:
> > On Thu, Jul 8, 2021 at 9:49 PM Linus Walleij <linus.walleij@linaro.org> wrote:
> > > With my GPIO maintainer hat on I'd say a GPIO driver would be quite
> > > interesting to look at. We are two GPIO maintainers and Bartosz is
> > > doing the heavy lifting for the moment so I'm connecting Bartosz to this
> > > discussion. (Now he has to read through the whole backlog,
> > > sorry Bart!)
> > >
> > > This is not to say I promise we will merge it or so, but I just generically
> > > like new approaches to old problems so I like this whole thing
> > > overall, despite being critical to some details.
> > >
> > > I am also trying to learn Rust. Baby steps.
> >
> > Thanks a lot for this offer Linus.
> >
> > Do you have a particular one in mind? Ideally, it would be one that
> > has QEMU support or a test suite of some kind, or at least one that
> > you can easily test for us etc.
>
> I don't use QEMU for GPIO development, we are so close to the
> real hardware that it's often not appropriate. We have a testing
> module but that is not a real world driver and would not meet the
> expectations set here of creating real hardware drivers.
>
> I have seen that QEMU has a piece of code for the Arm PrimeCell
> PL061 GPIO block which corresponds to drivers/gpio/gpio-pl061.c
> Note that this hardware apart from being used in all Arm reference
> designs is used on ARMv4T systems that are not supported by
> LLVM but only GCC, which might complicate things.

Still, the PL061 emulation may be incomplete. It also doesn't do that
much yet, i.e. you cannot use it to blink a virtual LED.

> I am a bit oldschool in that I think real hardware is awesome to test
> on. GPIO drivers exist in many shapes and sizes, some are directly
> memory-mapped to hardware registers, some are I2C or SPI.
> Most Raspberry Pis and Beagle Boards have them, albeit the
> on-chip GPIOs are often also pin controllers which complicates
> things. Expanders on I2C and SPI will be simpler. Maybe look
> for an I2C or SPI expander that has no existing kernel support and
> implement it in Rust?

That still requires an I2C or SPI bus, which may not be that easy
to find for people who don't have embedded boards on their desk...
Do you know of any unsupported expanders that connect to USB?
Something like an MCP2210 dev board[1], but that one is mainly
intended for SPI, although some pins can be used as GPIOs. There
is no upstream driver yet, but there is an out-of-tree driver and a
FOSDEM presentation.

[1] E.g. https://www.digikey.be/product-detail/en/microchip-technology/ADM00419/ADM00419-ND/3046570

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds