# VIMx (VIM1 VIM2 VIM3 VIM3L) and Edge mainline uboot images (GENERATED: Sun 08 Oct 2023 09:39:21 AM UTC)

## META

 Edge.u-boot.sd.bin.meta:UBOOT_VER: 2021.07+
 Edge.u-boot.sd.bin.meta:DATE: Sun, 08 Oct 2023 17:39:21 +0800
 Edge.u-boot.sd.bin.meta:GIT_DOWNLOAD: https://github.com/khadas/khadas-uboot/releases/tag/0.17.2
 VIM1.u-boot.sd.bin.meta:UBOOT_VER: 2021.07+
 VIM1.u-boot.sd.bin.meta:DATE: Sun, 08 Oct 2023 17:38:34 +0800
 VIM1.u-boot.sd.bin.meta:GIT_DOWNLOAD: https://github.com/khadas/khadas-uboot/releases/tag/0.17.2
 VIM2.u-boot.sd.bin.meta:UBOOT_VER: 2021.07+
 VIM2.u-boot.sd.bin.meta:DATE: Sun, 08 Oct 2023 17:38:44 +0800
 VIM2.u-boot.sd.bin.meta:GIT_DOWNLOAD: https://github.com/khadas/khadas-uboot/releases/tag/0.17.2
 VIM3.u-boot.sd.bin.meta:UBOOT_VER: 2021.07+
 VIM3.u-boot.sd.bin.meta:DATE: Sun, 08 Oct 2023 17:38:56 +0800
 VIM3.u-boot.sd.bin.meta:GIT_DOWNLOAD: https://github.com/khadas/khadas-uboot/releases/tag/0.17.2
 VIM3L.u-boot.sd.bin.meta:UBOOT_VER: 2021.07+
 VIM3L.u-boot.sd.bin.meta:DATE: Sun, 08 Oct 2023 17:39:07 +0800
 VIM3L.u-boot.sd.bin.meta:GIT_DOWNLOAD: https://github.com/khadas/khadas-uboot/releases/tag/0.17.2

# mainline u-boot for Khadas VIM and EDGE sbc series

## Features

+ universal series for VIM1 VIM2 VIM3 VIM3L EDGE boards
+ mainline u-boot + patches
+ suitable for SPI - SD - MMC
+ spi flash - read / write / bootup / env
+ usb kbd
+ usb storages
+ pcie + nvme storage
+ HDMI output
+ HDMI 4K supported
+ EFI
+ syslinux / pxetools
+ boot raw and compressed(gz lzma zstd lzop) kernel
+ embed LOGO splash - easy customize
+ extra commands like `script` `kbi`
+ boot seq SPI => USB => SD => NVME => MMC => PXE => DHCP
+ fully stand-alone
+ embed env suitable for SPI/MMC/SD
+ meta info

## Special environment Options

    no_video - disable video
    no_usb   - disable usb
    no_pci   - disable pci

```
# Activate
setenv no_video yes
setenv no_usb yes
setenv no_pci yes
saveenv

# Deactivate
setenv no_video
setenv no_usb
setenv no_pci
saveenv

```

## Environment location autodetection

+ uboot booted from SPI => Environment use SPI location
+ uboot booted from MMC/SD => Environment use MMC/SD location

## Embed Environment VIM

UBOOT_ENV_OFFSET=0x140000
UBOOT_ENV_SIZE=0x8000
UBOOT_ENV_SIZE=32768

```
saveenv
```
NOTE: spi/sd/emmc have same env offset and size

## NVME pcie vim3/Edge usage

can bootup from from pcie ( U-Boot 2021.07 )

VIM3/VIM3L prepare

    # configure pcie portmode 
    kbi portmode 1
    kbi poweroff

    # activate
    run boot_pci_enum; run nvme_init;

PCIE-0: Link up (Gen2-x1, Bus0)

    nvme info

Device 0: Vendor: 0x2646 Rev: S5Z42105 Prod: 50026B728253D824
Type: Hard Disk
Capacity: 238475.1 MB = 232.8 GB (488397168 x 512)

## setup boot mode under Krescue

main menu -> kbi device configure -> Set Port Mode to PCIe

## Update/Write eMMC U-Boot via Krescue

Advanced -> Experimental -> Update/Write U-Boot by online to EMMC

NOTE: non destructive for mainline linux OS

## Other features

### get meta from image file

    tail -n19 VIM*.u-boot.sd.bin
    tail -n19 VIM*.u-boot.spi.bin

    grep -m1 \#\#UBOOT\#\# -B18 /dev/mmcblk1
    head -c2m /dev/mmcblk1 | grep -m1 \#\#UBOOT\#\# -B18 # get sd/mmc uboot meta
    grep -m1 \#\#UBOOT\#\# -B18 /dev/mtdblock0           # get spi uboot meta

## check online meta examples

    curl https://dl.khadas.com/Firmware/uboot/mainline/VIM2.u-boot.spi.bin.meta
    curl https://github.com/khadas/khadas-uboot/releases/download/0.10/VIM2.u-boot.sd.bin.meta
    wget -qO- https://github.com/khadas/khadas-uboot/releases/download/0.10/VIM2.u-boot.spi.bin.meta
    https://github.com/khadas/khadas-uboot/releases/latest


### PXE FDT overlays example usage

    FDTOVERLAYS   fdt/ethmac_disable.dtbo fdt/pcie_disable.dtbo fdt/vpu_disable.dtbo
    FDTOVERLAYDIR fdt
    FDTOVERLAYS   ethmac_disable.dtbo pcie_disable.dtbo vpu_disable.dtbo
    FDTOVERLAYS   ethmac_disable pcie_disable vpu_disable

## VIMx sd / mmc / emmc uboot

+ VIM1.u-boot.sd.bin
+ VIM2.u-boot.sd.bin
+ VIM3.u-boot.sd.bin
+ VIM3L.u-boot.sd.bin
```
    # write to sd / emmc - example
    dd if=VIM3L.u-boot.sd.bin of=/dev/mmcblk? conv=fsync,notrunc bs=442 count=1
    dd if=VIM3L.u-boot.sd.bin of=/dev/mmcblk? conv=fsync,notrunc bs=512 skip=1 seek=1
```

!NOTE: same can be writed by 0 offset to sd / mmc ( cat VIM?.u-boot.sd.bin > /dev/mmcblk? ) 
!NOTE: but partition table will be rewrited missed ( by 442 offset ) and need created it

## VIMx spi flash uboot

+ VIM1.u-boot.spi.bin
+ VIM2.u-boot.spi.bin
+ VIM3.u-boot.spi.bin
+ VIM3L.u-boot.spi.bin

!NOTE: write to spi flash by 0 offset

## EDGE sd / mmc / emmc uboot

+ Edge.u-boot.mmc.64.bin
```
    # write to sd / emmc - example
    dd if=Edge.u-boot.mmc.64.bin of=/dev/mmcblk? conv=fsync,notrunc seek=64
```

!NOTE: write to 64*512 bytes offset
+ Edge.u-boot.sd.bin
```
    # write to sd / emmc - example
    dd if=Edge.u-boot.sd.bin of=/dev/mmcblk? conv=fsync,notrunc skip=64 seek=64
    # or just from begin and rewrite mbr
    dd if=Edge.u-boot.sd.bin of=/dev/mmcblk? conv=fsync,notrunc
```

!NOTE: write to 0 offset

## EDGEx spi flash uboot

+ Edge.u-boot.spi.bin

!NOTE: write to spi flash by 0 offset

## VIMx mmc uboot for aml-burn-tool

+ VIM1.uboot-mainline.emmc.aml.img
+ VIM2.uboot-mainline.emmc.aml.img
+ VIM3.uboot-mainline.emmc.aml.img
+ VIM3L.uboot-mainline.emmc.aml.img
!NOTE: emmc mainline uboot images for burn via aml-burn-tool software

```
    # burn example
    aml-burn-tool -b VIM? -i VIM?.uboot-mainline.emmc.aml.img
```


## VIMx mmc uboot for krescue

+ VIM*kresq

!NOTE: emmc mainline uboot images for krescue software


## ADDITIONAL

+ list.md5sum	- md5 sum list

## DOWNLOADS

+ https://dl.khadas.com/Firmware/uboot/main-line/
+ https://github.com/khadas/khadas-uboot/releases/tag/last

## LINKS

+ https://docs.khadas.com/
+ https://forum.khadas.com/
+ https://github.com/khadas
+ https://github.com/khadas/khadas-uboot
+ https://dl.khadas.com/Firmware/Krescue/