Closed C47D closed 6 years ago
My pull request is going to take some extra work to merge in command line because of conflicts GitHub wasn't able to handle automatically, which might be why it wasn't merged although arachnidlabs thought it looked good.
You're welcome to give it a try with my fork in the meantime. I think I cleaned up a lot of the python 2/3 compatibility issues, as well as some bugfixes for handling PSoC 5. However, I mainly tested in my use case which was a PSoC 5 board receiving the image over CANBus, so I'd hope but can't guarantee it would work better for you.
Yes, i was confused because i saw your PR on both the opened and closed PRs.
Just did the same procedure using your fork and and still getting the following error:
> py -3 -m cyflash --serial COM9 --serial_baudrate 57600 --canbus_wait 10 Bootloadable.cyacd
Entering bootload.
Initialising bootloader.
Silicon ID 0x2e161069, revision 0.
Verifying row ranges.
Array 0: first row 28, last row 255.
Array 3: first row 0, last row 255.
Checking metadata.
Cannot read metadata from device: Command unsupported on target device
Starting flash operation.
Unhandled error: The data is not of the proper form
So there's the same message as before:
Cannot read metadata from device: Command unsupported on target device
It can be caused because the metadata bug stated on the README file, or i'm doing something wrong, it's the first time i work on PSoC bootloaders, thanks for the help tho.
When you build and program the boatload in psoc, do you have the metadata command enabled on the bootloader component of the top design?
If the metadata command isn't enabled, then that result is normal. It seems to be when it gets to the flashing operation either the pyflash or psoc gets a packet it doesn't like.
Also, I didn't realize before but requiring the canbus wait or echo should only matter is the can implementation. I'll try and take a look at that tomorrow.
In the meantime, 4 months ago the last pull request added enabled can bus support. Can you pull a version of this repo from before that was merged in and see if it worked before the canbus code was added? It may be a bug in the serial implementing that was added with the canbus code.
Also, are you using any if the security or checksum configurations?
Sean
On Wed, Oct 26, 2016, 17:54 Carlos Diaz notifications@github.com wrote:
Yes, i was confused because i saw your PR on both the opened and closed PRs.
Just did the same procedure using your fork and and still getting the following error:
py -3 -m cyflash --serial COM9 --serial_baudrate 57600 --canbus_wait 10 Bootloadable.cyacd Entering bootload. Initialising bootloader. Silicon ID 0x2e161069, revision 0. Verifying row ranges. Array 0: first row 28, last row 255. Array 3: first row 0, last row 255. Checking metadata. Cannot read metadata from device: Command unsupported on target device Starting flash operation. Unhandled error: The data is not of the proper form
So there's the same message as before:
Cannot read metadata from device: Command unsupported on target device
It can be caused because the metadata bug stated on the README file, or i'm doing something wrong, it's the first time i work on PSoC bootloaders, thanks for the help tho.
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/arachnidlabs/cyflash/issues/13#issuecomment-256473953, or mute the thread https://github.com/notifications/unsubscribe-auth/AB3o_mXQR8ccqwZ4ga42DqaG6mKuAQDNks5q374LgaJpZM4Kgthk .
Hi, no i haven't enabled the Get Metadata option because i was following the AppNote AN68272 and it didn't have the that option enabled. After reading your response i enabled it, and using the "official" tool the bootload process is successfull. Using cyflash i got:
>py -3 -m cyflash --serial COM9 --serial_baudrate 57600 --canbus_wait 1 Bootloadable_NEW.cyacd
Entering bootload.
Initialising bootloader.
Silicon ID 0x2e161069, revision 0.
Verifying row ranges.
Array 0: first row 26, last row 255.
Array 3: first row 0, last row 255.
Checking metadata.
Traceback (most recent call last):
File "...\Python35\lib\site-packages\cyflash-1.6-py3.5.egg\cyflash\protocol.py", line 120, in __init__
struct.error: unpack requires a bytes object of length 56
During handling of the above exception, another exception occurred:
... in __init__
cyflash.protocol.InvalidPacketError: Cannot unpack packet data 'b'0\x11\x1a\x00\x00\x19\x00\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00q\xa3\xa6\xdd\xeam\xeex\xee\xf8\x94Q\xb7b\x0b\x1b\xf5d\xa2Z\xb7\xe2\xd5^\xfe\xda<:\x94\xfd'': unpack requires a bytes object of length 56
About the canbus_wait, i saw the source and that and another can options are on a argparse.mutualexclusiongroup, i think there´s the main problem, but i haven't a lot of experience with python or argparse.
I will try to go back to a commit before the canbus were supported and report the results here, i didn't thought about that option.
And about the configurations, i'm using the default component configuration, only changed the communication componet to UART. The following options are enabled:
Thanks for the help, it's first time i use the bootloader feature. Carlos
Hi, cloned the PR #6 and installed it using python 2.7, got the following:
> cyflash --serial COM9 --serial_baudrate 57600 Bootloadable_NEW.cyacd
Initialising bootloader...
Entered bootloader! Silicon ID 0x2e161069, revision 0.
Verifying row range...
Array 0: first row 26, last row 255.
Array 3: first row 0, last row 255.
Ok!
Checking metadata...
Traceback (most recent call last):
File "C:\Python27\Scripts\cyflash-script.py", line 11, in <module>
load_entry_point('cyflash==1.1', 'console_scripts', 'cyflash')()
File "build\bdist.win-amd64\egg\cyflash\bootload.py", line 329, in main
File "build\bdist.win-amd64\egg\cyflash\bootload.py", line 172, in bootload
File "build\bdist.win-amd64\egg\cyflash\bootload.py", line 251, in check_metadata
AttributeError: 'error' object has no attribute '__name__'
At least it seems that now i'm able to flash the Bootloadable file, but unable to get the metadata, as said before i'm new to python, have to investigate about this. Carlos
Hi Carlos, the Metadata error is a bug in the PSoC code generation, it generates the metadata size as 0x56 instead of decimal 56, so in the Canbus versions it throws an error. To correct it you need to modify the generated bootloader.h file and fix the metadata size macro.
However, the metadata shouldn't be required, so I would disable it again in the bootloader application for now (It allows you to see the current firmware version on a device to check if it needs to update or not, but isn't needed for the basic bootload process).
I'd shut off the metadata and try that python 2 implementation.
I'm afraid I don't have a setup where I can easily test serial bootloading to try and replicate and bugfix myself. I can try and look into one this weekend if I find time.
Do you still have the same issue with the current master?
Hi,
I installed the current master using python setup.py install
also did a new UART Bootloadable project to test it (since i deleted the original projects), the application works as expected with the UART Bootloader host provided by Cypress.
Testing with cyflash:
$ cyflash --serial=COM6 --serial_baudrate=115200 059_Bootloadable.cyacd
The error log:
Traceback (most recent call last):
File "C:\Users\Xwx47\AppData\Local\Programs\Python\Python36\Scripts\cyflash-script.py", line 11, in <module>
load_entry_point('cyflash==1.7', 'console_scripts', 'cyflash')()
File "C:\Users\Xwx47\AppData\Local\Programs\Python\Python36\lib\site-packages\pkg_resources\__init__.py", line 572, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "C:\Users\Xwx47\AppData\Local\Programs\Python\Python36\lib\site-packages\pkg_resources\__init__.py", line 2749, in load_entry_point
return ep.load()
File "C:\Users\Xwx47\AppData\Local\Programs\Python\Python36\lib\site-packages\pkg_resources\__init__.py", line 2402, in load
return self.resolve()
File "C:\Users\Xwx47\AppData\Local\Programs\Python\Python36\lib\site-packages\pkg_resources\__init__.py", line 2408, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "C:\Users\Xwx47\AppData\Local\Programs\Python\Python36\lib\site-packages\cyflash-1.7-py3.6.egg\cyflash\__init__.py", line 1, in <module>
ModuleNotFoundError: No module named 'bootload'
It seems more related to cyflash than the bootloader application.
Projects attached. 059_Bootloadable.cyprj.Archive01.zip 059_Bootloader.cyprj.Archive01.zip
Sorry for the spam,
I can run cyflash now, i'm using python on a windoze 10 box:
Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
I had to modify the init.py file, from:
impot bootload
import cyadc
import protocol
to:
from . impot bootload
from . import cyadc
from . import protocol
I'm not familiar with python but this seems to solve it.
After that i can successfully run cyflash:
$cyflash --version
usage: cyflash [-h] (--serial PORT | --canbus BUSTYPE)
[--serial_baudrate BAUD] [--canbus_baudrate BAUD]
[--canbus_channel CANBUS_CHANNEL] [--canbus_id CANBUS_ID]
[--canbus_echo | --canbus_wait CANBUS_WAIT] [--timeout SECS]
[--downgrade | --nodowngrade] [--newapp | --nonewapp] [--psoc5]
[--key KEY] [-cs CHUNK_SIZE] [--dual-app] [-v]
[logging_config] image
cyflash: error: the following arguments are required: image
but can't upload the bootloadable app:
$ cyflash --serial=COM6 --serial_baudrate=115200 059_Bootloadable.cyacd
Entering bootload.
Initialising bootloader.
Silicon ID 0x2e161069, revision 0.
Verifying row ranges.
Array 0: first row 26, last row 255.
Array 3: first row 0, last row 255.
Checking metadata.
Cannot read metadata from device: Command unsupported on target device
Starting flash operation.
Traceback (most recent call last):
File "C:\Users\Xwx47\AppData\Local\Programs\Python\Python36\Scripts\cyflash-script.py", line 11, in <module>
load_entry_point('cyflash==1.7', 'console_scripts', 'cyflash')()
File "C:\Users\Xwx47\AppData\Local\Programs\Python\Python36\lib\site-packages\cyflash-1.7-py3.6.egg\cyflash\bootload.py", line 396, in main
File "C:\Users\Xwx47\AppData\Local\Programs\Python\Python36\lib\site-packages\cyflash-1.7-py3.6.egg\cyflash\bootload.py", line 263, in bootload
File "C:\Users\Xwx47\AppData\Local\Programs\Python\Python36\lib\site-packages\cyflash-1.7-py3.6.egg\cyflash\bootload.py", line 355, in write_rows
File "C:\Users\Xwx47\AppData\Local\Programs\Python\Python36\lib\site-packages\cyflash-1.7-py3.6.egg\cyflash\protocol.py", line 411, in program_row
NameError: name 'xrange' is not defined
Leading to xrange is not defined in python 3
EDIT: I investigated a little to fix the compatibility problems, and found this page Cheat Sheet: Writing Python 2-3 compatible code
Solved with #23
$ cyflash --serial=COM6 --serial_baudrate=115200 .\059_Bootloadable.cyacd
Entering bootload.
Initialising bootloader.
Silicon ID 0x2e161069, revision 0.
Verifying row ranges.
Array 0: first row 26, last row 255.
Array 3: first row 0, last row 255.
Checking metadata.
Cannot read metadata from device: Command unsupported on target device
Starting flash operation.
Uploading data (6/7)
Uploading data (7/7)
Device checksum verifies OK.
Rebooting device.
Total running time 5.16s
Hi, firstly thanks for develop FOSS for PSoC. I just clone your repository to test the AN68272 from Cypress using the CY8CKIT-059 board, already test it with the host tool that Cypress provide and the bootloading is sucessfull, but when i try to upload the .cyacd file with your tool it give the following error:
Then i used:
I read in a PR about the super() function, so i tried using python 3
So i guess this is not 5LP compatible ;(
Thanks again for the tool. Carlos
[OT] Saw a couple of PR that improve a lot of stuff on the tool, those will be merged?