Closed nbigaouette closed 10 months ago
Probably your dev-board has two USB connectors, one named UART and one USB. the hello_world will print to UART so if you are using USB you won't see anything (after the boot message). You should see something after using the other connector.
Alternatively, you could run the usb_serial_jtag.rs
example and you should see something printed
Thanks for the info!
Yes, the board has two USB-C connectors, one USB and one UART. I can't do anything (yet?) with the USB one, neither monitor nor flash: I simply cannot connect.
For example, if connected to the USB port:
❯ espflash monitor
[2023-11-09T13:49:05Z INFO ] Detected 8 serial ports
[2023-11-09T13:49:05Z INFO ] Ports which match a known common dev board are highlighted
[2023-11-09T13:49:05Z INFO ] Please select a port
✔ Remember this serial port for future use? · no
[2023-11-09T13:49:13Z INFO ] Serial port: '/dev/cu.usbmodem56CC0427961'
[2023-11-09T13:49:13Z INFO ] Connecting...
[2023-11-09T13:49:13Z INFO ] Using flash stub
Error: × The bootloader returned an error
├─▶ Error while running MemData command
╰─▶ Other
❯ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.10s
Running `espflash flash --monitor target/riscv32imac-unknown-none-elf/debug/esp32-c6-hello-v5`
[2023-11-09T13:50:59Z INFO ] Detected 8 serial ports
[2023-11-09T13:50:59Z INFO ] Ports which match a known common dev board are highlighted
[2023-11-09T13:50:59Z INFO ] Please select a port
✔ Remember this serial port for future use? · no
[2023-11-09T13:51:04Z INFO ] Serial port: '/dev/cu.usbmodem56CC0427961'
[2023-11-09T13:51:04Z INFO ] Connecting...
[2023-11-09T13:51:04Z INFO ] Using flash stub
Error: × The bootloader returned an error
├─▶ Error while running MemData command
╰─▶ Other
Everything in the original post was obtained with the cable connected in the UART port, both flashing and monitor.
So I tried the esp32c6-hal
's usb_serial_jtag.rs
example.
I can see the hello world looping.
So the issue could be that the println!()
output of the hello world example is not sent to the proper location? i.e. it should go to the "USB Serial/JTAG" but instead it goes somewhere else (where?). Am I getting this right?
Is there a way to use println!()
or logging to be sent to the proper location on my board?
Thanks!
esp-println supports multiple "backends" chosen via features: https://github.com/esp-rs/esp-println/blob/c5bd57ab10ece3efa16e05d7a0d1322619ee64b8/Cargo.toml#L37-L42 (we need to improve documentation there, https://github.com/esp-rs/esp-println/issues/67)
When changing it you might also need to change it for esp-backtrace (https://github.com/esp-rs/esp-backtrace/blob/db2bb85bc9c24800287912efe305606a9f9ebb2a/Cargo.toml#L26-L30) which is slightly annoying t.b.h.
Awesome, using those dependencies:
[dependencies]
hal = { package = "esp32c6-hal", version = "0.6.0" }
esp-backtrace = { version = "0.9.0", features = [
"esp32c6",
"panic-handler",
"exception-handler",
# See https://github.com/esp-rs/esp-template/issues/125#issuecomment-1805242140
# Don't use "print-uart" on the ESP32-C6, use this instead:
"print-jtag-serial",
] }
esp-println = { version = "0.7.0", default-features = false, features = [
"esp32c6",
# See https://github.com/esp-rs/esp-template/issues/125#issuecomment-1805242140
"jtag_serial",
# Re-enable default features _except_ 'uart'
"critical-section",
"colors",
] }
the minimal hello world example worked as expected, thanks!!
With newer versions there is special option to print to jtag port. You should enable that feature for esp-println and disable default features which enables uart. So dependency will look like:
esp-println = { version = "0.9.0", default-features = false, features = ["esp32c6", "jtag-serial", "log"] }
With newer versions there is special option to print to jtag port. You should enable that feature for esp-println and disable default features which enables uart. So dependency will look like:
esp-println = { version = "0.9.0", default-features = false, features = ["esp32c6", "jtag-serial", "log"] }
This was the key I was missing. I wasn't sure the board was working at all until I tried making the builtin rgb light do something which led me to realize it was just debug printing that wasn't working.
Would it make sense to make it the default in the template? It would have solved me ~an hour of frustration, but I'm new to all of this so maybe other people figure it out quicker.
Ideally esp-println
would get an option to auto-detect: https://github.com/esp-rs/esp-hal/issues/1576
I guess half of people will run into problems no matter which one we default to
Got my hands on an ESP32-C6 and want to try rust on it. I am able to run the
esp-idf
examples (hello_world and blink) usingidf.py
to build and flash: I can see the hello world in my terminal or the del flash.I'm having trouble running this template though.
I use
cargo generate esp-rs/esp-template
to generate a bare bone project:Building and flashing seems to succeed, but the monitoring hangs:
There's no output after the last line, no hello world :(
The expanded template result in:
with the
.cargo/config.toml
:and
Cargo.toml
:Something I realized is that the built binary is large (larger than the available flash?):
I tried
opt-level = "s"
andopt-level = "z"
andstrip = true
which does reduce the size but the same result happens: there's no hello world :(Any idea what I could be doing wrong? I'm not sure what to look for as playing with embedded is quite new for me.
Thanks!!