Writing a Spin binary to EEPROM
David Betz
Posts: 14,530
If I want to write a Spin binary file as output by OpenSpin or the Propeller Tool to EEPROM, do I have to write the entire 32K or can I stop writing after the end of the .binary file? In other words, if the .binary file is 8K can I just overwrite the first 8K of EEPROM and leave the rest as-is or do I need to fill the remainder of the first 32K with zeros?

Comments
When loading eeprom with PropTool (and propeller bootloader) you have to write all 32k and need a correct checksum.
once in the eeprom the checksum does not matter.
If you have some loader already running on the prop it can write just needed bytes to the eeprom and leave the rest as is.
Enjoy!
Mike
CON ' program preamble PREAMBLE0 = $0000 PREAMBLE1 = $0004 PREAMBLE2 = $0008 PREAMBLE3 = $000c '' Adapted from code in sdspiFemto.spin '' After reading is finished for a boot, the stack marker is added below dbase '' and memory is cleared between that and vbase (the end of the loaded program). '' Memory beyond the stack marker is not cleared. Note that if ioNoStore is set, '' we go through the motions, but don't actually change memory or the clock. DAT rdlong t1,#PREAMBLE2 shr t1,#16 ' Get dbase value sub t1,#4 wrlong StackMark,t1 ' Place stack marker at dbase sub t1,#4 wrlong StackMark,t1 rdlong t2,#PREAMBLE2 ' Get vbase value and t2,WordMask sub t1,t2 shr t1,#2 wz ' Compute number of longs between :zeroIt if_nz wrlong zero,t2 ' vbase and below stack marker if_nz add t2,#4 if_nz djnz t1,#:zeroIt ' Zero that space (if any) rdlong t1,#PREAMBLE0 cmp t1,SaveClkFreq wz ' Is the clock frequency the same? rdlong t1,#PREAMBLE1 and t1,#$FF ' Is the clock mode the same also? if_ne jmp #:changeClock cmp t1,SaveClkMode wz ' If both same, just go start COG if_e jmp #:justStartUp :changeClock and t1,#$F8 ' Force use of RCFAST clock while clkset t1 ' letting requested clock start mov t1,time_xtal :startupDelay djnz t1,#:startupDelay ' Allow 20ms@20MHz for xtal/pll to settle rdlong t1,#PREAMBLE1 and t1,#$FF ' Then switch to selected clock clkset t1 :justStartUp cogid t1 or t1, interpreter coginit t1 StackMark long $FFF9FFFF ' Two of these mark the base of the stack interpreter long ($0004 << 16) | ($F004 << 2) | %0000 WordMask long $0000FFFF time_xtal long 20 * 20000 / 4 / 1 ' 20ms (@20MHz, 1 inst/loop) SaveClkFreq long 0 ' Initial clock frequency (clkfreqVal) SaveClkMode long 0 ' Initial clock mode value (clksetVal)