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

Missing Libraries in Nios II Software Build Tools for Eclipse

JKrek
Beginner
1,845 Views

Hello,

for one of my University Courses I am doing a Nios II Project on an DE2-115 Development Board from terasIC.

After adding some new Features in the Platform Designer, I found this error while I was debugging the now non working c code:

Can't find a source file at "/build/arc/temp/823101626/ACDS_lwr/ip/sopc/app/gnu/BUILD/gnu/build-newlib.nios2-elf.x86_64-w64-mingw32/nios2-elf/mno-hw-mul/newlib/libc/stdio/../../../../../../src/newlib-2.2/newlib/libc/stdio/printf.c"

I have no idea what to make of it, other than it now misses this file, where it did not before.

My theory is that some dependencies broke, but as to why they did I do not know.

I am using Quartus 18.1 Lite Edition with the Nios II Software Build Tools for Eclipse

 

Any help would be appreciated. If you need any additional Information let me know

0 Kudos
8 Replies
AnandRaj_S_Intel
Employee
1,234 Views

Hi,

 

Can you run project in normal mode instead of debug mode?

Try by cleaning project, regenerating bsp, build project and check.

Also try by adding source file directory by clicking run as->run configuration->source->add C:\intelFPGA_lite\18.1\nios2eds\bin\gnu\src ->apply-> run

 If possible please do attache the project.

 

The printf.c file should be available in directory C:\intelFPGA_lite\18.0\nios2eds\bin\gnu\src\newlib-2.2\newlib\libc\stdio

And this function can be accessed by adding header stdio.h.

 

Regards

Anand

0 Kudos
JKrek
Beginner
1,234 Views

Sadly this did not work. It made no change at all.

For the Project Code, it is below, but it is kind of a mess, but any attempt to tidy it up is making the Project not working correctly.

#include "system.h" #include <sys/alt_stdio.h> #include <sys/alt_irq.h> #include <unistd.h> #include "altera_avalon_pio_regs.h" #include "altera_up_avalon_audio.h" #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <limits.h> #include "altera_up_avalon_character_lcd.h" #include "altera_up_avalon_rs232.h"   #define SEC 500000 #define BUF_SIZE 792000 // about 10 seconds of buffer (@ 8K samples/sec) #define BUF_THRESHOLD 96 // 75% of 128 word buffer volatile int * green_LED_ptr = (int *) LED_GREEN_PIO_BASE; volatile int* red_LED_ptr = (int*) LED_RED_PIO_BASE; volatile int* switches = (int*) SW_PIO_BASE; volatile int * audio_ptr = (int *) AUDIO_BASE; volatile int * Recording = (int *) RECORD_PIO_BASE; volatile int * PLAY = (int *) PLAY_PIO_BASE; int fifospace; int record = 0, play = 0, transmit = 0, buffer_index = 0, Seg_com = 0; int buffer_nahm = 0, min, max; int temp; char normalized = 0; alt_16 left_buffer[BUF_SIZE],right_buffer[BUF_SIZE]; alt_8 left_normalized[BUF_SIZE], right_normalized[BUF_SIZE]; alt_up_character_lcd_dev * char_lcd_dev; alt_up_rs232_dev* serialport; unsigned int led_val[19]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767, 65535,131071,262143 }; /* function prototypes */ void check_KEYs(int *, int *, int *, int*); void init_vars(); void writeToLCDAt(int xpos, int ypos, char* text); int test(); void normalize(); enum {KEY_0 = 0x0E, KEY_1 = 0x0D, KEY_2 = 0x0B, KEY_3 = 0x07}; int main(int argc, char **argv) { init_vars(); writeToLCDAt(0,0,"Welcome to "); writeToLCDAt(0,1,"L'Audio Recorder"); while (1) { Seg_com = test(); if (Seg_com == 0) { *(green_LED_ptr) = *(green_LED_ptr) | 1; } if (Seg_com == 1) { *(green_LED_ptr) = 0; } check_KEYs(&record, &play, &transmit, &buffer_index); if (record){ *(green_LED_ptr) = 16; // turn on LEDR[0] fifospace = *(audio_ptr + 1); // read the audio port fifospace register max = 0; min = SHRT_MAX; if ((fifospace & 0x000000FF) > BUF_THRESHOLD) {// check RARC // store data until the the audio-in FIFO is empty or the buffer // is full while ((fifospace & 0x000000FF) && (buffer_index < BUF_SIZE)) { *(Recording) = 1; left_buffer[buffer_index] = *(audio_ptr + 2); *red_LED_ptr=led_val[(abs(left_buffer[buffer_index])) *(18) /(SHRT_MAX)]; right_buffer[buffer_index] = *(audio_ptr + 3); ++buffer_index; if(left_buffer[buffer_index] > max){max = left_buffer[buffer_index];}else if(left_buffer[buffer_index] < min){min = left_buffer[buffer_index];} // printf("index: %d name: %d",buffer_index,buffer_nahm); if (buffer_index == BUF_SIZE || (KEY_0 == *((int*) BTN_PIO_BASE))) {// done recording usleep(SEC/2); *(Recording) = 0; record = 0; normalized = 0; *(green_LED_ptr) = 0x0; // turn off LEDR temp = buffer_index; } fifospace = *(audio_ptr + 1); // read the audio port fifospace register } } } else if (play) { *(green_LED_ptr) = 64; // turn on LEDR_1 fifospace = *(audio_ptr + 1); // read the audio port fifospace register if ((fifospace & 0x00FF0000) > BUF_THRESHOLD) // check WSRC { // output data until the buffer is empty or the audio-out FIFO // is full while ((fifospace & 0x00FF0000) && (buffer_index < BUF_SIZE)) { *(PLAY) = 1; *(audio_ptr + 2) =( left_buffer[buffer_index]); if(buffer_index %256 == 0){ *red_LED_ptr=led_val[left_normalized[buffer_index]]; } *(audio_ptr + 3) = (right_buffer[buffer_index]); //alt_up_rs232_write_data(serialport, left_buffer[buffer_index] & 0x00FF); //alt_up_rs232_write_data(serialport, (left_buffer[buffer_index] & 0xFF00) >> 8); ++buffer_index; if (buffer_index == temp || (KEY_0 == *((int*) BTN_PIO_BASE))){// done playback play = 0; *(PLAY) = 0; *(green_LED_ptr) = 0x0; // turn off LEDR } fifospace = *(audio_ptr + 1); // read the audio port fifospace register } } } else if (transmit) { buffer_index = 0; while (buffer_index < 16000 || buffer_index <= temp) { if (alt_up_rs232_get_available_space_in_write_FIFO(serialport) > 2) { alt_up_rs232_write_data(serialport, left_buffer[buffer_index] & 0x00FF); alt_up_rs232_write_data(serialport, (left_buffer[buffer_index] & 0xFF00) >> 8); ++buffer_index; } } transmit = 0; } else if (record == 0 && play == 0 && transmit == 0) { *(PLAY) = 0; *(Recording) = 0; if(normalized == 0) normalize(); *red_LED_ptr = 0x0; writeToLCDAt(0,0,"Standby "); } } }       void check_KEYs(int* KEY0, int* KEY1, int* KEY2, int* buffer) { // read the pushbutton KEY values int* BTN_ptr = (int*)BTN_PIO_BASE; if (*(BTN_ptr) == KEY_2) { usleep(SEC); printf("RECORDING START \n"); writeToLCDAt(0,0,"RECORDING "); *buffer = 0; // clear audio-in FIFO *(audio_ptr) = 0x4; *(audio_ptr) = 0x0; *KEY0 = 1; } else if (*(BTN_ptr) == KEY_3) { usleep(SEC); printf("Playback soll abgespielt werden \n"); writeToLCDAt(0,0,"PLAYING "); *buffer = 0; // clear audio-out FIFO *(audio_ptr) = 0x8; *(audio_ptr) = 0x0; *KEY1 = 1; } else if (*(BTN_ptr) == KEY_1 ) { usleep(SEC); writeToLCDAt(0,0,"TRANSMITTING "); printf("Start Transmission!\n"); *buffer = 0; *KEY2 = 1; } } int test() { int Seg_value; volatile int * Seg_ptr = (int *) SEG_COM_BASE; Seg_value = *(Seg_ptr); return Seg_value; } void init_vars(){ *green_LED_ptr = 0x0; *red_LED_ptr =0x0; printf("%d", *switches>>1); char_lcd_dev = alt_up_character_lcd_open_dev(CHARACTER_LCD_NAME); if (char_lcd_dev == NULL){ alt_printf("Error: could not open character LCD device\n"); }else{ alt_printf("Opened character LCD device\n"); alt_up_character_lcd_init(char_lcd_dev); } serialport = alt_up_rs232_open_dev(RS232_UART_NAME); if (serialport == NULL){ alt_printf("Error: could not open serialport device\n"); }else{ alt_printf("Opened serialport device\n"); /*char teststring[] = "Hello World!"; for (int i = 0; i <= strlen(teststring); ++i) { alt_up_rs232_write_data(serialport, teststring[i]); }*/ } printf("Initialisierung fertig !\n"); } void writeToLCDAt(int x_pos, int y_pos, char* text){ alt_up_character_lcd_set_cursor_pos(char_lcd_dev, x_pos, y_pos); alt_up_character_lcd_string(char_lcd_dev,text); } void minmax(int* min, int* max){ *max = *min = left_buffer[0]; for (int i = 1; i < temp;i++ ){ if(left_buffer[i] > *max){ *max = abs(left_buffer[i]); }else if (left_buffer[i] < *min){ *min = abs(left_buffer[i]); } } } void normalize(){ writeToLCDAt(0,0,"Normalizing "); printf("min: %d, max: %d", min, max); for(int i = 0;i<temp;i++ ){ left_normalized[i]=(((abs(left_buffer[i])- min) *(18) /(max - min))); //printf("%d\n",left_normalized[i]); } normalized = 1; }

Thank you for your help so far, if you need anything else, let me know.

 

Jan

0 Kudos
AnandRaj_S_Intel
Employee
1,234 Views

Thanks jan,

 

Can you also attache the .qar file, Click on the Project menu -> Archive Project 

0 Kudos
JKrek
Beginner
1,234 Views

Here is the link to the .qar file

 

Sorry for the late reply, I got the notificaion when I was on my way to work.

If you need more Info, let me know.

 

Thank you for your help so far.

 

Regards,

Jan

0 Kudos
AnandRaj_S_Intel
Employee
1,234 Views

Thanks Jan,

 

I have used nios2_system.sopcinfo file from project and created a new eclipse project with name testlite and successfully generated elf without any error.

  1. Delete your software folder and recreate the eclipse project by importing .sopcinfo file.
  2. or import the software file attached.

testlite.JPG

 

Let me know if this has helped resolve the issue you are facing or if you need any further assistance.

 

Best Regards,

Anand

 

0 Kudos
JKrek
Beginner
1,234 Views

Hi Anand,

unfortunatly this hasn't fully resolved my problem, and I think I have not described my problem precisely enough. The Code did always compile without errors or warnings. However, none of the "debug" printf or alt_prinft statements where printet on the Nios II console. The write commands to the lcd do not work either. Sadly this error persists. The missing Libraries error only surfaced when I ran the code in debug mode. This error however has gone away and was replaced with this error message: 304   HAL/src/crt0.S: No such file or directory.

 

Thank you for your Assistance so far, and any more help would be appreciated.

 

Regards,

Jan

 

0 Kudos
AnandRaj_S_Intel
Employee
1,234 Views

Hi Jan,

 

Apologizes for late reply.

We dont have DE2-115 Development Board kit to replicate the given design however i have tried to recreate the scenario using other kit. We can eliminate the such error using step-over while debugging instead of step-into. try by pressing resume key while giving write commands to the lcd hope it helps.

 

Regards

Anand

 

0 Kudos
JKrek
Beginner
1,234 Views

Hi,

sadly this did not help.

Another thing that i tried was to revert to a previus stage of the project and reused the eclipse project from it. That code worked fine. I suspect one or more files got corrupted or my Nextcloud is at fault with its way of dealing with modified files.

Either way, Everything works now and thats what I need.

Thank you very much for your help. It was very much appreciated.

Also I am sorry for my late reply as well.

 

Thank you for your time.

Regards,

Jan

0 Kudos
Reply