How to cross compile static dtc for ARM ?

As we seen in our previous post, “How to Compile and Install device-tree-compiler (DTC) On Ubuntu”, we could compile DTC ( Device Tree Compiler ) for Host machine i.e. Ubuntu

In this post, we will describe what changes are required to get the DTC compiled to execute on embedded targets such as ARM. Since executing dtc on embedded targets is required very few times, we will get it statically compiled so we dont need to resolve the runtime library linking issues.

$ git clone git://git.kernel.org/pub/scm/utils/dtc/dtc.git

Assuming you have the toolchain and your GCC is something like “arm-linux-gnueabi-gcc” OR you can install the toolchain as,

$ sudo apt-get install gcc-arm-linux-gnueabi

once you installed toolchain, modify Makefile as,

$ cd dtc
$ vim Makefile
CC=arm-linux-gnueabi-gcc
CFLAGS = -g -Os $(SHAREDLIB_CFLAGS) -Werror $(WARNINGS) -static
$ file dtc
dtc: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, for GNU/Linux 3.2.0, BuildID[sha1]=024c7cafca22f3477e9266a293f98fcd82deb5c9, with debug_info, not stripped

Note: while compilation, you may get an error as below, but you can ignore this, as our main aim was to get DTC statically compiled which has been done with above changes and steps.

/usr/lib/gcc-cross/arm-linux-gnueabi/7/../../../../arm-linux-gnueabi/bin/ld: attempted static link of dynamic object `libfdt/libfdt-1.6.0.so'
collect2: error: ld returned 1 exit status
Makefile:343: recipe for target 'fdtget' failed
make: *** [fdtget] Error 1

Ignore above error.


lynxbee_ezoic

Subscribe with Valid Email Id to receive updates in Inbox. ( Secured by Google FeedBurner )

   


1 thought on “How to cross compile static dtc for ARM ?”

Leave a Comment

Android Android Applications Android Build system Android Commands Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development & Build Development, Debugging and Performance Tools Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web design and development Website Hosting Wordpress Yocto / Bitbake / Openembedded