PDA

View Full Version : CAN -> SPI EEPROM -> Code Update


Pacetech
09-09-05, 09:00 PM
I have a SPI EEPROM working with the PODs, its an Atmel AT25HP512. Its 512K and I'm moving my lookup tables in there. I went from having a lookup table for 6 of my things to 60. This will free up my precious POD Program Memory. And I haven't used up half the memory of the SPI chip yet.

I have it configured for 32K x 16. I can move blocks of memory to/from RAM or Program Memory to the SPI EEPROM. I'm writing words to allow me to re-program the whole memory via the CANBUS. That's working pretty well.

Then I had an idea, what if I were to use up some of the memory to hold my Forth code, I could easily update my Forth code via CAN. So I wanted to get some input/confirmation on what I would need to accomplish that.

1. My initial forth code will be the SPI EEPROM to Program Memory mover (with a Program Flash memory eraser).
2. Any code after that (my application) will need to reside on the next program memory flash block as to allow it to be erased without erasing any of the code in item 1.
3. I have to be able to move over the autostart vector (where is that again?)
4. To executate a flash update, I would set a byte in the Data Flash to indicate a flash update is needed. It would be cleared
5. Is there anything else I would need to copy & move??

Now for the details, I need to find out what the Program Flash locations are, but it appears PHERE is acting unusual.

COLD
IsoMax V0.76
SCRUB
IsoMax V0.76
HEX OK
." PFAVAIL = " PFAVAIL . PFAVAIL = 28FE OK
." PHERE = " PHERE . PHERE = 7E00 OK

If I download a medium sized program(1300 (hex) bytes), I get the following:

." PFAVAIL = " PFAVAIL . PFAVAIL = 15FE OK
." PHERE = " PHERE . PHERE = 7E86 OK

I would expect PHERE to be 9100, not 7E86.

Any ideas?

Pacetech
09-12-05, 12:23 PM
I tried the following

COLD
SCRUB
HEX
: TEST
1 .
; EEWORD

5400 PFERASE

I thought that it would work, but I managed to corrupt the POD, need to reload FORTH on it.

Any ideas on how I am supposed to erase Program Flash?

RMDumse
09-12-05, 06:41 PM
Your dictionary linkage is in RAM just after CURRENT and CONTEXT at 203 hex. Before you get rid of your dictionary, you need to unlink it.

(I'm using a slightly different, experimental version of the kernel, so my numbers may be different but here's the idea anyway to follow along.)

Here's your code, notice the 203 @ . is added so I can see where the dictionary was before I started adding any definitions.

COLD
SCRUB
HEX

203 @ .

: TEST
1 .
; EEWORD

When I download that, I get this result with WORDS, then I'll replug the previous dictionary link and do another WORDS to show the unlinking.

COLD
IsoMax V0.85
SCRUB
IsoMax V0.85
HEX OK
OK
203 @ . 598E OK
OK
: TEST
1 .
; EEWORD OK
WORDS
----- COMMON -----
5C09 TEST 357B TASK 433D LOOPINDEX 4339 LOOPINDEXES
42EB QUADS 42E7 QUAD1 42E3 QUAD0 42C2 ADCS
42BD ADC7 42B8 ADC6 42B3 ADC5 42AE ADC4
42A9 ADC3 42A4 ADC2 429F ADC1 429A ADC0
4290 SCIS 428B SCI1 4286 SCI0 4243 SPI
423E SPI0 4173 TIMERS 416E TD3 4169 TD2
4164 TD1 415F TD0 415A TC3 4155 TC2
4150 TC1 414B TC0 4146 TB3 4141 TB2
413C TB1 4137 TB0 4132 TA3 412D TA2
4128 TA1 4123 TA0 404E PWMIN 4049 ISB2
4044 ISB1 403F ISB0 403A FAULTB3 4035 FAULTB2
( --- SPACE to proceed ESC to abort. --- )
598E 203 ! OK
WORDS
----- COMMON -----
357B TASK 433D LOOPINDEX 4339 LOOPINDEXES 42EB QUADS
42E7 QUAD1 42E3 QUAD0 42C2 ADCS 42BD ADC7
42B8 ADC6 42B3 ADC5 42AE ADC4 42A9 ADC3
42A4 ADC2 429F ADC1 429A ADC0 4290 SCIS
428B SCI1 4286 SCI0 4243 SPI 423E SPI0
4173 TIMERS 416E TD3 4169 TD2 4164 TD1
415F TD0 415A TC3 4155 TC2 4150 TC1
414B TC0 4146 TB3 4141 TB2 413C TB1
4137 TB0 4132 TA3 412D TA2 4128 TA1
4123 TA0 404E PWMIN 4049 ISB2
( --- SPACE to proceed ESC to abort. --- )

So then I decided to see if I could still execute the unlinked word, and it worked. Then I decided to erase the word, and I did. So cautiously, I decided I'd try to execute the word, expected a crash, but as it turned out, it came back fine, but did not run the word because there was no 1 printed.

5C09 EXECUTE 1 OK
5C00 PFERASE OK
5C09 EXECUTE OK

HTH's

RMDumse
09-12-05, 06:48 PM
5. Is there anything else I would need to copy & move??

Well, the dictionary link to the last word is at 203.


I would expect PHERE to be 9100, not 7E86.

Yes, but the program words are first assembled in Program RAM, not Program Flash. Once a given definition is finished, EEWORD relinks it and moves it from Program RAM to Program Flash. So the PHERE is showing the Program RAM location. You might want to look at PFDP instead to find where your program is going and use PDUMP to look at it for that matter.

HTH's