Browse Source

machine/atsam*, nrf, rp2040, stm32: correct error flashBlockDevice pad() function

Signed-off-by: deadprogram <ron@hybridgroup.com>
pull/3715/head
deadprogram 2 years ago
committed by Ron Evans
parent
commit
e7363966a5
  1. 6
      src/machine/machine_atsamd21.go
  2. 6
      src/machine/machine_atsamd51.go
  3. 6
      src/machine/machine_nrf.go
  4. 6
      src/machine/machine_rp2040_rom.go
  5. 8
      src/machine/machine_stm32_flash.go

6
src/machine/machine_atsamd21.go

@ -1910,12 +1910,12 @@ func (f flashBlockDevice) EraseBlocks(start, len int64) error {
// pad data if needed so it is long enough for correct byte alignment on writes.
func (f flashBlockDevice) pad(p []byte) []byte {
paddingNeeded := f.WriteBlockSize() - (int64(len(p)) % f.WriteBlockSize())
if paddingNeeded == 0 {
overflow := int64(len(p)) % f.WriteBlockSize()
if overflow == 0 {
return p
}
padding := bytes.Repeat([]byte{0xff}, int(paddingNeeded))
padding := bytes.Repeat([]byte{0xff}, int(f.WriteBlockSize()-overflow))
return append(p, padding...)
}

6
src/machine/machine_atsamd51.go

@ -2239,12 +2239,12 @@ func (f flashBlockDevice) EraseBlocks(start, len int64) error {
// pad data if needed so it is long enough for correct byte alignment on writes.
func (f flashBlockDevice) pad(p []byte) []byte {
paddingNeeded := f.WriteBlockSize() - (int64(len(p)) % f.WriteBlockSize())
if paddingNeeded == 0 {
overflow := int64(len(p)) % f.WriteBlockSize()
if overflow == 0 {
return p
}
padding := bytes.Repeat([]byte{0xff}, int(paddingNeeded))
padding := bytes.Repeat([]byte{0xff}, int(f.WriteBlockSize()-overflow))
return append(p, padding...)
}

6
src/machine/machine_nrf.go

@ -396,12 +396,12 @@ func (f flashBlockDevice) EraseBlocks(start, len int64) error {
// pad data if needed so it is long enough for correct byte alignment on writes.
func (f flashBlockDevice) pad(p []byte) []byte {
paddingNeeded := f.WriteBlockSize() - (int64(len(p)) % f.WriteBlockSize())
if paddingNeeded == 0 {
overflow := int64(len(p)) % f.WriteBlockSize()
if overflow == 0 {
return p
}
padding := bytes.Repeat([]byte{0xff}, int(paddingNeeded))
padding := bytes.Repeat([]byte{0xff}, int(f.WriteBlockSize()-overflow))
return append(p, padding...)
}

6
src/machine/machine_rp2040_rom.go

@ -236,12 +236,12 @@ func (f flashBlockDevice) EraseBlocks(start, length int64) error {
// pad data if needed so it is long enough for correct byte alignment on writes.
func (f flashBlockDevice) pad(p []byte) []byte {
paddingNeeded := f.WriteBlockSize() - (int64(len(p)) % f.WriteBlockSize())
if paddingNeeded == 0 {
overflow := int64(len(p)) % f.WriteBlockSize()
if overflow == 0 {
return p
}
padding := bytes.Repeat([]byte{0xff}, int(paddingNeeded))
padding := bytes.Repeat([]byte{0xff}, int(f.WriteBlockSize()-overflow))
return append(p, padding...)
}

8
src/machine/machine_stm32_flash.go

@ -92,13 +92,13 @@ func (f flashBlockDevice) EraseBlocks(start, len int64) error {
// pad data if needed so it is long enough for correct byte alignment on writes.
func (f flashBlockDevice) pad(p []byte) []byte {
paddingNeeded := f.WriteBlockSize() - (int64(len(p)) % f.WriteBlockSize())
if paddingNeeded == 0 {
overflow := int64(len(p)) % f.WriteBlockSize()
if overflow == 0 {
return p
}
padded := bytes.Repeat([]byte{0xff}, int(paddingNeeded))
return append(p, padded...)
padding := bytes.Repeat([]byte{0xff}, int(f.WriteBlockSize()-overflow))
return append(p, padding...)
}
const memoryStart = 0x08000000

Loading…
Cancel
Save