Showing posts with label JTAG. Show all posts
Showing posts with label JTAG. Show all posts

Sunday, 9 November 2008

How to use Eclipse and GDB to debug the .NET Micro Framework

In my last post we were using GCC to build the .NET Micro Framework firmware for the i.MXS reference board. Now we go one step further and will debug the firmware using GDB.

What do we need?
First an overview of our setup:



The installation should be straight forward. Here are the configuration steps...
  • Open a command window, invoke setenv_gcc.cmd and run Eclipse from this initialized build environment.

  • Create a new C++ Project in Eclipse:

    File->New->C++ Project



    (I set the workspace to "C:\" and named the project like the installation directory of the porting kit "MicroFrameworkPK_v3_0".)

  • Configure Build:

    Project->Properties->C/C++ Build
    Add a new configuration e.g. "iMXS Debug RAM"
    Build command: msbuild.exe
    Build directory: ${workspace_loc:/MicroFrameworkPK_v3_0/Solutions/iMXS}



    Build (Incremental build): dotNetMF.proj /t:build /p:flavor=debug;memory=ram;platform=iMXS
    (This builds a debug version of the iMXS firmware that executes from RAM. To build a release version that executes from FLASH, don't add any additional arguments after dotNetMF.proj)


  • We add OpenOCD as an external tool:

    Run->External Tools->External Tools Configuration...
    Name: OpenOCD
    Location: C:\Program Files\openocd-r247\bin\openocd-ftd2xx.exe
    Working Directory: C:\Program Files\openocd-r247\bin\
    Arguments: -f imxs.cfg
    (For a sample imxs.cfg file look here.)



  • Finally we configure gdb:

    Run->Debug Configurations...
    Add "Zylin Embedded debug (native)" configuration
    Name: iMXS tinyclr
    C/C++ Application: C:\MicroFrameworkPK_v3_0\BuildOutput\ARM\GCC4.2\RAM\debug\iMXS\bin\tinyclr.axf



    GDB Debugger: C:\Programs\Raisonance\Ride\arm-gcc\bin\arm-none-eabi-gdb.exe



    Initialize commands:

    target remote 127.0.0.1:3333
    monitor reset
    monitor sleep 500
    monitor poll
    monitor soft_reset_halt
    monitor arm7_9 sw_bkpts enable

    break PreStackEntry
    load
    continue

    (This connects to the gdb server, enables software breakpoints, sets a breakpoint at the function PreStackEntry, loads the firmware into RAM and starts... )



  • Now we can settle back and only press some buttons...

    First we build a debug version that executes from RAM







    ...run our JTAG server OpenOCD






    ...and hit the debug button!
    Now it takes some seconds to transfer our debug firmware into the RAM of the i.MXS board.



    The firmware starts and immediately stops at PreStackEntry. Now we can discover the code line by line... :)




Read more! Post this to a friend!

Monday, 3 November 2008

.NET Micro Framework Porting Kit V3.0 with GCC Support?

Just a joke or what? The release notes of the recently released .NET Micro Framework Porting Kit V3.0 highlight the support for building the .NET MF firmware with GCC tools. It's hard to believe - so let's try it!
After installation of the porting kit I was looking for some information about the toolchain to use. The only hint I could find in the documentation is that GCC4.2 or later is supported for the ARM architecture. Frivolous as I am, I installed the first GNU ARM toolchain for Windows I found on the web. A few seconds later the build script ran and a lot of red output was flashing in the build window. Usually I like the red color but not in this case! ERRORS - wherever you look! Sure.. GCC support. Fortunately the cause was obvious. The toolchain I'd installed doesn't include a none EABI compiler, that was called by the build script. Due to the lack of information, I had to try several toolchains until I found the free ARM Tools from Raisonance, which finally worked :)

These are the three easy steps to build your home-made firmware:
  1. Start a command window
  2. Call setenv_gcc.cmd in the installation directory of the porting kit with the path of your toolchain to set up your build environment
    setenv_gcc.cmd C:\PROGRA~1\RAISON~1\Ride\arm-gcc
  3. Invoke MSBuild.exe with the command below in the directory of your platform solution
    msbuild dotNetMF.proj


E Voilá. We have built a release version of the .NET Micro Framework V3.0 firmware ready for flashing. How to do this? Take a look at this previous post :)

The following is just a reminder of the used OpenOCD commands for me, if I want to flash my i.MXS board again ;)

flash probe 0
flash erase 0 0 63
flash write_binary 0 C:\MicroFrameworkPK_v3_0\BuildOutput\ARM\GCC4.2\FLASH\release\iMXS\bin\TinyBooterDecompressor.bin 0x0
flash write_binary 0 C:\MicroFrameworkPK_v3_0\BuildOutput\ARM\GCC4.2\FLASH\release\iMXS\bin\tinyclr.bin\ER_CONFIG 0x40000
flash write_binary 0 C:\MicroFrameworkPK_v3_0\BuildOutput\ARM\GCC4.2\FLASH\release\iMXS\bin\tinyclr.bin\ER_FLASH 0x60000
flash write_binary 0 C:\MicroFrameworkPK_v3_0\BuildOutput\ARM\GCC4.2\FLASH\release\iMXS\bin\tinyclr.bin\ER_DAT 0x120000


The result looks like this:




Even the output of the deployment tool tells us V3.0. Now we could use Visual Studio to develop and deploy our real application with all the features of the new SDK.



Next time we'll visit the wonderful world of the gdb console and try to debug the whole thing. No, just kidding - we'll use a debugger with a graphical interface of course :)
Stay tuned!

Read more! Post this to a friend!