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

add serialport support to defmt-print #767

Closed
wants to merge 7 commits into from

Conversation

brandonros
Copy link

I got the idea from https://github.com/gauteh/defmt-serial/blob/main/example-pi-pico/pico-elf2uf2-defmt-wrapper.sh except that didn't work for me on Mac OS X Ventura with a FT232RL USB device

Instead of trying to really get into the weeds and debug why that was doing nothing, this seemed easier.

Obviously we'd probably want this behind some feature flag to make this optional (or not at all)

Just figured this might help somebody developing on RP2040 who doesn't have a 2nd RP2040 laying around + doesn't feel like soldering wires to be able to hit the SWD RTT debugger thingie

Copy link
Member

@Urhengulas Urhengulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @brandonros, thank you for your PR.

I'd be happy to add the serial support. Just a few questions:

  1. Can you please share an example of how you use the feature? Just want to understand it better.
  2. The library you are introducing, serialport, seems to look for new maintainers. I am a bit hesitant to add a library which has no active maintainers. Do you know if the found someone already?

print/src/main.rs Outdated Show resolved Hide resolved
@brandonros
Copy link
Author

brandonros commented Aug 16, 2023

Hi @brandonros, thank you for your PR.

I'd be happy to add the serial support. Just a few questions:

  1. Can you please share an example of how you use the feature? Just want to understand it better.
  2. The library you are introducing, serialport, seems to look for new maintainers. I am a bit hesitant to add a library which has no active maintainers. Do you know if the found someone already?

If you are working on a RP2040 and you don't want to solder/attach a 2nd USB thing to handle defmt logs over SWD, you can do

.cargo/config.toml

[build]
target = "thumbv6m-none-eabi"

[target.thumbv6m-none-eabi]
runner = "bash runner.sh"
rustflags = [
  "-C", "link-arg=--nmagic",
  "-C", "link-arg=-Tlink.x",
  "-C", "link-arg=-Tlink-rp.x",
  "-C", "link-arg=-Tdefmt.x",
]

[env]
DEFMT_LOG = "debug"

runner.sh

#!/bin/bash

set -e

# flash
elf2uf2-rs -d "$1"

# debug uart
defmt-print -e "$1" serial --path /dev/tty.usbserial-A50285BI

combined with https://github.com/gauteh/defmt-serial to achieve "compile, flash, get logs" all in one command + not need an SWD debugger and instead just a typical USB -> UART

@brandonros brandonros marked this pull request as ready for review August 16, 2023 23:33
@brandonros
Copy link
Author

image

I don't think CI / lint is failing due to something specifically related to this PR (other than adding a new serialport dependency)

@Urhengulas
Copy link
Member

Urhengulas commented Aug 17, 2023

I don't think CI / lint is failing due to something specifically related to this PR (other than adding a new serialport dependency)

It fails because of the introduced dependency serialport. The relevant part of the error is:

could not find system library 'libudev' required by the 'libudev-sys' crate

By adding serialport you introduce following dependencies:

└── serialport v4.2.2
    ├── bitflags v1.3.2
    ├── cfg-if v1.0.0
    ├── libudev v0.3.0
    │   ├── libc v0.2.147
    │   └── libudev-sys v0.1.4
    │       └── libc v0.2.147
    │       [build-dependencies]
    │       └── pkg-config v0.3.27
    ├── nix v0.26.2
    │   ├── bitflags v1.3.2
    │   ├── cfg-if v1.0.0
    │   ├── libc v0.2.147
    │   └── static_assertions v1.1.0
    └── scopeguard v1.2.0

You'd need to install libudev in the lint job in the CI. Similar to here:

run: sudo apt-get update && sudo apt-get install libudev-dev libusb-1.0-0-dev

But still, I do not want to add an unmaintained dependency. Are there any alternative crates?

@brandonros brandonros closed this Aug 17, 2023
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

Successfully merging this pull request may close these issues.

2 participants