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.

Custom USB BSL and CCS4

Other Parts Discussed in Thread: MSP430F5507, MSP430F5438

Hi,

I am trying to port the MSP430F552x_USB BSL example from IAR to CCS4. I unfortunately am not having much success. I am using the MSP430F5507 and have successfully loaded the MSP430F552x_USB BSL from IAR, but I have done all of my other development in CCS4 and would like to port it over. If I try and debug the BSL code in CCS, the code hangs on the crystal detect timer function in PI_Init(); located in BSL430_USB_PI.c. If I remove this function the code will hang further down the line on another clock associated function. Seems to me that the clocks are not being dealt with properly. Have yet to figure this out.

The only file that I have not ported over is the cstartup.s43 and I was wondering how to work with this file in CCS4 since it does call libraries that are, as far as I am aware, specific to the IAR compiler.

Has anyone had any success porting a custom USB BSL to CCS, or am I chasing my tail?

Any help would be great,

Thanks,

  • Hi Cody,

    I suspect there may be some memory map problem for the BSL code area. Did you use the 5438a example CCS project? Where exactly is the code stuck, and have you tried stepping through the code? If it's a clock problem then it should have been caught during the oscillator fault loop, but you should check if the oscillator fault flag is set anyway.

    Also, are you running the code from the BSL area or from RAM/normal flash?

    Tony

  • I did use the 5438a code and was successful in compiling in CCS.

    The code is stuck here in the BSL430_USB_PI.c @ PI_Init() :

      TIMER_CTL = TIMER_CTL_SETTINGS;                    // TB clock = SMCLK (DCO), cont. mode
      for( i = 300; i > 0; i --)                                                      // this loop causes the "crystal detect"
      {                                                                                          // to function as a crystal stabalization delay
                                                                                                  // delay = (1/32768)*4*300 = 36 ms
        TIMER_CCTL = TIMER_CCTL_SETTINGS;             // Rising edge, CCI6B = ACLK, Capture
        while(!(TIMER_CCTL & TIMER_CCTL_IFG) ){}       // wait for first capture (unknown time)
        TIMER_CTL |= TIMER_CTL_CLR;
      }
      TIMER_CCTL &= ~TIMER_CCTL_CM;   

    Stepping through the code the oscillator fault flag is set.

    I am pretty sure that the code is running from flash. Debugging reset start address is @ 0x9318, this should be flash.

    I have attached the memory map that I am using.

    5226.memMap.txt
    /******************************************************************************/
    /* lnk_msp430f5507.cmd - LINKER COMMAND FILE FOR LINKING MSP430F5507 PROGRAMS     */
    /*                                                                            */
    /*   Usage:  lnk430 <obj files...>    -o <out file> -m <map file> lnk.cmd     */
    /*           cl430  <src files...> -z -o <out file> -m <map file> lnk.cmd     */
    /*                                                                            */
    /*----------------------------------------------------------------------------*/
    /* These linker options are for command line linking only.  For IDE linking,  */
    /* you should set your linker options in Project Properties                   */
    /* -c                                               LINK USING C CONVENTIONS  */
    /* -stack  0x0100                                   SOFTWARE STACK SIZE       */
    /* -heap   0x0100                                   HEAP AREA SIZE            */
    /*                                                                            */
    /*----------------------------------------------------------------------------*/
    
    
    /****************************************************************************/
    /* SPECIFY THE SYSTEM MEMORY MAP                                            */
    /****************************************************************************/
    
    MEMORY
    {
        SFR                     : origin = 0x0000, length = 0x0010
        PERIPHERALS_8BIT        : origin = 0x0010, length = 0x00F0
        PERIPHERALS_16BIT       : origin = 0x0100, length = 0x0100
        RAM                     : origin = 0x2400, length = 0x1000
        INFOA                   : origin = 0x1980, length = 0x0080
        INFOB                   : origin = 0x1900, length = 0x0080
        INFOC                   : origin = 0x1880, length = 0x0080
        INFOD                   : origin = 0x1800, length = 0x0080
        
     /*BSL Memory Map*/
        ZAREA                   : origin = 0x1000, length = 0x0010
        cSPEED_1_PLL			: origin = 0x1074, length = 0x0002
        cSPEED_2_PLL			: origin = 0x1076, length = 0x0002
        cSPEED_3_PLL			: origin = 0x1078, length = 0x0002
        cSPEED_4_PLL			: origin = 0x107A, length = 0x0002
        BSL430_VersionM         : origin = 0x1010, length = 0x0004
    
        ZAREA_CODE              : origin = 0x108e, length = 0x0056
        BSLSIG                  : origin = 0x17F0, length = 0x000C
        JTAGLOCK_KEY			: origin = 0x17FC, length = 0x0004
     /*End BSL Memory Map*/
     
        FLASH                   : origin = 0x8000, length = 0x7F80
        INT00                   : origin = 0xFF80, length = 0x0002
        INT01                   : origin = 0xFF82, length = 0x0002
        INT02                   : origin = 0xFF84, length = 0x0002
        INT03                   : origin = 0xFF86, length = 0x0002
        INT04                   : origin = 0xFF88, length = 0x0002
        INT05                   : origin = 0xFF8A, length = 0x0002
        INT06                   : origin = 0xFF8C, length = 0x0002
        INT07                   : origin = 0xFF8E, length = 0x0002
        INT08                   : origin = 0xFF90, length = 0x0002
        INT09                   : origin = 0xFF92, length = 0x0002
        INT10                   : origin = 0xFF94, length = 0x0002
        INT11                   : origin = 0xFF96, length = 0x0002
        INT12                   : origin = 0xFF98, length = 0x0002
        INT13                   : origin = 0xFF9A, length = 0x0002
        INT14                   : origin = 0xFF9C, length = 0x0002
        INT15                   : origin = 0xFF9E, length = 0x0002
        INT16                   : origin = 0xFFA0, length = 0x0002
        INT17                   : origin = 0xFFA2, length = 0x0002
        INT18                   : origin = 0xFFA4, length = 0x0002
        INT19                   : origin = 0xFFA6, length = 0x0002
        INT20                   : origin = 0xFFA8, length = 0x0002
        INT21                   : origin = 0xFFAA, length = 0x0002
        INT22                   : origin = 0xFFAC, length = 0x0002
        INT23                   : origin = 0xFFAE, length = 0x0002
        INT24                   : origin = 0xFFB0, length = 0x0002
        INT25                   : origin = 0xFFB2, length = 0x0002
        INT26                   : origin = 0xFFB4, length = 0x0002
        INT27                   : origin = 0xFFB6, length = 0x0002
        INT28                   : origin = 0xFFB8, length = 0x0002
        INT29                   : origin = 0xFFBA, length = 0x0002
        INT30                   : origin = 0xFFBC, length = 0x0002
        INT31                   : origin = 0xFFBE, length = 0x0002
        INT32                   : origin = 0xFFC0, length = 0x0002
        INT33                   : origin = 0xFFC2, length = 0x0002
        INT34                   : origin = 0xFFC4, length = 0x0002
        INT35                   : origin = 0xFFC6, length = 0x0002
        INT36                   : origin = 0xFFC8, length = 0x0002
        INT37                   : origin = 0xFFCA, length = 0x0002
        INT38                   : origin = 0xFFCC, length = 0x0002
        INT39                   : origin = 0xFFCE, length = 0x0002
        INT40                   : origin = 0xFFD0, length = 0x0002
        INT41                   : origin = 0xFFD2, length = 0x0002
        INT42                   : origin = 0xFFD4, length = 0x0002
        INT43                   : origin = 0xFFD6, length = 0x0002
        INT44                   : origin = 0xFFD8, length = 0x0002
        INT45                   : origin = 0xFFDA, length = 0x0002
        INT46                   : origin = 0xFFDC, length = 0x0002
        INT47                   : origin = 0xFFDE, length = 0x0002
        INT48                   : origin = 0xFFE0, length = 0x0002
        INT49                   : origin = 0xFFE2, length = 0x0002
        INT50                   : origin = 0xFFE4, length = 0x0002
        INT51                   : origin = 0xFFE6, length = 0x0002
        INT52                   : origin = 0xFFE8, length = 0x0002
        INT53                   : origin = 0xFFEA, length = 0x0002
        INT54                   : origin = 0xFFEC, length = 0x0002
        INT55                   : origin = 0xFFEE, length = 0x0002
        INT56                   : origin = 0xFFF0, length = 0x0002
        INT57                   : origin = 0xFFF2, length = 0x0002
        INT58                   : origin = 0xFFF4, length = 0x0002
        INT59                   : origin = 0xFFF6, length = 0x0002
        INT60                   : origin = 0xFFF8, length = 0x0002
        INT61                   : origin = 0xFFFA, length = 0x0002
        INT62                   : origin = 0xFFFC, length = 0x0002
        RESET                   : origin = 0xFFFE, length = 0x0002
    }
    
    /****************************************************************************/
    /* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY                              */
    /****************************************************************************/
    
    SECTIONS
    {
        BSL430_Version_SEG        : {} > BSL430_VersionM
    
        BSL430_cSPEED_1_PLL		  : {} > cSPEED_1_PLL
        BSL430_cSPEED_2_PLL		  : {} > cSPEED_2_PLL
        BSL430_cSPEED_3_PLL		  : {} > cSPEED_3_PLL
        BSL430_cSPEED_4_PLL		  : {} > cSPEED_4_PLL
        .bss       : {} > RAM                /* GLOBAL & STATIC VARS              */
        ZAREA      : {} > ZAREA
        ZAREA_CODE : {} > ZAREA_CODE
        BSLSIG     : {} > BSLSIG
        JTAGLOCK_KEY : {} > JTAGLOCK_KEY
        .sysmem    : {} > RAM                /* DYNAMIC MEMORY ALLOCATION AREA    */
        .stack     : {} > RAM (HIGH)         /* SOFTWARE SYSTEM STACK             */
    
        .text      : {} > FLASH              /* CODE                              */
        .cinit     : {} > FLASH              /* INITIALIZATION TABLES             */
        .const     : {} > FLASH              /* CONSTANT DATA                     */
        .cio       : {} > RAM                /* C I/O BUFFER                      */
    
        .pinit     : {} > FLASH              /* C++ CONSTRUCTOR TABLES            */
    
        .infoA     : {} > INFOA              /* MSP430 INFO FLASH MEMORY SEGMENTS */
        .infoB     : {} > INFOB
        .infoC     : {} > INFOC
        .infoD     : {} > INFOD
    
        .int00   : {} > INT00                /* MSP430 INTERRUPT VECTORS          */
        .int01   : {} > INT01
        .int02   : {} > INT02
        .int03   : {} > INT03
        .int04   : {} > INT04
        .int05   : {} > INT05
        .int06   : {} > INT06
        .int07   : {} > INT07
        .int08   : {} > INT08
        .int09   : {} > INT09
        .int10   : {} > INT10
        .int11   : {} > INT11
        .int12   : {} > INT12
        .int13   : {} > INT13
        .int14   : {} > INT14
        .int15   : {} > INT15
        .int16   : {} > INT16
        .int17   : {} > INT17
        .int18   : {} > INT18
        .int19   : {} > INT19
        .int20   : {} > INT20
        .int21   : {} > INT21
        .int22   : {} > INT22
        .int23   : {} > INT23
        .int24   : {} > INT24
        .int25   : {} > INT25
        .int26   : {} > INT26
        .int27   : {} > INT27
        .int28   : {} > INT28
        .int29   : {} > INT29
        .int30   : {} > INT30
        .int31   : {} > INT31
        .int32   : {} > INT32
        .int33   : {} > INT33
        .int34   : {} > INT34
        .int35   : {} > INT35
        .int36   : {} > INT36
        .int37   : {} > INT37
        .int38   : {} > INT38
        .int39   : {} > INT39
        .int40   : {} > INT40
        .int41   : {} > INT41
        .int42   : {} > INT42
        .int43   : {} > INT43
        .int44   : {} > INT44
        .int45   : {} > INT45
        .int46   : {} > INT46
        .int47   : {} > INT47
        .int48   : {} > INT48
        .int49   : {} > INT49
        .int50   : {} > INT50
        .int51   : {} > INT51
        .int52   : {} > INT52
        .int53   : {} > INT53
        .int54   : {} > INT54
        .int55   : {} > INT55
        .int56   : {} > INT56
        .int57   : {} > INT57
        .int58   : {} > INT58
        .int59   : {} > INT59
        .int60   : {} > INT60
        .int61   : {} > INT61
        .int62   : {} > INT62
        .reset   : {} > RESET              /* MSP430 RESET VECTOR               */ 
    }
    
    /****************************************************************************/
    /* INCLUDE PERIPHERALS MEMORY MAP                                           */
    /****************************************************************************/
    
    -l msp430f5507.cmd

  • Currently your linker memory map has

        cSPEED_1_PLL			: origin = 0x1074, length = 0x0002
    cSPEED_2_PLL : origin = 0x1076, length = 0x0002
    cSPEED_3_PLL : origin = 0x1078, length = 0x0002
    cSPEED_4_PLL : origin = 0x107A, length = 0x0002

    which are located within the BSL ZAREA. This probably explains the program lock, since the processor tries to fetch the constants after the timer loop from *outside* the BSL ZAREA.

    You should either set those constants to normal flash, or put the entire BSL code in ZAREA_CODE.

    Tony

  • I checked the memory view to see what was written if anything and nothing was written in the ZAREA's until I removed the :

      cSPEED_1_PLL			: origin = 0x1074, length = 0x0002
    cSPEED_2_PLL : origin = 0x1076, length = 0x0002
    cSPEED_3_PLL : origin = 0x1078, length = 0x0002
    cSPEED_4_PLL : origin = 0x107A, length = 0x0002

    I rechecked the memory and it looks like the ZAREA's have been written to.

    I stopped the watchdog timer on startup and now the code does not loop in the timer loop. So that is solved I believe!

    Now the code is sitting in the PI_receivePacket() and waiting to enumerate.

    while( BSL430_BufferSize == 0 )
      {
        UsbHandler();
        if (bEnumerationStatus == ENUMERATION_COMPLETE) // if enumeration completed
        {
          if (bFunctionSuspended == FALSE)    // and device not suspended
          {
          BSL430_BufferSize = UsbReceiveHID();
          }
        }

    My issue could be associated with a change that I made with the UsbHander() to get CCS4 to compile? I was getting the following error:


    unresolved symbol UsbHandler, first referenced in ./Peripheral_Interfaces/BSL430_USB_PI.obj        custom bsl    line 0    1331766691242    10113

    so I removed the following statement in UsbIsr.c and made two separate functions, one for the interrupt vector and the other for the UsbHandler(). Could this be a problem?

    #ifndef _NO_ISR
    #pragma vector=USB_UBM_VECTOR
    __interrupt VOID iUsbInterruptHandler(VOID)
    #else
    VOID UsbHandler(VOID)
    #endif
    {......................}

    I really appreciate your help

  • Cody, I meant that you should *not* have them in the ZAREA (0x1000-0x17FF). As it stands, you have your BSL code in the main flash, but some constants in the BSL flash, ie ZAREA., but not that ZAREA as defined by the linker. Confused yet? :)

    Remove the mentioned four lines, as well as

        BSL430_cSPEED_1_PLL		  : {} > cSPEED_1_PLL
        BSL430_cSPEED_2_PLL		  : {} > cSPEED_2_PLL
        BSL430_cSPEED_3_PLL		  : {} > cSPEED_3_PLL
        BSL430_cSPEED_4_PLL		  : {} > cSPEED_4_PLL
    

    in the SECTIONS area of the linker map file. See if it helps.

    Tony

  • Argh the linker file got me all messed up w/ the names; replace all my mentions of "ZAREA" as "BSL Flash". My comments still stand though.

    Tony

  • I found out why the code was appeared to be hanging in the timer while loop. Basically the watchdog timer was not stopped, so the program would keep restarting. I tracked down where the watchdog was suppose to be disabled in the BSL430_API.c under the _low_level_init(), which is called in the cstartup.s43 which I do not have converted over to .asm. I changed the name of this function to _system_pre_int() and that worked.

    Now the program is looping in the PI_sendData() in the while(UsbSendHID());

    void PI_sendData(int bufSize)
    {
      RAM_Buf[0] = bufSize;
      while( UsbSendHID((BYTE const*)RAM_Buf) == 0 );
    }

    My computer recognizes that a USB device is attached, but does not recognize the device.

    I will keep working on it, but any input would be much appreciated.

    Thanks,

  • I have made some progress porting the custom USB BSL to CCS4. I declared the absolute addresses for the variables declared in usb.c into the memory map, this was the trick to get the PC to recognize the device.

    When using the BSL_USB_GUI I am able to initiate the downloading of the firmware and the GUI reports back that it is done downloading the firmware. The GUI then reports back that it has failed to read data from RAM BSL.

    I checked the memory in CCS and the BSL code has been written to flash @ x8000 instead of to BSL sections and USB RAM. I was thinking that I need to declare an absolute address for all of the functions, such as PI_Init(), USB_Init()...etc. Looking through the IAR code I do not see how the functions are being written to the appropriate memory sections (i.e. BSL, USB RAM) without explicitly declaring the address at which to write them in the code. I see the functions in the memory map in IAR, such as USB_reset at address x1462, is this a automatic declaration or a manual declaration?

    Any help would be appreciated,

    Thank you.

  • Hi Cody,

    To store the program in the BSL area, modify the FLASH location in the linker configuration file to look something like this:

    FLASH                   : origin = 0x1042, length = 0x7AE

    This will then put everything in the .text and .const sections, which contains your BSL code and constants, into the BSL memory.

    Hope that helps.

    Tony

  • Finally got the USB BSL ported to CCS V4. I will attach the project for anyone else that may struggle to do the same thing. A big thanks to Tony for all of the help.

    I had to change the debugging and optimization model for the compiler to squeeze the project into the BSL 2K memory.

    In build properties under MSP430 compiler:
         Set debugging model to: Symbolic Debug for program analysis
         Set optimization level to: 4

    Best regards,

    Cody

    5861.usb bsl 3.zip

  • Dear Sir,

    when i try to download the Application code to the MSP430F5438 using BSL programmer(BSL_Scripter.exe)

    i am facing following Problem...

    BSL Scripting application 1.06
    The local time is: 12:19 on 30.04.2012
    ------------------------------------------
    Initializing, Mode: 5438 COM: COM1 DONE
    Changing Baud Rate to 9600 DONE
    Mass Erase: FAIL(ee)
    RX Password: FAIL(ee)
    Writing MSP430TB.txt to device: FAIL writing data block starting at 5c00
    CRC from 5c00 of 4096 bytes to 982b FAIL....

    please help me...

    Thank you..

  • Hello Sunil Shet,

    The code that I uploaded was intended to compile and load using CCS V4. I have never tested the code with the BSL_Scripter tool.

    Have you tried using CCS V4 to test the code?

    Cody

  • Dear cody lohse,

    I am using CCS v5 to test the code..


    thank you.

**Attention** This is a public forum