https://toitlang.org/ logo
Issues with simple Neopixel code
# help
a
Using the following code, I get this when using
jag monitor
. Any ideas?
Copy code
import gpio
import pixel_strip show PixelStrip

PIXELS ::= 1
main:
  pin := gpio.Pin 08
  pixels := PixelStrip.uart PIXELS --pin=pin

  r := ByteArray PIXELS
  g := ByteArray PIXELS
  b := ByteArray PIXELS

  r.fill 0x44
  g.fill 0x80
  b.fill 0xff

  pixels.output r g b

  sleep --ms=1
https://cdn.discordapp.com/attachments/1432094642517704946/1432094642761109615/message.txt?ex=6901c7d1&is=69007651&hm=9bee49a60b551b46298f8298e2d562c69afc3af74da7665ee36c1ef66576a1f4&
f
Interesting. 10:1 is uart::create if I'm not wrong
I don't see how and/or why that would take too long
Is it reproducible?
In the meantime, you can just use
Pixelstrip.rmt
. (for one pixel that should work perfectly fine)
I can reproduce.
And the
rmt
variant doesn't seem to work either. Very strange. I will debug.
a
rmt
puts it into deep-sleep
Copy code
alexanderniebuhr@MacBookPro ~/D/P/c/toit [1]> jag monitor
✔ /dev/cu.usbmodem578E0248291
Starting serial monitor of port '/dev/cu.usbmodem578E0248291' ...
J�ESP-ROM:esp32c6-20220919
Build:Sep 19 2022
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:2
load:0x40875720,len:0x9c
load:0x4086c110,len:0xb94
load:0x4086e610,len:0x2534
entry 0x4086c110
[toit] INFO: starting <v2.0.0-alpha.188>
[toit] DEBUG: clearing RTC memory: invalid checksum
[toit] INFO: running on ESP32C6 - revision 0.0
[toit] INFO: entering deep sleep without wakeup time
f
How did you install the rmt version?
For me it just doesn't do anything.
could it be that the program finishes, and then nothing is left to do, and the system goes into deep-sleep?
a
Just installed it and then
jag monitor
f
installed it how?
a
Neopixel doesn't light up
/Users/alexanderniebuhr/.cache/jaguar/sdk/bin/toit compile --snapshot -o hello.snapshot hello.toit && /Users/alexanderniebuhr/.cache/jaguar/sdk/bin/toit tool firmware -e firmware.envelope container install -o hello.envelope hello hello.snapshot && /Users/alexanderniebuhr/.cache/jaguar/sdk/bin/toit tool firmware -e hello.envelope flash --port /dev/tty.usbmodem1401 --baud 921600
f
Ok. That confirms my suspicion.
Basically, your program finishes, and the system then decides that nothing is left to do and shuts down.
If you increase the sleep, you will see that it doesn't go into deep sleep immediately.
However, there is a bug with the
rmt
PixelStrip.rmt on the C6
a
Oh let me put a loop with logs, but I think that doesn't light up the pixel anyways
f
You can work around it for now with the (deprecated) `I2sPixelStrip`:
Copy code
import pixel_strip show I2sPixelStrip
...
main:
  ...
  pixels := I2sPixelStrip PIXELS --pin=pin
I will debug the other ones.
a
I still don't get it to light up. But I'm using a strange waveshare dev board 🤔
f
a
yeah
f
pin 8 looks correct, and I manage to make mine light up. So that's a bit weird.
So the
I2sPixelStrip
variant doesn't work for you?
a
No. But can be my board..
f
Either way, the uart-deadlock is clearly a bug. And the RMT should also work. I just tested on the normal ESP32 and there all three work. Will now try with the s2, s3 and C3.
S2 works.
C3 only works with uart and I2s.
I'm guessing RMT is currently broken on C3 and C6, and uart is broken on C6.
a
I'll get new prototype boards next week.. c3 & c6. But sounds like I have to switch to s3
f
The c6 shouldn't be broken. I'm already debugging the UART issue.
I made a bit of progress, but no solution yet. We are stuck in
uart_ll_update
, which waits for the peripheral to clear a bit. I think the clock isn't active which is why we just keep looping there. Will give up for today, but this is now a high priority.
z
I think I'm running into the same deadlock with UART on C6
I can reproduce it with a very simple:
Copy code
import uart 
import gpio 

RX0 ::= gpio.Pin 14
TX0 ::= gpio.Pin 15

main:


  port1 := uart.Port
      --rx=RX0
      --tx= TX0
      --baud-rate=9600
[toit] INFO: starting [toit] INFO: running on ESP32C6 - revision 0.1
f
Yes. Any UART is currently broken on the C6. It's still my top priority.
z
@floitsch I want to try a serial console app over UART0, which today prints out
log
and
print
statements. will we be able to accept input from Uart0 Rx as program input
f
At the moment there is no way to read from stdin on the esp. However, you could change the sdkconfig do that the default console (with the prints and logs) goes to different pins and then use the original pins for your own UART (or any other use for that matter). You could even keep the tx the same (so that prints... still go to the same output if that's what you want). Biggest downside: - you need your own sdkconfig - only works if you have a uart-usb chip on your board - uses up a UART
z
I guess I could write my own logging module that sends to another UART pin though too, and just do it all natively in Toit?
f
Also an option.
But the stdin needs to be changed in the sdkconfig
(there isn't any inherent problem with exposing the default stdin in Toit. It's just not implemented yet)
z
@floitsch Successfully setup Jaguar v1.58.0 with Toit SDK v2.0.0-alpha.189.
Copy code
import uart 
import gpio 

RX0 ::= gpio.Pin 14
TX0 ::= gpio.Pin 15

main:


  port1 := uart.Port
      --rx=RX0
      --tx= TX0
      --baud-rate=9600
this tiny example still causes a deadlock on c6. Is there a newer version of the SDK that I should be pointing to?
f
My UART PR hasn't been reviewed yet. Maybe I will just commit most things and let Kasper review them after the fact.
z
If I can build your branch I'm okay with that; I'm on Apple Silicon
f
Correct.
z
if @kasperl is willing to review that PR, I would appreciate it; I think setting up the RMT to receive ASCII UART data, 9600 baud, 8N1 might be the alternative you mentioned?
f
The RMT just receives signals. The deciding would be to happen outside. But (I hope) it wouldn't be too complicated. Even if Kasper doesn't find the time I should do another release. Has been too long. I will try to get it done this it next weekend
z
Thanks, @floitsch
I'm happy to test release 190 if you do ship it out this week
f
Still working on it... There are some changes to the DNS that should get tested a bit more (and have a follow-up cleanup PR that is still pending). I could, however just release today and not push it to Jaguar. That should affect fewer people. Would that work for you?
2 Views