Skip to content

Commit 36e24a4

Browse files
authored
Fix mistakes for STM32L475, add STM32WB55RG (#61)
* Erase both bank * Fix page size * Rename STM32WB55 to STM32WB55RG * Clean code * Add STM32WB55RC
1 parent 314556b commit 36e24a4

27 files changed

+19539
-16
lines changed

projects.yaml

+5-2
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,12 @@ projects:
161161
stm32l475:
162162
- *module_tools
163163
- records/projects/st/STM32L475.yaml
164-
stm32wb55:
164+
stm32wb55rg:
165165
- *module_tools
166-
- records/projects/st/STM32WB55.yaml
166+
- records/projects/st/STM32WB55RG.yaml
167+
stm32wb55rc:
168+
- *module_tools
169+
- records/projects/st/STM32WB55RC.yaml
167170
ncs36510:
168171
- *module_tools
169172
- records/projects/onsemi/ncs36510.yaml

records/projects/st/STM32WB55.yaml renamed to records/projects/st/STM32WB55RC.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ common:
66
- STM32WB55xx
77
includes:
88
- source/FlashOS.h
9-
- source/st/STM32WB55
10-
- source/st/STM32WB55/inc
9+
- source/st/STM32WB55RC
10+
- source/st/STM32WB55RC/inc
1111
sources:
12-
- source/st/STM32WB55
12+
- source/st/STM32WB55RC

records/projects/st/STM32WB55RG.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
common:
2+
target:
3+
- cortex-m4
4+
macros:
5+
- FLASH_DRV_VERS=0
6+
- STM32WB55xx
7+
includes:
8+
- source/FlashOS.h
9+
- source/st/STM32WB55RG
10+
- source/st/STM32WB55RG/inc
11+
sources:
12+
- source/st/STM32WB55RG

source/st/STM32L475/FlashDev.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,16 @@ struct FlashDevice const FlashDevice = {
4141
ONCHIP, // Device Type
4242
0x08000000, // Device Start Address
4343
0x00100000, // Device Size in Bytes (1024 kB)
44-
1024, // Programming Page Size -- maybe 256 by default ? --
44+
2048, // Programming Page Size
4545
0, // Reserved, must be 0
4646
0xFF, // Initial Content of Erased Memory
4747
100, // Program Page Timeout 100 mSec
4848
6000, // Erase Sector Timeout 6000 mSec
4949

5050
// Specify Size and Address of Sectors
51-
0x00800, 0x000000, // Sector Size 2kB (512 Sectors)
52-
SECTOR_END
51+
{
52+
{0x00800, 0x000000}, // Sector Size 2kB (512 Sectors)
53+
{SECTOR_END}
54+
}
5355
};
5456
#endif

source/st/STM32L475/FlashPrg.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,16 @@ int UnInit (unsigned long fnc) {
184184
* Return Value: 0 - OK, 1 - Failed
185185
*/
186186
int EraseChip (void) {
187-
188-
FLASH->CR |= FLASH_MER1; // Mass Erase Enabled (sectors 0..11)
189-
FLASH->CR |= FLASH_STRT; // Start Erase
187+
FLASH->CR |= FLASH_MER1; // Mass Erase Enabled (Bank 1)
188+
FLASH->CR |= FLASH_MER2; // Mass Erase Enabled (Bank 2)
189+
FLASH->CR |= FLASH_STRT; // Start Erase
190190

191191
while (FLASH->SR & FLASH_BSY) {
192192
IWDG->KR = 0xAAAA; // Reload IWDG
193193
}
194194

195195
FLASH->CR &= ~FLASH_MER1; // Mass Erase Disabled
196+
FLASH->CR &= ~FLASH_MER2; // Mass Erase Disabled
196197

197198
return (0); // Done
198199
}
@@ -245,7 +246,7 @@ int ProgramPage (unsigned long adr, unsigned long sz, unsigned char *buf) {
245246
FLASH->CR = 0; // reset CR
246247

247248
while (sz) {
248-
FLASH->CR |= (FLASH_PG | // Programming Enabled
249+
FLASH->CR |= (FLASH_PG | // Programming Enabled
249250
FLASH_PSIZE_Word); // Programming Enabled (Word)
250251

251252
M32(adr) = *((u32 *)buf); // Program Double Word

source/st/STM32WB55RC/FlashDev.c

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* -----------------------------------------------------------------------------
2+
* Copyright (c) 2021 ZeUGMA.
3+
*
4+
* This software is provided 'as-is', without any express or implied warranty.
5+
* In no event will the authors be held liable for any damages arising from
6+
* the use of this software. Permission is granted to anyone to use this
7+
* software for any purpose, including commercial applications, and to alter
8+
* it and redistribute it freely, subject to the following restrictions:
9+
*
10+
* 1. The origin of this software must not be misrepresented; you must not
11+
* claim that you wrote the original software. If you use this software in
12+
* a product, an acknowledgment in the product documentation would be
13+
* appreciated but is not required.
14+
*
15+
* 2. Altered source versions must be plainly marked as such, and must not be
16+
* misrepresented as being the original software.
17+
*
18+
* 3. This notice may not be removed or altered from any source distribution.
19+
*
20+
*
21+
* $Date: 16/06/2021
22+
* $Revision: V1.00
23+
*
24+
* Project: Flash Programming Functions for STMicroelectronics STM32WB55xx Flash
25+
* --------------------------------------------------------------------------- */
26+
27+
/* History:
28+
* Version 1.00
29+
* Initial release
30+
*/
31+
32+
33+
#include "FlashOS.h" // FlashOS Structures
34+
35+
#ifdef STM32WB55xx
36+
struct FlashDevice const FlashDevice = {
37+
FLASH_DRV_VERS, // Driver Version, do not modify!
38+
"STM32WB55RC 256kB Flash", // Device Name (256 kB)
39+
ONCHIP, // Device Type
40+
0x08000000, // Device Start Address
41+
0x00040000, // Device Size in Bytes (256 kB)
42+
4096, // Programming Page Size
43+
0, // Reserved, must be 0
44+
0xFF, // Initial Content of Erased Memory
45+
100, // Program Page Timeout 100 mSec
46+
6000, // Erase Sector Timeout 6000 mSec
47+
48+
// Specify Size and Address of Sectors
49+
{
50+
{0x01000, 0x000000}, // Sector Size 4kB (256 Sectors)
51+
{SECTOR_END}
52+
}
53+
};
54+
#endif
File renamed without changes.

source/st/STM32WB55/FlashDev.c renamed to source/st/STM32WB55RG/FlashDev.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,20 @@
3535
#ifdef STM32WB55xx
3636
struct FlashDevice const FlashDevice = {
3737
FLASH_DRV_VERS, // Driver Version, do not modify!
38-
"STM32L475VG 1024kB Flash", // Device Name (1024 kB)
38+
"STM32WB55RG 1024kB Flash", // Device Name (1024 kB)
3939
ONCHIP, // Device Type
4040
0x08000000, // Device Start Address
4141
0x00100000, // Device Size in Bytes (1024 kB)
42-
1024, // Programming Page Size -- maybe 256 by default ? --
42+
4096, // Programming Page Size -- maybe 256 by default ? --
4343
0, // Reserved, must be 0
4444
0xFF, // Initial Content of Erased Memory
4545
100, // Program Page Timeout 100 mSec
4646
6000, // Erase Sector Timeout 6000 mSec
4747

4848
// Specify Size and Address of Sectors
49-
0x01000, 0x000000, // Sector Size 4kB (256 Sectors)
50-
SECTOR_END
49+
{
50+
{0x01000, 0x000000}, // Sector Size 4kB (256 Sectors)
51+
{SECTOR_END}
52+
}
5153
};
5254
#endif

0 commit comments

Comments
 (0)