This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[C6713] SIO_create with dynamically created devices fails

In my DSP/BIOS application I need to be able to create devices at runtime. But calling SIO_create on a dynamically created device causes the following error message:

SYS_error called: error id = 0x6

In my real application, this is always the case. However I also have a small example project (see attached file) in which the error occurs only under certain conditions. It is based on the audio example from the DDK, but with dynamically created devices. If you comment out the line

int i = 0;

in the function createStreams, everything works fine. But if you uncomment this line, the error occurs.

What I found out so far (in my real application where i included the sources of the device drivers to the project) is that the mdCreatChan functions of the underlying device never gets called when the error occurs. So the error really comes from SIO_create itself and not from the device. And since the code works under certain conditions, I assume that my code is not completely wrong.

I hope that someone from TI who has access to the sources can step through SIO_create to see whats going wrong. I really have no idea how to solve this.

Robert

  • One thing that I noticed in the tcf you sent is that there is not dioCodec configured under Input/Output -> Device Drivers... That is probably part of the problem... you can not call the device driver for SIO if it is not there.

  • Thanks for your post!

    This was intended since I want to create the DIO adapter at runtime (see setup_dioCodec() in init.c).

    Robert

  • Hi Robert,

    I'm sorry I missed that was exactly your problem... I could not figure it out what is wrong.

    One thing that I can think of is what DSP/BIOS version are you using? What CCS version are you using?

    Please see the TMS320C6000 DSP/BIOS 5.32 Application Programming Interface (API) Ref Guide:

    http://focus.ti.com/general/docs/techdocsabstract.tsp?abstractName=spru403o

    page 107 - states that DEV_createDevice will not be supportted above BIOS 5.32...

     

  • Mariana,

    I'm using DSP/BIOS 5.33.03, CCS 3.3.81.6 and CGT 6.1.8.

    However, I tried it also with DSP/BIOS 5.32.04, as you suggested. But (unfortunately) the effects are exactly the same.

    But anyway, what would be the alternative to DEV_createDevice? The link you provided me also states that one should use the IOM driver interface instead and it refrences to SPRU616. But in SPRU616 (which is, by the way, older than the DSP/BIOS reference guide) I can't find a replacement for DEV_createDevice.

    Robert

  • As far as I know, there is no alternative to DEV_createDevice - you would need to create the Device statically in your DSP/BIOS Configuration file. Is it critical for you project to have the device created dynamically?

  • Yes, I need it to be created dynamically.

    The reason is that in my real application I want to be able to switch between the onboard AIC23-Codec and the codecs on a DSK_AUDIO4 daugthercard at runtime.

    The drivers for both of these devices are based on the generic EDMA McBSP driver, and both of them need McBSP0 and McBSP1. So they can't exist at the same time (because allocating the McBSPs is done in mdBindDev).

    So I would still be very happy if someone from TI could have a look at what is really going wrong inside SIO_create.

    Robert

  • Robert,

    I contacted the DSP/BIOs team  and they said that DEV_createDevice should still work with version 5.33.3. So I'm trying to investigate further, but so far could not figure out what is wrong.

  • Robert,

    I finally nailed it!

    I knew it was a stack problem (because if you comment the "i" the only think that changes is the position of things in the stack) so I tried increasing the system stack, increasing the task stack, put everything in internal memory and did not have any succes...

    Then I saw in your init.c that the variables that you used to configure the drivers were locals (local variables are stored in the stack) - I changed them to globals and everything works fine. The problem is that those variables are going to be accessed by the driver after the configuration as well, so they need to be global.

    Attached is the init.c (just rename it from init.txt to init.c) with the corrections.

     

  • Hi Mariana

    Thanks for your help!!!

    Now I'm able to create everything dynamically [:)]

    However, this works only once because DEV_deleteDevice() does not reset everything to the original states. There are (at least) two problems:

    • The AIC23 driver does not close McBSP0 (which is used for configuration). This one I could solve easily.
    • The second thing is that mdUnBindDev() is called with a wrong argument, which looks like a bug in DSP/BIOS. Therefore, the inUse flag of the port object in the generic driver is not reset properly.

    To show the second one I created a very small example project again which basically calls DEV_createDevice(), DEV_deleteDevice() and DEV_createDevice() again. I included the source of the AIC23 driver and the generic EDMA McBSP driver to show the problem:

    • The generic driver has an array which holds two Port-Objects. These two objects are located in the memory at locations:
      ports[0]: 0x17500
      ports[1]: 0x175B8
    • During mdBindDev(), the generic driver assings the address of ports[1] to devp. You can check this at line 506 in the generic driver.
    • When deleting the device, I would expect that mdUnBindDev() is called with devp pointing to ports[1] (0x175B8) again. But it points to 0x17A10 and therefore
      port->inUse = FALSE
      in line 896 does not reset ports[1] properly.
    • In my real application where also mdCreateChan() is called (when I create the streams), I can see that devp points to the expected location in mdCreateChan().

    Do you also think that mdUnBindDev() is called incorrectly from DSP/BIOS? If yes, is there a chance to get this fixed in the near future?

    Thanks again for your help!

    Robert

  • It's not a bug of DSP/BIOS!

    The problem is that the AIC23 driver does not implement mdUnBindDev(). Therefore, the mdUnBindDev() of the generic driver is called with the local port object of the AIC23 driver.

    To solve this, I had to implement mdUnBindDev() in the AIC23 driver in the following way:

    static Int mdUnBindDev(Ptr devp)
    {
     Int result;
        PortHandle localPort = (PortHandle) devp;
     result = (C6X1X_EDMA_MCBSP_FXNS.mdUnBindDev)(localPort->c6x1xPortObj);
     return result;
    }

    Of course, also the function table has to be modified accordingly.

    Robert

  • Hi Robert,

    I'm glad you figured that out.

    A hint from the DSP/BIOS team: A few things of caution, when calling DEV_createDevice, if the DEV device is configured to use the IOM model the DEV_createDevice will call into the Dev init() and the mdBindDev functions so make sure this code is protect (e.g HWI_disable/enable) or made to be interruptable.