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.

C2000 LaunchPad - Linker Command File

Other Parts Discussed in Thread: CONTROLSUITE

Just joined the Forum and looking for some C2000 LaunchPad help with Linker Command files.

I created a simple project with CCSv6 to blink a LED (I know ... another newbie ... ) linked it with 28027_RAM_lnk.cmd and can run the application from RAM with the debugger. Life is good !!

The problem is getting the Linker to map correctly for the LaunchPad target when booting directly from Flash.

I have tried several Linker command files (including DSP2802x_Headers_nonBIOS.cmd) and none seem to work for the LaunchPad  (dip SW 3 on LaunchPad set to "down" position to disable debugger). Have taken a brief look at SPRA958J - Running an Application from Internal Flash Memory and will study in more detail later.

Does anyone have a working Flash Linker Command File to use as a starting point for the C2000 Launchpad.

Would appreciate any help I can get.

Cheers,  John

  • John,

    C2000 applications typically make use of two linker command files in a single project.  One is used to link the application to flash/ram, while the other is used to link the peripheral header files to the proper locations in the device memory map.  The DSP2802x_Header_nonBIOS.cmd is the latter.

    If you look in the common/cmd directory in the device support or c2000_launchpad directories you should see a file named F28027.cmd.  This is the main flash linker file for these devices.  You can also import any of the example projects and switch the build configuration to Flash in order to build any of the examples to run from flash.

    Let me know if you need more assistance.

    BR,

  • Thanks for the infoTrey,

    I need more help to get this application to run from Flash. Here is what I have.

    I started by modifying the Example F2802X LaunchPad Demo (removed a few items not necessary for my app) and added a simple "blind a LED" loop in the main program. When I build this project with the 2802_RAM_lnk.cmd  it runs from RAM with the debugger. I have tried multiple linker command files including F2802x_Header_nonBIOS.cmd  (can't find DSP2802x_Header_nonBIOS.cmd) and can't get it to build and run from Flash. I am doing something fundamentally wrong in ccsV6 or with my app.

    Here is the .C file:


    //###########################################################################
    //
    // FILE:    PlasmaX.c
    //
    // TITLE:   This is a modified example from C2000 LaunchPad
    //
    // ASSUMPTIONS:
    //
    //    This program requires the F2802x0 header files.
    //
    //    This program makes use of variables stored in OTP during factory
    //    test on 2802x TMS devices only.
    //    These OTP locations on pre-TMS devices may not be populated.
    //    Ensure that the following memory locations in TI OTP are populated
    //    (not 0xFFFF) before use:
    //
    //    0x3D7E90 to 0x3D7EA4
    //
    //    As supplied, this project is configured for "boot to SARAM"
    //    operation.  The 2802x Boot Mode table is shown below.
    //
    //    $Boot_Table
    //    While an emulator is connected to your device, the TRSTn pin = 1,
    //    which sets the device into EMU_BOOT boot mode. In this mode, the
    //    peripheral boot modes are as follows:
    //
    //      Boot Mode:   EMU_KEY        EMU_BMODE
    //                   (0xD00)         (0xD01)
    //      ---------------------------------------
    //      Wait         !=0x55AA        X
    //      I/O           0x55AA          0x0000
    //      SCI          0x55AA          0x0001
    //      Wait         0x55AA          0x0002
    //      Get_Mode     0x55AA          0x0003
    //      SPI          0x55AA          0x0004
    //      I2C          0x55AA          0x0005
    //      OTP          0x55AA          0x0006
    //      Wait         0x55AA          0x0007
    //      Wait         0x55AA          0x0008
    //      SARAM        0x55AA          0x000A   <-- "Boot to SARAM"
    //      Flash        0x55AA          0x000B
    //      Wait         0x55AA          Other
    //
    //   Write EMU_KEY to 0xD00 and EMU_BMODE to 0xD01 via the debugger
    //   according to the Boot Mode Table above. Build/Load project,
    //   Reset the device, and Run example
    //
    //   $End_Boot_Table
    //
    // DESCRIPTION:
    //
    // Project:  PlasmaX.c                  Revision: 1.0
    //
    // Description:
    //
    // Watch Variables:
    //
    //
    //###########################################################################

    // List all pre-processor includes
    #include <stdio.h>
    #include <file.h>

    #include "DSP28x_Project.h"     // DSP28x Headerfile

    #include "f2802x_common/include/adc.h"
    #include "f2802x_common/include/clk.h"
    #include "f2802x_common/include/flash.h"
    #include "f2802x_common/include/gpio.h"
    #include "f2802x_common/include/pie.h"
    #include "f2802x_common/include/pll.h"
    #include "f2802x_common/include/wdog.h"

    #define CONV_WAIT 1L //Micro-seconds to wait for ADC conversion. Longer than necessary.

    extern void DSP28x_usDelay(Uint32 Count);


    int16_t pilot_current;
    int16_t cutting_current;

    ADC_Handle myAdc;
    CLK_Handle myClk;
    FLASH_Handle myFlash;
    GPIO_Handle myGpio;
    PIE_Handle myPie;


    int16_t sampleAnalogInput(void)
    {

        //Force start of conversion on SOC0 and SOC1
        ADC_forceConversion(myAdc, ADC_SocNumber_0);
        ADC_forceConversion(myAdc, ADC_SocNumber_1);

        //Wait for end of conversion.
        while(ADC_getIntStatus(myAdc, ADC_IntNumber_1) == 0)

        // Clear ADCINT1
        ADC_clearIntFlag(myAdc, ADC_IntNumber_1);

        // Get current sensor sample result from SOC1
        return (ADC_readResult(myAdc, ADC_ResultNumber_1));

    }

    void main()
    {
        volatile int status = 0;
        volatile FILE *fid;

        CPU_Handle myCpu;
        PLL_Handle myPll;
        WDOG_Handle myWDog;

        // Initialize all the handles needed for this application
        myAdc = ADC_init((void *)ADC_BASE_ADDR, sizeof(ADC_Obj));
        myClk = CLK_init((void *)CLK_BASE_ADDR, sizeof(CLK_Obj));
        myCpu = CPU_init((void *)NULL, sizeof(CPU_Obj));
        myFlash = FLASH_init((void *)FLASH_BASE_ADDR, sizeof(FLASH_Obj));
        myGpio = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj));
        myPie = PIE_init((void *)PIE_BASE_ADDR, sizeof(PIE_Obj));
        myPll = PLL_init((void *)PLL_BASE_ADDR, sizeof(PLL_Obj));
        myWDog = WDOG_init((void *)WDOG_BASE_ADDR, sizeof(WDOG_Obj));

        // Perform basic system initialization
        WDOG_disable(myWDog);
        CLK_enableAdcClock(myClk);
     //   (*Device_cal)();

        //Select the internal oscillator 1 as the clock source
        CLK_setOscSrc(myClk, CLK_OscSrc_Internal);

        // Setup the PLL for x10 /2 which will yield 50Mhz = 10Mhz * 10 / 2
        PLL_setup(myPll, PLL_Multiplier_12, PLL_DivideSelect_ClkIn_by_2);

        // Disable the PIE and all interrupts
        PIE_disable(myPie);
        PIE_disableAllInts(myPie);
        CPU_disableGlobalInts(myCpu);
        CPU_clearIntFlags(myCpu);

        // If running from flash copy RAM only functions to RAM
    #ifdef _FLASH
        memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
    #endif


        // Setup a debug vector table and enable the PIE
        PIE_setDebugIntVectorTable(myPie);
        PIE_enable(myPie);


        // Initialize the ADC
        ADC_enableBandGap(myAdc);
        ADC_enableRefBuffers(myAdc);
        ADC_powerUp(myAdc);
        ADC_enable(myAdc);
        ADC_setVoltRefSrc(myAdc, ADC_VoltageRefSrc_Int);

        // Setup ADC to convert channel 1 (sample twice to workaround silicon errata)
        ADC_setSocChanNumber (myAdc, ADC_SocNumber_0, ADC_SocChanNumber_A1);    //Set SOC0 channel select to ADCINA1
        ADC_setSocChanNumber (myAdc, ADC_SocNumber_1, ADC_SocChanNumber_A1);    //Set SOC1 channel select to ADCINA1
        ADC_setSocSampleWindow(myAdc, ADC_SocNumber_0, ADC_SocSampleWindow_7_cycles);   //Set SOC0 acquisition period to 7 ADCCLK
        ADC_setSocSampleWindow(myAdc, ADC_SocNumber_1, ADC_SocSampleWindow_7_cycles);   //Set SOC1 acquisition period to 7 ADCCLK
        ADC_setIntSrc(myAdc, ADC_IntNumber_1, ADC_IntSrc_EOC1);                 //Connect ADCINT1 to EOC1
        ADC_enableInt(myAdc, ADC_IntNumber_1);                                  //Enable ADCINT1

        // Set the flash OTP wait-states to minimum. This is important
        // for the performance of the analog conversion function.
        FLASH_setup(myFlash);


        // Initialize GPIO
        // Enable XCLOCKOUT to allow monitoring of oscillator 1
        GPIO_setMode(myGpio, GPIO_Number_18, GPIO_18_Mode_XCLKOUT);
        CLK_setClkOutPreScaler(myClk, CLK_ClkOutPreScaler_SysClkOut_by_1);

        // Configure GPIO 0-3 as outputs
        GPIO_setMode(myGpio, GPIO_Number_0, GPIO_0_Mode_GeneralPurpose);
        GPIO_setMode(myGpio, GPIO_Number_1, GPIO_1_Mode_GeneralPurpose);
        GPIO_setMode(myGpio, GPIO_Number_2, GPIO_2_Mode_GeneralPurpose);
        GPIO_setMode(myGpio, GPIO_Number_3, GPIO_3_Mode_GeneralPurpose);

        GPIO_setDirection(myGpio, GPIO_Number_0, GPIO_Direction_Output);
        GPIO_setDirection(myGpio, GPIO_Number_1, GPIO_Direction_Output);
        GPIO_setDirection(myGpio, GPIO_Number_2, GPIO_Direction_Output);
        GPIO_setDirection(myGpio, GPIO_Number_3, GPIO_Direction_Output);


        // Set GPIO 0-3 high
        GPIO_setHigh(myGpio, GPIO_Number_0);
        GPIO_setHigh(myGpio, GPIO_Number_1);
        GPIO_setHigh(myGpio, GPIO_Number_2);
        GPIO_setHigh(myGpio, GPIO_Number_3);


        //Main program loop - continually flash single LED (GPIO 2)
        for(;;) {

            // Loop forever and flash GPIO 2
            GPIO_setLow(myGpio, GPIO_Number_2);            // set "on" time to 0.5 sec
            DELAY_US(500000);

            GPIO_setHigh(myGpio, GPIO_Number_2);        // set "off" time t0 1.0 sec
            DELAY_US(1000000);
                  }

    }
    // End of Main

    When I build the project from RAM, I still get a few warnings:.......

    **** Build of configuration Debug for project PlasmaX ****

    "c:\\ti\\ccsv6\\utils\\bin\\gmake" -k all
    'Building file: ../main.c'
    'Invoking: C2000 Compiler'
    "c:/ti/ccsv6/tools/compiler/c2000_6.2.6/bin/cl2000" -v28 -ml -mt --include_path="c:/ti/ccsv6/tools/compiler/c2000_6.2.6/include" --include_path="C:/ti/controlSUITE/development_kits/C2000_LaunchPad" -g --diag_warning=225 --display_error_number --diag_wrap=off --preproc_with_compile --preproc_dependency="main.pp"  "../main.c"
    "../main.c", line 152: warning #225-D: function "PIE_setDebugIntVectorTable" declared implicitly
    "../main.c", line 112: warning #179-D: variable "fid" was declared but never referenced
    'Finished building: ../main.c'
    ' '
    'Building target: PlasmaX.out'
    'Invoking: C2000 Linker'
    "c:/ti/ccsv6/tools/compiler/c2000_6.2.6/bin/cl2000" -v28 -ml -mt -g --diag_warning=225 --display_error_number --diag_wrap=off -z -m"PlasmaX.map" --stack_size=0x300 --warn_sections -i"c:/ti/ccsv6/tools/compiler/c2000_6.2.6/lib" -i"c:/ti/ccsv6/tools/compiler/c2000_6.2.6/include" --reread_libs --display_error_number --diag_wrap=off --xml_link_info="PlasmaX_linkInfo.xml" --rom_model -o "PlasmaX.out"  "./main.obj" "../28027_RAM_lnk.cmd" -l"libc.a" -l"C:\ti\controlSUITE\development_kits\C2000_LaunchPad\f2802x_common\lib\driverlib.lib"
    <Linking>
    warning #10247-D: creating output section "csm_rsvd" without a SECTIONS specification
    warning #10247-D: creating output section "csmpasswds" without a SECTIONS specification
    'Finished building target: PlasmaX.out'
    ' '

    **** Build Finished ****

    Would appreciate your thoughts.

    Cheers,  John

  • Hello John,

    Maybe this picture below can help you. I forgot which thread I put this picture so I put it directly for you here.

    And now the ControlSuite has new version (I think it should be v220 or more for F2802x). In the picture it mentioned v210, better you use the ones from the latest version.

    Best regards,

    Maria

  • Thanks Maria,

    I'll give it a try.

    Cheers, John