polarfire-soc / platform

Other
6 stars 11 forks source link

How to use envm driver? #2

Closed griffini closed 2 years ago

griffini commented 3 years ago

In https://github.com/polarfire-soc/hart-software-services/issues/35#issue-1031102411, @fcuzzocrea asks...

Hi!

I am trying to understand how to use the mss_envm driver which I found shipped with the HSS here: https://github.com/polarfire-soc/hart-software-services/tree/master/baremetal/drivers/mss_envm

According to my understanding, we should fill with a buffer envm_set_page_data()

https://github.com/polarfire-soc/hart-software-services/blob/4efe944ec03ea011bb1a8e633a2e67eb4358e00d/baremetal/drivers/mss_envm/mss_envm.h#L167

and then load the buffer into envm with this function: envm_program_page_address() https://github.com/polarfire-soc/hart-software-services/blob/4efe944ec03ea011bb1a8e633a2e67eb4358e00d/baremetal/drivers/mss_envm/mss_envm.h#L99

However, in order to initialize the driver, we need to call envm_init()

https://github.com/polarfire-soc/hart-software-services/blob/4efe944ec03ea011bb1a8e633a2e67eb4358e00d/baremetal/drivers/mss_envm/mss_envm.h#L80

. This function takes as parameter p_envm_params. Which system service it is needed to call to fill this variable? The function which needs to be called after instead is envm_set_clock()

https://github.com/polarfire-soc/hart-software-services/blob/4efe944ec03ea011bb1a8e633a2e67eb4358e00d/baremetal/drivers/mss_envm/mss_envm.h#L64

, which is taking as input mss_frequency, but what is mss_frequency? Is LIBERO_SETTING_MSS_SYSTEM_CLK ? Can you provide an example of how to use this driver?? Also, it is possible to use it to change some values written in the eNVM at runtime?

Thanks!!!

I've moved this ticket here, as it is a question on a bare metal driver... The HSS no longer uses the eNVM driver.

fcuzzocrea commented 3 years ago

Thanks

fcuzzocrea commented 2 years ago

any update on this?

mallynch commented 2 years ago

Hi, This driver was not been tested and released, it was inadvertently left in the HSS unused. You can store data in sNVM using the system services driver during runtime. Please checkout and see if it meets your requirement. Thanks

fcuzzocrea commented 2 years ago

Alright, thanks

nitindeshpande commented 2 years ago

@fcuzzocrea Closing this while you try the sNVM. Please reach out in case you have further questions. Thanks.

fcuzzocrea commented 2 years ago

Actually, I am trying to write something on the sNVM, using the MSS_SYS_SNVM_NON_AUTHEN_TEXT_REQUEST_CMD format.

I fail to understand how this is supposed to work though.

The documentation here says that non authenticated plaintext is supported:

https://github.com/polarfire-soc/platform/blob/48c848c6ce788e517b67aab356c1a385799b63a8/drivers/mss/mss_sys_services/mss_sys_services.h#L1386

so I would assume that this means that we can skip setting a password and we can use a NULL_BUFFER as p_user_key or am I wrong?

Because the subsequent checks are assuming that p_user_key is not NULL.

Also, the documentation refers to a ROMFLAG which, if set will prevent the sNVM to be written, but I wasn't able to find any documentation in which is explained how to set that flag.

someshd7 commented 2 years ago

Hi, Yes, you can skip the password for the Non-authenticated plaintext service. We will update the driver to cover this possibility.

The ROMFLAG is set when the page is configured as Read-only. If ROMFLAG = 1, then the page cannot be written by the SNVM system service at runtime. This configuration should be done in the libero design from Configure Design Initialization Data and Memories.

fcuzzocrea commented 2 years ago

Alright!

So, just to clarify it to myself, even if the MSS_SYS_secure_nvm_write() function can take as format NON_AUTHENTICATED_PLAINTEXT_FORMAT, this is currently not supported, right? (since the function always check for p_user_key to be different from NULL).

Thanks for the hint at ROMFLAG, I will take a look at Libero then!

someshd7 commented 2 years ago

Yes, the current implementation will always check for p_user_key to be different from NULL.