Internal Flash Driver
Re: Internal Flash Driver
Giovanni, see the attachment. This should give you a head start. It's a working driver for the STM32L4 series based on the hal_flash abstraction.
- Attachments
-
- stm32_internal_flash.zip
- (3.66 KiB) Downloaded 251 times
- alex31
- Posts: 374
- Joined: Fri May 25, 2012 10:23 am
- Location: toulouse, france
- Has thanked: 38 times
- Been thanked: 61 times
- Contact:
Re: Internal Flash Driver
Hello,
Thanks for this flash driver for the L4
Is it possible for you to send a minimal example that use this library ?
Thanks
Alexandre
Thanks for this flash driver for the L4
Is it possible for you to send a minimal example that use this library ?
Thanks
Alexandre
Re: Internal Flash Driver
alex31 wrote:Hello,
Thanks for this flash driver for the L4
Is it possible for you to send a minimal example that use this library ?
Thanks
Alexandre
Sorry, I don't have one at this time. It should be fairly simple to use - below is an example for erasing.
Code: Select all
STM32Flash flashDevBank2;
stm32FlashObjectInit(&flashDevBank2, 2);
BaseFlash * pFlashDev = getBaseFlash(&flashDevBank1);
// Erasing
while(flashWaitErase(pFlashDev) != FLASH_NO_ERROR) {};
flashStartEraseAll(pFlashDev);
if(flashWaitErase(pFlashDev) != FLASH_NO_ERROR)
{
// handle error
}
As you can see, it uses the hal_flash abstraction. So for programming you would use the flashProgram() function. There is also a flashRead() function in hal_flash ..
If you can put together a simple example - that would help Giovanni integrating it, as an example code would be required in testhal .
Keep in mind the double word alignment requirements the STM32 has for writing to flash if I remember correctly.
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: Internal Flash Driver
Hi,
In preparation for this I am introducing a proper EFL driver in HAL, implementations will be normal LLD drivers, I will try to transform the L4 code into that. Should not take long.
Giovanni
In preparation for this I am introducing a proper EFL driver in HAL, implementations will be normal LLD drivers, I will try to transform the L4 code into that. Should not take long.
Giovanni
Re: Internal Flash Driver
If you're taking suggestions for the order of including device support, consider the stm32F72x next
Thanks for turning your attention to the internal flash driver. We may have some test/example code to contribute for testhal as well. I'll look into it if it would help.
Thanks for turning your attention to the internal flash driver. We may have some test/example code to contribute for testhal as well. I'll look into it if it would help.
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: Internal Flash Driver
Hi,
I added the new driver to trunk, it is not tested but you are welcome to give it a try
Currently it manages both banks as a single driver instance but I am thinking to modify it to have one instance for each bank like it was in the original proposal.
Giovanni
I added the new driver to trunk, it is not tested but you are welcome to give it a try
Currently it manages both banks as a single driver instance but I am thinking to modify it to have one instance for each bank like it was in the original proposal.
Giovanni
- FXCoder
- Posts: 384
- Joined: Sun Jun 12, 2016 4:10 am
- Location: Sydney, Australia
- Has thanked: 180 times
- Been thanked: 130 times
Re: Internal Flash Driver
Hi,
First option to try it would be on L4+ but probably 2 weeks before I get to that.
I'll check for differences L4 -> L4+ then and update L4+ .mk etc. accordingly.
Meanwhile, so I can keep up to date with the latest trunk, I added #if (HAL_USE_FLASH) conditionals in hal_flash.c/h and guard in halconf to avoid collision with existing flash driver macro/function names in use on my project.
If you could put those in to trunk it would be helpful.
--
Bob
First option to try it would be on L4+ but probably 2 weeks before I get to that.
I'll check for differences L4 -> L4+ then and update L4+ .mk etc. accordingly.
Meanwhile, so I can keep up to date with the latest trunk, I added #if (HAL_USE_FLASH) conditionals in hal_flash.c/h and guard in halconf to avoid collision with existing flash driver macro/function names in use on my project.
If you could put those in to trunk it would be helpful.
--
Bob
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: Internal Flash Driver
I just committed more changes and a demo EFL+MFS, please work on the latest version.
Giovanni
Giovanni
- Giovanni
- Site Admin
- Posts: 14444
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1074 times
- Been thanked: 921 times
- Contact:
Re: Internal Flash Driver
Just a note regarding the flash drivers.
There is this scenario:
- Program flash.
- Power loss results in ECC on read on next boot.
- CPU gets and NMI as result.
Giovanni
There is this scenario:
- Program flash.
- Power loss results in ECC on read on next boot.
- CPU gets and NMI as result.
Giovanni
- FXCoder
- Posts: 384
- Joined: Sun Jun 12, 2016 4:10 am
- Location: Sydney, Australia
- Has thanked: 180 times
- Been thanked: 130 times
Re: Internal Flash Driver
OK. Noted.
I'm migrating the code to L4+ from F413 and the flash driver is sort of disabled for now.
The flash driver in the F413 version of the project was used to keep log data in internal flash.
I will adopt the new ChibiOS EFL driver system for L4+ as part of the migration and generalization of the code.
It is multi-project so can be built for the L4+, F413, L072 and likely other MCUs.
I found the legacy flash driver (which is still built in the project) collided with ChibiOS hal_flash.h macro flashRead (one extra parameter... offset).
Hence my comment about (HAL_USE_FLASH) conditionals.
I will strip out the old flash driver but just not got to that yet and it didn't break compile until a recent update from trunk was moved into the project.
--
Bob
I'm migrating the code to L4+ from F413 and the flash driver is sort of disabled for now.
The flash driver in the F413 version of the project was used to keep log data in internal flash.
I will adopt the new ChibiOS EFL driver system for L4+ as part of the migration and generalization of the code.
It is multi-project so can be built for the L4+, F413, L072 and likely other MCUs.
I found the legacy flash driver (which is still built in the project) collided with ChibiOS hal_flash.h macro flashRead (one extra parameter... offset).
Hence my comment about (HAL_USE_FLASH) conditionals.
I will strip out the old flash driver but just not got to that yet and it didn't break compile until a recent update from trunk was moved into the project.
--
Bob
Return to “Development and Feedback”
Who is online
Users browsing this forum: No registered users and 14 guests