Hex-files spanning more than 64K not supported
Opened this issue · 5 comments
Having little knowledge on all things github, I will refrain from trying to commit stuff that'll break more than it fixes, and in stead upload information + test files to document an observed anomaly. I hope maintainers will find the below info useful:
The AVR ATmega2560 comes with 256KBytes of internal flash. However, trying to program in excess of 64K fails, as the expanded memory range record type 04 in intel Hex file format is not supported.
Run the attached code.py with the attached 128K test file on an ATmega2560 target and you will get the following output:
code.py output:
**************************************************************
* AVR ATmega2560 programmer *
* 02-11-2021 *
* Type 'g' to start: *g
**************************************************************
Working with an ATmega2560 CPU. Good!
Read lockbits: ['0xf7', '0x17', '0x4', '0x3f']
Erasing chip...
Re-read lockbits: ['0xf7', '0x17', '0x4', '0x3f']
Programming flash with Tester_128K.hex
Traceback (most recent call last):
File "code.py", line 68, in <module>
File "adafruit_avrprog.py", line 139, in program_file
File "adafruit_avrprog.py", line 425, in read_hex_page
RuntimeError: Unsupported record type 4 on line 1
Code done running.
Unsupported record type 4 on line 1
On line 1 of the HEX-file you find
:020000040000FA
which, according to https://en.wikipedia.org/wiki/Intel_HEX#Record_types
is an extended memory specifier allowing for up to 4GByte address range, of which we need up to 0x3FFFF.
Programming with a HEX file that uses Record type 4 is not supported.
hi ditto, if you can fix it, plz submit a PR ! :)
Don't know how to submit a PR. Busy working.
However, adding support for Record type 4 is done by adding something along these lines to read_hex_page()
if rec_type == 4:
file_state["ext_addr"] = int(line[9:13], 16) << 16
print("ExtLin addr: %05X" % file_state['ext_addr'])
continue
Difference from Record type 2 is that this one gets left-shifted 16 bits, not 4.
The easiest way to change code on GitHub and create a PR is through the web interface: https://docs.github.com/en/repositories/working-with-files/managing-files/editing-files
It is great for small changes.
The easiest way to change code on GitHub and create a PR is through the web interface: https://docs.github.com/en/repositories/working-with-files/managing-files/editing-files
It is great for small changes.
Cool. I've submitted two changes - both failed the 'black' check.
Now what?
@mafiltenborg there is a guide that covers the process of running the tools needed for the CI checks: https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/check-your-code this page covers the "all in one" approach with pre-commit that will do all of the checks. The next few pages cover each check individually if you want to do them seperately.
I am willing to help getting your PRs passing the CI if you'd like as well. As long as you selected the option "allow maintainers to add commits" (or similarly worded) I should have the access to push commits directly to your branches. If that is the case I can run the CI tools and push the results to those branches a little bit later on today.