[Microbit-Python] Maximum Size of Microbit Python Program?‏

Nevil Hunt nevil.hunt at hotmail.co.uk
Tue Jun 7 15:32:42 EDT 2016


Thanks David,
 
I now see how it is done, so, yes, the comments will use up precious memory space.
 
FYI I've just tried downloading the latest stand-alone mu editor to see if that allows me to write bigger programs but it doesn't. When a program gets over the same size and I hit "download" nothing happens (i.e. the yellow led doesn't start to flash) but if I delete a few lines of comments, the download  then works.
 
It sounds like you have already lodged the issue that exceeding the program size limit whether from the web interface or from the mu editor is silent - thanks.
It then leaves the other issue as to whether anything can be done to increase the size of program that can be run. My program is really of very modest size.
 
Anyone else got any thoughts on the matter?
 
 
Nevil
 
From: david at thinkingbinaries.com
Date: Tue, 7 Jun 2016 19:19:39 +0100
To: microbit at python.org
Subject: Re: [Microbit-Python] 	Maximum Size of Microbit Python Program?‏

Hi Neville,
I'm pretty sure the comments are included - the way it has always worked is that the web interface just appends a small binary header and then your python script to the embedded hex file it has cached in the browser. That way, no processing of the script is required. i.e. hex = [MICROPYTHONHEX + hex(BINARYHEADER) + hex(SCRIPT_INCLUDING_COMMENTS)]
Here is a Python version of the code that does that process:https://github.com/bbcmicrobit/micropython/blob/master/tools/makecombinedhex.py


I believe that all that Nicholas does in the web interface is the same, but in javascript, as it is easy.
That way, of course, just like all of the other editors, it is possible to completely recreate the source from a .hex file (as kids have a habit of not saving the source programs, or not keeping good records as to which source program generated which hex program).
So yes, comments take up space.
There is a pending question on the area51 proposed stackexchange site at the moment, where I ask how users can know in advance of flashing their micro:bit, whether the program will fit or not. There seems to be no obvious way in any of the editors of getting a read-out of how much of the available memory is used *before* you flash it and find it doesn't fit.

The other thing to find out is whether you are running out of flash memory, or running out of runtime memory. I would imagine that Damien's micropython parser ignores comments as it iterates through the flash version of the script file to parse it into bytecode in RAM - but you should check with Damien for clarification of how to work out if this is 'running out of flash' or 'running out of memory while parsing', as I can't find the code for that at the moment
Damien?



_______________________________________________
Microbit mailing list
Microbit at python.org
https://mail.python.org/mailman/listinfo/microbit 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/microbit/attachments/20160607/b94e4700/attachment.html>


More information about the Microbit mailing list