Skip to content
Snippets Groups Projects
Commit 75303861 authored by Per Lindgren's avatar Per Lindgren
Browse files

ktest and runner wip

parent fae6f193
Branches
No related tags found
No related merge requests found
/target
**/*.rs.bk
ktest/target
runner/target
\ No newline at end of file
......@@ -62,7 +62,7 @@ klee-analysis = [
inline-asm = ["cortex-m/inline-asm"]
# rtpro = [ "cortex-m-rtfm/klee-analysis", "cortex-m-rt/rtpro", "lm3s6965" ]
f4 = ["stm32f4/stm32f401", "stm32f4/rt", "cortex-m-semihosting", "cortex-m-rt"]
f4 = ["stm32f4/stm32f401", "stm32f4/rt", "cortex-m-semihosting", "cortex-m-rt", "cortex-m"]
[profile.dev]
panic = "abort"
......
// minimal example for the stm32-f401 (and the f4 series)
//! Prints "Hello, world!" on the host console using semihosting
#![no_main]
#![no_std]
extern crate panic_halt;
use stm32f4::stm32f401 as stm32;
use cortex_m::asm;
use cortex_m_rt::entry;
#[entry]
fn main() -> ! {
asm::bkpt();
loop {}
}
// See RM0368 Reference Manual for details
// https://www.st.com/content/ccc/resource/technical/document/reference_manual/5d/b1/ef/b2/a1/66/40/80/DM00096844.pdf/files/DM00096844.pdf/jcr:content/translations/en.DM00096844.pdf
//
// Memory map is given in `memory.x`, in particular we define:
// 96k RAM starting at 0x2000_0000, and
// 256k Flash starting at 0x0800_0000
//
// Run in separate terminal:
// openocd -f openocd.cfg
//
// cargo run --example f401_minimal --features f4 --target thumbv7em-none-eabihf
// This is the way!
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "ktest"
version = "0.1.0"
[package]
name = "ktest"
version = "0.1.0"
authors = ["Per Lindgren <per.lindgren@ltu.se>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
This diff is collapsed.
# ktest
Tool to read ktest files
use std::fs::File;
use std::io::prelude::*; // provide io traits
use std::io::{Error, ErrorKind};
fn main() -> std::io::Result<()> {
let ktest = read_ktest("test000001.ktest");
println!("{:?}", ktest);
Ok(())
}
#[derive(Debug)]
struct KTEST {
version: i32,
args: Vec<String>,
objects: Vec<(String, Vec<u8>)>,
}
fn read_ktest(file_name: &str) -> std::io::Result<KTEST> {
let mut file: File = File::open(file_name)?;
let mut hdr = [0u8; 5];
file.read_exact(&mut hdr)?;
if &hdr != b"KTEST" {
return Err(Error::new(ErrorKind::Other, "not a KTEST file"));
}
let version = read_i32(&mut file)?;
println!("version : {}", version);
if version > 3 {
return Err(Error::new(ErrorKind::Other, "non support KTEST version"));
}
let num_args = read_i32(&mut file)?;
// info regarding the KTEST file
let mut args = vec![];
for _ in 0..num_args {
let arg = read_sized(&mut file)?;
let str = String::from_utf8(arg).unwrap();
args.push(str);
}
// metadata not used here
let _sym_argvs = read_i32(&mut file)?;
let _sym_argv_len = read_i32(&mut file)?;
// read the objects
let num_objects = read_i32(&mut file)?;
let mut objects = vec![];
for _ in 0..num_objects {
let name = read_string(&mut file)?;
let data = read_sized(&mut file)?;
objects.push((name, data))
}
Ok(KTEST {
version,
args,
objects,
})
}
fn read_i32(file: &mut File) -> std::io::Result<i32> {
let mut str = [0u8; 4];
file.read_exact(&mut str)?;
Ok(i32::from_be_bytes(str)) // big endian
}
fn read_string(file: &mut File) -> std::io::Result<String> {
let str = read_sized(file)?;
Ok(String::from_utf8(str).unwrap())
}
fn read_sized(file: &mut File) -> std::io::Result<Vec<u8>> {
let size = read_i32(file)?;
let mut buf = vec![0u8; size as usize];
file.read_exact(&mut buf)?;
Ok(buf)
}
File added
This diff is collapsed.
[package]
name = "runner"
version = "0.1.0"
authors = ["Per Lindgren <per.lindgren@ltu.se>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
probe-rs = { path = "../../probe-rs/probe-rs", version = "0.3.0" }
ktest = { path = "../probe-rs/probe-rs", version = "0.3.0" }
\ No newline at end of file
fn main() {
println!("Hello, world!");
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment