Skip to content

Fix system attribute addressing#132

Open
K-Nicolas-10 wants to merge 1 commit into
WyliodrinEmbeddedIoT:mainfrom
K-Nicolas-10:fix-system-attribute-addressing
Open

Fix system attribute addressing#132
K-Nicolas-10 wants to merge 1 commit into
WyliodrinEmbeddedIoT:mainfrom
K-Nicolas-10:fix-system-attribute-addressing

Conversation

@K-Nicolas-10

Copy link
Copy Markdown

Pull Request Overview

This pull request:
-Adds the Nucleo U545RE-Q Board.
-Adds start address field for known boards.
-Fixes info/erase-apps commands on boards that don't have a bootloader by removing the reading of system attributes(which do not have exist if you don't have a bootloader).
-Change bytes_to_string function to standard library function.

Checks

Using Rust tooling

  • Ran cargo fmt
  • Ran cargo clippy
  • Ran cargo test
  • Ran cargo build

Features tested:

erase,info,list,listen

Comment on lines +44 to +48
// TODO: This should not expect, we should return none in case the chip doesn't have a bootloader
match n {
Ok(c) => key.push(c),
Err(_) => return None,
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are changing this, can we change it directly to the std implementation?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utf8_decode should be eradicated from this codebase

} else {
Ok(false)
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

Add a space after

@eva-cosma eva-cosma left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, rebase

/// Check if the bootloader is present on the version of Tock
pub(crate) async fn bootloader_is_present(
conn: &mut dyn IO,
flash_address: u64,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
flash_address: u64,
flash_start_address: u64,

/// - Err(TockloaderError::SerialReadError): if reading fails on Serial
pub(crate) async fn read_system_attributes(
conn: &mut dyn IO,
flash_address: u64,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
flash_address: u64,
flash_start_address: u64,

pub(crate) async fn read_system_attributes(
conn: &mut dyn IO,
flash_address: u64,
start_address: u64,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
start_address: u64,
app_start_address: u64,

Comment on lines 67 to +87
// System attributes start at 0x600 and up to 0x9FF. See:
// https://book.tockos.org/doc/memory_layout#flash-1
let address = 0x600;
let address = flash_address + 0x600;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Continue this comment. It start at an offset of 0x600, an example being visible at . Furthermore ,this is also evidenced by the linker script in tock upstream

result.boothash = Some(decoded_attributes.value.to_string());
let has_bootloader = Self::bootloader_is_present(conn, flash_address)
.await
.unwrap_or(false);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bubble up the error, don't unwrap_or

Comment on lines +100 to +101
} else {
for current_slot in 0..data.len() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else {
for current_slot in 0..data.len() {
} else {
// TODO(eva-cosma): Clean this up/refactor
for current_slot in 0..data.len() {

You can also do the cleanup in this PR, but you will need to test the new implementation. We can discuss what I don't like, if you want to cleanup

Comment on lines +174 to +176
let sentinel = std::str::from_utf8(&kernel_attr_binary[96..100])
.unwrap_or("unknown")
.to_string();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't have a sentinel, or we can't convert it, throw an error. A very specific one as well, INVALID_SENTINEL. something like that. Sentinels exist to be unchanged and always correct.

Comment on lines +4 to 5
pub flash_address: u64,
pub start_address: u64,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, but I've changed my mind, let's not have 1-to-1 parity with tockloader-python in the naming scheme here cause this is confusing. We can do

/// Previously named 'flash_address' in the python version of tockloader
pub flash_start_address: u64,
/// Previously named `start_address` in the python version of tockloader
pub app_start_Address: u64,

fn default() -> Self {
Self {
arch: None,
flash_address: 0x00000, // this would be actually like -0x10000

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can flash be negative?

Comment on lines +11 to +12
let installed_apps = self.read_installed_apps().await?;
let system_atributes = self.read_system_attributes().await?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Nice!

@K-Nicolas-10
K-Nicolas-10 force-pushed the fix-system-attribute-addressing branch from 5038ab5 to 685a08f Compare July 22, 2026 13:07
@K-Nicolas-10
K-Nicolas-10 force-pushed the fix-system-attribute-addressing branch from 685a08f to 022dafa Compare July 22, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants