Skip to content

Commit

Permalink
Merge pull request #52 from LedgerHQ/update-toolchain
Browse files Browse the repository at this point in the history
Update toolchain
  • Loading branch information
bigspider authored Jan 6, 2025
2 parents a178e14 + e8955be commit edc64ba
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
1 change: 0 additions & 1 deletion app-sdk/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(asm_const)]
#![cfg_attr(target_arch = "riscv32", no_main, no_std)]

extern crate alloc;
Expand Down
7 changes: 5 additions & 2 deletions vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ edition = "2021"

[dependencies]
common = { path = "../common", features=["device_sdk"] }
ledger_device_sdk = { version="1.17.4" }
include_gif = "1.2.0"
serde = {version="1.0.192", default-features = false, features = ["derive"]}
serde-json-core = { git = "https://github.com/rust-embedded-community/serde-json-core"}
hex = { version = "0.4.3", default-features = false, features = ["serde", "alloc"] }
numtoa = "0.2.4"
postcard = { version = "1.0.8", features = ["alloc"] }
ledger_secure_sdk_sys = "1.5.3"
ledger_secure_sdk_sys = "1.6.1"
zeroize = "1.8.1"
ledger_device_sdk = "1.19.1"

[profile.release]
opt-level = 3
Expand Down Expand Up @@ -42,4 +42,7 @@ icon = "vanadium_32x32.gif"
[package.metadata.ledger.flex]
icon = "vanadium_40x40.gif"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(target_os, values("stax", "flex", "nanos", "nanox", "nanosplus"))'] }

[workspace]
11 changes: 7 additions & 4 deletions vm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@

#![no_std]
#![no_main]
#![feature(panic_info_message)]

mod app_ui;
mod handlers;

mod settings;

use alloc::{vec, vec::Vec};
use alloc::{string::ToString, vec, vec::Vec};
use app_ui::menu::ui_menu_main;
use handlers::{
get_version::handler_get_version, register_vapp::handler_register_vapp,
Expand Down Expand Up @@ -71,12 +70,16 @@ fn handle_panic(info: &core::panic::PanicInfo) -> ! {
"Panic occurred in file '{}' at line {}: {:?}",
location.file(),
location.line(),
info.message().unwrap_or(&format_args!("no message"))
info.message()
.as_str()
.unwrap_or(&format_args!("no message").to_string())
)
} else {
alloc::format!(
"Panic occurred: {}",
info.message().unwrap_or(&format_args!("no message"))
info.message()
.as_str()
.unwrap_or(&format_args!("no message").to_string())
)
};
println!("{}", message);
Expand Down
5 changes: 4 additions & 1 deletion vm/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,28 @@ impl Default for Settings {
impl Settings {
#[inline(never)]
#[allow(unused)]
#[allow(static_mut_refs)] // This is safe because we are in single-threaded mode
pub fn get_mut(&mut self) -> &mut AtomicStorage<[u8; SETTINGS_SIZE]> {
return unsafe { DATA.get_mut() };
}

#[inline(never)]
#[allow(unused)]
#[allow(static_mut_refs)] // This is safe because we are in single-threaded mode
pub fn get_ref(&mut self) -> &AtomicStorage<[u8; SETTINGS_SIZE]> {
return unsafe { DATA.get_ref() };
}

#[allow(unused)]
#[allow(static_mut_refs)] // This is safe because we are in single-threaded mode
pub fn get_element(&self, index: usize) -> u8 {
let storage = unsafe { DATA.get_ref() };
let settings = storage.get_ref();
settings[index]
}

#[allow(unused)]
// Not used in this boilerplate, but can be used to set a value in the settings
#[allow(static_mut_refs)] // This is safe because we are in single-threaded mode
pub fn set_element(&self, index: usize, value: u8) {
let storage = unsafe { DATA.get_mut() };
let mut updated_data = *storage.get_ref();
Expand Down

0 comments on commit edc64ba

Please sign in to comment.