Altera_Forum
Honored Contributor
21 years agoLinux Application
Greetings, Long story here...
I have taken the Linux Ref Design provided by Microtronix and I have added a PIO -> user_pio. I have re-generated the system and compiled my design in Quartus. When I launch the IDE, I can create a NIOS II C Application and run code to write to my PIO (using IOWR_ALTERA_AVALON_PIO_DATA macro function). When I create my Linux Application Project, it does not like the IOWR_ALTERA_AVALON_PIO_DATA macro - understandably since this macro is not supported in uC-Linux. So... I have tried to access my pio using a FILE pointer such that:FILE *fp_User_PIO = 0;
fp_User_PIO = fopen("/dev/user_pio","w");
if(fp_User_PIO==0)
printf("Error opening User PIO\n");
// write AA to my PIO
fprintf(fp_User_PIO, "%d", 0xAA); After adding this prog to my filesystem and running the program; it crashed. No suprise after realizing that my new PIO that I added does not exist in /dev (Note that the button_pio created by the ref design does exist as /dev/button) So, I tried writing to my user_pio as memory: char* pUserPIO = (char *)USER_PIO_BASE; // this is the base address for my user_pio defined in my system.h file (yes I have included it)
// write AA to my PIO
pUserPIO = 0xAA; This too crashed. I am assuming this is standard practice with a "real" OS such that you don't want any yahoo writing to "just any" memory location. I have considered using malloc() but figure this will grab a whole new hunk of memory. Does anyone know how to write to my user_pio? Should I add it to my FS as /dev/user_pio? If so, how? Thanks, -Terry