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.

handle = WiFi_open(Board_WIFI, Board_SPI_CC3000, NULL, &params);

Hi,

I am using a cc3000patcher_TivaTM4C123GH6PM. I can't pass the line :

handle = WiFi_open(Board_WIFI, Board_SPI_CC3000, NULL, &params);

which is a the very beginning of the task. I had checked SPI configuration, and all the signals involved. They are all there.

It is a bit difficult for me to understand what is going on following the PC in assembly...

Is there any suggestion how to debug and understand what this issue issue?

If somebody can also suggest a reference document that describe the Wifi_open function, that will help me for sure.

Thanks.

  • Hi Gianluca,

    What version of the host driver are you using? And what is the service pack version that you are using along with that?
    Did you flash the relevant patches using the patch programmer (http://processors.wiki.ti.com/index.php/Http://processors.wiki.ti.com/index.php/CC3000_Patch_Programmer_pre_SP1.12)?

    Also, make sure that you are using wlan_start(0) call, which ensures using the patches from EEPROM and not from the host itself.

    Thanks & Regards,
    Raghavendra

  • Hi,

    /* Service Pack version P4.11.6.12.14 -  Driver patches */    Patch Programmer v1.10.2

    Tirtos_1_10_00_23 package (I have found the patcher here). CCS5.4

    I spent a bit more time on this issue and I have some other info:

    in the cc3000patcher_readme.txt I have:

    The application does the following items
        - Call the Board_initGeneral function for general board setup.
        - Call the Board_initGPIO to initialize Board_LED.
        - Call the Board_initWiFi function to initialize WiFi driver and the GPIO
          and SPI pins that it requires.
        - Call BIOS_start. This function does not return. It starts the SYS/BIOS
          threads.

    Looking at the code, I see

        WiFi_Params_init(&params);
        params.bitRate = 1000000;
        handle = WiFi_open(Board_WIFI, Board_SPI_CC3000, NULL, &params);

        /* Check service pack version */
        nvmem_read_sp_version(spNum);
        if ((spNum[0] == PACKAGEID) && (spNum[1] == PACKAGEBLDNUM)) {
            System_printf("You are using service pack version %d.%d already. No "
                          "need to patch the CC3000.\n\n", spNum[0], spNum[1]);

            GPIO_write(Board_LED, Board_LED_ON);
            BIOS_exit(0);
        }

    If I put a breakpoints after

    handle = WiFi_open(Board_WIFI, Board_SPI_CC3000, NULL, &params);

    If I foollow the PC I can tell you that wifi state go from STATE_POWER to STATE_INITIALIZATION to STATE_WRITE_EOT. wlan_start(0) is called. I don't have any errors message in console, but I do not have also any indication of the status...so I don't know if the program is doing something or not.

    The program runs.

    For sure at the base there is a lack of basic knowledge on my side (working on it).


    My understanding is that the patch programmer updates the EEPROM in the CC3000 using the serial interface between MCU and CC3000 itself.

    This was in my plan the first this to do in order to start to use CC3000. Is there any wifi communication involved? Do I need to run also something in my Laptop?


    Sorry for the elementary questions...but even if there is a huge quantity of material online...I think I am missing something really simple.

    Thanks for your time.

    Gianluca

  • Hi Gianluca,

    Your understanding about using the patch programmer is correct. But you would have to make sure that you use the correct Host driver version along with the correct Service pack. I would suggest you to obtain the release package and service pack from the below link.

    http://processors.wiki.ti.com/index.php/CC3000_Wi-Fi_Downloads_1.11.1. Look for the patch programmer and the SDK download link to get the Service pack and the corresponding host driver respectively.

    No wifi communication is involved during the initialization phase.

    Thanks & Regards,
    Raghavendra

  • i'm use the same board,and i use ccs to drive this,so i download two sample sorce code ,one is udpecho,another one is tcpecho,when done,i have no change any of then ,the tcpecho working best,but the udpecho don't working,it also stuck on WiFi_open.

    anther trouble,the board can't debug with ccs,once debug,it must stuck on WiFi_open,so i must use the UART to debug it

  • Hello, I have imported also those 2 projects but I wanted first to make sure patch_programmer was working fine.

    Now I have some more information about the failure.

    Using CCS/Tools/System Analyzer/Live..... I can see what happens.

    ,594662,,CORTEX_M4_0,WiFi: Object created.
    ,602412,,CORTEX_M4_0,WiFi: wlan_start() was called. IRQ interrupt is now enabled.,
    ,608487,,CORTEX_M4_0,WiFi: 0x1 was written to the WLAN EN
    ,63606712,,CORTEX_M4_0,WiFi: CC3000 is powered up and ready.
    ,63617712,,CORTEX_M4_0,WiFi: Performing first write to CC3000 after wlan_start().
    ,63742387,,CORTEX_M4_0,ERROR: [wifi/WiFiTivaCC3000.c:245] WiFi: SPI transfer (write) failed to begin!

    So, this is the first write to CC3000.

    This is the code:

    * ======== WiFiTivaCC3000_firstWrite ========

    * Function to perform the first write after power up. CC3000 requires a few

    * 50 us delays during this first transaction.

    */

    Void WiFiTivaCC3000_firstWrite(UChar *userBuffer, UShort length)

    {

    UInt delayAmt;

    Types_FreqHz freq;

    WiFiTivaCC3000_Object *object = wiFiHandle->object;

    WiFiTivaCC3000_HWAttrs const *hwAttrs = wiFiHandle->hwAttrs;

    Log_print0(Diags_USER1, "WiFi: Performing first write to CC3000 after "

    "wlan_start().");

    /* Calculate delay amount */

    BIOS_getCpuFreq(&freq);

    delayAmt = freq.lo/60000;

    /* Assert CS */

    GPIOPinWrite(hwAttrs->csPort, hwAttrs->csPin, 0);

    /* Need to wait at least 50 us after asserting CS */

    SysCtlDelay(delayAmt);

    /* SPI writes first 4 bytes of data */

    object->transaction.txBuf = userBuffer;

    object->transaction.count = 4;

    if(!SPI_transfer(object->spiHandle, &object->transaction)){

    Log_error0("WiFi: SPI transfer (write) failed to begin!");

    }

    /* Need to wait at least 50 us again */

    SysCtlDelay(delayAmt);

    /* SPI writes another 4 bytes of data */

    object->transaction.txBuf = userBuffer + 4;

    object->transaction.count = length - 4;

    object->spiState = STATE_WRITE_EOT;

    if(!SPI_transfer(object->spiHandle, &object->transaction)){

    Log_error0("WiFi: SPI transfer (write) failed to begin!");

    }}

    I will spend some more time on this issue but if I do not find a solution in the next 2 weeks I will change platform because I spent already too much time.

    There is not patcher update available for my configuration (TIROS+Launchpad) so I am not going to do a porting from another SW. I have to find the problem in this configuration.

  • Hi Gianluca,

    As this is the first write, have you checked if the IRQ has gone low after the nShutdown was toggled? You can only proceed with first write after you have waited for this IRQ line to go low.

    And also, assuming that with patches in place inside the EEPROM, please make sure that you are requesting patches within EEPROM. That is, in the SimpleLink_Init_Start 'SL_PATCHES_REQUEST_DEFAULT' is passed as an argument.

    Thanks & Regards,
    Raghavendra

  • Ok, first I answer your questions then some update.

    your questions:

    1) IRQ goes low. I had a problem in the DMA configuration. I fixed it (wrong channel). Now the first write is ok (no more errors).

    2) The sw I am using is an example coming from TI I don't know where the SL_PATCHES_REQUEST_DEFAULT is and where I should check. If you can please explain then I can check.

    I have the feeling that everything is working fine but the original flow was supposed to pass the handle and then give me some feedback...turn on a LED, some info on the console...

    handle = WiFi_open(Board_WIFI, Board_SPI_CC3000, NULL, &params);

    GPIO_write(Board_LED, Board_LED_ON);

    /* Check service pack version */

    nvmem_read_sp_version(spNum);

    if ((spNum[0] == PACKAGEID) && (spNum[1] == PACKAGEBLDNUM)) {

    System_printf("You are using service pack version %d.%d already. No "

    "need to patch the CC3000.\n\n", spNum[0], spNum[1]);

    GPIO_write(Board_LED, Board_LED_ON);

    BIOS_exit(0);

    }

    System_printf("Test1\n");

    /* Restart CC3000 for patching */

    wlan_stop();

    Task_sleep(500);

    wlan_start(1);

    But Wifi_Open points to a WifiTivaCC300_open...and the flow never go back to the original Wifi_open function..

    static WiFi_Handle WiFiTivaCC3000_open(WiFi_Handle handle, UInt spiIndex,

    WiFi_evntCallback evntCallback,

    WiFi_Params *params)

    {

    SPI_Params spiParams;

    WiFi_Params wiFiParams;

    Hwi_Params hwiParams;

    Semaphore_Params semParams;

    Error_Block eb;

    UInt key;

    WiFiTivaCC3000_Object *object = wiFiHandle->object;

    WiFiTivaCC3000_HWAttrs const *hwAttrs = wiFiHandle->hwAttrs;

    /* Determine if the WiFi object has already been opened */

    key = Hwi_disable();

    if (object->hwiIrq != NULL) {

    Hwi_restore(key);

    Log_warning0("WiFi: This index is already in use.");

    return (NULL);

    }

    /* Mark the handle as being used */

    object->hwiIrq = (Hwi_Handle)~0;

    Hwi_restore(key);

    /* Create a semaphore to block for the write transaction. */

    Error_init(&eb);

    Semaphore_Params_init(&semParams);

    semParams.mode = Semaphore_Mode_BINARY;

    object->writeComplete = Semaphore_create(0, &semParams, &eb);

    if (object->writeComplete == NULL) {

    Log_error0("WiFi: Error creating semaphore. WiFi instance was not ""opened.");

    WiFiTivaCC3000_close(handle);

    return (NULL);

    }

    /* BIOS Hwi create for IRQ interrupt */

    Hwi_Params_init(&hwiParams);

    object->hwiIrq = Hwi_create(hwAttrs->irqIntNum,

    WiFiTivaCC3000_hwiIrqFxn, &hwiParams, &eb);

    if (object->hwiIrq == NULL) {

    Log_error0("WiFi: Error creating IRQ Hwi. WiFi instance was not ""opened.");

    WiFiTivaCC3000_close(handle);

    return (NULL);

    }

    /* Set up the parameters */

    if (params == NULL) {

    /* No params passed in, so use the defaults */

    WiFi_Params_init(&wiFiParams);

    params = &wiFiParams;

    }

    /* Initialize SPI parameters */

    SPI_Params_init(&spiParams);

    spiParams.transferMode = SPI_MODE_CALLBACK;

    spiParams.transferCallbackFxn = WiFiTivaCC3000_spiCallbackFxn;

    spiParams.mode = SPI_MASTER;

    spiParams.bitRate = params->bitRate;

    spiParams.dataSize = 8;

    spiParams.frameFormat = SPI_POL0_PHA1;

    GPIOIntTypeSet(hwAttrs->irqPort, hwAttrs->irqPin,

    GPIO_FALLING_EDGE);

    object->spiHandle = SPI_open(spiIndex, &spiParams);

    if (object->spiHandle == NULL) {

    Log_error0("WiFi: Error opening SPI. WiFi instance was not opened.");

    WiFiTivaCC3000_close(handle);

    return (NULL);

    }

    Log_print0(Diags_USER1, "WiFi: Object created.");

    /* Register callbacks with the host driver */

    wlan_init(evntCallback, NULL, NULL, NULL,

    WiFiTivaCC3000_readIrqPin,

    WiFiTivaCC3000_enableIrqInt,

    WiFiTivaCC3000_disableIrqInt,

    WiFiTivaCC3000_writeWlanEnPin);

    /* Start the CC3000. Pass 0 because no patches are available. */

    wlan_start(0);

    return (handle);

    }

    ....I can brake on wlan_start(0)....so I guess....all the steps were done correctly...just no communicated

    However...

    it seems performing all the operations  in the correct way...and I reach this while loop:

    //*****************************************************************************

    //! Event Handler

    //! @param buf incoming data buffer

    //! @param len size of data buffer

    //! @return ESUCCESS if successful, EFAIL if an error occured

    //! @brief Parse the incoming events packets and issues correponding

    //! event handler from gloabal array of handlers pointers

    //*****************************************************************************

    unsigned char *

    hci_event_handler(void *pRetParams, unsigned char *from, unsigned char *fromlen)

    {

    unsigned char *pucReceivedData, ucArgsize;

    unsigned short usLength;

    unsigned char *pucReceivedParams;

    unsigned short usReceivedEventOpcode = 0;

    unsigned long retValue32;

    unsigned char * RecvParams;

    unsigned char *RetParams;

    while (1)

    {

    if (tSLInformation.usEventOrDataReceived != 0)

    {

    pucReceivedData = (tSLInformation.pucReceivedData);

    if someone wants to take a look to the project the name is : cc30000patcher_TivaTM4C123GH6PM.

    I still do not understand what the program did and why it did not follow the original flow...if someone has time to take a look and make some comment, I will really appreciate.

    Sorry for the long list of coded...again...it is not mine...it is the coming from the project above (no touched), so if you want better navigate the files..you may look to the files project directly.

    Gianluca

     

  • Bumping, I have exactly the same issue and I cannot solve it.

    I'm using CC3000 board with Service Pack 1.24.

  • Problem solved (at least in my case). It was related to debugger settings.

    Go to project's properties, then Debug -> Tiva Flash Settings and mark "Reset program during load to Flash memory".