Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 07:11 02 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : weird loss of program issue

     Page 8 of 8    
Author Message
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 08:11am 07 Sep 2015
Copy link to clipboard 
Print this post

No I haven't but will try it now. I have CPU 48, option explicit and option autorun on as my first three lines. Stay tuned....Edited by viscomjim 2015-09-08
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 08:57am 07 Sep 2015
Copy link to clipboard 
Print this post

Well HELLS BELLS!!! Remmed out the first three lines...

cpu 48
option explicit
option autorun on

Can't get it to fail. And boy did I try. So I put those lines back in and making it fail was no problem.

So I am guessing I can go back to 4.7b23 for now as long as I don't put the option autorun on in the program and just type it in the command line in the beginning before I hit run. Is there any reason I should be shy about doing this and letting it out in the wild? I would still like to know why this won't fail in 4.5E, I guess just out of curiosity.

I'm going to extensively test this and report back, but so far, this (4.7 without option autorun on) is working very well.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 09:03am 07 Sep 2015
Copy link to clipboard 
Print this post

I think I've found a bug in the code that checks whether to update flash when an OPTION is set even though it is set to the same as before.

I've reported this to Geoff.

If I'm correct this means that flash is written whenever the processor powers up, not just when first programmed - hence the problems and the difference to 4.5
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 09:08am 07 Sep 2015
Copy link to clipboard 
Print this post

That is very interesting news matherp. Can you tell if taking out the option autorun on (or any option) in the program will work ok, if we just put those items in using the command line?
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 09:59am 07 Sep 2015
Copy link to clipboard 
Print this post

Ah, so it was what i expected.
Great that the bug is found!


Microblocks. Build with logic.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 11:16am 07 Sep 2015
Copy link to clipboard 
Print this post

  Quote  Can you tell if taking out the option autorun on (or any option) in the program will work ok, if we just put those items in using the command line?


If I'm right then it should do
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3292
Posted: 04:58pm 07 Sep 2015
Copy link to clipboard 
Print this post

Oh well spotted by Peter. It was only two missing characters (*p++ vs *p) but I had looked at that code so many times and still did not see it.

So that people can test this right away below is V4.7 B24 (for the MX170 only).
2015-09-08_025424_Micromite_V4.7B24.zip

The only difference is the fix found by Peter. I have just got over the chaos from my trip away so in the near future you can expect more betas addressing the long list of missing features and bug fixes.

Geoff
Geoff Graham - http://geoffg.net
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2442
Posted: 06:29pm 07 Sep 2015
Copy link to clipboard 
Print this post

it is nice when i bug is finally nailed down! i once spent nearly a year at a company chasing a bug, in the end the solution was to swap round two lines of code - no one could figure out why it fixed the bug, but it did.

might i offer a suggestion? this is only partly developed (ie, half-baked), so will need a little tinkering before it is fully workable:

1. make all options specified in a program listing volatile.

2. make all options typed at the command prompt persistent, but have them prompt with the message "also save this option to flash (y/n)?". if the user types 'n' the option is still set in ram, but not saved to flash.

3. add the following command to the language:
OPTION SAVE
that saves all options to flash if there is any difference between ram and flash versions. if there are no differences, then the command does nothing. within a basic program, this command should be placed after setting all options if it is desired to save them in flash.

4. add the variable:
MM.CHOPT
that returns true if there is a difference between ram and flash versions of any options. this is so that the programmer can elect to print out a message that should only be displayed on first-run if everything is working correctly, and indeed can double as a 'first-run' detector in the basic program. normally it would appear thus:
if MM.CHOPT then print "options have changed and are being saved"
OPTION SAVE


5. expand the MEMORY command so that it also prints out the current setting of all options, both the ram and flash versions side-by-side.

6. the one exception to the above rules will be the command to set up a colour LCD - where a reboot is needed for the changes to take effect. if in basic code, this one command should (only if it changes the setting stored in flash), store the updated (single) setting directly to flash then cause an immediate reboot. if the command would cause no change in flash, then the command should do nothing and no reboot should occur.


does this sound like it may work?

cheers,
rob :-)Edited by robert.rozee 2015-09-09
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3292
Posted: 07:42pm 07 Sep 2015
Copy link to clipboard 
Print this post

  robert.rozee said  does this sound like it may work?

It does.

But first I need to make all the other fixes/changes in the list. My plan is to then re-examine the whole OPTION thing to see if it can be done in a better way.

I like the idea of OPTION SAVE as that puts control in the hands of the user. I am not sure about the interpreter prompting with "also save this option to flash (y/n)?". Generally BASIC (or Microsoft BASIC) does not ask questions, it just executes the command or produces an error message if it cannot.

Anyway, this is subject for the future.

Geoff
Geoff Graham - http://geoffg.net
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2944
Posted: 08:31pm 07 Sep 2015
Copy link to clipboard 
Print this post

  viscomjim said   Well HELLS BELLS!!! Remmed out the first three lines...

cpu 48
option explicit
option autorun on

Can't get it to fail. And boy did I try. So I put those lines back in and making it fail was no problem.


Just out of interest, for me it was only the OPTION AUTORUN ON line that caused the program to be 'wipable'. Don't the other two lines talk to flash; if so, why can't I get it to 'wipe'?

Nice find matherp

@viscomjim; if possible, can you repeat the test with only OPTION AUTORUN ON commented out (this is just out of curiosity for me!)

@Geoff; will be trying B24 in a short while and report back . . . .

WWEdited by WhiteWizzard 2015-09-09
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 09:04pm 07 Sep 2015
Copy link to clipboard 
Print this post

  Quote  Don't the other two lines talk to flash; if so, why can't I get it to 'wipe'?


No, it is only options where in the manual it says "this option will be remembered when power is removed" that cause the problem

Try "option case upper" on b23 instead of autorun and you will also see the problem
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2944
Posted: 09:24pm 07 Sep 2015
Copy link to clipboard 
Print this post

Thanks Peter for resolving this mystery for me.

Out of interest, is there a list anywhere of the instructions/commands that write to flash to save time in having to go through them all to see if they save? (I'm guessing its just potentially OPTIONS and VAR save?)
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2442
Posted: 11:02pm 07 Sep 2015
Copy link to clipboard 
Print this post

  Geoffg said  
  robert.rozee said  does this sound like it may work?

It does.

I like the idea of OPTION SAVE as that puts control in the hands of the user. I am not sure about the interpreter prompting with "also save this option to flash (y/n)?".
Geoff


i had in mind that the prompting would only happen when the statement was typed at the command prompt, and not when the statement was executed as part of a program. i did think about the asking a question of the user being 'abnormal', but then it is not entirely unreasonable as the user has already demonstrated that they have access to keyboard input to reply. in effect it makes the command:
OPTION AUTORUN ON<cr>y<cr>
(using autorun as an example)

another way to do it would to be have the commandline version as:
OPTION AUTORUN ON, SAVE
(where the ", SAVE" is optionally added to cause a save to flash)

all things to mull over until there is time to get back it it, and well down the todo list.


cheers,
rob :-)
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 01:32am 08 Sep 2015
Copy link to clipboard 
Print this post

This is excellent!!!! Thanks Peter, Geoff, robert, TZ, WhiteWizzard and all who messed with this. Crazy how two little plus signs wreaked so much havoc on this little project. My pickit 3 has its work cut out for it today. Again, MANY THANKS!!!!
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1593
Posted: 01:59am 08 Sep 2015
Copy link to clipboard 
Print this post

YES, great progress!

  robert.rozee said  another way to do it would to be have the commandline version as:
OPTION AUTORUN ON, SAVE
(where the ", SAVE" is optionally added to cause a save to flash)


hmm, why OPTION AUTORUN ON, SAVE? Is OPTION AUTORUN ON without saving to flash not completely useless?

But it seems, maybe we do not need to worry about AUTORUN when the new version works as expected.

Michael
causality ≠ correlation ≠ coincidence
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1593
Posted: 02:02am 08 Sep 2015
Copy link to clipboard 
Print this post

  robert.rozee said   5. expand the MEMORY command so that it also prints out the current setting of all options, both the ram and flash versions side-by-side.


I like that.
And then later, we can list the planned LIBRARIEs (and their functions) ...

Edited by twofingers 2015-09-09
causality ≠ correlation ≠ coincidence
 
viscomjim
Guru

Joined: 08/01/2014
Location: United States
Posts: 925
Posted: 11:57am 08 Sep 2015
Copy link to clipboard 
Print this post

Happy to report that 4.7b24 will not fall over due to sh*tty power connection. Tried very hard to make it fail. Works great. THANKS!!!!
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2944
Posted: 08:09pm 08 Sep 2015
Copy link to clipboard 
Print this post

Confirming the same here; 4.7B24 so far preventing the 'wipe' issue . . . .
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9610
Posted: 03:17pm 09 Sep 2015
Copy link to clipboard 
Print this post

Excellent news.

A very well hidden bug, that one!!!!

Interesting thread.
Smoke makes things work. When the smoke gets out, it stops!
 
     Page 8 of 8    
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025