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.

Serial Flasher tool OMAP L138 influence of "–targetType" argument

Other Parts Discussed in Thread: OMAPL138, OMAP-L138

Hi team,


Customer is reaching the erase state while using the OMAPL138_LCDK argument as –targetType when –targetType OMAPL138 doesnt allow for boot.

command used:

What is the influence of targettype arg?

  • Hi,

    Could you please update the full logs of sfh output?

    I suspect that customer might have missed to provide "flashType" information to the "sfh" exe since OMAPL138_LCDK board will use NAND flash but it depends.

    Is the board custom or TI OMAPL138 LCDK board?

    Ex:

    If board having NAND flash

    sfh_OMAP-L138.exe -erase -p COM2 targetType OMAPL138_LCDK flashType NAND

    If device having SPI flash

    sfh_OMAP-L138.exe -erase -p COM2 targetType OMAPL138_LCDK flashType SPI_MEM

    OR

    sfh_OMAP-L138.exe -erase -p COM2 targetType OMAPL138_LCDK

    Note:

    If customer had SPI flash on board then "flashType" option is not required since it will take default option as SPI flash.

  • OMAPL138 targetType configuration for the serial flasher utility refers to OMAPL138 EVM configuration which has mDDR hooked up as the external memory configuration and a 8 bit NAND flash. OMAPL138_LCDK is the targetType configuration of OMAPL138 Low cost development kit hardware that uses DDR2 memory as external memory and 16 bit NAND flash device.

    The serial flasher host (sfh) utility loads AIS signed target application called seral flashing on target (sft) on the ARM that loads part of the program into the external memory hence it needs to know if it is being loaded in mDDR or DDR2 so that it can initialize those memories appropriately before loading code into that section. Also as Titus mentioned you need to specify  the correct boot media configuration at command line.

    If this utility is being used by the customer on a custom board, they would need to make sure that they modify the utiltiy for their platform as the utility is only an example utility to flash TI supported platforms. How to modify the utility for custom platforms has been described here:

    http://processors.wiki.ti.com/index.php/Serial_Boot_and_Flash_Loading_Utility_for_OMAP-L138#Modifications_for_Custom_Boards

    Regards,

    Rahul

  • hi,

    I'm the customer who has requested this issue.

    I did all the changes you mentionned but it doesn't work. It seems that AIS target application doesn't send "DONE" sequence after to have received data over UART.

    ...

    Do you have explanations? and commands or tools to spy RS232

    Thanks

    Regars

  • Hi Sebastien,

    Could you please answer the following questions to support,

    Are you working with custom board?

    Did you erase your media flash successfully?

    What type of flash media are you using on your board ie NAND or SPI ?

    Could you please update your full o/p logs of sfh?

    If you are waiting at "(AIS Parse): Waiting for DONE..." then it could be the problem of mDDR/DDR2 (DDR parameters) timing issue.

    Are you testing this board for a first time?

    Have you initialized the DDR using gel script (CCS) with modifying the DDR parameters (The idea behind is that finalize the DDR parameters for your DDR on your custom board) ?

  • Hi,

    Are you working with custom board?

    yes

    Did you erase your media flash successfully?

    Yes

    What type of flash media are you using on your board ie NAND or SPI ?

    NAND 8 bits (same that LCDK but with 8 bits)

    Could you please update your full o/p logs of sfh?

    If you are waiting at "(AIS Parse): Waiting for DONE..." then it could be the problem of mDDR/DDR2 (DDR parameters) timing issue.

    I have a DDR2 like LCDK. It's because I use target OMAPL138_LCDK

    It seems there is a problem into file UBL on the NAND_open() because when I log UART with spy RS232 I see text "ERROR: Nand Memory Initialization failed" appears. I'm using "ubl_OMAPL138_LCDK_NAND.bin" after changing DEVICE_ASYNC_MEM_NANDBOOT_BUSWIDTH to DEVICE_BUSWIDTH_8BIT into device_async_mem.h

    Are you testing this board for a first time?

    Yes

    Have you initialized the DDR using gel script (CCS) with modifying the DDR parameters (The idea behind is that finalize the DDR parameters for your DDR on your custom board) ?

    I don't use CCS. I use GNU file and I build on Linux.

    When I use CCS, it doesn't work with gel file

  • Could you please update your full o/p logs of sfh?

    C:\Flash_omapl138\OMAP-L138_FlashAndBootUtils_2.42\OMAP-L138\GNU>sfh_OMAP-L138.e
    xe -p COM2 -flash ubl-NAND.bin u-boot.bin -flashType NAND -targetType OMAPL138_L
    CDK -v
    -----------------------------------------------------
       TI Serial Flasher Host Program for OMAP-L138
       (C) 2014, Texas Instruments, Inc.
       Ver. 1.67
    -----------------------------------------------------


          [TYPE] UBL and application image
           [UBL] ubl-NAND.bin
     [APP IMAGE] u-boot.bin
        [TARGET] OMAPL138_LCDK
        [DEVICE] NAND
        [NAND Block] 1

    Attempting to connect to device COM2...
    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 14100-Byte section to address 0x80000000.
    (AIS Parse): Processing command 1: 0x58535901.
    (AIS Parse): Performing Opcode Sync...
    (AIS Parse): Loading section...
    (AIS Parse): Loaded 1356-Byte section to address 0x80003714.
    (AIS Parse): Processing command 2: 0x58535906.
    (AIS Parse): Performing Opcode Sync...
    (AIS Parse): Performing jump and close...
    (AIS Parse): AIS complete. Jump to address 0x80000000.
    (AIS Parse): Waiting for DONE...
    (AIS Parse): Boot completed successfully.

    Waiting for SFT on the OMAP-L138...
            Target: BOOTUBL
            Target:    DONE

    Flashing UBL ubl-NAND.bin (13044 bytes) at 0x00000000

            Target: SENDIMG
            Target:   BEGIN
     100% [ ████████████████████████████████████████████████████████████ ]
                      Image data transmitted over UART.

    Have you initialized the DDR using gel script (CCS) with modifying the DDR parameters (The idea behind is that finalize the DDR parameters for your DDR on your custom board) ?

    With CCS, in debug, I have any problem:

    - I loose value of variable

    - program doesn't work step by step

    - ...

    I'm feeling there is a problem about compiler

    I'm using CCSv5 and I get source code by import with Legacy CCSv3.3 Projects

    Thank you

     

  • Hi,

    Are you testing this board for a first time?

    Yes

    Have you initialized the DDR using gel script (CCS) with modifying the DDR parameters (The idea behind is that finalize the DDR parameters for your DDR on your custom board) ?

    When I use CCS, it doesn't work with gel file

    lashing UBL ubl-NAND.bin (13044 bytes) at 0x00000000

            Target: SENDIMG
            Target:   BEGIN
     100% [ ████████████████████████████████████████████████████████████ ]
                      Image data transmitted over UART.


    I strongly believe that it might have problem with DDR2 parameters.

    Please refer the below TI wiki to get the DDR parameters for your DDR2 hw.

    http://processors.wiki.ti.com/index.php/Programming_mDDR/DDR2_EMIF_on_OMAP-L1x/C674x

    processors.wiki.ti.com/images/d/db/MDDR_DDR2_Memory_Controller_Register_Calc_Rev4.zip

    DDR Configuration

    • OMAP-L138/Common/src/device.c: Modify the parameters passed to the function DEVICE_ExternalMemInit to match the DDR timing requirements for the custom board

    Have you accomplished the above step?

  • Gents,

    My understanding is that there are 2 things that differs between LCDK and custom board :

    1/ DDR timing (sebastien is making the modifications you suggested)

    2/ NAND that is 8bit vs 16bit for the LCDK (where you this be specified?)

    Stalin, can you please explain us the step we are blocked at : SFL just loaded the UBL in DDR, then who takes care of flashing it in NAND?

  • Hi,

    I'm doing that today.

    I build source code with CodeSourcery version : arm-2009q1. Is it a good version?


    Thanks

  • Hi,

    O'Mellin Says said:

    2/ NAND that is 8bit vs 16bit for the LCDK (where you this be specified?)

    You have to change the NAND settings for 8bit data width like below " at "OMAP-L138/Common/include/device_async_mem.h"

    #if defined(OMAPL138_LCDK)
    /*  #define DEVICE_ASYNC_MEM_NANDBOOT_BUSWIDTH    (DEVICE_BUSWIDTH_16BIT) */

      #define DEVICE_ASYNC_MEM_NANDBOOT_BUSWIDTH    (DEVICE_BUSWIDTH_8BIT)
    #elif defined(C6748_LCDK)
      #define DEVICE_ASYNC_MEM_NANDBOOT_BUSWIDTH    (DEVICE_BUSWIDTH_16BIT)
    #else
      #define DEVICE_ASYNC_MEM_NANDBOOT_BUSWIDTH    (DEVICE_BUSWIDTH_8BIT)
    #endif

    Sebastien Says said:

    I build source code with CodeSourcery version : arm-2009q1. Is it a good version?

    Yes,

    Please refer the below TI wikis for rebuilding the SFH.

    http://processors.wiki.ti.com/index.php/Serial_Boot_and_Flash_Loading_Utility

    http://processors.wiki.ti.com/index.php/Rebuilding_the_Flash_and_Boot_Utils_Package

  • In the excel file mDDR_DDR2_Memory_Controller_Register_Calc_Rev4.xls,

    what does that mean Page Size?


    It's the number of column?

    Thanks

  • Hi,

    Please check your DDR2/mDDR data sheet and fill in the excel to calculate the timing parameters.

    OMAPL138 supports 256,512,1024 and 2048 page size for DDR.

  • I use MT47H32M16HR-25 DDR2 but datasheet doesn't speak about page.

    It has 4 banks of  128 Mbits = 512Mbits

  • I inform to you that I try to install all required firmware to build source code.

    - I work on Ubuntu 10.04 LTS

    - I installed gcc v4.2.3, Sourcery G++ Lite 2008q1-126 you tested

    - I'm using Mono Frameworks on ubuntu (the last release)


    Do you have aleady tested that on Ubuntu 10.04?

    Regards

  • I think it's a problem of Sourcery compiler because when I look at logs with my spy RS232, I have the feeling that "return" into source code don't work (I enter in all functions despite the "return") and too, all text messages appear in disorder. I suspect a problem of compiler version and optimized compiler.

    I did test with modifying registers with compliant with my DDR2 but I get same behavior.


    Before seeing DDR2, I focus about building source code sft into shared memory.

  • Hi,

    Firstly, You have modify the source code of "OMAP-L138_FlashAndBootUtils_2_40" as per your custom board (DDR2,NAND,crystal etc.,)

    Secondly, You have to compile the source code of "OMAP-L138_FlashAndBootUtils_2_40" to generate the new "sfh_OMAP-L138.exe" for your board then only It would get effect of DDR parameters etc.,\

    So, Try to Rebuild your source code of "OMAP-L138_FlashAndBootUtils_2_40".

    Yes, I have already rebuilt the "OMAP-L138_FlashAndBootUtils_2_40" in Linux host 12.04.

    Please refer the below ti e2e post for rebuilding.

    http://e2e.ti.com/support/dsp/omap_applications_processors/f/42/t/330825.aspx

    Have you modified the "build.mak" file for your compiler at OMAP-L138_FlashAndBootUtils_2_40/Common/build.mak?

    Ex:

    build.mak


    #############################################################
    # Common build definitions for Makefile use                 #
    #############################################################
    #
     
    ARM_TOOLS_PATH?=/opt/ti/ccsv5/tools/compiler/gcc-arm-none-eabi-4_7-2012q4/
    ARM_TOOLS_PREFIX?=arm-none-eabi-
     
    CROSSCOMPILE?=$(ARM_TOOLS_PATH)bin/$(ARM_TOOLS_PREFIX)
    ARM_CROSSCOMPILE=$(CROSSCOMPILE)
     
     
    DSP_TOOLS_PATH?=/opt/ti/C6000CGT7.4.6/
     
    DSP_LIB_PATH=$(DSP_TOOLS_PATH)lib/
    DSP_CROSSCOMPILE=$(DSP_TOOLS_PATH)bin/

  • Hi,

    Thank you for your responses.

    I did the same things that you. My question are :

    - is the version of compiler is important?

    - same question that mono framework. I'm using mono-complete for Ubuntu 10.04 LTS

    Best regards

  • Hi Sebastien,

    ARM_TOOLS_PATH?=/opt/ti/ccsv5/tools/compiler/gcc-arm-none-eabi-4_7-2012q4/

    DSP_TOOLS_PATH?=/opt/ti/C6000CGT7.4.6/


    Have you installed CCS on your Host PC (linux)?

    If yes, Better to choose available ARM & DSP cross compiler tools from CCS installation.

  • hi,


    ok it' done but I have same issue. I give you logs :

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

    000000: ØÿBOOTME XRYSXYSRYSXYSR€à4áÀãÓ€ãð)áî3Àã‡Àã€ã
    €ãîŸåŸå€àÐ@âÐÍãŸåð áþÿÿêà4€à4€0Ÿå$“å0â  áÿ/á@ÁPã@-å
    PãpŸåêlŸåÀ ã" á(Áåáüÿÿ́âAç@âTá

    âAç@Äã@„áA€ç å‚á €å(åáüÿÿ!ç âRáûÿÿ½èÿ/ápâÁ0ŸåH€âÁ“ç àÌá‚áƒçÿ/á@Á1Ÿå(1“å0âûÿÿø Ÿå
    ƒâ’ç0ƒâÀã€ãSã‚çöÿÿ    0 ãÐ Ÿå
    ĉՍ0ĉˋۋ
    000001: Sã‚çöÿÿ 1’å0ƒã 1‚å(1’åãüÿÿ˜0Ÿå(!“åãûÿÿ*“å Âã ‚ã*ƒå0 ãt Ÿå
    ƒâ’ç0ƒâÀã€ãSã‚çöÿÿ      ãL0Ÿå
    ‚â“ç ‚âÀã€ãRãƒçöÿÿ|*“å Âã ‚ã|*ƒå !“å ‚ã !ƒå(!“åãüÿÿÿ/áÁpâ0Ÿå Ÿå8 ƒå Ÿå< ƒåÿ/á@Áçƒàñ¤•0Ÿå  ã8 ƒå< ƒåÿ/á@Á0Ÿå 0“å Ÿå0âÒçÿ/á@Á\5€@-éõÿÿë@âÿâPã0Ÿ•ƒ Е ƒ@½èÿ/á\5€@-ééÿÿëPã  @½èÿ/áøE-éhÁŸå  á|1œå0Ãã\AŸå PÝå|1Œå1”å 0Ãã1„å1”å<Ãã1„å1”å0Ãã` á1„å ãp á€ áë1”å<Ãã1„å1”ådƒáa„å1”å0Ãã1„å1”å0ƒã1„å1”å0Ãã1„å1”å0Ãã1„å} ã‰ˆã©Šãëëq„偄å(¡„å<!”åã¬0Ÿåûÿÿ)…ãP…â… áQ áAâPEâãY…ã!ƒåƒå`Qƒåh!ƒå$ Ýå)‚ã !ƒå( Ýå)‚ãl!ƒå8!“å ‚ã8!ƒåP@Ÿå<”åPâûÿÿÈ ãÉë1”å0ƒã1„å} ãÄë1”å0ƒã1„å0Ÿå|!“å ‚ã|!ƒå áøE½èÿ/á@ÁÁÁŸåðA-造áˆ1œå 0ÃãAŸåˆ1Œå1”å 0Ãã1„å1”å<Ãã1„å1”å0ÃãP á1„å ã` áp á£ë1”å0Ãã1„å1”å0ƒã1„å1”å0Ãã1„å1”å0Ãã1„å} ãi†ã”ëQ„å(a„å<1”å〟åûÿÿy‡ã‰ˆãqåå0Ýå9ƒã 1å81‘å0ƒã81åP@Ÿå<”åPâûÿÿÈ ã~ë1”å0ƒã1„å} ãyë1”å0ƒã1„å0Ÿåˆ!“å  ‚ãˆ!ƒå áðA½èÿ/á@Á áóA-造áP áp á` á ã0 ã ã  ã­þÿëÁŸå0œå@ã
    0œå9ƒã0Œå0œå@0Ãã0Œå0œå:ƒã0Œå0œå:Ãã0Œå0œå:ƒã0ŒåÐÀŸå0œå    ãûÿÿ
    0œå€0ƒã0Œå0œå<ƒã0ŒåÅãÁãB ã5ãã䀄å0„å„åã$00„p„å`„å0”å9Ãã0„å 0å0„å0”å ã1ƒã0„å ã0 á  ãvþÿë ã ã  ã0 ãqþÿë0”å1Ãã0„å$ Ÿå$0Ÿå ƒå “å å å ã ƒåüA½èÿ/áÀâZ¥Z¥À@-éÜþÿëÒþÿëŒ ŸåŒ0Ÿåp’å0àp1‚å†þÿë ã  ã0 ã
    000002: è ã  á0 ãîþÿë Pâ0 ã ã0å ã0 áEÿÿë Pâ40Ÿå å0å, ŸåÅ ã(Ÿå(0Ÿå†ÿÿë  á áЍâàäÿ/á@Á Q’    2J&2H"Ç<@-é@Pâ  ã0 á  á+þÿëX0Ÿå4!“åÿ$Âã$‚ã4!ƒå<!“åDŸå$â‚á<ƒå8Ÿå@!“å@ƒåD!“åDƒåH!“åHƒåL!“åLƒåP!“åPƒå á@½èÿ/á@ÁPã@-é ƒŠt@Ÿå
     ã0 ã ã  áþÿë,1”åÿ<Ãã0Ãã<ƒã0ƒã,1„å01”åð0Ãã0ƒã01„å    ê0 ã
     ã  ãöýÿë41”åÿ8Ããÿ>Ãã8ƒã>ƒã41„å ã@½èÿ/á@ÁPã@-é
    :Pã   ã0 ã ã
    000003:  ãàýÿëh0Ÿå0!“åÿ(Âã"(‚ãê ã  á0 ã     ãÖýÿë@0Ÿå,!“åÿ(Âã"(‚ã,!ƒåê  ã0 ã ãÌýÿë0Ÿå0!“åÿ$Âã"$‚ã0!ƒå ã@½èÿ/á@ÁPã@-é ƒ
    000004: Š8@Ÿå01”ÿ<Ã"<ƒ0 ã ã  ã¶ýÿë01”åÿ8Ãã7ƒã01„å ã@½èÿ/á@ÁPã@-é ƒŠ|@Ÿå
     ã0 ã ã  á£ýÿëH1”å`0ŸåH1„åL1”åÿ0Ãã"0ƒãê  ã0 ã ã˜ýÿëH1”å8 Ÿå à40Ÿå0‚áH1„åL!”å(0Ÿå"* á* á0‚áL1„å ã@½èÿ/á@Á""""ÿð"" ãÿ/áÿ/áÿ/á ãÿ/á÷O-é@ áp á` áP á§ëPã²ÔÀ   Ÿ0†â\á Œà Šâ*À áøÿÿêÀ ã°!Ôá` á
    \á0Œà*`†âÀ áùÿÿêÈŸå®ë áµë¼Ÿåªë ”å á á Bâ    ëPã
    œŸå¡ë ã_ê á á7ëPã
    |Ÿå˜ë áŸëdŸå”ëP…âòÿÿê á á  áÁëPã
     á áÀë<Ÿåäÿÿê81Ÿå²!Ôá“å"! á áPá*0àã1ç€âùÿÿꀠã` á á á  á0 áÞë°Pâ
     á á§ëàŸåP…âmë²1Ôá–à€fàpcà` ã"êÀŸåeë álë´Ÿåaë áh눟å]ëÈ ã¼ë0™å á0å á  á0 áNëPã
     á á†ëP…âdŸåÝÿÿê²1Ôáp‡à°1Ôá`†âVဈâP…` 
    XáÇÿÿ: áÇë ãþO½èÿ/áŸ5€º5€c7€É5€Ý5€ë5€ :€ú5€6€76€?6€@-é0Ÿå á  ã“ågë@½èÿ/áÈ:€÷@-é,ŸåóÿÿëPã@ QŸå Ÿå•å  ãÀëpPâ9AŸå ã „â•åÞë ã` á „â•åÙë ã`€á „â•åÔë ã`†á „â•åÏë ã`†á  „â•åÊ묟å`†á  á•å ë`–á”åP㈟åÅÿÿëê1ë„åxŸåÀÿÿë0Pâ
    000005: ”å â"å•å”å^ëPã0”å åRá
    <Ÿåãë ãê0Ÿå¬ÿÿëâ þ@½èÿ/áf6€È:€n6€ :€v6€{6€ƒ6€‹6€¢6€ðO-é,ÐMâFŸåŸå”å  ãlëPãøÿÿŸå”ÿÿëPãôÿÿè%ŸåðŸå’å  ãaëPãíÿÿÌ5Ÿå ã“å$ âëPãæÿÿÀŸå‚ÿÿëpPââÿÿ´5Ÿå0“å ã“å$`åPë@P✟9
     ã1  ãë²Ôáàë„UŸå…å²ÔáÜë•å…å0 á²!ÔáSá* àã Áç Àç0ƒâ÷ÿÿêL5ŸåVá"
    0ƒâVá
     0CâVá6bÿÿëPã3 0•åŸå,0„å†ë,”åëŸå‚ë²!Ôá°1Ôá’à,”å“à…ëðŸåzë á•å •å 0•å¨þÿëPãÐ4ŸåƒåêEÿÿëPã á•å •å0 ã›þÿëPãŒdŸå
    œŸå0ÿÿëꔟå-ÿÿëdŸå+ÿÿëPã1ÿÿëPã0–å0å0–å0å0–å²ÁÔá –å0å0 á áQá` á€à0ƒâùÿÿ: á€•å(ëPã°!Ôp  Ÿ †â
    Pá0€à*p‡â áøÿÿêŸåpå8ë á?ëØŸå4ëP ã á áËëPã
    Пå,ë á3ëÄŸå(ëP…â10‡âUáðÿÿš°Ÿå"ë»ÿÿꨟåë á&뜟åë á á  áJëPã
     á áIëtŸå=ê03Ÿå²Ôá°“å! á áPá*ÀàãÁ‹ç€âùÿÿê å ‹å åD‹é å` ã ‹åP‹å`‹å Ÿå0åùë›åëÜŸåõëŸåóë›åúëÄŸåïëôŸåíë›åô묟åéëàŸåçë áîëÔŸåãë ãê넟åßë0å  ã á á0“åBë PâP²Ÿå
     á á
    됟åÑëTêȠ㠍å.ë0›å0å0›å á á åÀëPã° ` 
     á áöëDŸåêÿÿêÈ ãë0™å á0å á  á0 á®ëPã"²1Ôဈà°1Ôá`†âVá°‹â*

    [á(*0…à0Câ2Sã)Š á á  á0 á    ëPãåßÿÿ
     á áÑë´Ÿå˜ë0åWáP…â
    ²1Ôá–à°fà€càê á áÃ뀟åŠë åWáP…â

    ²1Ôá–à°fà€cà`åêP…âpGâ` ã
    [áÑÿÿ: áëè0Ÿå  ã ƒåê áTëPã
    ÔŸåoëêŸå9þÿëPã ãëøŸå3þÿ뤟å1þÿë á ã2  ã“ëPPâøþÿ áãët0ŸåPƒåLŸå%þÿë@Pâ
    `Ÿå!þÿë‚þÿê0Ÿåþÿë$ åœ0ŸåRá‡þÿ á,ЍâðO½èÿ/áÈ:€ª6€²6€º6€¢6€h8€Â6€ :€LBUï6€7€c7€Ì:€
    000006: 7€7€Ÿ5€7€M7€Y7€f7€‹7€²7€ë5€µ7€Â7€Ñ7€Ý7€76€8€8€ú5€?6€,8€e7€ÿLBU0 ã ÐçRã

    0ƒâøÿÿê0àãêSã0à áÿ/á@-é0å  ã0 ƒåŸåsë@½èÿ/á'p@-é@ á ã` áEë1Ÿå@€åA“ç@€åP á0”å@ãüÿÿ
    Vãè0Ÿ`…0… áãÿÿë00”å9Ãã00„å00”å9ƒã00„å0•å0ÓåSã0 
    Sã%0 ã40„å0”å€0ƒã0„åd ãIë0•å0Óå 0Äå0•å´0Óá` ã#4 á$0Äåd ã`„å>ëÇ0 ã0„åd ã:ëd ã`„å7ë0 ã0„åd ã3ë0 ã0„åd ã/ë0”åÀ0âÀSãd * áp@½èÿ/á@8€L8€RãðA-épåP á á
    –ÿÿë`€âê“ÿÿë` á@ ãTáªäüÿ뀗åäüÿ먂 á€(âP〠€XãöÿÿPã
    0Õç@„â0‡åíÿÿê ãê ãðA½èÿ/á@-éÀ á0 ã! á bâ<" á â    Rã ‚‚â0 ‚â Ãç0ƒâSãóÿÿ  ã ÍåÊÿÿëЍâàäÿ/áøE-éPåp á` á€ á@ ã0–åTá*±üÿë •å±üÿë0â0 
    0ÓáùÿÿPã
    •åÿâÇç0•åã

    Pã@†
    @„âæÿÿê ãê ãê ãøE½èÿ/á@-é< ã â0"å0 ãÓÿÿë@½èÿ/áRãðA-épåP á á
    0ÿÿë`€âê-ÿÿë` á@ ãTá
    ~üÿ뀗å~üÿë0â0 0ÓáùÿÿPã
     —å0Õçÿ âRá@„âíÿÿê ãê ãê ãðA½èÿ/áðO-éQãpå$ÐMâ!       € P á` ãVá@ ã"
    @…äWüÿë°—åWüÿë0â0 0ÓáùÿÿPã
     —åÿ â0BâQã1 áW B‚!‡Š    Qã7 B‚— ‡ —åã
    000007:     cà å0ç1‚á@„â
    Tá0åßÿÿ:`†âÙÿÿê áê ãê ã$ЍâðO½èÿ/á@-é0Ÿå á  ã“å4ÿÿë@½èÿ/áÈ:€8@-é$@ŸåP á Ÿå”å  ã*ÿÿë”å áJÿÿë8@½èÿ/áÈ:€J7€@-é0Ÿå á“åAÿÿë@½èÿ/áÈ:€@-é0Ÿå á“åtÿÿë@½èÿ/áÈ:€@-é0 ã â0"å0Ÿå á“å0 ãBÿÿë@½èÿ/áÈ:€0Ÿå“åÿ/áÄ:€0Ÿåƒåÿ/áÄ:€40Ÿå€â Àã“å(Ÿå‚àPá“•Ÿ•€“• ‚ ƒ• ƒÿ/áÄ:€ÐÀ@-é@ áêÿÿë0 ãSá
      ã Àç0ƒâùÿÿê@½èÿ/á0 ãSá
    ÀÑçÀÀç0ƒâùÿÿêÿ/á0 ãSá
     á0ƒâúÿÿêÿ/á÷ÿÿêø@-é` á ãp áP áÝÿÿë àã¼0Ÿå`ÀåpÀå Àå0€åàÓå “å@ áÀ ã\áÔå*ÿPã’å0 ãSá
    ’å`’å‘ça–ç`àUá` #` 3Uá` 3VãÀÄ0Ä0’0„0ƒìÿÿ
    ÀŒâ ‚ââÿÿêæúÿëPã@ 0” À“à ÿ/ áø@½èÿ/áX8€3 ãd“åâÿ/á0ÐåSãÿ/0å “åÿ Âã ƒåÀÐåÐå\ã ƒâÁàÁàÁ‚ç ÐåRã Ð`“ "` ƒÿ/á0åà0ÐåÐMâSãå
    Sã0( "( ° Ãê0åÿ â ÃåЍâÿ/á0 á “å0ÓåÐMâSã ã å
    Sã0°Óê0åÓåÿâЍâÿ/áp@-éP á` á@ ã0ÕåTá*„! á6" á áÿ â ãÏÿÿë@„âôÿÿêp@½èÿ/áp@-é0ÐåSã` áP á¡` @ ã0ÕåTá*„! á6" á áÿ â ã»ÿÿë@„âôÿÿêp@½èÿ/á0åÐMâå0å0ÐåSã
    S㢠 0 
    ê0 ãSá
    ååÀÑäÿÀâÀÀå0ƒâåõÿÿêSá
    åå²ÀÑà0ƒâ°ÀÀáåöÿÿêЍâÿ/á0åÐMâå0å0ÐåSã
    S㢠 0 
    ê0 ãSá
    ååÐåÿâÁä0ƒâåõÿÿêSá
    åå°Ðá²Áà0ƒâåöÿÿêЍâÿ/á7@-éåP á@ ã•å åÀ’åà áÿ/á åPã@ BâRãå
    $âPã0 0‚ãíÿÿ ã>@½èÿ/á00åQã$0ƒÓå‚0ƒàQã²Ð´0Óá €àÿ/á@-é
    ; ã0å@ á á ãp  ãGÿÿë áWÿÿë0å0Câ0å0åSã0åSã ê@ãìÿÿ
    ÷ÿÿê@½èÿ/á8@-é`  ã@ áP á ã/ÿÿë°Ôá á•àNÿÿë á ãÐ  ã'ÿÿë á
     ã°ÿÿëPã á8@½èÏÿÿê ã8@½èÿ/á@-é ãÿ  ã@ áÿÿë á ã@½èŸÿÿêð@-é ãCßMâ@ á  ã
    000008: ÿÿë á ã   ã    ÿÿë á
     ã’ÿÿëPãP 5 áÿÿë`âÆçP…âUãøÿÿ€3Ÿå åRá0 0 °2Äá á×ÿÿëPPâ$ á ã  ãîþÿë á ã  áêþÿë á
     ãsÿÿëPãP á áôþÿëÆçP…âUãùÿÿ°2ÔáSãK
     á ãì  ã×þÿë á ã  ãÓþÿë á
     ã\ÿÿëPãP %
     ã­ê áÛþÿëpâÇç`†âVãøÿÿ¤2ŸåP…â  ã`×ç ã€ ãÉâáƒ8 á#8 á
    \ãÉ À \ã9#0#Pâ¡ áñÿÿ ‚âþRãëÿÿâº/QáRá

    ` ãÙÿÿêUã
    H0Ýå    0Äå0Ýå
    0ÄåX0å²1Äá¼5Ýá´1Äád0åh å°1Äál0Ýå’à0„åm0Ýå#" á0â Äå0ÄåTê0ÝåÝå    0Äå
    Äå<”å ÑåRã0 á
    Páƒâøÿÿ Óå¶Óá°!Äá² Óá „åÿ,â²!Äá bà´!Äá0ÓåSã
    ²1ÔáSã    Š²1ÔáSã0 ƒ0 “0Äå”å°1Ôá“à0 ã%ê°!Ôá#4 á"" á’à ”å’à    Sãíÿÿš0Ýåâ  ã
    â áÈ á²Äá# áâ€âaà á°Äá# áàâ! á¬ á‘à@ã´!Äá* ã „å0Ôå
    SãêSãwÿÿÏÿÿê1# áRãš0ƒâúÿÿê£! áÿ â‚Sá ‚‚ Äå0 ã0Äå²1Ôá Ôå‚SáÚ ‚â Äåùÿÿê0”å²ÑáSá 1¶Ñá¶Äá´ÔáPá 1‘àRá¸ÄáVÿÿÊ    QãTÿÿšSã0 “0 ƒ¾1Äá ãCߍâð@½èÿ/áONFINOp@-éP á@ ã` á’ýÿë á@ á  á ã»ýÿë àã$ „å  ã¸"Äáp Ÿå0 „ål Ÿå4 „åh Ÿå8 „åd Ÿå!„è< „å Ðå Äå0Ðå á0ÄåÞþÿëPã
    @ ãê ááþÿëPãùÿÿ áÔþÿëPãõÿÿ áp@½èÿ/á(:€|:€p:€È8€øE-é¾aÐáVãp á@ áP á€ á ã:
      ãÝýÿë  ã ã á~þÿë` á á á    þÿë°Ôá á—Q!àôýÿë á ã0  ãÍýÿë á
     ãVþÿëPãP 70ÔåUá1*¸!Ôá á’…!à*þÿë …â¸1Ôá á ã
      á`†à^þÿë0Ôå0CâUáp á
    000009:

     ã á ã®ýÿë á áßýÿë á ãà  ã§ýÿë` á
    P áÜÿÿêP  ã¢ýÿë á áÓýÿë°Ôá á—Q!à¾ýÿë á
     ã$þÿëPã á á¸!Ôáüýÿë áøE½è?þÿê ãøE½èÿ/áðA-éÞMâ@ á€ á0âp áP á›ÿÿë á ã  ã€ýÿë ã  á á!þÿë` á á á¬ýÿë°Ôá á—Q!à—ýÿë¾1ÔáSã  0  nýÿ á
     ã÷ýÿëPPâ
     ãCê40”å áÀ“åà áÿ/á0ÔåUá9*40”å áÀ“åà áÿ/á¶!Ôá á’…!àÀýÿë40”å áÀ“åà áÿ/á4À”åÿ â áâ
    000010: 0 áÀœåà áÿ/á¶Ôá40”啁!à á
    000011:   áÀ“åà áÿ/áPâÕÿÿ¶1Ôá`†à0Ôå0CâUáP…âÕÿÿ
     á  áÚýÿëVáp áÏÿÿ
     ã á ã.ýÿë á á_ýÿë á ãà  ã'ýÿë` áÂÿÿê áÓýÿëލâðA½èÿ/áð@-é80å²0ÓáSã@ áAßMâP á 9
    $0”åSá3
    $„å  ã
    000012: 0 á'ÿÿë80”å á
    000013:  áÀ“åà áÿ/ápPâ0 ¸2Ä
    000014:  á  ã
    000015: 0 á áÿÿë80”å á
    000016:  áÀ“åà áÿ/á`Pâ
    ¸rÄá ãê°2ÔáSã
    °!Ôá á Bâ
    000017: 0 á áÿÿë80”å á
    000018:  áÀ“åà áÿ/áPã¸bÄëÿÿ0 ã¸2Äá ãê¸Ôápâ 3Aߍâð@½èÿ/á@-é ã@ áp  ãÕüÿë áåüÿë  á ââ@½èÿ/áðA-造á¾1ÐáSã@ áp á` á P  Äüÿ á ã€  ãÀüÿë  ã ã áaýÿë¾ÔáP áQã  áêüÿë°Ôá á—a!àÕüÿë` ã0ÔåVá*¸!Ôá á’†!àòüÿë¸1ÔáP…à0Ôå0CâVá`†âñÿÿ
     á ã  áDýÿëUáp áêÿÿ
     á ã…  ã˜üÿë á áÉüÿëP ááÿÿê ã  á áüÿë á
     ãýÿëPã áðA½è7ýÿê ãðA½èÿ/á0@-é80å° ÓáRãAßMâ@ áP á ã$ê$ åRá¸"ÐáRã÷ÿÿ
      ã¸"Äá á
    000019:  á$P„åÀ“åà áÿ/á á á3ýÿë Pâ  á á
    000020: 0 á“ÿÿëPããÿÿ
    °2ÔáSã°!Ô   B    
    000021: 0 á†ÿÿëAߍâ0@½èÿ/áðA-é@ á€ áÞMâ´1Ðáp á` á ãPá*à㠍âÀç€âøÿÿê¾!ÔáRã  >üÿ á ã€  ã:üÿë ã  á áÛüÿëP á á áfüÿë°Ôá á—a!àQüÿë40”å áÀ“åà áÿ/á` ã0ÔåVá5*40”å áÀ“åà áÿ/á¶!Ôá á’†!àdüÿë40”å áÀ“åà áÿ/á¶Ôá40”喁!à á
    000022:   áÀ“åà áÿ/áÿ ââ4À”å á
    000023: 0 áÀœåà áÿ/á¶1ÔáP…à0Ôå0CâVá`†â       á üÿëUáp áÏÿÿ
     á ã…  ãôûÿë á á%üÿëP áÆÿÿê` ã0ÔåVá*¸!Ôá0â’6!à á.üÿë¸1ÔáP…à0Ôå0CâVá`†âðÿÿ
     á ã  á€üÿëUáp áéÿÿ
     á ã…  ãÔûÿë á áüÿëP áàÿÿê ã  á áËûÿë á
     ãTüÿëPã  tüÿލâðA½èÿ/áp@-é@åP á0 á` á.þÿëPã²1Ö  
    Rá*ÀÕçÔç\ဠ‚â÷ÿÿêâ ê ãp@½èÿ/áø@-éP áp á` á@ ã°1ÕáTá* á á  á0 áþÿëPã²!ÕÀ "! 
     ã
    ê0œå0CâSã0Œäøÿÿ€âPá÷ÿÿ:@„âæÿÿê ãø@½èÿ/áp@-é0å`Aâ`†àVáP á@ 1*Tአá áEüÿë@„âøÿÿê ãê ãp@½èÿ/áp@-é0å`Aâ`†àVáP á@ 1*Tአá á1üÿëPã
    8Ÿå§úÿë á®úÿë,Ÿå£úÿë á á×þÿë@„âíÿÿê ãê ãp@½èÿ/áœ8€±8€ å ã BâÚÿÿê å ã BâÖÿÿêp@-é`Aâ@ áP á`†à ã#  ãCûÿë°Ôá á•àbûÿë á$  ã ã;ûÿë°Ôá á–àZûÿë ãp@½èÿ/á ã*  ã1ûÿê3 ãÀ“å?Áã?Áã‚åÄ“å?Áã?Áã‚åÈ“å?Áã?Áã‚åÌ0“å?3Ãã?;Ãã0‚åÿ/á0-éÀ ã ÐMâPÓç@âPÌçÀŒâ\ãùÿÿ0å@å[ áÈâ%Q áW…áË á,[…áˆÀŸåÀà,Ã…áPâÀåt@Ÿå •è@à[ á%W áA…áN„áÿ7â#9„á0åL0Ÿå0à?Îâ, á#5Œá¾ÀÝá8ƒá0å0 ã¸AÐáÀà’Ä,à@â@Óç0ƒâ
    Sã@Ìåöÿÿ Ѝâ0½èÿ/áÿ3 ã` “å0 Âã` ƒåÐå` “å á0⠁á` ƒå` “å*‚ã` ƒå0“åÐMâ0åЍâÿ/á0ÐåSã0åþ4ƒ4ƒ0“åÐMâ0å3 ãÀ0“å0åЍâÿ/á¸Ðá ÐMâ"à ãÀÒåâÀÀç€â
    Pã ‚âøÿÿå” Ÿå á à  á#€á å åÿÀââÉ á ÇŒálŸåà
    Œáå`Ÿå`Ÿåàà  á!€áååHŸåà?â á€á".á å  ãâÒçÃç ‚âRãùÿÿ Ѝâÿ/áüð?üÿÀÿ@-å ãÐMâ€0 á³À’áË á,Ë á3 ãPâ¼Àƒå÷ÿÿ* “å åÀ “åÄ@“åÈÀ“å „áÌ“å ‚á ‚á?#Âã?+Â㠍ååPãr
    ` “å*‚ã` ƒå3 ãd0“å<â#4 á0å0åSã÷ÿÿš
    ; ã# ãd ’å,â"$ á0S⠍å
    åRãõÿÿŠ0åSã
    0åSãš3 ãØ0“å0åêå3 ãPãØ0“0L
    d0“å8â#8 á0å0åSãñŸ—Cê@4€ü3€Ä3€x3€# ãÔ’å1Ÿå0à#8 á?câ0ƒâðŸå8 á#Pá* ã3êÜ’åÐ Ÿå à#Ñç"( à#(Áç# ãÔ0’å; á#; á?câ0ƒâ¨Ÿå8 á#Páíÿÿ:Ü’å#(Ñç  à#(Áç# ãÐ’å|0Ÿå0à#8 á?câ0ƒâlŸå8 á#PáÞÿÿ:Ø’åT Ÿå à#Ñç"( à#(Áç# ãÐ0’å; á#; á?câ0ƒâ,Ÿå8 á#PáÎÿÿ:Ø’å#(Ñç  à#(Áç ãЍâ½èÿ/áÿÿ0-é0 ã ÐåSá
    *  ã¸ÁÐá“à@à ‚âP ãRãPÄç÷ÿÿ0ƒâñÿÿê0½èÿ/á ãÿ/áYSXYSRà4€|@-é\ŸåŽùÿë ãbùÿëzôÿëPã ãëôÿë<0Ÿå ã“åøÿë00ŸåƒåLöÿëNõÿë$0Ÿå$ Ÿå0“å0‚åà áÿ/á@½èÿ/á †48€È:€Ì:€œ:€YSXYSR\5€@
    000024:
            ªOMAP-L138 LCDKNAND is write protected!
    000025:
    CurrBlockNum =Unprotect failed.
    000026:
    Bad block at Erase failed
    000027:
    Write failed, skipping block!
    000028:
    Writing image data to Block , Page Write verify failed, skipping block!
    000029:
    SENDIMG    ACK0000 BADCNT  BEGIN
    000030:
    UART Receive Error
    000031:
       DONE  STARTBOOTUBL    CMD    ERROR: NAND Memory Initialization failed.
    000032:
    Writing to block , address     FAILSENDINGNumber of blocks needed for header and data: 0xNAND block  is bad!!!
    000033:
    No good blocks in allowed range!!!
    000034:
    Attempting to start in block number 0x.
    Magicnum: 0xEntrypoint: 0xNumpage: 0xWriting header and image data to Block Write failed!
    000035:
    Write verify failed!
    000036:
       SIZE88€Q ÄÀÐÐÐL8€h8€<€,€hŒ8€|8€`bdf Bad block at block . Erasing is skipped
    ãå9æIYk3 s C S u 5 õ v 6 F V x  y  r  t  q@ ¡@@±@@Á@@ñ@@ª@@º@@Ê@@Ú@@¬@@¼@@Ì@@Ü@@£ @@³ @@Ã @@Ó @@¥@@@µ@@@Å@@@Õ@@>
    0@P`p€ °ÀÐàð4€Ø4€
    Ì/€0€ì0€41€h1€H2€YSXYSR€   DONE  STARTBOOTUBL    CMD55424C10   DONESENDIMG    ACK55424CBB000001000000315400000020000000000000  BEGINTIPAYSX@-å
    000037: ‚âÿ/á|1œå0Ãã\AŸå PÝå|1Œå0Ãã)‚ãl!ƒå8!“å ‚ã8!ƒåP@Ÿå<”åPâûÿÿÈ 0ÃãAŸåˆ1ŒåQ„å(a„å<1”å  ‚ãˆ!ƒå0”åŒ ŸåŒ0Ÿåp’å0àp1‚å†þÿë
    000038: Œ ŸåŒ0Ÿåp’å0àp1‚å†þÿëD!“åDƒåH!“åHƒåL!“åLƒåP!“åPƒåð0Ãã0ƒã01„å    
    000039: ð0Ãã0ƒã01„å    ÿ(Âã"(‚ã
    000040: ÿ(Âã"(‚ã01”ÿ<Ã"<ƒ"0ƒãA“ç@€å0•å0Óå 0Äå0•å´0Óáp@½èÿ/á<.€ áøE½èÿ/á@-é< ã â0"å0 ãÓÿÿë@½èÿ/á°—åûþÿë
    000041: °—åûþÿëÙÿÿê@-é0Ÿå0Ÿå@½èÿ/á`“0°0Õå0Câ0å0å
    000042: 5¤2ŸåP…âøÿÿ Óå¶Óá°!Äá² Óá „åÿ,â²!Äá bà´!Äá    Sãíÿÿš0Ýåâ  ã
    1# á    d Ÿå!¸!Ôá
    000043: ¸!ÔáP  ã¢ýÿëà áÿ/á0Ôå
    000044: à áÿ/á0Ôå
    000045: à áÿ/á0ÔåÀ“åà áÿ/áÓýÿëލâðA½èÿ/áð@-é80å²0Óá
    000046: ÓýÿëލâðA½èÿ/áð@-é80å²0Óá
    000047: ÓýÿëލâðA½èÿ/áð@-é80å²0Óá
    000048: ÓýÿëލâðA½èÿ/áð@-é80å²0Óá0 á
    000049: 0 á
    000050: 0 á
    000051: 0 á
    000052: 0 á0 ã¸2Äáñÿÿ
    0@-é80å° Óá
    000053: 0@-é80å° Óá0 á“ÿÿë
    000054: 0 á“ÿÿë
    000055: 0 á“ÿÿëøÿÿê¾!Ôá
    000056:
    000057: 0Câ0Ôå0CâލâðA½èÿ/áp@-é@åP á0 á°1Õá§úÿëCûÿë°ÔáÌ0“å?3Ãã?;Ãã0‚åÿ/á0A…áN„áÿ7â#9„á0åL0Ÿå0à?Îâ, á#5Œá¾ÀÝá8ƒá0å` “å á0⠁á` ƒå` “å*‚ã` ƒåÀÀçÄ@“åÈÀ“å „áÌÐ|1Ÿå0“åP“åöÿëùÿëQŸå0”å0…å0”å0…å0”å0…å0”å0…å0”å0…å@•å-ùÿëÀ‚âœ0ªøÿë ÿ/á8@½èÿ/áD
    000058:

    000059:

    000060:

    000061:

    000062:

    000063:
    nt at
    000064: nt at
    000065: nt at 9xÜ@
    000066: @ailed.

    000067: ailed.
    000068:

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

  • HI,

    âAç@Äã@„áA€ç å‚á €å(åáüÿÿ!ç âRáûÿÿ½èÿ/ápâÁ0ŸåH€âÁ“ç àÌá‚áƒçÿ/á@Á1Ÿå(1“å0âûÿÿø Ÿå
    ƒâ’ç0ƒâÀã€ãSã‚çöÿÿ    0 ãÐ Ÿå
    ĉՍ0ĉˋۋ

    What is this ?

    Is this building error or error occurred while running sfh or error occurred while running binaries on board after flashing u-boot ?

    What is your input reference clock for ARM (crystal) ?

    ex: 24MHz

    This error seems to me baud rate issue.

    What are all the changes have you done it?

    Could you please attach the file (ex: device.c etc.,) ?

  • What is this ?

    This is the logs I spy on RS232.

    Is this building error or error occurred while running sfh or error occurred while running binaries on board after flashing u-boot ?

    No building errors occur. No errors occur when running sfh; this tool wait for with undefined time after message "Image data transmitted over UART."

    What is your input reference clock for ARM (crystal) ?

    Oscillator 24Mhz

    This error seems to me baud rate issue.

    I configure to 115200,8,none,1,none. I'm using boot mode on UART1 of OMAPL138

    What are all the changes have you done it?

    DEVICE_ASYNC_MEM_NANDBOOT_BUSWIDTH                 (DEVICE_BUSWIDTH_8BIT)

    DEVICE_UART_PERIPHNUM                                                     (1)

    status |= DEVICE_ExternalMemInit(0x000000C6, 0x00134A21, 0x1E923209, 0x3C11C722, 0x00000492, 0x00000000); on device.c

    Could you please attach the file (ex: device.c etc.,) ?

    /*
     * device.c
    */
    
    /*
     * Copyright (C) 2012 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.
     *
    */
    /* --------------------------------------------------------------------------
      FILE        : device.c                                                   
      PROJECT     : TI Boot and Flash Utils
      AUTHOR      : Daniel Allred
      DESC        : This file provides low-level init functions.
    -------------------------------------------------------------------------- */ 
    
    
    /************************************************************
    * Include Files                                             *
    ************************************************************/
    
    // General type include
    #include "tistdtypes.h"
    
    // Utility functions
    #include "util.h"
    
    // PRU APIs
    #include "pru.h"
    
    // This module's header file
    #include "device.h"
    
    
    /************************************************************
    * Explicit External Declarations                            *
    ************************************************************/
    
    extern __FAR__ Uint32 EXTERNAL_RAM_START;
    
    #if (defined(DA850) || defined(C6746))
    extern __FAR__ Uint32 PRU0_DATA_START, PRU0_DATA_SIZE;
    extern __FAR__ Uint32 PRU0_INST_START, PRU0_INST_SIZE;
    extern __FAR__ Uint32 PRU0_CODE_START, PRU0_CODE_SIZE;
    
    extern __FAR__ Uint32 PRU1_DATA_START, PRU1_DATA_SIZE;
    extern __FAR__ Uint32 PRU1_INST_START, PRU1_INST_SIZE;
    
    extern __FAR__ Uint32 ARM_VECT_START,   ARM_VECT_SIZE;
    #endif
    
    
    /************************************************************
    * Local Macro Declarations                                  *
    ************************************************************/
    
    
    /************************************************************
    * Local Typedef Declarations                                *
    ************************************************************/
    
    
    /************************************************************
    * Local Function Declarations                               *
    ************************************************************/
    
    static inline Uint8 LOCAL_getOPP(void);
    
    #if (defined(DA850) || defined(C6746))
    static void LOCAL_initARMVectors (const Uint32 *armVectors);
    static void LOCAL_wakeUpARM ( void );
    #endif
    
    /************************************************************
    * Local Variable Definitions                                *
    ************************************************************/
    
    #if (defined(DA850) || defined(C6746))
    /* This array contains the PDSP instructions in a C array which are to  */
    /* be downloaded from the host CPU to the PDSP instruction memory.      */
    /* This array is generated by the PDSP assembler.                       */
    static const Uint32 LOCAL_pru_mem1d_transfer[] = 
    {
        0x9100a387,
        0x5100e90a,
        0x24002000,
        0xff00c70e,
        0xef00c80e,
        0x0400e9e9,
        0x0000e7e7,
        0x0000e8e8,
        0x8100a387,
        0x5100e902,
        0x7f0000f8,
        0x2a000000
    };
    
    static const far Uint32 LOCAL_arm_idle_vectors[] =
    {
      	0xeafffffe,
      	0xeafffffd,
      	0xeafffffc,
      	0xeafffffb,
      	0xeafffffa,
      	0xeafffff9,
      	0xeafffff8,
      	0xeafffff7
    };
    #endif
    
    
    static const Uint8 LOCAL_bootModeLUT[] = 
    {                                   // BOOT[7..0]
      DEVICE_BOOTMODE_I2C0_MASTER,      // 0x0000 0000
      DEVICE_BOOTMODE_I2C0_SLAVE,       // 0x0000 0001
      DEVICE_BOOTMODE_NOR_EMIFA,        // 0x0000 0010
      DEVICE_BOOTMODE_NOR_EMIFA,        // 0x0000 0011
      DEVICE_BOOTMODE_UHPI,             // 0x0000 0100
      DEVICE_BOOTMODE_UHPI,             // 0x0000 0101
      DEVICE_BOOTMODE_I2C1_MASTER,      // 0x0000 0110
      DEVICE_BOOTMODE_I2C1_SLAVE,       // 0x0000 0111
      DEVICE_BOOTMODE_SPI0_EEPROM,      // 0x0000 1000
      DEVICE_BOOTMODE_SPI1_EEPROM,      // 0x0000 1001
      DEVICE_BOOTMODE_SPI0_FLASH,       // 0x0000 1010
      DEVICE_BOOTMODE_SPI0_FLASH,       // 0x0000 1011
      DEVICE_BOOTMODE_SPI1_FLASH,       // 0x0000 1100
      DEVICE_BOOTMODE_SPI1_FLASH,       // 0x0000 1101
      DEVICE_BOOTMODE_NAND_EMIFA_8BIT,  // 0x0000 1110 
      DEVICE_BOOTMODE_NAND_EMIFA_8BIT,  // 0x0000 1111
      DEVICE_BOOTMODE_NAND_EMIFA_16BIT, // 0x0001 0000
      DEVICE_BOOTMODE_NONE,             // 0x0001 0001
      DEVICE_BOOTMODE_SPI0_SLAVE,       // 0x0001 0010
      DEVICE_BOOTMODE_SPI1_SLAVE,       // 0x0001 0011
      DEVICE_BOOTMODE_UART2,            // 0x0001 0100
      DEVICE_BOOTMODE_THB,              // 0x0001 0101
      DEVICE_BOOTMODE_UART0,            // 0x0001 0110
      DEVICE_BOOTMODE_UART1,            // 0x0001 0111
      DEVICE_BOOTMODE_ESF,              // 0x0001 1000
      DEVICE_BOOTMODE_ESF,              // 0x0001 1001
      DEVICE_BOOTMODE_USB11,            // 0x0001 1010
      DEVICE_BOOTMODE_USB20,            // 0x0001 1011
      DEVICE_BOOTMODE_SDMMC0,           // 0x0001 1100
      DEVICE_BOOTMODE_SDMMC1,           // 0x0001 1101
      DEVICE_BOOTMODE_EMU_DEBUG,        // 0x0001 1110
      DEVICE_BOOTMODE_NONE,             // 0x0001 1111
    };
    
    
    /************************************************************
    * Global Variable Definitions                               *
    ************************************************************/
    
    #if defined(OMAPL138)
      const char devString[] = "OMAP-L138";
    #elif defined(OMAPL138_LCDK)
      const char devString[] = "OMAP-L138 LCDK";
    #elif defined(AM1808)
      const char devString[] = "AM1808";
    #elif defined(AM1810)
      const char devString[] = "AM1810";  
    #elif defined(C6748)
      const char devString[] = "C6748";
    #elif defined(C6748_LCDK)
      const char devString[] = "C6748 LCDK";
    #elif defined(C6746)  
      const char devString[] = "C6746";
    #else
      const char devString[] = "OMAP-L138";
    #endif  
    
    //DEVICE_OperatingPoint gDeviceOpPoint;
    
    
    /************************************************************
    * Global Function Definitions                               *
    ************************************************************/
    
    Uint32 DEVICE_init()
    {
      Uint32 status = E_PASS;
      
      // Ensure the kick registers are unlocked 
      // Note these lines have no effect on 2.0 and later silicon
      DEVICE_kickLock();
      DEVICE_kickUnlock();
      
      SYSTEM->SUSPSRC &= ( (1 << 27) | (1 << 22) | (1 << 20) | (1 << 5) | (1 << 16));
    
    #ifndef SKIP_LOW_LEVEL_INIT
      // System PSC Setup
      DEVICE_PSCInit();
    
      // System PLL Setup
      if (status == E_PASS)
      {
      #if defined(AM1808)
        // CPU(s) at 456 MHz
        status |= DEVICE_PLL0Init(0, 18, 0, 0, 0, 18, 8);
      #else
        // CPU(s) at 300 MHz
        status |= DEVICE_PLL0Init(0, 24, 0, 1, 0, 11, 5);
      #endif  
      }
      
      if (status == E_PASS)
      {
        // mDDR @ 150MHz
        status |= DEVICE_PLL1Init(24, 1, 0, 1, 2);
      }
      
      // External Memory Timing Setup
      if (status == E_PASS)
      {
    	#if defined(AM1810)
          // Timings for DDR2 at 150 MHz
          status |= DEVICE_ExternalMemInit(0x00000047, 0x08934832, 0x204929C9, 0x0C12C722, 0x00000406, 0x00000000);
        #elif defined(OMAPL138_LCDK)
          // Timings for DDR2 at 150 MHz
          //status |= DEVICE_ExternalMemInit(0x000000C5, 0x00134832, 0x264A3209, 0x3C14C722, 0x00000492, 0x00000000);
    	status |= DEVICE_ExternalMemInit(0x000000C6, 0x00134A21, 0x1E923209, 0x3C11C722, 0x00000492, 0x00000000);
    	#elif defined(C6748_LCDK)
          // Timings for DDR2 at 150 MHz
          status |= DEVICE_ExternalMemInit(0x000000C5, 0x00134832, 0x264A3209, 0x3C14C722, 0x00000492, 0x00000000);
        #else
          // Timings for mDDR at 150 MHz
          status |= DEVICE_ExternalMemInit(0x000000C4, 0x0A034622, 0x1C912A08, 0x3811C700, 0x00000494, 0x00000000);
    	#endif
      }
    #endif
    
    #if (defined(DA850) || defined(C6746))
      LOCAL_initARMVectors((Uint32 *) &(LOCAL_arm_idle_vectors[0]));
    
      LOCAL_wakeUpARM();
      
      while(1);
    #endif
    
      return status;
    }
    
    DEVICE_ChipRevIDType DEVICE_chipRevIDType( )
    {
      // The code used by the actual ROM boot loader
      Uint32 chipType = (SYSTEM->CHIPREVID & DEVICE_CHIPREVID_TYPE_MASK) >> DEVICE_CHIPREVID_TYPE_SHIFT;
      return ((DEVICE_ChipRevIDType)chipType);
    }
    
    void DEVICE_LPSCTransition(Uint8 pscnum, Uint8 module, Uint8 domain, Uint8 state)
    {
      DEVICE_PSCRegs *PSC;
      
      if (pscnum == PSCNUM0)
        PSC = PSC0;
      else if(pscnum == PSCNUM1)
        PSC = PSC1;
      else
        return; 
    
      // Wait for any outstanding transition to complete
      while ( (PSC->PTSTAT) & (0x00000001 << domain) );
      
      // If we are already in that state, just return
      if (((PSC->MDSTAT[module]) & 0x1F) == state) return;
        
      // Perform transition
      PSC->MDCTL[module] = ((PSC->MDCTL[module]) & (0xFFFFFFE0)) | (state);
      PSC->PTCMD |= (0x00000001 << domain);
    
      // Wait for transition to complete
      while ( (PSC->PTSTAT) & (0x00000001 << domain) );
      
      // Wait and verify the state
      while (((PSC->MDSTAT[module]) & 0x1F) != state);
    }
    
    void DEVICE_pinmuxControl(Uint32 regOffset, Uint32 mask, Uint32 value)
    {
      SYSTEM->PINMUX[regOffset] = (SYSTEM->PINMUX[regOffset] & ~mask) | (mask & value);
    }
    
    void DEVICE_PSCInit()
    {                                                                    
      Uint32 i;
      
      // PSC0, domain 0 init
      while ((PSC0->PTSTAT) & 0x00000001);
    
      // LPSC_EDMA_CC0 through LPSC_ARM_RAMROM
      for( i = 0 ; i <= 7 ; i++ )
        PSC0->MDCTL[i] = (PSC0->MDCTL[i] & 0xFFFFFFE0) | PSC_ENABLE;
    
      // LPSC_UART0 through LPSC_SCR2
      for( i = 9 ; i <= 12 ; i++ )
        PSC0->MDCTL[i] = (PSC0->MDCTL[i] & 0xFFFFFFE0) | PSC_ENABLE;
        
      // Do Always-On Power Domain Transitions
      PSC0->PTCMD |= 0x00000001;
      while ((PSC0->PTSTAT) & 0x00000001);
      
      // PSC1, domain 1 init
      while ((PSC1->PTSTAT) & 0x00000001);
    
      // LPSC_EDMA_CC1 through LPSC_EDMA_CC1
      for( i = 0 ; i <= 0 ; i++ )
        PSC1->MDCTL[i] = (PSC1->MDCTL[i] & 0xFFFFFFE0) | PSC_ENABLE;
      
      // LPSC_GPIO through LPSC_EMAC
      for( i = 3 ; i <= 7 ; i++ )
        PSC1->MDCTL[i] = (PSC1->MDCTL[i] & 0xFFFFFFE0) | PSC_ENABLE;
    
      // LPSC_VPIF through LPSC_TPTC2
      for( i = 9 ; i <= 21 ; i++ )
        PSC1->MDCTL[i] = (PSC1->MDCTL[i] & 0xFFFFFFE0) | PSC_ENABLE;
      
      // LPSC_L3CBA through LPSC_L3CBA
      for( i = 31 ; i <= 31 ; i++ )
        PSC1->MDCTL[i] = (PSC1->MDCTL[i] & 0xFFFFFFE0) | PSC_ENABLE;
        
      // Do Always-On Power Domain Transitions
      PSC1->PTCMD |= 0x00000001;
      while ((PSC1->PTSTAT) & 0x00000001);
    }
    
    void DEVICE_kickUnlock(void)
    {
      SYSTEM->KICKR[0] = 0x83e70b13;  // Kick0 register + data (unlock)
      SYSTEM->KICKR[1] = 0x95a4f1e0;  // Kick1 register + data (unlock)
    }
    
    void DEVICE_kickLock( void )
    {
      SYSTEM->KICKR[0] = 0x00000000;  // Kick0 register + data (lock)
      SYSTEM->KICKR[1] = 0x00000000;  // Kick0 register + data (lock)
    }
    
    DEVICE_BootPeripheral DEVICE_bootPeripheral( void )
    {
      DEVICE_BootPeripheral bp;
      DEVICE_BootMode bm = DEVICE_bootMode();
      switch (bm)
      {
        case DEVICE_BOOTMODE_SPI0_EEPROM:
        case DEVICE_BOOTMODE_SPI1_EEPROM:
        case DEVICE_BOOTMODE_SPI0_FLASH:
        case DEVICE_BOOTMODE_SPI1_FLASH:
          bp = DEVICE_BOOTPERIPHERAL_SPI;
          break;
        case DEVICE_BOOTMODE_I2C0_MASTER:
        case DEVICE_BOOTMODE_I2C0_SLAVE:
        case DEVICE_BOOTMODE_I2C1_MASTER:
        case DEVICE_BOOTMODE_I2C1_SLAVE: 
          bp = DEVICE_BOOTPERIPHERAL_I2C;
          break;
        case DEVICE_BOOTMODE_NAND_EMIFA_8BIT:
        case DEVICE_BOOTMODE_NAND_EMIFA_16BIT:
          bp = DEVICE_BOOTPERIPHERAL_NAND;
          break;
        case DEVICE_BOOTMODE_UART0:
        case DEVICE_BOOTMODE_UART1:
        case DEVICE_BOOTMODE_UART2:
          bp = DEVICE_BOOTPERIPHERAL_UART;
          break;
        case DEVICE_BOOTMODE_NOR_EMIFA:
          bp = DEVICE_BOOTPERIPHERAL_NOR;
          break;
        case DEVICE_BOOTMODE_SDMMC0:
        case DEVICE_BOOTMODE_SDMMC1:
          bp = DEVICE_BOOTPERIPHERAL_SDMMC;
          break;
        default:
          bp = DEVICE_BOOTPERIPHERAL_NONE;
          break;
      }
      
      return bp;
    }
    
    DEVICE_BootMode DEVICE_bootMode( void )
    {
      Uint8 i;
    
      // Read BOOT pins and set bootMode using a look-up table
      i = (SYSTEM->BOOTCFG & DEVICE_BOOTCFG_BOOTMODE_MASK) >> DEVICE_BOOTCFG_BOOTMODE_SHIFT;
    
      // Bit sequence used for LUT is 4,3,2,1,0
      i &= 0x1F;
    
      return ((DEVICE_BootMode)LOCAL_bootModeLUT[i]);
    }
    
    DEVICE_BusWidth DEVICE_emifBusWidth( void )
    {
      if (DEVICE_bootMode() == DEVICE_BOOTMODE_NAND_EMIFA_8BIT)
      {
        return DEVICE_BUSWIDTH_8BIT;
      }
      else
      {
        return DEVICE_BUSWIDTH_16BIT;
      }
    }
    
    
    Uint32 DEVICE_PLL0Init(Uint8 clk_src, Uint8 pllm, Uint8 prediv, Uint8 postdiv, Uint8 div1 ,Uint8 div3, Uint8 div7)
    {
      // Note:  PLL0_SYSCLK1 - Not used on Freon subchip, fixed divider (/1) - allow to change div1 
      //        PLL0_SYSCLK2 - Used on Freon subchip, but it has a fixed divider ratio to SYSCLK1(/2) - should be used for sc ASYNC3 domain 
      //                       to simplify clock management for peripherals during the ROM boot loader CFGCHIP3[ASYNC3_CLKSRC] - configure with div1
      //        PLL0_SYSCLK3 - Variable Divider, not used on Freon subchip, but ASYNC1 (EMIFA) on matrix - treat same as in Primus (configure)
      //        PLL0_SYSCLK4 - Used on Freon subchip, but it has a fixed ratio to div1 (/4) - configure with div1
      //        PLL0_SYSCLK5 - Variable divider, not used on Freon subchip - do nothing
      //        PLL0_SYSCLK6 - Not used on Freon subchip, fixed ratio to div1 (/1) - configure with div1
      //        PLL0_SYSCLK7 - Variable divider, is used on Freon subchip (Test, RMII, possibly USB 1.1) - treat the same as on Primus (configure)
      //        PLL0_SYSCLK8 - Variable divider, not used on Freon subchip - treat same as in Primus (do nothing)
      //        PLL0_SYSCLK9 - Variable divider, used on Freon subchip (test) - treat same as in Primus (do nothing)
      //        DIV4p5CLOCK  - Not used on Freon, can be used in in EMIFA on matrix - treat same as in Primus - configure in EMIF setups, not here
      
      // Clear PLL lock bit
      SYSTEM->CFGCHIP[0] &= ~(DEVICE_CFGCHIP0_PLL0MASTERLOCK_MASK);
      
      // Set PLLENSRC '0',bit 5, PLL Enable(PLLEN) selection is controlled through MMR
      PLL0->PLLCTL &= ~DEVICE_PLLCTL_PLLENSRC_MASK;
    
      // PLLCTL.EXTCLKSRC bit 9 should be left at 0 for Freon
      PLL0->PLLCTL &= ~DEVICE_PLLCTL_EXTCLKSRC_MASK;
    
      // Set PLLEN=0 to put in bypass mode
      PLL0->PLLCTL &= ~DEVICE_PLLCTL_PLLEN_MASK;
    
      // Wait for 4 cycles to allow PLLEN mux switches properly to bypass clock
      UTIL_waitLoopAccurate (4);
    
      // Select the Clock Mode bit 8 as External Clock or On Chip Oscilator
      PLL0->PLLCTL &= 0xFFFFFEFF;
      PLL0->PLLCTL |= (clk_src << 8);
    
      // Clear PLLRST bit to reset the PLL
      PLL0->PLLCTL &= ~DEVICE_PLLCTL_PLLRST_MASK;
    
      // Disable the PLL output
      PLL0->PLLCTL |= DEVICE_PLLCTL_PLLDIS_MASK;
    
      // PLL initialization sequence
      // Power up the PLL by setting PWRDN bit set to 0
      PLL0->PLLCTL &= ~DEVICE_PLLCTL_PLLPWRDN_MASK;
    
      // Enable the PLL output
      PLL0->PLLCTL &= ~DEVICE_PLLCTL_PLLDIS_MASK;
    
      // FIXME - how long?: Wait for the PLLs to stabilize - see PLL spec/datasheet
      UTIL_waitLoopAccurate (2000);
    
      // Program the required multiplier value in PLLM
      PLL0->PLLM = pllm;
    
      // Prediv setup
      PLL0->PREDIV = DEVICE_PLLDIV_EN_MASK | prediv;
    
      // If desired to scale all the SYSCLK frequencies of a given PLLC, program the POSTDIV ratio
      PLL0->POSTDIV = DEVICE_PLLDIV_EN_MASK | 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 & DEVICE_PLLSTAT_GOSTAT_MASK);
    
      // 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 = DEVICE_PLLDIV_EN_MASK | div1;
      PLL0->PLLDIV2 = DEVICE_PLLDIV_EN_MASK | (((div1+1)*2)-1);
      PLL0->PLLDIV4 = DEVICE_PLLDIV_EN_MASK | (((div1+1)*4)-1);
      PLL0->PLLDIV6 = DEVICE_PLLDIV_EN_MASK | div1;
      PLL0->PLLDIV3 = DEVICE_PLLDIV_EN_MASK | div3;
      PLL0->PLLDIV7 = DEVICE_PLLDIV_EN_MASK | div7;
    
      // Set the GOSET bit in PLLCMD to 1 to initiate a new divider transition
      PLL0->PLLCMD |= DEVICE_PLLCMD_GOSET_MASK;
    
      // Wait for the GOSTAT bit in PLLSTAT to clear to 0 (completion of phase alignment)
      while (PLL0->PLLSTAT & DEVICE_PLLSTAT_GOSTAT_MASK);
    
      // FIXME: how long? Wait for PLL to reset - see PLL spec/datasheet
      UTIL_waitLoopAccurate (200);
    
      // Set the PLLRST bit in PLLCTL to 1 to bring the PLL out of reset
      PLL0->PLLCTL |= DEVICE_PLLCTL_PLLRST_MASK;
    
      // Wait for PLL to lock. See PLL spec for PLL lock time
      UTIL_waitLoopAccurate (2000);
    
      // Set the PLLEN bit in PLLCTL to 1 to remove the PLL from bypass mode
      PLL0->PLLCTL |= DEVICE_PLLCTL_PLLEN_MASK;
    
      // SET PLL lock bit
      SYSTEM->CFGCHIP[0] |= (0x1 << DEVICE_CFGCHIP0_PLL0MASTERLOCK_SHIFT) & DEVICE_CFGCHIP0_PLL0MASTERLOCK_MASK;
    
      return E_PASS;
    }
    
    Uint32 DEVICE_PLL1Init( Uint8 pllm, Uint8 postdiv, Uint8 div1, Uint8 div2, Uint8 div3 )
    { 
      // Clear PLL lock bit
      SYSTEM->CFGCHIP[3] &= ~(DEVICE_CFGCHIP3_PLL1MASTERLOCK_MASK);
    
      // Set PLLENSRC '0',bit 5, PLL Enable(PLLEN) selection is controlled through MMR
      PLL1->PLLCTL &= ~DEVICE_PLLCTL_PLLENSRC_MASK;
    
      // PLLCTL.EXTCLKSRC bit 9 should be left at 0 for Freon
      PLL1->PLLCTL &= ~DEVICE_PLLCTL_EXTCLKSRC_MASK;
    
      // Set PLLEN=0 to put in bypass mode
      PLL1->PLLCTL &= ~DEVICE_PLLCTL_PLLEN_MASK;
    
      // wait for 4 cycles to allow PLLEN mux switches properly to bypass clock
      UTIL_waitLoopAccurate (4);
    
      // Clear PLLRST bit to reset the PLL
      PLL1->PLLCTL &= ~DEVICE_PLLCTL_PLLRST_MASK;
    
      // Disable the PLL output
      PLL1->PLLCTL |= DEVICE_PLLCTL_PLLDIS_MASK;
    
      // PLL initialization sequence
      // Power up the PLL by setting PWRDN bit set to 0
      PLL1->PLLCTL &= ~DEVICE_PLLCTL_PLLPWRDN_MASK;
    
      // Enable the PLL output
      PLL1->PLLCTL &= ~DEVICE_PLLCTL_PLLDIS_MASK;
    
      // FIXME - how long?: Wait for the PLLs to stabilize - see PLL spec/datasheet
      UTIL_waitLoopAccurate (2000);
    
      // 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 = DEVICE_PLLDIV_EN_MASK | 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 & DEVICE_PLLSTAT_GOSTAT_MASK);
    
      // Program the RATIO field in PLLDIVx with the desired divide factors
      PLL1->PLLDIV1 = DEVICE_PLLDIV_EN_MASK | div1;
      PLL1->PLLDIV2 = DEVICE_PLLDIV_EN_MASK | div2;
      PLL1->PLLDIV3 = DEVICE_PLLDIV_EN_MASK | div3;
    
      // Set the GOSET bit in PLLCMD to 1 to initiate a new divider transition
      PLL1->PLLCMD |= DEVICE_PLLCMD_GOSET_MASK;
    
      // Wait for the GOSTAT bit in PLLSTAT to clear to 0 (completion of phase alignment)
      while (PLL1->PLLSTAT & DEVICE_PLLSTAT_GOSTAT_MASK);
    
      // FIXME: how long? Wait for PLL to reset - see PLL spec/datasheet
      UTIL_waitLoopAccurate (200);
    
      // Set the PLLRST bit in PLLCTL to 1 to bring the PLL out of reset
      PLL1->PLLCTL |= DEVICE_PLLCTL_PLLRST_MASK;
    
      // Wait for PLL to lock. See PLL spec for PLL lock time
      UTIL_waitLoopAccurate (2000);
    
      // Set the PLLEN bit in PLLCTL to 1 to remove the PLL from bypass mode
      PLL1->PLLCTL |= DEVICE_PLLCTL_PLLEN_MASK;
    
      // SET PLL lock bit
      SYSTEM->CFGCHIP[3] |= (0x1 << DEVICE_CFGCHIP3_PLL1MASTERLOCK_SHIFT) & DEVICE_CFGCHIP3_PLL1MASTERLOCK_MASK;
    
      return E_PASS;
    }
    
    Uint32 DEVICE_ExternalMemInit(Uint32 ddrphycr, Uint32 sdcr, Uint32 sdtimr, Uint32 sdtimr2, Uint32 sdrcr, Uint32 sdcr2)
    {
      VUint32 data_tmp;
      VUint32 *DDRStart = (VUint32 *) &EXTERNAL_RAM_START;
    
      // Set the DDR2 to enable                                          
      DEVICE_LPSCTransition(PSCNUM1, LPSC_EMIFB, PD0, PSC_ENABLE);
    
      if (SUBCHIPCFG->VTPIO_CTL & 0x00000040)
      {
        // Begin VTP Calibration
        SUBCHIPCFG->VTPIO_CTL |= DEVICE_VTPIO_CTL_IOPWRDN_MASK;     // Set IOPWRDN bit to enable input buffer powerdown enable mode
        SUBCHIPCFG->VTPIO_CTL &= ~(DEVICE_VTPIO_CTL_POWERDN_MASK);  // Clear POWERDN bit (enable VTP)
    
        // Pulse (low) CLRZ to initiate VTP IO Calibration
        SUBCHIPCFG->VTPIO_CTL |= DEVICE_VTPIO_CTL_CLKRZ_MASK;       // Set CLRZ bit 
        SUBCHIPCFG->VTPIO_CTL &= ~(DEVICE_VTPIO_CTL_CLKRZ_MASK);    // Clear CLRZ bit (CLRZ should be low for at least 2ns)
        SUBCHIPCFG->VTPIO_CTL |= DEVICE_VTPIO_CTL_CLKRZ_MASK;       // Set CLRZ bit 
    
        // Polling READY bit to see when VTP calibration is done
        while(!((SUBCHIPCFG->VTPIO_CTL & DEVICE_VTPIO_CTL_READY_MASK)>>DEVICE_VTPIO_CTL_READY_SHIFT)); 
    
        SUBCHIPCFG->VTPIO_CTL |= DEVICE_VTPIO_CTL_LOCK_MASK;        // Set LOCK bit for static mode
        SUBCHIPCFG->VTPIO_CTL |= DEVICE_VTPIO_CTL_PWRSAVE_MASK;     // Set PWRSAVE bit to save power              
        // End VTP Calibration
      }
    
      // Config DDR timings
      EMIF3A->DDRPHYC1R   = ddrphycr;
    
      // Clear the unlock bits (in case user accidentally set them)
      sdcr = sdcr & (~DEVICE_SDCR_BOOTUNLOCK_MASK) & (~DEVICE_SDCR_TIMUNLOCK_MASK);
      
      // Set SDCR with BOOTUNLOCK Set and TIMUNLOCK cleared
      EMIF3A->SDCR        = sdcr | ((0x1 << DEVICE_SDCR_BOOTUNLOCK_SHIFT) & DEVICE_SDCR_BOOTUNLOCK_MASK);
      // Set SDCR with BOOTUNLOCK cleared and TIMUNLOCK set
      EMIF3A->SDCR        = sdcr | ((0x1 << DEVICE_SDCR_TIMUNLOCK_SHIFT) & DEVICE_SDCR_TIMUNLOCK_MASK);
      
      // Check if this init is for mDDR
      if (sdcr & DEVICE_SDCR_MSDRAMEN_MASK)
      {
        // If it is, set SDCR2 with PASR and ROWSIZE PARAMS
        EMIF3A->SDCR2     = sdcr2;
      }
                            
      EMIF3A->SDTIMR      = sdtimr;
      EMIF3A->SDTIMR2     = sdtimr2;
    
      // Clear TIMUNLOCK bit
      EMIF3A->SDCR        &= (~DEVICE_SDCR_TIMUNLOCK_MASK); 
      EMIF3A->SDRCR       = sdrcr;
    
      // Set the DDR2 to syncreset
      EMIF3A->SDRCR |= 0xC0000000;  // Set to self-refresh, enable mclkstop
      DEVICE_LPSCTransition(PSCNUM1, LPSC_EMIFB, PD0, PSC_SYNCRESET);
    
      // Set the DDR2 to enable
      DEVICE_LPSCTransition(PSCNUM1, LPSC_EMIFB, PD0, PSC_ENABLE);
      EMIF3A->SDRCR &= ~(0xC0000000);  // disable self-refresh
    
      // Dummy write/read to apply timing settings
      *DDRStart = 0xA55AA55A;               // write
      data_tmp = *DDRStart;                 // read
      *DDRStart = data_tmp;
    
      return E_PASS;                                                              
    }
    
    Uint32 DEVICE_AsyncMemInit (Uint8 interfaceNum)
    {
      if (interfaceNum == 0)
      {
        // Turn on the EMIF LPSC
        DEVICE_LPSCTransition(PSCNUM0, LPSC_EMIFA, PD0, PSC_ENABLE);
    
        // Set PINMUX for EMIF use
        DEVICE_pinmuxControl(5 ,0xFF000000,0x11000000); // EMA_BA[1],EMA_BA[0]
        DEVICE_pinmuxControl(7 ,0xF0FFFFFF,0x00111111); // EMA_WAIT[0], nEMA_WE, nEMA_OE, nEMA_CS[2], nEMA_CS[3], nEMA_CS[4], nEMA_CS[5]
        DEVICE_pinmuxControl(8 ,0xFFFFFFFF,0x11111111); // EMA_D[15:8]
        DEVICE_pinmuxControl(9 ,0xFFFFFFFF,0x11111111); // EMA_D[7:0]
        DEVICE_pinmuxControl(10,0xFFFFFFFF,0x11111111); // EMA_A[23..16]
        DEVICE_pinmuxControl(11,0xFFFFFFFF,0x11111111); // EMA_A[15..8]
        DEVICE_pinmuxControl(12,0xFFFFFFFF,0x11111111); // EMA_A[7..0]
    
      }
      else
      {
        return E_FAIL;
      }
    
      return E_PASS;
    }
    
    // Device-level SPI initialization
    Uint32 DEVICE_SPIInit(Uint8 periphNum)
    {
      if (periphNum >= SPI_PERIPHERAL_CNT)
      {
        return E_FAIL;
      }
    
      switch (periphNum)
      {
        case 0:
          DEVICE_LPSCTransition(PSCNUM0, LPSC_SPI0, PD0, PSC_ENABLE);
          DEVICE_pinmuxControl(3,0x0000FF0F,0x00001101); // SPI0_CLK, SPI0_SIMO, SPI0_SOMI
          DEVICE_pinmuxControl(4,0x000000F0,0x00000010); // nSPI0_SCS[0]
          break;
        case 1:
          DEVICE_LPSCTransition(PSCNUM1, LPSC_SPI1, PD0, PSC_ENABLE);
          DEVICE_pinmuxControl(5,0x00FF0FF0,0x00110110); // nSPI1_SCS[0], SPI1_CLK, SPI1_SIMO, SPI1_SOMI
          break;
        default:
          return E_FAIL;
      }
      
      return E_PASS;
    }
    
    // Device-level UART initialization
    Uint32 DEVICE_UARTInit(Uint8 periphNum)
    {
      switch (periphNum)
      {
        case 0:
          DEVICE_LPSCTransition(PSCNUM0, LPSC_UART0, PD0, PSC_ENABLE);
          DEVICE_pinmuxControl(3,0x00FF0000,0x00220000); // UART0_TXD, UART0_RXD
          break;
        case 1:
          DEVICE_LPSCTransition(PSCNUM1, LPSC_UART1, PD0, PSC_ENABLE);
          DEVICE_pinmuxControl(4,0xFF000000,0x22000000); // UART1_TXD, UART1_RXD
          break;
        case 2:
          DEVICE_LPSCTransition(PSCNUM1, LPSC_UART2, PD0, PSC_ENABLE);
          DEVICE_pinmuxControl(4,0x00FF0000,0x00220000); // UART2_TXD, UART2_RXD
          break;
        default:
          return E_FAIL;
      }
    
      return E_PASS;
    }
    
    // Device-level I2C init
    Uint32 DEVICE_I2CInit(Uint8 periphNum)
    {
      // Assign the correct register base
      if (periphNum >= I2C_PERIPHERAL_CNT)
      {
        return E_FAIL;
      }
        
      switch (periphNum)
      {
        case 0:
          // No LPSC for I2C0
          DEVICE_pinmuxControl(4,0x0000FF00,0x00002200); // I2C0_SCL, I2C0_SDA
          break;
        case 1:
          DEVICE_LPSCTransition(PSCNUM1, LPSC_I2C1, PD0, PSC_ENABLE);
          DEVICE_pinmuxControl(4,0x00FF0000,0x00440000); // I2C1_SDA, I2C1_SCL
          break;
        default:
          return E_FAIL;
      }
        
      return E_PASS;
    }
    
    Uint32 DEVICE_SDMMCInit(Uint8 periphNum)
    {
      // Assign the correct register base
      if (periphNum >= SDMMC_PERIPHERAL_CNT)
      {
        return E_FAIL;
      }
      
      switch (periphNum)
      {
        case 0:
          DEVICE_LPSCTransition(PSCNUM0, LPSC_SDMMC0, PD0, PSC_ENABLE);
          DEVICE_pinmuxControl(10,0xFFFFFFFF,0x22222222); // CLK, CMD, DAT[5:0]
          DEVICE_pinmuxControl(11,0x000000FF,0x00000022); // DAT[7:6]
          break;
        case 1:
          DEVICE_LPSCTransition(PSCNUM1, LPSC_SDMMC1, PD0, PSC_ENABLE);
          DEVICE_pinmuxControl(10,0xFF0FFF00,0x11022200); // CLK, CMD, DAT[7:6,0]
          DEVICE_pinmuxControl(11,0x000FFFFF,0x00022211); // DAT[5:1]
          break;
        default:
          return E_FAIL;
      }
    
      return E_PASS;
    }
    
    Uint32 DEVICE_TIMER0Init()
    {
      // Power-up the Timer
      //DEVICE_LPSCTransition(PSCNUM0, LPSC_TIMER0, PD0 ,PSC_ENABLE);
    
      // Put timer into reset
      //TIMER0->EMUMGT_CLKSPD = 0x00000003;
      //TIMER0->TCR   = 0x00000000;
      
      // Setup as 2 unchained 32-bit timers
      //TIMER0->TGCR  = 0x00000005;
    
      // Reset timers to zero 
      //TIMER0->TIM12 = 0x00000000;
    
      // Set period to 5 sec
      //TIMER0->PRD12 = 0x019BFCC0;
    
      return E_PASS;
    }
    
    void DEVICE_TIMER0Start(void)
    {
      // Clear interrupt
      //AINTC->IRQ1   |=  0x00000001;
    
      // Put timer out in reset
      //TIMER0->TGCR  &= ~(0x00000001);
        
      // Reset the timer counter to zero
      //TIMER0->TIM12 = 0x00000000;
    
      // Set for one-time run
      //TIMER0->TCR   = 0x00000040;
        
      // Take timer out of reset
      //TIMER0->TGCR  = 0x00000005;
      
    }
    
    void DEVICE_TIMER0Stop(void)
    {
      // Clear interrupt
      //AINTC->IRQ1   |=  0x00000001;
    
      // Put timer in reset
      //TIMER0->TCR   = 0x00000000;
      //TIMER0->TGCR  = 0x00000000;
    
      // Reset timer count to zero 
      //TIMER0->TIM12 = 0x00000000;
    }
    
    Uint32 DEVICE_TIMER0Status(void)
    {
      //return ((AINTC->IRQ1)&0x1);
    	return 1;
    }
    
    
    /************************************************************
    * Local Function Definitions                                *
    ************************************************************/
    
    #if (defined(DA850) || defined(C6746))
    
    static void LOCAL_initARMVectors (const Uint32 *armVectors)
    {
      Uint32 *PRUDRam = (Uint32 *) &PRU0_DATA_START;
    
      PRU_enable();
      
      // Wake up the ARM memories
      DEVICE_LPSCTransition(PSCNUM0, LPSC_ARMRAM, PD0, PSC_ENABLE);
    
      // Make the address the global GEM address (prepend 0x11 to top two nibbles)
      // since the PRU cannot access stuff using local GEM address
      PRUDRam[0] = ((Uint32) armVectors)& 0x00FFFFFF | 0x11000000 ;
      PRUDRam[1] = (Uint32) (&ARM_VECT_START);
      PRUDRam[2] = (Uint32) (&ARM_VECT_SIZE);
    
      // Load PRU code
      PRU_load( (Uint32*)LOCAL_pru_mem1d_transfer, (sizeof(LOCAL_pru_mem1d_transfer)>>2));
      
      PRU_run();
      
      PRU_waitForHalt(-1);
      
      PRU_disable();
    }
    
    static void LOCAL_wakeUpARM ( void )
    {
      // Wake-up ARM
      SYSTEM->HOSTCFG[0] = 0x00000001;
      DEVICE_LPSCTransition(PSCNUM0, LPSC_ARMINTC, PD0, PSC_ENABLE);
      DEVICE_LPSCTransition(PSCNUM0, LPSC_ARM, PD0, PSC_ENABLE);
    
      // De-assert ARM local reset
      PSC0->MDCTL[LPSC_ARM] = (PSC0->MDCTL[LPSC_ARM] & (~PSC_MDCTL_LRSTZ_MASK)) | (0x01 << PSC_MDCTL_LRSTZ_SHIFT);
    }
    
    #endif  
    
    
    /***********************************************************
    * End file                                                 *
    ***********************************************************/
    
    

    Flash works now because I have modified device.c with function above.

    But when I reboot on NAND boot, I stop to :

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

    OMAP-L138 LCDK initialization passed!
    Booting TI User Boot Loader
            UBL Version: 1.65
            UBL Flashtype: NAND
    Starting NAND Copy...

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

    I think I have to rebuild UBOOT.

    Thank you

  • Hi,

    Please don't confuse me and don't change context what we are discussing,

    As of now, We are discussing the problem faced while flashed,

    Flash works now because I have modified device.c with function above.

    That is fixed right!

    them, What is the problem now?

    But when I reboot on NAND boot, I stop to :

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

    OMAP-L138 LCDK initialization passed!
    Booting TI User Boot Loader
            UBL Version: 1.65
            UBL Flashtype: NAND
    Starting NAND Copy...

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

    I think I have to rebuild UBOOT.

    Have you compiled the u-boot for your custom board?

    If not, please do it.

  • I'm changing Serial Driver info on omapl138_lcdk.h.

    What can I do in this file to change communication to UART1?

  • Hi,

    I'm changing Serial Driver info on omapl138_lcdk.h.

    What can I do in this file to change communication to UART1?

    For this issue(u-boot) , Please create new thread and close this thread if answered.

  • Hi,

    My purpose is to lauch UBOOT into target LCDK but I have to change number of UART for console from UART2 to UART1.


    I opened omapl138_lcdk.h file and I try to modify these "define" like this :

    - CONFIG_SYS_NS16555_COM1        DAVINCI_UART1_BASE

    - CONFIG_SYS_NS16555_CLK            clk_get(DAVINCI_UART2_CLKID)    I let this because    DAVINCI_UART1_CLKID doen't exist.

    - CONFIG_CONS_INDEX                       1. I don't know what I can put here

    Is it right? Is there another thing to do?

    Best regards

  • Hi Sebastien,

    Okay.

    My purpose is to lauch UBOOT into target LCDK but I have to change number of UART for console from UART2 to UART1.

    Please close this thread and create new thread for the new issue or requirement.

  • Sorry, I don't understand what you are saying me.

    What Thread?

    And where can I create new thread?

    Thanks

  • Hi Sebastien,

    Sorry, I thought that you know about threads/posts in ti e2e forums.

    I can understand this thread/post created by O'Mellin, that why, you don't know right !

    In generally, Community member (like you)  need to create new post for their issue.

    It is not a problem, please refer the link to know about TI forum website.

    http://e2e.ti.com/group/helpcentral/w/e2e/1156.04-how-to-post-a-new-question-on-e2e.aspx

    Create new post for your issue (u-boot) in the following link (OMAPL13x processors forums)  by clicking the "new post"  icon and describe your problem with "Subject" as "O'Mellin" did ( Serial Flasher tool OMAP L138 influence of "–targetType" argument)

    Heading Name : Change UART2 to UART1 in u-boot for OMAPL138 custom board.

    http://e2e.ti.com/support/dsp/omap_applications_processors/f/42.aspx

  • Hi O'Mellin,

    Please close this thread.