Hi All : I'm developing Flash Driver for TF-M AN524 demo , and trobuled by some code logic . It's that : For , AN524 , PS storage Area is redirect to BRAM , so PS area related read and write can be done using memcpy without Flash driver being implementened . see : platform/ext/target/arm/mps3/an524/cmsis_driver/Driver_Flash.c /* Redirecting PS storage to BRAM */ if (addr >= FLASH_REDIRECT_BASE && addr <= FLASH_REDIRECT_LIMIT) { start_addr = FLASH_REDIRECT_DEST + (addr - FLASH_REDIRECT_BASE); /* PS Flash is emulated over BRAM. use memcpy function. */ memcpy((void *)start_addr, data, cnt); } else { /* Flash driver for QSPI is not ready */ return ARM_DRIVER_ERROR_UNSUPPORTED; }
My question is : What the purpose of "else" branch above ? After I implement QSPI driver , in "if" branch , I remove redirect operation , and use Flash Write APIs to replace memcpy func. Then , shoud "else" branch be removed? Or , should I put Flash write driver in "else" branch , and keep "if" branch the same with origion?
Best regards, Jidong Mei
Looks like this is the driver to access the QSPI flash, but not fully implemented. It can only read the whole flash by direct access. And then it also "redirect" the PS storage area to BRAM. This means that if a caller is requesting access to an address that belongs to the PS storage area, the driver would write to the BRAM with another address instead of the requested address.
As for the code you referred to, the else branch is where the caller tries to write a QSPI flash with the address out of the PSA storage range. The address would not be redirected. And writing to the QSPI is not supported yet. Thus the driver returns UNSUPPORTED.
Once you implemented the flash driver, the redirect branch should be removed. It would then look like a regular flash driver.
Best Regards, Kevin
-----Original Message----- From: jidong.mei--- via TF-M tf-m@lists.trustedfirmware.org Sent: Thursday, August 18, 2022 10:50 AM To: tf-m@lists.trustedfirmware.org Subject: [TF-M] AN524 Flash_Driver issue consult
Hi All : I'm developing Flash Driver for TF-M AN524 demo , and trobuled by some code logic . It's that : For , AN524 , PS storage Area is redirect to BRAM , so PS area related read and write can be done using memcpy without Flash driver being implementened . see : platform/ext/target/arm/mps3/an524/cmsis_driver/Driver_Flash.c /* Redirecting PS storage to BRAM */ if (addr >= FLASH_REDIRECT_BASE && addr <= FLASH_REDIRECT_LIMIT) { start_addr = FLASH_REDIRECT_DEST + (addr - FLASH_REDIRECT_BASE); /* PS Flash is emulated over BRAM. use memcpy function. */ memcpy((void *)start_addr, data, cnt); } else { /* Flash driver for QSPI is not ready */ return ARM_DRIVER_ERROR_UNSUPPORTED; }
My question is : What the purpose of "else" branch above ? After I implement QSPI driver , in "if" branch , I remove redirect operation , and use Flash Write APIs to replace memcpy func. Then , shoud "else" branch be removed? Or , should I put Flash write driver in "else" branch , and keep "if" branch the same with origion?
Best regards, Jidong Mei -- TF-M mailing list -- tf-m@lists.trustedfirmware.org To unsubscribe send an email to tf-m-leave@lists.trustedfirmware.org
Hi Kevin
Thanks for the reply.Now , I konw what to do.
Regards, Jidong Mei
tf-m@lists.trustedfirmware.org