U-Boot recovery for i.MX6 Q/D/DL/S/ULL via JTAG: Difference between revisions

From Wiki-DB
Jump to navigationJump to search
No edit summary
Line 26: Line 26:
== U-Boot Programing ==
== U-Boot Programing ==
There are two ways for doing this.
There are two ways for doing this.
The easy way is an automatic Bash-script, which handles all the commands needed for the programing process.
The easy way is an automatic Bash script, which handles all the commands needed for the programing process.
In this case you need a specified folder-structure so that the automatic script can find all its needed files.
In this case you need a specified folder-structure so that the automatic script can find all its needed files.
The other one is to type in the required commands. In a few cases this fails then you need to go the other way
The other one is to type in the required commands. In a few cases the Bash script fails then you need to go the other way
and program the uBoot manually.
and program the U-Boot manually.
 
=== Preparation ===
# '''Download the needed files here:''' [https://www.dropbox.com/s/mip4t2apysmcv2x/2018-07-06_uBoot_recovery_iMX6.tar.gz?dl=0 Programing Files]
# '''Download the needed files here:''' [https://www.dropbox.com/s/mip4t2apysmcv2x/2018-07-06_uBoot_recovery_iMX6.tar.gz?dl=0 Programing Files]
#*Here you get the '''"dhcom_olimex_arm_usb_tiny_h.cfg"''' and the '''"u-boot-spl-prog"'''
# Here you get the '''"dhcom_olimex_arm_usb_tiny_h.cfg"''' and the '''"u-boot-spl-prog"'''
# '''Download newest uBoot here:''' [https://wiki.dh-electronics.com/index.php?title=COM_iMX6-D2#Downloads uBoot_iMX6]
# '''Download newest uBoot here:''' [https://wiki.dh-electronics.com/index.php?title=COM_iMX6-D2#Downloads uBoot_iMX6]
#*Here you get the '''"uBoot.imx"'''
# Here you get the '''"uBoot.imx"'''
# '''Connecting everything'''
# '''Connecting everything'''
#*Connect the JTAG-Adapter with your PC and the Debian VM (Player - Removeable Devices)
# Connect the JTAG-Adapter with your PC and the Debian VM (Player - Removeable Devices)
#*Connect the JTAG interface via the DHCOM JTAG adapter to the i.MX6 module (If you don't have a JTAG adapter, please ask DH electronics)
# Connect the JTAG interface via the DHCOM JTAG adapter to the i.MX6 module (If you don't have a JTAG adapter, please ask DH electronics)
#:[[File:JTAG-connection.jpeg|1000px]]
#:[[File:JTAG-connection.jpeg|1000px]]
#*Connect the board with a serial COM-port: [https://wiki.dh-electronics.com/index.php?title=COM_iMX6_Bootloader_U-Boot#Enter_Bootloader_Console Enter Bootloader Console]
# Connect the board with a serial COM-port: [https://wiki.dh-electronics.com/index.php?title=COM_iMX6_Bootloader_U-Boot#Enter_Bootloader_Console Enter Bootloader Console]
# '''Automatic Script'''
 
#*Create a new folder (it isn't necessary where the folder is located, you just need to keep the folder structure)
=== Automated Programming ===
#*The needed folder structure looks like this:
# Create a new folder (it isn't necessary where the folder is located, you just need to keep the folder structure)
#**DHcom_uBoot_Programmer
# The needed folder structure looks like this:
#***bin_File          (here are the uBoot files)
# DHcom_uBoot_Programmer
#***uBoot_Programmer  (here are the Programing scripts)
# bin_File          (here are the uBoot files)
#**Paste the '''"dhcom_olimex_arm_usb_tiny_h.cfg"'''-file in the OpenOCD folder at <code>/usr/share/openocd/scripts/board</code>
# uBoot_Programmer  (here are the Programing scripts)
#**The '''"uBoot_Programmer_Olimex_arm_usb_tiny_h.sh"'''-file needs to be in the uBoot_Programmer folder
# Paste the '''"dhcom_olimex_arm_usb_tiny_h.cfg"'''-file in the OpenOCD folder at <code>/usr/share/openocd/scripts/board</code>
#**In the bin_Folder belongs the '''"u-boot-spl-prog.bin"''' and your own uBoot file
# The '''"uBoot_Programmer_Olimex_arm_usb_tiny_h.sh"'''-file needs to be in the uBoot_Programmer folder
#**You need to adjust the '''"uBoot_Programmer_Olimex_arm_usb_tiny_h.sh"''' in terms of the name of your uBoot-file. Paste the name instead of the term "Your uBoot File"
# In the bin_Folder belongs the '''"u-boot-spl-prog.bin"''' and your own uBoot file
#*Open a Linux terminal and navigate into the folder e.g. <code>cd DHcom_uBoot_Programmer/uBoot_Programmer</code>
# You need to adjust the '''"uBoot_Programmer_Olimex_arm_usb_tiny_h.sh"''' in terms of the name of your uBoot-file. Paste the name instead of the term "Your uBoot File"
#*Power up the i.MX6 board and have a look at the serial output (COM-port). There must not be any output (no uBoot starting) else go to [https://wiki.dh-electronics.com/index.php?title=UBoot_recovery_for_imx6_via_JTAG#Delete_uBoot Delete uBoot]
# Open a Linux terminal and navigate into the folder e.g. <code>cd DHcom_uBoot_Programmer/uBoot_Programmer</code>
# Power up the i.MX6 board and have a look at the serial output (COM-port). There must not be any output (no uBoot starting) else go to [https://wiki.dh-electronics.com/index.php?title=UBoot_recovery_for_imx6_via_JTAG#Delete_uBoot Delete uBoot]
#*Start the programing script: <code>./uBoot_Programmer_Olimex_arm_usb_tiny_h.sh</code>
#*Start the programing script: <code>./uBoot_Programmer_Olimex_arm_usb_tiny_h.sh</code>
#:[[File:JTAG iMX6 script output.PNG|700px]]
#:[[File:JTAG iMX6 script output.PNG|700px]]
#:[[File:JTAG iMX6 Serial output.PNG|700px]]
#:[[File:JTAG iMX6 Serial output.PNG|700px]]
#*Note: If some error occures you can try the Manual Programing method below
# Note: If some error occures you can try the Manual Programing method below
# '''Manual Programming''' (Only needed if automatic script is not used!!!)
 
#*Power up the board and have a look at the serial output. If there is any uBoot starting:[https://wiki.dh-electronics.com/index.php?title=UBoot_recovery_for_imx6_via_JTAG#Delete_uBoot Delete uBoot]
=== Manual Programming ===
#*You need two terminals, one for GDB the other for OpenOCD an a Com-Port to get the serial output
# Power up the board and have a look at the serial output. If there is any uBoot starting:[https://wiki.dh-electronics.com/index.php?title=UBoot_recovery_for_imx6_via_JTAG#Delete_uBoot Delete uBoot]
# You need two terminals, one for GDB the other for OpenOCD an a Com-Port to get the serial output
## '''OpenOCD'''
## '''OpenOCD'''
##*<code>openocd –f board/dhcom_olimex_arm_usb_tiny_h.cfg</code>
## <code>openocd –f board/dhcom_olimex_arm_usb_tiny_h.cfg</code>
##:[[File:Openocd.png]]
##:[[File:Openocd.png]]
##*If OpenOCD does not open like in the picture then close and open it again
## If OpenOCD does not open like in the picture then close and open it again
## '''GDB'''
## '''GDB'''
##*Open second terminal window
## Open second terminal window
##*<code>gdb --quiet</code>
## <code>gdb --quiet</code>
##*<code>target remote localhost:3333</code>
## <code>target remote localhost:3333</code>
##*<code>mon load_image /path/to/the/u-boot-spl-prog/file 0x908000</code>
## <code>mon load_image /path/to/the/u-boot-spl-prog/file 0x908000</code>
##*<code>mon reg pc 0x908000</code>
## <code>mon reg pc 0x908000</code>
##*<code>mon reset</code>
## <code>mon reset</code>
##*<code>mon resume</code>
## <code>mon resume</code>
##*Wait until the message "Searching for IVT header at DDR address 0x18000000" is on the serial output
## Wait until the message "Searching for IVT header at DDR address 0x18000000" is on the serial output
##*<code>mon halt</code>
## <code>mon halt</code>
##*<code>mon load_image /path/to/the/u-boot-with-spl/file 0x18000000</code>
## <code>mon load_image /path/to/the/u-boot-with-spl/file 0x18000000</code>
##*<code>mon resume</code>
## <code>mon resume</code>


== Trouble shooting ==
== Trouble shooting ==

Revision as of 14:35, 8 October 2019

Technically all JTAG-adapter listed by OpenOCD should work, but DH electronics recommends the Olimex Arm-USB-OCD-Tiny-H. All tests and Documents were made in use of this one.

Needed Hardware

Note: One cable is included with the DHCOM JTAG adapter.

Installation

This installation was made on the Virtual Machine for Application Development. All console expressions refer to this Debian system, but any other debian based system should also work.

OpenOCD from Debian repositories (i.MX6 Q/D/DL/S)

  1. Install OpenOCD from Debian repositories
    sudo apt-get install openocd

OpenOCD from master branch (i.MX6 ULL)

  1. Install needed libraries and tools
    sudo apt-get install git build-essential pkg-config autoconf automake libtool libusb-dev libusb-1.0-0-dev libhidapi-dev libftdi-dev
  2. Clone git repository to local directory
    git clone https://repo.or.cz/openocd.git
  3. Prepare source directory and submodules (when building from the git repository)
    ./bootstrap
  4. Generate the Makefiles to build OpenOCD
    ./configure
  5. Build OpenOCD from source
    make -j4
  6. Install OpenOCD to /usr/local
    sudo make install

U-Boot Programing

There are two ways for doing this. The easy way is an automatic Bash script, which handles all the commands needed for the programing process. In this case you need a specified folder-structure so that the automatic script can find all its needed files. The other one is to type in the required commands. In a few cases the Bash script fails then you need to go the other way and program the U-Boot manually.

Preparation

  1. Download the needed files here: Programing Files
  2. Here you get the "dhcom_olimex_arm_usb_tiny_h.cfg" and the "u-boot-spl-prog"
  3. Download newest uBoot here: uBoot_iMX6
  4. Here you get the "uBoot.imx"
  5. Connecting everything
  6. Connect the JTAG-Adapter with your PC and the Debian VM (Player - Removeable Devices)
  7. Connect the JTAG interface via the DHCOM JTAG adapter to the i.MX6 module (If you don't have a JTAG adapter, please ask DH electronics)
  8. Connect the board with a serial COM-port: Enter Bootloader Console

Automated Programming

  1. Create a new folder (it isn't necessary where the folder is located, you just need to keep the folder structure)
  2. The needed folder structure looks like this:
  3. DHcom_uBoot_Programmer
  4. bin_File (here are the uBoot files)
  5. uBoot_Programmer (here are the Programing scripts)
  6. Paste the "dhcom_olimex_arm_usb_tiny_h.cfg"-file in the OpenOCD folder at /usr/share/openocd/scripts/board
  7. The "uBoot_Programmer_Olimex_arm_usb_tiny_h.sh"-file needs to be in the uBoot_Programmer folder
  8. In the bin_Folder belongs the "u-boot-spl-prog.bin" and your own uBoot file
  9. You need to adjust the "uBoot_Programmer_Olimex_arm_usb_tiny_h.sh" in terms of the name of your uBoot-file. Paste the name instead of the term "Your uBoot File"
  10. Open a Linux terminal and navigate into the folder e.g. cd DHcom_uBoot_Programmer/uBoot_Programmer
  11. Power up the i.MX6 board and have a look at the serial output (COM-port). There must not be any output (no uBoot starting) else go to Delete uBoot
    • Start the programing script: ./uBoot_Programmer_Olimex_arm_usb_tiny_h.sh
  12. Note: If some error occures you can try the Manual Programing method below

Manual Programming

  1. Power up the board and have a look at the serial output. If there is any uBoot starting:Delete uBoot
  2. You need two terminals, one for GDB the other for OpenOCD an a Com-Port to get the serial output
    1. OpenOCD
    2. openocd –f board/dhcom_olimex_arm_usb_tiny_h.cfg
    3. If OpenOCD does not open like in the picture then close and open it again
    4. GDB
    5. Open second terminal window
    6. gdb --quiet
    7. target remote localhost:3333
    8. mon load_image /path/to/the/u-boot-spl-prog/file 0x908000
    9. mon reg pc 0x908000
    10. mon reset
    11. mon resume
    12. Wait until the message "Searching for IVT header at DDR address 0x18000000" is on the serial output
    13. mon halt
    14. mon load_image /path/to/the/u-boot-with-spl/file 0x18000000
    15. mon resume

Trouble shooting

If there is a U-Boot starting, the OpenOCD procedure may not work properly. There are two solutions to prevent the start of U-Boot from the SPI-NOR-Flash.

SDP Boot (i.MX6 ULL)

  1. Boot in Serial Download Mode to prevent booting the broken U-Boot from SPI-NOR-Flash
    1. Hold the button for sdp boot mode on the SODIMM-200-Module (DHCOM) next to the BGA-Module (DHCOR)
    2. Reset the device. To reset the device, press the reset button on the baseboard or unplug and plug in the power plug.
    3. Release the button for sdp boot mode
  2. Go on with your procedure

Delete U-Boot (i.MX6 Q/D/DL/S)

  1. sf probe
  2. sf erase 0 f0000
  3. Restart the board
  4. Go on with your procedure