Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
The Intel sign-in experience is changing in February to support enhanced security controls. If you sign in, click here for more information.
15806 Discussions

a very simple question about Nios2 eclipse project build

dsun01
New Contributor III
346 Views

Dear Support/Expert

I have a very simple code while I play with Nois2 and SPI interface. 

/* "Hello World" example.
*/
#include "alt_types.h"
#include "altera_avalon_spi_regs.h"
#include "altera_avalon_spi.h"
#include "system.h"
#include <stdio.h>
#include <unistd.h> // usleep
int main( void){
printf ("Entered Main \n");
alt_u8 send_M;
alt_u8 count;
count = 0;
while (1) {
send_M = count;
IOWR_ALTERA_AVALON_SPI_TXDATA(SPI_0_BASE, send_M);
// Wait for transfer to complete
usleep(75);
// Print results
printf("master sent = %d \n",send_M);
count ++;
usleep(1000000);
} // end while
return 0;
}

 

--------------------------------

 

I will have this compile error

 

Description Resource Path Location Type
make: *** [spi_test2.elf] Error 1 spi_test2 C/C++ Problem
recipe for target 'spi_test2.elf' failed Makefile /spi_test2 line 1015 C/C++ Problem

 

I have tried %i, %c, %u. none of them can pass project build. 

but if I comment off the 

printf("master sent = %d \n",send_M);

 

the project will build successfully. 

I am new to Nios and eclipse, and I don't write C code. 

what is the problem of this printf sentence and how to solve it?

Thank you,

David 

 

 

0 Kudos
6 Replies
EricMunYew_C_Intel
Moderator
317 Views

For printf, you may try the uart core for data read write.


dsun01
New Contributor III
309 Views

Hi Eric

 

I don't fully understand your answer, my test platform can print text only string. if I don't use any % print format. when you say "try uart core" do you mean FPAG core, or eclipse domain. 

 

Thanks,

David

EricMunYew_C_Intel
Moderator
299 Views

You can add uart in your Platform Designer, which will be located in the FPGA fabric.


dsun01
New Contributor III
264 Views

Hi Eric

 

I have Uart core, I can printf the pure test string. but the compiler will report error when I printf with format, for example %c. 

do you mean if I add a uart core will solve this problem?

 

Thank you,

David

EricMunYew_C_Intel
Moderator
238 Views

Yes you are right.


EricMunYew_C_Intel
Moderator
172 Views

I’m glad that your question has been addressed, I now transition this thread to community support. If you have a new question, feel free to open a new thread to get the support from Intel experts. Otherwise, the community users will continue to help you on this thread. Thank you.


Reply