Skip to content

UART Debug Access Port

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

rfdonnelly/uart-dap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UART Debug Access Port

A UART DAP (Debug Access Port) for Green Hills Integrity and WxWork Wind River serial consoles.

Features

  • Configurable baud rate

  • Configurable echo: local, remote

  • Configurable line endings: lf, crlf

Example Usages

use uart_dap::{UartDap, Echo, LineEnding, Command, Event};

#[tokio::main]
async fn main() -> Result<()> {
    let dap = UartDap::new(
        "/dev/ttyS0",
        115200,
        Echo::Local,
        LineEnding::Lf,
    )?;

    let (command_tx, command_rx) = mpsc::channel(1);
    let (event_tx, mut event_rx) = mpsc::channel(1);

    tokio::spawn(async move { dap.run(command_rx, event_tx).await? });

    let command = Command::Read { addr: 0x600df00d };
    command_tx.send(command).await?;

    // Assumes the DUT responded with 0x5a5a5a5a
    assert_eq!(
        event_rx.recv().await?,
        Event::Read {
            addr: 0x600df00d,
            data: 0x5a5a5a5a
        }
    );

    Ok(())
}

Runnable Examples

Run the following in three separate terminals.

Create Two Virtual Serial Ports

Using socat

socat -d -d -v pty,link=ttyS0,raw,echo=0 pty,link=ttyS1,raw,echo=0

Or using TTYBUS

tty_bus -s ttyBus &
tty_fake -s ttyBus ttyS0 &
tty_fake -s ttyBus ttyS1 &

Start the DAP Server

cargo run --example server -- ttyS1

Start the DAP Client

cargo run --example client -- ttyS0

Enter Commands

The following commands can be entered into the terminal to send to the model.

help

Prints the help.

exit

Terminates the server.

mr kernel <addr> [<nbytes>]

Read a memory location.

mw kernel <addr> <data>

Write a memory location.

Test

Important
Care must be taken to prevent multiple tests from talking to the same ports at the same time. Limit the number of parallel tests and test threads to 1.
cargo test -j1 -- --test-threads=1

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

UART Debug Access Port

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages