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

Commit

Permalink
v1.2.0 to fix multiple-definitions linker error
Browse files Browse the repository at this point in the history
### Major Releases v1.2.0

1. Fix `multiple-definitions` linker error.
2. Add example [multiFileProject](examples/multiFileProject) to demo for multiple-file project.
  • Loading branch information
khoih-prog committed Jan 26, 2022
1 parent 2055be0 commit e97df56
Show file tree
Hide file tree
Showing 24 changed files with 1,113 additions and 347 deletions.
12 changes: 7 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p

Please ensure to specify the following:

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

```
Arduino IDE version: 1.8.13
Arduino STM32 core v2.0.0
Arduino IDE version: 1.8.19
Arduino STM32 core v2.2.0
OS: Ubuntu 20.04 LTS
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
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
Context:
The board couldn't autoreconnect to Local Blynk Server after router power recycling.
Expand All @@ -39,6 +39,8 @@ Steps to reproduce:
2. ...
3. ...
4. ...
```


### Sending Feature Requests

Expand Down
145 changes: 63 additions & 82 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@

## Table of Contents

* [Important Change from v1.2.0](#Important-Change-from-v120)
* [Why do we need this FlashStorage_STM32 library](#why-do-we-need-this-FlashStorage_STM32-library)
* [Features](#features)
* [Currently supported Boards](#currently-supported-boards)
* [Changelog](#changelog)
* [Major Releases v1.1.0](#major-releases-v110)
* [Releases v1.0.1](#releases-v101)
* [Releases v1.0.0](#releases-v100)
* [Changelog](changelog.md)
* [Prerequisites](#prerequisites)
* [Installation](#installation)
* [Use Arduino Library Manager](#use-arduino-library-manager)
Expand All @@ -26,6 +24,7 @@
* [Packages' Patches](#packages-patches)
* [1. For STM32 boards to use LAN8720](#1-for-stm32-boards-to-use-lan8720)
* [2. For STM32 boards to use Serial1](#2-for-stm32-boards-to-use-serial1)
* [HOWTO Fix `Multiple Definitions` Linker Error](#howto-fix-multiple-definitions-linker-error)
* [Limited number of writes](#limited-number-of-writes)
* [Usage](#usage)
* [Using the alternative EEPROM-like API](#using-the-alternative-eeprom-like-api)
Expand All @@ -41,6 +40,7 @@
* [ 9. **EmulateEEPROM**](examples/EmulateEEPROM)
* [ 10. **FlashStoreAndRetrieve**](examples/FlashStoreAndRetrieve)
* [ 11. **StoreNameAndSurname**](examples/StoreNameAndSurname)
* [ 12. **multiFileProject**](examples/multiFileProject) **New**
* [Examples from other libraries](#examples-from-other-libraries)
* [ 1. Library WiFiManager_Generic_Lite](#1-library-wifimanager_generic_lite)
* [ 2. Library WiFiManager_NINA_Lite](#2-library-wifimanager_nina_lite)
Expand All @@ -66,7 +66,6 @@
* [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)
* [Do you recommend to use FLASH instead of EEPROM?](#do-you-recommend-to-use-flash-instead-of-eeprom)
* [Troubleshooting](#troubleshooting)
* [Releases](#releases)
* [Issues](#issues)
* [TO DO](#to-do)
* [DONE](#done)
Expand All @@ -78,6 +77,13 @@
---
---

### Important Change from v1.2.0

Please have a look at [HOWTO Fix `Multiple Definitions` Linker Error](#howto-fix-multiple-definitions-linker-error)

---
---

### Why do we need this [FlashStorage_STM32 library](https://github.com/khoih-prog/FlashStorage_STM32)

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

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**.

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)
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)

---

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

---
---

## Changelog

### Major Releases v1.1.0

1. Add support to new [**STM32 core v2.0.0**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/2.0.0)
2. Add support to new STM32 L5 and many new STM32F/L/H/G/WB/MP1 boards

### Releases v1.0.1

1. Fix compiler warnings.

### Releases v1.0.0

1. Initial release to support STM32F/L/H/G/WB/MP1 board with / without integrated EEPROM


---
---

## Prerequisites

1. [`Arduino IDE 1.8.15+` for Arduino](https://www.arduino.cc/en/Main/Software)
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)
1. [`Arduino IDE 1.8.19+` for Arduino](https://www.arduino.cc/en/Main/Software)
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)

---

Expand Down Expand Up @@ -169,7 +156,7 @@ Another way to install is to:

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

Already updated and tested with latest **STM32 core v2.0.0**
Already updated and tested with latest **STM32 core v2.2.0**

To use LAN8720 on some STM32 boards

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

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.

Supposing the STM32 stm32 core version is 2.0.0. These files must be copied into the directory:
Supposing the STM32 stm32 core version is 2.2.0. These files must be copied into the directory:

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

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

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

**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.
**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.

Supposing the STM32 stm32 core version is 1.9.0. These files must be copied into the directory:
Supposing the STM32 stm32 core version is 2.2.0. These files must be copied into the directory:

- `~/.arduino15/packages/STM32/hardware/stm32/1.9.0/variants/NUCLEO_F767ZI/variant.h` for Nucleo-144 NUCLEO_F767ZI.
- `~/.arduino15/packages/STM32/hardware/stm32/1.9.0/variants/NUCLEO_L053R8/variant.h` for Nucleo-64 NUCLEO_L053R8.
- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/variants/NUCLEO_F767ZI/variant.h` for Nucleo-144 NUCLEO_F767ZI.
- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/variants/NUCLEO_L053R8/variant.h` for Nucleo-64 NUCLEO_L053R8.

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

### HOWTO Fix `Multiple Definitions` Linker Error

The current library implementation, using `xyz-Impl.h` instead of standard `xyz.cpp`, possibly creates certain `Multiple Definitions` Linker error in certain use cases.

You can include this `.hpp` file

```
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
#include "FlashStorage_STM32.hpp" //https://github.com/khoih-prog/FlashStorage_STM32
```

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

```
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include "FlashStorage_STM32.h" //https://github.com/khoih-prog/FlashStorage_STM32
```

Check the new [**multiFileProject** example](examples/multiFileProject) for a `HOWTO` demo.

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)

---
---

## Limited number of writes

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.
Expand Down Expand Up @@ -250,6 +262,8 @@ The API is very similar to the well known Arduino EEPROM.h API but with 4 additi
9. [EmulateEEPROM](examples/EmulateEEPROM)
10. [FlashStoreAndRetrieve](examples/FlashStoreAndRetrieve)
11. [StoreNameAndSurname](examples/StoreNameAndSurname)
12. [**multiFileProject**](examples/multiFileProject) **New**


---

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

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

const int WRITTEN_SIGNATURE = 0xBEEFDEED;
Expand Down Expand Up @@ -396,8 +411,8 @@ The following is the sample terminal output when running example [Ethernet_STM32
```
Start Ethernet_STM32_LAN8720 on BLACK_F407VE
Ethernet Shield type : LAN8720 Ethernet & STM32Ethernet Library
Ethernet_Manager_STM32 v1.3.0
DoubleResetDetector_Generic v1.0.3
Ethernet_Manager_STM32 v1.3.1
DoubleResetDetector_Generic v1.7.3
EEPROM size = 16384, start = 0
Flag read = 0xd0d04321
Expand Down Expand Up @@ -445,8 +460,8 @@ HHHHH[ETM] h:Updating EEPROM. Please wait for reset
```
Start Ethernet_STM32_LAN8720 on BLACK_F407VE
Ethernet Shield type : LAN8720 Ethernet & STM32Ethernet Library
Ethernet_Manager_STM32 v1.3.0
DoubleResetDetector_Generic v1.0.3
Ethernet_Manager_STM32 v1.3.1
DoubleResetDetector_Generic v1.7.3
EEPROM size = 16384, start = 0
Flag read = 0xd0d04321
Expand Down Expand Up @@ -519,7 +534,7 @@ The following is the sample terminal output when running example [StoreNameAndSu

```
Start StoreNameAndSurname on NUCLEO_H743ZI2
FlashStorage_STM32 v1.1.0
FlashStorage_STM32 v1.2.0
EEPROM length: 16384
EEPROM is empty, writing WRITTEN_SIGNATURE and some example data:
Insert your name : My_Name
Expand All @@ -535,7 +550,7 @@ Insert your surname : My_Surname

```
Start StoreNameAndSurname on NUCLEO_H743ZI2
FlashStorage_STM32 v1.1.0
FlashStorage_STM32 v1.2.0
EEPROM length: 16384
Hi My_Name
My_Surname
Expand All @@ -554,7 +569,7 @@ The following is the sample terminal output when running example [StoreNameAndSu

```
Start StoreNameAndSurname on NUCLEO_L552ZE_Q
FlashStorage_STM32 v1.1.0
FlashStorage_STM32 v1.2.0
EEPROM length: 2048
EEPROM is empty, writing WRITTEN_SIGNATURE and some example data:
Insert your name : My_Name
Expand All @@ -570,7 +585,7 @@ Insert your surname : My_Surname

```
Start StoreNameAndSurname on NUCLEO_L552ZE_Q
FlashStorage_STM32 v1.1.0
FlashStorage_STM32 v1.2.0
EEPROM length: 2048
Hi My_Name
My_Surname
Expand All @@ -589,7 +604,7 @@ The following is the sample terminal output when running example [StoreNameAndSu

```
Start StoreNameAndSurname on NUCLEO_F767ZI
FlashStorage_STM32 v1.1.0
FlashStorage_STM32 v1.2.0
EEPROM length: 16384
EEPROM is empty, writing WRITTEN_SIGNATURE and some example data:
Insert your name : My_Name
Expand All @@ -605,7 +620,7 @@ Insert your surname : My_Surname

```
Start StoreNameAndSurname on NUCLEO_F767ZI
FlashStorage_STM32 v1.1.0
FlashStorage_STM32 v1.2.0
EEPROM length: 16384
Hi My_Name
My_Surname
Expand Down Expand Up @@ -646,42 +661,6 @@ Sometimes, the library will only work if you update the board core to the latest
---
---

## Releases

### Major Releases v1.1.0

1. Add support to new [**STM32 core v2.0.0**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/2.0.0)
2. Add support to new **STM32L5** and many new STM32F/L/H/G/WB/MP1 boards

### Releases v1.0.1

1. Fix compiler warnings.

### Releases v1.0.0

1. Initial release to support STM32F/L/H/G/WB/MP1 board with / without integrated EEPROM

### Currently supported Boards

1. **STM32F/L/H/G/WB/MP1 boards with / without integrated EEPROM**

- Nucleo-144
- Nucleo-64
- Nucleo-32
- Discovery
- Generic STM32F0, STM32F1, STM32F2, STM32F3, STM32F4, STM32F7
- STM32L0, STM32L1, STM32L4, **STM32L5**
- STM32G0, STM32G4
- STM32H7
- STM32WB
- STM32MP1
- LoRa boards
- 3-D printer boards
- Generic Flight Controllers
- Midatronics boards

---
---

### Issues

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


---
---
Expand Down
44 changes: 44 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# FlashStorage_STM32 Library

[![arduino-library-badge](https://www.ardu-badge.com/badge/FlashStorage_STM32.svg?)](https://www.ardu-badge.com/FlashStorage_STM32)
[![GitHub release](https://img.shields.io/github/release/khoih-prog/FlashStorage_STM32.svg)](https://github.com/khoih-prog/FlashStorage_STM32/releases)
[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/khoih-prog/FlashStorage_STM32/blob/main/LICENSE)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing)
[![GitHub issues](https://img.shields.io/github/issues/khoih-prog/FlashStorage_STM32.svg)](http://github.com/khoih-prog/FlashStorage_STM32/issues)

---
---

## Table of Contents

* [Changelog](#changelog)
* [Major Releases v1.2.0](#major-releases-v120)
* [Major Releases v1.1.0](#major-releases-v110)
* [Releases v1.0.1](#releases-v101)
* [Releases v1.0.0](#releases-v100)

---
---

## Changelog

### Major Releases v1.2.0

1. Fix `multiple-definitions` linker error.
2. Add example [multiFileProject](examples/multiFileProject) to demo for multiple-file project.


### Major Releases v1.1.0

1. Add support to new [**STM32 core v2.0.0**](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/2.0.0)
2. Add support to new STM32 L5 and many new STM32F/L/H/G/WB/MP1 boards

### Releases v1.0.1

1. Fix compiler warnings.

### Releases v1.0.0

1. Initial release to support STM32F/L/H/G/WB/MP1 board with / without integrated EEPROM


Loading

0 comments on commit e97df56

Please sign in to comment.