How to do a demo showing run is from EEPROM vs RAM? Open terminal after start run?
John Kauffman
Posts: 653
Just as a simple demo, no programming objective:
How can I show if a program is running from EEPROM or RAM, i.e. it was started by SIDE F10 or F11? Is there something I can put in Print() that indicates the source?
Second, If my program has a print() and I want to run it then I normally hit F8 - run with terminal.
If I accidentally hit F10 load to RAM and run then I have to start terminal by hand. But when I do nothing appears on terminal. (Program runs fine w/ test to terminal with F8).
Same with F11 Load to EEPROM and run - can't get terminal to display text.
Thanks.
How can I show if a program is running from EEPROM or RAM, i.e. it was started by SIDE F10 or F11? Is there something I can put in Print() that indicates the source?
Second, If my program has a print() and I want to run it then I normally hit F8 - run with terminal.
If I accidentally hit F10 load to RAM and run then I have to start terminal by hand. But when I do nothing appears on terminal. (Program runs fine w/ test to terminal with F8).
Same with F11 Load to EEPROM and run - can't get terminal to display text.
Thanks.
Comments
Here's a thought: I believe that the PropGCC loader will only write the bytes that are actually used. I believe it also writes 0's to HUB RAM before RAM load. So, if that holds, you can (with a single one off program) write a non-zero value to EEPROM. Then your program can simply check that location in HUB RAM on run. If it's 0 then it's RAM loaded, if it's != 0 then it's EEPROM loaded. It's sort of the opposite side of the coin that T Chap proposed.
My guess to your second question is either that the print came and went before you opened the terminal (so it's output is lost forever), or opening the terminal toggles the reset line (which wipes the program in RAM). For the former, try adding a large delay (10-20seconds) before the print to give you time to open the terminal. For the second, try loading to EEPROM.
F10 programs RAM. F11 programs EEPROM. At power up, the program in EEPROM will run.
The only way to distinguish if the program is running from EEPROM or by RAM load is to have a global variable that is initialized to one value programmed in EEPROM and initialize to another value when programmed by RAM load. Display the contents at startup for example to find out.
Please post the example code you are using.
If this is a common need, it might be nice to have the compiler compute a hash for every program and save it in a known location. That way you would not have to read more than, say, 16 bytes of RAM and EEPROM to provide a test of content identity.
-Phil
PhiPi: good point for me to make. It is not running from EEPROM, it is loading from EEPROM
I've settled on an alternative that lacks elegance but can be understood after a couple lessons of BASIC person coming to PRop C
Project "DemoFromRAM" is always loaded to RAM and run - blinks red led on pin 15
Project "DemoFrom EEPROM" is always loaded to EEPROM and run - blinks green led on pin 10
By running in different combinations of first.second and observe after power off and reset, the story is pretty clear.
I'm moving start terminal problem to another thread