GNU Arm toolchain

This page will describe the procedure for compiling a GNU ARM toolchain. We will build a toolchain consisting of:

  • GCC 4.8.2
  • Binutils 2.21.1
  • Newlib 1.19

Getting the buildscript

First of all, create a directory you want to use for building the toolchain

we are going to do this under the root folder

so open up a new terminal window

and enter the following command:

mkdir gnuarm

0

next we need to enter that directory u do this by entering the following command:

cd gnuarm

1

and press Enter

u should now be here

2

next we need to download a script called gnu-arm-build.3.sh

so in the terminal window enter the following command:

wget www.pentestingshop.com/gnu-arm-build.3.sh

3

and press Enter

u should then get this

4

After that’s done we are going to install some dependencies

So do not close this terminal window!

Dependencies

In order to build the toolchain, you will need to install the following packages (assuming you’re using a Debian-based distribution):

sudo apt-get install build-essential libgmp3-dev libmpfr-dev libx11-6 libx11-dev texinfo flex bison libncurses5 \
  libncurses5-dbg libncurses5-dev libncursesw5 libncursesw5-dbg libncursesw5-dev zlibc zlib1g-dev libmpfr4 libmpc-dev

so in that same terminal window paste the command described up here

like seen here

5

after that u can press Enter

and you will see this happening

6 7

so now here type Y and press Enter again

8

and should then see the following pass by

9 10 11

Now that this is done we are going to prepare everything for installing

Preparation

In the same terminal window where gnu-arm-build.sh is we are going to create the following directories:

mkdir build install src

So copy the command and paste it

like seen here

12

Now that u pasted it u can press Enter

this command will create 3 folders (build, install and src)

next we need to download 3 files but they should come into the directory src

so to enter a directory using a terminal we use the following command:

cd src

like seen here

13

now that u entered this command press Enter

u should now be in the directory src

like seen here

14

Now that we are in the directory we need to download the needed sources.

u do this by entering the following commands:

wget http://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.bz2

so copy this and paste it in the terminal window

like seen below

15

now that it is pasted u can press Enter

and will see this

16

next we need to download 2 more files here

so the next command u need to enter is:

wget http://ftp.gnu.org/gnu/binutils/binutils-2.21.1a.tar.bz2

so also copy this line and paste it in the terminal window

like shown here

17

now that this is done press Enter

and u should then see the following happening

18

now that this is done we need to download just one more file

for the last file u need to copy and paste the following command into the terminal window:

wget ftp://sources.redhat.com/pub/newlib/newlib-1.19.0.tar.gz

like seen here

19

after that’s done u can press Enter

and should see this

20

now that all the downloading is done we need to go back a directory

to go back a directory in a terminal window we need to use the following command:

cd ..

like seen here

21

and then press Enter

you should then be back in the gnuarm directory

like seen here

22

Now

Building the toolchain

To build the toolchain we must make the first file we downloaded executable (the file gnu-arm-build.3.sh)

u do this by entering the following command:

chmod +x gnu-arm-build.3.sh

like seen here

23

after u pasted that in the terminal window u can press Enter

and will come back here

24

so now that we made the file gnu-arm-build.3.sh executable we can run it

u do this by entering the following command:

./gnu-arm-build.3.sh

like seen here

25

when u have done this u can press Enter

and will see this

26

And then press Enter again to start!

it will take a long time!

so i am not going to paste all the screenshots for this build

but it should end with this

27

This means it’s done but like u see in the screenshot u need to add the path /root/gnuarm/install/bin to your PATH to make arm-none-eabi-gcc friends.

You do this by doing the following

Open a new terminal window, but leave this one open.

and enter the following command:

nano  ~/.bashrc

28

and press Enter

u should then see this

29

this is the bashrc file opened in nano editor

now that u are here u need to press the down arrow on your keyboard to go to the end of this file

so untill u see this

30

now that u are at the bottom of the file we need to paste the following command here

export PATH=$PATH:/root/gnuarm/install/bin

yours could be different if u installed the gnu arm in a different folder, but u should add your path then after

export PATH=$PATH:

and then the path u saw on this screen

30-1
so that u end up with this on the bottom of your ~/.bashrc file

31

now that this is in place we need to close the nano editor and save the file

u do this by pressing

CTRL+X

and should then see this

32

So now u need to press Y

and see this

33

Now it actually asks u to which file u would like to save it

This is ok

so just press Enter

and should then come back out here

34

Congratulations u are now done setting up gnu arm

You can build OsmocomBB now.

 

 

 

Leave a Reply