![]() |
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 KingdomPosts: 57 |
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 KingdomPosts: 7937 |
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 KingdomPosts: 57 |
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 KingdomPosts: 1646 |
Snap!!! I stuck 24V on mine ![]() Craig |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7937 |
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 KingdomPosts: 57 |
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 KingdomPosts: 4311 |
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 KingdomPosts: 57 |
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 StatesPosts: 3378 |
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 KingdomPosts: 4311 |
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 KingdomPosts: 10315 |
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 KingdomPosts: 57 |
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 KingdomPosts: 633 |
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 KingdomPosts: 57 |
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 KingdomPosts: 633 |
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 KingdomPosts: 57 |
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 KingdomPosts: 7937 |
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 KingdomPosts: 57 |
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 KingdomPosts: 7937 |
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 KingdomPosts: 4311 |
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 ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |