AndersNielsen wrote:
Anyone actually try programming an SST39SF010 with a 6502?
The whole "magic byte dance" on the address bus looks like it's going to give me a headache.. By demanding $5555 and $2AAA are in ROM address space.
Yes, I'm doing it right now, as we speak.
I'm programming the SST39SF010 EEPROM in the WDC65C134-SXB board directly from 6502 code. (From TinyBasic, but that not relevant) It's working very well (now, anyway, it wasn't easy to get going for many reasons not directly connected to the SST39SF010).
You need to copy code into RAM and run it from RAM to program the EEPROM. You can't program it from code running inside the EEPROM - because code access gets in the way of the "magic byte dance" routine.
So that's what I do - I have a version of my TinyBasic that I download into RAM to run from there - it's a handy tool to write a programmable device flasher in than anything else and call some specific built-ins to do sector erase and programming from RAM images..
Here is the relevant snippets of code:
Code:
;********************************************************************************
;* doEra:
;* Erase a single 4K sector of the EEPROM
;* Variables:
;* A has the EEPROM address
;* D has the EEPROM bank (0-3)
;********************************************************************************
.macro flaCmd addr,data
lda #data
sta $8000+addr
.endmacro
.proc doEra
jsr extractVars
jsr flashSetup
flaCmd $5555,$AA ; Unlock
flaCmd $2AAA,$55
flaCmd $5555,$80
flaCmd $5555,$AA
flaCmd $2AAA,$55 ; Sector erase
lda #$30 ; Erase command
ldy #$00
sta (regA),y
wait:
lda (regA),y
cmp #$FF
bne wait
; Fall into...
.endproc
and
Code:
;********************************************************************************
;* doFla:
;* Flash data into the device
;* Variables:
;* A has the FROM address (RAM)
;* B has the TO address (Flash)
;* C has the length.
;* D has the ROM page (0-3)
;* On exit the variables, A, B and C are updated.
;********************************************************************************
.proc doFla
jsr extractVars
jsr flashSetup
ldy #0
loop:
flaCmd $5555,$AA ; Unlock
flaCmd $2AAA,$55
flaCmd $5555,$A0 ; Byte write
lda (regA),y
sta (regB),y
wait:
cmp (regB),y
bne wait
; Inc To:
inc regAL
bne :+
inc regAH
; Inc From:
: inc regBL
bne :+
inc regBH
; Dec. count
: lda regCL
bne :+
dec regCH
: dec regCL
; If not zero, then go back for more...
lda regCL
ora regCH
bne loop
You can ignore the JSRs at the start - that's to do with getting data from the Basic environment into the ASM world and also setting up the SXB hardware for the right thing (it treats the 128KB EEPROM as 4 banks of 32KB and there is further shenanigans to do with the built-in ROM).
Remember to disable all interrupts before you start the operations too.
This is what I'm doing for "bulk" re-flashes of my new OS and TB for the '134 - once my TB in is ROM, then to do the flashing for program saves, it copies a little stub into a small reserved area of RAM and calls that to do the actual load/save of Basic programs.
Hope this helps..
-Gordon
_________________
--
Gordon Henderson.
See my
Ruby 6502 and 65816 SBC projects here:
https://projects.drogon.net/ruby/