Skip to content

Commit 2db6146

Browse files
committed
feature: ability to generate nrf firmware manifest for Open DFU format using nrf_open_dfu build tag. Intended to fix #4089
Signed-off-by: deadprogram <[email protected]>
1 parent 17bb1fe commit 2db6146

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

builder/nrfutil.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/binary"
77
"encoding/json"
88
"os"
9+
"slices"
910

1011
"github.com/sigurn/crc16"
1112
"github.com/tinygo-org/tinygo/compileopts"
@@ -19,7 +20,7 @@ type jsonManifest struct {
1920
DataFile string `json:"dat_file"`
2021
InitPacketData nrfInitPacket `json:"init_packet_data"`
2122
} `json:"application"`
22-
DFUVersion float64 `json:"dfu_version"` // yes, this is a JSON number, not a string
23+
DFUVersion float64 `json:"dfu_version,omitempty"` // yes, this is a JSON number, not a string
2324
} `json:"manifest"`
2425
}
2526

@@ -93,7 +94,11 @@ func makeDFUFirmwareImage(options *compileopts.Options, infile, outfile string)
9394
manifest.Manifest.Application.BinaryFile = "application.bin"
9495
manifest.Manifest.Application.DataFile = "application.dat"
9596
manifest.Manifest.Application.InitPacketData = initPacket
96-
manifest.Manifest.DFUVersion = 0.5
97+
98+
// use build tag "nrf_open_dfu" to indicate open DFU format, otherwise defaults to secure DFU
99+
if !slices.Contains(options.Tags, "nrf_open_dfu") {
100+
manifest.Manifest.DFUVersion = 0.5
101+
}
97102

98103
// Write the JSON manifest to the file.
99104
jsonw, err := w.Create("manifest.json")

0 commit comments

Comments
 (0)