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.

Trouble with bootloader writed in C language

hello.I try to write bootloder in C language.The bootloder (boot()) in boot.c file comes with a application project. In the project ,the main funcion ,of course,don't call boot().

The result is in the project map file ,the section "boot_loader" set for boot function is lost.I think the compiler has ignore the boot function.I want to know how to solve this problem.

the following is my boot.c and link.cmd:

/*******************************
           boot.c
*******************************/
#include "c6x.h"
#include "c6747.h"

#define NAND_BASE                  0x62000000  // SNAND.CS0 BASE
#define NAND_CLE_PTR        *( volatile Uint8* )( NAND_BASE + 0x10 )
#define NAND_ALE_PTR        *( volatile Uint8* )( NAND_BASE + 0x08 )
#define NAND_CMD( cmd )     NAND_CLE_PTR = cmd;
#define NAND_ADDR_4( addr ) NAND_ALE_PTR = (addr >> 0) & 0xff;

#define CODE_ADDR   00800400h

extern far c_int00(void);
extern far unsigned int text_size; 

#pragma CODE_SECTION(boot,"boot_loader");
void boot(void)
{
 Uint32 i, j;
 Uint16 flag = 0;
 register int code_count=0;
 volatile Uint32 *dst8 =(volatile Uint32 *)0x00800400;
 Uint32 src=0x400;
  
 //AEMIF configure
 AEMIF_A2CR = 0x0886632C;
 AEMIF_NANDFCR = 0x00000002;

 // Code Copy
  
    for ( i = 0 ; i < 4 ; i++ )//copy 4 pages
    {

        NAND_CMD( 0x00 );           // Read page
        NAND_ADDR_4( src );
  NAND_CMD(0x30 );

  // Read MAIN array
  for ( j = 0 ; j < 2*1024 ; j++ )
           {
           *dst8++ = 0x62000000;
           code_count++;
           if(code_count==text_size)
            {
      flag = 1;
            break;
            }
     }           
  if(!flag )
  src += 0x1000;//4K
    }
    c_int00();

}   

/*******************************
            link.cmd
******************************/
-c
-heap  0x1000
-stack 0x1000

 

MEMORY
{
    BOOTRAM:       o = 00800000h   l = 00000400h  //1K
    IRAM:          o = 00800400h   l = 0083FFFFh
    FLASH_BOOT:    o = 0x62000000  l = 00000400h
    FLASH_REST:    o = 0x62000400  l = 63FFFFFFh                          

                                                             
}

SECTIONS
{
 .boot_loader   :   load = FLASH_BOOT, run = BOOTRAM   
                                                                  
    /* Initialized User Code Section */
    .text    : load = FLASH_REST, run = IRAM
     SIZE(_text_size)
          
    .cinit     >     IRAM
    .const      >       IRAM
    .stack      >       IRAM
    .bss        >       IRAM
    .data       >       IRAM
    .far        >       IRAM
    .switch     >       IRAM
    .sysmem     >       IRAM
    .cio        >       IRAM
 .vectors >  IRAM, RUN_START(_ISTP_START)
}                            

  • Use the BIOSPSP for the C6747. Search the TI Wiki Pages for "C6747 BIOSPSP" (no quotes) to find some articles that will guide you in locating and using the BIOSPSP.

    Use the tools that TI supplies for you.

    This is the way you can be successful.

    Regards,
    RandyP

     

    If you need more help, please reply back. If this answers the question, please click  Verify Answer  , below.

  • Thank you for your suggestion.But I think the current method is OK.The key point is the boot funcion  has been ignored by the compiler while I don't think I have done any compiler options.

    regards,

    Peng Xu

  • Respectfully disagreeing, the current method is not OK because it does not work.

    It will be easier and faster for you to use the BIOSPSP to see how a working system is implemented. Then if you still want to make yours work, you will have a working system to compare with yours. This is the method by which we are able to support you to get your application running.

    It is not possible for us to figure out everything that any user could do wrong, so we chose to create working examples and support libraries to provide either a direct solution you can use or an example solution you can base your application on.

    Regards,
    RandyP

  •  

    RandyP said:

    Respectfully disagreeing, the current method is not OK because it does not work.

    It will be easier and faster for you to use the BIOSPSP to see how a working system is implemented. Then if you still want to make yours work, you will have a working system to compare with yours. This is the method by which we are able to support you to get your application running.

    It is not possible for us to figure out everything that any user could do wrong, so we chose to create working examples and support libraries to provide either a direct solution you can use or an example solution you can base your application on.

    Regards,
    RandyP

    Thank you for your consideration.I'll follow your advice.

    By the way ,did the C6747 need secondary bootloader to run a application code with a 100K bytes size?

    Someone told me burn  the AIS file of the application code into the flash,then it can run in boot mode.Is that right?

     

    Regard,

    Peng  Xu