Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

Commit e97df56

Browse files
authored
v1.2.0 to fix multiple-definitions linker error
### Major Releases v1.2.0 1. Fix `multiple-definitions` linker error. 2. Add example [multiFileProject](examples/multiFileProject) to demo for multiple-file project.
1 parent 2055be0 commit e97df56

File tree

24 files changed

+1113
-347
lines changed

24 files changed

+1113
-347
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p
1414

1515
Please ensure to specify the following:
1616

17-
* Arduino IDE version (e.g. 1.8.13) or Platform.io version
18-
* Board Core Version (e.g. Arduino STM32 core v2.0.0, etc.)
17+
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
18+
* Board Core Version (e.g. Arduino STM32 core v2.2.0, etc.)
1919
* Contextual information (e.g. what you were trying to achieve)
2020
* Simplest possible steps to reproduce
2121
* Anything that might be relevant in your opinion, such as:
@@ -26,10 +26,10 @@ Please ensure to specify the following:
2626
### Example
2727

2828
```
29-
Arduino IDE version: 1.8.13
30-
Arduino STM32 core v2.0.0
29+
Arduino IDE version: 1.8.19
30+
Arduino STM32 core v2.2.0
3131
OS: Ubuntu 20.04 LTS
32-
Linux Inspiron-3593 5.4.0-72-generic #80-Ubuntu SMP Mon Apr 12 17:35:00 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
32+
Linux Inspiron-3593 5.4.0-96-generic #109-Ubuntu SMP Wed Jan 12 16:49:16 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
3333
3434
Context:
3535
The board couldn't autoreconnect to Local Blynk Server after router power recycling.
@@ -39,6 +39,8 @@ Steps to reproduce:
3939
2. ...
4040
3. ...
4141
4. ...
42+
```
43+
4244

4345
### Sending Feature Requests
4446

README.md

Lines changed: 63 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@
1111

1212
## Table of Contents
1313

14+
* [Important Change from v1.2.0](#Important-Change-from-v120)
1415
* [Why do we need this FlashStorage_STM32 library](#why-do-we-need-this-FlashStorage_STM32-library)
1516
* [Features](#features)
1617
* [Currently supported Boards](#currently-supported-boards)
17-
* [Changelog](#changelog)
18-
* [Major Releases v1.1.0](#major-releases-v110)
19-
* [Releases v1.0.1](#releases-v101)
20-
* [Releases v1.0.0](#releases-v100)
18+
* [Changelog](changelog.md)
2119
* [Prerequisites](#prerequisites)
2220
* [Installation](#installation)
2321
* [Use Arduino Library Manager](#use-arduino-library-manager)
@@ -26,6 +24,7 @@
2624
* [Packages' Patches](#packages-patches)
2725
* [1. For STM32 boards to use LAN8720](#1-for-stm32-boards-to-use-lan8720)
2826
* [2. For STM32 boards to use Serial1](#2-for-stm32-boards-to-use-serial1)
27+
* [HOWTO Fix `Multiple Definitions` Linker Error](#howto-fix-multiple-definitions-linker-error)
2928
* [Limited number of writes](#limited-number-of-writes)
3029
* [Usage](#usage)
3130
* [Using the alternative EEPROM-like API](#using-the-alternative-eeprom-like-api)
@@ -41,6 +40,7 @@
4140
* [ 9. **EmulateEEPROM**](examples/EmulateEEPROM)
4241
* [ 10. **FlashStoreAndRetrieve**](examples/FlashStoreAndRetrieve)
4342
* [ 11. **StoreNameAndSurname**](examples/StoreNameAndSurname)
43+
* [ 12. **multiFileProject**](examples/multiFileProject) **New**
4444
* [Examples from other libraries](#examples-from-other-libraries)
4545
* [ 1. Library WiFiManager_Generic_Lite](#1-library-wifimanager_generic_lite)
4646
* [ 2. Library WiFiManager_NINA_Lite](#2-library-wifimanager_nina_lite)
@@ -66,7 +66,6 @@
6666
* [The content of the FlashStorage is erased each time a new sketch is uploaded?](#the-content-of-the-flashstorage-is-erased-each-time-a-new-sketch-is-uploaded)
6767
* [Do you recommend to use FLASH instead of EEPROM?](#do-you-recommend-to-use-flash-instead-of-eeprom)
6868
* [Troubleshooting](#troubleshooting)
69-
* [Releases](#releases)
7069
* [Issues](#issues)
7170
* [TO DO](#to-do)
7271
* [DONE](#done)
@@ -78,6 +77,13 @@
7877
---
7978
---
8079

80+
### Important Change from v1.2.0
81+
82+
Please have a look at [HOWTO Fix `Multiple Definitions` Linker Error](#howto-fix-multiple-definitions-linker-error)
83+
84+
---
85+
---
86+
8187
### Why do we need this [FlashStorage_STM32 library](https://github.com/khoih-prog/FlashStorage_STM32)
8288

8389
### Features
@@ -86,7 +92,7 @@ The FlashStorage_STM32 library, inspired by [Cristian Maglie's FlashStorage](htt
8692

8793
The flash memory, generally used to store the firmware code, can also be used to store / retrieve more user's data and faster than from EEPROM. Thanks to the **buffered data writing and reading**, the flash access time is greatly reduced to **increase the life of the flash**.
8894

89-
Currently, the library supports both new [**STM32 core v2.0.0**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/2.0.0) and previous [**STM32 core v1.9.0**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/1.9.0)
95+
Currently, the library supports both new [**STM32 core v2.0.0+**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/2.2.0) and previous [**STM32 core v1.9.0-**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/1.9.0)
9096

9197
---
9298

@@ -109,32 +115,13 @@ Currently, the library supports both new [**STM32 core v2.0.0**](https://github.
109115
- Generic Flight Controllers
110116
- Midatronics boards
111117

112-
---
113-
---
114-
115-
## Changelog
116-
117-
### Major Releases v1.1.0
118-
119-
1. Add support to new [**STM32 core v2.0.0**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/2.0.0)
120-
2. Add support to new STM32 L5 and many new STM32F/L/H/G/WB/MP1 boards
121-
122-
### Releases v1.0.1
123-
124-
1. Fix compiler warnings.
125-
126-
### Releases v1.0.0
127-
128-
1. Initial release to support STM32F/L/H/G/WB/MP1 board with / without integrated EEPROM
129-
130-
131118
---
132119
---
133120

134121
## Prerequisites
135122

136-
1. [`Arduino IDE 1.8.15+` for Arduino](https://www.arduino.cc/en/Main/Software)
137-
2. [`Arduino Core for STM32 v2.0.0+`](https://github.com/stm32duino/Arduino_Core_STM32) for STM32 boards. [![GitHub release](https://img.shields.io/github/release/stm32duino/Arduino_Core_STM32.svg)](https://github.com/stm32duino/Arduino_Core_STM32/releases/latest)
123+
1. [`Arduino IDE 1.8.19+` for Arduino](https://www.arduino.cc/en/Main/Software)
124+
2. [`Arduino Core for STM32 v2.2.0+`](https://github.com/stm32duino/Arduino_Core_STM32) for STM32 boards. [![GitHub release](https://img.shields.io/github/release/stm32duino/Arduino_Core_STM32.svg)](https://github.com/stm32duino/Arduino_Core_STM32/releases/latest)
138125

139126
---
140127

@@ -169,7 +156,7 @@ Another way to install is to:
169156

170157
#### 1. For STM32 boards to use LAN8720
171158

172-
Already updated and tested with latest **STM32 core v2.0.0**
159+
Already updated and tested with latest **STM32 core v2.2.0**
173160

174161
To use LAN8720 on some STM32 boards
175162

@@ -179,10 +166,10 @@ To use LAN8720 on some STM32 boards
179166

180167
you have to copy the files [stm32f4xx_hal_conf_default.h](Packages_Patches/STM32/hardware/stm32/x.yy.zz/system/STM32F4xx) and [stm32f7xx_hal_conf_default.h](Packages_Patches/STM32/hardware/stm32/x.yy.zz/system/STM32F7xx) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/system) to overwrite the old files.
181168

182-
Supposing the STM32 stm32 core version is 2.0.0. These files must be copied into the directory:
169+
Supposing the STM32 stm32 core version is 2.2.0. These files must be copied into the directory:
183170

184-
- `~/.arduino15/packages/STM32/hardware/stm32/2.0.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h` for STM32F4.
185-
- `~/.arduino15/packages/STM32/hardware/stm32/2.o.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h` for Nucleo-144 STM32F7.
171+
- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h` for STM32F4.
172+
- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h` for Nucleo-144 STM32F7.
186173

187174
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz,
188175
theses files must be copied into the corresponding directory:
@@ -193,12 +180,12 @@ theses files must be copied into the corresponding directory:
193180

194181
#### 2. For STM32 boards to use Serial1
195182

196-
**To use Serial1 on some STM32 boards without Serial1 definition (Nucleo-144 NUCLEO_F767ZI, Nucleo-64 NUCLEO_L053R8, etc.) boards**, you have to copy the files [STM32 variant.h](Packages_Patches/STM32/hardware/stm32/1.9.0) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/1.9.0). You have to modify the files corresponding to your boards, this is just an illustration how to do.
183+
**To use Serial1 on some STM32 boards without Serial1 definition (Nucleo-144 NUCLEO_F767ZI, Nucleo-64 NUCLEO_L053R8, etc.) boards**, you have to copy the files [STM32 variant.h](Packages_Patches/STM32/hardware/stm32/2.2.0) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.2.0). You have to modify the files corresponding to your boards, this is just an illustration how to do.
197184

198-
Supposing the STM32 stm32 core version is 1.9.0. These files must be copied into the directory:
185+
Supposing the STM32 stm32 core version is 2.2.0. These files must be copied into the directory:
199186

200-
- `~/.arduino15/packages/STM32/hardware/stm32/1.9.0/variants/NUCLEO_F767ZI/variant.h` for Nucleo-144 NUCLEO_F767ZI.
201-
- `~/.arduino15/packages/STM32/hardware/stm32/1.9.0/variants/NUCLEO_L053R8/variant.h` for Nucleo-64 NUCLEO_L053R8.
187+
- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/variants/NUCLEO_F767ZI/variant.h` for Nucleo-144 NUCLEO_F767ZI.
188+
- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/variants/NUCLEO_L053R8/variant.h` for Nucleo-64 NUCLEO_L053R8.
202189

203190
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz,
204191
theses files must be copied into the corresponding directory:
@@ -209,6 +196,31 @@ theses files must be copied into the corresponding directory:
209196
---
210197
---
211198

199+
### HOWTO Fix `Multiple Definitions` Linker Error
200+
201+
The current library implementation, using `xyz-Impl.h` instead of standard `xyz.cpp`, possibly creates certain `Multiple Definitions` Linker error in certain use cases.
202+
203+
You can include this `.hpp` file
204+
205+
```
206+
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
207+
#include "FlashStorage_STM32.hpp" //https://github.com/khoih-prog/FlashStorage_STM32
208+
```
209+
210+
in many files. But be sure to use the following `.h` file **in just 1 `.h`, `.cpp` or `.ino` file**, which must **not be included in any other file**, to avoid `Multiple Definitions` Linker Error
211+
212+
```
213+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
214+
#include "FlashStorage_STM32.h" //https://github.com/khoih-prog/FlashStorage_STM32
215+
```
216+
217+
Check the new [**multiFileProject** example](examples/multiFileProject) for a `HOWTO` demo.
218+
219+
Have a look at the discussion in [Different behaviour using the src_cpp or src_h lib #80](https://github.com/khoih-prog/ESPAsync_WiFiManager/discussions/80)
220+
221+
---
222+
---
223+
212224
## Limited number of writes
213225

214226
The flash memory has a limited amount of write cycles. Typical flash memories can perform about 10000 writes cycles to the same flash block before starting to "wear out" and begin to lose the ability to retain data.
@@ -250,6 +262,8 @@ The API is very similar to the well known Arduino EEPROM.h API but with 4 additi
250262
9. [EmulateEEPROM](examples/EmulateEEPROM)
251263
10. [FlashStoreAndRetrieve](examples/FlashStoreAndRetrieve)
252264
11. [StoreNameAndSurname](examples/StoreNameAndSurname)
265+
12. [**multiFileProject**](examples/multiFileProject) **New**
266+
253267

254268
---
255269

@@ -298,6 +312,7 @@ and many more to libraries come.
298312
```cpp
299313
// Demonstrate how to use FlashStorage_STM32 with an API that is similar to the EEPROM library to Store and retrieve structured data.
300314

315+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
301316
#include <FlashStorage_STM32.h>
302317

303318
const int WRITTEN_SIGNATURE = 0xBEEFDEED;
@@ -396,8 +411,8 @@ The following is the sample terminal output when running example [Ethernet_STM32
396411
```
397412
Start Ethernet_STM32_LAN8720 on BLACK_F407VE
398413
Ethernet Shield type : LAN8720 Ethernet & STM32Ethernet Library
399-
Ethernet_Manager_STM32 v1.3.0
400-
DoubleResetDetector_Generic v1.0.3
414+
Ethernet_Manager_STM32 v1.3.1
415+
DoubleResetDetector_Generic v1.7.3
401416
402417
EEPROM size = 16384, start = 0
403418
Flag read = 0xd0d04321
@@ -445,8 +460,8 @@ HHHHH[ETM] h:Updating EEPROM. Please wait for reset
445460
```
446461
Start Ethernet_STM32_LAN8720 on BLACK_F407VE
447462
Ethernet Shield type : LAN8720 Ethernet & STM32Ethernet Library
448-
Ethernet_Manager_STM32 v1.3.0
449-
DoubleResetDetector_Generic v1.0.3
463+
Ethernet_Manager_STM32 v1.3.1
464+
DoubleResetDetector_Generic v1.7.3
450465
451466
EEPROM size = 16384, start = 0
452467
Flag read = 0xd0d04321
@@ -519,7 +534,7 @@ The following is the sample terminal output when running example [StoreNameAndSu
519534

520535
```
521536
Start StoreNameAndSurname on NUCLEO_H743ZI2
522-
FlashStorage_STM32 v1.1.0
537+
FlashStorage_STM32 v1.2.0
523538
EEPROM length: 16384
524539
EEPROM is empty, writing WRITTEN_SIGNATURE and some example data:
525540
Insert your name : My_Name
@@ -535,7 +550,7 @@ Insert your surname : My_Surname
535550

536551
```
537552
Start StoreNameAndSurname on NUCLEO_H743ZI2
538-
FlashStorage_STM32 v1.1.0
553+
FlashStorage_STM32 v1.2.0
539554
EEPROM length: 16384
540555
Hi My_Name
541556
My_Surname
@@ -554,7 +569,7 @@ The following is the sample terminal output when running example [StoreNameAndSu
554569

555570
```
556571
Start StoreNameAndSurname on NUCLEO_L552ZE_Q
557-
FlashStorage_STM32 v1.1.0
572+
FlashStorage_STM32 v1.2.0
558573
EEPROM length: 2048
559574
EEPROM is empty, writing WRITTEN_SIGNATURE and some example data:
560575
Insert your name : My_Name
@@ -570,7 +585,7 @@ Insert your surname : My_Surname
570585

571586
```
572587
Start StoreNameAndSurname on NUCLEO_L552ZE_Q
573-
FlashStorage_STM32 v1.1.0
588+
FlashStorage_STM32 v1.2.0
574589
EEPROM length: 2048
575590
Hi My_Name
576591
My_Surname
@@ -589,7 +604,7 @@ The following is the sample terminal output when running example [StoreNameAndSu
589604

590605
```
591606
Start StoreNameAndSurname on NUCLEO_F767ZI
592-
FlashStorage_STM32 v1.1.0
607+
FlashStorage_STM32 v1.2.0
593608
EEPROM length: 16384
594609
EEPROM is empty, writing WRITTEN_SIGNATURE and some example data:
595610
Insert your name : My_Name
@@ -605,7 +620,7 @@ Insert your surname : My_Surname
605620

606621
```
607622
Start StoreNameAndSurname on NUCLEO_F767ZI
608-
FlashStorage_STM32 v1.1.0
623+
FlashStorage_STM32 v1.2.0
609624
EEPROM length: 16384
610625
Hi My_Name
611626
My_Surname
@@ -646,42 +661,6 @@ Sometimes, the library will only work if you update the board core to the latest
646661
---
647662
---
648663

649-
## Releases
650-
651-
### Major Releases v1.1.0
652-
653-
1. Add support to new [**STM32 core v2.0.0**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/2.0.0)
654-
2. Add support to new **STM32L5** and many new STM32F/L/H/G/WB/MP1 boards
655-
656-
### Releases v1.0.1
657-
658-
1. Fix compiler warnings.
659-
660-
### Releases v1.0.0
661-
662-
1. Initial release to support STM32F/L/H/G/WB/MP1 board with / without integrated EEPROM
663-
664-
### Currently supported Boards
665-
666-
1. **STM32F/L/H/G/WB/MP1 boards with / without integrated EEPROM**
667-
668-
- Nucleo-144
669-
- Nucleo-64
670-
- Nucleo-32
671-
- Discovery
672-
- Generic STM32F0, STM32F1, STM32F2, STM32F3, STM32F4, STM32F7
673-
- STM32L0, STM32L1, STM32L4, **STM32L5**
674-
- STM32G0, STM32G4
675-
- STM32H7
676-
- STM32WB
677-
- STM32MP1
678-
- LoRa boards
679-
- 3-D printer boards
680-
- Generic Flight Controllers
681-
- Midatronics boards
682-
683-
---
684-
---
685664

686665
### Issues
687666

@@ -702,7 +681,9 @@ Submit issues to: [FlashStorage_STM32 issues](https://github.com/khoih-prog/Flas
702681
2. Add support to new [**STM32 core v1.9.0**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/1.9.0)
703682
3. Similar features for remaining Arduino boards such as SAMD21, SAMD51, etc.
704683
4. Add Table of Contents
705-
5. Add support to new [**STM32 core v2.0.0**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/2.0.0)
684+
5. Add support to new [**STM32 core v2.2.0+**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/2.2.0)
685+
6. Fix `multiple-definitions` linker error.
686+
706687

707688
---
708689
---

changelog.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# FlashStorage_STM32 Library
2+
3+
[![arduino-library-badge](https://www.ardu-badge.com/badge/FlashStorage_STM32.svg?)](https://www.ardu-badge.com/FlashStorage_STM32)
4+
[![GitHub release](https://img.shields.io/github/release/khoih-prog/FlashStorage_STM32.svg)](https://github.com/khoih-prog/FlashStorage_STM32/releases)
5+
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/FlashStorage_STM32/blob/main/LICENSE)
6+
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
7+
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/FlashStorage_STM32.svg)](http://github.com/khoih-prog/FlashStorage_STM32/issues)
8+
9+
---
10+
---
11+
12+
## Table of Contents
13+
14+
* [Changelog](#changelog)
15+
* [Major Releases v1.2.0](#major-releases-v120)
16+
* [Major Releases v1.1.0](#major-releases-v110)
17+
* [Releases v1.0.1](#releases-v101)
18+
* [Releases v1.0.0](#releases-v100)
19+
20+
---
21+
---
22+
23+
## Changelog
24+
25+
### Major Releases v1.2.0
26+
27+
1. Fix `multiple-definitions` linker error.
28+
2. Add example [multiFileProject](examples/multiFileProject) to demo for multiple-file project.
29+
30+
31+
### Major Releases v1.1.0
32+
33+
1. Add support to new [**STM32 core v2.0.0**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/2.0.0)
34+
2. Add support to new STM32 L5 and many new STM32F/L/H/G/WB/MP1 boards
35+
36+
### Releases v1.0.1
37+
38+
1. Fix compiler warnings.
39+
40+
### Releases v1.0.0
41+
42+
1. Initial release to support STM32F/L/H/G/WB/MP1 board with / without integrated EEPROM
43+
44+

0 commit comments

Comments
 (0)