mkiiskila commented on a change in pull request #1297: Fix some issues with the 
L1/L0 flash driver
URL: https://github.com/apache/mynewt-core/pull/1297#discussion_r205798134
 
 

 ##########
 File path: hw/mcu/stm/stm32l1xx/src/hal_flash.c
 ##########
 @@ -65,31 +65,44 @@ static int
 stm32l1_flash_write(const struct hal_flash *dev, uint32_t address,
         const void *src, uint32_t num_bytes)
 {
-    const uint32_t *sptr;
+    uint32_t val;
     uint32_t i;
     int rc;
+    uint8_t align;
     uint32_t num_words;
 
     if (!num_bytes) {
         return -1;
     }
 
+    align = dev->hf_align;
+    num_words = ((num_bytes - 1) / dev->hf_align) + 1;
 
 Review comment:
   Luckily I have this code around. And actually, I'd be quite interested in 
seeing what different it does make :)
   https://github.com/mkiiskila/incubator-mynewt-core/tree/flash_speed_test
   
   Include test/flash_test package with slinky, and then from console:
   'flash_speed 0 0x08000000 0 0 1'
   I admit, the arguments to this might not be the greatest.
   
   If you have multiple possible alignments, and this code will be shared by 
all, I'd do:
   #if FLASH_ALIGNMENT == 8
   #define FLASH_ALIGNMENT_SHIFT 3
   #elif FLASH_ALIGNMENT == 4
   #define FLASH_ALIGNMENT_SHIFT 2
   ...
   
   num_words = (((num_bytes - 1) >> FLASH_ALIGNMENT_SHIFT) + 1;
   
   Anyway, running the speed test would show if udiv is worth avoiding or not.

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


With regards,
Apache Git Services

Reply via email to