Skip to content

add ncs36510 fib and trim generation #6657

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

Merged
merged 1 commit into from
May 7, 2018

Conversation

tsailer
Copy link
Contributor

@tsailer tsailer commented Apr 17, 2018

Description

This pull request adds the NCS36510 specific bits to the codeblocks exporter.

NCS36510 needs a trim block and a fib block containing a CRC over the binary. In the mbed build system, the ELF object file is first linked, then converted to hex, and then a python function NCS36510TargetCode.ncs36510_addfib (in NCS36510TargetCode.ncs36510_addfib) adds the necessary trim and fib blocks to the hex file only.

For an IDE, this is confusing. One would have to start gdb with the ELF file, to get the symbol table, but then write the HEX file to the FLASH, because the ELF file wouldn't contain the fib and trim blocks.

So the codeblocks exporter strategy is somewhat different. If the target is NCS36510 (detected by the post_binary_hook), then two additional files ncs36510fib.c and ncs36510trim.c, created by the exporter, are linked to the ELF file. These two files put the necessary data (a dummy CRC only) into sections named .fib and .trim, the linker script puts them at the correct addresses. An external program then computes the proper CRC and updates it using a mechanism similar to objcopy --update-section. That way, the ELF file contains all information and no hex file is needed.

Pull request type

[ ] Fix
[X] Refactor
[ ] New target
[ ] Feature
[ ] Breaking change

@adbridge
Copy link
Contributor

@theotherjimmy we are still awaiting your review on this PR, could you please do so asap. Thanks

Copy link
Contributor

@theotherjimmy theotherjimmy left a comment

Choose a reason for hiding this comment

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

This is a bit unusual, but it works for me

@theotherjimmy
Copy link
Contributor

@tsailer Would it be significantly more difficult to make the same changes to the post-build script? Would it be worth it?

@tsailer
Copy link
Contributor Author

tsailer commented May 2, 2018

@theotherjimmy I thought about it, but then decided, because it would either mean another tool dependency (the ncs36510updatefib), or forking objdump/objcopy multiple times. Furthermore, as far as I see, the whole mbed infrastructure is geared very much at using the hex file and not the elf file, so I thought it wouldn't be worth it...

@theotherjimmy
Copy link
Contributor

Thanks for the detailed explanation. We need to add the external tool dependency to https://github.com/ARMmbed/Handbook/blob/new_engine/docs/tools/toolchains/export_to_third_party.md

@0xc0170
Copy link
Contributor

0xc0170 commented May 3, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented May 3, 2018

Build : SUCCESS

Build number : 1901
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/6657/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented May 3, 2018

@mbed-ci
Copy link

mbed-ci commented May 3, 2018

# finally, generate the project file
super(CodeBlocks, self).generate()

@staticmethod
def clean(project_name):
for ext in ['cbp', 'depend', 'layout']:
remove("%s.%s" % (project_name, ext))
for f in ['openocd.log']:
for f in ['openocd.log', 'ncs36510fib.c', 'ncs36510trim.c']:
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noting that this line looks interesting.

@cmonr cmonr merged commit ab81b61 into ARMmbed:master May 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants