Propeller reprogramming itself (what am I doing wrong?)
Bobb Fwed
Posts: 1,119
I have a program in memory, formatted like this:
I then have a function that copies that from its space in the DAT block to address 0 in the EEPROM, then reboots:
The read memory (in that final verification loop) looks perfect, but then it reboots and nothing happens. And yes, the "new" program works when I program it directly to the Propeller (should I post that code too).
So what am I doing wrong?
DAT '' Program to Program... prog_size LONG 64 ' bytes -- 16 longs var_size LONG 28 ' bytes -- 7 longs prog LONG $00b4_c404,$6fdb_1000,$4000_6400,$1800_6800 LONG $3000_0200,$0800_0000,$3703_3dd6,$1c38_113d LONG $d61c_3703,$3dd4_1c38,$113d_d418,$35c0_3701 LONG $e23f_91ec,$2337_033d,$d447_0470,$3200_0000 LONG 0,0,0,0 ' var space LONG 0,0,0,0 ' var space LONG 0,0,0,0 ' include this at the end -- for overrun memory purposesThis is a very simple program that just blinks an LED. A VAR block is included just for testing purposes
I then have a function that copies that from its space in the DAT block to address 0 in the EEPROM, then reboots:
PRI self_program | i, v REPEAT i FROM 0 TO ((prog_size + var_size) >> 2) + 1 bytemove(@v, MEM.read(@prog + (i << 2), 4), 4) MEM.write(i << 2, @v, 4) DEBUG.str(string("Rebooting soon...",$D)) ' this is here so I can verify the code got copied REPEAT i FROM 0 TO (prog_size + var_size) >> 2 + 1 bytemove(@v, MEM.read(i << 2, 4), 4) DEBUG.hex(v, 8) IF (i // 4 == 3) DEBUG.nl ELSE DEBUG.tx(" ") waitcnt(clkfreq << 3 + cnt) REBOOT(I know it's not as optimized as it should be...I haven't got to that stage yet)
The read memory (in that final verification loop) looks perfect, but then it reboots and nothing happens. And yes, the "new" program works when I program it directly to the Propeller (should I post that code too).
So what am I doing wrong?
Comments
Well, the reason it is like that, is because the program is actually going to be "downloaded" and stored before it's programmed, so it kind of has to be stored like this. I was just circumventing the downloading portion of the program to simplify it while I'm troubleshooting the issue.
Endianness was my best theory as to why it wasn't working. I'll try this fix. Thanks.