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.

Compiler/TM4C123GH6PGE: usb_stick_ update example not working

Part Number: TM4C123GH6PGE

Tool/software: TI C/C++ Compiler

Hello.

I can not update to the USB stick. !!

Let me know what's problem. ?

The problem is as follows.

I am using rvmdk (Keil tools) as my development environment.

(note) USB Stick FAT32 Format. , DK-EVB(DK-TM4C123G)

Step1: Rename the built usb_stick_demo.bin file to the name FIRMWAREBIN.bin.

Step2: Copy USB stick memory FIRMWAREBIN.bin file under root.

step3: Build the usb_stick_update example to write to the DK-EVB.

step4: OLED Display has no letters.

Step5: Connect USB stick memory to USB OTG Connector.

Step6: Press the Select button on the DK-EVB.

Result: There is no reaction after 3 minutes.

I tried to analyze the source with the blake pointer.

The UpdaterUSB () function call does not leave the endless loop with USBHCDMain ().

regards.

  • Hi Jame,

     After your step 5, did you first run the usb_stick_update program?

     Below are the steps I used and it is working for me.  

    Step1: Rename the built usb_stick_demo.bin file to the name FIRMWAREBIN.bin.

    Step2: Copy USB stick memory FIRMWAREBIN.bin file under root.

    step3: Build the usb_stick_update  and load it to the flash

    step4: Run the usb_stick_update program. Note the display screen should be blank at this time.

    step5: insert the USB memory

    step6. Reset the device.  In CCS go to Run->Reset->System Reset

    step7: Run the program again.

    After you run step7 you should see the display with the text below.

     You can press the SELECT/WAKE button and the usb_stick_demo program will call the updater to reload the program.

  • Hi Charles.

    charls replay Q1> After your step 5, did you first run the usb_stick_update program?
                          A1> Yes, it is usb_stick_update program DK_EVB write completed before Step1.

    charls replay Q2> step6. Reset the device. In CCS go to Run->Reset->System Reset
                          A2> I do not know what you mean about step6. ?
                                - The meaning of step6 is set to Reset of DK-EVB automatically after program witre finish !!
                         (In the case of me)
                         in rvmdk(Keil) , Options for Target -> Debug -> Stellaris ICD Settings -> Pop-Up window(Stellaris Debug Interface DLL)
                         Falsh -> (v) program , (v) verify, (v) Reset and Run

    charls replay Q3> step7: Run the program again.
                          A3> Write again usb_stick_update program to DK-EVB !!

    Q4> I do not know why you are doing step6 and step7. ?
    This application(usb_stick_update) explain force a new firmware update from the memory stick.
    It is also described in the source code (usb_stick_update) and is called the Press select button.

    if(ROM_GPIOPinRead(GPIO_PORTM_BASE, GPIO_PIN_4) == 0)
    {
    UpdaterMain();
    }

    (note)
    Thank you for your efforts to explain the captured image.
    " Press the select button to start the USB stick updater "

    However, it is the same as only writing the "usb_stick_demo " program to DK-EVB.

    regards.

  • Hi Jame,
    After step 5, the FIRMWARE.BIN is loaded from the usb memory stick to the flash starting at 0x4800. By this time the flash will have both the usb_stick_update (starting at 0x0) as well as the usb_stick_demo (starting at 0x4800). I asked you to do step 6 to reset the device so that the usb_stick_update will rerun again but upon detecting that there is already an application program image it will jump and run the FIRMWARE.BIN. This is why you will see the display that ask you to press the select button. If you press the SELECT button the FIRMWARE.BIN which is now running is supposed to transfer the control back to the usb_stick_update so that usb_stick_update will again reload the FIRMWARE.BIN.
  •  Hi Charles.

    charls replay >I asked you to do step 6 to reset the device so that the usb_stick_update will rerun again

    A1>  I am not use a CCS Tools. However, I understood that the meaning of the system reset setting

    Q1>  Is that correct ?

    Q2> Did not you proceed to step7?

    In step 7, "usb_stick_update" is written again via ICD.   The display screen does not change.

    charls replay > but upon detecting that there is already an application program image it will jump and run the FIRMWARE.BIN.

    Q3> Is the file name FIRMWARE.bin -> FIRMWAREBIN.bin error ?

    charls replay >  This is why you will see the display that ask you to press the select button.

     A3> After performing step 7, I understood that I could see the button on the display

          n that state, if you press SELECT button, it means that usb_stick_update is rewritten.

    Q4> Is there a problem with the procedural method?

    step1 : Rename usb_stick_demo.bin -> FIRMWAREBIN.bin
    step2 : copy USB stick memory " FIRMWAREBIN" file under root
    step3 : "usb_stick_update" write
    step4 : display screen blank
    step5 : insret USB stick memory
    step6 : again "usb_stick_update" write

    step7 : Wait three minutes

    step8 : reset button press the device(DK-EVB)

    - No display " Press the select button to start the USB stick updater "

    Q5> I have organized it into a memory map.

            Is it right for me to understand?

    [Attach capture image]

    1-step write " usb_stick_updata" via ICD
    2-step write " usb_stick_demo(FIRMWAREBIN.bin) via USB stick memory

    regards.

  •  Hi Charles.

    Usb_stick_Update This is a review that does not work.

    Do USB memory sticks only use TEXAS INSTRUMENTS USB?

    Currently USB memory stick is inserted into SanDisk Vendor.

    Because of the following log message.

    What's the problem?

    - My thoughts are so fast that I wonder if it's an initialization problem.

    How should we solve the problem ? 

    regards.

    In the " usb_host_msc"  example, the USB stick works well.

  • Hi Jame,

     Responding to your reply on Dec 5, 2017 8:04PM.

     First of all, it is FIRMWARE.BIN, not FIRMWAREBIN.BIN. If you use FIRMWAREBIN.BIN then it will not work. 

     Did you come to the point where the the display says "Press the select button to start the USB stick updater"? If your answer is yes, then the demo program has already been loaded to 0x4800. So this is considered working if you have come to this point.

     Look a the code below. The demo code will now wait for you to press the SELECT button. The code contains some debounce logic but once you press it will eventually transfer the control to the usb_demo_updater using the SVC call statement (*((void (*)(void))(*(uint32_t *)0x2c)))(); Before transferring the control to the usb_stick_updater it is supposed to print "The USB stick updater is now waiting for a USB stick". But you may not see this on the screen because everything happened too fast. As soon as the usb_stick_updater starts to run it will copy the new FIRMWARE.BIN again and afterward will reset the device. When the device is reset you will not be able to see the message on the display.

      BTW, your vector table is correct. 

        while(1)
        {
            //
            // See if the button is pressed.
            //
            if(ROM_GPIOPinRead(GPIO_PORTM_BASE, GPIO_PIN_4) == 0)
            {
                //
                // Increment the count since the button is pressed.
                //
                ui32Count++;
    
                //
                // If the count has reached 4, then the button has been debounced
                // as being pressed.
                //
                if(ui32Count == 4)
                {
                    break;
                }
            }
            else
            {
                //
                // Reset the count since the button is not pressed.
                //
                ui32Count = 0;
            }
    
            //
            // Delay for approximately 10ms.
            //
            SysCtlDelay(16000000 / (3 * 100));
        }
    
        //
        // Wait until the select button has been released for ~40ms (in order to
        // debounce the release).
        //
        ui32Count = 0;
        while(1)
        {
            //
            // See if the button is pressed.
            //
            if(ROM_GPIOPinRead(GPIO_PORTM_BASE, GPIO_PIN_4) != 0)
            {
                //
                // Increment the count since the button is released.
                //
                ui32Count++;
    
                //
                // If the count has reached 4, then the button has been debounced
                // as being released.
                //
                if(ui32Count == 4)
                {
                    break;
                }
            }
            else
            {
                //
                // Reset the count since the button is pressed.
                //
                ui32Count = 0;
            }
    
            //
            // Delay for approximately 10ms.
            //
            SysCtlDelay(16000000 / (3 * 100));
        }
    
        //
        // Indicate that the updater is being called.
        //
        GrStringDrawCentered(&sContext, "The USB stick", -1,
                             GrContextDpyWidthGet(&sContext) / 2, 20, true);
        GrStringDrawCentered(&sContext, "updater is now", -1,
                             GrContextDpyWidthGet(&sContext) / 2, 30, true);
        GrStringDrawCentered(&sContext, "waiting for a", -1,
                             GrContextDpyWidthGet(&sContext) / 2, 40, true);
        GrStringDrawCentered(&sContext, "USB stick.", -1,
                             GrContextDpyWidthGet(&sContext) / 2, 50, true);
    
       
        //
        // Flush any cached drawing operations.
        //
        GrFlush(&sContext);
    
        //
        // Call the updater so that it will search for an update on a memory stick.
        //
        (*((void (*)(void))(*(uint32_t *)0x2c)))();
    
        //
        // The updater should take control, so this should never be reached.
        // Just in case, loop forever.
        //
        while(1)
        {
        }

  • Hi Charles.

    I was confused  about name of the file must be 11 characters total, 8 for the base name and 3 for the extension.

    #define USB_UPDATE_FILENAME "FIRMWAREBIN"
    .
    ui32FileSize = SimpleFsOpen(USB_UPDATE_FILENAME);

    The file name works correctly with FIRMWARE. Thank you.

    Q1> What does BTW mean?

    Q2> I want to apply it to the current application.

            I tried to change usb_stick_demo to Hello example.

            I have added the following in the source code

             " (*((void (*)(void))(*(uint32_t *)0x2c)))(); "  // SVCall

            But it does not work. (Hello.bin  ->  FIRMWARE.bin)

           How should I apply it?

    regards.

    //*****************************************************************************
    //
    // Print "Hello World!" to the display.
    //
    //*****************************************************************************
    int
    main(void)
    {
        tContext sContext;
        tRectangle sRect;
    
        //
        // Enable lazy stacking for interrupt handlers.  This allows floating-point
        // instructions to be used within interrupt handlers, but at the expense of
        // extra stack usage.
        //
        ROM_FPULazyStackingEnable();
    
        //
        // Set the clocking to run directly from the crystal.
        //
        ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
                           SYSCTL_OSC_MAIN);
    
        //
        // Initialize the UART.
        //
        ConfigureUART();
    
        UARTprintf("Hello, world!\n");
    
        //
        // Initialize the display driver.
        //
        CFAL96x64x16Init();
    
        //
        // Initialize the graphics context.
        //
        GrContextInit(&sContext, &g_sCFAL96x64x16);
    
        //
        // Fill the top 24 rows of the screen with blue to create the banner.
        //
        sRect.i16XMin = 0;
        sRect.i16YMin = 0;
        sRect.i16XMax = GrContextDpyWidthGet(&sContext) - 1;
        sRect.i16YMax = 23;
        GrContextForegroundSet(&sContext, ClrDarkBlue);
        GrRectFill(&sContext, &sRect);
    
        //
        // Put a white box around the banner.
        //
        GrContextForegroundSet(&sContext, ClrWhite);
        GrRectDraw(&sContext, &sRect);
    
        //
        // Put the application name in the middle of the banner.
        //
        GrContextFontSet(&sContext, g_psFontCm12);
        GrStringDrawCentered(&sContext, "hello", -1,
                             GrContextDpyWidthGet(&sContext) / 2, 10, 0);
    
        //
        // Say hello using the Computer Modern 40 point font.
        //
        GrContextFontSet(&sContext, g_psFontCm12/*g_psFontFixed6x8*/);
        GrStringDrawCentered(&sContext, "Hello World!", -1,
                             GrContextDpyWidthGet(&sContext) / 2,
                             ((GrContextDpyHeightGet(&sContext) - 24) / 2) + 24,
                             0);
    
        //
        // Flush any cached drawing operations.
        //
        GrFlush(&sContext);
    		
        //
        // Call the updater so that it will search for an update on a memory stick.
        //
        (*((void (*)(void))(*(uint32_t *)0x2c)))();
    		
    
        //
        // We are finished. Hang around doing nothing.
        //
        while(1)
        {
        }
    }

  • Jame shin said:
    Q1> What does BTW mean?

    BTW is a abbreviation for "By the way".

    Jame shin said:

    Q2> I want to apply it to the current application.

            I tried to change usb_stick_demo to Hello example.

            I have added the following in the source code

             " (*((void (*)(void))(*(uint32_t *)0x2c)))(); "  // SVCall

            But it does not work. (Hello.bin  ->  FIRMWARE.bin)

           How should I apply it?

    As I explained in the last post that everything happened very fast that as soon as the SVC is called with  (*((void (*)(void))(*(uint32_t *)0x2c)))() the updater will reset the device and start to download the new FIRMWARE.BIN. When the reset happens you will not be able to see the "Hell World" on the screen.

    I modified your code just slightly with a delay before calling SVC and I see the Hello World on the display.

        GrStringDrawCentered(&sContext, "Hello World!", -1,
                             GrContextDpyWidthGet(&sContext) / 2,
                             ((GrContextDpyHeightGet(&sContext) - 24) / 2) + 24,
                             0);
    
        int i=0;
        for (i=0;i<10000000;i++);

  • Hi Charles.

    I have a Hello World on display with the addition of a delayed for statement in the code

    So again from the beginning "usb_stick_update" has been reviewed.

    There are three if conditional statements.

    1. App starting stack pointer or PC is not valid, so force an update.
    2. Check to see if the application has requested an update
    3. Check if the button is pressed, if so then force an update.

    (note) All fresh memory is erased at every initial step.

    In the case of me, in rvmdk(Keil) Options for Target -> Debug ->
    Stellaris ICD Settings -> Falsh -> (v) program , (v) verify, () Reset and Run

    Q1> 0xFFFF.FFFF because all of the flash memory contents have been erased.

            So,  enter SP + PC Point Check Routin

            Call the UpdaterMain () function.

             However, it is not displayed. Why?

    Q2> Apply 1 condition to #ifedf #endif and apply condition 3 to normal operation. Why?

             step1 : Rename usb_stick_demo.bin -> FIRMWARE.bin
             step2 : "usb_stick_update" write
             step3 : step3-1 "RESET + SELECT" button continue press in the device(DK-EVB)
                        step3-2. RESET not press
                        step3-3. SELECT not press

            Call the UpdaterMain () function

    It will display correctly as an attached image.

    main(void)
    {
        uint32_t *pui32App;
    		
    		// Initialize the UART.
        //
        ConfigureUART();
    		
       //UARTprintf("Update wating\n");
    
        //
        // See if the first location is 0xfffffffff or something that does not
        // look like a stack pointer, or if the second location is 0xffffffff or
        // something that does not look like a reset vector.
        //
        pui32App = (uint32_t *)APP_START_ADDRESS;
    	 UARTprintf("APP_START_ADDRESS : 0x%x \n", pui32App);
     #if 0
        if((pui32App[0] == 0xffffffff) ||
            ((pui32App[0] & 0xfff00000) != 0x20000000) ||
            (pui32App[1] == 0xffffffff) ||
            ((pui32App[1] & 0xfff00001) != 0x00000001))
        {
            //
            // App starting stack pointer or PC is not valid, so force an update.
            //
            UARTprintf("SP PC Check \n");
            UpdaterMain();
        }
    		
    #endif 
    
       
    	 UARTprintf("FORCE_UPDATE_ADDR : 0x%x \n", (int32_t *)FORCE_UPDATE_ADDR);
    	 UARTprintf(" FORCE_UPDATE_VALUE  0x%x \n", HWREG(FORCE_UPDATE_ADDR));
        //
        // Check to see if the application has requested an update
        //
    
        if(HWREG(FORCE_UPDATE_ADDR) == FORCE_UPDATE_VALUE)
        {
            UARTprintf("App req Update  \n");
            HWREG(FORCE_UPDATE_ADDR) = 0;
            UpdaterMain();
        }
    
    
        //
        // Enable the GPIO input for the user button.
        //
        ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);
        ROM_GPIODirModeSet(GPIO_PORTM_BASE, GPIO_PIN_4, GPIO_DIR_MODE_IN);
        MAP_GPIOPadConfigSet(GPIO_PORTM_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA,
                             GPIO_PIN_TYPE_STD_WPU);
        //UARTprintf("Key boutton Init\n");
    
        //
        // Check if the button is pressed, if so then force an update.
        //
        if(ROM_GPIOPinRead(GPIO_PORTM_BASE, GPIO_PIN_4) == 0)
        {
         UARTprintf("Update  SELECT Button detect \n");
            UpdaterMain();
        }
    
        //
        // If we get to here that means that none of the conditions that should
        // cause an update are true.  Therefore, call the application.
        //
        UARTprintf("CallApplication(0x4800) \n");
        CallApplication(APP_START_ADDRESS);
     
    }

  • Jame shin said:

    (note) All fresh memory is erased at every initial step.

    In the case of me, in rvmdk(Keil) Options for Target -> Debug ->
    Stellaris ICD Settings -> Falsh -> (v) program , (v) verify, () Reset and Run

    Q1> 0xFFFF.FFFF because all of the flash memory contents have been erased.

            So,  enter SP + PC Point Check Routin

            Call the UpdaterMain () function.

             However, it is not displayed. Why?

    I don't think I understand your question. The usb_stick_updater will check if the SP/PC is valid for the "application" program. If the SP/PC is not valid then the updater will force an update. It seems to me that you said you erased the flash when you said "All fresh memory is erased at every initial step.". If you erase the flash then you have also erased the usb_stick_updater program. Please clarify what are you trying do when you erase the flash. If you erase the flash then you need to reload the usb_stick_updater first.

  • Hi Charles.

    I will describe it concisely and clearly.

     - Eraser fresh is the reason for initializing.

    Above, in case of Q1)

    1. I first erase the fresh. Then write usb_stick_update to DK-EVB.

    2.  The SP/PC is not valid then the updater will force an update.

    3. So, we will call the UpdaterMain () function.

         Result, it is not displayed.

    Above, in case of Q2)

    1. Insert the #if 0 ~ #endif in source code,   build it.

    #if 0

         if((pui32App[0] == 0xffffffff) ||
         ((pui32App[0] & 0xfff00000) != 0x20000000) ||
         (pui32App[1] == 0xffffffff) ||
         ((pui32App[1] & 0xfff00001) != 0x00000001))
         {
         // App starting stack pointer or PC is not valid, so force an update.

         UpdaterMain();
         }

    #endif

    2. I first erase the fresh. Then write usb_stick_update to DK-EVB.

    3. Press the "RESET + SELECT" button simultaneously to release the RESET button.

    4. So, we will call the UpdaterMain () function.

        Result, The message will be displayed.

    Q1 and Q2 are the same, why is there a difference? 

    regards.

  • Jame shin said:

    Above, in case of Q1)

    1. I first erase the fresh. Then write usb_stick_update to DK-EVB.

    2.  The SP/PC is not valid then the updater will force an update.

    3. So, we will call the UpdaterMain () function.

         Result, it is not displayed.

    What is not displayed? Can you be more specific? What text do you anticipate to display? If you are asking about the LCD display with the text "Press the select button to start the USB stick updater" then that is part of the usb_stick_demo application, not the usb_stick_update program. The usb_stick_update does not print anything onto the LCD display. As soon as the usb_stick_update is run and you have plugged in the usb flash drive with the FIRMWARE.BIN on the root directory it will start the download operation. After the download, if you reset the device. If you run again it will show the "Press the select button to start the USB stick updater" on the display. I thought you already got this working.

    Jame shin said:

    #if 0

         if((pui32App[0] == 0xffffffff) ||
         ((pui32App[0] & 0xfff00000) != 0x20000000) ||
         (pui32App[1] == 0xffffffff) ||
         ((pui32App[1] & 0xfff00001) != 0x00000001))
         {
         // App starting stack pointer or PC is not valid, so force an update.

         UpdaterMain();
         }

    #endif

    2. I first erase the fresh. Then write usb_stick_update to DK-EVB.

    3. Press the "RESET + SELECT" button simultaneously to release the RESET button.

    Here you are forcing the update based on the SP/PC checking. You are forcing the an update by pressing the SELECT. By doing so the usb_stick_demo will call the UpdateMain() and do the update again. So what are you trying to prove?  I'm at a loss as to what you are trying to say. 

    Please revert back to the original usb_stick_update and usb_stick_demo and try again. Just tell me a yes or no answer for the below scenario.

      1. Load the original usb_stick_update

      2. Plug in the usb_stick_demo with the FIRMWARE.BIN which is renamed from usb_stick_demo.bin

      3. Run the usb_stick_update

      4. When it is successful, it will reset the device. In CCS, I see the PC (program counter) stop at the ResetISR. I have no idea about Keil. You need to consult the Keil support how to halt the CPU at reset vector when the device is reset. If your Keil is configured this way, it may just run the program from the reset vector again. However, if this is the case, it will jump to the usb_stick_demo application where you should see "Press the select button to start the USB stick updater" on the display.

      5. Run the device again. This time the usb_stck_update will know that there is already a valid application starting at 0x4800 and just jump to the application.

      6. When the application is run this is when you see the "Press the select button to start the USB stick updater" on the LCD display.

  • Hi Charles

    Finally,  I want to do is to save the test results to a USB test file

    DK-EVB board create file  test.txt  in USB in host mode

    The contents of test.txt file are as follows.

    1. SN:00001 OK
    2. SN:00002 OK
    3. SN:00003 NG

    My troubles,  How do I implement source code

    Can you help me?

    regards.

  • Hi Jame,

      Thanks for your greeting. Merry Christmas to you too!

      Please use usb_host_msc example for reference on read/write to the pen drive. 

      You may find these two posts also helpful.

  • Hi Charles

    Two link errors occur.

    1. ff_convert

    2. ff_wtoupper

    I can not find the drive file to resolve this.

    Please tell me how to solve the problem. ?

    regards.