Changing Data Endianness for Jetson TK1

I saw that the ARM Cortex A15 is a bi-endian processor. Has anybody changed data endianness before? My applications read in big endian data files so I need to switch the processor to big endian mode so that it can interpret the data. Also, will this break anything with the version of Linux that comes with the board? Any tips or references would be appreciated.

Thanks,
Chris

Changing the CPU endianness will affect absolutely everything starting from the kernel.

It’s common to have data files in different endianness (and e.g. networking commucation is often big endian even if the hosts are not) and it’s quite trivial to change the byte order when reading or writing the data. Check e.g. commands htonl, htons, ntohl, and ntohs. Depending on your date, you can create your own specialized function or macros for the conversion.

1 Like

I think I may have overthought this. My original assumption was that with the ARM processors’ bi-endianness, I could switch it between little and big endian mode. However, after doing some more research (courtesy of the gcc man page) there are some compiler flags which can be used which will inform the ARM processor to act as if it were a big or little endian processor.

-mlittle-endian
Generate code for a processor running in little-endian mode. This is the default for all standard configurations. 
-mbig-endian
Generate code for a processor running in big-endian mode; the default is to compile code for a little-endian processor. 
-mwords-little-endian
This option only applies when generating code for big-endian processors. Generate code for a little-endian word order but a big-endian byte order. That is, a byte order of the form ‘32107654’. Note: this option should only be used if you require compatibility with code for big-endian ARM processors generated by versions of the compiler prior to 2.8. This option is now deprecated.

Can anyone confirm my new assumption that compiling my CUDA program with -mbig-endian will allow my program to interpret big endian data files correctly and that the GPU will understand the big endian data?

Thanks,
Chris

I’m guessing here but I assume you can’t run part of applications in one endianness and part in another endianness.

As I stated already, the normal way to handle this is to convert the data when read or written.

1 Like