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

Add a nice wrapper for get_sys_info #877

Merged
merged 16 commits into from
Nov 25, 2024

Conversation

nahla-nee
Copy link
Contributor

Implements a nice safe wrapper for get_sys_info as described in #839 .

Copy link
Member

@thejpster thejpster left a comment

Choose a reason for hiding this comment

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

Thank you for this PR. In general it looks great!

I would like to see an example of using this API though.

rp235x-hal/src/rom_data.rs Outdated Show resolved Hide resolved
rp235x-hal/src/rom_data.rs Outdated Show resolved Hide resolved
@nahla-nee
Copy link
Contributor Author

Sure! And I'll go ahead make the suggestions changes too. I'll probably do that by tonight (us time). Do you want the example to be added to the existing rom function example? And if so do you want it to replace the existing one?

@thejpster
Copy link
Member

I'm ok with it going into the existing example binary. I'm not sure if we need to leave an example of the old API or if we expect people to only use the new one.

@nahla-nee
Copy link
Contributor Author

I also went ahead and added some more documentation. It probably could use more work cause I was in a bit of a rush but it should make things easier to read. I also elaborated on the existing examples since we don't have settle for printing the hex representation of the bytes get_sys_info gives back now.

_ = writeln!(uart, "get_sys_info(CPU_INFO/0x0004) -> {}", result);
_ = writeln!(uart, "\tSupported Flags: {:#06x}", buffer[0]);
let result = hal::rom_data::sys_info_api::cpu_info();
let result = match result {
Copy link
Member

Choose a reason for hiding this comment

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

These nested matches can be collapsed.

@nahla-nee
Copy link
Contributor Author

I'll get working on those changes. It just occurred to me that I didn't add an api for get_sys_info_ns. Do you want that added as well?

@nahla-nee
Copy link
Contributor Author

I held off on adding the ns version of the api for now but its ready (https://github.com/nahla-nee/rp-hal/tree/feature/get_sys_info_ns_api) for a pr whenever if you did want it included as well

@thejpster
Copy link
Member

thejpster commented Nov 23, 2024

I'll get working on those changes. It just occurred to me that I didn't add an api for get_sys_info_ns. Do you want that added as well?

I guess it would be good to have that, although I haven't written much NS software for the 2350.

Not a blocker for this PR though.

@thejpster
Copy link
Member

Looks great! Thank you.

@thejpster
Copy link
Member

ah, needs a cargo fmt please

@nahla-nee
Copy link
Contributor Author

I went ahead and merged the NS branch into my current branch. Hopefully that's not an issue, I glanced at the notification I got about your message which cut off the part about it not being a blocker. And cargo fmt has been ran 😅 forgot i made changes to the examples folder and only ran it in the hal folder

@thejpster
Copy link
Member

Before:

get_sys_info(CHIP_INFO/0x0001) -> 4
        Supported Flags: 0x0001
        RP2350 Package ID: 0x00000000
        RP2350 Device ID : 0x2d92c1e1
        RP2350 Wafer ID  : 0xb6d90d05
get_sys_info(CPU_INFO/0x0004) -> 2
        Supported Flags: 0x0004
        CPU Architecture: Arm
get_sys_info(FLASH_DEV_INFO/0x0008) -> 2
        Supported Flags: 0x0008
        CS0 Size: 16M
        CS1 Size: None
get_sys_info(BOOT_RANDOM/0x0010) -> 5
        Supported Flags: 0x0010
        A random number: 0xcfb87af017b6a85f4c1de260cef281e3

After:

get_sys_info(CHIP_INFO/0x0001)
        RP2350 Package ID: 0x00000000
        RP2350 Device ID : 0x2d92c1e1
        RP2350 Wafer ID  : 0xb6d90d05
get_sys_info(CPU_INFO/0x0004)
        CPU Architecture: Arm
get_sys_info(FLASH_DEV_INFO/0x0008)
        CS1 GPIO: 0
        D8H Erase Supported: false
        CS0 Size: 16M
        CS1 Size: None
get_sys_info(BOOT_RANDOM/0x0010)
        A random number: 0x6713d047488e82a24dc9660817f0f669

Looks great!

@thejpster thejpster merged commit f9892cd into rp-rs:main Nov 25, 2024
49 checks passed
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