Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 15:27 26 Jun 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 : PicoMite V6.00.02 betas

     Page 21 of 23    
Author Message
ville56
Senior Member

Joined: 08/06/2022
Location: Austria
Posts: 220
Posted: 01:23pm 06 Mar 2025
Copy link to clipboard 
Print this post

Peter,

basically the SEEK now works on A:, but the time required for I/O is a bit strange:

      drive a:           drive b:

seek     0.2 mSec           1.1 mSec
print   36   mSec           0.2 mSec
input    0.3 mSec           0.2 mSec
flush   65 - 200   mSec     3.7 mSec          

i would expect drive A: to be faster than drive B: but it's just the other way round and I/O on A: is incredible slow.

I will later make some experiments with sequential reads/writes.

But thank you for bringing the SEEK/write I/O functionality to drive A:, maybe the time behavior can be adjusted as well.

Gerald

P.S. added input (read) times
Edited 2025-03-06 23:31 by ville56
                                                                 
73 de OE1HGA, Gerald
 
ville56
Senior Member

Joined: 08/06/2022
Location: Austria
Posts: 220
Posted: 02:00pm 06 Mar 2025
Copy link to clipboard 
Print this post

tested now plain sequential writes/flushes ... performance is about same as with random writes and flushes.


Gerald
                                                                 
73 de OE1HGA, Gerald
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5001
Posted: 02:33pm 06 Mar 2025
Copy link to clipboard 
Print this post

Peter,

I have no idea what you fixed, but the 2040 VGA version b16 does not run any programs.
A variety of errors.
If-then statements that complain, no "then" (which is clearly there)
A single "Do" on a line gives a syntax error.

Try Geoff's "Blocks", or "Circle" , "FM" (filemanager), or Petscii Robots, or... just any program.

I am back at b14

Volhout
Edited 2025-03-07 00:38 by Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10170
Posted: 02:37pm 06 Mar 2025
Copy link to clipboard 
Print this post

You need to think about how flash memory works. Erasing flash sets it to all ones. Writing sets the relevant bits from 1 to 0. Flash memory has a 4Kbyte page size. So to overwrite a  single zero to a one it needs to read 4K, erase the 4k, and then write the 4K back with the changed data.
Now, your use of seek, as Tom indicates, sets NULL (zero) to bytes before the new position. This means to overwrite you need to erase for every write. I suspect LittleFS isn't clever enough to compare the stored data with your write to see if it needs to erase.
See the chip timing below for more info - in particular look at the sector erase time and the page (256 bytes) write times

 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10170
Posted: 02:48pm 06 Mar 2025
Copy link to clipboard 
Print this post

  Quote  I have no idea what you fixed, but the 2040 VGA version b16 does not run any programs.
A variety of errors.
If-then statements that complain, no then (which is clearly there)
A single "Do" on a line gives a syntax error.


Works for me testing petrobot/solar_eclipse. Suggest you clear flash or load a different firmware variant and try again. As always without a list of options set there is little more I can add
Edited 2025-03-07 00:50 by matherp
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5001
Posted: 03:11pm 06 Mar 2025
Copy link to clipboard 
Print this post

Hi Peter,

I cleared the system, VGA design 2.
The problem is different now, but related to the latest filemanager from twofingers (fm01998) that I use to browse b: drive and start programs.
This filemanagers is stored in a flash slot and started from commandline (F9).

When I run programs from this filemanager is causes problems (actually I cannot even select a folder anymore now, it does not accept <enter>).

When I use javavi's latest filemanager (fm123) it still works (from a flash slot).

So this may partly be an issue of the filemanager coding. But fact is that this filemanager fm01998 worked correct on b14 (used it for 2 days). Something has changed. I will report to twofingers.

Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10170
Posted: 03:13pm 06 Mar 2025
Copy link to clipboard 
Print this post

If anything is loaded in a flash slot you may need to reload it from source as tokens may have changed
Edited 2025-03-07 01:13 by matherp
 
ville56
Senior Member

Joined: 08/06/2022
Location: Austria
Posts: 220
Posted: 03:13pm 06 Mar 2025
Copy link to clipboard 
Print this post

OK Peter, I understand, it is the erase time. I have completely underestimated this. Buffred writes are still fast, so what I've intentionally tested with constant flushing was the worst case of course. But it is good to be reminded again that writing to flash is really slow.

Gerald
                                                                 
73 de OE1HGA, Gerald
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5001
Posted: 03:24pm 06 Mar 2025
Copy link to clipboard 
Print this post

@Peter,

I have no knowledge of the core of the filemanager.
So I am guessing..
Could this have a relation to the new END function (perform some tasks when program ends).

Anyway, b16 is not working with the filemanager fm01998 in flash. And b14 is.

Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10170
Posted: 03:47pm 06 Mar 2025
Copy link to clipboard 
Print this post

b16 updated 15:47 UTC  to fix possible issue
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5001
Posted: 04:32pm 06 Mar 2025
Copy link to clipboard 
Print this post

Peter,

EDIT

Running out of time now, but my diagnosis so far is that blocks with sound is causing the issue. It is playing a very large WAV file, sampled from a game boy.

When started from the file manager, The wav file plays at normal speed first, then slows down (half speed ?), then the mmbasic program crashes. Typically before the wrap around. The WAV file is on SD card.

And when it crashes the system, you get all kinds of problems, that are only solved with a re-boot. I had also problems with other programs, but only after blocks was played, and that was on the top of the lies (tried first).

So b16 could be valid, only the sound in blocks (and I wrote those 4 lines of code) are the problem.

EDIT

Volhout
Edited 2025-03-07 02:54 by Volhout
PicomiteVGA PETSCII ROBOTS
 
bfwolf
Regular Member

Joined: 03/01/2025
Location: Germany
Posts: 75
Posted: 04:51pm 06 Mar 2025
Copy link to clipboard 
Print this post

  ville56 said  Peter,

basically the SEEK now works on A:, but the time required for I/O is a bit strange:

      drive a:           drive b:

seek     0.2 mSec           1.1 mSec
print   36   mSec           0.2 mSec
input    0.3 mSec           0.2 mSec
flush   65 - 200   mSec     3.7 mSec          


LittleFs generally has a relatively poor performance when writing.

This is due to the design! LittleFs is designed to survive power cuts and crashes without errors. This is why it works with transactions. If a new empty flash block is needed for writing, the next invalid block found is only deleted immediately before writing.

In addition, when writing in the middle of an existing file, all existing data behind the current position up to the end of the file is rewritten during a "commit" (e.g. by flushing) to ensure that the file is in a valid state again.

LittleFs does not perform garbage collection in the background by itself! This can be added, but this means programming effort.

If you have use cases such as a circular buffer, LittleFs is certainly not the first choice. SPIFFS, for example, is suitable for this.

However, you can also distribute the circular buffer across several shorter files of a fixed size to achieve something like this. E.g. "values.1.dat", "values.2.dat", "values.3.dat", ...

@Peter: I'm sure, i didn't tell you something new?

bfwolf
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1556
Posted: 04:58pm 06 Mar 2025
Copy link to clipboard 
Print this post

@Harm
Have you tried reducing the number of files that can be loaded - setting it back to 200 (from RMax=300)?

You could also change the execution mechanism for running programs.
Edited 2025-03-07 03:00 by twofingers
causality ≠ correlation ≠ coincidence
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10170
Posted: 05:00pm 06 Mar 2025
Copy link to clipboard 
Print this post

Based on a very quick scan I would try replacing the RUN command with EXECUTE "RUN
 
twofingers

Guru

Joined: 02/06/2014
Location: Germany
Posts: 1556
Posted: 05:04pm 06 Mar 2025
Copy link to clipboard 
Print this post

  matherp said  Based on a very quick scan I would try replacing the RUN command with EXECUTE "RUN


Or
End "run "+chr$(34)+TEMP$+chr$(34)


??
Edited 2025-03-07 03:13 by twofingers
causality ≠ correlation ≠ coincidence
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5001
Posted: 06:43pm 06 Mar 2025
Copy link to clipboard 
Print this post

Peter,

Look at previous post, It is related to PLAY WAV from SD card.
Is it related to the recent heap increase for 2040.

Volhout
Edited 2025-03-07 04:45 by Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10170
Posted: 06:49pm 06 Mar 2025
Copy link to clipboard 
Print this post

I thought you said it was broken on b14 as well just a different symptom?
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5001
Posted: 07:33pm 06 Mar 2025
Copy link to clipboard 
Print this post

B14 has different symptoms, but also fails after running initially.

B14 crashes after running for 30 seconds or so.
B16 returns with an error,  returns to commandline, and appears to work, but errors on every successive program. Until a cpu restart.

The B14 I used is the one that has heap of 100k, I do not have a prior version with heap 96k.

Volhout
Edited 2025-03-07 05:34 by Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10170
Posted: 08:00pm 06 Mar 2025
Copy link to clipboard 
Print this post

have you tried the different approaches to RUN?
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10170
Posted: 09:43am 07 Mar 2025
Copy link to clipboard 
Print this post

  Quote  It seems to me I understand how things work, but if sub could be run from library multiple times withour RUN/EDIT in between (commands which would reset and clear vars) should`n entering multiple times SUB reset vars too ?

I see some ways how to work around this, but still need advice how I could solve this problem, before making something unnecesarry complicated.


Have you tried just using ON ERROR SKIP before the DIM statement? In general you shouldn't DIM variables in subroutines precisely because of this issue.
 
     Page 21 of 23    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025