Forum Discussion
22 Replies
- Altera_Forum
Honored Contributor
hi,
yes, you can use c++ coding with niosII. - Altera_Forum
Honored Contributor
In visuel studio the code excute with command Prompt and file script.txt.
iIn niosII i don't knows how excute it without command prompt ? and the processeur niosII read the file script .txt? can you help me - Altera_Forum
Honored Contributor
You can use the JTAG conneciton as stdin/sdout, then for command prompt and printf.
You can't use the .txt file, unless you implement a filesystem with Nios and a NV memory device and I think you don't want to make such an effort. I'd suggest to incorporate the script.txt file information into the code, assuming you don't need to modify it. This is ok if itt contains only configuration information to be read when the executable starts. - Altera_Forum
Honored Contributor
--- Quote Start --- In niosII i don't knows how excute it without command prompt ? --- Quote End --- command prompt is similar to niosii console. You can use printf() or getc() functions for user interaction if STDIN/STDOUT is set to your JTAG UART of your niosII design. This is a default setting and normally you should not need to set it by yourself. So this should work the way you are used to. --- Quote Start --- and the processeur niosII read the file script .txt? --- Quote End --- Problem here, you must transfer the script.txt to your embedded system in order to access it from niosII. For example you can load it in your FLASH or RAM. If you want to read it from your PC-filesystem you have to set up a communication-protocol between the niosII based embedded system and your PC. For example via UART or even the JTAG UART (using my_jtag_atlantic.h). Regards - Altera_Forum
Honored Contributor
hello,
I would like to explain how use the JTAG UART (using my_jtag_atlantic.h) can I send me the file ? - Altera_Forum
Honored Contributor
hi
I did not understand how to use the command prompt it does not exist in the menu nios explain me the path or steps to use the command prompt - Altera_Forum
Honored Contributor
The following applies to Nios IDE 9.0. Probably something changes if you are using a different version of the tools.
- Integrate the jtag uart function in your sopc and build fpga project - open System Library properties and select jtag uart for stdout/stin/stderr - in Nios application you use printf and getc as an ordinary C program running on pc. - build the Nios IDE project - Select Run... and in Target Connection option select jtag uart as Nios II communication device - when application runs on Nios, the Console pane will work as the pc monitor, as if your application were executing on the pc. Cris - Altera_Forum
Honored Contributor
--- Quote Start --- hello, I would like to explain how use the JTAG UART (using my_jtag_atlantic.h) can I send me the file ? --- Quote End --- Take a look at this thread. (second post) http://alteraforums.net/forum/showthread.php?t=6146 You will find links to download the files you need for the communication between PC and NIOSII using the jtag_uart. Also you find some sort of example code. With this library you can transfer data (bytes) from PC to your embedded NIOSII system. Regards - Altera_Forum
Honored Contributor
hello
i download the folder "jtag_atlantic_terminal" and the auther the folder "jtag_atlantic_terminal" contains tow file my_jtag_atlantic.h and min the role of the algorithm to read the image load in memore of fpga ? i dont' know ,how I can incorporate in my code or just put them with my code ?and how I run my algorithm through command prompt? my board fpga is cyclone II and the code is in cyclone I EP1C20F400C7 can I use the somme file to excute in cyclone II? regard - Altera_Forum
Honored Contributor
--- Quote Start --- and min the role of the algorithm to read the image load in memore of fpga ? --- Quote End --- Sorry, I didn't understand this sentence. --- Quote Start --- and how I run my algorithm through command prompt? --- Quote End --- Cris, described in his last post how to do it. If you want to use the niosii console as command prompt you don't need my_jtag_atlantic.lib. You only need my_jtag_atlantic.lib if you want to transfer data from your pc to your embedded system via jtag_uart. For example if you want to transfer the content of your script.txt. On PC-side I would write code which set up the connection with your embedded system via my_jtag_atlantic.lib. After establishing the connection (see the example files for that), I would open script.txt with fopen and read the content using fread () or similar function. With my_jtag_atlantic.lib you can then transfer the content to your embedded system. On your embedded system-side you can now use read/write/printf for receiving/transmitting/transmitting data. Example (quick and dirty!):
note: You can not do both. Use the jtag_uart for Command Prompt and for data transfers as described above using my_jtag_atlantic. If you want to do that you need 2 jtag_uarts. One for command prompt and one for transferring data. Regards# include <stdio.h># include <stddef.h># include <unistd.h># include <fcntl.h># include <stdlib.h># include <system.h># include <string.h># include <io.h># include "jtag_comm.h"# include "sys/alt_dev.h"# include "priv/alt_file.h"# include "alt_types.h" # include "altera_avalon_jtag_uart.h" # define READ_BUFFER_SIZE 64# define WRITE_BUFFER_SIZE 64 # define TIMEOUT 1000# define SEND_TIMEOUT 1000 # define SUCCESS 0# define ERROR -1# define ERROR_TIMEOUT -2 // locals UChar8 read_buffer; Int32 read_cnt; Int32 JTAG_COMM_Init (void) { UInt32 ulCnt; Int32 lResult; Char8 sBuf; Char8 sFlush; Int32 dummy; Char8 *pch=NULL; memset(sFlush,0,2048); // forgive me for this hack but I couldn't figure out a more eligant way to do this alt_fd_list.fd_flags |= O_NONBLOCK; // flush any stale STDIN data while((dummy=getchar()) != -1); return SUCCESS; } Int32 JTAG_COMM_Send(Int32 lValue) { printf("%d\n",lValue); return SUCCESS; } Int32 JTAG_COMM_Rcv(Char8 *pMsg) { Char8 sBuf; Int32 lResult=0; memset(sBuf, 0, READ_BUFFER_SIZE); lResult = read(STDIN_FILENO, sBuf, READ_BUFFER_SIZE); if (lResult>0) { memcpy(pMsg,sBuf,lResult); } return lResult; }