Giter Club home page Giter Club logo

tricore-probe's Introduction

Tricore-Probe: Run rust effortlessly on Tricore chips

tricore-probe is an effort to deploy and debug rust programs with little effort on Tricore chips. It uses publicly available Infineon tools to interface with the chips debug controller. As its name suggests, it is inspired by probe-run and depends on the defmt framework to integrate seamlessly just as probe-run does.

Platform support

Currently only Windows and Linux are supported.

Installation

Windows

Requirements

  1. Infineon DAS tool version 8.0.5 Please make sure the DAS_HOME environment variable points to the DAS tool installation directory.
  2. Infineon AURIX™ Flasher Software Tool Please make sure the AURIX_FLASHER_PATH environment variable points to the AurixFlasher executable (<your-path>\AURIXFlasher.exe).
  3. defmt-print CLI utility: cargo install defmt-print
  4. objcopy CLI utility (obtain e.g. as part of the MinGW-w64 project)
  5. addr2line CLI utility (obtain e.g. as part of the MinGW-w64 project)
  6. Rust toolchain
  7. LLVM (also set LIBCLANG_PATH to <your-path>\LLVM\lib)

Installation

Install tricore-probe:

cargo install tricore-probe --git https://github.com/veecle/tricore-probe --version 0.2.0

Linux

The Linux setup is not officially supported by Infineon and thus might not work as expected. Please report any bugs or issues you encounter with the Linux setup only to this repository, not to Infineon.

Requirements

  1. Place the Infineon DAS tool version 8.0.5 installer (DAS_V8_0_5_SETUP.exe) in tricore-docker.
  2. Place the Infineon AURIX™ Flasher Software Tool installer (aurixflashersoftwaretool_1.0.10_Windows_x64.msi) in tricore-docker.
  3. objcopy CLI utility
  4. Rust toolchain
  5. libudev library (libudev-dev on Ubuntu, systemd-libs on Fedora)

Installation

Clone the repository and place the DAS tool installer and AurixFlasher installer into the tricore-docker directory. Build the docker container running the DAS tool, AurixFlasher and other utilities.

Note: The veecle/flash-tricore container will contain an AurixFlasher and DAS installation in a Wine environment. To use this setup, make sure you checked the terms and conditions of these programs and accept them by setting the required build argument with --build-arg=AGREE_INFINEON_TERMS=1 when building the docker image.

docker build . --tag veecle/flash-tricore --build-arg=AGREE_INFINEON_TERMS=1 -f tricore-docker/Dockerfile

Install tricore-probe:

cargo install tricore-probe --git https://github.com/veecle/tricore-probe --version 0.2.0

Attribution

The Linux setup is based on a modified version of the wineftd2xx project by brentr.

Quickstart

> tricore-probe <your-executable>.elf --list-devices
Found 1 devices:
Device 0: "DAS JDS AURIX LITE KIT V2.0 (TC375) LK7KFCF1"

In case of a simple example based on the Bluewind blinky the output will look something like this:

> tricore-probe blinky.elf
DEBUG power on reset
└─ bw_r_drivers_tc37x::ssw::tc0::init_clock @ C:\Users\andra\.cargo\registry\src\github.com-d2f9efa20490c5c8\bw-r-drivers-tc37x-0.2.0\src\ssw\tc0.rs:12
INFO  LED2 toggle
└─ blinky::main @ src\main.rs:46

For more sample code refer to the Bluewind bare-metal examples and to the Veecle PXROS examples.

Cargo runner

This program can be configured as a runner. Check main.rs for additional configuration options.

A simple runner config for a TC375 lite kit could look like this:

[target.tc162-htc-none]
runner = "tricore-probe"
# The default dwarf version of the HighTec compiler is version 2 in v0.2.0
# and version 3 in v1.0.0, both versions being incompatible with defmt location information.
rustflags = ["-Z", "dwarf-version=4"]

[build]
target = "tc162-htc-none"

Then you can call cargo run in your project root which will run the built .elf on your board via tricore-probe.

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

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

tricore-probe's People

Contributors

arctic-alpaca avatar therealfrauholle avatar gemesa avatar alepez avatar

Stargazers

Marc Espin avatar SuperBongo avatar  avatar Markus avatar Xander Cesari avatar Lucas Brendel avatar Atabey avatar  avatar Hèctor Morales Carnicé avatar  avatar Francesco Mecatti avatar  avatar Simon Berger avatar  avatar dpl avatar  avatar  avatar

Watchers

 avatar SuperBongo avatar

tricore-probe's Issues

Automatically generate MCD bindings

Currently under linux we use a pregenerated version of the MCD bindings. Even though the MCD library can currently only be used under windows, this allows to develop the library under linux as well.

I quickly prototyped it, and in contrary to this setup (and what I initially believed) it should be possible to generate the bindings through a builds script even in linux, so we could get rid of the pregenerated version of the bindings.

We have to to investigate the compability overall, because in the end it must compile under windows and should compile in linux. E.g. I had some issues regarding the signedness of enum { ... }; definitions.

Frozen flashing on TC397

I'm opening this issue to report that, while trying to flash on a TC397 board, the flashing process hangs indefinitely.

Details about my environment:

uname -sm

Linux x86_64

Which implies docker backend.

./target/debug/tricore-probe [...] --log-level trace

[...]
INFO  tricore_windows::flash <- docker] Spawned Infineon Memtool to flash hex file

Listing devices:

Found 1 devices:
Device 0: "DAS JDS TriBoard TC397 V2.0 TB7RWQK8"

I do not have edited Memtool configuration in any way. Am I supposed to do it or should be automatically managed (like in create_cfg function for Windows backend)?

Use llvm objcopy and addr2line

Since the tricore rust toolchain is based on the LLVM backend the tools objcopy and addr2line from the LLVM toolchain should be used
rename:

  • objcopy -> llvm-objcopy
  • addrline -> llvm-addr2line

Make use of enumerations in mcd bindings

The current MCD bindings only contain anonymous enumerations. This converts all variants to constants which make it hard to manage and use in rust. With a bit of preprocessing of the header file, bindgen could be able to produce rust enumerations, e.g. compare

typedef uint32_t mcd_return_et;
enum {
MCD_RET_ACT_NONE = 0x00000000 , /**< No special action required. */
MCD_RET_ACT_AGAIN = 0x00000001 , /**< Try to call the function again. */
MCD_RET_ACT_HANDLE_EVENT = 0x00000002 , /**< Handle the event or events. */
MCD_RET_ACT_HANDLE_ERROR = 0x00000003 , /**< Handle the error. */
MCD_RET_ACT_RESERVED_LO = 0x00000004 , /**< Begin Range: Action reserved for future API use. */
MCD_RET_ACT_RESERVED_HI = 0x00008000 , /**< End Range: Action reserved for future API use. */
MCD_RET_ACT_CUSTOM_LO = 0x00010000 , /**< Begin Range: For user defined actions. */
MCD_RET_ACT_CUSTOM_HI = 0x40000000 , /**< End Range: For user defined actions. */
};
with the rust equivalent
/// This is a rusty wrapper around MCD API return codes, see [mcd_return_et].
#[derive(Debug, PartialEq, thiserror::Error)]
pub enum McdReturnError {
#[error("Try to call the function again")]
TryAgain,
#[error("Handle the event or events")]
HandleEvent,
#[error("Handle the error")]
HandleError,
#[error("Action reserved for future API use")]
Reserved(u32),
#[error("Range: For user defined actions")]
Custom(u32),
}

Check therealfrauholle@55ba686 for a prototyped implementation. I preprocessed the headerfile manually (actually, with a regex); I believe this should actually happen within the buildscript and we should not touch the header files directly.

What we need to see is how we implement the usual custom and reserved variants, which were manually implemented for McdReturnError. Check the equivalent definition of mcd_return_et. These variants are not actually rust variants, but boundaries for custom variants. Three options we have, which are all good:

  1. Do not handle these variants - which is acceptable because there will never be variants in the "custom" range. To my understanding, this is meant to be used by users of the library to use the same type in their code, thanks to rust we don't have to do that. It is acceptable because it is unlikely that we ever encounter a "reserved" error code.
  2. Build a derive macro that derives something allong the following trait:
/// Error code completely unknown, should never be reported by MCD
struct UnknownCode;

/// Codes that MCD can report but we can't really handle
enum McdUnhandledCodes {
   Reserved(u32)
   Custom(u32)
}

trait UnhandledCodes {
    fn try_from(code: u32) -> Result<Result<Self, McdUnhandledCode>, UnknownCode>;
}

The final enumerations would still contain e.g. the _RESERVED_LO and _RESERVED_HI variants, which is not perfect.
3. Keep a manual definition of enumerations in sync in the rust library. This is somewhat tedious, manual work but it would only have to be done once and with better binding generation this will be much easier than it already is.

Refactor all calls into MCD libray

In rust_mcd::raw we started to build strong(er) typed variants of the native, unsafe MCD functions. We want to refactor all calls into the library that happen outside of this module into that module.

Error: Elf file does not have _SEGGER_RTT symbol

I built some blinky examples with HighTec Rust Aurix compiler version 1.0.0 for the TC375 lite kit board. I am trying to run these elfs on my board via tricore-probe but I face this error:

PS C:\Users\andra\git-repos\tricore-probe> cargo run -- .\blinking_led_1_litekit.elf -l trace
    Finished dev [unoptimized + debuginfo] target(s) in 0.08s
     Running `target\debug\tricore-probe.exe .\blinking_led_1_litekit.elf -l trace`
[2024-04-22T12:43:23Z TRACE tricore_windows::das] Starting dashpas
[2024-04-22T12:43:23Z TRACE tricore_windows::das] Starting UDAS_Console
[2024-04-22T12:43:23Z INFO  tricore_windows::das] DAS server started
[2024-04-22T12:43:24Z DEBUG rust_mcd::library] Initializing MCD library
[2024-04-22T12:43:24Z DEBUG tricore_probe::chip_interface] Connecting to any available device
[2024-04-22T12:43:24Z INFO  tricore_probe::chip_interface] Converting elf .\blinking_led_1_litekit.elf to hex file
[2024-04-22T12:43:24Z INFO  tricore_probe::chip_interface] Flashing hex file
[2024-04-22T12:43:24Z TRACE rust_mcd::connection] Scanned for servers, found Connection { servers: [ServerInfo { acc_hw: "DAS JDS AURIX LITE KIT V2.0 (TC375) LK7KFCF1", server: "UDAS", system_instance: "" }] }
[2024-04-22T12:43:24Z INFO  tricore_windows::flash] Spawned Infineon Memtool to flash hex file
[2024-04-22T12:43:26Z INFO  tricore_windows::flash] Infineon Memtool terminated successfully
Error: Elf file does not have _SEGGER_RTT symbol
error: process didn't exit successfully: `target\debug\tricore-probe.exe .\blinking_led_1_litekit.elf -l trace` (exit code: 1)

I assume this means I need to utilize the rtt-target crate somehow. Do you have some examples for that (preferably with the Lite Kit board)?

Make elf path optional when listing devices

Currently the user must supply an elf path when listing devices. This argument is actually not used, the tool will exit after listing devices and can actually be a path not pointing to a file.

See therealfrauholle@f95ac87 for a reference, e.g. a hack that could solve this. This could already solve the problem, but we want to use clap to its full potential to nicely reflect the usage of elf path in the CLI.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.