Wednesday, 29 January 2020

iMX6ull u-boot knowlege

Board: http://variwiki.com/index.php?title=DART-6UL

What: u-boot mostly

Where: booting over USB using uuu or from sdcard or from emmc without sdcard



After following this porocedure:

http://variwiki.com/index.php?title=DART-6UL_Debian_Jessie_MX6UL

Considering var_mx6ul_dart_debian/ the base of the tree

  • the output folder would have
    • u-boot.img.mmc & SPL.mmc
      • they are both used in eMMC flash and SDcard flashing
      • the command to flash them is a script located in / folder
        • SPL at offset 1K
        • u-boot at offset 69K

#!/bin/bash
[[ -z $1 ]] && echo "pass in the sdcard or usb device" && exit
if [[ -b $1 ]];then
    dd if=./output/SPL.mmc of=/dev/mmcblk0 bs=1K seek=1 && sync
    dd if=./output/u-boot.img.mmc of=/dev/mmcblk0 bs=1K seek=69 &&  sync
else
    echo "$1 is not a block device of file does not exist or you you have a hanging file as $1"
fi


This mx6ul_var_dart_mmc_defconfig is the defconfig for the uboot for ull board.

This uboot build by default is NOT GOOD for
https://github.com/boundarydevices/imx_usb_loader  neither for https://github.com/NXPmicro/mfgtools because does not contain the Device Configuration Data (DCD) information



Hold on the above boot mmc binaries files because you need them for the sdcard of for the emmc.

To build a in-ram u-boot to recover a bricked device using uuu or  imx-usb the uboot image needs the Device Configuration Data (DCD).

The mx6ul_var_dart_mmc_defconfig does not have that because the line

CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=arch/arm/mach-imx/spl_sd.cfg"

points to arch/arm/mach-imx/spl_sd.cfg

which is quite empty.

To make the u-boot.imx image with the DCD we have to ether change the src/uboot./.config file  or the arch/arm/mach-imx/spl_sd.cfg

I chosen to change the arch/arm/mach-imx/spl_sd.cfg.

Copy the src/uboot/board/freescale/mx6ullevk/imximage.cfg onto
src/uboot/arch/arm/mach-imx/spl_sd.cfg

As the default build make_var_mx6ul_dart_debian.sh -c bootloader wont biuld the u-boot.imx we have to do it manually.

in ./ paste this script and name it envsetup.sh

#!/bin/bash
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-
export PATH=$(pwd)/toolchain/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin:$PAT
H


source it
  source envsetup.sh
cd to src/uboot
make u-boot.imx

This will compile and link in uboot folder a file called  u-boot.imx.
This is the file to use it over the USB uuu pr imx-usb-flash utility.

Now you can hold on to u-boot.imx file for recovery only. You have to roll back the
arch/arm/mach-imx/spl_sd.cfg  because a normal u-boot build wont save the environment is case of saveenv is invoked form the uboot prompt









Recovery using uuu

If you have the Varisicte mother board on which you have plugged the dart, you would need a USB cable MALE to MALE. If you solder one be sure you don't connect the RED wire (power wont run form board to PC and vicevera on male to male cable).

Make sure you have selected the boot from SDcard or from eMMC from the micro-switches.  On the selected device make sure the SDcard is not plugged or the emmc has not u-boot yet or is damaged.


Plug in one USB the micro USB UART. You should see on dmesg the UART




If you don't have the Varisicte motherboard you have to check every USB pins you have (adapt and connect) until the PC dmesg would say.




 Now the USB is in the download mode.

I used the uuu tool. Open 2 terminals




in one run screen, on the  other go to output folder. copy the u-boot.imx form src/uboot in ./output as shown
Start scrreen on one terminal. Reset the board. You get nothing in the screen output because there is no u-boot (if emmc) or no sdcard.

I presume uuu is installed on the system. On the second terminal type

u-boot.imx
zImage
>uuu ./u-boot.imx


Yea the fastboot default boot command is placed int he code by the u-boot.imx make configuration but you can take that out.






AT this stage, you can either boot from NFS, form the other USB and repair the eMMC.

If you have the other USB available, power off, plugin the USB flashed as you flashed any sdcard, repeat the procedure and get again the ram uboot prompt.

Botting from ther USB

=> usb start
starting USB...
USB0:   Port not available.
USB1:   USB EHCI 1.00
scanning bus 1 for devices... 2 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
       scanning usb for ethernet devices... 0 Ethernet Device(s) found


Check if you have the files on the USB

=> ls usb 0:!
** Bad partition specification usb 0:! **
=> ls usb 0:1
    35125   imx6ull-var-dart-6ulcustomboard-emmc-sd-card.dtb
    35124   imx6ull-var-dart-6ulcustomboard-emmc-wifi.dtb

Check the rootfs



=> ls usb 0:2
<DIR>       4096 .
<DIR>       4096 ..
<DIR>       4096 bin
<DIR>       4096 boot
<DIR>       4096 dev
<DIR>       4096 etc
<DIR>       4096 home
<DIR>       4096 lib
<DIR>       4096 lost+found
<DIR>       4096 media
<DIR>       4096 mnt
<DIR>       4096 opt
<DIR>       4096 proc
<DIR>       4096 root
<DIR>       4096 run
<DIR>       4096 sbin
<DIR>       4096 srv
<DIR>       4096 sys
<DIR>       4096 tmp
<DIR>       4096 usr
<DIR>       4096 var
=>


Let's boot form it.

3 weeks later, using ums gadget

Prerequisites
  • uuu  (mfgtools). Clone it from git hub. cmake. && make
    • eventually change the cmake version in every CMakeList.txt
  • u-boot.imx 
    • Build as explained above
 Procedure
    
  •  connect male to male imx6ull usb cable from USB2 to PC
    • Connect the micro USB from imx to the board
  • open terminal1 and screen /dev/ttyUSB0 115200
  •  in terminal2 copy to mfgtools the u-boot.imx
    • type ./uuu ./u-boot.imx
  • In screen terminal you should see the uboot messages
    • stop it at =>  prompt
    • type 
      • mmc rescan
      • ums mmc 1
    • you should have now a block device /dev/sdX, like the next block device available in your system
  • at this point you can flash block device as any other HDD device, using dd and or fdisk.























No comments:

Post a Comment