U-Boot recovery for i.MX6 Q/D/DL/S/ULL via JTAG v2: Difference between revisions
Jneuhauser (talk | contribs) (Initial v2 with untested i.MX6ULL) |
Jneuhauser (talk | contribs) No edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 55: | Line 55: | ||
=== Start up OpenOCD === | === Start up OpenOCD === | ||
# Ensure you have everything properly connected like in [[#Connect JTAG adapter|Connect JTAG adapter]] | # Ensure you have everything properly connected like in [[#Connect JTAG adapter|Connect JTAG adapter]] | ||
# Power up the i.MX6 board and have a look at the serial output (serial port). There must be no output | # Power up the i.MX6 board and have a look at the serial output (serial port). | ||
#:* '''i.MX6 Q/D/DL/S'''<br>It is okay if a U-Boot is starting up, because the device will be reset later. | |||
#:* '''i.MX6 ULL'''<br>There must be no output of U-Boot, otherwise go to [[#Troubleshooting|Troubleshooting]]. | |||
# Open a new terminal window (local shell console) | # Open a new terminal window (local shell console) | ||
# Ensure you are in the directory with the recovery files <br><code>cd /path/to/ | # Ensure you are in the directory with the recovery files <br><code>cd /path/to/2023-08-28_imx6_U-Boot_recovery</code> | ||
# Start OpenOCD depending on your hardware | # Start OpenOCD depending on your hardware | ||
#:* '''i.MX6 Q/D/DL/S'''<br><code>openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f target/imx6.cfg -f dhcom-manual-loaded-code.cfg</code> | #:* '''i.MX6 Q/D/DL/S'''<br><code>openocd -f interface/ftdi/olimex-arm-usb-tiny-h.cfg -f target/imx6.cfg -f dhcom-manual-loaded-code.cfg</code> | ||
Line 167: | Line 169: | ||
# Ensure you are in the directory with the recovery files <br><code>cd /path/to/2023-08-28_imx6_U-Boot_recovery</code> | # Ensure you are in the directory with the recovery files <br><code>cd /path/to/2023-08-28_imx6_U-Boot_recovery</code> | ||
# Open a telnet session to OpenOCD <br><code>telnet localhost 4444</code> | # Open a telnet session to OpenOCD <br><code>telnet localhost 4444</code> | ||
## Ensure device boot fails by booting from invalid media<br><code>boot_from_sd</code> | ## Ensure device boot fails by booting from invalid media | ||
##:* '''i.MX6 Q/D/DL/S'''<br><code>boot_from_sd</code> | |||
##:* '''i.MX6 ULL'''<br>Follow [[#Troubleshooting|Troubleshooting]] to ensure no U-Boot starts. | |||
## Prepare for running manual loaded code<br><code>prepare_code_load</code> | ## Prepare for running manual loaded code<br><code>prepare_code_load</code> | ||
## Load modified U-Boot SPL as flash programmer in SRAM (device dependent) | ## Load modified U-Boot SPL as flash programmer in SRAM (device dependent) | ||
Line 191: | Line 195: | ||
## Reset the device. To reset the device, press the reset button on the baseboard or unplug and plug in the power plug. | ## Reset the device. To reset the device, press the reset button on the baseboard or unplug and plug in the power plug. | ||
## Release the button for sdp boot mode | ## Release the button for sdp boot mode | ||
# If no new output is printed on the serial console (serial port), continue with the flashing procedure | |||
=== SD Boot (only i.MX6 Q/D/DL/S) === | |||
# Ensure OpenOCD is running like in [[#Start up OpenOCD|Start up OpenOCD]] | |||
# Open a telnet session to OpenOCD <br><code>telnet localhost 4444</code> | |||
# Use the following command to trigger a boot from an invalid source by setting the boot source to an invalid media for the next boot and then reset the device. <br><code>boot_from_sd</code> | |||
# If no new output is printed on the serial console (serial port), continue with the flashing procedure | # If no new output is printed on the serial console (serial port), continue with the flashing procedure |
Latest revision as of 13:56, 11 October 2023
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
- Baseboard as power source for DHCOM
- JTAG Debugger: Olimex Arm-USB-OCD-Tiny-H
- 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
- 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 master branch (before Debian 11 alias Bullseye)
- 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 and checkout v0.12.0 tag
git clone -b v0.12.0 https://repo.or.cz/openocd.git
- Change working directory to the extracted one
cd openocd
- 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
- (optional) Remove openocd source directory
cd .. && rm -rf openocd
OpenOCD from Debian repositories (since Debian 11 alias Bullseye)
- Install OpenOCD from Debian repositories
sudo apt-get install openocd
Non root access to tty devices
- Add your user to the dialout group:
sudo usermod -a -G dialout ${USER}
- Add your user to the plugdev group:
sudo usermod -a -G plugdev ${USER}
- Logout and login to apply new group rights
U-Boot Programming
There are two ways for doing this. The easy way is an automatic shell 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 shell 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
- Download and extract the needed files 2023-08-28_imx6_U-Boot_recovery.tar.xz
wget -O - 'https://www.dropbox.com/scl/fi/bj6s93ym5gwa17ecm7tqb/2023-08-28_imx6_U-Boot_recovery.tar.xz?rlkey=r7p3kwonbfafa81ug4gnyibbz' | tar xJ
- Change working directory to the extracted one
cd 2023-08-28_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)
- Put the SODIMM-200 module (DHCOM) into the SODIMM-200 slot on your basebord
- Connect to the serial console (serial port) of the board like here 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).
- i.MX6 Q/D/DL/S
It is okay if a U-Boot is starting up, because the device will be reset later. - i.MX6 ULL
There must be no output of U-Boot, otherwise go to Troubleshooting.
- i.MX6 Q/D/DL/S
- Open a new terminal window (local shell console)
- Ensure you are in the directory with the recovery files
cd /path/to/2023-08-28_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.12.0 Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'. Warn : imx6.sdma: nonstandard IR value boot_from_sd Info : Listening on port 6666 for tcl connections Info : Listening on port 4444 for telnet connections Info : clock speed 1000 kHz Info : JTAG tap: imx6.cpu tap/device found: 0x4ba00477 (mfg: 0x23b (ARM Ltd), part: 0xba00, ver: 0x4) Info : TAP imx6.sdma does not have valid IDCODE (idcode=0x4323803a) Info : JTAG tap: imx6.sjc tap/device found: 0x2191c01d (mfg: 0x00e (Freescale (Motorola)), part: 0x191c, ver: 0x2) Info : imx6.cpu.0: hardware has 6 breakpoints, 4 watchpoints Info : starting gdb server for imx6.cpu.0 on 3333 Info : Listening on port 3333 for gdb connections
Automated Programming
- Ensure OpenOCD is running like in Start up OpenOCD
- Open a second terminal window (local shell console)
- Ensure you are in the directory with the recovery files
cd /path/to/2023-08-28_imx6_U-Boot_recovery
- 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
sh prog_bl.sh imx6qdl
- i.MX6 ULL
sh prog_bl.sh imx6ull
- i.MX6 Q/D/DL/S
- Custom U-Boot
- i.MX6 Q/D/DL/S
sh prog_bl.sh imx6qdl /path/to/u-boot-with-spl.imx
- i.MX6 ULL
sh prog_bl.sh imx6ull /path/to/u-boot-with-spl.imx
- i.MX6 Q/D/DL/S
- Default DH U-Boot
On success the output of the script should look like:
Programming: u-boot-with-spl-imx6qdl.imx to imx6qdl Trying ::1... Connection failed: Connection refused Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Open On-Chip Debugger > boot_from_sd imx6.cpu.0: MPIDR level2 0, cluster 0, core 0, multi core, no SMT target halted in Thumb state due to debug-request, current mode: Supervisor cpsr: 0xa00001f3 pc: 0x8ff7a982 MMU: enabled, D-Cache: enabled, I-Cache: enabled Invalid ACK (0) in DAP response Could not read DSCR register Error waiting for cortex_a_exec_opcode Invalid ACK (0) in DAP response Could not read DSCR register Invalid ACK (0) in DAP response JTAG-DP STICKY ERROR Could not read DSCR register Error waiting for dpm prepare Invalid ACK (7) in DAP response Polling target imx6.cpu.0 failed, trying to reexamine Debug regions are unpowered, an unexpected reset might have happened JTAG-DP STICKY ERROR Could not initialize the APB-AP Examination failed, GDB will be halted. Polling again in 100ms JTAG-DP STICKY ERROR Polling target imx6.cpu.0 failed, trying to reexamine imx6.cpu.0: hardware has 6 breakpoints, 4 watchpoints > prepare_code_load target halted in Thumb state due to debug-request, current mode: Supervisor cpsr: 0x800001f3 pc: 0x8ff7a982 MMU: disabled, D-Cache: disabled, I-Cache: disabled > load_image u-boot-spl-prog-imx6qdl.bin 0x908000 32768 bytes written at address 0x00908000 downloaded 32768 bytes in 1.152152s (27.774 KiB/s) > resume > halt target halted in Thumb state due to debug-request, current mode: Supervisor cpsr: 0x800001f3 pc: 0x0090ba5e MMU: disabled, D-Cache: disabled, I-Cache: enabled > load_image u-boot-with-spl-imx6qdl.imx 0x12000000 567752 bytes written at address 0x12000000 downloaded 567752 bytes in 18.675529s (29.688 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-23076-g8686cf2574 (Mar 10 2020 - 10:26:00 +0100) SPL: Unsupported Boot Device! SPL: failed to boot from all boot devices ### ERROR ### Please RESET the board ### Searching for IVT header at DDR address 0x12000000 .... Found IVT header Determinded image length: 0x8a9c8 ### Recovery ### Trying to program SPI flash ### Probing SPI flash... ok Erasing SPI flash... ok Programming SPI flash... ok ### Recovery ### Finished ###
Note: If some error occures you can try the Manual Programming method below
Manual Programming
- Ensure OpenOCD is running like in Start up OpenOCD
- Open a second terminal window (local shell console)
- Ensure you are in the directory with the recovery files
cd /path/to/2023-08-28_imx6_U-Boot_recovery
- Open a telnet session to OpenOCD
telnet localhost 4444
- Ensure device boot fails by booting from invalid media
- i.MX6 Q/D/DL/S
boot_from_sd
- i.MX6 ULL
Follow Troubleshooting to ensure no U-Boot starts.
- i.MX6 Q/D/DL/S
- Prepare for running manual loaded code
prepare_code_load
- 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 (serial port) looks like in Automated Programming
- Exit telnet with
exit
and close OpenOCD with STRG+C
- Ensure device boot fails by booting from invalid media
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)
- Boot in Serial Download Mode to prevent booting the broken U-Boot from SPI-NOR-Flash
- If no new output is printed on the serial console (serial port), continue with the flashing procedure
SD Boot (only i.MX6 Q/D/DL/S)
- Ensure OpenOCD is running like in Start up OpenOCD
- Open a telnet session to OpenOCD
telnet localhost 4444
- Use the following command to trigger a boot from an invalid source by setting the boot source to an invalid media for the next boot and then reset the device.
boot_from_sd
- If no new output is printed on the serial console (serial port), continue with the flashing procedure