Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12590 Discussions

Compiling assembly file to hex file

Altera_Forum
Honored Contributor II
1,228 Views

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
Altera_Forum
Honored Contributor II
546 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
546 Views

bump......

0 Kudos
Altera_Forum
Honored Contributor II
546 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
Altera_Forum
Honored Contributor II
546 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
Altera_Forum
Honored Contributor II
546 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
Altera_Forum
Honored Contributor II
546 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
Altera_Forum
Honored Contributor II
546 Views

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

0 Kudos
Altera_Forum
Honored Contributor II
546 Views

Check your Makefile. The paths are added in there.

0 Kudos
Altera_Forum
Honored Contributor II
546 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
Reply