Fix sector size in STM32F4xx EFL driver and add F4x5/4x7
@@ -16,7 +16,7 @@ | ||
16 | 16 | |
17 | 17 | /** |
18 | 18 | * @file hal_efl_lld.c |
19 | - * @brief STM32F412/413 Embedded Flash subsystem low level driver source. | |
19 | + * @brief STM32F4xx Embedded Flash subsystem low level driver source. | |
20 | 20 | * |
21 | 21 | * @addtogroup HAL_EFL |
22 | 22 | * @{ |
@@ -44,6 +44,10 @@ | ||
44 | 44 | #define FLASH_OPTKEY1 0x08192A3BU |
45 | 45 | #define FLASH_OPTKEY2 0x4C5D6E7FU |
46 | 46 | |
47 | +#if !defined(FLASH_SR_OPERR) | |
48 | +#define FLASH_SR_OPERR FLASH_SR_SOP | |
49 | +#endif | |
50 | + | |
47 | 51 | /*===========================================================================*/ |
48 | 52 | /* Driver exported variables. */ |
49 | 53 | /*===========================================================================*/ |
@@ -57,41 +61,43 @@ | ||
57 | 61 | /* Driver local variables and types. */ |
58 | 62 | /*===========================================================================*/ |
59 | 63 | |
60 | -#if defined(STM32F413xx) || defined(STM32F412xx) || defined(__DOXYGEN__) | |
64 | +#if defined(STM32F413xx) || defined(STM32F412xx) || defined(STM32F40_41xxx) \ | |
65 | + || defined(__DOXYGEN__) | |
66 | + | |
61 | 67 | /* Sector table for 1.5M device. */ |
62 | 68 | static const flash_sector_descriptor_t efl_lld_sect1[STM32_FLASH1_SECTORS_TOTAL] = { |
63 | - { 0, 16834}, /* Sector 0. */ | |
64 | - { 1 * 16834, 16834}, /* Sector 1. */ | |
65 | - { 2 * 16834, 16834}, /* Sector 2. */ | |
66 | - { 3 * 16834, 16834}, /* Sector 3. */ | |
67 | - { 4 * 16834, 65536}, /* Sector 4. */ | |
68 | - { 4 * 16834 + 65536, 131072}, /* Sector 5. */ | |
69 | - { 4 * 16834 + 65536 + 1 * 131072, 131072}, /* Sector 6. */ | |
70 | - { 4 * 16834 + 65536 + 2 * 131072, 131072}, /* Sector 7. */ | |
71 | - { 4 * 16834 + 65536 + 3 * 131072, 131072}, /* Sector 8. */ | |
72 | - { 4 * 16834 + 65536 + 4 * 131072, 131072}, /* Sector 9. */ | |
73 | - { 4 * 16834 + 65536 + 5 * 131072, 131072}, /* Sector 10. */ | |
74 | - { 4 * 16834 + 65536 + 6 * 131072, 131072}, /* Sector 11. */ | |
75 | - { 4 * 16834 + 65536 + 7 * 131072, 131072}, /* Sector 12. */ | |
76 | - { 4 * 16834 + 65536 + 8 * 131072, 131072}, /* Sector 13. */ | |
77 | - { 4 * 16834 + 65536 + 9 * 131072, 131072}, /* Sector 14. */ | |
78 | - { 4 * 16834 + 65536 + 10 * 131072, 131072} /* Sector 15. */ | |
69 | + { 0, 16384}, /* Sector 0. */ | |
70 | + { 1 * 16384, 16384}, /* Sector 1. */ | |
71 | + { 2 * 16384, 16384}, /* Sector 2. */ | |
72 | + { 3 * 16384, 16384}, /* Sector 3. */ | |
73 | + { 4 * 16384, 65536}, /* Sector 4. */ | |
74 | + { 4 * 16384 + 65536, 131072}, /* Sector 5. */ | |
75 | + { 4 * 16384 + 65536 + 1 * 131072, 131072}, /* Sector 6. */ | |
76 | + { 4 * 16384 + 65536 + 2 * 131072, 131072}, /* Sector 7. */ | |
77 | + { 4 * 16384 + 65536 + 3 * 131072, 131072}, /* Sector 8. */ | |
78 | + { 4 * 16384 + 65536 + 4 * 131072, 131072}, /* Sector 9. */ | |
79 | + { 4 * 16384 + 65536 + 5 * 131072, 131072}, /* Sector 10. */ | |
80 | + { 4 * 16384 + 65536 + 6 * 131072, 131072}, /* Sector 11. */ | |
81 | + { 4 * 16384 + 65536 + 7 * 131072, 131072}, /* Sector 12. */ | |
82 | + { 4 * 16384 + 65536 + 8 * 131072, 131072}, /* Sector 13. */ | |
83 | + { 4 * 16384 + 65536 + 9 * 131072, 131072}, /* Sector 14. */ | |
84 | + { 4 * 16384 + 65536 + 10 * 131072, 131072} /* Sector 15. */ | |
79 | 85 | }; |
80 | 86 | |
81 | 87 | /* Sector table for 1M device. */ |
82 | 88 | static const flash_sector_descriptor_t efl_lld_sect2[STM32_FLASH2_SECTORS_TOTAL] = { |
83 | - { 0, 16834}, /* Sector 0. */ | |
84 | - { 1 * 16834, 16834}, /* Sector 1. */ | |
85 | - { 2 * 16834, 16834}, /* Sector 2. */ | |
86 | - { 3 * 16834, 16834}, /* Sector 3. */ | |
87 | - { 4 * 16834, 65536}, /* Sector 4. */ | |
88 | - { 4 * 16834 + 65536, 131072}, /* Sector 5. */ | |
89 | - { 4 * 16834 + 65536 + 1 * 131072, 131072}, /* Sector 6. */ | |
90 | - { 4 * 16834 + 65536 + 2 * 131072, 131072}, /* Sector 7. */ | |
91 | - { 4 * 16834 + 65536 + 3 * 131072, 131072}, /* Sector 8. */ | |
92 | - { 4 * 16834 + 65536 + 4 * 131072, 131072}, /* Sector 9. */ | |
93 | - { 4 * 16834 + 65536 + 5 * 131072, 131072}, /* Sector 10. */ | |
94 | - { 4 * 16834 + 65536 + 6 * 131072, 131072} /* Sector 11. */ | |
89 | + { 0, 16384}, /* Sector 0. */ | |
90 | + { 1 * 16384, 16384}, /* Sector 1. */ | |
91 | + { 2 * 16384, 16384}, /* Sector 2. */ | |
92 | + { 3 * 16384, 16384}, /* Sector 3. */ | |
93 | + { 4 * 16384, 65536}, /* Sector 4. */ | |
94 | + { 4 * 16384 + 65536, 131072}, /* Sector 5. */ | |
95 | + { 4 * 16384 + 65536 + 1 * 131072, 131072}, /* Sector 6. */ | |
96 | + { 4 * 16384 + 65536 + 2 * 131072, 131072}, /* Sector 7. */ | |
97 | + { 4 * 16384 + 65536 + 3 * 131072, 131072}, /* Sector 8. */ | |
98 | + { 4 * 16384 + 65536 + 4 * 131072, 131072}, /* Sector 9. */ | |
99 | + { 4 * 16384 + 65536 + 5 * 131072, 131072}, /* Sector 10. */ | |
100 | + { 4 * 16384 + 65536 + 6 * 131072, 131072} /* Sector 11. */ | |
95 | 101 | }; |
96 | 102 | |
97 | 103 | /* The descriptors for 1.5M device. */ |
@@ -325,10 +331,12 @@ | ||
325 | 331 | memcpy((void *)rp, (const void *)efl_lld_get_descriptor(instance)->address |
326 | 332 | + offset, n); |
327 | 333 | |
334 | +#if defined(FLASH_CR_RDERR) | |
328 | 335 | /* Checking for errors after reading.*/ |
329 | 336 | if ((devp->flash->SR & FLASH_SR_RDERR) != 0U) { |
330 | 337 | err = FLASH_ERROR_READ; |
331 | 338 | } |
339 | +#endif | |
332 | 340 | |
333 | 341 | /* Ready state again.*/ |
334 | 342 | devp->state = FLASH_READY; |
@@ -16,7 +16,7 @@ | ||
16 | 16 | |
17 | 17 | /** |
18 | 18 | * @file hal_efl_lld.h |
19 | - * @brief STM32F412/413 Embedded Flash subsystem low level driver header. | |
19 | + * @brief STM32F4xx Embedded Flash subsystem low level driver header. | |
20 | 20 | * |
21 | 21 | * @addtogroup HAL_EFL |
22 | 22 | * @{ |
@@ -51,7 +51,8 @@ | ||
51 | 51 | /* Derived constants and error checks. */ |
52 | 52 | /*===========================================================================*/ |
53 | 53 | |
54 | -#if defined(STM32F413xx) || defined(STM32F412xx) || defined(__DOXYGEN__) | |
54 | +#if defined(STM32F413xx) || defined(STM32F412xx) || defined(STM32F40_41xxx) \ | |
55 | + || defined(__DOXYGEN__) | |
55 | 56 | |
56 | 57 | /* Flash size register. */ |
57 | 58 | #define STM32_FLASH_SIZE_REGISTER 0x1FFF7A22 |