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.

Sys/bios USB Stack required for use with TI-RTOS

Hello,

I'd like to create a TI-RTOS project which uses USB, but I'd like to disable dynamic instance creation to save memory. When generating the USB descriptor files, one option is whether or not to use the sys/bios version. The sys/bios version dynamically creates a few items (semaphores, gates, etc.) which requires the HEAP. Is it possible to use the non-sysbios version and add the necessary Hwi for USB functionality?

Best regards,

Blair

  • Hi Blair,

    Based on the thread below, it sounds like if you disable "Dynamic Instance Creation", the BIOS will not do any memory allocation.  If your app doesn't do any malloc() or Memory_alloc() calls, then no heap should be required. I've moved this thread into the TI-RTOS forum for better support.

    Regards,

    James

    MSP Customer Applications

  • In your .cfg file, by setting:

    BIOS.runtimeCreatesEnabled = false;

    The TI-RTOS code which invokes Memory_alloc() is removed from the custom BIOS library that is created during your project build phase.

    As James mentioned, as long as your application code doesn't do any malloc() or Memory_alloc() calls, no heap management code should get linked in with your application.

    Alan
  • Thank you for the responses. Yes, I am aware of that feature. The problem is when I do that the program immediately crashes because of dynamic calls from "USBCDCD.c".  During the "USBCDCD_init" function call which does dynamically create semaphores and gate mutex's. 

    void USBCDCD_init(void)
    {
        Error_Block eb;
        Semaphore_Params semParams;
        GateMutex_Params gateParams;
    
        Error_init(&eb);
    
        /* RTOS primitives */
        Semaphore_Params_init(&semParams);
        semParams.mode = Semaphore_Mode_BINARY;
        semParams.__iprms.name = "semTxSerial";
        semTxSerial = Semaphore_create(0, &semParams, &eb);
        if (semTxSerial == NULL) {
            System_abort("Can't create TX semaphore");
        }
    
        semParams.__iprms.name = "semRxSerial";
        semRxSerial = Semaphore_create(0, &semParams, &eb);
        if (semRxSerial == NULL) {
            System_abort("Can't create RX semaphore");
        }
    
        semParams.__iprms.name = "semUSBConnected";
        semUSBConnected = Semaphore_create(0, &semParams, &eb);
        if (semUSBConnected == NULL) {
            System_abort("Can't create USB semaphore");
        }
    
        GateMutex_Params_init(&gateParams);
        gateParams.__iprms.name = "gateTxSerial";
        gateTxSerial = GateMutex_create(NULL, &eb);
        if (gateTxSerial == NULL) {
            System_abort("Can't create gate");
        }
    
        gateParams.__iprms.name = "gateRxSerial";
        gateRxSerial = GateMutex_create(NULL, &eb);
        if (gateRxSerial == NULL) {
            System_abort("Can't create gate");
        }
    
        gateParams.__iprms.name = "gateUSBWait";
        gateUSBWait = GateMutex_create(NULL, &eb);
        if (gateUSBWait == NULL) {
            System_abort("Could not create USB Wait gate");
        }
    
        /* Initialize the USB module, enable events and connect if UBUS is present */
        USB_setup(true, true);
    }

    I suppose I could adjust the code and remove those calls and add the instances to my configuration file, but I'd prefer using unmodified libraries.

    Best regards,

    Blair

  • Blair,

    If you use the USB library without SYS/BIOS, then you cannot use the Hwi module. You will need to provide your own tasking and interrupt support.

    As you discovered, simply disabling runtime create in SYS/BIOS does not make the program static. All calls to create must be replaced by calls to construct. Unfortunately, the USB stack does not support static configuration.

    In your original post, you indicate that you want to disable create in order to save memory. But simply disabling create does not necessarily save memory. If you replace all dynamic instances with static instances, you are still using about the same amount of memory. There might be some savings if you don't have the heap manager, but I expect that do be small. Bottom line, the USB library needs object instances regardless of how they are created. I suggest you profile your memory usage and then reduce the heap size as much as possible. That should give you the smallest footprint possible.

    ~Ramsey