U-Boot recovery for i.MX6 Q/D/DL/S/ULL via JTAG
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.
Required Hardware
- JTAG Debugger: Olimex Arm-USB-OCD-Tiny-H.
- DHCOM JTAG adapter for FFC connection: Article number FD00037
- Wuerth FFC cable: 687610050002
- 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)
- Install OpenOCD from Debian repositories
sudo apt-get install openocd
OpenOCD from master branch (i.MX6 ULL)
- 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
- Clone git repository to local directory
git clone https://repo.or.cz/openocd.git
- Prepare source directory and submodules (when building from the git repository)
./bootstrap
- Generate the Makefiles to build OpenOCD
./configure
- Build OpenOCD from source
make -j4
- Install OpenOCD to /usr/local
sudo make install
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. 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
Get the needed recovery files
- Download the needed files 2019-10-08_imx6_U-Boot_recovery.tar.gz
wget https://www.dropbox.com/s/l6139yluoqrj76x/2019-10-08_imx6_U-Boot_recovery.tar.gz
- Extract the files in a local directory
tar xf 2019-10-08_imx6_U-Boot_recovery.tar.gz
- Change working directory to the extracted one
cd 2019-10-08_imx6_U-Boot_recovery
Connect JTAG adapter
- Connect the JTAG adapter with your PC and the Debian VM (Player - Removeable Devices) through USB
- 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 board with a serial port: Enter Bootloader Console
Start up OpenOCD
- Ensure you have everything properly connected like in Connect JTAG-Adapter
- 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 Trouble shooting
- Open a new terminal window
- Ensure you are in the directory with the recovery files
cd /path/to/2019-10-08_imx6_U-Boot_recovery
- 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
- i.MX6 Q/D/DL/S
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
- Ensure OpenOCD is running like in Start up OpenOCD
- Open a second terminal window
- Ensure you are in the directory with the recovery files
cd /path/to/2019-10-08_imx6_U-Boot_recovery
- Execute the automated bash script with arguments depending on your hardware (the second argument is optional)
- 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
- i.MX6 Q/D/DL/S
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.
The output of serial console 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 Programing method below
Manual Programming
- Ensure OpenOCD is running like in Start up OpenOCD
- Open a second terminal window
- Ensure you are in the directory with the recovery files
cd /path/to/2019-10-08_imx6_U-Boot_recovery
- Open a telnet session to OpenOCD
telnet localhost 4444
- Reset and halt the device
reset
- 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
- i.MX6 Q/D/DL/S
- Resume code execution at entry point of loaded U-Boot SPL
resume 0x00908000
- Halt code execution if you see Searching for IVT header at DDR address 0xX2000000 in serial console
halt
- 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
- i.MX6 Q/D/DL/S
- Resume code execution after U-Boot image is in RAM
resume
- Wait until the serial output looks like in Automated Programming
- Reset and halt the device
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 (i.MX6 ULL)
- Boot in Serial Download Mode to prevent booting the broken U-Boot from SPI-NOR-Flash
- Go on with your procedure
Delete U-Boot (i.MX6 Q/D/DL/S)
sf probe
sf erase 0x0 0xf0000
- Restart the board
- Go on with your procedure