Internal Flash Driver

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

Re: Internal Flash Driver

Postby faisal » Fri Feb 15, 2019 5:18 pm

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

User avatar
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

Postby alex31 » Wed Feb 20, 2019 4:27 pm

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

faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

Re: Internal Flash Driver

Postby faisal » Wed Feb 20, 2019 8:49 pm

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.

User avatar
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

Postby Giovanni » Sun Apr 07, 2019 10:50 am

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

faisal
Posts: 374
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 44 times
Been thanked: 60 times

Re: Internal Flash Driver

Postby faisal » Sun Apr 07, 2019 7:25 pm

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.

User avatar
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

Postby Giovanni » Sat Apr 13, 2019 3:52 pm

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

User avatar
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

Postby FXCoder » Sun Apr 14, 2019 12:23 pm

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

User avatar
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

Postby Giovanni » Sun Apr 14, 2019 12:32 pm

I just committed more changes and a demo EFL+MFS, please work on the latest version.

Giovanni

User avatar
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

Postby Giovanni » Sun Apr 14, 2019 1:28 pm

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

User avatar
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

Postby FXCoder » Sun Apr 14, 2019 1:46 pm

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


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 14 guests