Skip to content

Commit f51ab82

Browse files
authored
Merge pull request #103 from arduino/new-partition-table
New partition table: move NVS at the end of flash
2 parents 4aa4719 + 27657d7 commit f51ab82

File tree

4 files changed

+57
-19
lines changed

4 files changed

+57
-19
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@ include $(IDF_PATH)/make/project.mk
2727
firmware: all
2828
python combine.py
2929

30-
.PHONY: firmware
30+
clean:
31+
rm -rf NINA_W102*
32+
33+
.PHONY: firmware, clean

combine.py

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,73 @@
77
phyData = open("data/phy.bin", "rb").read()
88
certsData = open("data/roots.pem", "rb").read()
99
appData = open("build/nina-fw.bin", "rb").read()
10+
spiffsData = open("data/spiffs.bin", "rb").read()
1011

11-
# calculate the output binary size, app offset
12+
# Offset Size Name
13+
# 0x001000 0x007000 bootloader
14+
# 0x008000 0x001000 partitions
15+
# 0x009000 0x001000 phy data
16+
# 0x00A000 0x026000 certs
17+
# 0x030000 0x180000 app
18+
# 0x1B0000 0x040000 spiffs
19+
# 0x1F0000 0x010000 nvs
20+
21+
# calculate the output binary size, app offset
1222
outputSize = 0x30000 + len(appData)
1323
if (outputSize % 1024):
14-
outputSize += 1024 - (outputSize % 1024)
24+
outputSize += 1024 - (outputSize % 1024)
1525

1626
# allocate and init to 0xff
17-
outputData = bytearray(b'\xff') * outputSize
27+
outputData = bytearray(b'\xff') * 0x200000
1828

19-
# copy data: bootloader, partitions, app
29+
# copy data: bootloader, partitions, phy, certs, app
2030
for i in range(0, len(booloaderData)):
21-
outputData[0x1000 + i] = booloaderData[i]
31+
outputData[0x1000 + i] = booloaderData[i]
2232

2333
for i in range(0, len(partitionData)):
24-
outputData[0x8000 + i] = partitionData[i]
34+
outputData[0x8000 + i] = partitionData[i]
2535

2636
for i in range(0, len(phyData)):
27-
outputData[0xf000 + i] = phyData[i]
37+
outputData[0x9000 + i] = phyData[i]
2838

2939
for i in range(0, len(certsData)):
30-
outputData[0x10000 + i] = certsData[i]
40+
outputData[0xA000 + i] = certsData[i]
3141

3242
# zero terminate the pem file
33-
outputData[0x10000 + len(certsData)] = 0
43+
outputData[0xA000 + len(certsData)] = 0
3444

3545
for i in range(0, len(appData)):
36-
outputData[0x30000 + i] = appData[i]
46+
outputData[0x30000 + i] = appData[i]
47+
48+
# add empty spiffs
49+
for i in range(0, len(spiffsData)):
50+
outputData[0x1B0000 + i] = spiffsData[i]
3751

3852

39-
outputFilename = "NINA_W102.bin"
53+
baseFilename = "NINA_W102"
4054
if (len(sys.argv) > 1):
41-
outputFilename = sys.argv[1]
55+
baseFilename = sys.argv[1]
56+
57+
outputFilename = baseFilename + ".bin"
58+
# write out
59+
with open(outputFilename,"w+b") as f:
60+
f.seek(0)
61+
f.write(outputData[:outputSize])
62+
63+
outputFilename = baseFilename + "_BOOT_APP.bin"
64+
# write out
65+
with open(outputFilename,"w+b") as f:
66+
f.seek(0)
67+
f.write(outputData[:outputSize])
68+
69+
outputFilename = baseFilename + "_APP.bin"
70+
# write out
71+
with open(outputFilename,"w+b") as f:
72+
f.seek(0)
73+
f.write(outputData[0x30000:outputSize])
4274

75+
outputFilename = baseFilename + "_ALL.bin"
4376
# write out
4477
with open(outputFilename,"w+b") as f:
45-
f.seek(0)
46-
f.write(outputData)
78+
f.seek(0)
79+
f.write(outputData)

data/spiffs.bin

Lines changed: 2 additions & 0 deletions
Large diffs are not rendered by default.

partitions.csv

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Name, Type, SubType, Offset, Size
22
# Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild
3-
nvs, data, nvs, 0x9000, 0x6000
4-
phy_init, data, phy, 0xf000, 0x1000
5-
certs, data, 0x04, 0x10000, 0x20000
3+
phy_init, data, phy, 0x9000, 0x001000
4+
certs, data, 0x06, 0xA000, 0x026000
65
factory, app, factory, 0x30000, 0x180000
7-
storage, data, spiffs, 0x1B0000,0x40000
6+
storage, data, spiffs, 0x1B0000,0x040000
7+
nvs, data, nvs, 0x1F0000,0x010000

0 commit comments

Comments
 (0)