Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 00:35 28 Apr 2024 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 : How to intentionally crash MMBASIC on the PM....

     Page 1 of 2    
Author Message
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9063
Posted: 01:51am 08 Mar 2024
Copy link to clipboard 
Print this post

This is an interesting one, and probably not a request that is seen very often - if at all.

In my other thread about the HW watchdog, I am looking to use that, to get around a problem I have with some PM boards, where MMBASIC crashes for some reason I have yet to discover.

This is a hard-crash.
The interpreter is totally done for, and you cannot talk to the module's VCP - AT ALL.
There simply IS no VCP to connect to, to try to CTRL-C in and play about with the code.

You can only ever get things going again, by pressing the RESET button on the module, or cycling the power.

I now want to CREATE that situation, so I can test if the HW watchdog on the 2040 chip, can recover the situation.

The software watchdog cannot, cos the MMBASIC interpreter has crashed, so it no longer resets the system to get things going again.

So, I need a way to actually hard-crash MMBASIC on the PM module, to see if the HW watchdog gets me around this issue - which I am hopeful it will.

Can I use POKE and a memory location or something, for force a hard-crash to test this idea?

As I said - this is probably not a request that you will hear of very often.
Most people WANT the interpreter to stay alive at all times!  
Smoke makes things work. When the smoke gets out, it stops!
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 844
Posted: 02:31am 08 Mar 2024
Copy link to clipboard 
Print this post

Call the CSUB GONE should do it.
Remove the WatchDog HW and I think you need a hard reset to get out of it.


Print MM.Info(BOOT COUNT)
Print MM.Info(AUTORUN)
WatchDog HW 8000
GONE
Print " I did not DIE"
'File LOG.bas written 08-03-2024 13:23:49 v1.44
CSub GONE
 00000000
   'main
 AF00B580 0000E7FE
End CSub


C code

void main()
{
while (1){
}
}


Edited 2024-03-08 12:32 by disco4now
Latest F4 Latest H7
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9063
Posted: 05:37am 08 Mar 2024
Copy link to clipboard 
Print this post

EXCELLENT!!!  

Thanks.

I will try that with b6 over the weekend.
Smoke makes things work. When the smoke gets out, it stops!
 
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 444
Posted: 06:11am 08 Mar 2024
Copy link to clipboard 
Print this post

Can you just use an infinite function recursion to force a stack overflow?
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3659
Posted: 08:01am 08 Mar 2024
Copy link to clipboard 
Print this post

  LeoNicolas said  Can you just use an infinite function recursion to force a stack overflow?

May well be detected by MMBasic with an error and back to the command prompt.

John
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9063
Posted: 08:22am 08 Mar 2024
Copy link to clipboard 
Print this post

Yes, I need something that can FORCE a total MMBASIC hard-crash.
Assume when that happens, that MMBASIC no longer exists.
The only way to recover, is a hard-reset via a tact-button, or cycling the power.
VERY keen to try out disco4now's crash-code during the weekend.

EDIT: Yes, the timeout is fixed.  Times greater then 201ms now work in this beta.  I will now try the crash-code to see what happens, but I am hopeful it will recover fine.

EDIT: disco4now's code hard-crashes MMBASIC beautifully - no CTRL-C access, no nothing!  
The HW watchdog then DOES work as I hoped, and it kicks MMBASIC back into life.
I expect this will fix my issue completely.
Hopefully, one day, I will be able to find out WHAT causes the PM to hard-crash like this, but this effectively becomes my "Get out of jail free" card - for now.
Edited 2024-03-09 10:13 by Grogster
Smoke makes things work. When the smoke gets out, it stops!
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9063
Posted: 12:19am 09 Mar 2024
Copy link to clipboard 
Print this post

ADDITIONAL: Well, the crash-code DOES work, but then, so does the standard software watchdog if I set that before calling the GONE routine, so perhaps still not quite the hard-crash that I need.

I expect this is simply cos the software watchdog must still be running in the background, even if you call a CSUB that never returns, so it then kicks the system to bring it back to life.

Progress, but as the software watchdog still works during a call to a CSUB, I don't think that the MMBASIC interpreter is actually hard-crashed - it is just stuck in a C routine that never returns to MMBASIC, so can anyone think of something else I can try to totally kill MMBASIC?

It is that aspect that I need to test, cos that is what is happening.
I currently have software watchdog commands in the code, but as the PM is locking up so bad, the software watchdog never comes into effect.  That's what I need to simulate.
Smoke makes things work. When the smoke gets out, it stops!
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8582
Posted: 07:04am 09 Mar 2024
Copy link to clipboard 
Print this post

The club needs to disable interrupts to do what you need
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8582
Posted: 07:04am 09 Mar 2024
Copy link to clipboard 
Print this post

The club needs to disable interrupts to do what you need
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8582
Posted: 07:04am 09 Mar 2024
Copy link to clipboard 
Print this post

The club needs to disable interrupts to do what you need
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8582
Posted: 07:04am 09 Mar 2024
Copy link to clipboard 
Print this post

The csub needs to disable interrupts to do what you need
Edited 2024-03-09 17:31 by matherp
 
Bryan1

Guru

Joined: 22/02/2006
Location: Australia
Posts: 1209
Posted: 09:25am 09 Mar 2024
Copy link to clipboard 
Print this post

ah stuck in a never ending loop mate just aswell you weren't in windows as it would be forever
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5727
Posted: 09:58am 09 Mar 2024
Copy link to clipboard 
Print this post

Peter finally managed to use his club to disable the interrupts by the looks of things.
:)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
zeitfest
Guru

Joined: 31/07/2019
Location: Australia
Posts: 381
Posted: 11:31am 09 Mar 2024
Copy link to clipboard 
Print this post

Using an illegal address will force a reset in many micros. But many microcontrollers will automatically reset and then restart after a serious error condition, it is a deliberate design strategy and one of the differences between microcontrollers and microprocessors. Don't know about PM / STM. It sound like you need to watch it with a debugger as it runs, catch it and see what the status registers tell.
 
LouisG
Senior Member

Joined: 19/03/2016
Location: Australia
Posts: 121
Posted: 09:48pm 09 Mar 2024
Copy link to clipboard 
Print this post

As a humble alternative, have you considered an external transistor pulling down the reset pin upon loss of, say, a square wave from one of the Picomite's pins? Might get away with just a diode and R-C circuit? Can't get a harder hardware reset than that.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5727
Posted: 08:54am 10 Mar 2024
Copy link to clipboard 
Print this post

555 as a watchdog chip. Cheap and nasty but they work. :)
Or - and prettier - an ATTiny as a watchdog. :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 09:25am 10 Mar 2024
Copy link to clipboard 
Print this post

I think that Grogster is looking for a way to totally crash the CPU, not reset/restart it.
So far disco4now's CSUB GONE with interrupts disabled sounds the best.
Geoff Graham - http://geoffg.net
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8582
Posted: 09:35am 10 Mar 2024
Copy link to clipboard 
Print this post

Sorry about the multiple posts, bloody phones. Press save, nothing happens, repeat etc. then they all post  

back to the watchdog issue now I'm on a proper computer:

The S/W watchdog will work in all circumstances except when the H/W timer interrupt has been disabled. The H/W watchdog will work in ALL circumstances. The test CSub did not disable interrupts so the S/W watchdog still worked. To test the H/W watchdog the CSUB needs to disable all interrupts. I can't think of a simple way of doing this from a CSub because you need to link the RP2040 sdk to get the register definition but I can guarantee the H/W watchdog WILL WORK in all circumstances
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9063
Posted: 11:12pm 10 Mar 2024
Copy link to clipboard 
Print this post

Excellent, thanks chums.  

It was a bit of an odd request.  
I mean - who WANTS to intentionally crash the FW running on an MCU? (rhetorical!)

I will simply adopt the HW watchdog now that I can set a time greater then 201ms.

BTW: @ Peter - Do you know what was going on there? (the 201ms issue)
It seems to be corrected in b6, so it's all good, I am just curious.

Also @ Peter - do you want me to delete the duplicate posts via your phone, or are you happy that I leave them there?  It gave us all a chuckle, so I think they should stay, but I can delete them on your request.  
Smoke makes things work. When the smoke gets out, it stops!
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3659
Posted: 10:40am 11 Mar 2024
Copy link to clipboard 
Print this post

Don't you need to carry out a test which disables interrupts - i.e. GONE with something like
cpsid if

(maybe __asm() can do that?)

John
 
     Page 1 of 2    
Print this page
© JAQ Software 2024