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.

LCDK C6748 application boot problems!

Other Parts Discussed in Thread: OMAP-L138, OMAPL138, SYSBIOS

Hi,

For the past three days I have been trying to make my application boot-able on the LCDK-C6748 board. The application works fine on the board with the CCS debugger. Now I am trying to flash it to NAND on the board and I am having NO luck. I used AISgen_d800k008 and flash writer provided with starter ware which is sfh_OMAP-L138.exe. I used the OMAPL138_LCDK_AISGen_Config.cfg in the AISgen. The nand flash 16bits and the some pll settings are automatically set by the .cfg.

The steps work fine. That is I can AISGen the app.out to produce app.bin. Then I can use sfh utility to connect to the lcdk via uart (with BOOTME) prompt and erase the flash and then write the image to flash. The steps go without a problem.

For the sfh I use the following steps.

sfh_OMAP-L138.exe -targettype C6748_LCDK -flashtype NAND -p COMx -erase

    Flash bootable AIS image (ais_image.bin) to block 1 of the NAND:

sfh_OMAP-L138.exe -targettype C6748_LCDK -flashtype NAND -p COMx -flash_noubl ais_image.bin


However when I change the dip switches to boot from NAND flash and power cycle the board nothing happens. I am expecting to see a banner out put from the serial port. on my computer.

I then built the SerialEcho example in starter ware and ran it using CCS and debugger and works fine. Same story as above when I flashed it and tried to boot without the debugger attached. I have attached the linker map from the SerialEcho program. I am trying to run everything from L2 RAM. My final application will also run from L2 ram entirely.

Please let me know exact steps to follow from a known working tools. Where to download them from etc as several versions of the above tools seems to be floating around. I think there should be a utility integrated with CCS which will allow hapless engineers like me to easily flash target boards which will save a lot of development time.

Another question is can I boot from SD card on the LCDK? If possible can you point me to some information regarding this as well?

Thanks and best regards

Manjula

uart link Map.txt
******************************************************************************
               TMS320C6x Linker PC v7.4.15                     
******************************************************************************
>> Linked Fri Oct 30 01:27:16 2015

OUTPUT FILE NAME:   <uart.out>
ENTRY POINT SYMBOL: "_c_int00"  address: 11803400


MEMORY CONFIGURATION

         name            origin    length      used     unused   attr    fill
----------------------  --------  ---------  --------  --------  ----  --------
  DSPL2ROM              00700000   00100000  00000000  00100000  RWIX
  DSPL2RAM              00800000   00040000  00000000  00040000  RWIX
  DSPL1PRAM             00e00000   00008000  00000000  00008000  RWIX
  DSPL1DRAM             00f00000   00008000  00000000  00008000  RWIX
  SHDSPL2ROM            11700000   00100000  00000000  00100000  RWIX
  SHDSPL2RAM            11800000   00040000  0000404c  0003bfb4  RWIX
  SHDSPL1PRAM           11e00000   00008000  00000000  00008000  RWIX
  SHDSPL1DRAM           11f00000   00008000  00000000  00008000  RWIX
  EMIFACS0              40000000   20000000  00000000  20000000  RWIX
  EMIFACS2              60000000   02000000  00000000  02000000  RWIX
  EMIFACS3              62000000   02000000  00000000  02000000  RWIX
  EMIFACS4              64000000   02000000  00000000  02000000  RWIX
  EMIFACS5              66000000   02000000  00000000  02000000  RWIX
  SHRAM                 80000000   00020000  00000000  00020000  RWIX
  DDR2                  c0000000   20000000  00000000  20000000  RWIX


SEGMENT ALLOCATION MAP

run origin  load origin   length   init length attrs members
----------  ----------- ---------- ----------- ----- -------
11800000    11800000    00003580   00003580    r-x
  11800000    11800000    00003580   00003580    r-x .text
11803580    11803580    00000a40   00000000    rw-
  11803580    11803580    00000800   00000000    rw- .stack
  11803d80    11803d80    00000240   00000000    rw- .far
11803fc0    11803fc0    0000002c   0000002c    rw-
  11803fc0    11803fc0    00000024   00000024    rw- .fardata
  11803fe4    11803fe4    00000008   00000008    rw- .neardata
11803ff0    11803ff0    00000060   00000060    r--
  11803ff0    11803ff0    00000060   00000060    r-- .cinit


SECTION ALLOCATION MAP

 output                                  attributes/
section   page    origin      length       input sections
--------  ----  ----------  ----------   ----------------
.init_array 
*          0    11800000    00000000     UNINITIALIZED

.text      0    11800000    00003580     
                  11800000    00001aa0     interrupt.obj (.text:retain)
                  11801aa0    000005e0     interrupt.obj (.text)
                  11802080    00000580     uart.obj (.text)
                  11802600    00000200     uartEcho.obj (.text)
                  11802800    00000200     intvecs.obj (.text)
                  11802a00    00000180     rts6740_elf.lib : copy_decompress_rle.obj (.text:__TI_decompress_rle_core)
                  11802b80    00000180     uart_6748plat.obj (.text)
                  11802d00    00000140     psc.obj (.text)
                  11802e40    00000100     rts6740_elf.lib : autoinit.obj (.text:_auto_init_elf)
                  11802f40    00000100                     : cpy_tbl.obj (.text:copy_in)
                  11803040    000000e0                     : copy_zero_init.obj (.text:decompress:ZI:__TI_zero_init)
                  11803120    000000c0                     : divu.obj (.text:__divu)
                  118031e0    000000c0                     : exit.obj (.text:exit)
                  118032a0    000000c0                     : tls.obj (.text:tls:init:__TI_tls_init)
                  11803360    000000a0                     : memcpy64.obj (.text:memcpy)
                  11803400    00000080                     : boot.obj (.text:_c_int00)
                  11803480    00000060                     : cpp_init.obj (.text:__TI_cpp_init)
                  118034e0    00000040                     : args_main.obj (.text:_args_main)
                  11803520    00000020                     : exit.obj (.text:abort)
                  11803540    00000020                     : copy_decompress_none.obj (.text:decompress:none:__TI_decompress_none)
                  11803560    00000020                     : copy_decompress_rle.obj (.text:decompress:rle24:__TI_decompress_rle24)

.stack     0    11803580    00000800     UNINITIALIZED
                  11803580    00000008     rts6740_elf.lib : boot.obj (.stack)
                  11803588    000007f8     --HOLE--

.far       0    11803d80    00000240     UNINITIALIZED
                  11803d80    00000240     interrupt.obj (.far)

.fardata   0    11803fc0    00000024     
                  11803fc0    00000018     uartEcho.obj (.fardata:txArray)
                  11803fd8    0000000c     rts6740_elf.lib : exit.obj (.fardata)

.neardata 
*          0    11803fe4    00000008     
                  11803fe4    00000008     uartEcho.obj (.neardata)

.cinit     0    11803ff0    00000060     
                  11803ff0    00000024     (.cinit..fardata.load) [load image, compression = rle]
                  11804014    0000000c     (__TI_handler_table)
                  11804020    0000000a     (.cinit..neardata.load) [load image, compression = rle]
                  1180402a    00000002     --HOLE-- [fill = 0]
                  1180402c    00000008     (.cinit..far.load) [load image, compression = zero_init]
                  11804034    00000004     --HOLE-- [fill = 0]
                  11804038    00000018     (__TI_cinit_table)


LINKER GENERATED COPY TABLES

__TI_cinit_table @ 11804038 records: 3, size/record: 8, table size: 24
	.fardata: load addr=11803ff0, load size=00000024 bytes, run addr=11803fc0, run size=00000024 bytes, compression=rle
	.neardata: load addr=11804020, load size=0000000a bytes, run addr=11803fe4, run size=00000008 bytes, compression=rle
	.far: load addr=1180402c, load size=00000008 bytes, run addr=11803d80, run size=00000240 bytes, compression=zero_init


LINKER GENERATED HANDLER TABLE

__TI_handler_table @ 11804014 records: 3, size/record: 4, table size: 12
	index: 0, handler: __TI_zero_init
	index: 1, handler: __TI_decompress_rle24
	index: 2, handler: __TI_decompress_none


GLOBAL SYMBOLS: SORTED ALPHABETICALLY BY Name 

address    name
--------   ----
11803520   C$$EXIT
11801ef8   ExcCombineAdd
11801f40   ExcCombineRemove
11801ed8   ExcGlobalEnable
11801aa0   IntDSPINTCInit
11801e50   IntDisable
11801e20   IntEnable
11801c18   IntEventClear
11801d54   IntEventCombineAdd
11801c50   IntEventCombineInit
11801df8   IntEventCombineRegister
11801da8   IntEventCombineRemove
11801b5c   IntEventMap
11801be4   IntEventSet
11801eac   IntGlobalDisable
11801e98   IntGlobalEnable
11801ec0   IntGlobalRestore
11801b10   IntRegister
11801e84   IntReset
11801b34   IntUnRegister
11802d00   PSCModuleControl
118024e4   UARTBreakCtl
118023d4   UARTCharGet
118023a8   UARTCharGetNonBlocking
11802410   UARTCharPut
11802368   UARTCharPutNonBlocking
11802318   UARTCharsAvail
11802114   UARTConfigGetExpClk
11802080   UARTConfigSetExpClk
118021ec   UARTDMADisable
118021cc   UARTDMAEnable
11802294   UARTDisable
11802278   UARTEnable
118022d4   UARTFIFODisable
118022c0   UARTFIFOEnable
118021a8   UARTFIFOLevelSet
11802490   UARTIntDisable
11802468   UARTIntEnable
118024b8   UARTIntStatus
11802570   UARTModemControlClear
118025a4   UARTModemControlGet
11802518   UARTModemControlSet
118025c4   UARTModemStatusGet
11802254   UARTParityModeGet
1180220c   UARTParityModeSet
11802b80   UARTPinMuxSetup
11802348   UARTRxErrorGet
118022ec   UARTSpaceAvail
11804038   __TI_CINIT_Base
11804050   __TI_CINIT_Limit
11804014   __TI_Handler_Table_Base
11804020   __TI_Handler_Table_Limit
UNDEFED    __TI_INITARRAY_Base
UNDEFED    __TI_INITARRAY_Limit
11803d80   __TI_STACK_END
00000800   __TI_STACK_SIZE
11803fe4   __TI_STATIC_BASE
UNDEFED    __TI_TLS_INIT_Base
UNDEFED    __TI_TLS_INIT_Limit
00000001   __TI_args_main
11803480   __TI_cpp_init
11803540   __TI_decompress_none
11803560   __TI_decompress_rle24
11803fe0   __TI_enable_exit_profile_output
ffffffff   __TI_pprof_out_hndl
ffffffff   __TI_prof_data_size
ffffffff   __TI_prof_data_start
118032a0   __TI_tls_init
11803040   __TI_zero_init
ffffffff   __binit__
11803120   __c6xabi_divu
ffffffff   __c_args__
11803120   __divu
118034e0   _args_main
11802e40   _auto_init_elf
11800ff8   _c674x_mask_int10_isr
118011c0   _c674x_mask_int11_isr
11801384   _c674x_mask_int12_isr
11801548   _c674x_mask_int13_isr
11801710   _c674x_mask_int14_isr
118018d8   _c674x_mask_int15_isr
11800550   _c674x_mask_int4_isr
11800718   _c674x_mask_int5_isr
118008e0   _c674x_mask_int6_isr
11800aa4   _c674x_mask_int7_isr
11800c68   _c674x_mask_int8_isr
11800e30   _c674x_mask_int9_isr
11800000   _c674x_nmi_isr
118001c4   _c674x_rsvd_int2_isr
11800388   _c674x_rsvd_int3_isr
11803400   _c_int00
11803fd8   _cleanup_ptr
11803fdc   _dtors_ptr
11802800   _intcVectorTable
11803580   _stack
11803520   abort
ffffffff   binit
11802f40   copy_in
118031e0   exit
11802600   main
11803360   memcpy
11803fc0   txArray


GLOBAL SYMBOLS: SORTED BY Symbol Address 

address    name
--------   ----
00000001   __TI_args_main
00000800   __TI_STACK_SIZE
11800000   _c674x_nmi_isr
118001c4   _c674x_rsvd_int2_isr
11800388   _c674x_rsvd_int3_isr
11800550   _c674x_mask_int4_isr
11800718   _c674x_mask_int5_isr
118008e0   _c674x_mask_int6_isr
11800aa4   _c674x_mask_int7_isr
11800c68   _c674x_mask_int8_isr
11800e30   _c674x_mask_int9_isr
11800ff8   _c674x_mask_int10_isr
118011c0   _c674x_mask_int11_isr
11801384   _c674x_mask_int12_isr
11801548   _c674x_mask_int13_isr
11801710   _c674x_mask_int14_isr
118018d8   _c674x_mask_int15_isr
11801aa0   IntDSPINTCInit
11801b10   IntRegister
11801b34   IntUnRegister
11801b5c   IntEventMap
11801be4   IntEventSet
11801c18   IntEventClear
11801c50   IntEventCombineInit
11801d54   IntEventCombineAdd
11801da8   IntEventCombineRemove
11801df8   IntEventCombineRegister
11801e20   IntEnable
11801e50   IntDisable
11801e84   IntReset
11801e98   IntGlobalEnable
11801eac   IntGlobalDisable
11801ec0   IntGlobalRestore
11801ed8   ExcGlobalEnable
11801ef8   ExcCombineAdd
11801f40   ExcCombineRemove
11802080   UARTConfigSetExpClk
11802114   UARTConfigGetExpClk
118021a8   UARTFIFOLevelSet
118021cc   UARTDMAEnable
118021ec   UARTDMADisable
1180220c   UARTParityModeSet
11802254   UARTParityModeGet
11802278   UARTEnable
11802294   UARTDisable
118022c0   UARTFIFOEnable
118022d4   UARTFIFODisable
118022ec   UARTSpaceAvail
11802318   UARTCharsAvail
11802348   UARTRxErrorGet
11802368   UARTCharPutNonBlocking
118023a8   UARTCharGetNonBlocking
118023d4   UARTCharGet
11802410   UARTCharPut
11802468   UARTIntEnable
11802490   UARTIntDisable
118024b8   UARTIntStatus
118024e4   UARTBreakCtl
11802518   UARTModemControlSet
11802570   UARTModemControlClear
118025a4   UARTModemControlGet
118025c4   UARTModemStatusGet
11802600   main
11802800   _intcVectorTable
11802b80   UARTPinMuxSetup
11802d00   PSCModuleControl
11802e40   _auto_init_elf
11802f40   copy_in
11803040   __TI_zero_init
11803120   __c6xabi_divu
11803120   __divu
118031e0   exit
118032a0   __TI_tls_init
11803360   memcpy
11803400   _c_int00
11803480   __TI_cpp_init
118034e0   _args_main
11803520   C$$EXIT
11803520   abort
11803540   __TI_decompress_none
11803560   __TI_decompress_rle24
11803580   _stack
11803d80   __TI_STACK_END
11803fc0   txArray
11803fd8   _cleanup_ptr
11803fdc   _dtors_ptr
11803fe0   __TI_enable_exit_profile_output
11803fe4   __TI_STATIC_BASE
11804014   __TI_Handler_Table_Base
11804020   __TI_Handler_Table_Limit
11804038   __TI_CINIT_Base
11804050   __TI_CINIT_Limit
ffffffff   __TI_pprof_out_hndl
ffffffff   __TI_prof_data_size
ffffffff   __TI_prof_data_start
ffffffff   __binit__
ffffffff   __c_args__
ffffffff   binit
UNDEFED    __TI_INITARRAY_Base
UNDEFED    __TI_INITARRAY_Limit
UNDEFED    __TI_TLS_INIT_Base
UNDEFED    __TI_TLS_INIT_Limit

[102 symbols]

  • Dear Manjula,
    Which example are you working with ?
    Starterware package or your own code ?
    Did you use bootloader ?

    If you are using starterware then you may need to use starterware boot loader to boot the application.

    C:\ti\C6748_StarterWare_1_20_04_01\build\c674x\cgt_ccs\c6748\lcdkC6748\bootloader

    Please refer to the following TI wiki page for the steps.

    processors.wiki.ti.com/.../C6748_StarterWare_Booting_And_Flashing
    processors.wiki.ti.com/.../OMAPL138_StarterWare_Booting_And_Flashing

    My suggestion is that use LED application for booting then try for other examples.


    Another question is can I boot from SD card on the LCDK? If possible can you point me to some information regarding this as well?

    I hope its possible, done that stuff earlier.

    You can flash the same AIS binary on SD card with the following writer tool.
    C:\ti\OMAP-L138_FlashAndBootUtils_2.40\OMAP-L138\CCS\SDMMCWriter
  • Hi Titusrathinaraj,

    Thank you for the reply. Here are the answers to your questions.

    I am working with UartEcho in starterware. I can run this in CCS with the debugger without a problem.

    I also have my own firmware which is RTOS based running on CCS with debugger without a problem. I want to flash this and boot on lcdk. I developed the whole firmware on lcdk.

    I haven't used boot-loader yet. However I just saw on the wiki page of starterware that the bootloader needs to be used together with the app.out to work properly.
    This gives rise to some questions from me:

    1. Shouldn't UartEcho which is a simple example be able to be booted from flash without the special bootloader in starterwarer? The DSP ROM has all the functions to load the tables and jump to cinit so why do you need this bootloader?

    2. Does this mean that I need to use the starterware bootloader binary with my RTOS based app as well to run on the lcdk?

    3. Doesn't the AIS gen tool generate all the information required for the firmware to be booted correctly from the ROM program?

    4. Is there anything I need to do to the RTOS based app.out before it is bootable? That is any link switches etc?

    I will look at the wikis you sent me.

    Thanks for your help and BR

    Manjula

  • Dear Manjula,
    Actually bootloader is not required in your case since you are using C6748 LCDK board (DSP core alone).
    Its possible to boot your RTOS without bootloader, how ever we suggest customer to use starterware bootloader for starterware examples.
    Starterware bootloader is able to boot the ARM app as well as DSP app on OMAPL138 processors.

    Can you provide the RTOS project here to check from my side.
    I think, may be require some settings in AISgen conversion.

    For uart based starterware example, please use the starterware bootloader, it will work directly if you follow the wiki.
  • HI Titus

    Thank you for the reply. I am still having zero luck in getting the flash programmed and booting from flash successfully. Now this has turned into a lengthy research project and nearing one week of reading posts, docs etc etc. The information is allover the place. Why can't TI have one document with all the required information on how to make a bootable image and boot from flash etc. After my research so far I still have questions:

     I understand that CCS runs the GEL script before executing the user firmware in the debug environment. The GEL script initializes the processor setting such things as clocks, PSC etc etc. Therefore the user firmware needs to add initialization code at the start when creating a boot image.  I created a  C file out of the GEL file and called this first after entry into main(). This works with CCS debugger but after I flashed nothing happened.

    1. In CCS at which point does the GEL script get executed? Is it after the RBL executes loads all the sections and jumps to  _c_int00? Where should I place the initialization code? Is it ok to call from main() as the first routine or does it need to be executed as part of _c_int00?

    2. Is all the required initialization contained  in the C6748_LCDK gel file?

    3. I understand that the AIS_gen will generate some code to do some initialization to boot from a particular device such as NAND flash but not all the required initialization. Is this correct?

    4. Is there an example initialization source file that you could point me to that will do the required initialization of RTOS based firmware on the LCDK board?

    We have spent one year developing the firmware and now ready to run on production boards. I thought flashing would be easy. But it turns out not to be so as the information is scattered everywhere and is cryptic. This is really very frustrating! Making a boot image and flashing should be easy and done within a few hours. But TI wants us to do lengthy research projects it seems, as if we haven't got other things to do to meet customer deadlines :(


    We need to resolve this quickly as we have customer FAT next week!!!

    Regards

    Manjula

  • TItus


    I have further questions:

    There are several links and versions of the tools required to flash the image on the various posts, wikis etc etc which ones should i be using that is what is the correct version of the tools? ANd why are the tools on source forge? I have to install Cygwin, .Net and do about 20 cryptic steps to build these tools????

    I am talking about the AISgen tool and the sfh_ tools.

    Can you point me to the correct place so that I know I am getting the correct tools for the C6748?

    Can you please answer my questions please in the earlier post and this one? We are under extreme pressure here to solve this problem which should have been completed days ago...
    IF you are too busy let me know and will try someone else or contact TI support directly...


    Manjula

    Ps: I was reading the post from Walter Snafu in 2011... nothing has changed for the better in four years!!! He took SIX weeks to solve the flashing and image!...it is still a mess with regards to making an image and flashing...the tools are buggy ...several different versions scattered through wikis etc...too much or too little information...confused which rabbit hole to follow...what a mess! No single document explaining what needs to be done..

    Link to that post which is amusing and highly recommended reading: e2e.ti.com/.../112073
  • Dear Manjula,

    I then built the SerialEcho example in starter ware and ran it using CCS and debugger and works fine. Same story as above when I flashed it and tried to boot without the debugger attached. I have attached the linker map from the SerialEcho program. I am trying to run everything from L2 RAM. My final application will also run from L2 ram entirely.

    You should not face any problem since your code sitting on L2 internal RAM.

    Okay, leave about your code, just focus on C6748 starterware example code.

    Able to flash & boot any starterware code ??

    I am able to flash and boot the starterware DSP GPIO code and I attached here.

    gpioLed_1.ais

  • Titus

    Thanks for the link. I will try it and let you know if it works. I am assuming that the .ais you sent me can be directly flashed on the lcdk without the boot.out? It seems to be that either the _sfh tool is not flashing properly or the aisGen is not working properly...

    Can you send me the _sfh tools and the aisGen tools you are using? I can send you my email address.

    Can you please answer each of my questions point by point? It is important to clarify and fill gaps in the information I have gathered so far so that I can build a complete picture of what needs to be done when I try to make bootale image of the RTOS app.

    I repeat the questions here from my earlier posts:

    1. In CCS at which point does the GEL script get executed? Is it after the RBL executes loads all the sections and jumps to _c_int00? Where should I place the initialization code? Is it ok to call from main() as the first routine or does it need to be executed as part of _c_int00?

    2. Is all the required initialization contained in the C6748_LCDK gel file?

    3. I understand that the AIS_gen will generate some code to do some initialization to boot from a particular device such as NAND flash but not all the required initialization. Is this correct?

    4. Is there an example initialization source file that you could point me to that will do the required initialization of RTOS based firmware on the LCDK board?

    5 There are several links and versions of the tools required to flash the image on the various posts, wikis etc etc which ones should i be using that is what is the correct version of the tools? ANd why are the tools on source forge? I have to install Cygwin, .Net and do about 20 cryptic steps to build these tools????

    I am talking about the AISgen tool and the sfh_ tools.

    6. Can you point me to the correct place so that I know I am getting the correct tools for the C6748?

    Thanks

    Manjula
  • GPIO flashing Log:

    C:\ti\OMAP-L138_FlashAndBootUtils_2.40\OMAP-L138\GNU>

    C:\ti\OMAP-L138_FlashAndBootUtils_2.40\OMAP-L138\GNU>

    C:\ti\OMAP-L138_FlashAndBootUtils_2.40\OMAP-L138\GNU>sfh_OMAP-L138.exe  -targetType C6748_LCDK -flashType NAND -p COM19 -flash_noubl gpioLed_1.ais

    -----------------------------------------------------

      TI Serial Flasher Host Program for OMAP-L138

      (C) 2012, Texas Instruments, Inc.

      Ver. 1.67

    -----------------------------------------------------

         [TYPE] Single boot image

    [BOOT IMAGE] gpioLed_1.ais

       [TARGET] C6748_LCDK

       [DEVICE] NAND

       [NAND Block] 1

    Attempting to connect to device COM19...

    Press any key to end this program at any time.

    (AIS Parse): Read magic word 0x41504954.

    (AIS Parse): Waiting for BOOTME... (power on or reset target now)

    (AIS Parse): BOOTME received!

    (AIS Parse): Performing Start-Word Sync...

    (AIS Parse): Performing Ping Opcode Sync...

    (AIS Parse): Processing command 0: 0x58535901.

    (AIS Parse): Performing Opcode Sync...

    (AIS Parse): Loading section...

    (AIS Parse): Loaded 19808-Byte section to address 0x11800000.

    (AIS Parse): Processing command 1: 0x58535901.

    (AIS Parse): Performing Opcode Sync...

    (AIS Parse): Loading section...

    (AIS Parse): Loaded 1364-Byte section to address 0x11804D60.

    (AIS Parse): Processing command 2: 0x58535901.

    (AIS Parse): Performing Opcode Sync...

    (AIS Parse): Loading section...

    (AIS Parse): Loaded 20-Byte section to address 0x118052F0.

    (AIS Parse): Processing command 3: 0x58535901.

    (AIS Parse): Performing Opcode Sync...

    (AIS Parse): Loading section...

    (AIS Parse): Loaded 16-Byte section to address 0x11805304.

    (AIS Parse): Processing command 4: 0x58535906.

    (AIS Parse): Performing Opcode Sync...

    (AIS Parse): Performing jump and close...

    (AIS Parse): AIS complete. Jump to address 0x11804620.

    (AIS Parse): Waiting for DONE...

    (AIS Parse): Boot completed successfully.

    Waiting for SFT on the OMAP-L138...

    Flashing application gpioLed_1.ais (4000 bytes)

    100% [ ████████████████████████████████████████████████████████████ ]

                     Image data transmitted over UART.

    100% [ ████████████████████████████████████████████████████████████ ]

                      Application programming complete

    Operation completed successfully.

    2) I have also able to flash and boot the UARTecho app.

    uart.ais

    I don't see any problem in AISGen tool.

  • Titus

    I get all those outputs from sfh tool. I will try the led_blink you sent me today and let you know the results soon. Can you please answer my questions pls?
    If you are unsure can you point to someone else?

    Manjula

    My unanswered questions:

    I repeat the questions here from my earlier posts:

    1. In CCS at which point does the GEL script get executed? Is it after the RBL executes loads all the sections and jumps to _c_int00? Where should I place the initialization code (that I created from the GEL file)? Is it ok to call from main() as the first routine or does it need to be executed as part of _c_int00?

    2. Is all the required initialization contained in the C6748_LCDK gel file?

    3. I understand that the AIS_gen will generate some code to do some initialization to boot from a particular device such as NAND flash but not all the required initialization. Is this correct?

    4. Is there an example initialization source file that you could point me to that will do the required initialization of RTOS based firmware on the LCDK board?

    5 There are several links and versions of the tools required to flash the image on the various posts, wikis etc etc which ones should i be using that is what is the correct version of the tools? ANd why are the tools on source forge? I have to install Cygwin, .Net and do about 20 cryptic steps to build these tools????

    I am talking about the AISgen tool and the sfh_ tools.

    6. Can you point me to the correct place so that I know I am getting the correct tools for the C6748?
  • Dear Manjula,

    I understand that CCS runs the GEL script before executing the user firmware in the debug environment. The GEL script initializes the processor setting such things as clocks, PSC etc etc. Therefore the user firmware needs to add initialization code at the start when creating a boot image.  I created a  C file out of the GEL file and called this first after entry into main(). This works with CCS debugger but after I flashed nothing happened.

    Your understanding was 100% correct.

    1. In CCS at which point does the GEL script get executed? Is it after the RBL executes loads all the sections and jumps to _c_int00? Where should I place the initialization code? Is it ok to call from main() as the first routine or does it need to be executed as part of _c_int00?

    Yes, after RBL code, the gel file is initialized.

    When you connect the target (DSP), the gel file is get initialized.

    When you use AISGen code, it will sit top of your original app code to initialize the peripherals like what gel file is doing...

    2. Is all the required initialization contained in the C6748_LCDK gel file?

    Yes.

    3. I understand that the AIS_gen will generate some code to do some initialization to boot from a particular device such as NAND flash but not all the required initialization. Is this correct?

    Yes.

    4. Is there an example initialization source file that you could point me to that will do the required initialization of RTOS based firmware on the LCDK board?

    I hope, AISGen conversion is same for all type of projects.

    5 There are several links and versions of the tools required to flash the image on the various posts, wikis etc etc which ones should i be using that is what is the correct version of the tools? ANd why are the tools on source forge? I have to install Cygwin, .Net and do about 20 cryptic steps to build these tools????

    6. Can you point me to the correct place so that I know I am getting the correct tools for the C6748?

    You can download the latest OMAPL138 flash and boot utils tools here.

    Steps for rebuilding the tools,

    1. Download the cygwin x86 exe .

    2. Install it successfully by choosing the internet option.

    3. Observe that the icon apeears on the desktop.

    4. Open cygwin window.

    5. go to the path : /cygdrive/c/ti/mcsdk_1_01_00_01/host-tools/OMAP-L138_FlashAndBootUtils_2.40/OMAP-L138 using $cd < dir >

    6. open C:\ti\mcsdk_1_01_00_01\host-tools\OMAP-L138_FlashAndBootUtils_2.40\Common\build.mak in a notepad and make sure the path are appropriate:

    For example:

    ARM_TOOLS_PATH?=C:\\ti\\ccsv5\\tools\\compiler\\gcc-arm-none-eabi-4_7-2012q4\\

    #ARM_TOOLS_PATH?=C:\\CodeSourcery\\arm_eabi_2009q1-161\\

    ARM_TOOLS_PREFIX?=arm-none-eabi-

    CROSSCOMPILE?=$(ARM_TOOLS_PATH)bin\\$(ARM_TOOLS_PREFIX)

    ARM_CROSSCOMPILE=$(CROSSCOMPILE)

    DSP_TOOLS_PATH?=C:\\ti\\ccsv5\\tools\\compiler\\C6000_7.4.5\\

    #DSP_TOOLS_PATH?=C:\\CCSv5_1_0\\ccsv5\\tools\\compiler\\c6000\\

    DSP_LIB_PATH=$(DSP_TOOLS_PATH)lib\\

    DSP_CROSSCOMPILE=$(DSP_TOOLS_PATH)bin\\

    7. Go to computer properties, advanced system properties -- > system variables --> path edit --> c:\MinGW\bin;C:\Windows\Microsoft.NET\Framework64\v4.0.30319

    8. Go to this folder : c/ti/mcsdk_1_01_00_01/host-tools/OMAP-L138_FlashAndBootUtils_2.40/OMAP-L138

    and do

    $make clean

    $make

  • Dear Manjula,

    There were 3 important points to remember when you do AIS conversion.

    1)Flash type.

    if NAND, you have to mention the bus width correcly.

    In LCDK boards, we have 16bit data widh NAND device.

    2) Type of RAM

    Please aware about the code area, i.e RAM (internal RAM or external RAM)

    If external DDR RAM, then you have to setup the DDR correctly through PLL1 tab.

    If internal RAM used, no need any settings for PLL1.

    3) System clock (PLL0)

    If any code related to system clock (say ex: UART code) then you may need to set up the PLL0 settings.

    4) PINMUX.

    Please make sure that you have setup the PINMUX correctly if required for your project.

    Please let me know still if you have questions or not able to flash & boot the C6748 starterware examples on C6748 LCDK board.

    FYI:

    I have modified the linked command files *.cmd of the project in starterware examples, it booted from L2 RAM.

    For UART starterware code, just I have enabled the PLL0 settings since its depends on PLL clock.

       /* Configuring the UART parameters*/

    /* Titus SOC_UART_2_MODULE_FREQ  -> 150MHz */

       UARTConfigSetExpClk(SOC_UART_2_REGS, SOC_UART_2_MODULE_FREQ,

                           BAUD_115200, config,

                           UART_OVER_SAMP_RATE_16);

    Please use attached settings for your LCDK UART & GPIO examples and convert yourself then flash & boot.

    Titus_AIS_settings.cfg

  • Hi Titus

    Thank you for the led blink and UartEcho .ais files. both of them worked. That is I was able to flash them, run and get the expected result.
    So this confirms that the sfh tool and the flash is ok which is good. A step in the right direction... :)

    Next I AIS'ed my uart.out with the Titusxxx.cfg file loaded in the AIS tool. Then I flashed and ran but this time didn't work :(

    So there is either something wrong with the AISgen tool or my source. The source runs on ccs debug without a problem.
    Can you send me your source for the uart_echo ?

    I will rebuild the uart echo and try again. I saw somewhere that optimization needs to be turned off for the code that does the cpu init.
    Will try again and let you know.

    Please send me the uartEcho code.

    Thanks

    Manjula
  • Hi Titus

    Can you please send me the source files for the uart_echo application? Did you use an UBL to build the uart.ais file?
    I can run your .ais and it works but I'm not having luck with what I generate.

    Do you entirely rely on the .cfg that is loaded into the AISgen to initialize the device and run the uart app or you use additional processor init routine called from main()?

    Pls need to resolve this quickly.

    Manjula
  • Dear Manjula,
    Did you read my last post ?

    FYI:

    I have modified the linked command files *.cmd of the project in starterware examples, it booted from L2 RAM.

    You have to use internal L2 RAM, you have to modify the linker command file.

    e2e.ti.com/.../1673573

    Actually, default starterware example code using the DDR2 for running examples, I have changed the linked command file to run the code on L2 RAM, if you want to run the code on DDR2 then you may need to enable PLL1.

    // ============================================================================
    // Linker Command File for Linking c674 DSP Programs
    //
    // 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 0x1000 Software Stack Size
    // -heap 0x1000 Heap Area Size
    // ===========================================================================
    -stack 0x1000
    -heap 0x1000

    // ============================================================================
    // Specify the System Memory Map
    // ============================================================================
    MEMORY
    {
    L1P: o = 0x11E00000 l = 0x00008000
    L1D: o = 0x11F00000 l = 0x00008000
    L2: o = 0x11800000 l = 0x00040000
    DDR2: o = 0xC0000000 l = 0x08000000
    }

    // ============================================================================
    // Specify the Sections Allocation into Memory
    // ============================================================================
    SECTIONS
    {
    .cinit > L2 // Initialization Tables
    .pinit > L2 // Constructor Tables
    .init_array > L2 //
    .binit > L2 // Boot Tables
    .const > L2 // Constant Data
    .switch > L2 // Jump Tables
    .text > L2 // Executable Code
    .text:_c_int00: align=1024 > L2 // Entrypoint

    GROUP (NEARDP_DATA) // group near data
    {
    .neardata
    .rodata
    .bss // note: removed fill = 0
    } > L2
    .far: fill = 0x0, load > L2 // Far Global & Static Variables
    .fardata > L2 // Far RW Data
    .stack > L2 // Software System Stack
    .sysmem > L2 // Dynamic Memory Allocation Area

    .cio > L2 // C I/O Buffer
    .vecs > L2 // Interrupt Vectors
    }
  • Hi Titus,

    Yes I am aware of the linker command file. I had changed it to L2 ram earlier.

    Now my version of serialEcho also works. I think I have found the real culprit which seems to be a rogue version of AisGen... :(
    I downloaded it from the TI website.... AISgen for D800K008.exe version 1.13
    This seems to be generating incorrect .ais files

    When I used the AISgen that came with the starter-ware the LED_blink (my version) can now boot and run. This one is version 1.9

    So 1.13 is > 1.9 yes? Wud have thought 1.13 would be more bug fixed...

    Can you please investigate about the version 1.13 above and let me know of any reported problems?

    We have made good progress today. Next I will flash my actual RTOS app and let you know how things go soon...
    Thanks for your help....you have been great :)

    Manjula
  • Dear Manjula,

    I have generated one more *.cfg for DDR based code.

    You can use this for any starterware *.out which would run on DDR RAM.

    Titus_AIS_settings_with_DDR.cfg

  • Dear Manjula,
    Sounds good.
    I'm using AISgen tool version 1.9
    You can check out the following link for revision history with reported & fixed bugs.
    C:\AISgen_d800k008_Install_v1.13\AISgen for D800K008\README.txt
  • boardInit.c
    /*
     * boardInit.c
     *
     *  Created on: Nov 1, 2015
     *      Author: windows7
     */
    
    
    #define PLL0_BASE       0x01C11000                              /*SYSTEM PLL BASE ADDRESS*/
    #define PLL0_PID        *(unsigned int*) (PLL0_BASE + 0x00)     /*PID*/
    #define PLL0_RSTYPE     *(unsigned int*) (PLL0_BASE + 0xE4)     /*Reset Type status Reg*/
    #define PLL0_PLLCTL     *(unsigned int*) (PLL0_BASE + 0x100)    /*PLL Control Register*/
    #define PLL0_OCSEL      *(unsigned int*) (PLL0_BASE + 0x104)    /*OBSCLK Select Register*/
    #define PLL0_SECCTL     *(unsigned int*) (PLL0_BASE + 0x108)    /*PLL Secondary Control Register*/
    #define PLL0_PLLM       *(unsigned int*) (PLL0_BASE + 0x110)    /*PLL Multiplier*/
    #define PLL0_PREDIV     *(unsigned int*) (PLL0_BASE + 0x114)    /*Pre divider*/
    #define PLL0_PLLDIV1    *(unsigned int*) (PLL0_BASE + 0x118)    /*Divider-1*/
    #define PLL0_PLLDIV2    *(unsigned int*) (PLL0_BASE + 0x11C)    /*Divider-2*/
    #define PLL0_PLLDIV3    *(unsigned int*) (PLL0_BASE + 0x120)    /*Divider-3*/
    #define PLL0_OSCDIV1    *(unsigned int*) (PLL0_BASE + 0x124)    /*Oscilator Divider*/
    #define PLL0_POSTDIV    *(unsigned int*) (PLL0_BASE + 0x128)    /*Post Divider*/
    #define PLL0_BPDIV      *(unsigned int*) (PLL0_BASE + 0x12C)    /*Bypass Divider*/
    #define PLL0_WAKEUP     *(unsigned int*) (PLL0_BASE + 0x130)    /*Wakeup Reg*/
    #define PLL0_PLLCMD     *(unsigned int*) (PLL0_BASE + 0x138)    /*Command Reg*/
    #define PLL0_PLLSTAT    *(unsigned int*) (PLL0_BASE + 0x13C)    /*Status Reg*/
    #define PLL0_ALNCTL     *(unsigned int*) (PLL0_BASE + 0x140)    /*Clock Align Control Reg*/
    #define PLL0_DCHANGE    *(unsigned int*) (PLL0_BASE + 0x144)    /*PLLDIV Ratio Chnage status*/
    #define PLL0_CKEN       *(unsigned int*) (PLL0_BASE + 0x148)    /*Clock Enable Reg*/
    #define PLL0_CKSTAT     *(unsigned int*) (PLL0_BASE + 0x14C)    /*Clock Status Reg*/
    #define PLL0_SYSTAT     *(unsigned int*) (PLL0_BASE + 0x150)    /*Sysclk status reg*/
    #define PLL0_PLLDIV4    *(unsigned int*) (PLL0_BASE + 0x160)    /*Divider 4*/
    #define PLL0_PLLDIV5    *(unsigned int*) (PLL0_BASE + 0x164)    /*Divider 5*/
    #define PLL0_PLLDIV6    *(unsigned int*) (PLL0_BASE + 0x168)    /*Divider 6*/
    #define PLL0_PLLDIV7    *(unsigned int*) (PLL0_BASE + 0x16C)    /*Divider 7*/
    #define PLL0_PLLDIV8    *(unsigned int*) (PLL0_BASE + 0x170)    /*Divider 8*/
    #define PLL0_PLLDIV9    *(unsigned int*) (PLL0_BASE + 0x174)    /*Divider 9*/
    #define PLL0_PLLDIV10   *(unsigned int*) (PLL0_BASE + 0x178)    /*Divider 10*/
    #define PLL0_PLLDIV11   *(unsigned int*) (PLL0_BASE + 0x17C)    /*Divider 11*/
    #define PLL0_PLLDIV12   *(unsigned int*) (PLL0_BASE + 0x180)    /*Divider 12*/
    #define PLL0_PLLDIV13   *(unsigned int*) (PLL0_BASE + 0x184)    /*Divider 13*/
    #define PLL0_PLLDIV14   *(unsigned int*) (PLL0_BASE + 0x188)    /*Divider 14*/
    #define PLL0_PLLDIV15   *(unsigned int*) (PLL0_BASE + 0x18C)    /*Divider 15*/
    #define PLL0_PLLDIV16   *(unsigned int*) (PLL0_BASE + 0x190)    /*Divider 16*/
    
    #define PLL1_BASE       0x01E1A000                              /*SYSTEM PLL1 BASE ADDRESS*/
    #define PLL1_PID        *(unsigned int*) (PLL1_BASE + 0x00)     /*PID*/
    #define PLL1_RSTYPE     *(unsigned int*) (PLL1_BASE + 0xE4)     /*Reset Type status Reg*/
    #define PLL1_PLLCTL     *(unsigned int*) (PLL1_BASE + 0x100)    /*PLL Control Register*/
    #define PLL1_OCSEL      *(unsigned int*) (PLL1_BASE + 0x104)    /*OBSCLK Select Register*/
    #define PLL1_SECCTL     *(unsigned int*) (PLL1_BASE + 0x108)    /*PLL Secondary Control Register*/
    #define PLL1_PLLM       *(unsigned int*) (PLL1_BASE + 0x110)    /*PLL Multiplier*/
    #define PLL1_PREDIV     *(unsigned int*) (PLL1_BASE + 0x114)    /*Pre divider*/
    #define PLL1_PLLDIV1    *(unsigned int*) (PLL1_BASE + 0x118)    /*Divider-1*/
    #define PLL1_PLLDIV2    *(unsigned int*) (PLL1_BASE + 0x11C)    /*Divider-2*/
    #define PLL1_PLLDIV3    *(unsigned int*) (PLL1_BASE + 0x120)    /*Divider-3*/
    #define PLL1_OSCDIV1    *(unsigned int*) (PLL1_BASE + 0x124)    /*Oscilator Divider*/
    #define PLL1_POSTDIV    *(unsigned int*) (PLL1_BASE + 0x128)    /*Post Divider*/
    #define PLL1_BPDIV      *(unsigned int*) (PLL1_BASE + 0x12C)    /*Bypass Divider*/
    #define PLL1_WAKEUP     *(unsigned int*) (PLL1_BASE + 0x130)    /*Wakeup Reg*/
    #define PLL1_PLLCMD     *(unsigned int*) (PLL1_BASE + 0x138)    /*Command Reg*/
    #define PLL1_PLLSTAT    *(unsigned int*) (PLL1_BASE + 0x13C)    /*Status Reg*/
    #define PLL1_ALNCTL     *(unsigned int*) (PLL1_BASE + 0x140)    /*Clock Align Control Reg*/
    #define PLL1_DCHANGE    *(unsigned int*) (PLL1_BASE + 0x144)    /*PLLDIV Ratio Chnage status*/
    #define PLL1_CKEN       *(unsigned int*) (PLL1_BASE + 0x148)    /*Clock Enable Reg*/
    #define PLL1_CKSTAT     *(unsigned int*) (PLL1_BASE + 0x14C)    /*Clock Status Reg*/
    #define PLL1_SYSTAT     *(unsigned int*) (PLL1_BASE + 0x150)    /*Sysclk status reg*/
    #define PLL1_PLLDIV4    *(unsigned int*) (PLL1_BASE + 0x160)    /*Divider 4*/
    #define PLL1_PLLDIV5    *(unsigned int*) (PLL1_BASE + 0x164)    /*Divider 5*/
    #define PLL1_PLLDIV6    *(unsigned int*) (PLL1_BASE + 0x168)    /*Divider 6*/
    #define PLL1_PLLDIV7    *(unsigned int*) (PLL1_BASE + 0x16C)    /*Divider 7*/
    #define PLL1_PLLDIV8    *(unsigned int*) (PLL1_BASE + 0x170)    /*Divider 8*/
    #define PLL1_PLLDIV9    *(unsigned int*) (PLL1_BASE + 0x174)    /*Divider 9*/
    #define PLL1_PLLDIV10   *(unsigned int*) (PLL1_BASE + 0x178)    /*Divider 10*/
    #define PLL1_PLLDIV11   *(unsigned int*) (PLL1_BASE + 0x17C)    /*Divider 11*/
    #define PLL1_PLLDIV12   *(unsigned int*) (PLL1_BASE + 0x180)    /*Divider 12*/
    #define PLL1_PLLDIV13   *(unsigned int*) (PLL1_BASE + 0x184)    /*Divider 13*/
    #define PLL1_PLLDIV14   *(unsigned int*) (PLL1_BASE + 0x188)    /*Divider 14*/
    #define PLL1_PLLDIV15   *(unsigned int*) (PLL1_BASE + 0x18C)    /*Divider 15*/
    #define PLL1_PLLDIV16   *(unsigned int*) (PLL1_BASE + 0x190)    /*Divider 16*/
    
    /*PSC Module Related Registers*/
    #define PSC0_BASE       0x01C10000
    #define PSC1_BASE       0x01E27000
    
    #define PSC0_MDCTL      (PSC0_BASE+0xA00)
    #define PSC0_MDSTAT     (PSC0_BASE+0x800)
    #define PSC0_PTCMD      *(unsigned int*) (PSC0_BASE + 0x120)
    #define PSC0_PTSTAT     *(unsigned int*) (PSC0_BASE + 0x128)
    
    #define PSC1_MDCTL      (PSC1_BASE+0xA00)
    #define PSC1_MDSTAT     (PSC1_BASE+0x800)
    #define PSC1_PTCMD      *(unsigned int*) (PSC1_BASE + 0x120)
    #define PSC1_PTSTAT     *(unsigned int*) (PSC1_BASE + 0x128)
    
    #define PSC_TIMEOUT      200 // This value can be optimized by the user
    
    #define LPSC_EDMA_CC0    0
    #define LPSC_EDMA_TC0    1
    #define LPSC_EDMA_TC1    2
    #define LPSC_EMIFA       3   /*PSC0*/
    #define LPSC_SPI0        4   /*PSC0*/
    #define LPSC_MMCSD0      5   /*PSC0*/
    #define LPSC_ARM_AINTC   6
    #define LPSC_ARM_RAMROM  7   /*PSC0*/
    // LPSC #8 not used
    #define LPSC_UART0       9   /*PSC0*/
    #define LPSC_SCR0        10
    #define LPSC_SCR1        11
    #define LPSC_SCR2        12
    // LPSC #13 not used
    #define LPSC_ARM         14  /*PSC0*/
    #define LPSC_DSP         15  /*PSC0*/
    
    #define LPSC_EDMA_CC1    0
    #define LPSC_USB20       1   /*PSC1*/
    #define LPSC_USB11       2   /*PSC1*/
    #define LPSC_GPIO        3   /*PSC1*/
    #define LPSC_UHPI        4   /*PSC1*/
    #define LPSC_EMAC        5   /*PSC1*/
    #define LPSC_DDR         6   /*PSC1*/
    #define LPSC_MCASP0      7   /*PSC1*/
    #define LPSC_SATA        8   /*PSC1*/
    #define LPSC_VPIF        9   /*PSC1*/
    #define LPSC_SPI1        10  /*PSC1*/
    #define LPSC_I2C1        11  /*PSC1*/
    #define LPSC_UART1       12  /*PSC1*/
    #define LPSC_UART2       13  /*PSC1*/
    #define LPSC_MCBSP0      14  /*PSC1*/
    #define LPSC_MCBSP1      15  /*PSC1*/
    #define LPSC_LCDC        16  /*PSC1*/
    #define LPSC_EPWM        17  /*PSC1*/
    #define LPSC_MMCSD1      18
    #define LPSC_UPP         19
    #define LPSC_ECAP        20
    #define LPSC_EDMA_TC2    21
    // LPSC #22-23 not used
    #define LPSC_SCR_F0      24
    #define LPSC_SCR_F1      25
    #define LPSC_SCR_F2      26
    #define LPSC_SCR_F6      27
    #define LPSC_SCR_F7      28
    #define LPSC_SCR_F8      29
    #define LPSC_BR_F7       30
    #define LPSC_SHARED_RAM  31
    
    /*DDR MMR Declaration*/
    #define VTPIO_CTL           *(unsigned int*)(0x01E2C000)                  // VTPIO_CTL Register
    #define EMIFDDR_SDRAM_CFG   0xB0000000
    #define EMIFDDR_REVID       *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0x00)      //EMIF Module ID and Revision Register
    #define EMIFDDR_SDRSTAT     *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0x04)      //SDRAM Status Register
    #define EMIFDDR_SDCR        *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0x08)      //SDRAM Bank Config Register
    #define EMIFDDR_SDRCR       *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0x0C)      //SDRAM Refresh Control Register
    #define EMIFDDR_SDTIMR1     *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0x10)      //SDRAM Timing Register1
    #define EMIFDDR_SDTIMR2     *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0x14)      //SDRAM Timing Register2
    #define EMIFDDR_SDCR2       *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0x1C)      //SDRAM Config Register2
    #define EMIFDDR_PBBPR       *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0x20)      //VBUSM Burst Priority Register
    #define EMIFDDR_VBUSMCFG1   *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0x28)      //VBUSM config Value1 Register
    #define EMIFDDR_VBUSMCFG2   *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0x2C)      //VBUSM config Value2 Register
    #define EMIFDDR_IRR         *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0xC0)      //Interrupt Raw Register
    #define EMIFDDR_IMR         *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0xC4)      //Interrupt Masked Register
    #define EMIFDDR_IMSR        *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0xC8)      //Interrupt Mask Set Register
    #define EMIFDDR_IMCR        *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0xCC)      //Interrupt Mask Clear Register
    #define DDRPHYREV           *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0xE0)      //DDR PHY ID and Revision Register
    #define DRPYC1R             *(unsigned int*)(EMIFDDR_SDRAM_CFG + 0xE4)      //DDR PHY Control 1 Register
    
    #define DDR2 0              // Do not change this value
    #define MDDR 1              // Do not change this value
    #define VTP_TIMEOUT 200     // This value can be optimized by the user
    #define DDR_DEBUG 0         // Set this to "1" to program DDR with more timing slack
    
    #define EMIFDDR_BASE_ADDR       0xC0000000
    #define EMIFA_BASE_ADDR         0x40000000
    #define EMIFA_CS2_BASE_ADDR     0x60000000
    #define EMIFA_CS3_BASE_ADDR     0x62000000
    #define EMIFA_CS4_BASE_ADDR     0x64000000
    #define EMIFA_CS5_BASE_ADDR     0x66000000
    
    /*EMIF2.5 MMR Declaration*/
    #define EMIFA             0x68000000
    
    #define EMIFA_AWAITCFG    *(unsigned int*)(EMIFA + 0x04)
    #define EMIFA_SDCFG       *(unsigned int*)(EMIFA + 0x08)
    #define EMIFA_SDREF       *(unsigned int*)(EMIFA + 0x0C)
    #define EMIFA_ACFG2       *(unsigned int*)(EMIFA + 0x10)    //Async Bank1 Config Register
    #define EMIFA_ACFG3       *(unsigned int*)(EMIFA + 0x14)    //Async Bank2 Config Register
    #define EMIFA_ACFG4       *(unsigned int*)(EMIFA + 0x18)    //Async Bank3 Config Register
    #define EMIFA_ACFG5       *(unsigned int*)(EMIFA + 0x1C)    //Async Bank4 Config Register
    #define EMIFA_SDTIM       *(unsigned int*)(EMIFA + 0x20)    //SDRAM Timing Register
    #define EMIFA_SRPD        *(unsigned int*)(EMIFA + 0x3C)
    #define EMIFA_NANDFCR     *(unsigned int*)(EMIFA + 0x60)
    
    /*GPIO MMR*/
    #define GPIO_REG_BASE         (0x01E26000)
    #define GPIO_BANK_OFFSET      (0x28)
    #define GPIO_DAT_OFFSET       (0x04)
    #define GPIO_SET_OFFSET       (0x08)
    #define GPIO_CLR_OFFSET       (0x0C)
    #define GPIO_BINTEN           *(unsigned int*)(GPIO_REG_BASE + 0x08)
    #define GPIO_BANK01_BASE      (GPIO_REG_BASE + 0x10)
    #define GPIO_BANK23_BASE      (GPIO_BANK01_BASE + GPIO_BANK_OFFSET)
    #define GPIO_BANK45_BASE      (GPIO_BANK23_BASE + GPIO_BANK_OFFSET)
    #define GPIO_BANK67_BASE      (GPIO_BANK45_BASE + GPIO_BANK_OFFSET)
    #define GPIO_BANK8_BASE       (GPIO_BANK67_BASE + GPIO_BANK_OFFSET)
    #define GPIO_BANK23_DIR       *(unsigned int*)(GPIO_BANK23_BASE)
    #define GPIO_BANK23_DAT       *(unsigned int*)(GPIO_BANK23_BASE + GPIO_DAT_OFFSET)
    #define GPIO_BANK23_SET       *(unsigned int*)(GPIO_BANK23_BASE + GPIO_SET_OFFSET)
    #define GPIO_BANK23_CLR       *(unsigned int*)(GPIO_BANK23_BASE + GPIO_CLR_OFFSET)
    
    /*System MMR Declaration*/
    #define SYS_BASE           0x01C14000
    #define HOST0CFG           *(unsigned int*)(SYS_BASE + 0x040)  //ARM HOST0CFG
    #define KICK0R             *(unsigned int*)(SYS_BASE + 0x038)
    #define KICK1R             *(unsigned int*)(SYS_BASE + 0x03c)
    #define PINMUX0            *(unsigned int*)(SYS_BASE + 0x120)  //PINMUX0
    #define PINMUX1            *(unsigned int*)(SYS_BASE + 0x124)  //PINMUX1
    #define PINMUX2            *(unsigned int*)(SYS_BASE + 0x128)  //PINMUX2
    #define PINMUX3            *(unsigned int*)(SYS_BASE + 0x12C)  //PINMUX3
    #define PINMUX4            *(unsigned int*)(SYS_BASE + 0x130)  //PINMUX4
    #define PINMUX5            *(unsigned int*)(SYS_BASE + 0x134)  //PINMUX5
    #define PINMUX6            *(unsigned int*)(SYS_BASE + 0x138)  //PINMUX6
    #define PINMUX7            *(unsigned int*)(SYS_BASE + 0x13C)  //PINMUX7
    #define PINMUX8            *(unsigned int*)(SYS_BASE + 0x140)  //PINMUX8
    #define PINMUX9            *(unsigned int*)(SYS_BASE + 0x144)  //PINMUX9
    #define PINMUX10           *(unsigned int*)(SYS_BASE + 0x148)  //PINMUX10
    #define PINMUX11           *(unsigned int*)(SYS_BASE + 0x14C)  //PINMUX11
    #define PINMUX12           *(unsigned int*)(SYS_BASE + 0x150)  //PINMUX12
    #define PINMUX13           *(unsigned int*)(SYS_BASE + 0x154)  //PINMUX13
    #define PINMUX14           *(unsigned int*)(SYS_BASE + 0x158)  //PINMUX14
    #define PINMUX15           *(unsigned int*)(SYS_BASE + 0x15C)  //PINMUX15
    #define PINMUX16           *(unsigned int*)(SYS_BASE + 0x160)  //PINMUX16
    #define PINMUX17           *(unsigned int*)(SYS_BASE + 0x164)  //PINMUX17
    #define PINMUX18           *(unsigned int*)(SYS_BASE + 0x168)  //PINMUX18
    #define PINMUX19           *(unsigned int*)(SYS_BASE + 0x16C)  //PINMUX19
    #define CFGCHIP0           *(unsigned int*)(SYS_BASE + 0x17C)
    #define CFGCHIP2           *(unsigned int*)(SYS_BASE + 0x184)
    #define CFGCHIP3           *(unsigned int*)(SYS_BASE + 0x188)
    #define PD0                0   /*Power Domain-0*/
    #define PD1                1   /*Power Domain-1*/
    
    #define PLLEN_MUX_SWITCH         4
    #define PLL_LOCK_TIME_CNT        2400
    #define PLL_STABILIZATION_TIME   2000
    #define PLL_RESET_TIME_CNT       200
    
    void Clear_Memory_Map(void);
    void Setup_Memory_Map(void);
    
    void PSC_All_On(void);
    void Core_300MHz_mDDR_150MHz(void);
    
    void GEL_MapOff(void );
    void GEL_MapOn(void );
    void GEL_MapReset(void );
    void device_PLL0(unsigned int CLKMODE, unsigned int PLLM, unsigned int POSTDIV,unsigned int PLLDIV1, unsigned int PLLDIV2, unsigned int PLLDIV3, unsigned int PLLDIV7 );
    
    void targetConnect(void )
    {
       // //("\tTarget Connected.\n","Output",1,1,1);
       // //("\t---------------------------------------------\n","Output",1,1,1);
        Clear_Memory_Map();
        Setup_Memory_Map();
    
        PSC_All_On();
        Core_300MHz_mDDR_150MHz();
    
    }
    
    //menuitem "C6748 Memory Map"
    /* ------------------------------------------------------------------------ *
     *                                                                          *
     *  Clear_Memory_Map( )                                                     *
     *      Clear the Memory Map                                                *
     *                                                                          *
     * ------------------------------------------------------------------------ */
    void Clear_Memory_Map()
    {
       // GEL_MapOff( );
       // GEL_MapReset( );
       // //("\tMemory Map Cleared.\n","Output",1,1,1);
       // //("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    void Setup_Memory_Map(void)
    {
      //  GEL_MapOn( );
      //  GEL_MapReset( );
    
        /* ARM */
    
    }
    
    Set_Core_456MHz() {
        device_PLL0(0,18,0,0,1,11,5);
        //("\tPLL0 init done for Core:456MHz, EMIFA:38MHz\n","Output",1,1,1);
    }
    Set_Core_300MHz() {
        device_PLL0(0,24,1,0,1,11,5);
        //("\tPLL0 init done for Core:300MHz, EMIFA:25MHz\n","Output",1,1,1);
    }
    Set_Core_200MHz() {
        device_PLL0(0,24,2,0,1,7,3);
        //("\tPLL0 init done for Core:200MHz, EMIFA:25MHz\n","Output",1,1,1);
    }
    Set_Core_100MHz() {
        device_PLL0(0,24,5,0,1,3,1);
        //("\tPLL0 init done for Core:100MHz, EMIFA:25MHz\n","Output",1,1,1);
    }
    
    Set_DDRPLL_150MHz() {
        device_PLL1(24,1,0,1,2);
        //("\tPLL1 init done for DDR:150MHz\n","Output",1,1,1);
    }
    Set_DDRPLL_132MHz() {
        device_PLL1(21,1,0,1,2);
        //("\tPLL1 init done for DDR:132MHz\n","Output",1,1,1);
    }
    Set_DDRPLL_126MHz() {
        device_PLL1(20,1,0,1,2);
        //("\tPLL1 init done for DDR:126MHz\n","Output",1,1,1);
    }
    Set_DDRPLL_102MHz() {
        device_PLL1(16,1,0,1,2);
        //("\tPLL1 init done for DDR:102MHz\n","Output",1,1,1);
    }
    
    Set_DDR2_150MHz() {
        //("\tDDR initialization is in progress....\n","Output",1,1,1);
        Set_DDRPLL_150MHz();
        DEVICE_DDRConfig(DDR2, 150);
        //("\tDDR2 init for 150 MHz is done\n","Output",1,1,1);
    }
    
    Set_DDR2_132MHz() {
    
        Set_DDRPLL_132MHz();
        DEVICE_DDRConfig(DDR2, 132);
    
    }
    
    Set_DDR2_126MHz() {
    
        Set_DDRPLL_126MHz();
        DEVICE_DDRConfig(DDR2, 126);
    
    }
    
    Set_DDR2_102MHz() {
    
        Set_DDRPLL_102MHz();
        DEVICE_DDRConfig(DDR2, 102);
    }
    
    
    
    //menuitem "Frequency Settings"
    void Core_456MHz_mDDR_150MHz() {
        Set_Core_456MHz();
        Set_DDR2_150MHz();
        //("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    void Core_300MHz_mDDR_150MHz() {
        Set_Core_300MHz();
        Set_DDR2_150MHz();
        //("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    void Core_300MHz_mDDR_132MHz() {
        Set_Core_300MHz();
        Set_DDR2_132MHz();
        //("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    void Core_300MHz_mDDR_126MHz() {
        Set_Core_300MHz();
        Set_DDR2_126MHz();
        //("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    void Core_300MHz_mDDR_102MHz() {
        Set_Core_300MHz();
        Set_DDR2_102MHz();
        //("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    void Core_200MHz_mDDR_126MHz() {
        Set_Core_200MHz();
        Set_DDR2_126MHz();
        //("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    void Core_100MHz_mDDR_102MHz() {
        Set_Core_100MHz();
        Set_DDR2_102MHz();
        //("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    //menuitem "Board Settings"
    
    void PSC_All_On() {
        // PSC0
        PSC0_LPSC_enable(0, LPSC_EDMA_CC0);
        PSC0_LPSC_enable(0, LPSC_EDMA_TC0);
        PSC0_LPSC_enable(0, LPSC_EDMA_TC1);
        PSC0_LPSC_enable(0, LPSC_EMIFA);
        PSC0_LPSC_enable(0, LPSC_SPI0);
        PSC0_LPSC_enable(0, LPSC_MMCSD0);
        PSC0_LPSC_enable(0, LPSC_ARM_AINTC);
        PSC0_LPSC_enable(0, LPSC_ARM_RAMROM);
        PSC0_LPSC_enable(0, LPSC_UART0);
        PSC0_LPSC_enable(0, LPSC_SCR0);
        PSC0_LPSC_enable(0, LPSC_SCR1);
        PSC0_LPSC_enable(0, LPSC_SCR2);
    
        // PSC1
        PSC1_LPSC_enable(0, LPSC_EDMA_CC1);
        PSC1_LPSC_enable(0, LPSC_USB20);
        PSC1_LPSC_enable(0, LPSC_USB11);
        CFGCHIP2 = 0x09F2;  //Enable USB clock, PHY_PLLON, glue logic mux(USB2 ref clk input)
        PSC1_LPSC_enable(0, LPSC_GPIO);
        PSC1_LPSC_enable(0, LPSC_UHPI);
        PSC1_LPSC_enable(0, LPSC_EMAC);
        PSC1_LPSC_enable(0, LPSC_MCASP0);
        PSC1_LPSC_force(LPSC_SATA);
        PSC1_LPSC_enable(0, LPSC_SATA);
        PSC1_LPSC_enable(0, LPSC_VPIF);
        PSC1_LPSC_enable(0, LPSC_SPI1);
        PSC1_LPSC_enable(0, LPSC_I2C1);
        PSC1_LPSC_enable(0, LPSC_UART1);
        PSC1_LPSC_enable(0, LPSC_UART2);
        PSC1_LPSC_enable(0, LPSC_MCBSP0);
        PSC1_LPSC_enable(0, LPSC_MCBSP1);
        PSC1_LPSC_enable(0, LPSC_LCDC);
        PSC1_LPSC_enable(0, LPSC_EPWM);
        PSC1_LPSC_enable(0, LPSC_MMCSD1);
        PSC1_LPSC_enable(0, LPSC_UPP);
        PSC1_LPSC_enable(0, LPSC_ECAP);
        PSC1_LPSC_enable(0, LPSC_EDMA_TC2);
        PSC1_LPSC_enable(0, LPSC_SCR_F0);
        PSC1_LPSC_enable(0, LPSC_SCR_F1);
        PSC1_LPSC_enable(0, LPSC_SCR_F2);
        PSC1_LPSC_enable(0, LPSC_SCR_F6);
        PSC1_LPSC_enable(0, LPSC_SCR_F7);
        PSC1_LPSC_enable(0, LPSC_SCR_F8);
        PSC1_LPSC_enable(0, LPSC_BR_F7);
        PSC1_LPSC_enable(0, LPSC_SHARED_RAM);
    
        //("\tPSC Enable Complete.\n","Output",1,1,1);
        //("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    void EMIFA_NAND_PINMUX() {
        PSC0_LPSC_enable(0, LPSC_EMIFA);
        PINMUX7        = (PINMUX7 & ~0x00FF0FF0) | 0x00110110;
        PINMUX8        = 0x11111111;
        PINMUX9        = 0x11111111;
        PINMUX12       = (PINMUX12 & ~0x0FF00000) | 0x01100000;
        EMIFA_ACFG3   |= 0x1;
        EMIFA_NANDFCR  = (EMIFA_NANDFCR & ~0x30) | 0x12;
    
        //("\tEMIFA Pins Configured for NAND.\n","Output",1,1,1);
        //("\t---------------------------------------------\n","Output",1,1,1);
    }
    
    /**************************************************************************************************************************************************
       Device_PLL0 init:
    
       CLKMODE -  0---->On Chip Oscilator  1---->External Oscilator
       PLL0_SYSCLK1 - Fixed ratio /1
       PLL0_SYSCLK2 - Fixed ratio /2
       PLL0_SYSCLK3 - Variable Divider (EMIFA)
       PLL0_SYSCLK4 - Fixed ratio /4
       PLL0_SYSCLK5 - Not used -- do nothing
       PLL0_SYSCLK6 - Fixed ratio /1
       PLL0_SYSCLK7 - Variable Divider (RMII)
    ******************************************************************************************************************************************************/
    void device_PLL0(unsigned int CLKMODE, unsigned int PLLM, unsigned int POSTDIV,unsigned int PLLDIV1, unsigned int PLLDIV2, unsigned int PLLDIV3, unsigned int PLLDIV7 )
    {
    
        unsigned int i=0;
    
        /* Clear PLL lock bit */
        CFGCHIP0 &= ~(0x00000010);
    
        /* Set PLLENSRC '0',bit 5, PLL Enable(PLLEN) selection is controlled through MMR */
        PLL0_PLLCTL &= ~(0x00000020);
    
        /* PLLCTL.EXTCLKSRC bit 9 should be left at 0 for Freon */
        PLL0_PLLCTL &= ~(0x00000200);
    
        /* Set PLLEN=0 to put in bypass mode*/
        PLL0_PLLCTL &= ~(0x00000001);
    
        /*wait for 4 cycles to allow PLLEN mux switches properly to bypass clock*/
        for(i=0; i<PLLEN_MUX_SWITCH; i++) {;}
    
        /* Select the Clock Mode bit 8 as External Clock or On Chip Oscilator*/
        PLL0_PLLCTL &= 0xFFFFFEFF;
        PLL0_PLLCTL |= (CLKMODE << 8);
    
        /*Clear PLLRST bit to reset the PLL */
        PLL0_PLLCTL &= ~(0x00000008);
    
        /* Disable the PLL output*/
        PLL0_PLLCTL |= (0x00000010);
    
        /* PLL initialization sequence
        Power up the PLL by setting PWRDN bit set to 0 */
        PLL0_PLLCTL &= ~(0x00000002);
    
        /* Enable the PLL output*/
        PLL0_PLLCTL &= ~(0x00000010);
    
        /*PLL stabilisation time- take out this step , not required here when PLL in bypassmode*/
        for(i=0; i<PLL_STABILIZATION_TIME; i++) {;}
    
        /*Program the required multiplier value in PLLM*/
        PLL0_PLLM    = PLLM;
    
        /*If desired to scale all the SYSCLK frequencies of a given PLLC, program the POSTDIV ratio*/
        PLL0_POSTDIV = 0x8000 | POSTDIV;
    
        /*Check for the GOSTAT bit in PLLSTAT to clear to 0 to indicate that no GO operation is currently in progress*/
        while(PLL0_PLLSTAT & 0x1==1){}
    
        /*Program the RATIO field in PLLDIVx with the desired divide factors. In addition, make sure in this step you leave the PLLDIVx.DxEN bits set so clocks are still enabled (default).*/
        PLL0_PLLDIV1 = 0x8000 | PLLDIV1;             // Fixed Ratio /1
        PLL0_PLLDIV2 = 0x8000 | PLLDIV2;             // Fixed Ratio /2
        PLL0_PLLDIV4 = 0x8000 | (((PLLDIV1+1)*4)-1); // Fixed Ratio /4
        PLL0_PLLDIV6 = 0x8000 | PLLDIV1;             // Fixed Ratio /1
        PLL0_PLLDIV3 = 0x8000 | PLLDIV3;             // Variable Ratio (EMIF)
        PLL0_PLLDIV7 = 0x8000 | PLLDIV7;             // Variable Ratio (RMII)
    
    
        /*Set the GOSET bit in PLLCMD to 1 to initiate a new divider transition.*/
        PLL0_PLLCMD |= 0x1;
    
        /*Wait for the GOSTAT bit in PLLSTAT to clear to 0 (completion of phase alignment).*/
        while(PLL0_PLLSTAT & 0x1==1) { }
    
        /*Wait for PLL to reset properly.*/
        for(i=0; i<PLL_RESET_TIME_CNT; i++) {;}
    
        /*Set the PLLRST bit in PLLCTL to 1 to bring the PLL out of reset*/
        PLL0_PLLCTL |= 0x8;
    
        /*Wait for PLL to lock.*/
        for(i=0; i<PLL_LOCK_TIME_CNT; i++) {;}
    
        /*Set the PLLEN bit in PLLCTL to 1 to remove the PLL from bypass mode*/
        PLL0_PLLCTL |=  0x1;
    }
    
    
    /**********************************************************************************
    DDR PLL1 init:
    
    ***********************************************************************************/
    
    device_PLL1(unsigned int PLLM,unsigned int POSTDIV,unsigned int PLLDIV1, unsigned int PLLDIV2, unsigned int PLLDIV3 ) {
    
        unsigned int i=0;
    
        /* Clear PLL lock bit */
        CFGCHIP3 &= ~(0x00000020);
    
        /* Set PLLENSRC '0',bit 5, PLL Enable(PLLEN) selection is controlled through MMR */
        PLL1_PLLCTL &= ~(0x00000020);
    
        /* PLLCTL.EXTCLKSRC bit 9 should be left at 0 for Freon */
        PLL1_PLLCTL &= ~(0x00000200);
    
        /* Set PLLEN=0 to put in bypass mode*/
        PLL1_PLLCTL &= ~(0x00000001);
    
        /*wait for 4 cycles to allow PLLEN mux switches properly to bypass clock*/
        for(i=0; i<PLLEN_MUX_SWITCH; i++) {;}
    
        /*Clear PLLRST bit to reset the PLL */
        PLL1_PLLCTL &= ~(0x00000008);
    
        /* Disable the PLL output*/
        PLL1_PLLCTL |= (0x00000010);
    
        /* PLL initialization sequence
        Power up the PLL by setting PWRDN bit set to 0 */
        PLL1_PLLCTL &= ~(0x00000002);
    
        /* Enable the PLL output*/
        PLL1_PLLCTL &= ~(0x00000010);
    
        /*PLL stabilisation time- take out this step , not required here when PLL in bypassmode*/
        for(i=0; i<PLL_STABILIZATION_TIME; i++) {;}
    
        /*Program the required multiplier value in PLLM*/
        PLL1_PLLM    = PLLM;
    
        /*If desired to scale all the SYSCLK frequencies of a given PLLC, program the POSTDIV ratio*/
        PLL1_POSTDIV = 0x8000 | POSTDIV;
    
        /*Check for the GOSTAT bit in PLLSTAT to clear to 0 to indicate that no GO operation is currently in progress*/
        while(PLL1_PLLSTAT & 0x1==1){}
    
        /*Program the RATIO field in PLLDIVx with the desired divide factors. In addition, make sure in this step you leave the PLLDIVx.DxEN bits set so clocks are still enabled (default).*/
        PLL1_PLLDIV1 = 0x8000 | PLLDIV1;   // DDR frequency (aka 2X_CLK)
        PLL1_PLLDIV2 = 0x8000 | PLLDIV2;   // Optional CFGCHIP3[ASYNC3_CLKSRC] clock source
        PLL1_PLLDIV3 = 0x8000 | PLLDIV3;   // Optional PLL0 clock source
    
        /*Set the GOSET bit in PLLCMD to 1 to initiate a new divider transition.*/
        PLL1_PLLCMD |= 0x1;
    
        /*Wait for the GOSTAT bit in PLLSTAT to clear to 0 (completion of phase alignment).*/
        while(PLL1_PLLSTAT & 0x1==1) { }
    
        /*Wait for PLL to reset properly */
        for(i=0; i<PLL_RESET_TIME_CNT; i++) {;}
    
        /*Set the PLLRST bit in PLLCTL to 1 to bring the PLL out of reset*/
        PLL1_PLLCTL |= 0x8;
    
        /*Wait for PLL to lock. See PLL spec for PLL lock time*/
        for(i=0; i<PLL_LOCK_TIME_CNT; i++) {;}
    
        /*Set the PLLEN bit in PLLCTL to 1 to remove the PLL from bypass mode*/
        PLL1_PLLCTL |=  0x1;
    }
    
    /**********************************************************************************
    Device Kick Unlock:
        Kick0 register + data (unlock)
        Kick1 register + data (unlock)
    ***********************************************************************************/
    DEVICE_kickUnlock() {
        KICK0R = 0x83e70b13;  // Kick0 register + data (unlock)
        KICK1R = 0x95a4f1e0;  // Kick1 register + data (unlock)
        //("\tKICK Unlocked.\n","Output",1,1,1);
        //("\t---------------------------------------------\n","Output",1,1,1);
     }
    
    
    /**********************************************************************************
      PSC Common functions :
    
    ***********************************************************************************/
    /*Force module state without handshaking */
    PSC1_LPSC_force(unsigned int LPSC_num) {
        *(unsigned int*) (PSC1_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC1_MDCTL+4*LPSC_num) | 0x80000000);
    }
    
    /*SyncReset Function for PSC1*/
    PSC1_LPSC_SyncReset(unsigned int PD, unsigned int LPSC_num) {
        unsigned int j;
    
        if( (*(unsigned int*)(PSC1_MDSTAT+4 * LPSC_num) & 0x1F) != 0x1 ) {
          *(unsigned int*) (PSC1_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC1_MDCTL+4*LPSC_num) & 0xFFFFFFE0) | 0x0001;
          PSC1_PTCMD = 0x1<<PD;
    
          j = 0;
          /*Wait for power state transition to finish*/
          while( (PSC1_PTSTAT & (0x1<<PD) ) !=0) {
            if( j++ > PSC_TIMEOUT ) {
              //("\tPSC1 Sync Reset Transition Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);
              break;
            }
          }
    
          j = 0;
          while( (*(unsigned int*)(PSC1_MDSTAT+4 * LPSC_num) & 0x1F) !=0x1) {
            if( j++ > PSC_TIMEOUT ) {
              //("\tPSC1 Sync Reset Verify Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);
              break;
            }
          }
        }
    }
    
    /*Enable Function for PSC1*/
    PSC1_LPSC_enable(unsigned int PD, unsigned int LPSC_num) {
        unsigned int j;
    
        if( (*(unsigned int*)(PSC1_MDSTAT+4 * LPSC_num) & 0x1F) != 0x3 ) {
          *(unsigned int*) (PSC1_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC1_MDCTL+4*LPSC_num) & 0xFFFFFFE0) | 0x0003;
          PSC1_PTCMD = 0x1<<PD;
    
          j = 0;
          /*Wait for power state transition to finish*/
          while( (PSC1_PTSTAT & (0x1<<PD) ) !=0) {
            if( j++ > PSC_TIMEOUT ) {
              //("\tPSC1 Enable Transition Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);
              break;
            }
          }
    
          j = 0;
          while( (*(unsigned int*)(PSC1_MDSTAT+4 * LPSC_num) & 0x1F) !=0x3) {
            if( j++ > PSC_TIMEOUT ) {
              //("\tPSC1 Enable Verify Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);
              break;
            }
          }
        }
    }
    
    /*LPSC Enable Function for ARM or DSP*/
    PSC0_LPSC_enableCore(unsigned int PD, unsigned int LPSC_num) {
        unsigned int j;
    
        if( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x11F) != 0x103 ) {
          *(unsigned int*) (PSC0_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC0_MDCTL+4*LPSC_num) & 0xFFFFFEE0) | 0x0103;
          PSC0_PTCMD = 0x1<<PD;
    
          j = 0;
          /*Wait for power state transition to finish*/
          while( (PSC0_PTSTAT & (0x1<<PD) ) !=0) {
            if( j++ > PSC_TIMEOUT ) {
              //("\tPSC0 Enable Core Transition Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);
              break;
            }
          }
    
          j = 0;
          while( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x11F) !=0x103) {
            if( j++ > PSC_TIMEOUT ) {
              //("\tPSC0 Enable Core Verify Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);
              break;
            }
          }
        }
    }
    
    /*SyncReset Function for PSC0*/
    PSC0_LPSC_SyncReset(unsigned int PD, unsigned int LPSC_num) {
        unsigned int j;
    
        if( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x1F) != 0x1 ) {
          *(unsigned int*) (PSC0_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC0_MDCTL+4*LPSC_num) & 0xFFFFFFE0) | 0x0001;
          PSC0_PTCMD = 0x1<<PD;
    
          j = 0;
          /*Wait for power state transition to finish*/
          while( (PSC0_PTSTAT & (0x1<<PD) ) !=0) {
            if( j++ > PSC_TIMEOUT ) {
              //("\tPSC0 Sync Reset Transition Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);
              break;
            }
          }
    
          j = 0;
          while( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x1F) !=0x1) {
            if( j++ > PSC_TIMEOUT ) {
              //("\tPSC0 Sync Reset Verify Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);
              break;
            }
          }
        }
    }
    
    /*Enable Function for PSC0*/
    PSC0_LPSC_enable(unsigned int PD, unsigned int LPSC_num) {
        unsigned int j;
    
        if( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x1F) != 0x3 ) {
          *(unsigned int*) (PSC0_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC0_MDCTL+4*LPSC_num) & 0xFFFFFFE0) | 0x0003;
          PSC0_PTCMD = 0x1<<PD;
    
          j = 0;
          /*Wait for power state transition to finish*/
          while( (PSC0_PTSTAT & (0x1<<PD) ) !=0) {
            if( j++ > PSC_TIMEOUT ) {
              //("\tPSC0 Enable Transition Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);
              break;
            }
          }
    
          j = 0;
          while( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x1F) !=0x3) {
            if( j++ > PSC_TIMEOUT ) {
              //("\tPSC0 Enable Verify Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);
              break;
            }
          }
        }
    }
    
    
    /**********************************************************************************
      DDR Configuration routine:
        1. DDR Enable
        2. VTP calibration
        3. Configure DDR
        4. Set to self-refresh, enable mclkstop and DDR Sync Reset
        5. Enable DDR and disable self-refresh
    
      int freq is MHz
    
      DDR2 = 0
      MDDR = 1
    
      A DDR configuration spreadsheet tool is located here:
        http://processors.wiki.ti.com/index.php/Programming_mDDR/DDR2_EMIF_on_OMAP-L1x/C674x
    
    ***********************************************************************************/
    
    DEVICE_DDRConfig(unsigned int ddr_type, unsigned int freq)
    {
        unsigned int j;
        unsigned int tmp_SDCR;
    
        // Enable the Clock to EMIFDDR SDRAM
        PSC1_LPSC_enable(PD0, LPSC_DDR);
    
        // Begin VTP Calibration
        VTPIO_CTL &= ~0x00000040;       // Clear POWERDN
        VTPIO_CTL &= ~0x00000080;       // Clear LOCK
        VTPIO_CTL |=  0x00002000;       // Set CLKRZ in case it was cleared before (VTP looks for CLKRZ edge transition)
        VTPIO_CTL &= ~0x00002000;       // Clear CLKRZ (Use read-modify-write to ensure 1 VTP cycle wait for previous instruction)
        VTPIO_CTL |=  0x00002000;       // Set CLKRZ (Use read-modify-write to ensure 1 VTP cycle wait for previous instruction)
    
        j = 0;
        // Polling READY bit to see when VTP calibration is done
        while((VTPIO_CTL & 0x00008000) == 0) {
          if( j++ > VTP_TIMEOUT ) {
            //("\tVTP Ready timeout\n","Output",1,1,1);
            break;
          }
        }
    
        VTPIO_CTL |= 0x00000080;       // Set LOCK bit for static calibration mode
        VTPIO_CTL |= 0x00000040;       // Set POWERDN bit to power down VTP module
        // End VTP Calibration
    
        VTPIO_CTL |= 0x00004000;       // Set IOPWRDN to allow powerdown of input receivers when PWRDNEN is set
    
        // **********************************************************************************************
        // Setting based 1Gb DDR2 Samsung K4T1G164QF-BCF8
        // Config DDR timings
        DRPYC1R     = (0x0               << 8)   |  // Reserved
                      (0x1               << 7)   |  // EXT_STRBEN
                      (0x1               << 6)   |  // PWRDNEN
                      (0x0               << 3)   |  // Reserved
                      (0x4               << 0);     // RL
        // DRPYC1R Value = 0x000000C4
    
        if( DDR_DEBUG ) {
          // Configure EMIF with max timings for more slack
          // Try this if memory is not stable
          DRPYC1R  |=  0x7; // RL
        }
    
        EMIFDDR_SDCR |= 0x00800000; // Set BOOTUNLOCK
    
        // Settings depending on DDR2
          tmp_SDCR = (0x0               << 25)  |  // MSDRAMEN
                     (0x1               << 20);    // DDR2EN
          //("\tUsing DDR2 settings\n","Output",1,1,1);
    
    
        EMIFDDR_SDCR = tmp_SDCR                    |  // Settings that change depending on DDR2 or MDDR
                       (EMIFDDR_SDCR & 0xF0000000) |  // Reserved
                       (0x0               << 27)   |  // DDR2TERM1
                       (0x0               << 26)   |  // IBANK_POS
                       (0x0               << 24)   |  // DDRDRIVE1
                       (0x0               << 23)   |  // BOOTUNLOCK
                       (0x0               << 22)   |  // DDR2DDQS
                       (0x0               << 21)   |  // DDR2TERM0
                       (0x0               << 19)   |  // DDRDLL_DIS
                       (0x0               << 18)   |  // DDRDRIVE0
                       (0x1               << 17)   |  // DDREN
                       (0x1               << 16)   |  // SDRAMEN
                       (0x1               << 15)   |  // TIMUNLOCK
                       (0x1               << 14)   |  // NM
                       (0x0               << 12)   |  // Reserved
                       (0x4               << 9)    |  // CL
                       (0x0               << 7)    |  // Reserved
                       (0x3               << 4)    |  // IBANK
                       (0x0               << 3)    |  // Reserved
                       (0x2               << 0);      // PAGESIZE
    
        EMIFDDR_SDCR2   = 0x00000000; // IBANK_POS set to 0 so this register does not apply
    
        if( DDR_DEBUG ) {
          // Configure EMIF with max timings for more slack
          // Try this if memory is not stable
    
          EMIFDDR_SDTIMR1 = (0x7F << 25)             |  // tRFC
                            (0x07 << 22)             |  // tRP
                            (0x07 << 19)             |  // tRCD
                            (0x07 << 16)             |  // tWR
                            (0x1F << 11)             |  // tRAS
                            (0x1F << 6)              |  // tRC
                            (0x07 << 3)              |  // tRRD
                            (EMIFDDR_SDTIMR1 & 0x4)  |  // Reserved
                            (0x03 << 0);                // tWTR
    
          EMIFDDR_SDTIMR2 = (EMIFDDR_SDTIMR2 & 0x80000000)                       |  // Reserved
                            (((unsigned int) ((70000 / 3400) - 0.5))  << 27)   |  // tRASMAX (original 7812.5)
                            (0x3                                        << 25)   |  // tXP
                            (0x0                                        << 23)   |  // tODT (Not supported)
                            (0x7F                                       << 16)   |  // tXSNR
                            (0xFF                                       << 8)    |  // tXSRD
                            (0x07                                       << 5)    |  // tRTP (1 Cycle)
                            (0x1F                                       << 0);      // tCKE
    
    
          //("\tDDR Timings Configured for Debug\n","Output",1,1,1);
        }
        else {
          // Let float -> integer truncate handle minus 1; Safer to round up for timings
          EMIFDDR_SDTIMR1 = (((unsigned int) (127.5 * freq / 1000))  << 25)  |  // tRFC
                            (((unsigned int) (13.13 * freq / 1000))  << 22)  |  // tRP
                            (((unsigned int) (13.13 * freq / 1000))  << 19)  |  // tRCD
                            (((unsigned int) ( 15.0 * freq / 1000))  << 16)  |  // tWR
                            (((unsigned int) ( 45.0 * freq / 1000))  << 11)  |  // tRAS
                            (((unsigned int) (58.13 * freq / 1000))  << 6)   |  // tRC
                            (((unsigned int) (  7.5 * freq / 1000))  << 3)   |  // tRRD
                            (EMIFDDR_SDTIMR1 & 0x4)                          |  // Reserved
                            ((2 - 1)                                 << 0);     // tWTR
    
          EMIFDDR_SDTIMR2 = (EMIFDDR_SDTIMR2 & 0x80000000)                    |  // Reserved
                            (((unsigned int) ((70000 / 7800) - 1))   << 27)   |  // tRASMAX (original 3400)
                            ((0x3-1)                                 << 25)   |  // tXP (Should be 6-1 per MT46H64M16LFBF-6 datasheet, but field only goes up to 0b11)
                            (0x0                                     << 23)   |  // tODT (Not supported)
                            (((unsigned int) (137.5 * freq / 1000))  << 16)   |  // tXSNR (tXSR for mDDR)
                            ((200-1)                                 << 8)    |  // tXSRD (tXSR for mDDR)
                            ((2 - 1)                                 << 5)    |  // tRTP
                            ((3 - 1)                                 << 0);      // tCKE
           }
    
        EMIFDDR_SDCR    &= ~0x00008000; // Clear TIMUNLOCK
    
        // Let float -> integer truncate handle RR round-down; Safer to round down for refresh rate
        EMIFDDR_SDRCR   = (0x1                                  << 31)  |  // LPMODEN (Required for LPSC SyncReset/Enable)
                          (0x1                                  << 30)  |  // MCLKSTOPEN (Required for LPSC SyncReset/Enable)
                          (0x0                                  << 24)  |  // Reserved
                          (0x0                                  << 23)  |  // SR_PD
                          (0x0                                  << 16)  |  // Reserved
                          (((unsigned int) (7.8 * freq))        << 0);     // RR  (original 7.8125)
    
        // SyncReset the Clock to EMIFDDR SDRAM
        PSC1_LPSC_SyncReset(PD0, LPSC_DDR);
    
        // Enable the Clock to EMIFDDR SDRAM
        PSC1_LPSC_enable(PD0, LPSC_DDR);
    
        // Disable self-refresh
        EMIFDDR_SDRCR &= ~0xC0000000;
    
        // Set PBBPR to a value lower than default to prevent blocking
        EMIFDDR_PBBPR = 0x30;
    }
    
    
    
    
    AquacommMini Ver1LinkMap.txtHi Titus

    I built and ran my app.out through aisGen and the sfh and flashed board. However the app didn't boot. The app is RTOS based. I tested in ccs debug and it works. Are there additional things I have to do in the boardInit() function (made from GEL file) to get the RTOS based app to boot properly?

    Attached is the boardInit() and the map file. Everything runs in L2 ram. We are not using ddr.

    Thanks

    Manjula

  • Dear Manjula,
    You no need to add any board related init files like gel since we are using AISgen conversed code.
    Please refer to the following wiki page which would flash and boot the RTOS based "face detect code"
    processors.wiki.ti.com/.../BIOS_C6SDK_2.0_User_Guide

    Can you please send me (x0213399@ti.com) your project and will try to reproduce.
  • Hi Titus

    I have read that before. It doesn't say anything about special inits for RTOS/Bios apps. Are there any compile or link switches that need to be set to make the app boot-able? That is something extra that is aded to the .cinit_00 before main() is called?
    I have included everything in the boadInit.c as that in the GEL file. Have you had a look at this?
    I am able to flash the my_uartEcho which is non bios.

    There must be something on the TI website that talks about making RTOS/BIOS bootable surely!!!

    Thanks

    Manjula
  • Dear Manjula,
    You have provided, just gel file copy.
    You can directly flash and boot the application (RTOS) , why do use boardinit.c file etc., ?

    Still if you are not interested to share the code with us, my suggestion would be you can fine tune your AISgen tool settings.
    You no need to worry about PLL1 & PLL0 settings since I have shared in last *.cfg, so you can use that *.cfg & try to add some all PSC .
  • Hi Titus

    I cannot provide our project files as they are confidential IP. However I will build the serialEcho app under RTOS similar to the app and try flashing it to see if it runs.

    To answer your questions:

    The boardInit.c file is a c file that I made from the gel file. The idea is that after entry into main() then I call this function first to set up everything that the GEL file would do in a debug session. Is this correct?

    I am trying to directly flash and boot my RTOS application and it is not booting! Hence my question is are there compile/link switches required during the build process to make the app bootable? Please answer this question.

    I used the titusxx.cfg file with the AISgen app when generating the AIS file for the RTOS app. The titusxxx.cfg file worked for the serialEcho non rtos app that I created and I could boot this. Hence my questions as to if extra things need to be done to the RTOS app to make it boot-able compared with the non RTOS app?

    So can you exactly clarify the following questions:

    1. If my RTOS app runs in code composer studio debug without a problem then all I have to do is use AISgen loaded with the correct .cfg file to create the app.ais which I can burn on the flash and the app should boot from flash without a problem?

    2. If the SerialEcho (non rtos) is able to be successfully booted after generating with the titusxxx.cfg then why wouldn't the RTOS app work when I generate with the exact same .cfg and AISGen? The RTOS app runs entirely in L2 ram. So it is exactly the same as the serialEcho in that sense but a larger image.

    3. The peripherals I use are individually set up correctly when they are being initialized from main(). Which means I only need the .cfg that is loaded into AISgen to set up clocks and some PSC modules for the device to boot and enter into main()? IS this correct?

    Titus please answer each of my questions one by one. It is difficult when you point me to something else and I end up going in circles though we made progress today. I need answers to these questions so that I can create a map and narrow down what is going on through a process of elimination without running around like a headless chook (chicken).

    Thanks and regards

    Manjula

  • Hi Titus

    Can I have the answers to the questions in my earlier post please? Time is running out for us!
    Let me know if you are tired of this and I will re-post so someone else can pick up.

    Thanks

    Manjula
  • Dear Manjula,

    The boardInit.c file is a c file that I made from the gel file. The idea is that after entry into main() then I call this function first to set up everything that the GEL file would do in a debug session. Is this correct?

    In my opinion, no need to use gel stuff here, we can use AISGen tool to do those things.


    I am trying to directly flash and boot my RTOS application and it is not booting! Hence my question is are there compile/link switches required during the build process to make the app bootable? Please answer this question.

    No.


    I used the titusxx.cfg file with the AISgen app when generating the AIS file for the RTOS app. The titusxxx.cfg file worked for the serialEcho non rtos app that I created and I could boot this. Hence my questions as to if extra things need to be done to the RTOS app to make it boot-able compared with the non RTOS app?

    I think, not required. I will try to some RTOS app and confirm today.


    1. If my RTOS app runs in code composer studio debug without a problem then all I have to do is use AISgen loaded with the correct .cfg file to create the app.ais which I can burn on the flash and the app should boot from flash without a problem?

    2. If the SerialEcho (non rtos) is able to be successfully booted after generating with the titusxxx.cfg then why wouldn't the RTOS app work when I generate with the exact same .cfg and AISGen? The RTOS app runs entirely in L2 ram. So it is exactly the same as the serialEcho in that sense but a larger image.


    Yes, it should boot.
    Also it depends on your project, that's why I requested, because your code might get executed and stuck some where due to some other code in your project.
    So I would like you to suggest to add some LED stuff to confirm that your code got executed.


    3. The peripherals I use are individually set up correctly when they are being initialized from main(). Which means I only need the .cfg that is loaded into AISgen to set up clocks and some PSC modules for the device to boot and enter into main()? IS this correct?

    Yes correct, please refer the above answer.

    Please let me know if any questions.
    Will try some RTOS LED app and let you know the results.
  • Hi Titus

    Thanks a lot for the answers! Glad you haven't given up on me :}

    I will create and RTOS based SerialEcho app based off the non-rtos SerialEcho and see if it works and will let you know the results. I will also await results from your RTOS tests.

    Best regards

    Manjula
  • Hi Titus

    I have just sent you an email with the uartEchoRTOS version. I built this and flashed without booting success. This runs in CCS debug ok.
    Can you please try this your end let me know if you can get it working.

    Thanks

    Manjula
  • Dear Manjula,

    I'm also not able to boot new RTOS (tirtos_c6000_2_00_01_23) based application but I'm able to boot SYS/BIOS based application

    What is your SYS/BIOS version in your actual project ?

    This is DSP gpio application for C6748/OMAPL138 processors.

    I have converted this app to AIS and able to boot this application.

    C:\ti\pdk_OMAPL138_1_01_00_02\packages\ti\csl\exampleProjects\gpio_exampleProject

    gpio.ais

    You can also try this app and test it on your board.

    Also I have changed the actual code (attached below) for LED blinking.

    Gpio_example.c
    /*
     * Gpio_example.c
     *
     * This file contains the test / demo code to demonstrate basic GPIO operations 
     * using the Regsiter CSL macros.
     *
     * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
     *
     *
     *  Redistribution and use in source and binary forms, with or without
     *  modification, are permitted provided that the following conditions
     *  are met:
     *
     *    Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     *    Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the
     *    distribution.
     *
     *    Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
    */
    
    /** ============================================================================
     *   @brief A simple example to demonstrate CSL GPIO register layer usage
         and interrupts in a BIOS application.
     *
     *   @file  Gpio_example.c
     *
     *   <b> Example Description </b>
     *   @verbatim
     *   This example demonstrates the use of GPIO module. The sample does
     *   this by configuring the GPIO pin GPIO0_7(configured as output pin) as
     *   an interrupt pin. Then it sets the status of the pin to high to
     *   trigger an interrupt which is then serviced by an ISR function.
     *   @endverbatim
     *
     *
     *   <b> Procedure to run the example </b>
     *   @verbatim
     *   1. Open Gpio_example.pjt in CCS
     *   2. Build the project
     *   3. Connect to target and load the gpio_example.out
     *   4. Run the program
     *   5. The messages will be printed on to the console as the interrupts are
     *      generated and ISR function is called.
     *   6. on successful completion "GPIO sample application completed" is
     *      logged to the console.
     *   @endverbatim
     *
     * ============================================================================
     **/
    
    /*============================================================================*/
    /*                              INLCUDE FILES                                 */
    /*============================================================================*/
    
    #include <stdio.h>
    #include <c6x.h>
    #include <ti/csl/cslr_dspintc.h>
    #include <ti/csl/soc_C6748.h>
    #include <ti/csl/cslr_gpio.h>
    #include <ti/csl/cslr_syscfg0_C6748.h>
    #include <ti/csl/cslr_psc_C6748.h>
    
    /*============================================================================*/
    /*                        EXTERNAL FUNCTION PROTOTYPES                        */
    /*============================================================================*/
    
    extern void _intcVectorTable(void);
    
    /*============================================================================*/
    /*                         LOCAL FUNCTION PROTOTYPES                          */
    /*============================================================================*/
    
    static void gpioPowerOn(void);
    static void GpioStartTest(void);
    static void delay(Uint32 count);
    
    volatile Bool intStatus = 0;
    static Uint8 count    = 0;
    
    
    /*============================================================================*/
    /*                             GLOBAL VARIABLES                               */
    /*============================================================================*/
    
    /* sys config registers overlay                                               */
    CSL_SyscfgRegsOvly   sysRegs  = (CSL_SyscfgRegsOvly)(CSL_SYSCFG_0_REGS);
    /* Psc register overlay                                                       */
    CSL_PscRegsOvly      psc1Regs = (CSL_PscRegsOvly)(CSL_PSC_1_REGS);
    /* Gpio register overlay                                                      */
    CSL_GpioRegsOvly     gpioRegs = (CSL_GpioRegsOvly)(CSL_GPIO_0_REGS);
    /* Interrupt Controller Register Overlay                                      */
    CSL_DspintcRegsOvly intcRegs = (CSL_DspintcRegsOvly)CSL_INTC_0_REGS;
    /*============================================================================*/
    /*                             MACRO DEFINITIONS                              */
    /*============================================================================*/
    
    
    #define INT_GENERATED_FALSE 0x00
    #define INT_GENERATED_TRUE  0x01
    
    /*============================================================================*/
    /*                          FUNCTION DEFINITIONS                              */
    /*============================================================================*/
    
    void main (void)
    {
        /* This function will configure an GPIO pin as an interrupt pin           */
    
        /* Key to be written to enable the pin mux registers for write            */
        sysRegs->KICK0R = 0x83e70b13;
        sysRegs->KICK1R = 0x95A4F1E0;
    
        /* enable the pinmux for the GPIO bank 0 pin 7                            */
    //    sysRegs->PINMUX1 = ((CSL_SYSCFG_PINMUX1_PINMUX1_3_0_GPIO0_7)
    //                        << (CSL_SYSCFG_PINMUX1_PINMUX1_3_0_SHIFT));
    
    
        // Enable the pinmux for the GPIO bank 0 pin 9 (tied to LED on LCDK)
            sysRegs->PINMUX0 = ((CSL_SYSCFG_PINMUX0_PINMUX0_27_24_GPIO0_9)
                                << (CSL_SYSCFG_PINMUX0_PINMUX0_27_24_SHIFT));
    
    
        /* lock the pinmux registers                                              */
        sysRegs->KICK0R = 0x00000000;
        sysRegs->KICK1R = 0x00000000;
    
        /* first enable the GPIO in the PSC                                       */
        gpioPowerOn();
    
    //Titus
        CSL_FINS(gpioRegs->BANK[0].DIR,GPIO_DIR_DIR9,0);
        while(1)
        {
    
    
    	    CSL_FINS(gpioRegs->BANK[0].OUT_DATA,GPIO_OUT_DATA_OUT9,1);
    										// LED_state is "0" - OFF, turn LED OFF via GPIO
    		delay(10000000);
    
    		CSL_FINS(gpioRegs->BANK[0].OUT_DATA,GPIO_OUT_DATA_OUT9,0);
    
    		delay(10000000);
    
        }
    
    
        /* Configure GPIO0_7 (GPIO0_7_PIN) as an output                           */
        CSL_FINS(gpioRegs->BANK[0].DIR,GPIO_DIR_DIR7,0);
    
        /* set the GIPO0_7 value to 0                                             */
        CSL_FINS(gpioRegs->BANK[0].OUT_DATA,GPIO_OUT_DATA_OUT7,0);
    
        /* Enable GPIO Bank interrupt for bank 0                                  */
        CSL_FINST(gpioRegs->BINTEN,GPIO_BINTEN_EN0,ENABLE);
    
        /* Configure GPIO(GPIO0_7_PIN) to generate interrupt on rising edge       */
        CSL_FINS(gpioRegs->BANK[0].SET_RIS_TRIG,
                 GPIO_SET_RIS_TRIG_SETRIS7,
                 CSL_GPIO_SET_RIS_TRIG_SETRIS_ENABLE);
    
        /* map GPIO0 event to cpu int4                                            */
        CSL_FINS(intcRegs->INTMUX1,
                 DSPINTC_INTMUX1_INTSEL4,
                 CSL_INTC_EVENTID_GPIO_BNK0_INT);
    
        /* set ISTP to point to the vector table address                          */
        ISTP = (unsigned int)_intcVectorTable;
    
        /* clear all interrupts, bits 4 thru 15                                   */
        ICR = 0xFFF0;
    
        /* enable the bits for non maskable interrupt and CPUINT4                 */
        IER = 0x12;
    
        /* enable interrupts, set GIE bit                                         */
        _enable_interrupts();
    
        /* set interrupt generated status to false                                */
        intStatus = INT_GENERATED_FALSE;
    
        GpioStartTest();
    }
    
    /*
     * \brief    Function to test the GPIO functionality.
     *
     *           Will generate a GPIO interrupt by writing to the GPIO outdata
     *           register
     *
     * \param    None
     * \return   None
     *
     */
    
    static void GpioStartTest(void)
    {
        printf("Starting the GPIO testing\n");
        /* This function will set a GPIO pin to 1 (which is configured earlier) so*
         * an interrupt handler registered previously for that event is invoked   */
        while (count <= 5)
        {
            /* set the Bank 0 pin 7 to 1 to generate an interrupt                 */
            CSL_FINS(gpioRegs->BANK[0].OUT_DATA,GPIO_OUT_DATA_OUT7,1);
    
            while (INT_GENERATED_TRUE != intStatus)
            {
                delay(1000);
            }
    
            printf("Interrupt generated by Gpio module, Int count %d \n",count);
            intStatus = INT_GENERATED_FALSE;
            count++;
        }
        printf("GPIO sample application completed\n");
    }
    
    /*
     * \brief    interrupt Handler routine for the GPIO interrupt
     *
     * \param    None
     * \return   None
     *
     */
    interrupt void gpioInputIsr(void)
    {
        /* The interrupt handler for the GPIO interrupts                          */
    
        /* the interrupt could have been because of any one of the pins in the    *
         * bank 0. Hence we will only check if the pin 7 is generating the        *
         * interrupt and then reset it and exit.                                  */
        if (gpioRegs->BANK[0].INTSTAT & CSL_GPIO_INTSTAT_STAT7_MASK)
        {
            /* reset the interrupt source (so that multiple interrupts dont ccur  */
            CSL_FINS(gpioRegs->BANK[0].OUT_DATA,GPIO_OUT_DATA_OUT7,0);
    
            /* reset the interrupt status register                                */
            CSL_FINS(gpioRegs->BANK[0].INTSTAT,GPIO_INTSTAT_STAT7,0);
    
            /* cannot print here hence set the status variable so that that task  *
             * can print the message                                              */
            intStatus = INT_GENERATED_TRUE;
        }
    }
    
    
    /*
     * \brief    Function to power on the GPIO module in the power sleep controller.
     *
     * \param    None
     * \return   None
     *
     *  Note: This function causes the program to abort in case it is unable to   *
     *        enable the GPIO module.
     */
    static void gpioPowerOn(void)
    {
        volatile Uint32 pscTimeoutCount = 10240u;
        Uint32          temp            = 0;
    
        /* we will now power on the GPIO module in the PSC.                       *
         * Configure the GPIO Module to Enable state                              */
        psc1Regs->MDCTL[CSL_PSC_GPIO] = ((psc1Regs->MDCTL[CSL_PSC_GPIO]
                                            & 0xFFFFFFE0)
                                         | CSL_PSC_MDSTAT_STATE_ENABLE);
    
        /* Kick start the Enable Command                                          */
        temp = psc1Regs->PTCMD;
        temp = ((temp & CSL_PSC_PTCMD_GO0_MASK)
                | (CSL_PSC_PTCMD_GO0_SET << CSL_PSC_PTCMD_GO0_SHIFT));
    
        psc1Regs->PTCMD |= temp;
    
        /* Wait for the power state transition to occur                           */
        while (((psc1Regs->PTSTAT & (CSL_PSC_PTSTAT_GOSTAT0_IN_TRANSITION)) != 0)
            && (pscTimeoutCount>0))
        {
            pscTimeoutCount--;
        }
    
        /* Check if PSC state transition timed out                                */
        if (0 == pscTimeoutCount)
        {
            printf("GPIO PSC transition to ON state timed out\n");
        }
        else
        {
            printf("Gpio enabled in PSC\n");
        }
    }
    
    
    /*
     * \brief    Function to introduce a delay in to the program.
     *
     * \param    count [IN]  delay count to wait
     * \return   None
     *
     */
    static void delay(Uint32 count)
    {
        volatile Uint32 tempCount = 0;
    
        for (tempCount = 0; tempCount < count; tempCount++)
        {
            /* dummy loop to wait for some time  */
        }
    }
    /*============================================================================*/
    /*                               END OF FILE                                  */
    /*============================================================================*/
    

    I am trying to boot the application with TI-RTOS (newest SYSBIOS version) based app.

  • Hi Titus

    Thank you for your efforts to find out what the problem is.

    I suspect that the AISGen tool does not fully support the new RTOS as it must have extra sections that need to be loaded and booted that the AISGen does not understand or support so the RBL does not load properly at boot and the system cannot be initialized correctly.

    Surely someone at TI must have fully tested that the RTOS is boot-able! Can you also ask the RTOS/sysbios experts at TI what is going on?

    I noticed that the RTOS does not fully support the C674x devices but it seems to have more support for other devices such as the MSP ucs. For example you cannot load the drivers under RTOS for this device but there is support for other devices.

    The version of SYS/Bios that I have installed is 6.40.01.15

    It would be also good to find out what AISGen version we should be using that supports RTOS. There seems to be several versions floating around. In my earlier post I found that later version of AISGen has problems compared with 1.09 which you also use. Also I don't understand why the AISGen tools are on sourceforge! Is this a TI owned product or is it done by third parties?

    My install only allows me to build RTOS based projects. How do I ask it to do a sysbios project instead? Do I need to uninstall RTOS?

    I will try the .ais you sent me and let you know the results.

    Thanks for your help so far...at least I have stopped myself going nuts :)

    BR

    Manjula
  • HI Titus,

    So IS the conclusion that Nobody at TI knows if RTOS based projects can be made boot-able?

    Please let me know Yes/No answer asap as I need to take decisions before the customer arrives.

    Thanks

    Manjula

  • Dear Manjula,

    My install only allows me to build RTOS based projects. How do I ask it to do a sysbios project instead? Do I need to uninstall RTOS?

    No need to uninstall the RTOS.
    You can download the following MCSDK package where you get the PDK examples of DSP.

    software-dl.ti.com/.../index_FDS.html

    You can use refer to the following package after installation.
    C:\ti\pdk_OMAPL138_1_01_00_02\packages\ti\csl\exampleProjects\gpio_exampleProject

    Already I'm checking with internal DSP team and also requested TI-RTOS team for this bootable issue on OMAPL138 device.

    Thanks for your patience.
  • Hi Titus


    Is there any resolution to this problem? Has anyone succeeded at TI to do what we are trying?

    Let me know at your earliest.

    Customers are usually wrong in thinking that when products are put out they are tested and verified....

    Thanks

    Manjula

    Manjula

  • Dear Manjula,
    Sorry for the inconvenience.
    Actually I'd involved full time for this issue.
    Surely, I will try to fix the problem today.
    I came to know that you are also posted the problem in TI-RTOS forum since I'm already discussing with RTOS team directly.
    Thanks for your patience.
  • Hi Titus

    I thought it might be worth a try if the RTOS guys could shed additional light, but they gave me the same answers as you.
    I am confident that you will find a solution for this problem soon.
    Let me know at your earliest when you find the solution. I have asked the customer to cancel flights as the app is not ready due to TI tool problems and that and can't do FAT. They are not too happy :(

    BR

    Manjula
  • Dear Manjula,

    I'm able to flash and boot your UART ECHO RTOS based DSP application now.

    I emailed you with your UARTecho project AIS config file and AIS converted file, please try it and let me know.

    Here I have attached AIS config file and AIS converted file for other community members.

    I think, its due to "System_printf" APIs in that project.

    If you are interested, you can attach that  RTOS based UART echo project here for other community members.

    Also I have attached LED RTOS based DSP app.

    Titus_AIS_settings_with_DDR_working_UARTECHO_RTOS.cfg

    uart_rtos.ais

    blink_C6000_HWI_SOL_TI-RTOS.zip

    Now its clear that we are able to boot RTOS based application on C6748 LCDK board.

    We will look into your actual project now, please check if any "System_printf" used, comment it out, rebuild and convert to AIS then flash & boot.

    Will check with RTOS team for why "System_printf" is causing not to boot or some other problem is there.

    Please let me know your finding and results.

    Now you have RTOS based application working and non-working project , compare with yours and give your feedbacks.

  • Hi Titus

    I built and ran uartEchoRTOS you sent me on the LCDK and it works.

    Then I rebuilt my_app (the real thing) and used the new .cfg file converted/flashed and .....
    No Luck! Didn't boot.
    The my_app does not have System_printf. my_app runs in the ccs debugger without a problem.
    But still I cannot boot it. So I think there are more things wrong with RTOS or in other words there
    are incompatibilities between RTOS and the boot tools.

    Now I have run out of time and cannot hang out for the RTOS to boot anymore. I have decided to
    move the project to standalone C without RTOS/Sysbios. It is causing too many headaches!

    Anyway I think you guys need to look at this issue and solve it. I think would be a very good idea
    to test products before they are put out to hapless customers ;)

    Thank you very much for your help. You are a great support eng and stuck with me all this time...

    BR

    Manjula
  • Titus and Manjula,

    Your posts have helped me to get my application running on a LCDK C6748 board using CCS to burn the NAND FLASH (via NANDWrite_DSP). The cfg file from Titus was very useful. However I suggest TI post a modified version that fully mimics the typical gel file that is run at connect time, namely C6748_LCDK.gel. The cfg from Titus seems to lack enabling many of the peripherals in the PSC. The blink routine was useful in proving that the flashed code was running out of DDR properly. I used version 1.13 of AISgen. The gel file OMAPL1x_debug.gel was useful in comparing the configuration set by C6748_LCDK.gel at target connection in a normal CCS debug session with the configuration inserted into the bin (ais) file by AISgen.

    I struggled for several days, mainly due to misinformation in some Wiki pages, etc. However, I was successful in getting my RTOS app to run out of DDR, with UART capability and a web server.

    Much thanks for your efforts.

    KTM
  • Hi KTM,

    Thank you for the post and I am glad that our previous posts were helpful. I am sure you would agree with me that TI should make things easier by providing a wiki page or site with all the required info and proven tools in one go-to place. The most frustrating thing I found was that information is scattered everywhere and I spent hours trolling wikis etc. Worst is that you get led down rabbit holes with dead ends and misinformation. Some tools are out of date and buggy. I also found that some utils are on third party sites which is really not good. That is TI is nor responsible for these tools which they expect us to use.

    It would be great if there where was utility integrated with CCS to flash the boards.I really want TI to improve in this customer support area.


    It is interesting that you were able to get your RTOS based app to boot. I had no such luck. I just gave up at the point when our RTOS based app didn't boot and used our own embedded OS instead which works fine. Interestingly the RTOS guys didn't know that if C674X based devises can be made boot-able. There seems to be much more support for other micro controllers such as MSP.

    Titus is an awesome SE. Without his support I would have totally given up and gone to another vendor.


    Good luck with your product development!

    BR

    Manjula

  • Hi Manjula,

    Just want to thank you for discovering that AISgen1.13 fails to create valid boot images for the LDCK. I rolled back to revision 1.9 and (surprise!) my problems were solved. That saved me days, if not weeks, of troubleshooting.

    You would think that after 6 months someone at TI would say or do something about a bad software update...

    Thanks,
    David
  • Hi David

    Thank you for letting me know and I am glad that the pain I went through is helping others.

    TI makes the best DSPs in the world but the tools are not up to the mark. That is CCS is great but when we come to the point of going onto custom board we are more or less left out in the cold to find our way in the rabbit holes of posts and wikis so much so that I suspect that my local cafe barista might know something and hold that vital bit of missing information which is the last piece to the puzzle ;)

    It would have been great if there is a utility within CCS where we could flash boards but that is yet to come. The result is tools and utils scattered everywhere and some exist on third party sites as well. So who knows which one to use except through trial and error? I have highlighted this earlier and so have others posting, but so far fallen on deaf TI ears :)

    Let us keep posting and help each other out :)

    Best regards

    Manjula