Closed Dave-Vallance closed 1 year ago
You have to decode the output with defmt-print. See the example runner script for artemis. Essentially: cat /dev/serial0 | defmt-print path/to/elf
fre. 16. jun. 2023, 22:38 skrev Dave-Vallance @.***>:
Hello there, Thanks for providing the defmt_serial crate!
I am having a little trouble getting it to work at the moment. It seems to be only outputting tildes to my terminal.
Welcome to minicom 2.8
OPTIONS: I18n Port /dev/serial0, 21:03:28
Press CTRL-A Z for help on special keys
As I am very new to rust and embedded programming, I am sure the issue is on my end. Here is my code for a raspberry pi pico. Interestingly, the UART setup works if I comment out defmt_serial and uncomment the lines with uart.write_str(). I am able to see the word "Test" printed to minicom. Any ideas what I am doing wrong here? Any pointers in the right direction would be appreciated! //! Blinks the LED on a Pico board //! //! This will blink an LED attached to GP25, which is the pin the Pico uses for the on-board LED. #![no_std] #![no_main] use bsp::{entry}; use defmt::*; use defmt_serial as _; //use defmt_rtt as _; use embedded_hal::digital::v2::OutputPin; use panic_probe as _; // Provide an alias for our BSP so we can switch targets quickly. // Uncomment the BSP you included in Cargo.toml, the rest of the code does not need to change. use rp_pico as bsp; // use sparkfun_pro_micro_rp2040 as bsp; use bsp::hal::{ clocks::{init_clocks_and_plls, Clock}, pac, sio::Sio, watchdog::Watchdog, }; #[entry] fn main() -> ! { //info!("Program start"); let mut pac = pac::Peripherals::take().unwrap(); let core = pac::CorePeripherals::take().unwrap(); let mut watchdog = Watchdog::new(pac.WATCHDOG); let sio = Sio::new(pac.SIO); // External high-speed crystal on the pico board is 12Mhz let external_xtal_freq_hz = 12_000_000u32; let clocks = init_clocks_and_plls( external_xtal_freq_hz, pac.XOSC, pac.CLOCKS, pac.PLL_SYS, pac.PLL_USB, &mut pac.RESETS, &mut watchdog, ) .ok() .unwrap(); let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().to_Hz()); let pins = bsp::Pins::new( pac.IO_BANK0, pac.PADS_BANK0, sio.gpio_bank0, &mut pac.RESETS, ); // This is the correct pin on the Raspberry Pico board. On other boards, even if they have an // on-board LED, it might need to be changed. // Notably, on the Pico W, the LED is not connected to any of the RP2040 GPIOs but to the cyw43 module instead. If you have // a Pico W and want to toggle a LED with a simple GPIO output pin, you can connect an external // LED to one of the GPIO pins, and reference that pin here. let mut led_pin = pins.gpio26.into_push_pull_output(); // Need to perform clock init before using UART or it will freeze. let uart = bsp::hal::uart::UartPeripheral::new( pac.UART0, (pins.gpio0.into_mode::<bsp::hal::gpio::FunctionUart>(), pins.gpio1.into_mode::<bsp::hal::gpio::FunctionUart>()), &mut pac.RESETS) .enable( bsp::hal::uart::UartConfig::default(), clocks.peripheral_clock.freq(), ) .unwrap(); defmt_serial::defmt_serial(uart); loop { defmt::info!("on!"); led_pin.set_high().unwrap(); delay.delay_ms(500); info!("off!"); led_pin.set_low().unwrap(); delay.delay_ms(500); //let text = "Test\r\n"; //let _ = uart.write_str(text); } } // End of file — Reply to this email directly, view it on GitHub <https://github.com/gauteh/defmt-serial/issues/2>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAAN365HB76C7EAAIPQW2R3XLS7Z7ANCNFSM6AAAAAAZJWVBEA> . You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
Gosh, literally the first line of the readme... I read that, honest ;p - Just didn't make the connection that it was a hard requirement. Apologies.
I can confirm I have been able to do this. So for any others that might stumble on this from google...
Installing print-defmt to path.
cargo install print-defmt
Then
sudo cat /dev/serial0 | defmt-print -e target/thumbv6m-none-eabi/debug/blinky-led
where target/thumbv6m-none-eabi/debug/blinky-led
is the output elf file from cargo run
Which is producing
pi@rpi:~/Development/rust/blinky-led $ sudo cat /dev/serial0 | defmt-print -e target/thumbv6m-none-eabi/debug/blinky-led
INFO off!
└─ blinky_led::__cortex_m_rt_main @ src/main.rs:82
INFO on!
└─ blinky_led::__cortex_m_rt_main @ src/main.rs:79
INFO off!
└─ blinky_led::__cortex_m_rt_main @ src/main.rs:82
INFO on!
└─ blinky_led::__cortex_m_rt_main @ src/main.rs:79
INFO off!
└─ blinky_led::__cortex_m_rt_main @ src/main.rs:82
Thanks for your help!
Nice! If you want to contribute a raspberry pi example to this repo at some point, it would be much appreciated!
lør. 17. jun. 2023, 09:53 skrev Dave-Vallance @.***>:
Closed #2 https://github.com/gauteh/defmt-serial/issues/2 as completed.
— Reply to this email directly, view it on GitHub https://github.com/gauteh/defmt-serial/issues/2#event-9558014089, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAN363VW5CA72JGCHNXQPDXLVO7FANCNFSM6AAAAAAZJWVBEA . You are receiving this because you commented.Message ID: @.***>
Sure! Let me tidy it up and I will generate a pull request.
Hello there, Thanks for providing the defmt_serial crate!
I am having a little trouble getting it to work at the moment. It seems to be only outputting tildes to my terminal.
As I am very new to rust and embedded programming, I am sure the issue is on my end. Here is my code for a raspberry pi pico. Interestingly, the UART setup works if I comment out
defmt_serial
and uncomment the lines withuart.write_str()
. I am able to see the word "Test" printed to minicom.Any ideas what I am doing wrong here? Any pointers in the right direction would be appreciated!