Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

printing to terminal with elf2uf2 (without a probe) on the pico/pico w #3351

Open
anandijain opened this issue Sep 18, 2024 · 1 comment
Open

Comments

@anandijain
Copy link

hello and apologies if this isn't the best place to ask this.

i am trying to run a basic hello world program that prints to the terminal on my pico w.

im able to get examples/rp/src/bin/wifi-blinky.rs example to work by following the instruction in the embassy book (replacing probe-rs with elf2uf2-rs in .cargo/config.toml:
https://embassy.dev/book/#_how_to_deploy_to_rp2040_without_a_debugging_probe

my issue is I just can't seem to get any terminal output using info! commands. is it possible to log information to my terminal without a debug probe? i am new to embedded programming

my code is here. when i do a cargo run --release --bin hello_world, I can see that the pico is getting flashed (because of the page and address info):

PS C:\Users\anand\src\embedded\pico_w_rust_test> c r --release --bin hello_world
   Compiling pico_w_rust_test v0.1.0 (C:\Users\anand\src\embedded\pico_w_rust_test)
...
     Running `elf2uf2-rs --deploy --serial --verbose target\thumbv6m-none-eabi\release\hello_world`
Found pico uf2 disk E:\
Detected FLASH binary
Mapped segment 0x10000100->0x100001c0 (0x10000100->0x100001c0)
Mapped segment 0x100001c0->0x10003804 (0x100001c0->0x10003804)
Mapped segment 0x10003804->0x10003e30 (0x10003804->0x10003e30)
Mapped segment 0x10003e30->0x1000402c (0x20000000->0x200001fc)
Mapped segment 0x10000000->0x10000100 (0x10000000->0x10000100)
Transfering program to pico
Page 0 / 65 0x10000000
Page 1 / 65 0x10000100
Page 2 / 65 0x10000200
...
Page 64 / 65 0x10004000

PS C:\Users\anand\src\embedded\pico_w_rust_test> 

So it seems like everything runs (just like with the wifi_blinky example). but no output in my terminal

any help would be greatly appreciated!
thank you!

@JonathanPlasse
Copy link

Hello,
Without debug probe, you cannot use defmt logging.
If you have another pico, you could make it into a probe and use it on the other.
Or as an alternative, you can use the usb_serial.rs example to read and write message to the Pico.
You can then use pyserial read and write to the usb serial or any other similar program.
This is the code I use on Linux.

import serial

def main():
    with serial.Serial(
        port="/dev/serial/by-id/usb-Embassy_USB-serial_example_12345678-if00",
        baudrate=921600,
        timeout=1,
    ) as ser:
        while ser.is_open:
            message = input()
            if len(message) == 0:
                message = " "
            ser.write(message.encode())
            while ser.in_waiting == 0:
                pass
            response = ser.read(ser.in_waiting)
            print(response.decode())


if __name__ == "__main__":
    try:
        main()
    except KeyboardInterrupt:
        pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants