Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for programming from intel hex files #37

Merged
merged 4 commits into from
Oct 23, 2015

Conversation

g-oikonomou
Copy link
Contributor

This will need rebased, but feel free to have a look at the feature. It is implemented in the last 4 commits of this pull.

Requires IntelHex and python-magic in site-packages.

With those packages available, we auto-detect the firmware type.

If those packages are not available, support for .hex will be disabled gracefully and the script will still work the way it does not for bin files.

@g-oikonomou g-oikonomou changed the title Do not merge: Add support for programming with an intel hex file Do not merge: Add support for programming from intel hex files Sep 15, 2015
@g-oikonomou g-oikonomou force-pushed the contrib/hex-support branch 2 times, most recently from e1f206f to 19f786f Compare September 16, 2015 11:48
@JelmerT
Copy link
Owner

JelmerT commented Sep 17, 2015

This looks like a very nice feature, and will make the script more useful!

Let me play around with it a little bit (and pull the 26xx support first), and we'll try to get it in there.

@JelmerT JelmerT self-assigned this Sep 17, 2015
@g-oikonomou g-oikonomou force-pushed the contrib/hex-support branch 3 times, most recently from ce369a1 to 8c143c9 Compare September 20, 2015 13:08
@g-oikonomou g-oikonomou changed the title Do not merge: Add support for programming from intel hex files Add support for programming from intel hex files Sep 20, 2015
@g-oikonomou
Copy link
Contributor Author

This is rebased and ready for consideration


If you want to be able to program your device from an intel hex file, you will also need to install the following:

* IntelHex: https://pypi.python.org/pypi/IntelHex
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add 'pip install intelhex' here? One less link to visit for the programmer that's less familiar with python.

@JelmerT
Copy link
Owner

JelmerT commented Oct 23, 2015

Sorry for the delay on these.

This PR seems to work great! Tested with 2.7 and 3.4. I made some small comments inline.

One thing I noticed: when you don't have the extra libs installed and you're trying to upload a hex file, it'll treat the file as a normal bin. If the file has the correct length it gets uploaded (but doesn't work of course), if not, you get an error about the size not being a multiple of 4. This behavior is to be expected, but there's never a hint to what is going wrong and how you can fix it (without activating verbose mode or looking at the readme).

Would it make sense to check the filename extension for .hex? And print the extra debug string in that case. Do most intel hex files use that extension?
Bringing down the verbosity of the extra debug string from 10 to 5 would be another solution, but this clutters the normal output of the script of course.
Making a note in the -h might be another option.

Any ideas? This is not a big issue btw, I'm willing to pull as-is.

@g-oikonomou g-oikonomou force-pushed the contrib/hex-support branch 2 times, most recently from a06e3de to 9dcedc3 Compare October 23, 2015 15:45
@g-oikonomou
Copy link
Contributor Author

@JelmerT thanks for the feedback. I've rebased this on top of current master and implemented a new logic:

  • First, we try to auto-detect file type through python-magic. If this fails, fall-back to checking the extension and warn if running with -V.
  • If the firmware is (or looks like) an Intel Hex, fail with a verbose error if IntelHex is not installed. Thus, we will no longer treat hex files as if they were a .bin.

I think the verb is always "program" in En-GB!

@g-oikonomou
Copy link
Contributor Author

Hmm hang on, this is buggy. Do not merge

@g-oikonomou
Copy link
Contributor Author

There we go, ready for consideration now!

@JelmerT
Copy link
Owner

JelmerT commented Oct 23, 2015

Works like a charm!

This is very good stuff, thanks @g-oikonomou !

JelmerT added a commit that referenced this pull request Oct 23, 2015
Add support for programming from intel hex files
@JelmerT JelmerT merged commit f24e852 into JelmerT:master Oct 23, 2015
@g-oikonomou g-oikonomou deleted the contrib/hex-support branch October 23, 2015 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants