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

Commit 939a953

Browse files
authored
v1.1.0 to fix multiple-definitions linker error
### Releases v1.1.0 1. Fix `multiple-definitions` linker error. 2. Add example [multiFileProject](examples/multiFileProject) to demo for multiple-file project. 3. Update `Packages' Patches`
1 parent 7c8c2d6 commit 939a953

File tree

23 files changed

+753
-367
lines changed

23 files changed

+753
-367
lines changed

CONTRIBUTING.md

Lines changed: 5 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.15) 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
* Board and Configuration
2020
* Contextual information (e.g. what you were trying to achieve)
2121
* Simplest possible steps to reproduce
@@ -27,11 +27,11 @@ Please ensure to specify the following:
2727
### Example
2828

2929
```
30-
Arduino IDE version: 1.8.15
31-
Arduino STM32 core v2.0.0
30+
Arduino IDE version: 1.8.19
31+
Arduino STM32 core v2.2.0
3232
Board: STM32F103C8T6, 64KB Flash
3333
OS: Ubuntu 20.04 LTS
34-
Linux Inspiron-3593 5.4.0-81-generic #91-Ubuntu SMP Thu Jul 15 19:09:17 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
34+
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
3535
3636
Context:
3737
The board couldn't autoreconnect to Local Blynk Server after router power recycling.

README.md

Lines changed: 64 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111

1212
## Table of Contents
1313

14+
* [Important Change from v1.1.0](#Important-Change-from-v110)
1415
* [Why do we need this FlashStorage_STM32F1 library](#why-do-we-need-this-flashstorage_stm32f1-library)
1516
* [Features](#features)
1617
* [Currently supported Boards](#currently-supported-boards)
1718
* [STM32F1xx](#stm32f1xx)
1819
* [STM32F3xx](#stm32f3xx)
19-
* [Changelog](#changelog)
20-
* [Releases v1.0.1](#releases-v101)
21-
* [Initial Releases v1.0.0](#initial-releases-v100)
20+
* [Changelog](changelog.md)
2221
* [Prerequisites](#prerequisites)
2322
* [Installation](#installation)
2423
* [Use Arduino Library Manager](#use-arduino-library-manager)
@@ -27,6 +26,7 @@
2726
* [Packages' Patches](#packages-patches)
2827
* [1. For STM32 boards to use LAN8720](#1-for-stm32-boards-to-use-lan8720)
2928
* [2. For STM32 boards to use Serial1](#2-for-stm32-boards-to-use-serial1)
29+
* [HOWTO Fix `Multiple Definitions` Linker Error](#howto-fix-multiple-definitions-linker-error)
3030
* [Limited number of writes](#limited-number-of-writes)
3131
* [Usage](#usage)
3232
* [Using the alternative EEPROM-like API](#using-the-alternative-eeprom-like-api)
@@ -41,6 +41,7 @@
4141
* [ 8. EEPROM_write](examples/EEPROM_write)
4242
* [ 9. **EmulateEEPROM**](examples/EmulateEEPROM)
4343
* [ 10. **FlashStoreAndRetrieve**](examples/FlashStoreAndRetrieve)
44+
* [ 11. **multiFileProject**](examples/multiFileProject) **New**
4445
* [Example FlashStoreAndRetrieve](#example-flashstoreandretrieve)
4546
* [Debug Terminal Output Samples](#debug-terminal-output-samples)
4647
* [1. EEPROM_get on BLUEPILL_F103C8 with 64KB Flash](#1-eeprom_get-on-bluepill_f103c8-with-64kb-flash)
@@ -61,7 +62,6 @@
6162
* [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)
6263
* [Do you recommend to use FLASH instead of EEPROM?](#do-you-recommend-to-use-flash-instead-of-eeprom)
6364
* [Troubleshooting](#troubleshooting)
64-
* [Releases](#releases)
6565
* [Issues](#issues)
6666
* [TO DO](#to-do)
6767
* [DONE](#done)
@@ -73,6 +73,13 @@
7373
---
7474
---
7575

76+
### Important Change from v1.1.0
77+
78+
Please have a look at [HOWTO Fix `Multiple Definitions` Linker Error](#howto-fix-multiple-definitions-linker-error)
79+
80+
---
81+
---
82+
7683
### Why do we need this [FlashStorage_STM32F1 library](https://github.com/khoih-prog/FlashStorage_STM32F1)
7784

7885
### Features
@@ -122,31 +129,13 @@ Currently, the library supports both new [**STM32 core v2.0.0**](https://github.
122129
- GENERIC_F334K4TX, GENERIC_F334K6TX, GENERIC_F334K8TX
123130
- SPARKY_F303CC
124131

125-
---
126-
---
127-
128-
## Changelog
129-
130-
### Releases v1.0.1
131-
132-
1. Fix mistake in initial releases
133-
134-
135-
### Initial Releases v1.0.0
136-
137-
1. Initial release to support STM32F1/F3 boards with / without integrated EEPROM
138-
2. Tested using genuine STM32F103, or CH32F103/CS32F103 boards with 32KB, 64KB or 128KB Flash Size
139-
3. Configurable Flash Sector to use
140-
4. FlashStorage size is 1024 bytes (including `1-byte valid` and `4-byte signature`)
141-
142-
143132
---
144133
---
145134

146135
## Prerequisites
147136

148-
1. [`Arduino IDE 1.8.15+` for Arduino](https://www.arduino.cc/en/Main/Software)
149-
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)
137+
1. [`Arduino IDE 1.8.19+` for Arduino](https://github.com/arduino/Arduino). [![GitHub release](https://img.shields.io/github/release/arduino/Arduino.svg)](https://github.com/arduino/Arduino/releases/latest)
138+
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)
150139

151140
---
152141

@@ -181,7 +170,7 @@ Another way to install is to:
181170

182171
#### 1. For STM32 boards to use LAN8720
183172

184-
Already updated and tested with latest **STM32 core v2.0.0**
173+
Already updated and tested with latest **STM32 core v2.2.0**
185174

186175
To use LAN8720 on some STM32 boards
187176

@@ -191,10 +180,10 @@ To use LAN8720 on some STM32 boards
191180

192181
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.
193182

194-
Supposing the STM32 stm32 core version is 2.0.0. These files must be copied into the directory:
183+
Supposing the STM32 stm32 core version is 2.2.0. These files must be copied into the directory:
195184

196-
- `~/.arduino15/packages/STM32/hardware/stm32/2.0.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h` for STM32F4.
197-
- `~/.arduino15/packages/STM32/hardware/stm32/2.o.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h` for Nucleo-144 STM32F7.
185+
- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h` for STM32F4.
186+
- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h` for Nucleo-144 STM32F7.
198187

199188
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz,
200189
theses files must be copied into the corresponding directory:
@@ -205,19 +194,46 @@ theses files must be copied into the corresponding directory:
205194

206195
#### 2. For STM32 boards to use Serial1
207196

208-
**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.
197+
**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.
209198

210-
Supposing the STM32 stm32 core version is 1.9.0. These files must be copied into the directory:
199+
Supposing the STM32 stm32 core version is 2.2.0. These files must be copied into the directory:
211200

212-
- `~/.arduino15/packages/STM32/hardware/stm32/1.9.0/variants/NUCLEO_F767ZI/variant.h` for Nucleo-144 NUCLEO_F767ZI.
213-
- `~/.arduino15/packages/STM32/hardware/stm32/1.9.0/variants/NUCLEO_L053R8/variant.h` for Nucleo-64 NUCLEO_L053R8.
201+
- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/variants/NUCLEO_F767ZI/variant.h` for Nucleo-144 NUCLEO_F767ZI.
202+
- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/variants/NUCLEO_L053R8/variant.h` for Nucleo-64 NUCLEO_L053R8.
214203

215204
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz,
216205
theses files must be copied into the corresponding directory:
217206

218207
- `~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/variants/NUCLEO_F767ZI/variant.h`
219208
- `~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/variants/NUCLEO_L053R8/variant.h`
220209

210+
211+
---
212+
---
213+
214+
### HOWTO Fix `Multiple Definitions` Linker Error
215+
216+
The current library implementation, using `xyz-Impl.h` instead of standard `xyz.cpp`, possibly creates certain `Multiple Definitions` Linker error in certain use cases.
217+
218+
You can include this `.hpp` file
219+
220+
```
221+
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
222+
#include "FlashStorage_STM32F1.hpp" //https://github.com/khoih-prog/FlashStorage_STM32F1
223+
```
224+
225+
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
226+
227+
```
228+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
229+
#include "FlashStorage_STM32F1.h" //https://github.com/khoih-prog/FlashStorage_STM32F1
230+
```
231+
232+
Check the new [**multiFileProject** example](examples/multiFileProject) for a `HOWTO` demo.
233+
234+
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)
235+
236+
221237
---
222238
---
223239

@@ -261,7 +277,7 @@ The API is very similar to the well known Arduino EEPROM.h API but with 4 additi
261277
8. [EEPROM_write](examples/EEPROM_write)
262278
9. [EmulateEEPROM](examples/EmulateEEPROM)
263279
10. [FlashStoreAndRetrieve](examples/FlashStoreAndRetrieve)
264-
280+
11. [**multiFileProject**](examples/multiFileProject) **New**
265281

266282
---
267283
---
@@ -277,6 +293,7 @@ The API is very similar to the well known Arduino EEPROM.h API but with 4 additi
277293
// Default is (REGISTERED_NUMBER_FLASH_SECTORS - 1) if you don't specify here
278294
#define USING_FLASH_SECTOR_NUMBER (REGISTERED_NUMBER_FLASH_SECTORS - 2)
279295

296+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
280297
#include <FlashStorage_STM32F1.h>
281298

282299
// Note: the area of flash memory reserved for the variable is
@@ -337,7 +354,7 @@ The following is the sample terminal output when running example [EEPROM_get](ex
337354

338355
```
339356
Start EEPROM_get on BLUEPILL_F103C8
340-
FlashStorage_STM32F1 v1.0.1
357+
FlashStorage_STM32F1 v1.1.0
341358
EEPROM length: 1019
342359
Start Flash Address: 0x800F800
343360
[FLASH] REGISTERED_NUMBER_FLASH_SECTORS (KB) = 64
@@ -357,7 +374,7 @@ Reset to see how you can retrieve the values by using EEPROM_get!
357374

358375
```
359376
Start EEPROM_get on BLUEPILL_F103C8
360-
FlashStorage_STM32F1 v1.0.1
377+
FlashStorage_STM32F1 v1.1.0
361378
EEPROM length: 1019
362379
Start Flash Address: 0x800F800
363380
[FLASH] REGISTERED_NUMBER_FLASH_SECTORS (KB) = 64
@@ -382,7 +399,7 @@ The following is the sample terminal output when running example [FlashStoreAndR
382399

383400
```
384401
Start FlashStoreAndRetrieve on BLUEPILL_F103C8
385-
FlashStorage_STM32F1 v1.0.1
402+
FlashStorage_STM32F1 v1.1.0
386403
EEPROM length: 1019
387404
Start Flash Address: 0x800FC00
388405
[FLASH] REGISTERED_NUMBER_FLASH_SECTORS (KB) = 64
@@ -396,7 +413,7 @@ Done writing to emulated EEPROM. You can reset now
396413
```
397414
398415
Start FlashStoreAndRetrieve on BLUEPILL_F103C8
399-
FlashStorage_STM32F1 v1.0.1
416+
FlashStorage_STM32F1 v1.1.0
400417
EEPROM length: 1019
401418
Start Flash Address: 0x800FC00
402419
[FLASH] REGISTERED_NUMBER_FLASH_SECTORS (KB) = 64
@@ -414,7 +431,7 @@ The following is the sample terminal output when running example [EEPROM_write](
414431

415432
```
416433
Start EEPROM_write on BLUEPILL_F103C8
417-
FlashStorage_STM32F1 v1.0.1
434+
FlashStorage_STM32F1 v1.1.0
418435
EEPROM length: 1019
419436
Start Flash Address: 0x801F800
420437
[FLASH] REGISTERED_NUMBER_FLASH_SECTORS (KB) = 128
@@ -437,7 +454,7 @@ The following is the sample terminal output when running example [EmulatedEEPROM
437454

438455
```
439456
Start EmulatedEEPROM on BLUEPILL_F103C8
440-
FlashStorage_STM32F1 v1.0.1
457+
FlashStorage_STM32F1 v1.1.0
441458
EEPROM length: 1019
442459
Start Flash Address: 0x801FC00
443460
[FLASH] REGISTERED_NUMBER_FLASH_SECTORS (KB) = 128
@@ -451,7 +468,7 @@ Done writing to emulated EEPROM. You can reset now to test
451468

452469
```
453470
Start EmulatedEEPROM on BLUEPILL_F103C8
454-
FlashStorage_STM32F1 v1.0.1
471+
FlashStorage_STM32F1 v1.1.0
455472
EEPROM length: 1019
456473
Start Flash Address: 0x801FC00
457474
[FLASH] REGISTERED_NUMBER_FLASH_SECTORS (KB) = 128
@@ -487,7 +504,7 @@ The following is the sample terminal output when running example [FlashStoreAndR
487504

488505
```
489506
Start FlashStoreAndRetrieve on GENERIC_F103RCTX
490-
FlashStorage_STM32F1 v1.0.0
507+
FlashStorage_STM32F1 v1.1.0
491508
EEPROM length: 1019
492509
Start Flash Address: 0x803F800
493510
[FLASH] REGISTERED_NUMBER_FLASH_SECTORS (KB) = 256
@@ -500,7 +517,7 @@ Done writing to emulated EEPROM. You can reset now
500517

501518
```
502519
Start FlashStoreAndRetrieve on GENERIC_F103RCTX
503-
FlashStorage_STM32F1 v1.0.0
520+
FlashStorage_STM32F1 v1.1.0
504521
EEPROM length: 1019
505522
Start Flash Address: 0x803F800
506523
[FLASH] REGISTERED_NUMBER_FLASH_SECTORS (KB) = 256
@@ -540,60 +557,6 @@ Sometimes, the library will only work if you update the board core to the latest
540557
---
541558
---
542559

543-
## Releases
544-
545-
### Releases v1.0.1
546-
547-
1. Fix mistake in initial releases
548-
549-
### Initial Releases v1.0.0
550-
551-
1. Initial release to support STM32F1/F3 boards with / without integrated EEPROM
552-
2. Tested using genuine STM32F103, or CH32F103/CS32F103 boards with 32KB, 64KB or 128KB Flash Size
553-
3. Configurable Flash Sector to use
554-
4. FlashStorage size is 1024 bytes (including `1-byte valid` and `4-byte signature`)
555-
556-
---
557-
558-
### Currently supported Boards
559-
560-
1. **STM32F1/F3 boards with / without integrated EEPROM**
561-
562-
#### STM32F1xx
563-
564-
- NUCLEO_F103RB, DISCO_F100RB
565-
- BLUEPILL_F103C6, BLUEPILL_F103C8, BLUEPILL_F103CB
566-
- BLACKPILL_F103C8, BLACKPILL_F103CB
567-
- Generic STM32F1, STM32F3
568-
- VCCGND_F103ZET6_MINI, VCCGND_F103ZET6,
569-
- HY_TINYSTM103TB, MAPLEMINI_F103CB
570-
- BLUEBUTTON_F103R8T, BLUEBUTTON_F103RBT, BLUEBUTTON_F103RCT, BLUEBUTTON_F103RET
571-
- GENERIC_F100C4TX, GENERIC_F100C8TX, GENERIC_F100CBTX
572-
- GENERIC_F103C4TX, GENERIC_F103C6TX, GENERIC_F103C6UX, GENERIC_F103C8TX, GENERIC_F103CBTX, GENERIC_F103CBUX
573-
- GENERIC_F100R8TX, GENERIC_F100RBTX
574-
- GENERIC_F103R4HX, GENERIC_F103R6HX, GENERIC_F103R4TX, GENERIC_F103R6TX, GENERIC_F103R8HX, GENERIC_F103RBHX, GENERIC_F103R8TX
575-
- GENERIC_F103RBTX, GENERIC_F103RCTX, GENERIC_F103RDTX, GENERIC_F103RETX, GENERIC_F103RCYX, GENERIC_F103RDYX, GENERIC_F103REYX
576-
- GENERIC_F103RFTX, GENERIC_F103RGTX
577-
- GENERIC_F103T4UX, GENERIC_F103T6UX, GENERIC_F103T8UX, GENERIC_F103TBUX
578-
- GENERIC_F103V8HX, GENERIC_F103VBHX, GENERIC_F103V8TX, GENERIC_F103VBTX, GENERIC_F103VBIX, GENERIC_F103VCHX, GENERIC_F103VDHX
579-
- GENERIC_F103VEHX, GENERIC_F103VCTX, GENERIC_F103VDTX, GENERIC_F103VETX, GENERIC_F103VFTX, GENERIC_F103VGTX,
580-
- GENERIC_F103ZCHX, GENERIC_F103ZDHX, GENERIC_F103ZEHX, GENERIC_F103ZCTX, GENERIC_F103ZDTX, GENERIC_F103ZETX, GENERIC_F103ZFHX,
581-
- GENERIC_F103ZGHX, GENERIC_F103ZFTX, GENERIC_F103ZGTX
582-
- MALYANM200_F103CB, AFROFLIGHT_F103CB
583-
584-
#### STM32F3xx
585-
586-
- NUCLEO_F302R8, NUCLEO_F303RE, NUCLEO_F303K8, DISCO_F303VC
587-
- BLACKPILL_F303CC, OLIMEXINO_STM32F3
588-
- GENERIC_F302R6TX, GENERIC_F302R8TX, GENERIC_F303RBTX, GENERIC_F303RCTX, GENERIC_F303RDTX, GENERIC_F303RETX
589-
- GENERIC_F303CBTX, GENERIC_F303CCTX
590-
- GENERIC_F303K6TX, GENERIC_F303K8TX
591-
- GENERIC_F303VBTX, GENERIC_F303VCTX
592-
- GENERIC_F334K4TX, GENERIC_F334K6TX, GENERIC_F334K8TX
593-
- SPARKY_F303CC
594-
595-
---
596-
---
597560

598561
### Issues
599562

@@ -614,7 +577,10 @@ Submit issues to: [FlashStorage_STM32F1 issues](https://github.com/khoih-prog/Fl
614577
2. Add support to new [**STM32 core v1.9.0**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/1.9.0)
615578
3. Similar features for remaining Arduino boards such as SAMD21, SAMD51, etc.
616579
4. Add Table of Contents
617-
5. Add support to new [**STM32 core v2.0.0**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/2.0.0)
580+
5. Add support to new [**STM32 core v2.2.0+**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/2.2.0)
581+
6. Add `EEPROM.put()` and `EEPROM.get()` functions to read/write the whole struct in emulated-EEPROM
582+
7. Fix `multiple-definitions` linker error.
583+
8. Clean-up by reducing the number of library files
618584

619585
---
620586
---
@@ -645,7 +611,7 @@ If you want to contribute to this project:
645611

646612
### License
647613

648-
- The library is licensed under [MIT](https://github.com/khoih-prog/FlashStorage_STM32F1/blob/main/LICENSE)
614+
- The library is licensed under [LGPLv3](https://github.com/khoih-prog/FlashStorage_STM32F1/blob/main/LICENSE)
649615

650616
---
651617

0 commit comments

Comments
 (0)