Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 05:43 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 : Chain command for sd card?

     Page 1 of 2    
Author Message
fred777
Regular Member

Joined: 01/07/2021
Location: United Kingdom
Posts: 57
Posted: 09:15pm 08 Jun 2022
Copy link to clipboard 
Print this post

Hello,
is there a way to do a CHAIN for files on sd card?
Like the FLASH CHAIN command?
(From mmbasic manual: Execute$ Command „RUN is a special case and will cancel the timer allowing you to use the command to chain programs if required.“ … is that a way to do it?)
Edited 2022-06-09 07:33 by fred777
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 06:56am 09 Jun 2022
Copy link to clipboard 
Print this post

Which platform, CMM2? That can, but I'm not sure about the PicoMite. Try it. :)

FLASH CHAIN preserves variables, unlike FLASH RUN. I suspect that using EXECUTE$ will lose the variables and that it wouldn't work with CHAIN.

All I can suggest is to please try it and report back. :)
Mick

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

Joined: 01/07/2021
Location: United Kingdom
Posts: 57
Posted: 07:07am 09 Jun 2022
Copy link to clipboard 
Print this post

Oops, its about the picomite
Will try as soon as a pico arrives, I blew mine up yesterday…. thought I had 3.3volts but had set the power supply to 33v (aargh)
I’m getting too old for this stuff
 
Tinine
Guru

Joined: 30/03/2016
Location: United Kingdom
Posts: 1646
Posted: 07:16am 09 Jun 2022
Copy link to clipboard 
Print this post

  fred777 said  Oops, its about the picomite
Will try as soon as a pico arrives, I blew mine up yesterday…. thought I had 3.3volts but had set the power supply to 33v (aargh)
I’m getting too old for this stuff


Snap!!! I stuck 24V on mine  







Craig
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 10:26am 09 Jun 2022
Copy link to clipboard 
Print this post

Ulp! I don't allow anything over 5V anywhere near my little 40-legged beasties. TBH I've no other PSU set up at this table so it would be fairly difficult.  :)
Mick

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

Joined: 01/07/2021
Location: United Kingdom
Posts: 57
Posted: 02:23pm 16 Jun 2022
Copy link to clipboard 
Print this post

So with my new Pico (now on a fixed 3.3 power supply...)

I tested these files on sdcard
ch1.bas:
PRINT gna
x$ = "RUN "+CHR$(34)+"CH2.BAS"+CHR$(34)
EXECUTE x$

ch2.bas:
PRINT gna
gna = gna + 1
x$ = "RUN "+CHR$(34)+"CH1.BAS"+CHR$(34)
EXECUTE x$

output:
> run
0
0
0
0
0

So variables are not preserved, but as the CMM2 can do this, could that be ported to the PicoMite?  (Or, but less fun, the manual needs updating)

Cheers,
Fred
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 02:42pm 16 Jun 2022
Copy link to clipboard 
Print this post

What specifically are you trying to do Fred ?

1. What you've shown "works" on the CMM2 as illustrated, printing zeroes.
2. I believe it also works in the same way on recent PicoMite firmware - or is a bug if it doesn't.
3. In neither case (CMM2 or PicoMite) would I expect it to preserve variables; RUN is not CHAIN.
4. The CMM2 does not have CHAIN, if you want to preserve variables between programs I believe you need to serialise them to/from files - though there *may* be some flash variable storage that you have to use explicitly - never looked into it.

Best wishes,

Tom
Edited 2022-06-17 00:43 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
fred777
Regular Member

Joined: 01/07/2021
Location: United Kingdom
Posts: 57
Posted: 03:14pm 16 Jun 2022
Copy link to clipboard 
Print this post

I wanted to see if there is a way to chain a program form SD card with variables intact like with "flash chain".
I suspected it wouldn't work but that sentence in the manual about using run inside an execute statement got me interested ("RUN is a special case...allowing you to use the command to chain programs")
Edited 2022-06-17 01:15 by fred777
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 03:28pm 16 Jun 2022
Copy link to clipboard 
Print this post

What's the advantage you see to chaining programs from the SD card rather from flash?

You can chain an awful lot of code using the flash slots and a variable to switch to the routine you want to use.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 03:30pm 16 Jun 2022
Copy link to clipboard 
Print this post

  fred777 said  I wanted to see if there is a way to chain a program form SD card with variables intact like with "flash chain".
I suspected it wouldn't work but that sentence in the manual about using run inside an execute statement got me interested ("RUN is a special case...allowing you to use the command to chain programs")


As far as I'm aware you can't do it and the sentence in the manual (probably copied from the CMM2 manual) possibly deliberately uses lower case "chain" so as to (try to) avoid confusion with the behaviour of FLASH CHAIN (and the CHAIN command in some other BASICs).

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 03:38pm 16 Jun 2022
Copy link to clipboard 
Print this post

You can't CHAIN from SDcard on either the CMM2 or PicoMite. In both cases the variable memory is used to load the program so it can then be tokenised into flash. The reference in the manual in the EXECUTE command merely relates to the fact that the execute timer is disabled when "executing" the RUN command allowing one program to run another.

In both cases variable persistence can be achieved using VAR SAVE/RESTORE if required. In the case of the CMM2 this uses 4K of battery backed RAM so can be done without consequence. In the case of the Picomite saving is done to flash memory so care should be exercised to stay within the limits of the write capability of the flash chip "Min. 100K Program-Erase cycles per sector"
Edited 2022-06-17 01:39 by matherp
 
fred777
Regular Member

Joined: 01/07/2021
Location: United Kingdom
Posts: 57
Posted: 08:38am 17 Jun 2022
Copy link to clipboard 
Print this post

Thanks for the explanation. Now this got me thinking, is there any way to save the tokenized version of a programme from flash to a file on SD and to load such a file directly to a flash slot and then to run that with flash chain?
I'm trying to find a way to load/update a program during runtime from SD (or from a SPI ram or flash device if sd support is too complicated for that task) without losing variable data (VAR SAVE/RESTORE doesn't offer enough room in this case).
A "chain tokenized file" kind of thing, really
 
Bleep
Guru

Joined: 09/01/2022
Location: United Kingdom
Posts: 633
Posted: 10:07am 17 Jun 2022
Copy link to clipboard 
Print this post

Can you not use the "flash load x"  "flash save x"  "flasb chain x" you can have up to 8 saved individual programs stored this way?
 
fred777
Regular Member

Joined: 01/07/2021
Location: United Kingdom
Posts: 57
Posted: 10:33am 17 Jun 2022
Copy link to clipboard 
Print this post

  Bleep said  Can you not use the "flash load x"  "flash save x"  "flasb chain x" you can have up to 8 saved individual programs stored this way?

Flash load and Flash save can only be used at the command prompt, the idea was to chain a new file from sd card from within a running programme, perhaps by flashing it first to another slot and then chaining it.
Edited 2022-06-17 20:33 by fred777
 
Bleep
Guru

Joined: 09/01/2022
Location: United Kingdom
Posts: 633
Posted: 10:43am 17 Jun 2022
Copy link to clipboard 
Print this post

No, I have programs that "flash run 1" "flash run 2" you just run one program from another, page 13 of the manual, I've never tried "flash chain 5", but I assume that'll be fine as well.
Regards, Kevin.
Edited 2022-06-17 20:50 by Bleep
 
fred777
Regular Member

Joined: 01/07/2021
Location: United Kingdom
Posts: 57
Posted: 11:02am 17 Jun 2022
Copy link to clipboard 
Print this post

Yes flash chain 1-7 are all fine, but that's not the point, its chaining a (perhaps pre tokenized) file from SD Card from within a programm without going to the command line
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 11:31am 17 Jun 2022
Copy link to clipboard 
Print this post

You can't (currently anyway) chain a tokenized file from SD because they are never stored on SD in that format (you wouldn't be able to list them from SD if they were).

There isn't, AFAIK, any way to get a tokenized file onto an SD.

When you use FLASH SAVE or FLASH OVERWRITE they are already tokenized as you are copying from RAM, which also allows them to be run from flash without loading first.
Mick

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

Joined: 01/07/2021
Location: United Kingdom
Posts: 57
Posted: 12:43pm 17 Jun 2022
Copy link to clipboard 
Print this post

I guess there is no way to access the flash from Basic directly, maybe using a csub?
Hmmm, well I'll have to think of something ;-)
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7937
Posted: 01:09pm 17 Jun 2022
Copy link to clipboard 
Print this post

You might be able to save variables to a file then RUN a new program from SD. That will replace the program in RAM and clear the variables area. The new program should then load the variables from the file. That way you can save whatever variables you like, only restricted by the file space available.
Mick

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

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 01:15pm 17 Jun 2022
Copy link to clipboard 
Print this post

  fred777 said  I guess there is no way to access the flash from Basic directly, maybe using a csub?
Hmmm, well I'll have to think of something ;-)


Perhaps, but seems like a deep hole and I don't imagine you will get much support from Peter; be sure to say hello to our friends in Oz if you go down it.

Assuming what you are trying to do is get a running program to update itself then:

1. Have running program serialise its variables to a file (or flash using VAR SAVE/RESTORE).
2. Copy new version of program file over existing program file - I don't believe the PicoMite has any protection to prevent this.
3. Have program EXECUTE "RUN ..." its own file ... you may even be able to just RUN
4. Have new instance read its variables back in.

Step 4 would be IMO cleaner if the PicoMite supported running programs with command-line flags (hint, hint Peter), but there are other ways of communicating that you want the variables to be read back in, e.g. the very existence of a serialised variable file.

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
     Page 1 of 2    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025