RiotBoard has a JTAG header on board. So I connected Jlink Ultra and tried my luck. The StartJLinkExe.sh utility available from segger website could detect "Cortex-A9" core when executed.



After this, using eclipse I wanted to debug U-Boot. For this, I used KEPLER. Initial step is to create a workspace for building and debugging U-boot.



Select a workspace location, Select File -> Import -> Existing Code as Makefile project.



In next window, Browse into U-boot's location as shown in image below,

 

 

Click Finish. Now the project can be seen in Project Explorer. To successfully build U-boot sources environment variables should be updated. Right Click on the project and click on properties. Select Environment under C/C++ Build



Add new variable ARCH as arm.

 

 

Create an environment variable CROSS_COMPILE as arm-linux-gnueabihf- . I used linaro toolchain.



Update already available PATH variable to contain the path of the toolchain binaries.



Add a new make target to configure u-boot for RiotBoard.



Then add a make target to build and cleaning u-boot sources.


 


After addition of make targets, now it's time to build. To start with, double click on the make target for configuring u-boot for RiotBoard. The message on the console confirms that u-boot is configured for RiotBoard.



Now double click on make all to start building the u-boot sources. Once this process is complete you can see the binaries in the root folder of u-boot. This is confirmed on the console too.



In order to debug the u-boot, we need the GDB Hardware Debugging plugin to be installed. Goto Help -> Install New Software. Update Work with field as shown below. Make sure that you have stable internet connection.



Under CDT Optional Features select C/C++ GDB Hardware Debugging and click on Next.



Once the installation is complete you can confirm the installation by looking into already installed software dialog as shown below.



Now if you open the Debug configurations window, a new GDB Hardware Debugging configuration can be created.



In C/C++ Application field, "Browse" to the file "u-boot" present in the root directory of u-boot.



Update GDB command field with the toolchain gdb as shown below. Change the port number to 2331. Because by default, JLink listens on TCP/IP port 2331.



In Startup Window, uncheck Reset and Delay and Halt.

 

 

 

Note that we have Load Image checked. But JLink has no driver for the on board memory. So the trick is to use "imx_usb_loader". This utility is useful to flash binaries. The build steps are as follows,

 

$ git clone https://github.com/boundarydevices/imx_usb_loader.git

$ cd imx_usb_loader

$ make


Once the build process is complete, two binaries can be found one for loading via USB and other for UART. Now configure the RiotBoard to enter USB serial Download mode.


 

After setting the DIP switches appropriately, connect the USB cable to the usb connector next to ethernet port. Then run the following command,

 

$ ./imx_usb <path to your u-boot.bin>

 

Following was my console out for above command

 

config file <./imx_usb.conf>
vid=0x066f pid=0x3780 file_name=mx23_usb_work.conf
vid=0x15a2 pid=0x004f file_name=mx28_usb_work.conf
vid=0x15a2 pid=0x0052 file_name=mx50_usb_work.conf
vid=0x15a2 pid=0x0054 file_name=mx6_usb_work.conf
vid=0x15a2 pid=0x0061 file_name=mx6_usb_work.conf
vid=0x15a2 pid=0x0063 file_name=mx6_usb_work.conf
vid=0x15a2 pid=0x0041 file_name=mx51_usb_work.conf
vid=0x15a2 pid=0x004e file_name=mx53_usb_work.conf
vid=0x15a2 pid=0x006a file_name=vybrid_usb_work.conf
vid=0x066f pid=0x37ff file_name=linux_gadget.conf
config file <./mx6_usb_work.conf>
parse ./mx6_usb_work.conf
15a2:0061(mx6_qsb) bConfigurationValue =1
Interface 0 claimed
HAB security state: development mode (0x56787856)
== work item
filename ../u-boot-imx-embest_imx_3.0.35_4.0.0/u-boot.bin
load_size 0 bytes
load_addr 0x00000000
dcd 1
clear_dcd 0
plug 1
jump_mode 2
jump_addr 0x00000000
== end work item
main dcd length 1e0
sub dcd length 1dc


loading binary file(../u-boot-imx-embest_imx_3.0.35_4.0.0/u-boot.bin) to 27800000, skip=0, fsize=69a68 type=aa


<<<432744, 432744 bytes>>>
succeeded (status 0x88888888)
jumping to 0x27800400

 

The u-boot.bin was loaded to 0x27800000. Now time to run GDB server!!! This can be done using following command,

 

$ cd <to JLink folder>

$ ./StartJLinkGDBServer.sh -device MCIMX6U8


 

 

Launch the debug configuration from eclipse. Below is screenshot where the image loading happens at 0x27800000 soon after the launch of debug session.

.

 

Below is the screenshot after debug session launch in eclipse.

 

 

All register except PC are zero. PC is updated to 0x27800000 where the u-boot is loaded.

 

 

 

Disassembly view shows that the jump to 0x27800620 instruction is present at 0x27800000.

 

 

Enable instruction mode debugging and issue step into command. After few step into commands, the control jumps into the lowlevel_init.S file as shown below.

 

 

 

Board initialization can be debugged by opening mx6solo_RiotBoard.c file and placing a breakpoint in board_init().

 


 

Happy Debugging!!!

Nitin