Try this one.
This version loads the P2 eval board Ok.
Thanks for the simple example of loading a file. Isn't there an ACK sent after the load completes though? How do I know it worked other than observing the program's behavior?
In my own P2 code I send my own "ACK" back to my loader to prove load success.
So the ROM loader itself doesn't send any sort of ACK? Should that be changed in the next version of the chip? It seems like the loaded program shouldn't have to complete the handshake.
I wonder if this loading scheme is really the best...
Seems like you should tell the P2 how many bytes are coming at least... And then a checksum at the end would be the usual way, right?
I don't really understand the base64 encode either... Doesn't seem to add any value to me... Ok, well I see that it can be used to detect bad data. Looks like the upper 2 bits of each byte have to be zero to be valid.
But, seems this ship has sailed. I guess one could always add their own error checking to their code... On the other hand, errors using FTDI chip (with it's own error detection) are probably very remote...
Try this one.
This version loads the P2 eval board Ok.
Thanks for the simple example of loading a file. Isn't there an ACK sent after the load completes though? How do I know it worked other than observing the program's behavior?
In my own P2 code I send my own "ACK" back to my loader to prove load success.
So the ROM loader itself doesn't send any sort of ACK? Should that be changed in the next version of the chip? It seems like the loaded program shouldn't have to complete the handshake.
I just read the documentation and the "~" character that the Python loader uses to end the program loading command bypasses checksum validation. You can also end the command with "?" which will result in a "." response if the load was success and the program started and "T" if the checksum failed. So it seems you can get a positive ACK. I withdraw my comment.
Try this one.
This version loads the P2 eval board Ok.
To augment this Python loader, here is minimal code to scan/list available COM ports on a PC
# Minimal Python code to scan all Serial ports, and report Port info
import serial.tools.list_ports
portlist = serial.tools.list_ports.comports() # List All ports can be useful to avoid conflicts
for sp in portlist:
if (sp.vid is not None) and (sp.pid is not None):
print(sp.device, sp.description, sp.manufacturer, sp.serial_number, hex(sp.vid), hex(sp.pid)) # Usually USB
else:
print (sp.device, sp.description, sp.manufacturer ) # Shorter list for motherboard ports.
# Results on PC with one USB COM port connected :
# COM1 Communications Port (COM1) (Standard port types)
# COM3 Intel(R) Active Management Technology - SOL (COM3) Intel
# COM19 USB Serial Port (COM19) FTDI P2EEI94A 0x403 0x6015
#
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
RESTART: C:\py_p2_loader\P2Eval_loader_1.1.py
HUBSET #1 Ok
HUBSET #2 Ok
Loading TXT ....complete
>>>
@Rayman ,
Have you tried the latest version of the loader in this thread? From your filename and text output above, it looks like it could be the original version...wouldn't expect that aspect to matter, but worth a try...
Works for me in both interactive mode (using IDLE 3.7) and command line mode.
Maybe Rayman's case is finding an older Python in command line, but works fine from loaded 3.7.2 ?
Perhaps Python loader should check/report the Python version it finds ?
Does python 2 come installed on Mac ?
I only installed one
A Python 2 version is installed, initially on macOS (Python 2.7.10 on macOS Mojave - 10.14.2).
An install of Python 3 can coexist with Python 2. Python as a command will exec Python 2... Python3 as a command launches Python 3. This link may help:
I was able to use the loader (P2Eval_loader_1.1.py) from avsa242's link in a post above. My Python3 is version: 3.6.5. In P2Eval_loader_1.1.py, I had to change 2 references to 'com5' to '/dev/cu.usbserial-P2EEI8V', which is what macOS names my P2 board (your's may differ).
I think I am somehow invoking python 2.7 even though using python launcher...
If I try running python3 from command line I get an error saying "No module named 'serial' ".
Think I need to fix the path somehow...
I really wish python2 wasn't on my system or that python3 would overwrite python2...
But, I just have to remember to type "python3".
I've begrudgingly become a Python user. My life was worse before I discovered "virtualenv" to manage the different versions of Python (I have to use three versions to get my day work done) as well as the plethora of differing library needs.
Although I'm primarily on either Linux or macOS, this tool apparently supports Windows, as shown here:
The hex form allows finer version testing, in one line, if early 3.x are found to have issues.
import sys
print('Python hexversion %s is in use.' % hex(sys.hexversion))
if sys.hexversion < 0x3000000:
print('Python Version 3.x required for py_p2loader')
Comments
Seems like you should tell the P2 how many bytes are coming at least... And then a checksum at the end would be the usual way, right?
I don't really understand the base64 encode either... Doesn't seem to add any value to me... Ok, well I see that it can be used to detect bad data. Looks like the upper 2 bits of each byte have to be zero to be valid.
But, seems this ship has sailed. I guess one could always add their own error checking to their code... On the other hand, errors using FTDI chip (with it's own error detection) are probably very remote...
I forgot the boot process was described in the Google Docs file now...
To augment this Python loader, here is minimal code to scan/list available COM ports on a PC
but that is proving more elusive.
I was hoping something in the COM port infos, could easily expand into the USB bMaxPower setting ?
Is this Python2 or Python3?
Did you use Python 3.x ?
File loaded was Invaders, works Ok.
Have you tried the latest version of the loader in this thread? From your filename and text output above, it looks like it could be the original version...wouldn't expect that aspect to matter, but worth a try...
Cheers
Wasn’t in interactive mode
Maybe try end = "" with spaes?
Maybe Rayman's case is finding an older Python in command line, but works fine from loaded 3.7.2 ?
Perhaps Python loader should check/report the Python version it finds ?
(Its easy to tell if you are in python3, because print requires parentheses in python 3
I only installed one
An install of Python 3 can coexist with Python 2. Python as a command will exec Python 2... Python3 as a command launches Python 3. This link may help:
https://legacy.python.org/getit/mac/
I was able to use the loader (P2Eval_loader_1.1.py) from avsa242's link in a post above. My Python3 is version: 3.6.5. In P2Eval_loader_1.1.py, I had to change 2 references to 'com5' to '/dev/cu.usbserial-P2EEI8V', which is what macOS names my P2 board (your's may differ).
Python 2 gives the following error:
If I try running python3 from command line I get an error saying "No module named 'serial' ".
Think I need to fix the path somehow...
Had to do "python3 -m pip install pyserial" to get serial module installed.
Now, I can run from command line with "python3 P2Eval_loader_1.1.py"
I really wish python2 wasn't on my system or that python3 would overwrite python2...
But, I just have to remember to type "python3".
Can finally load up the VGA example with a Mac.
You have to go to the bottom and change sp.port. Mine is like this:
I've begrudgingly become a Python user. My life was worse before I discovered "virtualenv" to manage the different versions of Python (I have to use three versions to get my day work done) as well as the plethora of differing library needs.
Although I'm primarily on either Linux or macOS, this tool apparently supports Windows, as shown here:
http://timmyreilly.azurewebsites.net/python-pip-virtualenv-installation-on-windows/
Good luck!
https://stackoverflow.com/questions/9079036/how-do-i-detect-the-python-version-at-runtime
Which has various version tests.
I suspect the serial module will be Python version specific, making a universal version impractical ?
However, should be easy to add a version test, of one of the many forms...
The hex form allows finer version testing, in one line, if early 3.x are found to have issues.