Fix the issue about RTEMS-libbsd interrupt install failed
RTEMS-libbsd use RTEMS as kernel, and libbsd as a library.
But when i use the interrupt in RTEMS-libbsd, For some bsp, there will be an situation about interrupt can not used.
For example, When I transplant USB driver for the beaglebone black , we need to install usb interrupt(interrupt vector 0x18, 0x19). But the program stuck at the interrupt install function, That is _Terminate.
What's more, my GSOC mentor Christian Mauderer meet the same problem when he used the ATSAM v71 bsp.
Through gdb for debug, gdb output information:
But when i use the interrupt in RTEMS-libbsd, For some bsp, there will be an situation about interrupt can not used.
For example, When I transplant USB driver for the beaglebone black , we need to install usb interrupt(interrupt vector 0x18, 0x19). But the program stuck at the interrupt install function, That is _Terminate.
What's more, my GSOC mentor Christian Mauderer meet the same problem when he used the ATSAM v71 bsp.
Through gdb for debug, gdb output information:
- (gdb) c
- Continuing.
- Breakpoint 3, _Terminate (the_source=the_source@entry=RTEMS_FATAL_SOURCE_BSP, the_error=the_error@entry=0) at /home/christian/rtems/rtems-sichenzhao/build/..//rtems/c/src/../../cpukit/score/src/interr.c:34
- 34 {
- (gdb) bt
- #0 _Terminate (the_source=the_source@entry=RTEMS_FATAL_SOURCE_BSP, the_error=the_error@entry=0) at /home/christian/rtems/rtems-sichenzhao/build/..//rtems/c/src/../../cpukit/score/src/interr.c:34
- #1 0x800a71c4 in rtems_fatal (error_code=0, fatal_source=RTEMS_FATAL_SOURCE_BSP) at ../../../../../.././beagleboneblack/lib/include/rtems/fatal.h:88
- #2 bsp_fatal (code=BSP_FATAL_INTERRUPT_INITIALIZATION) at ../../../../../.././beagleboneblack/lib/include/bsp/fatal.h:142
- #3 omap_get_mir_reg (vector=<optimized out>, mask=<optimized out>) at /home/christian/rtems/rtems-sichenzhao/build/..//rtems/c/src/lib/libbsp/arm/beagle/irq.c:92
- #4 0x800a7270 in bsp_interrupt_vector_disable (vector=<optimized out>) at /home/christian/rtems/rtems-sichenzhao/build/..//rtems/c/src/lib/libbsp/arm/beagle/irq.c:113
- #5 0x800a7344 in bsp_interrupt_server_trigger (arg=0x8032b488, arg@entry=0x8032b480) at /home/christian/rtems/rtems-sichenzhao/build/..//rtems/c/src/lib/libbsp/arm/beagle/../../shared/src/irq-server.c:59
- #6 0x800a7584 in bsp_interrupt_server_call_helper (vector=vector@entry=18, options=options@entry=0, handler=<optimized out>, arg=arg@entry=0x800369b8 <nexus_setup_intr+148>, helper=0x800a73b0 <bsp_interrupt_server_install_helper>)
- at /home/christian/rtems/rtems-sichenzhao/build/..//rtems/c/src/lib/libbsp/arm/beagle/../../shared/src/irq-server.c:276
- #7 0x800a7678 in rtems_interrupt_server_handler_install (server=server@entry=0, vector=vector@entry=18, info=<optimized out>, options=options@entry=0, handler=0x800a73b0 <bsp_interrupt_server_install_helper>,
- handler@entry=0x80000898 <musbotg_wrapper_interrupt>, arg=arg@entry=0x80396a90) at /home/christian/rtems/rtems-sichenzhao/build/..//rtems/c/src/lib/libbsp/arm/beagle/../../shared/src/irq-server.c:352
- #8 0x800369b8 in nexus_setup_intr (dev=dev@entry=0x803951a8, child=child@entry=0x803954f8, res=res@entry=0x803982b0, flags=flags@entry=514, filt=filt@entry=0x0, intr=intr@entry=0x80000898 <musbotg_wrapper_interrupt>, arg=0x80396a90,
- arg@entry=0x80000bac <musbotg_attach+444>, cookiep=0x8039709c, cookiep@entry=0x80000898 <musbotg_wrapper_interrupt>) at ../../rtemsbsd/rtems/rtems-kernel-nexus.c:307
- #9 0x800208dc in BUS_SETUP_INTR (_cookiep=0x80000898 <musbotg_wrapper_interrupt>, _arg=0x80000bac <musbotg_attach+444>, _intr=0x80000898 <musbotg_wrapper_interrupt>, _filter=0x0, _flags=514, _irq=0x803982b0, _child=0x803954f8,
- _dev=0x803951a8) at ../../rtemsbsd/include/rtems/bsd/local/bus_if.h:529
- #10 _bsd_bus_setup_intr (dev=dev@entry=0x803954f8, r=0x803982b0, flags=flags@entry=514, filter=filter@entry=0x0, handler=handler@entry=0x80000898 <musbotg_wrapper_interrupt>, arg=arg@entry=0x80396a90, cookiep=cookiep@entry=0x8039709c)
- at ../../freebsd/sys/kern/subr_bus.c:4584
- #11 0x80000bac in musbotg_attach (dev=0x803954f8) at ../../freebsd/sys/arm/ti/am335x/am335x_musb.c:304
- #12 0x8001f07c in DEVICE_ATTACH (dev=0x803954f8) at ../../rtemsbsd/include/rtems/bsd/local/device_if.h:180
- #13 _bsd_device_attach (dev=dev@entry=0x803954f8) at ../../freebsd/sys/kern/subr_bus.c:2947
- #14 0x8001ff44 in _bsd_device_probe_and_attach (dev=dev@entry=0x803954f8) at ../../freebsd/sys/kern/subr_bus.c:2903
- #15 0x8001fff0 in _bsd_bus_generic_attach (dev=<optimized out>) at ../../freebsd/sys/kern/subr_bus.c:3714
- #16 0x8001f07c in DEVICE_ATTACH (dev=0x803951a8) at ../../rtemsbsd/include/rtems/bsd/local/device_if.h:180
- #17 _bsd_device_attach (dev=dev@entry=0x803951a8) at ../../freebsd/sys/kern/subr_bus.c:2947
- #18 0x8001ff44 in _bsd_device_probe_and_attach (dev=dev@entry=0x803951a8) at ../../freebsd/sys/kern/subr_bus.c:2903
- #19 0x800203e8 in _bsd_bus_generic_new_pass (dev=0x80392950) at ../../freebsd/sys/kern/subr_bus.c:4000
- #20 0x8001eca8 in BUS_NEW_PASS (_dev=0x80392950) at ../../rtemsbsd/include/rtems/bsd/local/bus_if.h:939
- #21 _bsd_bus_set_pass (pass=2147483647) at ../../freebsd/sys/kern/subr_bus.c:987
- #22 0x8003e2fc in _bsd_mi_startup () at ../../freebsd/sys/kern/init_main.c:306
- #23 0x80036228 in rtems_bsd_initialize () at ../../rtemsbsd/rtems/rtems-kernel-init.c:158
- #24 0x800005e4 in Init (arg=<optimized out>) at ../../testsuite/usb01/init.c:110
- #25 0x800ccfcc in _Thread_Handler () at /home/christian/rtems/rtems-sichenzhao/build/..//rtems/c/src/../../cpukit/score/src/threadhandler.c:88
- #26 0x800b9cb0 in _Thread_Life_action_handler (executing=0x0, action=<optimized out>, lock_context=0x0) at /home/christian/rtems/rtems-sichenzhao/build/..//rtems/c/src/../../cpukit/score/src/threadrestart.c:379
- #27 0x00000000 in ?? ()
- Backtrace stopped: previous frame identical to this frame (corrupt stack?)
- (gdb)
- (gdb) up
- #3 omap_get_mir_reg (vector=<optimized out>, mask=<optimized out>) at /home/christian/rtems/rtems-sichenzhao/build/..//rtems/c/src/lib/libbsp/arm/beagle/irq.c:92
- 92 bsp_fatal(0);
- (gdb) list
- 87 mir_reg = OMAP3_INTCPS_MIR2;
- 88 } else if (vector < 128u) {
- 89 mir_reg = OMAP3_INTCPS_MIR3;
- 90 } else {
- 91 /* Invalid IRQ number. This should never happen. */
- 92 bsp_fatal(0);
- 93 }
- 94
- 95 return mir_reg;
- 96 }
- (gdb)
We can see that the code is terminated in bsp_fatal (), which is in the rtems source beagle's irq.c file
So , it seems that the reason for the problem is obvious:
128 is a pseudo vector that is used for the interrupt server on this target. But during install of the vector, the `bsp_interrupt_vector_disable` is called. this function doesn't know about the pseudo-IRQ number that is used for the interrupt server. Therefore it would try to disable it in the hardware.
And the hardware doesn't have that much interrupts.
And Christian Mauderer has create a patch to solve the ATSAM v71 irq:
I use this as a reference:
In the rtems source beagle bsp folder, the irq.c file, bsp_interrupt_vector_disable and bsp_interrupt_vector_enable function, i add a judge, if the interrupt vector is valid, then the processing
The patch i create for Beaglebone Black is:
The patch reads as follows:
评论
发表评论