Forum Discussion
Altera_Forum
Honored Contributor
15 years ago --- 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!):
# 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;
}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