RodeX27
Posts: 2
Joined: Thu May 23, 2019 2:56 pm

Any Tutorial to Create a Cross Compiler for ARM? Rpi3

Thu May 23, 2019 3:17 pm

As the title says Some tutorial or documentation to do the cross compiler to program without operating system the Raspberry pi 3 which is x64, what happens is that I am developing hardware similar to the Raspberry pi board but in this case I use an ARM Cortex A53 Like the raspberry pi 3

then as the raspberry pi is already a done board, I wanted to develop in the small kernel that does basic functions such as printing text on the screen and reading a keyboard (only tests)

Can you give me a guide to start?


I wanted to write this kernel for this board to make sure it works
BCM2837

In another case that I can not get it I will be designing with one of them:
x64 cortex A72

https://www.digikey.com/product-detail/ ... ND/8344025
or microprocessor from texas instrument am3558 (who has it BeagleBoard from Texas instrument)
this 32 bits
https://www.digikey.com/product-detail/ ... ND/4073874

LdB
Posts: 1143
Joined: Wed Dec 07, 2016 2:29 pm

Re: Any Tutorial to Create a Cross Compiler for ARM? Rpi3

Thu May 23, 2019 4:44 pm

Little bit confused if you are trying to build AARCh32 or AARCH64 so I will give you both for the Cortex8A families

AARCH32 CROSS COMPILER:
https://developer.arm.com/open-source/g ... downloads
Has versions for Windows, Mac and 64bit versions of Linux.

AARCH64 CROSS COMPILER
https://releases.linaro.org/components/ ... rch64-elf/
Versions for Windows and linux but working out which from name is fun :-)
Windows version is gcc-linaro-7.4.1-2019.02-i686-mingw32_aarch64-elf.tar.xz

There is a sticky for baremetal resources
viewtopic.php?f=72&t=72260

RodeX27
Posts: 2
Joined: Thu May 23, 2019 2:56 pm

Re: Any Tutorial to Create a Cross Compiler for ARM? Rpi3

Fri May 24, 2019 1:03 pm

Good morning! :)
thanks for answering, the computer where I will be compiling is x64, is not it a problem if I install 32bit compiler versions?

another question :!:
for now I just want to compile to run it on the raspberry pi 3 B (BCM2837) x64 It would be correct to use your source, right? since I researched and I think I'm a bit lost since others download other packages. hehe Excuse my english I'm Spanish speaking :D ..

jahboater
Posts: 4474
Joined: Wed Feb 04, 2015 6:38 pm

Re: Any Tutorial to Create a Cross Compiler for ARM? Rpi3

Fri May 24, 2019 2:29 pm

RodeX27 wrote:
Fri May 24, 2019 1:03 pm
Good morning! :)
thanks for answering, the computer where I will be compiling is x64, is not it a problem if I install 32bit compiler versions?

another question :!:
for now I just want to compile to run it on the raspberry pi 3 B (BCM2837) x64 It would be correct to use your source, right? since I researched and I think I'm a bit lost since others download other packages. hehe Excuse my english I'm Spanish speaking :D ..
It is "aarch64", not "x64" on the Pi by the way.

Most OS's on the Pi have an excellent C/C++ compiler included - and all the usual development tools, so you may find you don't need to cross-compile (I never do).

LdB
Posts: 1143
Joined: Wed Dec 07, 2016 2:29 pm

Re: Any Tutorial to Create a Cross Compiler for ARM? Rpi3

Fri May 24, 2019 3:16 pm

Not sure that is an option jahboater he wants a small kernel which I assume means no linux on the Pi and he obviously wants to compile on a PC.

Anyhow RodeX27 yes the 32bit windows executable works fine on x64 windows versions .. I personally have Windows10 64 bit.
It is a command line compiler on windows, you just use any IDE to edit your files and just have a command prompt open to compile.

For a windows make executable which saves having to install cygwin junk
https://sourceforge.net/projects/ezwinports/files/
download "make-4.2.1-without-guile-w32-bin.zip" and set the extracted executable on the command line enviroment path

If you want to test if it all works here is an example to try. Just download, extract and then Edit the makefile with a text editor and change the path to match the directory where you put GCC compiler. Then type "make Pi3-64" on the command line in the directory ... without the " " characters obviously :-)
https://github.com/LdB-ECM/Raspberry-Pi-Multicore

dwelch67
Posts: 954
Joined: Sat May 26, 2012 5:32 pm

Re: Any Tutorial to Create a Cross Compiler for ARM? Rpi3

Fri Jun 14, 2019 3:20 pm

https://github.com/dwelch67/build_gcc I have scripts to build arm (aarch32) and aarch64 cross compilers on linux. I used to maintain them for windows as well but dont boot windows but once every few years. would use mingw32 back then, cygwin would have worked, but now windows has some bash thing dont know how good it is or what it does.

if for linux then if you have the right tools to build gnu stuff in the first place then you can build a cross compiler.

mine are for bare metal which is what you sound like you are doing initially. and I try to keep up with the cutting edge of gcc and binutils.

if you look at my pi tutorials you can also use an aarch64-linux-.... build for bare metal by avoiding the operating system dependencies. which means if nothing else you can run linux on one pi to not-cross-compile but natively compile for another board under test, or do the sd card dance with one pi. 32 bit or 64 bit.

User avatar
Gavinmc42
Posts: 3182
Joined: Wed Aug 28, 2013 3:31 am

Re: Any Tutorial to Create a Cross Compiler for ARM? Rpi3

Wed Jun 26, 2019 11:14 am

You can make a cross compiler on the Pi's.
It took 13 hours last time I tried.

If you want to compile for aarch64 you can grab Sakaki's Gentoo64 which is ready to go.
Native compiling is better and can be faster.
Sakaki even has a Raspbian spawn spin that can do 32 and 64bit ARM compiling.
https://github.com/sakaki-/raspbian-nspawn-64
Pretty sure it is using some sort of Linux magic that will take me a decade to understand :oops:

x64 generally refers to x86_64 ie Intel/AMD.
A53/A72 aarch64 is Pi3 and Pi4.

If you don't want to compile your own compiler
https://gcc.gnu.org/gcc-9/
https://gcc.gnu.org/install/index.html

There are pre made binaries, a google will find those.
They will look something like these
ttps://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

User avatar
DavidS
Posts: 4308
Joined: Thu Dec 15, 2011 6:39 am
Location: USA
Contact: Website

Re: Any Tutorial to Create a Cross Compiler for ARM? Rpi3

Sat Jun 29, 2019 1:13 pm

Many have already answered your first question about the cross compiler. What Linux distro are you running on the x86 computer (or other OS [eg. BSD, Haiku OS, MenuetOS, AROS, other x64 OS])?

Now as to your questions about putting text on the screen and accessing the keyboard.

First putting text on the screen:
You are going to have to first get to a booted state and access the mailbox protocal to setup the graphics framebuffer, then learn to draw into the framebuffer (no text mode in the Raspberry Pi, text has to be drawn), then you will need some kind of font renderer to actually display the text (fixed width bitmapped font is the easiest).

You will likely draw a lot of graphics before you actually implement a font rendering system to display text.

As to accessing the Keyboard:
You will need to get a USB stack up and running, as there is no pre provided way to access the keyboard on the Raspberry Pi. This one is simplified if you do not mind using restrictively GPL licensed code as USPi is a good easy to use USB stack for bare metal programming on the Raspberry Pi.

If you study the existing USB stacks, maybe you can end up learning enough to write your own.

Back to text rendering
Once you get far enough that you are starting to get a good grip on the Raspberry Pi HW, using the DMA's with stride to display a fixed width bitmapped font on screen is fairly simple to accomplish, this will reduce the time the CPU spends writing to the framebuffer.

Also the DMA channels can be used to accomplish many other graphics functions including:
  • Any straight vertical or horizontal line.
  • Most other line drawing (look at Bresenham's Run Segment Line Drawing algorithm, and think about 2 DMA channels with stride).
  • Rectangle fill.
  • Rectangular area copy (drawing a bitmapped image into a rectangular view port on the screen).
  • Line filling of any shaped region (so long as the start/end x pos is known in each row).
  • And many more.
Of course if you get that far you can also get to the point of playing with using OpenGL and similar interfaces on the GPU in bare metal, giving GPU accelerated graphics.
RPi = The best ARM based RISC OS computer around
More than 95% of posts made from RISC OS on RPi 1B/1B+ computers. Most of the rest from RISC OS on RPi 2B/3B/3B+ computers

Return to “Bare metal, Assembly language”