<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Also:</div><div dir="ltr"><br><div><div>R0 = 0x2000125c R8 = 0x00000000</div><div>R1 = 0x0000f7d0 R9 = 0x00000000</div><div>R2 = 0x200033c8 R10 = 0x00000000</div><div>R3 = 0x20001084 R11 = 0x00000000</div><div>R4 = 0x024010e8 R12 = 0x00008b00</div><div>R5 = 0x00006301 SP = 0xffffff04</div><div>R6 = 0x00000001 LR = 0x00007791</div><div>R7 = 0x00000000 PC = 0x0000631e</div><div>XPSR = 0x21000000 VEC = 0x00000003</div><div>RTEMS version: 5.0.0.6ade69e777ed678d9776956dbe32e858232f915e-modified</div><div>RTEMS tools: 7.3.0 20180125 (RTEMS 5, RSB f07d2b6e9ad70d62eb617a9f5515c5045ee0c119, Newlib 08eab6396f678cf5e5968acaed0bae9fd129983b)</div><div>executing thread ID: 0x089010001</div><div>executing thread name: IDLE</div></div><div><br></div><div>Checking the PC pointed to _Thread_queue_Enqueue:</div><div><div>0000630c <_Thread_queue_Enqueue>:</div><div> 630c: e92d 41f0 stmdb sp!, {r4, r5, r6, r7, r8, lr}</div><div> 6310: 4604 mov r4, r0</div><div> 6312: 6550 str r0, [r2, #84] ; 0x54</div><div> 6314: e003 b.n <b>631e</b> <_Thread_queue_Enqueue+0x12></div><div> 6316: 42a2 cmp r2, r4</div><div> 6318: d04c beq.n 63b4 <_Thread_queue_Enqueue+0xa8></div><div> 631a: 6d64 ldr r4, [r4, #84] ; 0x54</div><div> 631c: b114 cbz r4, 6324 <_Thread_queue_Enqueue+0x18></div><div> <b>631e</b>: 6864 ldr r4, [r4, #4]</div></div><div><br></div><div>Digging into the close function I found that fatal occurred when I try to get inside rtems_libio_free. If I try to get just an address of that function fatal occurred also. Maybe I corrupt some addresses by stack overflow? But my program doesn't do anything, just created node, open it, cal ioctl and than try to close with corresponding fd. I have no debugger right now, maybe someone can give me some advice how I can debug this problem without debugger?</div><div><br></div><div>Thank you.</div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, 9 Nov 2018 at 18:02, Ярослав Лещинский <<a href="mailto:midniwalker@gmail.com">midniwalker@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">I've tried the variant with posix descriptor and got an error when trying to call close(fd). Program crashed with RTEMS_FATAL_SOURCE_EXCEPTION. </div><div dir="ltr"><br></div><div dir="ltr"><div dir="ltr"><div dir="ltr">107 rv = IMFS_make_generic_node(</div><div dir="ltr">108 "/dev/gpio",</div><div dir="ltr">109 S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO,</div><div dir="ltr">110 &gpio_node_control,</div><div dir="ltr">111 NULL);</div><div dir="ltr">112 </div><div dir="ltr">113 assert(rv == 0);</div><div dir="ltr">114 </div><div dir="ltr">115 fd = open("/dev/gpio", O_RDWR);</div><div dir="ltr">116 </div><div dir="ltr">117 if(fd < 0)</div><div dir="ltr">118 {</div><div dir="ltr">119 printf("stderr:[%s] at: [%d]\n", strerror (errno), __LINE__);</div><div dir="ltr">120 }</div><div dir="ltr">121 </div><div dir="ltr">122 rv = ioctl(fd, SET_HIGH, NULL);</div><div dir="ltr">123 </div><div dir="ltr">124 if(rv < 0)</div><div dir="ltr">125 {</div><div dir="ltr">126 printf("stderr:[%s] at: [%d]\n", strerror (errno), __LINE__);</div><div dir="ltr">127 }</div><div>128 <b>/* Everything was ok until now*/</b></div><div dir="ltr">129 rv = close(fd);</div><div dir="ltr">130 if(rv != 0)</div><div dir="ltr">131 {</div><div dir="ltr">132 printf("stderr:[%s] at: [%d]\n", strerror (errno), __LINE__);</div><div dir="ltr">133 }</div><div><br></div><div>It even didn't enter inside the if block line:132. </div><div>For test purpose I'm using such declaration of file handlers:</div><div><br></div><div><div>static const rtems_filesystem_file_handlers_r gpio_node_handlers = { </div><div> .open_h = rtems_filesystem_default_open,</div><div> .close_h = rtems_filesystem_default_close,</div><div> .read_h = NULL,</div><div> .write_h = NULL,</div><div> .ioctl_h = gpio_bus_ioctl,</div><div> .lseek_h = rtems_filesystem_default_lseek,</div><div> .fstat_h = IMFS_stat,</div><div> .ftruncate_h = rtems_filesystem_default_ftruncate,</div><div> .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,</div><div> .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,</div><div> .fcntl_h = rtems_filesystem_default_fcntl,</div><div> .kqfilter_h = rtems_filesystem_default_kqfilter,</div><div> .mmap_h = rtems_filesystem_default_mmap,</div><div> .poll_h = rtems_filesystem_default_poll,</div><div> .readv_h = rtems_filesystem_default_readv,</div><div> .writev_h = rtems_filesystem_default_writev</div><div>};</div></div><div><br></div><div>Could someone take a look and give some advice, seems like I made some silly mistake. </div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, 9 Nov 2018 at 16:26, Ярослав Лещинский <<a href="mailto:midniwalker@gmail.com" target="_blank">midniwalker@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr">Hello Sebastian,<div><br></div><div>Thank you. This looks like what I needed.</div></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, 9 Nov 2018 at 13:32, Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello Yaroslav,<br>
<br>
the initialization sequence is documented here:<br>
<br>
<a href="https://docs.rtems.org/branches/master/c-user/initialization.html#initializing-rtems" rel="noreferrer" target="_blank">https://docs.rtems.org/branches/master/c-user/initialization.html#initializing-rtems</a><br>
<br>
I would not use the I/O Manager. Working with major/minor numbers is <br>
quite painful. I would initialize custom devices in the initialization <br>
task. If you need the POSIX file descriptor API for your devices, then I <br>
would use IMFS_make_generic_node() to register them.<br>
<br>
On 09/11/2018 11:25, Ярослав Лещинский wrote:<br>
> Hello,<br>
><br>
> I read the documentation about I/O Manager, found different source <br>
> codes where mentioning not only rtems_io_* functionality but also <br>
> drvmgr*, rtems_libio* and another mechanisms which are referred to <br>
> device driver topic and I have a feeling that I'm missing something.<br>
><br>
> Could you please correct me if I'm wrong in the following steps of <br>
> initialization of device driver:<br>
><br>
> 1. define *CONFIGURE_MAXIMUM_DRIVERS* macro<br>
> 1. Create *rtems_driver_address_table *and register it via <br>
> *register_io_register_driver*<br>
> 2. Write all necessary functions for *rtems_io_initialize, <br>
> rtems_io_open, etc*<br>
> 3. Associate name with major:minor pair using *rtems_register_name*<br>
> *<br>
> *<br>
> As I understood there are can be a lot of different device drivers <br>
> tables and I should somehow get the right major:minor driver from the <br>
> right table. How I can do this?<br>
><br>
> -- <br>
> --<br>
> Kind regards,<br>
> *Yaroslav Leshchinsky*<br>
><br>
> _______________________________________________<br>
> users mailing list<br>
> <a href="mailto:users@rtems.org" target="_blank">users@rtems.org</a><br>
> <a href="http://lists.rtems.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/users</a><br>
<br>
-- <br>
Sebastian Huber, embedded brains GmbH<br>
<br>
Address : Dornierstr. 4, D-82178 Puchheim, Germany<br>
Phone : +49 89 189 47 41-16<br>
Fax : +49 89 189 47 41-09<br>
E-Mail : <a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a><br>
PGP : Public key available on request.<br>
<br>
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_3413620224836160491m_-138646110126736930gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><span><div style="font-size:12.8px"><font face="verdana, sans-serif" color="#000000">--</font></div><div style="font-size:12.8px"><font face="verdana, sans-serif" color="#000000">Kind regards,</font></div><div style="font-size:12.8px"><font face="verdana, sans-serif" color="#000000"><b>Yaroslav Leshchinsky</b></font></div></span></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_3413620224836160491gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><span><div style="font-size:12.8px"><font face="verdana, sans-serif" color="#000000">--</font></div><div style="font-size:12.8px"><font face="verdana, sans-serif" color="#000000">Kind regards,</font></div><div style="font-size:12.8px"><font face="verdana, sans-serif" color="#000000"><b>Yaroslav Leshchinsky</b></font></div></span></div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><span><div style="font-size:12.8px"><font face="verdana, sans-serif" color="#000000">--</font></div><div style="font-size:12.8px"><font face="verdana, sans-serif" color="#000000">Kind regards,</font></div><div style="font-size:12.8px"><font face="verdana, sans-serif" color="#000000"><b>Yaroslav Leshchinsky</b></font></div></span></div></div></div></div></div>