thombles / ax25-rs

Utilities for Packet Radio in Rust. AX.25 encoding/decoding and radio interfacing.
Apache License 2.0
54 stars 10 forks source link

Compilation failure with `thumbv6m-none-eabi` target #8

Closed exepirit closed 4 months ago

exepirit commented 4 months ago

I'm using the ax25 v0.3.0 crate, which is giving me trouble when I try to compile it for a thumbv6m-none-eabi target on an RP2040 microcontroller. The compilation process fails with some import-related errors:

658 | fn parse_ui_frame(bytes: &[u8]) -> Result<FrameContent, FrameParseError> {
    |                                    ^^^^^^ not found in this scope
    |
help: consider importing one of these items
    |
1   + use alloc::fmt::Result;
    |
1   + use core::fmt::Result;
    |
1   + use core::result::Result;
    |
1   + use crate::frame::fmt::Result;

I think that issues in the ax25 crate, and i've clone ax25-rs repository and run checks for all libs. Checks passes for x86_64-unknown-linux-gnu target without any issues, but failed for thumbv6m-none-eabi with same errors:

~/ax25-rs (master) » cargo check --lib --target thumbv6m-none-eabi
... skipped a lot of duplicating lines

error[E0425]: cannot find function, tuple struct or tuple variant `Ok` in this scope
   --> ax25/src/frame.rs:727:5
    |
727 |     Ok(FrameContent::FrameReject(FrameReject {
    |     ^^ not found in this scope
    |
help: consider importing this tuple variant
    |
1   + use core::result::Result::Ok;
    |

error[E0412]: cannot find type `Result` in this scope
   --> ax25/src/frame.rs:745:35
    |
745 | fn parse_content(bytes: &[u8]) -> Result<FrameContent, FrameParseError> {
    |                                   ^^^^^^ not found in this scope
    |
help: consider importing one of these items
    |
1   + use alloc::fmt::Result;
    |
1   + use core::fmt::Result;
    |
1   + use core::result::Result;
    |
1   + use crate::frame::fmt::Result;

Is it library and target incompatibility issue or maybe my build toolchain issue? How can I use this library on arm6 targets?

thombles commented 4 months ago

Hi, I think there are a few things going on.

  1. On master branch I inadvertently introduced some code that does not compile in no_std mode. I have just pushed a fix. This problem was not present at the v0.3.0 tag.
  2. The ax25 crate has a default feature std. When compiling for your target you will need to use --no-default-features.
  3. Take care that the repo has two crates in its workspace: ax25 which supports no_std, and ax25_tnc, which does not. If you are testing any builds please do it within the ax25 subdirectory.

With the fixes for (1) I am able to run this successfully:

# in ax25 subdir
cargo check --lib --target thumbv6m-none-eabi --no-default-features

Does this help?

exepirit commented 4 months ago

Disabling all crate features of the crate fixed (or masked?) the problem.

$ cargo remove ax25
$ cargo add --no-default-features ax25

Thank you very much!