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++
12600 Discussions

Argument passing to C Main using Nios II IDE

Altera_Forum
Honored Contributor II
991 Views

Hi, 

 

It would be very helpful if any of you can tell me If I can pass arguments to Main function in a C program using Nios II IDE, either using GUI or shell. I know how to run without arguments using both GUI and shell but I need help passing arguments. 

 

Thanks, 

Amjad
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
285 Views

I haven't done this myself, but in alt_main.c the arguments to main.c are passed. 

 

024: /* 025: * Standard arguments for main. By default, no arguments are passed to main. 026: * However a device driver may choose to configure these arguments by calling 027: * alt_set_args(). The expectation is that this facility will only be used by 028: * the iclient/ihost utility. 029: */ 030: 031: int alt_argc = 0; 032: char** alt_argv = {NULL}; 033: char** alt_envp = {NULL}; ... 116: main (alt_argc, alt_argv, alt_envp);  

 

What exactly are you trying to accomplish? If you're looking for input arguments, why not keep it simple and use scanf()?
0 Kudos
Altera_Forum
Honored Contributor II
285 Views

Hi, Thanks for the prompt reply. I will try it out.  

 

I actually need to demonstrate buffer overflow attacks in embedded systems, which happens when you pass arguments with size more than the allotted memory.
0 Kudos
Altera_Forum
Honored Contributor II
285 Views

I'm no security guru, but would a RPC suffice? Lots of embedded systems have TCP/IP stacks. I imagine RPCs are a simple way to control an embedded device.

0 Kudos
Reply