From 39bca29025a313e3e2d1039f13fb1fdc514e3c0d Mon Sep 17 00:00:00 2001 From: zombieleet Date: Thu, 1 Oct 2026 22:43:45 +0200 Subject: [PATCH 1/2] tools/gen-device-svd: include the last register in cluster size For a cluster with dim 1 or no dim, the size was computed from the address of the last register instead of its end. The padding after the cluster was too large, so every field after it was shifted. This fixes the SPU struct in nrf9160 and nrf5340_application, and DCNF in nrf5340_application. No other generated file changes. --- tools/gen-device-svd/gen-device-svd.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/gen-device-svd/gen-device-svd.go b/tools/gen-device-svd/gen-device-svd.go index 6c5e78ed81..884fd29a52 100755 --- a/tools/gen-device-svd/gen-device-svd.go +++ b/tools/gen-device-svd/gen-device-svd.go @@ -323,7 +323,7 @@ func processCluster(p *Peripheral, clusters []*SVDCluster, peripheralDict map[st }) if dimIncrement == -1 && len(clusterRegisters) > 0 { lastReg := clusterRegisters[len(clusterRegisters)-1] - lastAddress := lastReg.Address + lastAddress := lastReg.Address + uint64(lastReg.ElementSize) if lastReg.Array != -1 { lastAddress = lastReg.Address + uint64(lastReg.Array*lastReg.ElementSize) } From 9ee9fb78239af51f07e2172830b27cffe38d5720 Mon Sep 17 00:00:00 2001 From: zombieleet Date: Tue, 13 Oct 2026 19:28:09 +0200 Subject: [PATCH 2/2] tools/gen-device-svd: test cluster size for a dim 1 cluster --- tools/gen-device-svd/gen-device-svd_test.go | 27 +++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tools/gen-device-svd/gen-device-svd_test.go diff --git a/tools/gen-device-svd/gen-device-svd_test.go b/tools/gen-device-svd/gen-device-svd_test.go new file mode 100644 index 0000000000..3edfe45cc9 --- /dev/null +++ b/tools/gen-device-svd/gen-device-svd_test.go @@ -0,0 +1,27 @@ +package main + +import "testing" + +func TestProcessClusterSizeDim1(t *testing.T) { + dim := 1 + off0, off4 := "0x0", "0x4" + p := &Peripheral{Name: "TIMG", BaseAddress: 0x1000} + processCluster(p, []*SVDCluster{ + { + Name: "T%s", + Dim: &dim, + AddressOffset: "0x0", + Registers: []*SVDRegister{ + {Name: "CONFIG", AddressOffset: &off0}, + {Name: "LO", AddressOffset: &off4}, + }, + }, + }, map[string]*Peripheral{}) + + if len(p.Registers) != 1 { + t.Fatalf("got %d registers, want 1", len(p.Registers)) + } + if got := p.Registers[0].ElementSize; got != 8 { + t.Errorf("cluster ElementSize = %d, want 8", got) + } +}