nrf: fix flash writes when SoftDevice is enabled

The data to write is specififed in words, not in bytes.

This fix is needed for correctness. Without it, a
`machine.Flash.WriteAt` call can result in **data loss** since it will
overwrite more data than it should.
This commit is contained in:
Ayke van Laethem
2025-12-16 13:41:08 +01:00
committed by Ron Evans
parent a65ac105cc
commit 750b0e5c18
+2 -1
View File
@@ -400,7 +400,8 @@ func (f flashBlockDevice) WriteAt(p []byte, off int64) (n int, err error) {
// SoftDevices I've checked.
// Documentation:
// https://docs.nordicsemi.com/bundle/s140_v6.0.0_api/page/group_n_r_f_s_o_c_f_u_n_c_t_i_o_n_s.html
result := arm.SVCall3(0x20+9, address, &p[0], uint32(len(p)))
numberOfWords := len(padded) / 4 // flash access goes in 32-bit words
result := arm.SVCall3(0x20+9, address, &padded[0], uint32(numberOfWords))
if result != 0 {
// Could not queue flash operation? Not sure when this can
// happen.