Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Valued Contributor III
688 Views

Compiling assembly file to hex file

I am attempting to compile my source.s code into the hex file that will be placed in my system RAM. This must be done completely through the command line and I am having some problems. I am using the following commands in order. 

 

nios2-bsp: This creates the BSP from the .sopcinfo file 

nios2-app-generate-makefile : This generates the make file from the source code 

make all: Compile the make file and generate the .elf file 

elf2hex: This converts the elf file to the hex file 

 

Now, I am running into problems when I run the make all. It appears that the src file (named "code_name" below) is not able to be compiled into the .o file that is required later on in the build process. I am left with the following error: 

 

 

Assembler messages: 

Fatal error: can't create obj/default//C/Users/..../code_name.o: No such file or directory 

make: *** [obj/default//C/Users/..../code_name.o] Error 1 

 

The directory exists, but the file does not. Has anyone succesfully created their .hex file for their ram from simply their source code, and the .sopcinfo file using the command line?!?! 

 

Thanks
0 Kudos
9 Replies
Highlighted
Valued Contributor III
6 Views

Anyone? I am sure this is able to be done rather easily outside of the GUI.

0 Kudos
Highlighted
Valued Contributor III
6 Views

bump......

0 Kudos
Highlighted
Valued Contributor III
6 Views

Try "make mem_init_generate" after running make all. Is should create a mem_init folder and your hex will contain in it.

0 Kudos
Highlighted
Valued Contributor III
6 Views

Mike, 

 

I am getting the following error when I run make all. I need to run make all before I can make mem_init_generate. 

 

Fatal error: can't create obj/default//C/Users/mattmaur/Desktop/sel2740s_mainboa 

rd_SEPARTE_QSYS/sel2740x/rtl/sel2740s_mainboard/sel2740s_mainboard_top/syn/softw 

are/nios_sw/main.o: No such file or directory 

make: *** [obj/default//C/Users/mattmaur/Desktop/sel2740s_mainboard_SEPARTE_QSYS 

/sel2740x/rtl/sel2740s_mainboard/sel2740s_mainboard_top/syn/software/nios_sw/mai 

n.o] Error 1 

make: Leaving directory `C:/Users/mattmaur/Desktop/sel2740s_mainboard_SEPARTE_QS 

YS/sel2740x/rtl/sel2740s_mainboard/sel2740s_mainboard_top/syn/software/nios_sw'
0 Kudos
Highlighted
Valued Contributor III
6 Views

I do not understand why main.o is getting created at the above directory. It should go to obj/default, not obj/default//"My_Full_Project_Path"

0 Kudos
Highlighted
Valued Contributor III
6 Views

Check the generated Makefile. Do install cygwin? 

How did you generate the Makefile at the first place? Using eclipse or command line? 

You can try using the Nios II command shell.
0 Kudos
Highlighted
Valued Contributor III
6 Views

Cygwin is included in the nios command line tools I believe. I generated the Makefile using nios2-app-generate-makefile.

0 Kudos
Highlighted
Valued Contributor III
6 Views

Check your Makefile. The paths are added in there.

0 Kudos
Highlighted
Valued Contributor III
6 Views

This problem has been solved.  

 

I believe the problem came from my path length being too long. When the assembler creates the main.o file, is is placed under your obj/default folder in which the whole directory is created again. It follows this format. 

 

MY_DIR/project_folder/obj/fefault/MY_DIR/project_folder/main.o 

 

As you can imagine, this path length can get rather long. My guess is it exceeded the maximum allowed by the Nios Cygwin build tools. 

 

Simply making my MY_DIR path less levels solved this issue. 

 

-Matt
0 Kudos