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.

Bootloader c2000 linker problem

Other Parts Discussed in Thread: TMS320F28335, UNIFLASH

Hello everybody,

I have to program a bootloader for TMS320f28335. I want to reserve the A sector of FLASH to allocate the bootloader, and the other sectors for application. I have 2 diferent projects, one for bootloader and one for application. I have 2 linker files, is right?, in both i have defined the same memory pages:

PAGE 0:	/* Program Memory */

 	FLASHA      : origin = 0x338000, 	length = 0x007F80   /* Internal flash A */
 	FLASH		: origin = 0x300000, 	length = 0x37FFF	/* Internal flash (B-H) */
 	L03SARAM	: origin = 0x008000, 	length = 0x004000	/* Internal RAM */
 	JUMPCINT00	: origin = 0x33FFF6, 	length = 0x000002	/* Reset vector */
 	IQTABLES (R): origin = 0x3FE000,	length = 0x000B50	/* In Rom IQ math tables */
 	FPUTABLES	: origin = 0x3FEBDC,	length = 0x0006A0	/* Floating poit unit ROM tables */

 PAGE 1:    /* Data Memory */

 	L47SARAM	: origin = 0x00C000,	length = 0x3C00		/* Internal RAM */
 	HEAP		: origin = 0x00FC00,	length = 0x0400		/* Internal RAM Reserved for Heap Memory	*/
 	MSARAM		: origin = 0x000040,	length = 0x07C0		/* Internal RAM */
 	PIEVECT		: origin = 0x000D00,	length = 0x0100		/* PIE table */
 	SRAM		: origin = 0x200000,	length = 0x010000	/* External RAM in Zone 7: CAUTION SELECT THE PROPER SIZE AND NEXT COMPILE */

but the sectors of each file are different, in the bootloader I have this:

.text:			>		FLASHA,						PAGE= 0
	.switch:		>		FLASHA,						PAGE= 0
	.cinit:			>		FLASHA,						PAGE= 0
	.pinit:			>		FLASHA,						PAGE= 0
	.econst:		>		FLASHA,						PAGE= 0
	.reset:			>		FLASHA,						PAGE= 0
	.jumpint00:		>		JUMPCINT00,					PAGE= 0

and in the application file, I have this:

.text:			>		FLASH,						PAGE= 0
	.switch:		>		FLASH,						PAGE= 0
	.cinit:			>		FLASH,						PAGE= 0
	.pinit:			>		FLASH,						PAGE= 0
	.econst:		>		FLASH,						PAGE= 0
	.reset:			>		FLASH,						PAGE= 0
	.jumpint00:		>		JUMPCINT00,					PAGE= 0

Doing this, I have an error, first, in bootloader project, the compiler try to search the _main function, but I don't have a main function in bootloader. I try to change the entry point to my bootloader functions, but not work

  • hello again,

    I'm still trying to program the bootloader. I found this asm code, for jump to main of the App, allocated in H sector:

    	.text
    _jumpToAppEntry:
    	C28OBJ ; Select C28x object mode
    	C28ADDR ; Select C27x/C28x addressing
    
    	SETC INTM;
    	ZAPA;
    	MOV @SP,#0;
    	PUSH ACC;
    	PUSH AL;
    	MOV AL, #0x0a08;
    	PUSH AL;
    	MOVL XAR7, #0x300000;
    	PUSH XAR7;
    	POP RPC;
    	POP ST1;
    	POP ST0;
    	POP IER;
    	POP DBGIER;
    	LRETR;
    

    I created an .asm file with this code. I also have a .c file with this code

    void PE_bootloader(void)
    {
    	/*	Disable WD	*/
    	WD.Disable();
    
    // Bootloader tasks....
    // Call jumpToAppEntry } void main(void){ asm(" nop"); }

    if I call the asm function from the C code, my app can start, right?, How I can to call the asm function (jumpToAppEntry), from my C code? Thanks!!!

  • Pablo,

    There seem to be a lot of users doing the same thing as you the past couple of days.  There are numerous old threads on this forum discussing how to connect a secondary bootloader and main app project.  Here is one from just today.  I think it will help.

    http://e2e.ti.com/support/microcontrollers/c2000/f/171/p/383198/1357443.aspx#1357443

    You're on the right track with your linker .cmd files.  All you need to do is handle the branch from the secondary bootloader to the main app.  The thread I cited will show you what to do.

    Regards,

    David

  • Hello David, 

    thanks for answer. I was searching the word "bootloader". I will read that post.

    Thanks!

  • Hello everybody,

    I have my bootloader project runnning before the app project, and works fine. My error was in the linker file... I have 2 linker files, one for App and 1 for bootloader. In the bootloader file, the redirection to cint00 function is in the address 0x33FFF6, because is the first program that executes, but in the App programm shall be in the first ( or last) address of flash sector where is allocated, in my case, I have only 1 sector reserved for bootloader, and the rest oh Flash is for application, so I put the redirection to cint00 in the last address of Flash b sector, that is 0x337FFE. Must ensure that the bootloader project only erases the flash A sector, and the App project erases all sectors except A.

    Now I have to program the device. First I include to my bootloader project the FLASH API v210 for 28335. When I link the libraries and write the #includes in my code, I can use the API funcions. When I compile the project, all seems well, but when in debuggin, the program arrive to the erase function... Can't find a source file at "Flash28_Erase.c", and the DSP restarts.

    I just trying the program function with the same result, the DSP is restarted....

    Thanks!

  • Pablo,

    Pablo Trujillo said:

    Now I have to program the device. First I include to my bootloader project the FLASH API v210 for 28335. When I link the libraries and write the #includes in my code, I can use the API funcions. When I compile the project, all seems well, but when in debuggin, the program arrive to the erase function... Can't find a source file at "Flash28_Erase.c", and the DSP restarts.

    I just trying the program function with the same result, the DSP is restarted....

    The "Can't find a source file" message is just CCS saying it doesn't have the source file for the flash APIs.  This is a very common thing when using libraries.  You don't have the soruce files, right?  So, CCS cannot do source level debug.  Instead, CCS will just use the disassembly window.  This is not the cause of your problem.

    It terms of the device reset, I'm not quite seeing what you're doing here.  You should be programming your secondary bootloader using a flash tool, say CCS or TI Uniflash.  Then you can use the secondary bootloader to flash your main app (or you could use a flash tool to do it at production time, which is what most people will do).  Maybe you can explain more clearly what is being done.  You say you arrive at the erase function.  I assume you mean you set a breakpoint in your secondary bootloader where the call to erase() is, and you've hit that breakpoint.  Now what do you do?  Do you step?  You should not step through flash API functions (erase or program) as these functions are timing dependent and you could damage the flash if you try to step through them.  Do you hit run?  Assuming you hit run, you're saying the device just resets?  Then something else is wrong here.  Did you copy the API functions to RAM prior to executing them?  You setup the linker .cmd file to load to flash but run from RAM, but you still MUST do the copy yourself in your own code.  Maybe that's what went wrong here.

    Regards,

    David

  • Hello David,

    I want to program my device from a uP, that is connected to DSP through McBSP. the McBSP is running as SPI slave.

    The code of my bootloader is this:

    void main(void){
    
    	/*	Disable WD		*/
    	WD_Disable();
    
        /* 	Config the DSP	*/
    	DSP_Config();
    
    	/*	Led sequence	*/
    	led_sequence();
    
    	DINT;
    	/*	Bootloader		*/
    	bootloader();
    	EINT;
    
    	/*	Jump to application		*/
    	JumpToApp();
    }
    
    void bootloader(void){
    
    	Uint16 status;
    	FLASH_ST ProgStatus; // Status structure
    
    	Flash_CPUScaleFactor = SCALE_FACTOR;
    	Flash_CallbackPtr = &MyCallbackFunction;	// Flash API callback function
    
    	//	STEP 1:		Erase all memory sectors
    	status = Flash_Erase(SECTORH, &FlashStatus);
    
    	asm("  nop");
    
    }

    I put the breakpoint in nop instruction, but the program never arrives here, and the DSP is restarted. I know now why the CCS not find the source code, but, as you say, this is not the problem.

    In the DSP configuration, I configure the peripherals that I use, in this case, only GPIOs.

    When the program arrive to Flash-erase, after 1 o 2 seconds, it's restarted.  if I put a breakpoint in nop instruction, the program never arrives.

    I have 3 RAM sections for differents code, 1 for Flash initialization, 1 for other functions, and 1 for FLASH API. the CMD file is this:

    .codeinram:				LOAD = FLASHA,
    							RUN = L03SARAM,
    							LOAD_START(_CodeinRam_Start),
    							LOAD_SIZE(_CodeinRam_Size),
    							RUN_START(_CodeinRam_Run),
    							PAGE= 0
    
    	.initflash:				LOAD = FLASHA,
    							RUN = L03SARAM,
    							LOAD_START(_Initflash_Start),
    							LOAD_SIZE(_Initflash_Size),
    							RUN_START(_Initflash_Run),
    							PAGE= 0
    	Flash28_API:
       {
            -lFlash28335_API_V210.lib(.econst)
            -lFlash28335_API_V210.lib(.text)
       }  	               LOAD = FLASHA,
                           RUN = L03SARAM,
                           LOAD_START(_Flash28_API_LoadStart),
                           LOAD_END(_Flash28_API_LoadEnd),
                           RUN_START(_Flash28_API_RunStart),
                           PAGE = 0

    And there how I ejecute the memcopy, inside the DSP_config

    /// Flash configuration and Code in RAM loading			
    	FLASH_MemCopy(INITFLASH);				
    	FLASH_Init();							
    	FLASH_MemCopy(CODERAM);					
    	FLASH_MemCopy(FLASH_API);	

    Tha FLASH_memcopy is a original memcopy function, but this have three cases.

    I seems a problem with memory allocation, but whether the program go to a null address, the illegal interrupt shall execute, but this interrupt never set.

    P.D. I notice that I have a warning that say:

    #10068-D no matching section  

    referent to this line in .cmd file

          -lFlash28335_API_V210.lib(.econst)

    can be the problem?

    is necesary unlock the FLASH with the function CsmUnlock()?

  • Hello all!!
    I have my botloader running on the 28335, but I have a little problem,... In the power on, the bootloader check if there is any program saved in FLASh, and if all it's ok, the program runs perfectly, but, when from App, I have to reset the DSP, the program jumps to HW Illegal interrupt... For reset the DSP I use the assembly instruction LB 0x33FFF6... but not work. The App starts in 0x300000. I reserve the sectorA for bootloader, and the rest for application. How I can restart the DSP by software? I try to hold the program with a while(1), and then, the watchdog reset the DSP, but.. in this case.. the program jumps to 0x33FFF6 or to the CInit of application (0x300000)? This method don't works... Thanks!!