Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:02 01 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 : CMM2: v5.05.04RC7 - RAM and FLASH flexibility

     Page 1 of 3    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 02:01pm 23 Jul 2020
Copy link to clipboard 
Print this post

This release could be the final release version if no bugs are found.

http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip

OPTION RAM causes the program to be loaded into RAM to run rather than flash memory. Loading is somewhat faster and avoids impacting the flash write life.
CSUBs do not work in this mode and you will get an error when exiting the editor or running a program with a CSUB
OPTION FLASH [n] sets the start position of a program to run from flash memory. The optional parameter specifies the starting point in 128Kbyte pages of memory.
Defaults to 0.
For 0<=n<=4 the maximum program size is 512KBytes
for n=5 the maximum program size is 384KBytes
for n=6 the maximum program size is 256KBytes
for n=7 the maximum program size is 128KBytes
Given that very few programs exceed 128KBytes in length when tokenised, using the OPTION FLASH command can increase flash lifespan by a factor of 8

Note, for most users these new commands will never be needed or used.
Note, I am not going to implement any type of automatic wear levelling - don't ask
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 490
Posted: 02:11pm 23 Jul 2020
Copy link to clipboard 
Print this post

Thank you for your always prompt and forward thinking work.  This is a good option and you added pageing that makes it much better than anyone discused.  Kudos to you.  Don't hate me for asking but is there any way that CSUB can be made to work in ram or is that to much of a effort for what may be a seldom used function?  I really have no idea how CSUBs work and am trying to understand them.  Can anyone point me to an artical of video that goes into details about how CSUBs work?  Thanks.
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 02:33pm 23 Jul 2020
Copy link to clipboard 
Print this post

Thank you for being so open to, and improving further on, our suggestions Peter.

Apologies for repeating myself, but can Mm.Info(Program) be used by a program to determine if it is running from RAM or FLASH ?

When running from RAM the MEMORY command still reports usage of "Flash:", would I be correct in assuming this is actually "Program RAM:" and that what is reported as "RAM" is actually "Variable RAM:" ?

  matherp said  This release could be the final release version if no bugs are found.


Did you see the final entry here: https://www.thebackshed.com/forum/ViewTopic.php?FID=16&TID=12332&LastEntry=Y#150564 ?

Regards,

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

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 02:42pm 23 Jul 2020
Copy link to clipboard 
Print this post

  Quote  can Mm.Info(Program) be used by a program to determine if it is running from RAM or FLASH ?


Why not try it and see

  Quote  When running from RAM the MEMORY command still reports usage of "Flash:", would I be correct in assuming this is actually "Program RAM:" and that what is reported as "RAM" is actually "Variable RAM:" ?

Yes and yes

  Quote  Did you see

works for me
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 02:53pm 23 Jul 2020
Copy link to clipboard 
Print this post

  matherp said  
  Quote  can Mm.Info(Program) be used by a program to determine if it is running from RAM or FLASH ?


Why not try it and see


Thanks Peter, I'll take that as a "yes"

  matherp said  
  Quote  Did you see

works for me


I tested again with RC6 and it failed consistently.

Just flashed RC7 and it works.

<shrugs shoulders>

Thanks,

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

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 02:57pm 23 Jul 2020
Copy link to clipboard 
Print this post

  thwill said  Just flashed RC7 and it works.


And I've got the problem back again. Watch this space.

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

Guru

Joined: 08/05/2020
Location: United States
Posts: 377
Posted: 02:58pm 23 Jul 2020
Copy link to clipboard 
Print this post

  thwill said  Thank you for being so open to, and improving further on, our suggestions Peter.

Apologies for repeating myself, but can Mm.Info(Program) be used by a program to determine if it is running from RAM or FLASH ?



You should be able to determine if the program resides in RAM or which one of the flash pages it is in using MM.Info(Program).  I'll do some experimenting and let you know what I find.
-Carl
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 03:03pm 23 Jul 2020
Copy link to clipboard 
Print this post

Here you go, with RC7:
> option reset

> option list
CURRENT VGA mode 800x600 RGB332
CURRENT DISPLAY 50,100
OPTION USBKEYBOARD UK

> Print Cwd$
A:/

> list "/test.bas"
Print Mm.CmdLine$

> *test "abcdefgh"
"abcdefgh"

> option search path "/bin/"

> *test "abcdefgh"
Error: Expression syntax

> ls "/bin/"
A:/bin
22:51 25-06-2020         98  mmpp.bas
11:44 24-06-2020         74  zmim.bas
0 directories, 2 files



Regards,

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

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 03:04pm 23 Jul 2020
Copy link to clipboard 
Print this post

  Sasquatch said  You should be able to determine if the program resides in RAM or which one of the flash pages it is in using MM.Info(Program).  I'll do some experimenting and let you know what I find.


Much appreciated,

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

Guru

Joined: 08/05/2020
Location: United States
Posts: 377
Posted: 03:07pm 23 Jul 2020
Copy link to clipboard 
Print this post

Thank You Peter!


You have been prolific on this and the previous projects.  Unfortunately, a disproportionate amount of the work on these projects has fallen to a few of you "Guru's"

I hope you don't feel unappreciated when confronted by all the questions, requests and outright demands made by the community here.

I agree, it's time to freeze the feature list, let the dust settle and get the new features released.  Hopefully you can get some well deserved rest after months of dedication to this project.


Thanks again,
-Carl
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 03:09pm 23 Jul 2020
Copy link to clipboard 
Print this post

Also should OPTION LIST tell you the value of [n] for OPTION FLASH [n] ?

Currently:
> option reset
> option flash 3
> option list
CURRENT VGA mode 800x600 RGB332
CURRENT DISPLAY 50,100
OPTION USBKEYBOARD UK


I apologise if I come off as ungrateful :-(

Regards,

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

Joined: 11/12/2012
Location: United Kingdom
Posts: 10310
Posted: 04:07pm 23 Jul 2020
Copy link to clipboard 
Print this post

V5.05.04RC8

http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip

Fixes bug in shortform RUN command when search path is specified. Displays non-default FLASH settings in OPTION LIST.
Note to thwill: if you find any more bugs in the shortform RUN or search paths I will remove both forever!!!!!!!!!
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 04:09pm 23 Jul 2020
Copy link to clipboard 
Print this post

  matherp said  V5.05.04RC8

http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip

Fixes bug in shortform RUN command when search path is specified. Displays non-default FLASH settings in OPTION LIST.
Note to thwill: if you find any more bugs in the shortform RUN or search paths I will remove both forever!!!!!!!!!


Thanks Peter, I'll bite my tongue until the source code for 5.05.04 becomes available then.

Best wishes,

Tom
Edited 2020-07-24 02:10 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
Sasquatch

Guru

Joined: 08/05/2020
Location: United States
Posts: 377
Posted: 05:33pm 23 Jul 2020
Copy link to clipboard 
Print this post

  mclout999 said  Don't hate me for asking but is there any way that CSUB can be made to work in ram or is that to much of a effort for what may be a seldom used function?  I really have no idea how CSUBs work and am trying to understand them.  Can anyone point me to an artical of video that goes into details about how CSUBs work?  Thanks.



CSubs currently don't work if the MMBasic program is stored in RAM.  It is not clear at this point whether the limitation is in the GCC Compiler (or how we are using it) or a hardware limitation in the CPU.  Peter has indicated that this is not on his short-list of things to look into.  I may look into this myself at some future date if it really becomes an issue.  It seems like a solution looking for a problem to solve at this point.  Keep in mind the following:

1.  The 10,000 flash write cycles specified in the data-sheet are a gaurenteed minimum, not some kind of hard limit.  Your chip is not likely to die at 10,000 cycles.

2.  Nobody in the history of the MM projects has EVER reported burning out their flash memory.  It is likely that your chip will outlive your interest in the project and may even out live you (or at least your memory)

3.  The cost of the chip is $14.00USD and even the Waveshare module is $30.00USD.  If you do manage to wear the chip out, consider it money well spent.



For CSUBs there is a tutorial here:

http://circuitgizmos.com/projects/microboard-micromite-projects/mmbasic-code-library/understanding-cfunctions-1/

Keep in mind that these tutorials are for older Microchip(tm) based 'Mites, there is a different compiler used for the CMM2.  They do give a good overview and some examples.


For the CMM2, there are some examples in this thread:
https://www.thebackshed.com/forum/ViewTopic.php?TID=12289&P=1

and another example in this thread:
https://www.thebackshed.com/forum/ViewTopic.php?TID=12306&P=1

These should at least allow you to get your tool-chain set up and tested.  Note that you should be able to run the MMBasic examples even if you have no idea how this all works.  Then have a look at the "C" source code for the examples.

The basic process is as follows:

1.  Write a function in "C".  The ArmCFunctions.h file has the functions to access MMBasic features.  Usually these are short functions that accomplish a small task very FAST!

2.  Compile the "C" code using the GCC compiler.  You will need to run the compiler using the proper command line switches as shown in Peter's initial thread (linked above) to generate the ARM code properly.

3.  If there are no errors in the compile process, Link the object file again using the proper command line switches.

4.  If there are no link errors, run the resulting .elf file through the ArmCFGen.bas program to generate the HEX text that will be used by MMBasic to load the CFunctoin into memory.
-Carl
 
Sasquatch

Guru

Joined: 08/05/2020
Location: United States
Posts: 377
Posted: 06:13pm 23 Jul 2020
Copy link to clipboard 
Print this post

  thwill said  

Apologies for repeating myself, but can MM.Info(Program) be used by a program to determine if it is running from RAM or FLASH ?



So it appears that when the program is stored in RAM the address returned by MM.Info(Program) is 0xD0300000

The Flash "pages" start at 0x8100000

The following example shows the use of MM.Info(Program) to determine the memory location of your MMBasic program.  Note this was tested with V5.05.04RC8 not gaurenteed to work with earlier versions!


N% = MM.Info(Program)


Print "MMBasic Program lives at: 0x";HEX$(N%)
Print

If (N% = &HD0300000) Then
 Print "MMBasic Program is in RAM"
Else
 Print "MMBasic Program is in Flash Page ";Int((N%-&H8100000)/&H1FFFF)
EndIf

-Carl
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 06:34pm 23 Jul 2020
Copy link to clipboard 
Print this post

  Sasquatch said  The following example shows the use of MM.Info(Program) to determine the memory location of your MMBasic program...


Thanks, that's really helpful. The reason I want to know is so that my proposed unit-test framework can exit or at least warn the user if executed in FLASH. Whether it is a real or imagined problem I don't want to be responsible for someone wearing out their flash because running one command is actually writing the flash multiple times.

Regards,

Tom
Edited 2020-07-24 06:34 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1427
Posted: 09:44pm 23 Jul 2020
Copy link to clipboard 
Print this post

For a moment I thought that this was a way to do FLASH libraries. Load a page with code, then change the page to load code in a different place. Kinda a poor-man's LIBRARY.

But then that wouldn't work as the core MMBasic would only know about the one current page that is set. Probably too difficult to get to work as a way to store library routines in other pages.
Micromites and Maximites! - Beginning Maximite
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 09:59pm 23 Jul 2020
Copy link to clipboard 
Print this post

  Quote  1.  The 10,000 flash write cycles specified in the data-sheet are a gaurenteed minimum, not some kind of hard limit.  Your chip is not likely to die at 10,000 cycles.

2.  Nobody in the history of the MM projects has EVER reported burning out their flash memory.  It is likely that your chip will outlive your interest in the project and may even out live you (or at least your memory)

3.  The cost of the chip is $14.00USD and even the Waveshare module is $30.00USD.  If you do manage to wear the chip out, consider it money well spent.


I am currently running a burnout test on one of my systems.
I am up over 100,000 erase cycles on the flash and counting.
It's only testing a portion of the first 128k flash but an indication of practical use.

And that was starting from a system that had been in heavy use for 6 months before starting the burnout.

Having OPTION RAM and having the flash page options is a security blanket for some, irrelevant for most users.

Jim
VK7JH
MMedit
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 490
Posted: 10:17pm 23 Jul 2020
Copy link to clipboard 
Print this post

  Sasquatch said  
  mclout999 said  Don't hate me for asking but is there any way that CSUB can be made to work in ram or is that to much of a effort for what may be a seldom used function?  I really have no idea how CSUBs work and am trying to understand them.  Can anyone point me to an artical of video that goes into details about how CSUBs work?  Thanks.



CSubs currently don't work if the MMBasic program is stored in RAM.  It is not clear at this point whether the limitation is in the GCC Compiler (or how we are using it) or a hardware limitation in the CPU.  Peter has indicated that this is not on his short-list of things to look into.  I may look into this myself at some future date if it really becomes an issue.  It seems like a solution looking for a problem to solve at this point.  Keep in mind the following:......


Thanks. Your responce was very helpfull and a good synopsis with good links.
 
PCG68
Newbie

Joined: 14/07/2018
Location: Italy
Posts: 16
Posted: 11:27pm 23 Jul 2020
Copy link to clipboard 
Print this post

Hello everyone.
Sorry if the question is trivial, but I don't own yet my CMM2.
And sorry for my english too.
I was wondering what happens to the autorun option when I select OPTION RAM.
it is bypassed, ignored or what, in short, there is nothing in the ram at power on.
If so, it would be possible to load the old one, if present Autoexec.bas?
Second question, where I find a biography on peter and geoff, I have always been curious about the life of geniuses.
Thanks again for your time and talent.
 
     Page 1 of 3    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025