Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update toolchain #52

Merged
merged 4 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading