Skip to content

Commit

Permalink
Add RT version to binary
Browse files Browse the repository at this point in the history
  • Loading branch information
sree-revoori1 authored and jhand2 committed Feb 24, 2024
1 parent b1136a8 commit 26a45c6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
11 changes: 9 additions & 2 deletions builder/bin/image_gen.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed under the Apache-2.0 license

use caliptra_builder::firmware;
use caliptra_builder::version;
use caliptra_builder::ImageOptions;
use clap::{arg, value_parser, Command};
use std::collections::HashSet;
Expand Down Expand Up @@ -45,7 +46,10 @@ fn main() {
let image = caliptra_builder::build_and_sign_image(
&firmware::FMC_WITH_UART,
&firmware::APP_WITH_UART,
ImageOptions::default(),
ImageOptions {
app_version: version::get_runtime_version(),
..Default::default()
},
)
.unwrap();
std::fs::write(path, image.to_bytes().unwrap()).unwrap();
Expand All @@ -56,7 +60,10 @@ fn main() {
let image = caliptra_builder::build_and_sign_image(
&firmware::FMC_FAKE_WITH_UART,
&firmware::APP_WITH_UART,
ImageOptions::default(),
ImageOptions {
app_version: version::get_runtime_version(),
..Default::default()
},
)
.unwrap();
std::fs::write(path, image.to_bytes().unwrap()).unwrap();
Expand Down
14 changes: 14 additions & 0 deletions builder/src/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ pub const ROM_VERSION_MAJOR: u16 = 1;
pub const ROM_VERSION_MINOR: u16 = 0;
pub const ROM_VERSION_PATCH: u16 = 1;

pub const RUNTIME_VERSION_MAJOR: u32 = 1;
pub const RUNTIME_VERSION_MINOR: u32 = 0;
pub const RUNTIME_VERSION_PATCH: u32 = 0;

// ROM Version - 16 bits
// Major - 5 bits [15:11]
// Minor - 5 bits [10:6]
Expand All @@ -13,3 +17,13 @@ pub fn get_rom_version() -> u16 {
| ((ROM_VERSION_MINOR & 0x1F) << 6)
| (ROM_VERSION_PATCH & 0x3F)
}

// Runtime Version - 32 bits
// Major - 8 bits [31:24]
// Minor - 8 bits [23:16]
// Patch - 16 bits [15:0]
pub fn get_runtime_version() -> u32 {
((RUNTIME_VERSION_MAJOR & 0xFF) << 24)
| ((RUNTIME_VERSION_MINOR & 0xFF) << 16)
| (RUNTIME_VERSION_PATCH & 0xFFFF)
}
5 changes: 4 additions & 1 deletion coverage/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ fn main() -> std::io::Result<()> {
let image = caliptra_builder::build_and_sign_image(
&FMC_WITH_UART,
&APP_WITH_UART,
caliptra_builder::ImageOptions::default(),
caliptra_builder::ImageOptions {
app_version: caliptra_builder::version::get_runtime_version(),
..Default::default()
},
)
.unwrap();

Expand Down

0 comments on commit 26a45c6

Please sign in to comment.