Can someone help me out with a makefile for raspbian gcc ?

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.
May 11, 2008
22,551
1,471
126
Interesting, the suspect sd card just died. :grinning:
Or my sd card reader just died. And that seems more likely. SInce yet another sd card is also not being recognized.
I just tried yet another sd card with another card reader. And it works.
:fearful:
 
Last edited:

sdifox

No Lifer
Sep 30, 2005
100,238
17,895
126
Too bad. The winflashtool does not run in my W XP Virtual machine.
I am thinking of installing a virtual machine with ubuntu. To test it out.
I will wait until tomorrow. If i have the same issue with the new sd card as well, i am suspecting windows 10 corrupting the sd card when adding the system volume information folder.
I will have to find out if that is really the case.

why are you formatting the sd card at all? just burn the image onto the sd card.
 
May 11, 2008
22,551
1,471
126
why are you formatting the sd card at all? just burn the image onto the sd card.

I tried. Etcher and winflashtool both failed. That is why i tried the sd card formatter utility.
I think my sd card was just bad and took my card reader with it.
I just ordered a new card reader.
I keep my fingers crossed i will receive the card reader tomorrow. The shipping address is my work address.
And Friday i will be free from work. Would be just my typical luck that while promoting next day delivery, that it would be postponed until Friday.
I hope if that happens, that my colleague can take it with him and i can pick it up at his house which is closer to my house. But it would delay my programming efforts. Grrmbll.. :rage:
 
May 11, 2008
22,551
1,471
126
I mean to write, that i just downloaded the latest jessie raspbian and that i was trying to write that image.
 
May 11, 2008
22,551
1,471
126
you mean you don't have a microsd to usb adapter that comes with microsd cards?
example https://www.amazon.com/Kingston-Dig...5095249&sr=8-1&keywords=32gb+microsd+card+kit

No, i never knew that some suppliers also add a usb to sdhc card adapter.
But i have good news and bad news.
First the bad news.
Etcher.io is an unstable program. It crashes constantly for some reason.
I am going to de install it.

Now the good news :
Yesterday, i was a bit in a foul mood. But today i am happy because i received everything (card and separate reader) today at work.
Thus tonight, i used winflashtool and wrote the latest raspbian image : "2016-09-23-raspbian-jessie.img" to the new kingston sd card i received. And it wrote flawlessly and without errors.
I just booted up raspbian and it is lightning fast. The 16GB SDHC [1] card from kingston has a max read speed of 45MB/s. Max write speed is 12MB/s.
Tomorrow i will continue to play with the RBPI 3.
 

sdifox

No Lifer
Sep 30, 2005
100,238
17,895
126
Odd. I have no issues at all with etcher. But then I am in win7.

what x11 server are you running? I find xming wanting.
 
Last edited:
May 11, 2008
22,551
1,471
126
I am very new at this.
At the moment i just have raspbian and my monitor has next to the dvi input, a hdmi input.
I connected the raspberry pi to the hdmi input and switch manually. :grimacing:
I understand that with x11server and client i can have a remote desktop yes ?

At the moment i use SmarTTY that was provided with the gnutools cross compiler package for the remote connection.
I noticed it has a folder with Xming in it.
I have to see if it is possible to have a remote desktop.
 

sdifox

No Lifer
Sep 30, 2005
100,238
17,895
126
I am very new at this.
At the moment i just have raspbian and my monitor has next to the dvi input, a hdmi input.
I connected the raspberry pi to the hdmi input and switch manually. :grimacing:
I understand that with x11server and client i can have a remote desktop yes ?

At the moment i use SmarTTY that was provided with the gnutools cross compiler package for the remote connection.
I noticed it has a folder with Xming in it.
I have to see if it is possible to have a remote desktop.
So you can use putty to ssh to RPI, and set some settings in putty to enable x forwarding. That way you can run your RPI headless.
 
May 11, 2008
22,551
1,471
126
I will have a try it. I am planning to use a monitor in the future since it will be part of the little droid. But for getting to know the RBPI 3 and development, a remote desktop alike connection is ideal.
I googled a bit. I see there are various ways, one popular way seems to use remote desktop of windows and xrdp, the other uses vnc.
Have you experimented with this ?
What were your personal experiences about this if exist ?
 
Last edited:

sdifox

No Lifer
Sep 30, 2005
100,238
17,895
126
I will have a try it. I am planning to use a monitor in the future since it will be part of the little droid. But for getting to know the RBPI 3 and development, a remote desktop alike connection is ideal.
I googled a bit. I see there are various ways, one popular way seems to use remote desktop of windows and xrdp, the other uses vnc.
Have you experimented with this ?
What were your personal experiences about this if exist ?
I am using putty and xming, having issues with x11, but text terminal works fine.
 
May 11, 2008
22,551
1,471
126
I see.
Since i installed the latest raspbian version called pixel, i have learned that it comes default with vnc server installed but not enabled.
Enabling it is real easy. Go to the raspbian pi configuration and enable vnc. After a reboot vnc server is present.
Since i have it in my private home network, security is not a real issue. When the rpi is used in a public network, of course security precautions must be taken like changing the password.
I have it up and running. Works great, so far so good.

If you are interested :

https://www.realvnc.com/docs/raspberry-pi.html

This is the vnc client that will run on for example windows :
https://www.realvnc.com/download/viewer/

New items about raspbian pixel :
http://lifehacker.com/the-new-raspberry-pi-os-is-here-and-it-looks-great-1787194540
 

sdifox

No Lifer
Sep 30, 2005
100,238
17,895
126
I see.
Since i installed the latest raspbian version called pixel, i have learned that it comes default with vnc server installed but not enabled.
Enabling it is real easy. Go to the raspbian pi configuration and enable vnc. After a reboot vnc server is present.
Since i have it in my private home network, security is not a real issue. When the rpi is used in a public network, of course security precautions must be taken like changing the password.
I have it up and running. Works great, so far so good.

If you are interested :

https://www.realvnc.com/docs/raspberry-pi.html

This is the vnc client that will run on for example windows :
https://www.realvnc.com/download/viewer/

New items about raspbian pixel :
http://lifehacker.com/the-new-raspberry-pi-os-is-here-and-it-looks-great-1787194540
Cool. Will get to it when I get to it. Thanks.
 
May 11, 2008
22,551
1,471
126
I did just found out that only one ssh connection can be made it seems. If i have the vnc terminal open, the smarrt tty ssh terminal does not function. Something that i must keep in mind.

edit:
However, i just found out that when first enabling the ssh terminal, the realvnc viewer can be enabled after wards and for now seem to work fine next to each other.

Another edit:
Yep, i can now upload my program to the RBPI through smartty and then run it in the vnc viewer.
Of course after changing permissions with "chmod a+x programname". :grinning:
 
Last edited:
May 11, 2008
22,551
1,471
126
Well, i got a housing for the RBPI3. With a little Zalman memory chip cooler on the SOC.
I am now in the process of reverse engineering how my old linker script worked and how i have to setup my new linker script.
My old linker script was for a bare metal style of programming for embedded controllers. But now i am confused because of how to setup the linker script with respect to stack usage, bss sections and other data storage that is (I assume)under linux handled by the kernel. I have to do some more digging for a standard linker script for a linux program. Once i have that, i can modify the W-ARM manager to create the linker script automatically and then i am finally set to start to program with the use of separate libraries with gcc and c standard libraries.

I also figured out how to transfer files through vnc, so a ssh command line terminal is no longer needed.



RBPI3.jpg~original
 
May 11, 2008
22,551
1,471
126
I just experienced this because for the first time, i did not connect a monitor hdmi cable to it :
Handy tips when running the raspberry pi headless and the realvnc viewer windows is tiny because with no monitor attached, the RBPI will default to a low resolution.
With these tips, the config.txt can be adjusted to increase the screen. After a reboot, the realvnc window will be adjusted to the resolution in the config.txt file.
You need (sudo) root access for to modify the config.txt file.

https://support.realvnc.com/knowledgebase/article/View/523

https://www.raspberrypi.org/documentation/configuration/config-txt.md
 
May 11, 2008
22,551
1,471
126
I still had some errors in it because i used my makefile and linkerfile for bare metal embedded programming as a template.
And that was not a good idea. If i am right, i do not need a special linker file. LD will link just fine.
I still have to test if the script accepts external *.o libraries, but at least it should work better.
Upcoming weekend i have some time to test it fully by making a program for the raspberry pi that uses libraries .

This is my latest version :

Code:
# Automatically generated by W-ARM for RPI !
# Do not edit this file with an editor that replaces tabs with spaces !
################################################################################

ECHO = echo.exe
CP = cp.exe
CC = arm-linux-gnueabihf-g++.exe
AS = arm-linux-gnueabihf-g++.exe -x assembler-with-cpp
CREATE_OUTPUT_FILE = arm-linux-gnueabihf-g++ -o RPITEST.exe

SRC = ./src/file2.c ./src/main.c
ASRC =

USR_INC_DIR = ./inc
USR_LIB_DIR = ./lib
################################################################################

# These are the object files of external libraries.
LIBOBJS =
# Library directory with LD switches.
LIBDIR = -L USR_LIB_DIR

# substitution reference OBJS = every module name, replace s with o and every c with o.
OBJS = $(ASRC:.s=.o) $(SRC:.c=.o)

### compiler flags.
# architecture optimizations
MCU_FLAGS = -mcpu=cortex-a53
# compiler optimisation level
OPT =-O1

# debugger
DBGGR =
# floating point unit
FLPU =-mfpu=vfpv4
# compiler flags combined into a single variable.
CP_FLAGS = $(DBGGR) $(FLPU) $(OPT) $(MCU_FLAGS) -Wall -g -Wa,-adhln=$(<:.c=.lst)

# assembler flags combined into a single variable.
AS_FLAGS = $(OPT) $(MCU_FLAGS) -Wa

# linker flags.
LD_FLAGS = $(MCU_FLAGS) -lgcc -lrt -Wl,-Map=./output/RPITEST.map,--cref $(LIB_DIR)

# Eye candy.
begin:
    @$(ECHO)
    @$(ECHO) ---------------- begin ----------------
    @$(ECHO)

finished:
    @$(ECHO)
    @$(ECHO) Errors none.
    @$(ECHO)
    @$(ECHO) Output format = Raspbian executable
    @$(ECHO)
    @$(ECHO) Project name = RPITEST
    @$(ECHO)

end:
    @$(ECHO)
    @$(ECHO) ---------------- end ----------------
    @$(ECHO)

clean_message:
    @$(ECHO)
    @$(ECHO) Cleaning directories of current project : RPITEST
    @$(ECHO)

# Display compiler version information.
gccversion:
    @$(CC) --version

#Execute from here.
all: begin gccversion create move_files finished end

#copy files to new destination.
move_files:
    @$(CP) ./src/*.lst ./list/
    @$(CP) ./src/*.o  ./object/
    @$(CP) *.exe ./output/
    @-rm -f ./src/*.lst
    @-rm -f ./src/*.o
    @-rm -f *.exe

# create output file.
#Make searches for pattern rules first.
create: $(OBJS)
    $(CREATE_OUTPUT_FILE) $(LD_FLAGS) $(OBJS) $(LIBOBJS)

# This pattern rule is performed for every single c module. One object file for every c module.
%.o : %.c
    $(CC) -c $(CP_FLAGS) -I $(USR_INC_DIR) $< -o $@

# This pattern rule is performed for every single assembly module. One object file for every assembly module.
%.o : %.s
    $(AS) -c $(AS_FLAGS) -I $(USR_INC_DIR) $< -o $@

clean: begin gccversion deletefiles clean_message end

deletefiles:
    @-rm -f $(OBJS)
    @-rm -f $(SRC:.c=.c.bak)
    @-rm -f $(SRC:.c=.lst)
    @-rm -f $(ASRC:.s=.s.bak)
    @-rm -f $(ASRC:.s=.lst)
    @-rm -fR .dep
    @-rm -f ./output/*.map
    @-rm -f ./output/*.exe
    @-rm -f ./list/*.lst
    @-rm -f ./object/*.o


# Listing of phony targets.
.PHONY : all begin finish end move_files clean_message sizebefore sizeafter gccversion build elf hex lss sym clean clean_list program

# *** EOF ***
 
May 11, 2008
22,551
1,471
126
Well, i am playing around and gained some interesting knowledge about gcc. Having the per list files to examine the output really helps to understand how it all works..
Whenever i select the A53 core "-mcpu=cortex-a53", not adding the fpu option to the gcc4.9.2 compiler options, makes no difference. When the compiler knows that the A53 core is selected, gcc will always use floating point registers and not use math libraries. This makes sense of course, why would the compiler not use instructions that are there anyway. I never used floating point values before. And just learned that type float is a single precision value and type double is a double precision value :flushed:. And this reflects in the list file when comparing the instructions generated by the compiler. Of course, this is not really relevant, but i was curious how it all would work out. And now i know a bit more, i can continue with my experiments.
 
May 11, 2008
22,551
1,471
126
Hey Sdifox, i have been reading on the opencv.org tutorial and downloaded the latest zip file, but it seems i am missing a lot of files.

What do you recommend that i install on the rbpi3 ? The gcc version or the linux version ?
What is your experience with opencv ?

I am also going to install ubuntu in a virtual machine.
 

sdifox

No Lifer
Sep 30, 2005
100,238
17,895
126
Hey Sdifox, i have been reading on the opencv.org tutorial and downloaded the latest zip file, but it seems i am missing a lot of files.

What do you recommend that i install on the rbpi3 ? The gcc version or the linux version ?
What is your experience with opencv ?

I am also going to install ubuntu in a virtual machine.

Welcome to the hell that is linux dependencies. I cannot even tell you which packages I had to install to get opencv going since thee had been many . Look at the make log and see which ones it says are missing and install them and hopefully you can get a combination that allows it to compile and compile correctly. Many times it starts compiling then craps put half way. That is why I imaged my microsd right after I got it working.

I think it took me two weeks to get it going.
 
  • Like
Reactions: Ken g6
May 11, 2008
22,551
1,471
126
I see. I looked through the files in the opencv and opencv2 directory, but it seems, some files are just not there. I will have a look around the raspberry pi forum and see if i can find something there.
I am sure more people have stumbled upon this.

I did found a manual :

http://docs.opencv.org/2.4/doc/tuto...troduction.html#table-of-content-introduction
I did some reading and comparing :
It seems that for every opencv function there are several 3rd party functions needed.

The show image example seems to rely on GTK and the jpeg handling libraries if i am not mistaken.
http://docs.opencv.org/2.4/doc/tutorials/introduction/display_image/display_image.html

Tomorrow morning when i am fresh i will try to get the needed files with apt-get.

All the opencv functions in a handy index :
http://docs.opencv.org/2.4/genindex.html
 
May 11, 2008
22,551
1,471
126
I just installed all packages on the rbpi3. Some packages were not found on the raspbian servers. I might get into trouble later on.
I changed the video mode to (1280x720) 720p as well. It is now : hdmi_group=2 ,hdmi_mode =85.
It is a bit better and seem to response faster in vnc. But that could be just me.

I also just installed ubuntu-64bit in a virtual machine. I can also try to install all needed packages to get opencv code to run on ubuntu. Just for the test.
Now i can try to find out where all the install directories are. :disrelieved:
 
May 11, 2008
22,551
1,471
126
I just installed espeak. The dutch female voice is pretty good, just need to modify the text a bit as for example "Pi" becomes "Pij" for the right pronunciation :
I am pleasantly surprised, that it works right away. It does produce a lot of error messages like not finding the jack server. but it seems that there is a solution for that.

sudo apt-get install espeak

English voice.

espeak -ven+f3 -k5 -s150 "Hi, i am a raspberry pi "

Dutch voice

espeak -vnl+f3 -k5 -s150 "Hallo, ik ben een raspberry pij ".

Adding this to the end of the line helps surpress the messages : " 2>/dev/null ".
The messages are redirected to the null device.
The error message about not finding the pulseaudio server is not relevant. Since the alsa audio bcm2835 driver works fine.
 
Last edited: