Skip to content

Flash-write repetitively missing bytes on 0x100-boundary #23

Open
@mafiltenborg

Description

@mafiltenborg

Writing Hex-file to ATmega644PA using below chip_dict, a Feather nRF52840 and a bit of wiring to the ISP target. Works beautifully and validates - but target code does not run as expected.

.
.
.
# Processor definition
atmega644pa = {'name': "ATmega644PA"}
atmega644pa['sig'] = [0x1E, 0x96, 0x0A]
atmega644pa['flash_size'] = 65536
atmega644pa['page_size'] = 256
atmega644pa['fuse_mask'] = (0xF7, 0x8F, 0xFD, 0xFF) # Low, High, Extended, Lockbits
.
.
print("Programming flash with",filename)
if not avrprog.program_file(atmega644pa, filename, verbose=False, verify=False):
    error("Failure programming flash with" + filename )
else:
    print("Programmed OK")
time.sleep(1)

print("Verifying flash against",filename)
if not avrprog.verify_file(atmega644pa,filename,verbose=False):
    error("Failure verifying flash against " + filename )
else:
    print("Validated OK")

creates this screen output

Working with an ATmega644PA CPU. Good!
Read lockbits: ['0xf7', '0x8f', '0xfd', '0xff']
Erasing chip...
Re-read lockbits: ['0xf7', '0x8f', '0xfd', '0xff']
Programming flash with SENSORCARD644_V7.hex
Programmed OK
Verifying flash against SENSORCARD644_V7.hex
Validated OK
Lockbits now:  ['0xf7', '0x8f', '0xfd', '0xff']
Writing fuses & lockbits
Re-read lockbits: ['0xf7', '0x8f', '0xfd', '0xff']
Programming done!

Looks good. However, target doesn't function. So I read the flash content back again using AtmelStudio+AVRISPmk2 and this shows something is not right.

Every 0x100 bytes a block of 0xFFs appear in the read-back content, effectively being unprogrammed 'holes' in the binary.

What triggers my suspicion is that these holes all start on ..00, and their size goes from tiny to small, proceeding over medium to largish, then big - in a linear fashion. And then back to tiny to repeat the cycle.
Hole size 0 to 18 bytes.

Some kind of overrun in a counter?

I've attached a screenshot of a binary diff, exposing the phenomenon; readback on left, original on right.

AVRprog taken from Circuitpython bundle 20211024

InputVsReadbackComparison

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions