Linux Mint+FriendlyARM Mini2440. Cannot make hello.c

Abhishek Ekhare
Attachment: 20160207_194144.jpg (777.38 KB)
Hi,
I am using Linux Mint 17 + FriendlyARM Mini 2440 development board.
I am referring the following link for setting the cross compiler
https://alselectro.wordpress.com/2013/01/05/cross-compiler-installation-...

I have successfully installed the cross-compiler and export its path.
I have also configured the codeblocks compiler arm-gcc settings to execute
files for FriendlyARM2440.

Now, when i try to make the examples (provided alongwith the FriendlyARM
CD)
make hello
I get permission denied error.

I have attached a picture of the error.

Why doesn't the arm-gcc "make" the hello.c even when it is correctly
installed??

Thank you in advance,
Abhishek Ekhare.

davef
Maybe,

   sudo make hello

davef
http://www.friendlyarm.net/forum/topic/26

6 1/2 years ago, probably not much help

Stopped using CodeBlocks after that.

Abhishek Ekhare
Hi davef,
Thank you for replying.

Actually, i have configured codeblocks correctly and have mentioned that in
my question.
My problem is executing "make hello.c" in the Linux terminal.

And sudo make hello.c doesn't help either.

davef
If you are not using CodeBlocks then where is your makefile for this
project?

It might be easier to just cross-compile it on the command line.

davef
http://www.cyberciti.biz/faq/compiling-c-program-and-creating-executable...

davef
I assume you have the necessary tools installed on your host, ie
build-essential, etc

Abhishek Ekhare
I have not installed build-essentials etc on my host.
I have only followed whatever is given in the link:-

https://alselectro.wordpress.com/category/friendly-arm-mini2440/

There is no mention of build-essential etc.

davef
Most tutorials make many assumptions about the skill and experience of the
user, as well as the tools they are using.

Try:

   sudo apt-get install build-essential
   sudo apt-get install automake
   sudo apt-get install autoconf

Also, is your host 32 or 64 bits?

Abhishek Ekhare
Hi,
I will try this.
My host is 32-bit.

Abhishek Ekhare
Hi,
I am still unable to use the command "make hello".

So, instead of that i have configured codeblocks to build the files using
arm-none-linux-gnueabi toolschain. I generate the binary file and load it
into the FriendlyARM through pen-drive.

Atleast it got my stuff going, for now!!

Cheers!!

davef
You are possibly a lucky guy.

Eventually you will face new problems unless you use the same toolchain to
built your libraries (in your root filesystem) and your kernel.

BTW, on the FriendlyARM Wiki and the NanoPi page you will see a list of
tools needed, but it is a special case.

Did you export the path to your compiler in .bashrc when you were trying to
do it from the command line?

davef
What did you actually type on the command line?

Abhishek Ekhare
Hi,
Actually after much searching, i found out that you need to export the path
in .profiles file, not .bashrc !!

Abhishek Ekhare
And i didn't type anything in the command line.
I just installed and configured codeblocks as given in the link:-
https://alselectro.wordpress.com/category/friendly-arm-mini2440/

Then i created a new project to print Hello World.
I compiled it in codeblocks using the toolschain and generated a hello.bin
file.
Then i copied hello.bin into pen drive and connected the pen drive to
FriendlyARM and ran the commands cd /udisk and ./hello in putty terminal
and saw Hello World being printed in putty terminal.

P.S: Still getting Permission Denied (as seen in the attached snapshot)
when doing make hello or arm-linux-gcc -o hello hello.c

davef
Sorry I thought this:

P.S: Still getting Permission Denied (as seen in the attached snapshot)
when doing make hello or arm-linux-gcc -o hello hello.c

meant you were doing it on the command line

Correct .bashrc or .profile depending which host distribution you are
using.

Abhishek Ekhare
No no, while compiling my code in codeblocks, i didn't use command line at
all, and generated hello.bin and loaded into FriendlyARM via pen-drive.


I used command line only to check if i can build my hello.c from command
line (which i eventually couldn't).

davef
I think it would be a good exercise to use the FriendlyArm toolchain and
cross-compile your hello.c on the command line.

Then have CodeBlocks build your project pointing to the same toolchain.

Did you try:

   arm-linux-gcc -v

on the command line?

> I am still unable to use the command "make hello".

Are you sure <make hello> is a valid command?

davef
I could be wrong but to use <make hello> requires a makefile, that is why I
asked if you had one.

davef
Thought I would refresh my memory and compile a test program.  On the
command line:

   arm-linux-gcc hello.c -o hello

Abhishek Ekhare
Hi Davef,
I think you got to the crux of my problem!! :-)

Actually, when i install the cross compiler for the first time and try
>arm-none-linux-gnueabi-cc –v
I do not get any error.

But after i restart my laptop and try 
>arm-none-linux-gnueabi-cc –v
I get error "no such directory" and "Permissions Denied".

I have done all the procedure in /opt directory.

But i can still see the toolschain configured in codeblocks, so i proceeded
with codeblocks.

Yes, i have the makefile provided with the examples with FriendlyARM dvd.
I am trying to make the same example (hello.c).





Am i following the right procedures (as explained in the link
https://alselectro.wordpress.com/2013/01/05/cross-compiler-installation-...)
??????

davef
Does:

   arm-linux-gcc hello.c -o hello

work for you?

davef
Regarding the tutorial ... unless I actually try to go through it I can't
comment.

I notice <extract> was spelled wrong!

Also:

   arm-none-linux-gnueabi-cc is a link to arm-none-linux-gnueabi-gcc.

I don't know what is special about arm-none-linux-gnueabi-cc

Check around for other mini2440 tutorials.  mini2440vietnam has some good
stuff.

Abhishek Ekhare
Hi Davef,

"
Does:

   arm-linux-gcc hello.c -o hello

work for you?
"

No it doesn't work for me.
I am attaching a screenshot about this...

Abhishek Ekhare
Inspite of installing the arm-none-linux-gcc correctly,
I still get this error...

Abhishek Ekhare
And this is how i have configured codeblocks to compile the code using
arm-none-linux-gnueabi.

Abhishek Ekhare
CodeBlocks configuration...

davef
But you are not typing:

   arm-linux-gcc hello.c -o hello


Also type:

   arm-linux-gcc -v

Until you can do this there is not much point in me looking at your
CodeBlocks setup. (I am on a quite limited data package which renews 
Sunday()

davef
Another thought in your toolchain /bin directory do:

   ls -la

so we can see who owns the files in that directory.

davef
Forget my two previous comments.

I notice my export statement is in .bashrc on Ubuntu 14.04LTS

   arm-linux-gcc -v

works for me because that is what I have in my export statement.  I am
looking at the toolchain for NanoPi, as I don't have FriendlyARM mini2440
toolchain on this machine anymore.  Also, I tried changing it to
arm-none-linux-gnueabi and I get:

   command not found

Sorry, it has been about 5 years since I cross-compiled my own programs on
the mini2440 and obviously I have forgotten a few things!

The arm-none-linux-gnueabi directory is there but I can't access it either.
 All my FriendlyARM notes are about 75kms away, so I can't help further.

Also, try <printenv> on the command line and check you have the export path
correct.

Good luck!

Abhishek Ekhare
Hi Davef,
When i type echo $PATH on the command line, i get the PATH correctly.

"
The arm-none-linux-gnueabi directory is there but I can't access it either.
All my FriendlyARM notes are about 75kms away, so I can't help further.
"

No worries, I'll find a way out.

Thank you for your help!! :-)

davef
Just for fun ...

In your toolchain directory is there a folder that is called bin at the
same level as your arm-none-linux-gnueabi folder?  And in that bin folder a
link to arm-linux-gcc?

If so, change your export path to that /bin folder and then run

   arm-linux-gcc -v 

and if successful then

   arm-linux-gcc hello,c -o hello

and see if that runs on the mini2440.

davef
... hello.c

Abhishek Ekhare
Yes, will surely try this.

On the other hand, since i am getting "Permissions Denied", i will change
the permissions of the cd/opt/FriendlyARM/ itself.

davef
From:

OSELAS.BSP-Pengutronix-Mini2440-Quickstart.pdf


3.3.4 Protecting the Toolchain

All toolchain components are built with regular user permissions. In order
to avoid accidential changes in the
toolchain, the files should be set to read-only permissions after the
installation has finished successfully. It is also
possible to set the file ownership to root. This is an important step for
reliability, so it is highly recommended.

If you get "Permissions Denied" you should be able to just preface your
command with:

   sudo

Abhishek Ekhare
Hi Davef,
Yes you are right with the "sudo" part.
Actually my FriendlyARM folder was not having permissions.
So i executed

cd /opt

sudo chmod -R 777 FriendlyARM


Now i can execute "make hello" or "arm-linux-gcc hello.c -o hello",
generate hello.bin and load it into FriendlyARM development board and
execute it.

Thank you very much for you valuable time and help :-)

davef
I'd be surprised that your FriendlyARM folder had no permissions, ie 000

In the FA 4.4.3 for the NanoPi the top level directories are 755 and the
4.4.3 directory is 555.  From my understanding making the directory with
the tools that you use, ie arm-linux-gcc, writeable is not a good idea.

In my other toolchain everything is 755. (At least only root can write to
these files!)

It is difficult to know whether or not you have everything setup in a safe
manner  until things stop working and you spend days trying to figure out
the problem.

As, well as permissions, don't forget there is the owner and group
descriptions for each file and directory.

Happy programming!

Abhishek Ekhare
"As, well as permissions, don't forget there is the owner and group
descriptions for each file and directory."
Does it mean that sudo chmod -R 777 FriendlyARM has imparted permissions to
only the FriendlyARM folder and not its sub-folders??
Then how did the "make hello" command start working ??

I also tested the led-player and leds programs by using make command and
generating and loading their respective binary files into the development
board.




"It is difficult to know whether or not you have everything setup in a safe
manner  until things stop working..."
Can you give me a sample program to test ?? I will make its binary and load
it into my board and check...

davef
chmod -R does every directory under FriendlyARM

What I mean is that someday you might accidentally write to a tool or file
and change it and then you might end up with a broken system. 

It appears to be work now so no point in giving you a program.

I have never had to change permissions on a toolchain from FriendlyARM.

Can you install another toolchain and check the permissions again?

Abhishek Ekhare
Hi Davef,

You suggest me a toolschain. I will install it and check.

Also, under which scenarios would i write to a tool or file to change it ??

davef
> Actually my FriendlyARM folder was not having permissions.

When you installed this toolchain are you sure the permissions were wrong?

Re-install that toolchain and then tell me what the file permissions are in
the various directories.

> Also, under which scenarios would i write to a tool or file to change it
??

By making a mistake, by something crashing ... all I was suggesting that
some methods help to reduce potential errors.

I can recall when I started learning Linux, it felt like a million things
had to be done correctly OR what I was trying to do would fail.  It gets
better after you have made several thousand mistakes :)

Actually, over the last few years the tools and procedures have become more
streamlined, so it is easier to get the desired results.

For example, running Debian Jessie on the NanoPi, using the procedure on
the FA Wiki page only took a few days to set it up the way I wanted.
  
So, back to your toolchan\in and hello.c

Abhishek Ekhare
>When you installed this toolchain are you sure the permissions were wrong?

Actually, to be true, i really didn't knew what permissions are during
installation. I just put my stuff together and started following:-
https://alselectro.wordpress.com/category/friendly-arm-mini2440/
(blindly, as you may say!!)


>Re-install that toolchain and then tell me what the file permissions are
in the various directories.

Ok, i will take that risk for the sake of learning. Will get back with
results by Monday.


One question, do i need to "uninstall" the currently installed toolchain in
order to "re-install" it ??? If yes, how do i do that ??

davef
For now rename your folder FriendlyARM to FriendlyARM_modified_permissions
and go through the process of installing a new toolchain.

When you are confident that the new toolchain is working properly just
delete the old one.

Just so I know ... where are you downloading the toolchain from and tell me
if it has a specific file name?

Abhishek Ekhare
I used the toolschain from the DVD provided with FriendlyARM development
board. I didn't download it from anywhere.
Its filename is "arm-linux-gcc-4.4.3.tar.gz"

Abhishek Ekhare
Hi Davef,
Sorry for replying late.
I just finished-off some exercises on the FriendlyARM before renaming the
folder "FriendlyARM_OLD", and installing the toolchain again in the new
folder "FriendlyARM".

This toolchain seems to be working fine as well !!

davef
Now, you are "off and running".

Good luck

Abhishek Ekhare
Hi Davef,
Thank you very much for your help and support. I really appreciate it.

Can you suggest some material which i can refer to, to start programming
the FriendlyARM.
I have run the sample codes by generating and loading their respective
binaries into the FriendlyARM.

However,
1]Should i continue with codeblocks ??
2]How can i write some programs to configure and use the 3.5'display,
serial port, usb etc ??

davef
If CodeBlocks is still currently supported, I guess it is worth sticking
with as you have some experience.  Maybe, have a look at Eclipse.

I used it for awhile when I first starting with the mini2440, mainly as a
learning exercise.  The C code I have written for the mini2440, which is
very little,  I just used the command line instructions.

All my C programming is on the AVR ATmega series.  I talk to all the GPIO,
ADCs, etc I want using Teensy ATmega32u4 boards as using the SPI, I2C,
GPIO, and ADCs on the mini2440 was overly-complicated.  I blame many years
of experience using the AVR!

Search for <mini2440vietnam> he has several good tutorials.

Configuring the display will be quite a big challenge.  There is a recent
thread on C programming the serial port.

Abhishek Ekhare
Hi Davef,
I spent a considerable amount of time learning and understanding Linux and
writing some shell scripts.
I also practiced some tutorials with Mini2440.
I have come to a point wherein i need to install and run QT.
Now, QT installation is quite complex and confusing (especially when doing
it for the first time).
I referred some links on regarding installing Qt on Linux Mint:-

https://forum.qt.io/topic/24693/how-to-install-qt-5-0-x-in-linux-mint/2


https://importgeek.wordpress.com/2012/04/09/compiling-qt-and-tslib-for-m...


Can you please suggest which one to follow and move ahead with ??

Regards,
Abhishek.
(Apologies for not opening a new thread for small suggestion).

davef
Pop <mini2440vietnam> into Google.  He has a good tutorial on running Qt on
the mini2440.

Also, search for <sereno-on-line> Paulo has written some good tutorials.