summaryrefslogtreecommitdiffstats
path: root/meta-aspeed/classes/aspeed_uboot_image.bbclass
blob: b22b0b8d5a0f701f1caaac4460d4c6e8f3b48bd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
inherit image_types_uboot

# oe_mkimage() was defined in image_types_uboot. Howver, it does not consider
# the image load address and entry point. Override it here.

oe_mkimage () {
    mkimage -A ${UBOOT_ARCH} -O linux -T ramdisk -C $2 -n ${IMAGE_NAME} \
        -a ${UBOOT_IMAGE_LOADADDRESS} -e ${UBOOT_IMAGE_ENTRYPOINT} \
        -d ${DEPLOY_DIR_IMAGE}/$1 ${DEPLOY_DIR_IMAGE}/$1.u-boot
}

UBOOT_IMAGE_ENTRYPOINT ?= "0x42000000"
UBOOT_IMAGE_LOADADDRESS ?= "${UBOOT_IMAGE_ENTRYPOINT}"

# 24M
IMAGE_ROOTFS_SIZE = "24576"
# and don't put overhead behind my back
IMAGE_OVERHEAD_FACTOR = "1"

IMAGE_PREPROCESS_COMMAND += " generate_data_mount_dir ; "
IMAGE_POSTPROCESS_COMMAND += " flash_image_generate ; "

FLASH_IMAGE_NAME ?= "flash-${MACHINE}-${DATETIME}"
FLASH_IMAGE_LINK ?= "flash-${MACHINE}"
# 16M
FLASH_SIZE ?= "16384"
FLASH_UBOOT_OFFSET ?= "0"
# 512k
FLASH_KERNEL_OFFSET ?= "512"
# 3M
FLASH_ROOTFS_OFFSET ?= "3072"

flash_image_generate() {
  kernelfile="${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}"
  ubootfile="${DEPLOY_DIR_IMAGE}/u-boot.${UBOOT_SUFFIX}"
  # rootfs has to match the type defined in IMAGE_FSTYPES"
  rootfs="${DEPLOY_DIR_IMAGE}/${IMAGE_LINK_NAME}.cpio.lzma.u-boot"
  if [ ! -f $kernelfile ]; then
    echo "Kernel file ${kernelfile} does not exist"
    return 1
  fi
  if [ ! -f $ubootfile ]; then
    echo "U-boot file ${ubootfile} does not exist"
    return 1
  fi
  if [ ! -f $rootfs ]; then
    echo "Rootfs file ${rootfs} does not exist"
    return 1
  fi
  dst="${DEPLOY_DIR_IMAGE}/${FLASH_IMAGE_NAME}"
  rm -rf $dst
  dd if=/dev/zero of=${dst} bs=1k count=${FLASH_SIZE}
  dd if=${ubootfile} of=${dst} bs=1k seek=${FLASH_UBOOT_OFFSET}
  dd if=${kernelfile} of=${dst} bs=1k seek=${FLASH_KERNEL_OFFSET}
  dd if=${rootfs} of=${dst} bs=1k seek=${FLASH_ROOTFS_OFFSET}
  dstlink="${DEPLOY_DIR_IMAGE}/${FLASH_IMAGE_LINK}"
  rm -rf $dstlink
  ln -sf ${FLASH_IMAGE_NAME} $dstlink
}

generate_data_mount_dir() {
  mkdir -p "${IMAGE_ROOTFS}/mnt/data"
}
OpenPOWER on IntegriCloud