From e5caa99b9c060daa6791106fbb8e8729ddbdd72f Mon Sep 17 00:00:00 2001 From: deadprogram Date: Sat, 22 Feb 2025 11:17:34 +0100 Subject: [PATCH] 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 --- builder/nrfutil.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/builder/nrfutil.go b/builder/nrfutil.go index 6f33eb7c65..d7019f120e 100644 --- a/builder/nrfutil.go +++ b/builder/nrfutil.go @@ -19,7 +19,7 @@ type jsonManifest struct { DataFile string `json:"dat_file"` InitPacketData nrfInitPacket `json:"init_packet_data"` } `json:"application"` - DFUVersion float64 `json:"dfu_version"` // yes, this is a JSON number, not a string + DFUVersion float64 `json:"dfu_version,omitempty"` // yes, this is a JSON number, not a string } `json:"manifest"` } @@ -93,7 +93,19 @@ func makeDFUFirmwareImage(options *compileopts.Options, infile, outfile string) manifest.Manifest.Application.BinaryFile = "application.bin" manifest.Manifest.Application.DataFile = "application.dat" manifest.Manifest.Application.InitPacketData = initPacket - manifest.Manifest.DFUVersion = 0.5 + + // use build tag "nrf_open_dfu" to indicate open DFU format, otherwise defaults to secure DFU + openDFU := false + for _, tag := range options.Tags { + if tag == "nrf_open_dfu" { + openDFU = true + break + } + } + + if !openDFU { + manifest.Manifest.DFUVersion = 0.5 + } // Write the JSON manifest to the file. jsonw, err := w.Create("manifest.json")