Pokitto SD loader to support Python script loading


I was thinking that the Pokitto SD loader could be quite easily to be improved to support the Python script file (*.py) loading

  • When e.g. the “mygame.py” file is selected in the loader it would search for the “python.bin” file in the SD card and would flash that instead
  • Before flashing it would write the string “mygame.py” to EEPROM (or in a file in SD?)
  • When Python.bin is started it gets the name of the script from EEPROM and imports the “mygame.py” file from SD.

Of course, compared to the frozen python files in ROM, there are more memory limitations for the scripts as we can use RAM only. But it would be suitable for simple games and programs that e.g. control the PEX pins (e.g. “Robot Car” :wink: ). In the “Python.bin” ROM image there could be included some example graphics and libraries (like PyGame based Sprite classes I am using in the Mars Attack game).

Edit: To improve the loader even further: it could recognize if the Python.bin is already flashed to the device and do not flash it again. It just updates EEPROM and restarts the device. That way you can load consecutive Python games very quickly. The recognition could be based some fixed ROM memory address where the Python.bin has some ID.


does python.bin have an internal filesystem?
theres no way to keep the selected string name in ram or something, or write it in a temp file on the sd card,
my concerns mostly on the eeprom accidentally overwriting some save of another game

yes, that is possible also

Come to think of it, how big is the execution engine?

If a game could live in RAM then it could just stream the code off the SD card and the flash could just contain an interpreter and compiler.
(I say ‘just’, that’s actually a hard thing to get it doing, but it would be very useful if that were possible.)

Say more on ram python programs. Any way to make hybrid apps
Or how well can it load/unload parts like for example having a master python program and separate “scenes scripts”

An interesting idea, but that kind of virtual memory would just be too slow for the games at least. Python will also always first compile the code to a bytecode before execution. The size of the bin is dependent of the “core” library modules included, which are coded in C. I would say bare essentials would be more than 150 kb total. I think Python loads the script only when “import” is called but I do not know if it is possible to unload it.

1 Like