Forum Discussion
Altera_Forum
Honored Contributor
19 years agoToday I write a test.c for test ipc/msg. frist I make it use GCC, it work fine in FC4.
Then I make it use nios2-linux-uclibc-gcc, and exec it. But msgQ not inplemented following is the return information in shell. # msgsend msgget: Calling msgget(0x4d2,01666) msgget: Function not implemented# So I check the nios2 kernel configure, I slect "general-->POSIX Message Queues" setting and rebuild the kernel. follow is rebuilding kernel information: [Alex@localhost linux-2.6.x]$ make ARCH=nios2nommu CROSS_COMPILE=nios2-linux-uclibc- zImage no emulation specific options. CHK include/linux/version.h SPLIT include/linux/autoconf.h -> include/config/* CHK include/nios2_system.h perl -I/home/Alex/linux-2.6.x/arch/nios2nommu/scripts /home/Alex/linux-2.6.x/arch/nios2nommu/scripts/gen_nios2_system.h.pl cpu sdram ext_flash < ../nios2_ptf/CRM3500N_cpu_v2.ptf > include/nios2_system.h.tmp; if [ -r include/nios2_system.h ] && cmp -s include/nios2_system.h include/nios2_system.h.tmp; then rm -f include/nios2_system.h.tmp; else echo ' UPD include/nios2_system.h'; mv -f include/nios2_system.h.tmp include/nios2_system.h; fi make[1]: “arch/nios2nommu/kernel/asm-offsets.s”是最新的。 CHK include/asm-nios2nommu/asm-offsets.h CHK include/linux/compile.h CHK usr/initramfs_list CC ipc/mqueue.o CC ipc/msgutil.o LD ipc/built-in.o GEN .version CHK include/linux/compile.h UPD include/linux/compile.h CC init/version.o LD init/built-in.o LD vmlinux SYSMAP System.map OBJCOPY arch/nios2nommu/boot/compressed/vmlinux.bin GZIP arch/nios2nommu/boot/compressed/vmlinux.bin.gz LD arch/nios2nommu/boot/compressed/piggy.o LD arch/nios2nommu/boot/compressed/vmlinux OBJCOPY arch/nios2nommu/boot/zImage Kernel: arch/nios2nommu/boot/zImage is ready [Alex@localhost linux-2.6.x]$ I find CC ipc/mqueue.o , so I think maybe ipcs will suppourt. CC ipc/msgutil.o LD ipc/built-in.o http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/sad.gif I exec the zImage, but ipcs cmd still lost. And exec the test bin still failed. The following is the test.c for test ipc/mqueue # include <sys/types.h># include <sys/ipc.h># include <sys/msg.h># include <stdio.h># include <string.h># define MSGSZ 128 /* * Declare the message structure. */ typedef struct { long mtype; char mtext[MSGSZ]; } message_buf; main(){ int msqid; int msgflg = IPC_CREAT | 0666; key_t key; message_buf sbuf; size_t buf_length; /* * Get the message queue id for the * "name" 1234, which was created by * the server. */ key = 1234; (void) fprintf(stderr, "\nmsgget: Calling msgget(%#lx,\%#o)\n", key, msgflg); if ((msqid = msgget(key, msgflg )) < 0) { perror("msgget"); exit(1); } else (void) fprintf(stderr, "msgget: msgget succeeded: msqid = %d\n", msqid); /* * We'll send message type 1 */ sbuf.mtype = 1; (void) fprintf(stderr, "msgget: msgget succeeded: msqid = %d\n", msqid); (void) strcpy(sbuf.mtext, "Did you get this?"); (void) fprintf(stderr, "msgget: msgget succeeded: msqid = %d\n", msqid); buf_length = strlen(sbuf.mtext) ; /* * Send a message. */ if (msgsnd(msqid, &sbuf, buf_length, IPC_NOWAIT) < 0) { printf ("%d, %d, %s, %d\n", msqid, sbuf.mtype, sbuf.mtext, buf_length); perror("msgsnd"); exit(1); } else printf("Message: \"%s\" Sent\n", sbuf.mtext); exit(0); } Pleaes let us solver the question togeter. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif