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

Commit 227b8d5

Browse files
authored
v1.3.0 to fix multiple-definitions linker error
### Releases v1.3.0 1. Fix `multiple-definitions` linker error. 2. Add support to many more boards, such as `SAMD21E1xA`, `SAMD21G1xA` and`SAMD21J1xA` 3. Add example [multiFileProject](examples/multiFileProject) to demo for multiple-file project. 4. Fix bug 5. Update `Packages' Patches`
1 parent 4eac01e commit 227b8d5

26 files changed

+830
-267
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.16) or Platform.io version
18-
* `SAMD` Core Version (e.g. Arduino SAMD core v1.8.11, Adafruit SAMD core v1.7.5, Seeed Studio SAMD v1.8.2)
17+
* Arduino IDE version (e.g. 1.8.19) or Platform.io version
18+
* `SAMD` Core Version (e.g. Arduino SAMD core v1.8.12, Adafruit SAMD core v1.7.7, Seeed Studio SAMD v1.8.2)
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.16
30-
Arduino SAMD Core Version 1.8.11
29+
Arduino IDE version: 1.8.19
30+
Arduino SAMD Core Version 1.8.12
3131
OS: Ubuntu 20.04 LTS
32-
Linux Inspiron-3593 5.4.0-86-generic #97-Ubuntu SMP Fri Sep 17 19:19:40 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
I encountered a crash while trying to use the Timer Interrupt.

README.md

Lines changed: 57 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
## Table of Contents
1313

14+
* [Important Change from v1.3.0](#Important-Change-from-v130)
1415
* [Why do we need this FlashStorage_SAMD library](#why-do-we-need-this-flashstorage_samd-library)
1516
* [Features](#features)
1617
* [Currently supported Boards](#currently-supported-boards)
@@ -26,6 +27,7 @@
2627
* [For core version v1.8.9-](#for-core-version-v189-)
2728
* [2. For Adafruit SAMD boards](#2-for-adafruit-samd-boards)
2829
* [3. For Seeeduino SAMD boards](#3-for-seeeduino-samd-boards)
30+
* [HOWTO Fix `Multiple Definitions` Linker Error](#howto-fix-multiple-definitions-linker-error)
2931
* [Limited number of writes](#limited-number-of-writes)
3032
* [Usage](#usage)
3133
* [Using FlashStorage objects directly](#using-flashstorage-objects-directly)
@@ -42,6 +44,7 @@
4244
* [ 9. **EmulateEEPROM**](examples/EmulateEEPROM)
4345
* [ 10. **FlashStoreAndRetrieve**](examples/FlashStoreAndRetrieve)
4446
* [ 11. **StoreNameAndSurname**](examples/StoreNameAndSurname)
47+
* [ 12. **multiFileProject**](examples/multiFileProject) **New**
4548
* [Examples from other libraries](#examples-from-other-libraries)
4649
* [ 1. Library BlynkEthernet_WM](#1-library-blynkethernet_wm)
4750
* [ 2. Library Blynk_Esp8266AT_WM](#2-library-blynk_esp8266at_wm)
@@ -75,6 +78,14 @@
7578
---
7679
---
7780

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

8091
### Features
@@ -101,9 +112,9 @@ The flash memory, generally used to store the firmware code, can also be used to
101112

102113
## Prerequisites
103114

104-
1. [`Arduino IDE v1.8.16+` for Arduino](https://www.arduino.cc/en/Main/Software)
105-
2. [`Arduino SAMD core 1.8.11+`](https://github.com/arduino/ArduinoCore-samd) for SAMD ARM Cortex-M0+ boards. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-samd.svg)](https://github.com/arduino/ArduinoCore-samd/releases/latest)
106-
3. [`Adafruit SAMD core 1.7.5+`](https://github.com/adafruit/ArduinoCore-samd) for SAMD ARM Cortex-M0+ and M4 boards (Nano 33 IoT, etc.). [![GitHub release](https://img.shields.io/github/release/adafruit/ArduinoCore-samd.svg)](https://github.com/adafruit/ArduinoCore-samd/releases/latest)
115+
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)
116+
2. [`Arduino SAMD core 1.8.12+`](https://github.com/arduino/ArduinoCore-samd) for SAMD ARM Cortex-M0+ boards. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-samd.svg)](https://github.com/arduino/ArduinoCore-samd/releases/latest)
117+
3. [`Adafruit SAMD core 1.7.7+`](https://github.com/adafruit/ArduinoCore-samd) for SAMD ARM Cortex-M0+ and M4 boards (Nano 33 IoT, etc.). [![GitHub release](https://img.shields.io/github/release/adafruit/ArduinoCore-samd.svg)](https://github.com/adafruit/ArduinoCore-samd/releases/latest)
107118
4. [`Seeeduino SAMD core 1.8.2+`](https://github.com/Seeed-Studio/ArduinoCore-samd) for SAMD21/SAMD51 boards (XIAO M0, Wio Terminal, etc.). [![Latest release](https://img.shields.io/github/release/Seeed-Studio/ArduinoCore-samd.svg)](https://github.com/Seeed-Studio/ArduinoCore-samd/releases/latest/)
108119
5. [`IndustruinoSAMD core 1.0.3+`](https://github.com/Industruino/IndustruinoSAMD) for SAMD21 boards (Industruino DG21, etc.).
109120
6. [`IndustruinoSAML core 1.0.0+`](https://github.com/Industruino/IndustruinoSAMx) for SAML21 boards (Industruino 420MAKER, etc.).
@@ -141,13 +152,13 @@ Another way to install is to:
141152

142153
#### 1. For Arduino SAMD boards
143154

144-
***To be able to compile, run and automatically detect and display BOARD_NAME on Arduino SAMD (Nano-33-IoT, etc) boards***, you have to copy the whole [Arduino SAMD Packages_Patches](Packages_Patches/arduino/hardware/samd/1.8.11) directory into Arduino SAMD directory (~/.arduino15/packages/arduino/hardware/samd/1.8.11).
155+
***To be able to compile, run and automatically detect and display BOARD_NAME on Arduino SAMD (Nano-33-IoT, etc) boards***, you have to copy the whole [Arduino SAMD Packages_Patches](Packages_Patches/arduino/hardware/samd/1.8.12) directory into Arduino SAMD directory (~/.arduino15/packages/arduino/hardware/samd/1.8.12).
145156

146157
#### For core version v1.8.10+
147158

148-
Supposing the Arduino SAMD version is 1.8.11. Now only one file must be copied into the directory:
159+
Supposing the Arduino SAMD version is 1.8.12. Now only one file must be copied into the directory:
149160

150-
- `~/.arduino15/packages/arduino/hardware/samd/1.8.11/platform.txt`
161+
- `~/.arduino15/packages/arduino/hardware/samd/1.8.12/platform.txt`
151162

152163
Whenever a new version is installed, remember to copy this files into the new version directory. For example, new version is x.yy.zz
153164

@@ -180,13 +191,13 @@ Whenever the above-mentioned compiler error issue is fixed with the new Arduino
180191

181192
#### 2. For Adafruit SAMD boards
182193

183-
***To be able to compile, run and automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards***, you have to copy the whole [Adafruit SAMD Packages_Patches](Packages_Patches/adafruit/hardware/samd/1.7.5) directory into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.7.5).
194+
***To be able to compile, run and automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards***, you have to copy the whole [Adafruit SAMD Packages_Patches](Packages_Patches/adafruit/hardware/samd/1.7.7) directory into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.7.7).
184195

185-
Supposing the Adafruit SAMD core version is 1.7.5. This file must be copied into the directory:
196+
Supposing the Adafruit SAMD core version is 1.7.7. This file must be copied into the directory:
186197

187-
- `~/.arduino15/packages/adafruit/hardware/samd/1.7.5/platform.txt`
188-
- `~/.arduino15/packages/adafruit/hardware/samd/1.7.5/cores/arduino/Print.h`
189-
- `~/.arduino15/packages/adafruit/hardware/samd/1.7.5/cores/arduino/Print.cpp`
198+
- `~/.arduino15/packages/adafruit/hardware/samd/1.7.7/platform.txt`
199+
- `~/.arduino15/packages/adafruit/hardware/samd/1.7.7/cores/arduino/Print.h`
200+
- `~/.arduino15/packages/adafruit/hardware/samd/1.7.7/cores/arduino/Print.cpp`
190201

191202
Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz
192203
This file must be copied into the directory:
@@ -214,6 +225,30 @@ This file must be copied into the directory:
214225
- `~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/cores/arduino/Print.h`
215226
- `~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/cores/arduino/Print.cpp`
216227

228+
---
229+
---
230+
231+
### HOWTO Fix `Multiple Definitions` Linker Error
232+
233+
The current library implementation, using `xyz-Impl.h` instead of standard `xyz.cpp`, possibly creates certain `Multiple Definitions` Linker error in certain use cases.
234+
235+
You can include this `.hpp` file
236+
237+
```
238+
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
239+
#include "FlashStorage_SAMD.hpp" //https://github.com/khoih-prog/FlashStorage_SAMD
240+
```
241+
242+
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
243+
244+
```
245+
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
246+
#include "FlashStorage_SAMD.h" //https://github.com/khoih-prog/FlashStorage_SAMD
247+
```
248+
249+
Check the new [**multiFileProject** example](examples/multiFileProject) for a `HOWTO` demo.
250+
251+
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)
217252

218253
---
219254
---
@@ -290,6 +325,7 @@ The API is very similar to the well-known [Arduino EEPROM library API](https://w
290325
9. [EmulateEEPROM](examples/EmulateEEPROM)
291326
10. [FlashStoreAndRetrieve](examples/FlashStoreAndRetrieve)
292327
11. [StoreNameAndSurname](examples/StoreNameAndSurname)
328+
12. [**multiFileProject**](examples/multiFileProject) **New**
293329

294330
### Examples from other libraries
295331

@@ -355,6 +391,7 @@ The API is very similar to the well-known [Arduino EEPROM library API](https://w
355391
// Use 0-2. Larger for more debugging messages
356392
#define FLASH_DEBUG 0
357393

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

360397
const int WRITTEN_SIGNATURE = 0xBEEFDEED;
@@ -537,7 +574,7 @@ BBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB BBBBBBBBBB
537574

538575
```
539576
Start StoreNameAndSurname on SEEED_XIAO_M0
540-
FlashStorage_SAMD v1.2.1
577+
FlashStorage_SAMD v1.3.0
541578
EEPROM length: 1024
542579
EEPROM is empty, writing WRITTEN_SIGNATURE and some example data:
543580
Insert your name : John
@@ -552,7 +589,7 @@ You can reset to check emulated-EEPROM data retention.
552589

553590
```
554591
Start StoreNameAndSurname on SEEED_XIAO_M0
555-
FlashStorage_SAMD v1.2.1
592+
FlashStorage_SAMD v1.3.0
556593
EEPROM length: 1024
557594
Hi John Doe, nice to see you again :-)
558595
Clearing WRITTEN_SIGNATURE for next try
@@ -567,7 +604,7 @@ Done clearing signature in emulated EEPROM. You can reset now
567604

568605
```
569606
Start EEPROM_Clear on SEEED_XIAO_M0
570-
FlashStorage_SAMD v1.2.1
607+
FlashStorage_SAMD v1.3.0
571608
572609
Emulated EEPROM length (bytes) = 1024
573610
@@ -579,7 +616,7 @@ Done clearing emulated EEPROM. Time spent (ms) = 11
579616

580617
```
581618
Start EEPROM_Clear on SEEED_XIAO_M0
582-
FlashStorage_SAMD v1.2.1
619+
FlashStorage_SAMD v1.3.0
583620
Emulated EEPROM length (bytes) = 2048
584621
Done clearing emulated EEPROM. Time spent (ms) = 22
585622
```
@@ -588,7 +625,7 @@ Done clearing emulated EEPROM. Time spent (ms) = 22
588625

589626
```
590627
Start EEPROM_Clear on SEEED_XIAO_M0
591-
FlashStorage_SAMD v1.2.1
628+
FlashStorage_SAMD v1.3.0
592629
Emulated EEPROM length (bytes) = 4096
593630
Done clearing emulated EEPROM. Time spent (ms) = 42
594631
```
@@ -601,7 +638,7 @@ Done clearing emulated EEPROM. Time spent (ms) = 42
601638

602639
```
603640
Start EEPROM_get on SEEED_XIAO_M0
604-
FlashStorage_SAMD v1.2.1
641+
FlashStorage_SAMD v1.3.0
605642
EEPROM length: 1024
606643
EEPROM doesn't store valid data, writing WRITTEN_SIGNATURE and some example data
607644
Float written to EEPROM: 123.456
@@ -618,7 +655,7 @@ Reset to see how you can retrieve the values by using EEPROM_get!
618655

619656
```
620657
Start EEPROM_get on SEEED_XIAO_M0
621-
FlashStorage_SAMD v1.2.1
658+
FlashStorage_SAMD v1.3.0
622659
EEPROM length: 1024
623660
EEPROM has valid data with WRITTEN_SIGNATURE. Now read some example data
624661
Read float from EEPROM: 123.456
@@ -683,6 +720,8 @@ Submit issues to: [FlashStorage_SAMD issues](https://github.com/khoih-prog/Flash
683720
4. Add Table of Contents
684721
5. Add support to Industruino SAMD21 DG21 and Industruino SAML21 420MAKER boards
685722
6. Add support to **Sparkfun SAMD21 and SAMD51 boards**
723+
7. Fix `multiple-definitions` linker error.
724+
8. Add support to many more boards, such as `SAMD21E1xA`, `SAMD21G1xA` and`SAMD21J1xA`
686725

687726
---
688727
---

changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
## Table of Contents
1313

1414
* [Changelog](#changelog)
15+
* [Releases v1.3.0](#releases-v130)
1516
* [Releases v1.2.1](#releases-v121)
1617
* [Releases v1.2.0](#releases-v120)
1718
* [Releases v1.1.0](#releases-v110)
@@ -23,6 +24,14 @@
2324

2425
## Changelog
2526

27+
### Releases v1.3.0
28+
29+
1. Fix `multiple-definitions` linker error.
30+
2. Add support to many more boards, such as `SAMD21E1xA`, `SAMD21G1xA` and`SAMD21J1xA`
31+
3. Add example [multiFileProject](examples/multiFileProject) to demo for multiple-file project.
32+
4. Fix bug
33+
5. Update `Packages' Patches`
34+
2635
### Releases v1.2.1
2736

2837
1. Update `platform.ini` and `library.json` to use original `khoih-prog` instead of `khoih.prog` after PIO fix

examples/EEPROM_CRC/EEPROM_CRC.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
// Use 0-2. Larger for more debugging messages
3737
#define FLASH_DEBUG 0
3838

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

4142
unsigned long eeprom_crc()

examples/EEPROM_Clear/EEPROM_Clear.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
// Use 0-2. Larger for more debugging messages
2929
#define FLASH_DEBUG 0
3030

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

3334
void setup()

examples/EEPROM_get/EEPROM_get.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
// Use 0-2. Larger for more debugging messages
4343
#define FLASH_DEBUG 0
4444

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

4748
const int WRITTEN_SIGNATURE = 0xBEEFDEED;

examples/EEPROM_iteration/EEPROM_iteration.ino

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
// Use 0-2. Larger for more debugging messages
3939
#define FLASH_DEBUG 0
4040

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

4344
void setup()
@@ -59,7 +60,7 @@ void setup()
5960

6061
for (int index = 0 ; index < EEPROM.length() ; index++)
6162
{
62-
// Add one to each cell in the EEPROM
63+
// Add one to each cell in the EEPROM
6364
EEPROM.write(index, EEPROM.read(index) + 1);
6465
}
6566

@@ -75,7 +76,7 @@ void setup()
7576

7677
while (index < EEPROM.length())
7778
{
78-
// Add one to each cell in the EEPROM
79+
// Add one to each cell in the EEPROM
7980
EEPROM.write(index, EEPROM.read(index) + 1);
8081
index++;
8182
}
@@ -88,14 +89,14 @@ void setup()
8889
Iterate the EEPROM using a do-while loop.
8990
***/
9091

91-
int idx = 0; //Used 'idx' to avoid name conflict with 'index' above.
92+
index = 0; //Used 'idx' to avoid name conflict with 'index' above.
9293

93-
do
94+
do
9495
{
9596
// Add one to each cell in the EEPROM
9697
EEPROM.write(index, EEPROM.read(index) + 1);
97-
idx++;
98-
} while (idx < EEPROM.length());
98+
index++;
99+
} while (index < EEPROM.length());
99100

100101
EEPROM.commit();
101102

examples/EEPROM_put/EEPROM_put.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
// Use 0-2. Larger for more debugging messages
4141
#define FLASH_DEBUG 0
4242

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

4546
const int WRITTEN_SIGNATURE = 0xBEEFDEED;

examples/EEPROM_read/EEPROM_read.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
// Use 0-2. Larger for more debugging messages
3535
#define FLASH_DEBUG 0
3636

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

3940
// start reading from the first byte (address 0) of the EEPROM

examples/EEPROM_update/EEPROM_update.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
// Use 0-2. Larger for more debugging messages
4141
#define FLASH_DEBUG 0
4242

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

4546
/** the current address in the EEPROM (i.e. which byte we're going to write to next) **/

0 commit comments

Comments
 (0)