Friday, July 11, 2014

imx6 board-bringup: the need for JTAG

Recently I was working for a client and demo'd a Lauterbach for the imx6 solo SOC.  As anyone in the industry knows, the Lauterbach devices are top-notch, best in class, and come with a GUI that works on Ubuntu (though it is somewhat obfuscated) as well as Windows.  These are excellent products and I'm a very big fan.  However, the cost per seat is on the order of $3000 US.

So how do we deal with this cost in a small business environment, while maintaining or even excelling at our effectiveness in development?

Development For a U-Boot Based Platform: The Need for JTAG

In general, we need JTAG for very limited circumstances when developing a Linux based product (Embedded products are different... that's for a later discussion).  The reason it is limited is that there are absolutely excellent tools to help you once the OS has been launched.  From system trace capabilities, to system profiling, to the basics like gdb and kdb, there is a lot available.

But before the OS has launched on the board, there's a hole.  And that debug hole is usually just after the uP has started to execute, but just before the serial port has been setup.  For the IMX6, the boot sequence is as follows.

  Reset --> ROM Execution --> uBoot.imx Load  ---> Exec uBoot.imx

Freescale provides tools to help with much of the above. For example, the uBoot.imx contains the DDR3 tuning (and clock setup, and other values) contained in the "DCD" table. These values are programmed into the board.  But what if they fail to load?  What if we fail to execute the u-Boot?

JTAG can be used to break into the micro processor, and examine registers to see if any of the values have taken effect.  One can then tweak the values, test them, attempt to load DDR3 memory, and more.

see u-boot/board/boundary/nitrogen6x/ddr-setup.cfg

What about after the first execution of the uBoot, but before the serial ports are properly setup?  If we crash in this region of time, there's no serial console for debug.  Certainly we can toggle LEDs and perform other operations, but JTAG can quickly fill in the gap without requiring the modification of source code.

There are additional concerns of course: after u-boot launches the kernel but before the linux kernel can start writing to a serial port.  There is a whole host of operations that take place during this time, and if there is a flaw, a crash prior to the first context switch, there is very limited debug capability available.

For these reasons, if you're working with a new board design, it is important to consider JTAG as a first-step to board development.

Ironically, in my most recent project I didn't have JTAG available during the most critical portions of board-bringup.  Solving the board-bringup issues without JTAG was an absolutely incredible experience.  But once done, I would rather have better tools the next time around.







1 comment:

  1. Hi Stephen,

    Excellent article and that gives good understanding of the process

    "What about after the first execution of the uBoot, but before the serial ports are properly setup? If we crash in this region of time, there's no serial console for debug."

    I am struck exactly in this problem. I am working on iMX6Q based custom board and while setting some environmental variables in u-boot something went wrong. Below is the following link I have followed

    https://wiki.linaro.org/Boards/MX6QSabreLite

    Once executed the steps as per the above link.., nothing comes on to the console and I am stuck with no clue.

    I don't have bus blaster, but have J-Link Segger. Is there a way that I can get the serial console back using this one?

    I have gone through your post
    http://imx6dev.blogspot.in/2014/07/inexpensive-jtag-on-imx6-solo-u-boot.html
    for imx6 solo

    Can u suggest me some steps for imx6Q using J-Link?

    It will be great help if u can suggest some steps

    Regards,
    Pavan

    ReplyDelete