Forum Discussion

dsun01's avatar
dsun01
Icon for Contributor rankContributor
3 years ago

a very simple question about Nios2 eclipse project build

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

6 Replies

    • dsun01's avatar
      dsun01
      Icon for Contributor rankContributor

      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

    • dsun01's avatar
      dsun01
      Icon for Contributor rankContributor

      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's avatar
    EricMunYew_C_Intel
    Icon for Frequent Contributor rankFrequent Contributor

    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.