Skip to content

Commit 656dfd0

Browse files
committed
support for nano33iot without breaking legacy
1 parent 96ce5f9 commit 656dfd0

File tree

5 files changed

+1487
-23
lines changed

5 files changed

+1487
-23
lines changed

libraries/SDU/extras/SDUBoot/Board.h

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
Copyright (c) 2021 Arduino LLC. All right reserved.
3+
4+
This library is free software; you can redistribute it and/or
5+
modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either
7+
version 2.1 of the License, or (at your option) any later version.
8+
9+
This library is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12+
See the GNU Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with this library; if not, write to the Free Software
16+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17+
*/
18+
19+
#ifndef _BOARD_H_INCLUDED
20+
#define _BOARD_H_INCLUDED
21+
22+
23+
/*SDU_SIZE is not specifically for nano 33 iot but it's core version dependent.
24+
From 1.8.11 the core footprint is too big to fit 0x4000.
25+
If you need to recompile SDUBoot.ino for */
26+
27+
28+
#ifdef ARDUINO_SAM_ZERO
29+
#define SDU_START 0x4000
30+
#else
31+
#define SDU_START 0x2000
32+
#endif
33+
#if defined(ARDUINO_SAMD_NANO_33_IOT)
34+
#define SDU_SIZE 0x6000
35+
#else
36+
#define SDU_SIZE 0x4000
37+
#endif
38+
39+
#define SKETCH_START (uint32_t*)(SDU_START + SDU_SIZE)
40+
41+
#define UPDATE_FILE "UPDATE.BIN"
42+
43+
#if defined(USE_ARDUINO_MKR_PIN_LAYOUT)
44+
#ifndef SDCARD_SS_PIN
45+
#define SDCARD_SS_PIN 4
46+
#endif
47+
#else
48+
#define SDCARD_SS_PIN 10
49+
#endif
50+
51+
#endif

libraries/SDU/extras/SDUBoot/SDUBoot.ino

+1-18
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,10 @@
1515
License along with this library; if not, write to the Free Software
1616
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1717
*/
18-
18+
#include "Board.h"
1919
#include <SD.h>
2020
#include <FlashStorage.h>
2121

22-
#ifdef ARDUINO_SAM_ZERO
23-
#define SDU_START 0x4000
24-
#else
25-
#define SDU_START 0x2000
26-
#endif
27-
#define SDU_SIZE 0x4000
28-
29-
#define SKETCH_START (uint32_t*)(SDU_START + SDU_SIZE)
30-
31-
#ifndef SDCARD_SS_PIN
32-
#define SDCARD_SS_PIN 4
33-
#endif
34-
35-
#define UPDATE_FILE "UPDATE.BIN"
36-
3722
FlashClass flash;
3823

3924
// Initialize C library
@@ -93,5 +78,3 @@ int main() {
9378
// jump to reset handler
9479
asm("bx %0"::"r"(resetHandlerAddress));
9580
}
96-
97-

libraries/SDU/src/SDU.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717
*/
1818

1919
#include <Arduino.h>
20-
2120
#include "SDU.h"
2221

2322
__attribute__ ((section(".sketch_boot")))
24-
unsigned char sduBoot[0x4000] = {
23+
unsigned char sduBoot[SDU_SIZE] = {
2524
#if defined(ARDUINO_SAMD_ZERO)
2625
#include "boot/zero.h"
2726
#elif defined(ARDUINO_SAMD_MKR1000)
@@ -40,6 +39,8 @@ unsigned char sduBoot[0x4000] = {
4039
#include "boot/mkrnb1500.h"
4140
#elif defined(ARDUINO_SAM_ZERO)
4241
#include "boot/mzero.h"
42+
#elif defined(ARDUINO_SAMD_NANO_33_IOT)
43+
#include "boot/nano33iot.h"
4344
#else
4445
#error "Unsupported board!"
4546
#endif

libraries/SDU/src/SDU.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,5 @@
1818

1919
#ifndef _SDU_H_INCLUDED
2020
#define _SDU_H_INCLUDED
21-
22-
// nothing for now
23-
21+
#include "../extras/Board.h"
2422
#endif

0 commit comments

Comments
 (0)