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

how to use "msgget" in nios2 uclinx?

Altera_Forum
Honored Contributor II
1,568 Views

hi: 

 

I use function ret = msgget(KEY_MQ_CORE, IPC_CREAT|0660); make successed. 

 

After exec, but the return value is -1 

 

I want to use cmd "IPCS" to check the ipc ID. but shell return: not found. 

 

http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/sad.gif  

 

How can I do? The same function "msgget" used in other uClinx os is OK. 

 

Why failed in nios2 uClinux? Why the cmd "IPCS" not support nios2 linux? 

 

Thanks a lot.
0 Kudos
13 Replies
Altera_Forum
Honored Contributor II
768 Views

Today 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 &#39; UPD include/nios2_system.h&#39;; mv -f include/nios2_system.h.tmp include/nios2_system.h; fi 

make[1]: “arch/nios2nommu/kernel/asm-offsets.s”&#26159;&#26368;&#26032;&#30340;&#12290; 

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&#39;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
0 Kudos
Altera_Forum
Honored Contributor II
768 Views

for ipcs you can enable it in busybox under buildroot. 

But I don&#39;t know if nios2 kernel support it correctly.
0 Kudos
Altera_Forum
Honored Contributor II
768 Views

 

--- Quote Start ---  

originally posted by hippo@May 11 2006, 02:10 PM 

for ipcs you can enable it in busybox under buildroot. 

but i don&#39;t know if  nios2 kernel support it correctly. 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=15279) 

--- quote end ---  

 

--- Quote End ---  

 

I enabled msg queue in kernel, run ipcs, 

# ipcs 

kernel not configured for shared memory 

kernel not configured for semaphores 

kernel not configured for message queues#
0 Kudos
Altera_Forum
Honored Contributor II
768 Views

Thank you hippo. 

 

I use make menuconfig and make in ~/buildroot/build_nios2/busybox dir. 

 

frist I enable " ipcs" 

 

second "make"  

 

but how can I update roofs? I use"make" in `/buildroot dir,but the busybox exec file is not the nios2 exec file
0 Kudos
Altera_Forum
Honored Contributor II
768 Views

 

--- Quote Start ---  

originally posted by hippo+may 11 2006, 01:47 am--><div class='quotetop'>quote (hippo @ may 11 2006, 01:47 am)</div> 

--- quote start ---  

<!--quotebegin-hippo@May 11 2006, 02:10 PM 

for ipcs you can enable it in busybox under buildroot. 

but i don&#39;t know if  nios2 kernel support it correctly. 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=15279) 

--- quote end ---  

 

--- Quote End ---  

 

I enabled msg queue in kernel, run ipcs, 

# ipcs 

kernel not configured for shared memory 

kernel not configured for semaphores 

kernel not configured for message queues#  

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=15281)</div> 

[/b] 

--- Quote End ---  

 

 

HI hippo: 

 

What meanings the "kernel not configured for message queues"? 

 

Is it meaning the nios2 uclinux kernel not support message queues?or I lost some 

 

setting in kernel configur?
0 Kudos
Altera_Forum
Honored Contributor II
768 Views

 

--- Quote Start ---  

originally posted by alex824@May 11 2006, 05:11 PM 

thank you hippo. 

 

i use make menuconfig and make in ~/buildroot/build_nios2/busybox dir. 

 

frist i enable " ipcs" 

 

second "make"  

 

but how can i update roofs? i use"make" in `/buildroot dir,but the busybox exec file is not  the nios2 exec file 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=15286) 

--- quote end ---  

 

--- Quote End ---  

 

Please follow step12 in the buildroot guide.
0 Kudos
Altera_Forum
Honored Contributor II
768 Views

TO_BE_DONE

0 Kudos
Altera_Forum
Honored Contributor II
768 Views

please check ~/apps/mqueue .

0 Kudos
Altera_Forum
Honored Contributor II
768 Views

 

--- Quote End ---  

 

 

SysV IPC can not support without MMU. 

I am not sure if msg queue is supported in Nios II. 

please debug the kernel ipc/ to find out. 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=15303)</div> 

 

--- Quote End ---  

 

 

 

I have a doubt 

I use "msgget", "msgsnd" "msgrcv" in winbond arm7 cpu is ok. 

The winbond arm7 cpu without MMU.
0 Kudos
Altera_Forum
Honored Contributor II
768 Views

 

--- Quote Start ---  

 

 

--- Quote End ---  

 

 

SysV IPC can not support without MMU. 

I am not sure if msg queue is supported in Nios II. 

please debug the kernel ipc/ to find out. 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=15303)</div> 

 

--- Quote End ---  

 

 

 

I have a doubt 

I use "msgget", "msgsnd" "msgrcv" in winbond arm7 cpu is ok. 

The winbond arm7 cpu without MMU. 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=15314)</div> 

 

--- Quote End ---  

 

There may be bugs for msg queue on Nios2 kernel.
0 Kudos
Altera_Forum
Honored Contributor II
768 Views

 

--- Quote Start ---  

originally posted by hippo@May 11 2006, 09:11 PM 

please check ~/apps/mqueue . 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=15310) 

--- quote end ---  

 

--- Quote End ---  

 

 

I make ~/apps/mqueue but failed. So I rework the Makefile of mqueue . 

 

But I meet a question. If I want to use mqueue ,frist I must make ~/apps/mqueue/src to make libmqueue.a 

 

So I added "ar = nios2-linux-uclibc-ar&#39; id makefile. 

 

but in make process, the cc use gcc not nios2-linux-uclibc-gcc,so the libmqueue.a 

is wrong.
0 Kudos
Altera_Forum
Honored Contributor II
768 Views

 

--- Quote Start ---  

originally posted by alex824+may 12 2006, 02:51 pm--><div class='quotetop'>quote (alex824 @ may 12 2006, 02:51 pm)</div> 

--- quote start ---  

<!--quotebegin-hippo@May 11 2006, 09:11 PM 

please check ~/apps/mqueue . 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=15310) 

--- quote end ---  

 

--- Quote End ---  

 

 

I make ~/apps/mqueue but failed. So I rework the Makefile of mqueue . 

 

But I meet a question. If I want to use mqueue ,frist I must make ~/apps/mqueue/src to make libmqueue.a 

 

So I added "ar = nios2-linux-uclibc-ar&#39; id makefile. 

 

but in make process, the cc use gcc not nios2-linux-uclibc-gcc,so the libmqueue.a 

is wrong. 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=15316)</div> 

[/b] 

--- Quote End ---  

 

Please look at download/mx140apps.diff, and modify the Makefile.
0 Kudos
Altera_Forum
Honored Contributor II
768 Views

--- Quote End ---  

 

Please look at download/mx140apps.diff, and modify the Makefile. 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=15319)</div> 

 

--- Quote End ---  

 

 

Thanks hippo. 

I have already rework ~/app/mqueue fo following mx140apps.diff. 

 

But the mx140apps.diff not dabble at the link *.A . 

 

Can you give us a template?
0 Kudos
Reply