Giter VIP home page Giter VIP logo

bincopy's Introduction

About

Mangling of various file formats that conveys binary information (Motorola S-Record, Intel HEX, TI-TXT, Verilog VMEM, ELF and binary files).

Project homepage: https://github.com/eerimoq/bincopy

Documentation: https://bincopy.readthedocs.io

Installation

pip install bincopy

Example usage

Scripting

A basic example converting from Intel HEX to Intel HEX, SREC, binary, array and hexdump formats:

>>> import bincopy
>>> f = bincopy.BinFile("tests/files/in.hex")
>>> print(f.as_ihex())
:20010000214601360121470136007EFE09D219012146017E17C20001FF5F16002148011979
:20012000194E79234623965778239EDA3F01B2CA3F0156702B5E712B722B7321460134219F
:00000001FF

>>> print(f.as_srec())
S32500000100214601360121470136007EFE09D219012146017E17C20001FF5F16002148011973
S32500000120194E79234623965778239EDA3F01B2CA3F0156702B5E712B722B73214601342199
S5030002FA

>>> print(f.as_ti_txt())
@0100
21 46 01 36 01 21 47 01 36 00 7E FE 09 D2 19 01
21 46 01 7E 17 C2 00 01 FF 5F 16 00 21 48 01 19
19 4E 79 23 46 23 96 57 78 23 9E DA 3F 01 B2 CA
3F 01 56 70 2B 5E 71 2B 72 2B 73 21 46 01 34 21
q

>>> print(f.as_verilog_vmem())
@00000100 21 46 01 36 01 21 47 01 36 00 7E FE 09 D2 19 01 21 46 01 7E 17 C2 00 01 FF 5F 16 00 21 48 01 19
@00000120 19 4E 79 23 46 23 96 57 78 23 9E DA 3F 01 B2 CA 3F 01 56 70 2B 5E 71 2B 72 2B 73 21 46 01 34 21

>>> f.as_binary()
bytearray(b'!F\x016\x01!G\x016\x00~\xfe\t\xd2\x19\x01!F\x01~\x17\xc2\x00\x01
\xff_\x16\x00!H\x01\x19\x19Ny#F#\x96Wx#\x9e\xda?\x01\xb2\xca?\x01Vp+^q+r+s!
F\x014!')
>>> list(f.segments)
[Segment(address=256, data=bytearray(b'!F\x016\x01!G\x016\x00~\xfe\t\xd2\x19\x01
!F\x01~\x17\xc2\x00\x01\xff_\x16\x00!H\x01\x19\x19Ny#F#\x96Wx#\x9e\xda?\x01
\xb2\xca?\x01Vp+^q+r+s!F\x014!'))]
>>> f.minimum_address
256
>>> f.maximum_address
320
>>> len(f)
64
>>> f[f.minimum_address]
33
>>> f[f.minimum_address:f.minimum_address + 1]
bytearray(b'!')

See the test suite for additional examples.

Command line tool

The info subcommand

Print general information about given binary format file(s).

$ bincopy info tests/files/in.hex
File:                    tests/files/in.hex
Data ranges:

    0x00000100 - 0x00000140 (64 bytes)

Data ratio:              100.0 %
Layout:

    0x100                                                      0x140
    ================================================================

The convert subcommand

Convert file(s) from one format to another.

$ bincopy convert -i ihex -o srec tests/files/in.hex -
S32500000100214601360121470136007EFE09D219012146017E17C20001FF5F16002148011973
S32500000120194E79234623965778239EDA3F01B2CA3F0156702B5E712B722B73214601342199
S5030002FA
$ bincopy convert -i binary -o hexdump tests/files/in.hex -
00000000  3a 32 30 30 31 30 30 30  30 32 31 34 36 30 31 33  |:200100002146013|
00000010  36 30 31 32 31 34 37 30  31 33 36 30 30 37 45 46  |60121470136007EF|
00000020  45 30 39 44 32 31 39 30  31 32 31 34 36 30 31 37  |E09D219012146017|
00000030  45 31 37 43 32 30 30 30  31 46 46 35 46 31 36 30  |E17C20001FF5F160|
00000040  30 32 31 34 38 30 31 31  39 37 39 0a 3a 32 30 30  |02148011979.:200|
00000050  31 32 30 30 30 31 39 34  45 37 39 32 33 34 36 32  |12000194E7923462|
00000060  33 39 36 35 37 37 38 32  33 39 45 44 41 33 46 30  |3965778239EDA3F0|
00000070  31 42 32 43 41 33 46 30  31 35 36 37 30 32 42 35  |1B2CA3F0156702B5|
00000080  45 37 31 32 42 37 32 32  42 37 33 32 31 34 36 30  |E712B722B7321460|
00000090  31 33 34 32 31 39 46 0a  3a 30 30 30 30 30 30 30  |134219F.:0000000|
000000a0  31 46 46 0a                                       |1FF.            |

Concatenate two or more files.

$ bincopy convert -o srec tests/files/in.s19 tests/files/convert.s19 -
S00F000068656C6C6F202020202000003C
S325000000007C0802A6900100049421FFF07C6C1B787C8C23783C600000386300004BFFFFE5F2
S32500000020398000007D83637880010014382100107C0803A64E80002048656C6C6F20776F13
S30B00000040726C642E0A003A
S32500000100214601360121470136007EFE09D219012146017E17C20001FF5F16002148011973
S32500000120194E79234623965778239EDA3F01B2CA3F0156702B5E712B722B73214601342199
S5030005F7
S70500000000FA

The pretty subcommand

Easy to read Motorola S-Record, Intel HEX and TI TXT files with the pretty subcommand.

https://github.com/eerimoq/bincopy/raw/master/docs/pretty-s19.png

https://github.com/eerimoq/bincopy/raw/master/docs/pretty-hex.png

https://github.com/eerimoq/bincopy/raw/master/docs/pretty-ti-txt.png

The fill subcommand

Fill empty space between segments. Use --max-words to only fill gaps smaller than given size.

$ bincopy info tests/files/in_exclude_2_4.s19 | grep byte
    0x00000000 - 0x00000002 (2 bytes)
    0x00000004 - 0x00000046 (66 bytes)
$ bincopy fill tests/files/in_exclude_2_4.s19 filled.s19
$ bincopy info filled.s19 | grep byte
    0x00000000 - 0x00000046 (70 bytes)

Contributing

  1. Fork the repository.

  2. Install prerequisites.

    pip install -r requirements.txt
    
  3. Implement the new feature or bug fix.

  4. Implement test case(s) to ensure that future changes do not break legacy.

  5. Run the tests.

    make test
    
  6. Create a pull request.

Similar projects

These projects provides features similar to bincopy:

bincopy's People

Contributors

asgeroverby avatar bessman avatar danarcana avatar eerimoq avatar jrast avatar jvroutak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bincopy's Issues

[Question] Why is len(binfile) != len(binfile.as_binary())?

I haven't looked into this too deeply, but just thought I'd ask. How come the length of the binfile object is not equal to the length of the bytes returned by binfile.as_binary()?

For example, if you added this statement to the regression test code, the test will fail.

--- a/tests/test_bincopy.py
+++ b/tests/test_bincopy.py
@@ -397,6 +397,7 @@ class BinCopyTest(unittest.TestCase):
         self.assertEqual(binfile.minimum_address, 0)
         self.assertEqual(binfile.maximum_address, 184)
         self.assertEqual(len(binfile), 170)
+        self.assertEqual(len(binfile), len(binfile.as_binary()))

         # Dump with start address beyond end of binary.
         self.assertEqual(binfile.as_binary(minimum_address=512), b'')

Could you explain the difference between the two?

Thanks!

Chunk.__len__ should return length of data

import bincopy
hexdata = bincopy("myfile.hex")
print(len(next(hexdata.segments.chunks(size=32))))
2

I find this surprising. Anyone doing len(chunk) probably wants the length of its data member, not the fact that it's a two-tuple. I propose implementing Chunk like so:

class Chunk(namedtuple("Chunk", ["address", "data"])):  # Or _Chunk, depending on outcome of #35
    def __len___(self):
        return len(self.data)

While this would technically change the API, I argue that it is extremely unlikely to break anything; anyone doing len(chunk) almost certainly means len(chunk.data).

Bincopy Header does not allow non-ascii values

Hello,

Due to our needs of our project, the headers could have binary values that represents Integer values over than ASCII such as 0x88, but the library does not allow it rasing an exception:

`bincopy.py in as_srec(self, number_of_data_bytes, address_length_bits)
684
685 if self._header:
--> 686 encoded_header = self._header.encode('utf-8')
687 record = pack_srec('0', 0, len(encoded_header), encoded_header)
688 header.append(record)

UnicodeDecodeError: 'ascii' codec can't decode byte 0x88 in position 0: ordinal not in range(128)
`

Could you modify the library to not enconde in UTF-8 and allow any kind of value to not limit only string headers?

Many thanks!!
Ferran.

First chunk is misaligned if segment has non-aligned start address

records = """
    :02000004000AF0
    :10B8440000000000000000009630000007770000B0
"""
hexfile = bincopy.BinFile()
hexfile.add_ihex(records)
align = 8
chunks = hexfile.segments.chunks(size=16, alignment=align)
assert not any(c.address % align for c in chunks)

IMO, the first chunk should be padded such that it is also aligned.

Change behaviour of `as_binary` when data is not present?

For my use-case it would be useful for as_binary to raise an Exception if I ask for data which is not contained in the files I have added.

At the moment, if padding is None, it is converted to a default of 0xFF . I would request the following (which admittedly changes the API):

make the default parameters more explicit:

def as_binary(self,
                  minimum_address=None,
                  maximum_address=None,
                  padding=0xFF):

and then alter the behaviour of padding==None to raise a RuntimeException if there is any data requested which does not 'exist'. Would this be acceptable?

as_binary() raises a MemoryError

Hi there,

I am running the following script :

import bincopy 

f = bincopy.BinFile("Test_2.hex")
print(f.as_binary())

I get the following error :
image

I noticed that when I reduce the size of the binary file, it works. (the original binary is around 26 KB)

Thanks in advance

intel hex Extended Linear Address

There is an issue with outputting type 4 addresses that are > 0xffff, they create address that have 5 digits, and are invalid in the format. i.e. have a segment with address as 0x1000e, and it will be output as two records, one the Extended Linear Address record which is correct, but then the data record has all 5 didgits of the address. example:

read and then write the following text:

:020000040001F9
:04000E00A4CFFFDD9F

you will get an error on the write due to the CRC routine getting an odd number of digits:

:020000040001F9
:041000E00A4CFFFDD9F note address is 0x1000e

the issue is in the as_ihex function:

def as_ihex(self, size=32, address_length=32):
"""Return string of Intel HEX records of all data.

    """

    data_address = []
    extmaximumed_address = -1

    for address, data in self.segments.iter(size):
        address //= self.word_size_bytes

        if address_length == 32:
            if ((address >> 16) & 0xffff) > extmaximumed_address :
                extmaximumed_address = ((address >> 16) & 0xffff)

I added this fix as a hack for my situation, but would not work for subsequent segments that are in the same address space.

                address = address & 0xffff   

end of hack

                packed = pack_ihex(4,
                                   0,
                                   2,
                                   binascii.unhexlify('%04X'
                                                      % extmaximumed_address))
                data_address.append(packed)
        else:
            raise Error('unsupported address length %d'
                             % address_length)

        data_address.append(pack_ihex(0, address, len(data), data))

But the function also assumes that all address are in sorted order, which I do not believe is the case for all Intel hex files, unless you are sorting them as you insert into the list, I may have missed that.

Package permissions issue

I'm having a weird issue that, to be honest, I can't imagine how it's a bincopy issue but it doesn't appear to affect any other packages. When our admin bootstraps a Windows machine he installs bincopy (and several other packages). Later, a user runs python and attempts to run import bincopy and gets an ImportError. Logging in as admin, I can successfully perform the import.

We suspected it was a permissions error so we tested our theory by changing the owner of the Libs directory to the present user (recursively) and ensuring proper permissions were set, but it made no difference. We then logged in as admin and removed bincopy (pip uninstall bincopy), then reinstalled as the user account (pip install bincopy) and everything worked fine. In both cases bincopy was installed into C:\Python27\Libs\site-packages which is in the search path for both users.

I looked through the package and can't find anything that should be affected by installing user. Have you seen anything like this? I have been installing and using bincopy under Linux for a while without any such issues.

Missing option for byte width

SRecord reading fails on hex files targeting devices with 16-bit bytes (such as TI Piccolo), where 4 hex digits increment address by 1. Below is a beginning of such file:

S00600004844521B
S2083E80000123ABCD9D
S2223E8002761B0005ABBDA8BDA0BDC2BDC3BDFE04FF6929425616761F002C0E01761FB8
S2223E80110227FF3D1E00761F002C0E02761F0227FF3D1E10761F002C0E03761F022702

See how 0123ABCD changes address from 3E8000 to 3E8002.

Would be nice to have a way to select byte width.

Feature request: Support Microchip HEX format

The Microchip HEX format is identical to the Intel format, except the addresses in the HEX file are twice the actual machine addresses. This is because Microchip's PIC architecture typically has wider instructions than its machine word. For example, the PIC24 uses 16-bit words but 24-bit instructions.

This can be handled by parsing the file as Intel format with a word size of one byte, and then changing the word size to two bytes after parsing is done.

I can make a PR if you think this would be a useful feature. It could be enabled with an optional microchip=False argument to BinFile.

Incorrect error check condition?

Hi
I was checking the code in bincopy.py and I think the if condition used to check for non-overlapping segments in remove_data is incorrect:

if ((minimum_address >= self.maximum_address)
            and (maximum_address <= self.minimum_address)):

This will only be true in the rare case of trying to remove a zero-length segment from a zero-length segment at the same address which is not what was intended. I think the and condition should be changed to or i.e.

if ((minimum_address >= self.maximum_address)
            or (maximum_address <= self.minimum_address)):

Problem with loading ELF file produced by CodeWarrior toolchain

Hello Erik,

I am not able to parse ELF file produced by CodeWarrior. I get the following error: bincopy.AddDataError: data added to a segment must be adjacent to or overlapping with the original segment data

However, I am able to parse it using the pyelftools.

Attached is the ELF file and corresponding binary created by the objcopy.
files.zip

Thanks, Marek

How to convert from HEX to binary?

Hi Erik,
This is a very cool tool, but the instruction for converting a file from (for example) Intel HEX to binary is missing. How do you do that?
Cheers,

Extract data by address in S19

Thanks for the useful library.

Is it possible to extract part of Data by start address from S19 and convert to binary.
because in my S19 there are jumps in addresses and there is no need to convert all of them to binary and add 0xFF in such jumped places.

17.14.3: Missing some test files in sdist tarball

Hi! When trying to package 17.14.3 for Arch Linux I had two failing tests, as there are test files missing in the sdist tarball:

=================================== FAILURES ===================================
_______________________ BinCopyTest.test_add_elf_blinky ________________________

self = <tests.test_bincopy.BinCopyTest testMethod=test_add_elf_blinky>

    def test_add_elf_blinky(self):
        bf = bincopy.BinFile()
>       bf.add_elf_file('tests/files/evkbimxrt1050_iled_blinky_sdram.axf')

tests/test_bincopy.py:1777:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <bincopy.BinFile object at 0x7fa750e43e80>
filename = 'tests/files/evkbimxrt1050_iled_blinky_sdram.axf', overwrite = False

    def add_elf_file(self, filename, overwrite=False):
        """Open given ELF file and add its contents. Set `overwrite` to
        ``True`` to allow already added data to be overwritten.

        """

>       with open(filename, 'rb') as fin:
E       FileNotFoundError: [Errno 2] No such file or directory: 'tests/files/evkbimxrt1050_iled_blinky_sdram.axf'

bincopy.py:1161: FileNotFoundError
_________________________ BinCopyTest.test_add_elf_gcc _________________________

self = <tests.test_bincopy.BinCopyTest testMethod=test_add_elf_gcc>

    def test_add_elf_gcc(self):
        bf = bincopy.BinFile()
>       bf.add_elf_file('tests/files/elf/gcc.elf')

tests/test_bincopy.py:1788:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <bincopy.BinFile object at 0x7fa750e43ac0>
filename = 'tests/files/elf/gcc.elf', overwrite = False

    def add_elf_file(self, filename, overwrite=False):
        """Open given ELF file and add its contents. Set `overwrite` to
        ``True`` to allow already added data to be overwritten.

        """

>       with open(filename, 'rb') as fin:
E       FileNotFoundError: [Errno 2] No such file or directory: 'tests/files/elf/gcc.elf'

bincopy.py:1161: FileNotFoundError
=========================== short test summary info ============================
FAILED tests/test_bincopy.py::BinCopyTest::test_add_elf_blinky - FileNotFound...
FAILED tests/test_bincopy.py::BinCopyTest::test_add_elf_gcc - FileNotFoundErr...
========================= 2 failed, 91 passed in 1.22s =========================

Promote _Segments, _Segment, _Chunk to public API

It would be nice to be able to use these types in annotations:

write_data(data: bincopy.Chunk) -> None:
    ...

instead of having to write:

write_data(data: bincopy._Segment._Chunk) -> None:
    ...

which is both harder on the eyes and makes various linters complain about accessing protected members.

Can't load srec file with python 3.2.1

It is not possible to load a srec file with python 3.2.1:

bincopyfile_obj = bincopy.BinFile()
bincopyfile_obj.add_srec_file(target_path)

The Problem:

    address = int(record[4:4+width], 16)
    data = binascii.unhexlify(record[4 + width:4 + 2 * size - 2]) # Throws Exception: 'str' does not support the buffer interface
    actual_crc = int(record[4 + 2 * size - 2:], 16)

The docs (Python 3.x) of binascii describes the behavior:
"a2b_* functions accept Unicode strings containing only ASCII characters. Other functions only accept bytes-like objects (such as bytes, bytearray and other objects that support the buffer protocol)."

Invalid ELF file parsing

Hello,
I have found an issue within parsing of ELF file generated for ARM Cortex M4 MCU generated by GCC compiler (IAR has same issue).

The issue is following:
As a ELF file has a lot of sections that should be placed in ROM area of MCU memory map, and one is BSS section (part of initial data that should be copied into RAM after MCU start) that is place after last .text section, but the BINCOPY placed it into address where will be copied after startup.

To simplify it:
image

The bin copy place this section on 0x1fff_0000 address instead of ~0x0000_9400.

To proof that I generate from GCC as ELF file (dev_hid_mouse_freertos.elf) as Intel HEX file(dev_hid_mouse_freertos.hex) both those file I convert by bincopy into S19 files(dev_hid_mouse_freertos_elf.s19, dev_hid_mouse_freertos_hex.s19) and compare that (See picture above). And to be sure that ELF file is correct I also convert ELF file by "arm-none-eabi-objcopy.exe" from GNU Tools and get binary file that's is using just right lower addresses (dev_hid_mouse_freertos.bin).

I guess that there is some issue with using of final address of data after MCU startup (any mark of reallocation in ELF probably) and address where is stored in ROM.
bincopy issue.zip

Thank you
Petr

save the object bincopy.BinFile

I want to extract the data from S19 file.
I decided to convert it to binary in this way (as it is done in:https://stackoverflow.com/questions/24110121/how-to-manipulate-srec-file/45465864#45465864)

import bincopy
f = bincopy.BinFile()
f.add_srec_file("New.s19")
f.as_binary()

Then I want to save this object and extract data part.
I use .write to save but it has "TypeError: write() argument must be str, not BinFile" error.

with open('out.txt', 'w') as w:
    w.write(f)

How should i save it and what is your idea?
Thanks

Unit test fails

One test fails on 64-bit Windows 10 host & 32-bit Python:

C:\GIT\bincopy>git log -1
commit 2f83b6f1570cb96bb925b416b631112c0ab4283e (HEAD -> master, tag: 14.4.0, origin/master, origin/HEAD)
Author: Erik Moqvist <[email protected]>
Date:   Mon Jul 16 08:08:12 2018 +0200

    Version 14.4.0.

C:\GIT\bincopy>git status
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        .project
        .pydevproject

nothing added to commit but untracked files present (use "git add" to track)

C:\GIT\bincopy>python2
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> ^Z


C:\GIT\bincopy>python3
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> ^Z

Tests seem to fail:

C:\GIT\bincopy>python2 setup.py test
...
======================================================================
FAIL: test_binary (tests.test_bincopy.BinCopyTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\git\bincopy\tests\test_bincopy.py", line 245, in test_binary
    padding=b'\x00'), fin.read())
AssertionError: bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00:2001:20010000214601360121470136007EFE09D219012146017E17C20001FF5F16002148011979\r\n:20012000194E79234623965778239EDA3F01B2CA3F0156702B5E712B722B7321460134219F\r\n:00000001FF\r\n') != '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00:2001:20010000214601360121470136007EFE09D219012146017E17C20001FF5F16002148011979\n:20012000194E79234623965778239EDA3F01B2CA3F0156702B5E712B722B7321460134219F\n:00000001FF\n'

----------------------------------------------------------------------
Ran 61 tests in 2.170s

FAILED (failures=1)
C:\GIT\bincopy>python3 setup.py test
running test
...
======================================================================
FAIL: test_binary (tests.test_bincopy.BinCopyTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\git\bincopy\tests\test_bincopy.py", line 245, in test_binary
    padding=b'\x00'), fin.read())
AssertionError: bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x[205 chars]r\n') != b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00[188 chars]FF\n'

----------------------------------------------------------------------
Ran 61 tests in 1.912s

FAILED (failures=1)
Test failed: <unittest.runner.TextTestResult run=61 errors=0 failures=1>
error: Test failed: <unittest.runner.TextTestResult run=61 errors=0 failures=1>

fill empty space

There is fill(value=None, max_words=None)
that: Fills all empty space between segments
Is there any way to fill empty space between chunks?

convert S19 to S19 file (add empty space and create new S19 file)

how can we fill empty space in S19 file that is less than 4000 bytes and then create new S19 file?
the issue is how to write?

f = bincopy.BinFile("file1.s19")
print(f.info())
f.fill(value=b'\xFF', max_words=4000)   #4000)
print(f.info())
print(type(f))
with open("file2.s19") as s19:
    f.write(f.as_srec())

The error is:
f.write(f.as_srec())
AttributeError: 'BinFile' object has no attribute 'write'

thanks

Invalid section from ELF file

The BINCOPY create invalid section from ELF file. The ELF file is created in NXP MCUXpresso compiler.

The SREC from BINCOPY contains additional (probably irrelevant) data
Observation: the output contains some data at 0x8000000, while the image is located at 0x80002000.

Used OBJCOPY to validate result:
arm-none-eabi-objcopy.exe -O srec evkbimxrt1050_iled_blinky_sdram.axf evkbimxrt1050_iled_blinky_sdram.srec
Use BINCOPY to unify S record output to simplify comparison:
bincopy convert -i srec -o srec .\evkbimxrt1050_iled_blinky_sdram.srec .\evkbimxrt1050_iled_blinky_sdram.s19

Observation: no data at 0x8000000, the code starts at 0x80002000

Procedure to reproduce:

  • Convert ELF file by bincopy:
    bincopy convert -i elf -o srec .\evkbimxrt1050_iled_blinky_sdram.axf converted.s19

  • Compare result with evkbimxrt1050_iled_blinky_sdram.s19 created by "arm-none-eabi-objcopy.exe"
    bincopy.zip

Do we have function like change s19 content?

Hello thanks for your great job, we already use bincopy in our projects. it works very well!
my question were do we have a function that can change the content in a specific address, and update to a new s19 file
for example
old
S32580040320FFFFFFFF0000100000010000000000000000000000000000000000000000000026
new
S32580040320FFFFFFFF00001000000FFFF000000000000000000000000000000000000000003C
hope your respond.

Enhancement: support full Verilog hex format

Hi,

you seem to only support the specialised TI Verilog hex format and I'd like to see support for the base format. I've recently had to implement my own package as I couldn't find anything outside of srec_cat that could read/write this format.

Did you have any plans to add support for Verilog hex? I think it would be fairly easy move your TI specific loading/dumping as wrappers around a Verilog hex loader/dumper.

My implementation is here: https://github.com/idex-biometrics/veriloghex/blob/main/veriloghex/veriloghex.py

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.