- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm able to program the board using PSoC creator and programmer. Meanwhile, if I use python given in example on psoc family 4, it gives me this random error "Program All using COM-object interface only
Failed! CMSIS-DAP/VENDOR command 0x84 returned Error or unknown status 0x82."
Anyone have any idea on how to solve it? Incase you need to look at the script, I'm attaching the file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello.
You can insert some simple print statements into the python script. That way you'll know (roughly) where things go wrong.
I'd put a print as the first line at each function call. Good for showing progress.
I couldn't identify where "CMSIS-DAP/VENDOR command 0x84 returned Error or unknown status 0x82." was coming from. It's an error return code, but from which function call? It's not in the python script, it's not a return code from COM (at least not from what I read in the manual). Maybe it's from PSoC Programmer?
I'm not a python person so that's about all the advice I can offer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As I inspected a little into it and it's coming from initializing function. I'm using miniprog4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
def InitializePort():
global m_sLastError
#Setup Power On
pp.SetPowerVoltage("3.3")
hResult = pp.PowerOn()
hr = hResult[0]
print(hResult)
m_sLastError = hResult[1]
print("success 6")
if (not SUCCEEDED(hr)): return hr
print("sucess 7")
#Set protocol, connector and frequency
hResult = pp.SetProtocol(enumInterfaces.SWD)
hr = hResult[0]
m_sLastError = hResult[1]
if (not SUCCEEDED(hr)): return hr
pp.SetProtocolConnector(0) #5-pin connector
pp.SetProtocolClock(enumFrequencies.FREQ_03_0) #3.0 MHz clock on SWD bus
return hr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How far down into the print statements does it get to before the error is detected?
It would be helpful to discover when/where the error message, "CMSIS-DAP/VENDOR command 0x84 returned Error or unknown status 0x82" is generated.
Is there something amiss with Miniprog4 when "pp.SetProtocol" is called?
You'd think if this code works with Miniprog3, it should work with Miniprog4 as well.
Based on python "main", the error text is put into variable "m_sLastError", (based on my limited python understanding).
Keep hunting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It stops at print('success6') line. This "hResult = pp.PowerOn()" line has been causing issues.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello.
Looking at this a bit more and comparing to COM examples (C#), the problem might be the preceding line, pp.SetPowerVoltage("3.3"). All the examples I found have used the return result code and tested it for failure.
Try changing those first few lines from:
#Setup Power On
pp.SetPowerVoltage("3.3")
hResult = pp.PowerOn()
hr = hResult[0]
print(hResult)
m_sLastError = hResult[1]
print("success 6")
if (not SUCCEEDED(hr)): return hr
To this:
#Setup Power On
hResult = pp.SetPowerVoltage("3.3")
hr = hResult[0]
print(hResult[0])
print(hResult[1])
m_sLastError = hResult[1]
if (not SUCCEEDED(hr)): return hr
hResult = pp.PowerOn()
hr = hResult[0]
print(hResult[0])
print(hResult[1])
m_sLastError = hResult[1]
print("success 6")
if (not SUCCEEDED(hr)): return hr
I also noticed you deleted the line from "main" (now named "programBoard"):
pp = win32com.client.Dispatch("PSoCProgrammerCOM.PSoCProgrammerCOM_Object")
Is this not needed? I don't know, I'm not a python person.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I really appreciate your help with getting to figure out the bug here. The solution didn't work.
To answer your question to: pp = win32com.client.Dispatch("PSoCProgrammerCOM.PSoCProgrammerCOM_Object")
There are two lines:
pp = win32com.client.Dispatch("PSoCProgrammerCOM.PSoCProgrammerCOM_Object") is non version dependant
pp = win32com.client.Dispatch("PSoCProgrammerCOM.PSoCProgrammerCOM_Object.14") is version dependant. I have used both and you will see me using version dependant line
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi.
Well, that's a bummer!
Can you pass along the 2 print results after the hResult = pp.SetPowerVoltage("3.3") and after the hResult = pp.PowerOn().
This next suggestion is not permanent, but worth a try for debugging.
Comment out the few lines for hResult = pp.PowerOn() and the IF not SUCCEEDED stuff.
The intention is to see how far it gets before breaking.
We still need to find where "CMSIS-DAP/VENDOR command 0x84 returned Error or unknown status 0x82" is generated.
edit: I've attached a ppcli script to test your MiniProg4. Open the file with a text editor, read the comments, type the commands, and let me know what you observe. If this works, then there's some other issue with COM commands since ppcli commands are the same (just a slightly different format).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A couple more tries and here are the results for it. I already tried your suggestion before you suggested it. The results are still the same. It doesn't go very far. I initially thought it was the programmer but when I disconnect the board from power it wasn't failing on initialization. There must be something with the board. I'm not suspecting anything wrong with the board since I'm able to program it with the psoc programmer. I don't know what's wrong tbh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi.
That's interesting about the powering. Can you describe how you power the board.
When using PSoC Programmer, do you tell it that you're using external power? If that's the case, then you should not be turning power ON in python script.
When you commented out the PowerON stuff, how far into Initialization did it get?
Can you run the ppcli commands and pass along the results.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It wouldn't go far. It fails to get the serial number of the board. One of that ord() at line 450. I have attached the ppcli commands hope this makes sense.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi.
Thanks for running ppcli script commands. It tells me PowerOn command is successfully executed when Miniprog4 is instructed to do so via a script. So, Miniprog4 should also execute the PowerOn command via Python script. Why it doesn't execute this command is still unknown.
Can you attach your Python script file. I only have your original zip file and it only goes to line 420. I expect the addition of print statements has made it grow in length. And that's okay. Or, copy a few lines from Python script surrounding the offending ord()... line.
BTW, in Python, what does "ord" do? I don't know Python coding.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi.
The zip file is good to post.
You mentioned in previous msg that python script stopped when it fetches serial number of board. What line is that? You can just paste those couple of lines into reply and I'll find them in zip file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
def CheckHexAndDeviceCompatibility():
global m_sLastError
listResult = []
result = 0
hResult = pp.PSoC4_GetSiliconID()
print(pp.PSoC4_GetSiliconID())
hr = hResult[0]
chipJtagID = hResult[1]
m_sLastError = hResult[2]
if (not SUCCEEDED(hr)):
listResult.append(hr)
listResult.append(result)
return listResult
hResult = pp.HEX_ReadJtagID()
hr = hResult[0]
hexJtagID = hResult[1]
m_sLastError = hResult[2]
if (not SUCCEEDED(hr)):
listResult.append(hr)
listResult.append(result)
return listResult
result = 1
for i in range(0, 4):
if (i == 2): continue #ignore revision, 11(AA),12(AB),13(AC), etc
if(ord(hexJtagID[i]) != ord(chipJtagID[i])):
result = 0
break
listResult.append(0)
listResult.append(result)
return listResult
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This seems to be the function that fails.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello.
I don't know Python coding, but the array element assignments don't make any sense to me. So, when the comparison is done, it's not comparing apples to apples.
Replace this line:
chipJtagID = hResult[1]
with the following 4 lines:
chipJtagID[0] = hResult[0]
chipJtagID[1] = hResult[1]
chipJtagID[2] = hResult[2]
chipJtagID[3] = hResult[3]
And, replace this line:
hexJtagID = hResult[1]
with the following 4 lines:
hexJtagID[0] = hResult[0]
hexJtagID[1] = hResult[1]
hexJtagID[2] = hResult[2]
hexJtagID[3] = hResult[3]
If you want to put them into a 'for' loop, you can. I just don't know the correct syntax to do it properly.
Let me know the results.
BTW, do you see this printed out: print(pp.PSoC4_GetSiliconID())
If yes, what values are printed on monitor?
edit: also add a print statement following the line:
hResult = pp.HEX_ReadJtagID()
That would be (I think this is right):
print(pp.HEX_ReadJtagID())