You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/02/28 12:55:14 UTC

[GitHub] [incubator-nuttx] bjbrandt commented on issue #391: arch/arm/src/stm32/stm32f20xxf40xx_flash.c: Add progmen flash block mapping.

bjbrandt commented on issue #391: arch/arm/src/stm32/stm32f20xxf40xx_flash.c: Add progmen flash block mapping.
URL: https://github.com/apache/incubator-nuttx/pull/391#issuecomment-592500639
 
 
   > I think we need to step back and look at the API. It seems to have become very corrupted.
   Blocks, pages and Sectors have been muddled. The only thing that matters in the STM32 Soc is the Sector size and sizes.
   
   I think the use of terms like 'pages' and ' erase blocks' is just a try of generalization. Regarding the STM32 family an 'erase block' is just an alias for 'sector' while 'page' means the smaller r/w hunks (that do not have a name in the STM32 Reference manual). It is defined that an erase block is always a multiple of a single r/w page.
   
   
   > Consider the use case of a bootloader: How does one implement a simple Erase From Sector 2 to N (23 on the F4) and program from Sector 2 - n?
   > 
   > With the changes in [29164c5](https://github.com/apache/incubator-nuttx/commit/29164c5706490b74a84d44ba0f79cd588fd3e910) and herein what are the calls to do this? Can it even be done?
   
   If I got the API right, it should be done like this:
   
   ```
   /* erase sector 2 - N */
   
   for (int block = 1; block < N; ++i)
   {
      up_progmem_eraseblock(block);
   }
   
   /* get the first write page */
   
   size_t page = up_progmem_erasesize(0) / up_progmem_pagesize(0); 
   
   /* get the address off the desired page */
   
   size_t addr = up_progmem_getaddress(page);
   
   /* finally write the hunk */
   
   up_progmem_write(addr, buf, count);
   ```
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services