Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Nov 2025 18:54:56 +0100
From:      Tomek CEDRO <tomek@cedro.info>
To:        "Daniel O'Connor" <darius@dons.net.au>
Cc:        Sulev-Madis Silber <freebsd-hackers-freebsd-org952@ketas.si.pri.ee>,  freebsd-hackers@freebsd.org
Subject:   Re: addressable led driver
Message-ID:  <CAFYkXjnqqfmO7zWv4-diFa99ZsDc2Dor2DK4qowLzhh_=a=v8g@mail.gmail.com>
In-Reply-To: <4DE06290-81C0-4D21-8919-5A39B1DB3949@dons.net.au>
References:  <BB74B308-9501-4DA0-89E9-4DA0AE553AA5@ketas.si.pri.ee> <4DE06290-81C0-4D21-8919-5A39B1DB3949@dons.net.au>

next in thread | previous in thread | raw e-mail | index | archive | help

On Fri, Nov 14, 2025 at 4:31 AM Daniel O'Connor <darius@dons.net.au> wrote:
> > On 14 Nov 2025, at 11:27, Sulev-Madis Silber <freebsd-hackers-freebsd-org952@ketas.si.pri.ee> wrote:
> > i want to create a proper driver together with userland tools to control all addressable leds directly from fbsd
> >
> > they all have different cursed protocols that don't fit spi at all
> > most popular is ws1812 which would mean if you want actual spi it would be clockless and this all kind of sucks
> >
> > i found gpiospi.c which is entirely undocumented. unsure how to get it working, i tried and failed
>
> gpiospi.c does bit banging - I think you will struggle to meet the timing requirements for WS2812 with it unless you do something horrible like disable all IRQs, send the bit stream and then enable them again.
>
> What actual SoC do you have?
>
> For example, the Beaglebone has PRUs which are simple coprocessors which can do this sort of bit banging (I have done it in Linux using LEDScape).
>
> If you don’t have something like that then SPI is probably the most reliable but be aware that you have to care a lot about the clock speed it uses so if the SoC changes clock speed for power saving it might make your clock speed wrong (I ran into this in the RPi4 for I2C).

Yup, very hard to accomplish these timings for WS2812B with GPIO on
MCU, especially when some sort of RTOS + SDK is in use. Usually SPI or
RMT peripheral is used to generate these pulses with correct timings.
The smallest and cheapest MCU is AtTiny series but not much
peripherals. Also note that "bare" WS2812B needs 5V on the data line,
but WS2812B-MINI works with 3.3V data logic :-)

On the other hand I found some "AURA LED Controller" on my
motherboard. It shows up as the USB Device:

% usbconfig -d1.2 dump_device_desc
ugen1.2: <AURA LED Controller ASUSTek Computer, Inc.> at usbus1, cfg=0
md=HOST spd=FULL (12Mbps) pwr=ON (16mA)

  bLength = 0x0012
  bDescriptorType = 0x0001
  bcdUSB = 0x0200
  bDeviceClass = 0x0000  <Probed by interface class>
  bDeviceSubClass = 0x0000
  bDeviceProtocol = 0x0000
  bMaxPacketSize0 = 0x0040
  idVendor = 0x0b05
  idProduct = 0x19af
  bcdDevice = 0x0100
  iManufacturer = 0x0001  <AsusTek Computer Inc.>
  iProduct = 0x0002  <AURA LED Controller>
  iSerialNumber = 0x0003  <XXX>
  bNumConfigurations = 0x0001

Maybe this is the best generic way to support these leds over USB and
let some dedicated hardware (i.e. STM/ESP/whatever has USB) do the
rest? And maybe there is already some standard protocol?

--
CeDeROM, SQ7MHZ, http://www.tomek.cedro.info



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFYkXjnqqfmO7zWv4-diFa99ZsDc2Dor2DK4qowLzhh_=a=v8g>