[MUSIC PLAYING] Hi, and welcome to Module 10, the final module of our Linux Board Porting Online Series. In this module, I'm going to use the bootable multimedia card with TFT pinging of the kernel that we set up in the previous module in order to set up a JTAG based debugging session in Code Composer Studio that we will use to debug the Linux kernel.
Again, we have our x86 host computer. And the computer is attached now to an AM335x Starter Kit. The reason that I'm using an AM335x Starter Kit as opposed to the BeagleBone black is that the BeagleBone black does not have a UART-style serial port. This board can do UART over USB or RS232 over a USB, which we will be using. And you can also see that I have connected to the board at the J6 connector-- there's actually two ethernet connections-- but at the J6 connector, I have a ethernet cable.
This board, because of the LCD, does require external power. So we're going to have that attached as well. In order to set up our bootable multimedia card, I'll be using this card reader. This one happens to be a multi-format card reader. But if you look closely here, you can see the micro SD card. So just be sure that whatever reader you use has micro SD support.
In this final section, we're going to set up Code Composer Studio with JTAG to debug the kernel source code. Now, recall that from the previous modules, I have rebuilt the Linux kernel with debug information and set it up to boot using TFTP. So we have our rebuilt kernel with debug information in the TFTP boot directory. And we've set up a multimedia card with SPL U-Boot. It then TFTPs the Linux kernel and boots Linux.
So I'll start us off just by resetting the board to show that we're at that state. Here, we see it is loading the Linux kernel from TFTP. And we should, of course, get all the way through to a successful boot. So we're starting with our kernel booting successfully on the system, without, of course, Code Composer Studio involved.
So I'll now start Code Composer Studio. You notice that there's no project under the Project Explorer. That's OK. We're just going to use the debugger. We're not going to use CCS to rebuild the Linux kernel. You can do that, but it's not necessary.
I'm using the AM335x EVM. So I'm going to launch my XDS200 connection to the AM335x EVM. Once the emulator has connected, which it has here, before I connect to the Cortex core, what I'm going to do is go back to the terminal, I'm going to reset, and then stop U-Boot. So just halt U-Boot at this point.
What that's going to do is it's going to allow us to connect to the Cortex-A8 without the boot process going on. So here, we see it's connected. And no symbols are defined. So we're not going to get a call stack.
That's because we don't have any of the symbols loaded for U-Boot. Remember, we're in U-Boot right now and not in the Linux kernel. Also, of course, we haven't loaded the symbols for the Linux kernel.
So I load the Linux kernel symbols. If you look here, this is just the SDK installation directory, under the board support, the Linux source code, and then VM Linux, which is the full Linux kernel with the debugging information that we've built into it. We don't need offsets. So we go ahead and press OK and load those symbols into CCS. Be sure, by the way, that the Cortex-A8 is highlighted when you load those symbols, which will indicate to CCS that the symbols are for that core, since this device has multiple cores on it.
Now, I want to open up the source file. So I go to Open File. Now within the source code for Linux under architecture, arm, and then machine omap2-- this device, the machine layer is omap2-- within that machine directory, we have the board file. And the board file that we're using is the AM335x EVM board file. Recall, during our lecture, we discussed that this board file is the basic initial point that you would use for a code port or a board port.
And I'm going to do the find, Control-F, to find am335x_evm_setup. And I can Right Click here, just this first line within am335x_evm_setup, going to Right Click, go to Breakpoint and a Hardware Breakpoint. Again, whenever using JTAG, be sure that you use Hardware Breakpoint. And here, the breakpoint shows up under our Breakpoints. And so we have it correctly set.
At this point, we've got everything set up as we need it. And so we're ready to resume. Once I resume and I go back to U-Boot, remember that we're still in U-Boot command mode. So it's not going to attempt to boot. But I can press Return, and you notice that it returns. Had I done that when it was paused, it wouldn't recognize the return.
So I'm going to say run boot command. And that's going to run the default boot command to continue booting. There you see the Linux kernel being downloaded. Again, this is the Linux kernel we rebuilt with the debug information.
Once it downloads the kernel, it will begin booting. We'll see some feedback as it goes through. Now, notice that it halts at this point. It's halted because we have reached the breakpoint. So let's go back to CCS.
Within CCS here, the Debug window, which I'll expand, is showing us a call stack. Go to board.c. And here is-- you might be able to see the arrow here right on top of the breakpoint indicating that we did reach that breakpoint.
If I hover over this expression, you'll see that it shows you some information-- the value of the pointer. If I select a variable, I can Right Click and Add it to the Watch Expression list. And if I make that smaller, here's our Expressions in the top right corner. I've purposely dialed down the resolution, so that it streams well as video. But you can see here in our Expressions now that mem_acc.
It shows us the value of the pointer to the structure. And then it shows the structure itself. We can continue expanding out the structure. You can see the values here.
So it's actually a structure comprised of function pointers. And here are the pointers to those individual functions. So anyway, not perhaps the most exciting of structures. But it does demonstrate the ability to watch variables.
As you would expect, we can open up the Core Registers. So here's the program counter, stack pointer, et cetera, some variables. It looks like there's no global variables that show up, which is fine. Oh, yeah, there are, so context.
I don't know what these are. They're no doubt something that kernel programmers would be familiar with. But you can see here the usual variable views showing up from some of those internal variables of the Linux kernel.
Let's do a C single step over. Go back to the Registers, so we can see the-- and we see the updated program counter. If I expand the board file again, we can see an update in where the pointer is located. Oddly, it seems to have gone backwards. Sometimes that happens with some of the optimizations.
I'll do another couple of C step overs. I can also open up the Disassembly window. So here, we see the pointer for the disassembly. And we can do an assembly step over and another.
It's going a little slowly, because I'm using an XDS200. But you can get the point, obviously, as we step through the code. Get back out of the Disassembly view. Take a look, you'll notice it opened up this at24.c. Complete the C step over, C step over completes.
And here, we are within the C code. So this is good, because we can clearly see the arrow indicating the line that we're on. Here is the original breakpoint that stopped us. Again, we are successfully using the emulator to trace through the code-- single stepping in both C and assembly, viewing the registers, viewing the variables, all of which are useful to do.
This concludes Module 10 and with it concludes the Linux Board Porting Online Series. I hope that this has been informative and useful for you.
[MUSIC PLAYING]

Module 4 - Linux/U-boot Source Code Structure: Overview of the layered organization of the source code files for both Linux and U-boot, focusing on those files which are most pertinent to a typical board porting effort.

Module 5 - Installing Code Composer Studio: This first lab exercise of the series is a recording of the presenter installing Code Composer Studio. In particular, installation of the proper JTAG drivers and a valid CCS license are required to debug U-boot. This is the first of three lab exercises centered around debugging U-boot using JTAG.

Module 6 - Building U-boot in CCS: This lab exercise shows the user how to set up a makefile-based project in Code Composer Studio in order to rebuild u-boot from source code.

Module 7 - Debugging U-boot with JTAG in CCS: This module is a recording of the presenter using Code Composer Studio and an xds560 emulator to debug U-boot on the Beaglebone Black platform.

Module 8 - Installing SDK and Building Kernel with Debug Symbols: This module is a recording of the presenter installing the Sitara Software Development Kit (SDK) and rebuilding the Linux Kernel with Debugging Symbols. It is the first of three modules demonstrating the debugging of the Linux Kernel in Code Composer Studio using JTAG.

Module 9 - Booting Linux from MMC/SD Card and TFTP: This module is a recording of the presenter using the SDK utility to build a bootable MMC/SD card for the AM335x starter kit and modifying the card to load the Linux Kernel from a TFTP server.

Module 10 - Debugging Linux Kernel with JTAG in CCS: This module is a recording of the presenter configuring JTAG debugging of the Linux Kernel using Code Composer Studio. It is the final in a ten-part series.