none
WinEC 7: Debug ENV variable RRS feed

  • Question

  • Hello,

    I need one environmet variable which I can recognize "debug" or "release" image. I like to use this variable in the BSP source code and bib files to query the image type. I tried to set my own BSP_DEBUG_IMAGE variable in BSP batch file by query WINCEDEBUG. But this doesn't work. I think that batch file runs before WINCEDEBUG is set.

    IF "%WINCEDEBUG%" == "debug" set BSP_DEBUG_IMAGE=1

    Does someone has an idea?

    Best regards,

    Andreas

    Thursday, November 22, 2012 2:50 PM

Answers

  • ok, but you can define (or not) "BSP_DEBUG_IMAGE=1" as an environment variable in your OS design, can't you?

    in your .bib files you can check for the variable like:

    IF BSP_DEBUG_IMAGE !
    <some settings>
    ELSE
    <some other settings>
    ENDIF ; BSP_DEBUG_IMAGE 

    In the source.cmn file of your BSP you can put:

    !IF "$(BSP_DEBUG_IMAGE)"=="1"
    CDEFINES=$(CDEFINES) -DBSP_DEBUG_IMAGE
    !ENDIF

    If your code you can finally have:

    #ifdef BSP_DEBUG_IMAGE
    //some code
    #else
    //some other code
    #endif

     


    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom www.eurotech.com Check my blog: http://lcalligaris.wordpress.com

    • Marked as answer by Andreas_1981 Tuesday, December 4, 2012 2:25 PM
    Friday, November 30, 2012 4:33 PM
  • It turns out that setting BSP_anything based on whether the system is built for debug is very difficult - so it will undoubtably by set wrong.  The BSP BAT file runs before WINCEDEBUG is set.

    But if you combine Luca's advice with the first question, you get:

    in sources.cmn:

    !IF "$(WINCEDEBUG)" == "debug"
    CDEFINES=$(CDEFINES) -DBSP_DEBUG_IMAGE
    !ENDIF

    And you can do this similarly in the bib file.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com

    • Marked as answer by Andreas_1981 Tuesday, December 4, 2012 2:25 PM
    Friday, November 30, 2012 5:49 PM
    Moderator

All replies

  • In the platform.reg file you may have, as an example:

    [HKEY_LOCAL_MACHINE\SOFTWARE\Andreas]
    IF IMGNODEBUGGER !
      "Image"="Release"
    ENDIF IMGNODEBUGGER
    IF IMGNODEBUGGER
      "Image"="Debug"
    ENDIF IMGNODEBUGGER
    When you create a debug image (or better when you enable/include the kernel debugger) you will have "Image"="Debug", otherwise you will have "Image"="Retail"

    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom www.eurotech.com Check my blog: http://lcalligaris.wordpress.com

    Thursday, November 22, 2012 2:58 PM
  • Thanks for you answer,

    but I don't have set IMGNODEBUGGER in my debug image. For debugging I use a JTAG debugger and I need the environment variable to query debug or retail information in the OEMinit() function. So I think I can't use the registry, because I don't have registry at this time.

    Do you have another idea?

    Best regards,

    Andreas

    Thursday, November 22, 2012 3:07 PM
  • In the MEMORY section of your BSP config.bib:

    IF BSP_DEBUG_IMAGE 
        nk.exe:dwOEMDebugImage        	00000000          1       FIXUPVAR
    ELSE
        nk.exe:dwOEMDebugImage    	00000000          0       FIXUPVAR
    ENDIF

    In your OAL code (maybe in your oeminit.c file) you need to define a global variable like this:

    DWORD dwOEMDebugImage = 0;
    More info here: http://msdn.microsoft.com/en-us/library/ee478653(v=winembedded.60).aspx

    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom www.eurotech.com Check my blog: http://lcalligaris.wordpress.com

    Thursday, November 22, 2012 3:36 PM
  • BSP_DEBUG_IMAGE is self-generated ENV variable which i like to set in BSP batch file. But I don't know how I could set this variable, because WINCEDEBUG (IF "%WINCEDEBUG%" == "debug" set BSP_DEBUG_IMAGE=1) doesn't work, because batch file runs before WINCEDEBUG is set.

    How can I set BSP_DEBUG_IMAGE in dependence of release and debug image in my BSP batch file?

    Thursday, November 22, 2012 3:46 PM
  • Hmm. Being here: since the above mentioned config.bib file is handled by romimage, try create a file named  <YOURBSP>-preri.bat in %_WINCEROOT%\PLATFORM\<YOURBSP>\FILES. The batch file (not tested obvioulsy) which will be run before romimage (see my post http://lcalligaris.wordpress.com/2010/11/04/customizing-windows-embedded-ce-6-0-makeimg-processing-using-batch-files/) and may look like:

    set BSP_DEBUG_IMAGE=
    if "%WINCEDEBUG%" == "debug" set BSP_DEBUG_IMAGE=1

    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom www.eurotech.com Check my blog: http://lcalligaris.wordpress.com

    Thursday, November 22, 2012 4:19 PM
  • Hi Luca,

    first of all thanks for your help.

    Sorry, but your proposal dosen't work in my case. If I use %_TGTPLAT%-preri.bat file the BSP_DEBUG_IMAGE variable isn't set in case of debug image.

    Here an exact description what I want to do actually:

    BSP_DEBUG_IMAGE is used in my case in a BSP config header file. This file contains address range defines and is included in source code and in the config.bib file to generate the memory section. So I need a possibility to change the address range defines depending on debug and release image.

    BSP_DEBUG_IMAGE is also used in source code to uncomment code which isn't used in debug case.

    Best Regards,

    Andreas

    Friday, November 23, 2012 8:33 AM
  • ok, but you can define (or not) "BSP_DEBUG_IMAGE=1" as an environment variable in your OS design, can't you?

    in your .bib files you can check for the variable like:

    IF BSP_DEBUG_IMAGE !
    <some settings>
    ELSE
    <some other settings>
    ENDIF ; BSP_DEBUG_IMAGE 

    In the source.cmn file of your BSP you can put:

    !IF "$(BSP_DEBUG_IMAGE)"=="1"
    CDEFINES=$(CDEFINES) -DBSP_DEBUG_IMAGE
    !ENDIF

    If your code you can finally have:

    #ifdef BSP_DEBUG_IMAGE
    //some code
    #else
    //some other code
    #endif

     


    Luca Calligaris lucaDOTcalligarisATeurotechDOTcom www.eurotech.com Check my blog: http://lcalligaris.wordpress.com

    • Marked as answer by Andreas_1981 Tuesday, December 4, 2012 2:25 PM
    Friday, November 30, 2012 4:33 PM
  • It turns out that setting BSP_anything based on whether the system is built for debug is very difficult - so it will undoubtably by set wrong.  The BSP BAT file runs before WINCEDEBUG is set.

    But if you combine Luca's advice with the first question, you get:

    in sources.cmn:

    !IF "$(WINCEDEBUG)" == "debug"
    CDEFINES=$(CDEFINES) -DBSP_DEBUG_IMAGE
    !ENDIF

    And you can do this similarly in the bib file.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com

    • Marked as answer by Andreas_1981 Tuesday, December 4, 2012 2:25 PM
    Friday, November 30, 2012 5:49 PM
    Moderator