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

From Wiki-DB
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

This guide details the process of flashing U-Boot onto our i.MX6 based DHCOM using OpenOCD. The hardware configuration, software installation, and step-by-step programming procedures are provided.

Required Hardware

All tests and documents were made with this one, but technically all JTAG adapters listed by OpenOCD should work.
  • DHCOM JTAG adapter for FFC connection: Article number FD00037
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.

To support all our i.MX6 based DHCOM, it is necessary to have OpenOCD v0.11.0 or higher.

OpenOCD from master branch (before Debian 11 alias Bullseye)

  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 and checkout v0.12.0 tag
    git clone -b v0.12.0 https://repo.or.cz/openocd.git
  3. Change working directory to the extracted one
    cd openocd
  4. Prepare source directory and submodules (when building from the git repository)
    ./bootstrap
  5. Generate the Makefiles to build OpenOCD
    ./configure
  6. Build OpenOCD from source
    make -j4
  7. Install OpenOCD to /usr/local
    sudo make install
  8. (optional) Remove openocd source directory
    cd .. && rm -rf openocd

OpenOCD from Debian repositories (since Debian 11 alias Bullseye)

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

Non root access to tty devices

  1. Add your user to the dialout group:
    sudo usermod -a -G dialout ${USER}
  2. Add your user to the plugdev group:
    sudo usermod -a -G plugdev ${USER}
  3. Logout and login to apply new group rights

U-Boot Programming

There are two ways for doing this. The easy way is an automatic bash script, which handles all the commands needed for the programming process. 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. The steps Preparation and Start up OpenOCD are required for both automatic and manual flash programming.

Preparation

Get the needed recovery files

  1. Download and extract the needed files 2020-03-10_imx6_U-Boot_recovery.tar.gz
    wget -O - https://www.dropbox.com/s/klddy9grhac8g0x/2020-03-10_imx6_U-Boot_recovery.tar.gz | tar xz
  2. Change working directory to the extracted one
    cd 2020-03-10_imx6_U-Boot_recovery

Connect JTAG adapter

  1. Connect the JTAG adapter with your PC and the Debian VM (Player - Removeable Devices) through USB
  2. 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)
  3. Put the SODIMM-200 module (DHCOM) into the SODIMM-200 slot on your basebord
  4. Connect to the serial console (serial port) of the board like here Enter_Bootloader_Console

Start up OpenOCD

  1. Ensure you have everything properly connected like in Connect JTAG adapter
  2. Power up the i.MX6 board and have a look at the serial output (serial port). There must be no output (no U-Boot starting) else go to Troubleshooting
  3. Open a new terminal window (local shell console)
  4. Ensure you are in the directory with the recovery files
    cd /path/to/2020-03-10_imx6_U-Boot_recovery
  5. Start OpenOCD depending on your hardware
    • i.MX6 Q/D/DL/S
      openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f target/imx6.cfg -f dhcom-manual-loaded-code.cfg
    • i.MX6 ULL
      openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f imx6ull.cfg -f target/imx6ul.cfg -f dhcom-manual-loaded-code.cfg

The output should look like:

Open On-Chip Debugger 0.10.0+dev-00935-g31100927 (2019-10-01-12:14)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
0x088c101d
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
Warn : imx6ull.sdma: nonstandard IR value
2182283264
imx6_dummy_init
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 1000 kHz
Info : JTAG tap: imx6ull.cpu tap/device found: 0x5ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x5)
Info : TAP imx6ull.sdma does not have IDCODE
Info : JTAG tap: imx6ull.sjc tap/device found: 0x088c101d (mfg: 0x00e (Freescale (Motorola)), part: 0x88c1, ver: 0x0)
Info : imx6ull.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections

Automated Programming

  1. Ensure OpenOCD is running like in Start up OpenOCD
  2. Open a second terminal window (local shell console)
  3. Ensure you are in the directory with the recovery files
    cd /path/to/2019-10-08_imx6_U-Boot_recovery
  4. Execute the automated bash script with arguments depending on your hardware and desired U-Boot
    • Default DH U-Boot
      • i.MX6 Q/D/DL/S
        ./prog_bl.sh imx6qdl
      • i.MX6 ULL
        ./prog_bl.sh imx6ull
    • Custom U-Boot
      • i.MX6 Q/D/DL/S
        ./prog_bl.sh imx6qdl /path/to/u-boot-with-spl.imx
      • i.MX6 ULL
        ./prog_bl.sh imx6ull /path/to/u-boot-with-spl.imx

On success the output of the script should look like:

Programming: u-boot-with-spl-imx6ull.imx to imx6ull
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Open On-Chip Debugger
> reset
JTAG tap: imx6ull.cpu tap/device found: 0x5ba00477 (mfg: 0x23b (ARM Ltd.), part: 0xba00, ver: 0x5)
TAP imx6ull.sdma does not have IDCODE
JTAG tap: imx6ull.sjc tap/device found: 0x088c101d (mfg: 0x00e (Freescale (Motorola)), part: 0x88c1, ver: 0x0)
imx6ull.cpu rev 5, partnum c07, arch f, variant 0, implementor 41
imx6ull.cpu: MPIDR level2 0, cluster 0, core 0, multi core, no SMT
target halted in Thumb state due to debug-request, current mode: Supervisor
cpsr: 0x400001f3 pc: 0x00002f76
MMU: disabled, D-Cache: disabled, I-Cache: enabled
imx6ull.cpu rev 5, partnum c07, arch f, variant 0, implementor 41
target halted in Thumb state due to debug-request, current mode: Supervisor
cpsr: 0x400001f3 pc: 0x00002f74
MMU: disabled, D-Cache: disabled, I-Cache: enabled
> load_image u-boot-spl-prog-imx6ull.bin 0x908000
45056 bytes written at address 0x00908000
downloaded 45056 bytes in 1.610037s (27.329 KiB/s)

> resume 0x00908000
> halt
imx6ull.cpu rev 5, partnum c07, arch f, variant 0, implementor 41
target halted in Thumb state due to debug-request, current mode: Supervisor
cpsr: 0x800001f3 pc: 0x00908934
MMU: disabled, D-Cache: disabled, I-Cache: enabled
> load_image u-boot-with-spl-imx6ull.imx 0x82000000
451456 bytes written at address 0x82000000
downloaded 451456 bytes in 15.305990s (28.804 KiB/s)

> resume
> Connection closed by foreign host.

On success the output of serial console (serial port) should look like:

U-Boot SPL 2018.05-DH_v0.19_emmc-00102-gc8e3c3df13 (Oct 01 2019 - 16:12:44 +0200)
DRAM: Auto calibration...successful
SPL: Unsupported Boot Device!
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###
Searching for IVT header at DDR address 0x82000000
.....
Found IVT header
Probing SPI flash... ok
Erasing... ok
Programming... ok

Note: If some error occures you can try the Manual Programming method below

Manual Programming

  1. Ensure OpenOCD is running like in Start up OpenOCD
  2. Open a second terminal window (local shell console)
  3. Ensure you are in the directory with the recovery files
    cd /path/to/2019-10-08_imx6_U-Boot_recovery
  4. Open a telnet session to OpenOCD
    telnet localhost 4444
    1. Reset and halt the device
      reset
    2. Load modified U-Boot SPL as flash programmer in SRAM (device dependent)
      • i.MX6 Q/D/DL/S
        load_image u-boot-spl-prog-imx6qdl.bin 0x908000
      • i.MX6 ULL
        load_image u-boot-spl-prog-imx6ull.bin 0x908000
    3. Resume code execution at entry point of loaded U-Boot SPL
      resume 0x00908000
    4. Halt code execution if you see Searching for IVT header at DDR address 0xX2000000 in serial console
      halt
    5. Load desired U-Boot image into RAM (device and customer dependent)
      • i.MX6 Q/D/DL/S
        load_image u-boot-with-spl-imx6qdl.imx 0x12000000
      • i.MX6 ULL
        load_image u-boot-with-spl-imx6ull.imx 0x82000000
    6. Resume code execution after U-Boot image is in RAM
      resume
    7. Wait until the serial output (serial port) looks like in Automated Programming

Troubleshooting

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 (only 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. If no new output is printed on the serial console (serial port), continue with the flashing procedure

Delete U-Boot

  1. sf probe
  2. sf erase 0x0 0xf0000
  3. Restart the board
  4. If no new output is printed on the serial console (serial port), continue with the flashing procedure