Re: esp32 custom board gpio and ws2812 problem
On Mon, May 22, 2023 at 5:02 PM Alan C. Assis wrote: > Just a update from Espressif: probably ESP32-C5 will have USB OTG, but > since it was not released yet we cannot confirm it (things can change > before releasing the chip). Thank You Alan!! :-) -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info
Re: esp32 custom board gpio and ws2812 problem
Hi Tomek, Just a update from Espressif: probably ESP32-C5 will have USB OTG, but since it was not released yet we cannot confirm it (things can change before releasing the chip). They suggested that companies interested on get this information should ask directly to the business support: sa...@espressif.com BR, Alan On 5/20/23, Tomek CEDRO wrote: > Well all ESP32-C3 boards that I have (DevKit, M5) have UART-to-USB > converter so no JTAG so far.. I will order Beetle ESP32-C3 this one > should have direct USB/UART/JTAG pins on the USB-C connector :-) > > I have ordered ESP32-S2 as it has USB OTG. I really miss RISC-V MCU > with USB Device/OTG.. ESP32-C6 would be perfect if it only had this > (it has WiFi + BLE + Mesh already) :-) > > Is there any chance that Espressif releases ESP32-C6 + USB OTG anytime soon? > :-) > > -- > CeDeROM, SQ7MHZ, http://www.tomek.cedro.info >
Re: esp32 custom board gpio and ws2812 problem
Maybe OTG is superseded? USB C dual role port is the way to go, but needs a 25c chip and software support to make it work. FUSB30x FTW :) From: "Alan C. Assis" Reply to: "dev@nuttx.apache.org" Date: Saturday, 20 May 2023 at 20:10 To: "dev@nuttx.apache.org" Subject: Re: esp32 custom board gpio and ws2812 problem Hi Tomek, On 5/20/23, Tomek CEDRO mailto:to...@cedro.info>> wrote: Well all ESP32-C3 boards that I have (DevKit, M5) have UART-to-USB converter so no JTAG so far.. I will order Beetle ESP32-C3 this one should have direct USB/UART/JTAG pins on the USB-C connector :-) I have ordered ESP32-S2 as it has USB OTG. I really miss RISC-V MCU with USB Device/OTG.. ESP32-C6 would be perfect if it only had this (it has WiFi + BLE + Mesh already) :-) Is there any chance that Espressif releases ESP32-C6 + USB OTG anytime soon? :-) C6 is like C3, only USB Serial/JTAG, not real USB OTG support: https://www.espressif.com/sites/default/files/documentation/esp32-c6_technical_reference_manual_en.pdf BR, Alan
Re: esp32 custom board gpio and ws2812 problem
Hi Tomek, On 5/20/23, Tomek CEDRO wrote: > Well all ESP32-C3 boards that I have (DevKit, M5) have UART-to-USB > converter so no JTAG so far.. I will order Beetle ESP32-C3 this one > should have direct USB/UART/JTAG pins on the USB-C connector :-) > > I have ordered ESP32-S2 as it has USB OTG. I really miss RISC-V MCU > with USB Device/OTG.. ESP32-C6 would be perfect if it only had this > (it has WiFi + BLE + Mesh already) :-) > > Is there any chance that Espressif releases ESP32-C6 + USB OTG anytime soon? > :-) C6 is like C3, only USB Serial/JTAG, not real USB OTG support: https://www.espressif.com/sites/default/files/documentation/esp32-c6_technical_reference_manual_en.pdf BR, Alan
Re: esp32 custom board gpio and ws2812 problem
Well all ESP32-C3 boards that I have (DevKit, M5) have UART-to-USB converter so no JTAG so far.. I will order Beetle ESP32-C3 this one should have direct USB/UART/JTAG pins on the USB-C connector :-) I have ordered ESP32-S2 as it has USB OTG. I really miss RISC-V MCU with USB Device/OTG.. ESP32-C6 would be perfect if it only had this (it has WiFi + BLE + Mesh already) :-) Is there any chance that Espressif releases ESP32-C6 + USB OTG anytime soon? :-) -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info
Re: esp32 custom board gpio and ws2812 problem
On Thu, May 18, 2023 at 9:13 PM Alan C. Assis wrote: > There is also the RMT driver from Victor Benso: > https://www.youtube.com/watch?v=rmOh9iGzwtk > He submitted a PR to mainline: https://github.com/apache/nuttx/pull/6992 > Maybe you can work with him to fix the remaining issue and get it merged! Thank you Alan! :-) Hello Victor :-) I have assigned myself to the Issue, please let us know the status and how can I help :-) -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info
Re: esp32 custom board gpio and ws2812 problem
On Thu, May 18, 2023 at 9:31 PM Tomek CEDRO wrote: > 2. WS2812 timing pains. I know it is possible to drive WS2812 from > ESP32 because I have done that already on MicroPyhon both with GPIO > bitbang and even better with RMT peripheral that makes it walk in the > park (we can make one for NuttX!!) :-) Okay, I think I got it better now with you hints guys, thank you! This is my loud learning curve so please remain calm :-P :-P So currently there is a SPI and non-SPI (aka gpio bitnabg) WS2812 driver. GPIO bitbang driver is most generic but uses underlying layers of application -> device_file -> upper_half -> lower_half -> MCU_SDK and that is too slow for most implementations to generate nanosecond pulses. It _may_ work for really fast MCU but it will probably not work for most implementations..? I did not manage to compile code for SPI driver for ESP32 (build error speed unsupported). But it still may work and is quite generic approach on the chips that have SPI peripheral with desired speed support. Yet another approach, that would provide "proven-to-work" trademark , is providing arch/chip specific lower half driver? For instance ESP32 could use RMT peripheral, that would be implemented in arch/chip level for all ESP32 based boards. So verified solution would be using arch/chip code, and user could use SPI or bitbang as alternate fallback that _may_ work if the arch/chip code is not available for a given chip? We would then have kind of compatibility matrix / verified hardware notification at glance :-) -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info
Re: esp32 custom board gpio and ws2812 problem
On Thu, May 18, 2023 at 8:59 PM Brennan Ashton wrote: > I tested it on an nRF52 but I think others have use STM32. It is > particular since we are abusing SPI for something that looks kind of like > SPI. I recommend using a logic analyzer to verify the waveform on the wire > if debugging this. Thanks Brennan :-) I have various STM32 and nRF52 boards. But at this point I am working with ESP32. The problem I am facing now is that ws2812 application does not want to open /dev/led_rgb device for some reason while gpio application works fine with that dev. So its not yet really timing related. Most likely a messed up custom board / build / peripherals configuration? :-P -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info
Re: esp32 custom board gpio and ws2812 problem
On Thu, May 18, 2023 at 8:53 PM Alan C. Assis wrote: > Hi Tomek, > > I don't think you can get ws2812 working directly using a GPIO over > bitbang, the protocol used by this chip is very time sensitive. > Actually even in SPI mode I failed to get it working, I tried it on > stm32f103-minimum and stm32f4discover because AFAIK originally Brennan > implemented and tested the driver in STM32. Whoops o_O There are two problems: 1. ws2812 application not talking to the (working) /dev/led_rgb what I would love to understand and solve in the first place as my learning curve :-) 2. WS2812 timing pains. I know it is possible to drive WS2812 from ESP32 because I have done that already on MicroPyhon both with GPIO bitbang and even better with RMT peripheral that makes it walk in the park (we can make one for NuttX!!) :-) I have already whole bunch WS2812-MINI WS2813 etc already purchased in the boxes and on boards so I cannot really replace them at this point.. but thank you for the APA102 / SK9822 hints I never used them and they may be better solution for smaller MCUs! :-) As for now I just need to make at least one RGB LED shine green or red so anything else can stop for that short time (~1.2us). Is there a some sort of compatibility matrix in NuttX to quickly see what peripheral will work on what hardware.. in terms of what has been proven to work? Maybe a Kconfig confirmation/warning flag? Or its always trial-and-error-evaluation? > For GDB debug you will need a ESP-Prog or some OpenOCD compatible JTAG > programmer. > More info here: > https://acassis.wordpress.com/2021/05/12/debugging-esp32-using-openocd-and-gdb/ Yeah I have whole bunch of JTAG probes and I have created initial port of OpenOCD for FreeBSD.. I was wondering is there any other way I would like to debug this situation on a running production device where JTAG pins are already used by peripherals? For instance GDB that runs on target nsh over UART/Telnet? Alternatively, I am considering trying out the same application running on a ESP32-C3 (with the same GPIO and RMT I guess?) that has this magic USB/JTAG port, because I never used that before, and NuttX portability allows me to rebuild everything for a different hardware in 17 sec that is faster than I reach out to my cables box :-) :-) -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info
Re: esp32 custom board gpio and ws2812 problem
On 5/18/23, Brennan Ashton wrote: > On Thu, May 18, 2023, 11:53 AM Alan C. Assis wrote: > >> I don't think you can get ws2812 working directly using a GPIO over >> bitbang, the protocol used by this chip is very time sensitive. >> Actually even in SPI mode I failed to get it working, I tried it on >> stm32f103-minimum and stm32f4discover because AFAIK originally Brennan >> implemented and tested the driver in STM32. >> >> BR, >> >> Alan >> > > I tested it on an nRF52 but I think others have use STM32. It is > particular since we are abusing SPI for something that looks kind of like > SPI. I recommend using a logic analyzer to verify the waveform on the wire > if debugging this. > Thank you Brennan, so it was nRF52! There is also the RMT driver from Victor Benso: https://www.youtube.com/watch?v=rmOh9iGzwtk He submitted a PR to mainline: https://github.com/apache/nuttx/pull/6992 Maybe you can work with him to fix the remaining issue and get it merged! BR, Alan
Re: esp32 custom board gpio and ws2812 problem
On 5/18/23, Tomek CEDRO wrote: > Hello world :-) > > === Short Story Long === > > I have just created my first custom board configuration based on > ESP32DevkitC. Both application and board configuration is external to > the nuttx.git and nuttx-apps.git (these are git submodules of my > project). > > From what I can see the board definition for ESP32DevkitC is only a > template as it does not define all GPIOs for use. So I have modified > myboard/src/esp32_gpio.c that is creates all /dev/blah entries for > gpio in/out/irq. Why the board definition does not define all GPIO as > devices? Would that interfere with alternate functions assigned to the > pins even on read? > > I have also added ws2812 driver (non SPI one) for LED RGB as part of the > UI. > > I have added gpio and ws2812 example application to test gpio from > nsh. There is a /dev/led_rgb output device created that will drive > WS2812 LED. I can read/write that pin state with gpio application, but > ws2812 application cannot write to that device. Any hints are welcome > here why :-) > > As a remark I can mention that initially that GPIO initialization > caused kernel panic triggered by assertion in the chip gpio code. > Having that assertion helped me figure out that some pins (34..39) > cannot use pull-up/dn that are by default set on gpio irq > initialization. That assertion helped me a lot, thank you! > > What else can I do to trace/debug the ws2812 write problem from the OS > perspective? I cannot really use JTAG pins as they are already used by > some external peripherals on the board. I can work on ESP32DevkitC > with that single example WS2812, but there may be some better way > already out there that would not involve JTAG? > > === Long Story short === > > 1. If I create /dev/gpio0 as GPIO input, and then use that pin for > alternate function would reading /dev/gpio0 interfere with alternate > function? This is important for situations where GPIO configuration is > done at runtime (ie. alternate hardware configuration like GPIO vs > CAN). > > 2. I have /dev/led_rgb set as output that can be successfully > controlled with gpio utility (i.e. set 1 or 0 + readout), but the > ws2812 application (non SPI mode) has problems opening/using that > device (error code -1). Is there any way to tell why opening device > fails? Is it open already by other application for writing? I guess > only one application can have file opened for writing right? > > 3. Is there any way to OS level trace driver development related > problems that would not involve JTAG debug? Something like gdb/kdb > launched from nsh? > > Any hints welcome :-) If you don't want to have timing issues a good option is using APA102 or its clone chip SK9822. They will work with any SPI and any speed. Very reliable! More info: https://cpldcpu.wordpress.com/2016/12/13/sk9822-a-clone-of-the-apa102/ BR, Alan
Re: esp32 custom board gpio and ws2812 problem
On Thu, May 18, 2023, 11:53 AM Alan C. Assis wrote: > I don't think you can get ws2812 working directly using a GPIO over > bitbang, the protocol used by this chip is very time sensitive. > Actually even in SPI mode I failed to get it working, I tried it on > stm32f103-minimum and stm32f4discover because AFAIK originally Brennan > implemented and tested the driver in STM32. > > BR, > > Alan > I tested it on an nRF52 but I think others have use STM32. It is particular since we are abusing SPI for something that looks kind of like SPI. I recommend using a logic analyzer to verify the waveform on the wire if debugging this. --Brennan
Re: esp32 custom board gpio and ws2812 problem
Hi Tomek, On 5/18/23, Tomek CEDRO wrote: > Hello world :-) > > === Short Story Long === > > I have just created my first custom board configuration based on > ESP32DevkitC. Both application and board configuration is external to > the nuttx.git and nuttx-apps.git (these are git submodules of my > project). > > From what I can see the board definition for ESP32DevkitC is only a > template as it does not define all GPIOs for use. So I have modified > myboard/src/esp32_gpio.c that is creates all /dev/blah entries for > gpio in/out/irq. Why the board definition does not define all GPIO as > devices? Would that interfere with alternate functions assigned to the > pins even on read? > > I have also added ws2812 driver (non SPI one) for LED RGB as part of the > UI. > > I have added gpio and ws2812 example application to test gpio from > nsh. There is a /dev/led_rgb output device created that will drive > WS2812 LED. I can read/write that pin state with gpio application, but > ws2812 application cannot write to that device. Any hints are welcome > here why :-) > > As a remark I can mention that initially that GPIO initialization > caused kernel panic triggered by assertion in the chip gpio code. > Having that assertion helped me figure out that some pins (34..39) > cannot use pull-up/dn that are by default set on gpio irq > initialization. That assertion helped me a lot, thank you! > > What else can I do to trace/debug the ws2812 write problem from the OS > perspective? I cannot really use JTAG pins as they are already used by > some external peripherals on the board. I can work on ESP32DevkitC > with that single example WS2812, but there may be some better way > already out there that would not involve JTAG? > > === Long Story short === > > 1. If I create /dev/gpio0 as GPIO input, and then use that pin for > alternate function would reading /dev/gpio0 interfere with alternate > function? This is important for situations where GPIO configuration is > done at runtime (ie. alternate hardware configuration like GPIO vs > CAN). > > 2. I have /dev/led_rgb set as output that can be successfully > controlled with gpio utility (i.e. set 1 or 0 + readout), but the > ws2812 application (non SPI mode) has problems opening/using that > device (error code -1). Is there any way to tell why opening device > fails? Is it open already by other application for writing? I guess > only one application can have file opened for writing right? > > 3. Is there any way to OS level trace driver development related > problems that would not involve JTAG debug? Something like gdb/kdb > launched from nsh? > > Any hints welcome :-) I don't think you can get ws2812 working directly using a GPIO over bitbang, the protocol used by this chip is very time sensitive. Actually even in SPI mode I failed to get it working, I tried it on stm32f103-minimum and stm32f4discover because AFAIK originally Brennan implemented and tested the driver in STM32. For GDB debug you will need a ESP-Prog or some OpenOCD compatible JTAG programmer. More info here: https://acassis.wordpress.com/2021/05/12/debugging-esp32-using-openocd-and-gdb/ BR, Alan
esp32 custom board gpio and ws2812 problem
Hello world :-) === Short Story Long === I have just created my first custom board configuration based on ESP32DevkitC. Both application and board configuration is external to the nuttx.git and nuttx-apps.git (these are git submodules of my project). >From what I can see the board definition for ESP32DevkitC is only a template as it does not define all GPIOs for use. So I have modified myboard/src/esp32_gpio.c that is creates all /dev/blah entries for gpio in/out/irq. Why the board definition does not define all GPIO as devices? Would that interfere with alternate functions assigned to the pins even on read? I have also added ws2812 driver (non SPI one) for LED RGB as part of the UI. I have added gpio and ws2812 example application to test gpio from nsh. There is a /dev/led_rgb output device created that will drive WS2812 LED. I can read/write that pin state with gpio application, but ws2812 application cannot write to that device. Any hints are welcome here why :-) As a remark I can mention that initially that GPIO initialization caused kernel panic triggered by assertion in the chip gpio code. Having that assertion helped me figure out that some pins (34..39) cannot use pull-up/dn that are by default set on gpio irq initialization. That assertion helped me a lot, thank you! What else can I do to trace/debug the ws2812 write problem from the OS perspective? I cannot really use JTAG pins as they are already used by some external peripherals on the board. I can work on ESP32DevkitC with that single example WS2812, but there may be some better way already out there that would not involve JTAG? === Long Story short === 1. If I create /dev/gpio0 as GPIO input, and then use that pin for alternate function would reading /dev/gpio0 interfere with alternate function? This is important for situations where GPIO configuration is done at runtime (ie. alternate hardware configuration like GPIO vs CAN). 2. I have /dev/led_rgb set as output that can be successfully controlled with gpio utility (i.e. set 1 or 0 + readout), but the ws2812 application (non SPI mode) has problems opening/using that device (error code -1). Is there any way to tell why opening device fails? Is it open already by other application for writing? I guess only one application can have file opened for writing right? 3. Is there any way to OS level trace driver development related problems that would not involve JTAG debug? Something like gdb/kdb launched from nsh? Any hints welcome :-) Tomek -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info