blob: 6877243e895afa3c9e20dddab4c8fb03dfbd37df (
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
inherit image_types
IMAGE_BOOTLOADER ?= "u-boot"
# Handle u-boot suffixes
UBOOT_SUFFIX ?= "bin"
UBOOT_PADDING ?= "0"
UBOOT_SUFFIX_SDCARD ?= "${UBOOT_SUFFIX}"
#
# Handles i.MX mxs bootstream generation
#
UBOOT_SUFFIX_SDCARD_mxs ?= "mxsboot-sdcard"
IMAGE_DEPENDS_uboot.mxsboot-sdcard = "u-boot-mxsboot-native u-boot"
IMAGE_CMD_uboot.mxsboot-sdcard = "mxsboot sd ${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX} \
${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX_SDCARD}"
# Default to 3.4GiB images
SDCARD_SIZE ?= "3400"
# Boot partition volume id
BOOTDD_VOLUME_ID ?= "Boot ${MACHINE}"
# Addional space for boot partition
BOOT_SPACE ?= "5MiB"
IMAGE_DEPENDS_sdcard = "parted-native dosfstools-native mtools-native \
virtual/kernel ${IMAGE_BOOTLOADER}"
SDCARD = "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.sdcard"
SDCARD_GENERATION_COMMAND_mxs = "generate_mxs_sdcard"
SDCARD_GENERATION_COMMAND_mx5 = "generate_imx_sdcard"
SDCARD_GENERATION_COMMAND_mx6 = "generate_imx_sdcard"
#
# Create an image that can by written onto a SD card using dd for use
# with i.MX SoC family
#
# External variables needed:
# ${SDCARD_ROOTFS} - the rootfs image to incorporate
# ${IMAGE_BOOTLOADER} - bootloader to use {u-boot, barebox}
#
# The disk layout used is:
#
# 0 - 1M - reserved to bootloader and other data
# 1M - BOOT_SPACE - kernel
# BOOT_SPACE - SDCARD_SIZE - rootfs
#
generate_imx_sdcard () {
# Create partition table
parted -s ${SDCARD} mklabel msdos
parted -s ${SDCARD} mkpart primary 0 1MiB
parted -s ${SDCARD} mkpart primary 1MiB ${BOOT_SPACE}
parted -s ${SDCARD} mkpart primary ${BOOT_SPACE} 100%
parted ${SDCARD} print
case "${IMAGE_BOOTLOADER}" in
u-boot)
dd if=${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX_SDCARD} of=${SDCARD} conv=notrunc seek=2 skip=${UBOOT_PADDING} bs=512
;;
barebox)
dd if=${DEPLOY_DIR_IMAGE}/barebox-${MACHINE}.bin of=${SDCARD} conv=notrunc seek=1 skip=1 bs=512
dd if=${DEPLOY_DIR_IMAGE}/bareboxenv-${MACHINE}.bin of=${SDCARD} conv=notrunc seek=1 bs=512k
;;
*)
bberror "Unkown IMAGE_BOOTLOADER value"
exit 1
;;
esac
BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDCARD} unit b print \
| awk '/ 2 / { print substr($4, 1, length($4 -1)) / 1024 }')
mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS
mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/uImage-${MACHINE}.bin ::/uImage
dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc seek=1 bs=1M
dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc seek=1 bs=${BOOT_SPACE}
}
#
# Create an image that can by written onto a SD card using dd for use
# with i.MXS SoC family
#
# External variables needed:
# ${SDCARD_ROOTFS} - the rootfs image to incorporate
# ${IMAGE_BOOTLOADER} - bootloader to use {u-boot, barebox}
#
# The disk layout used is:
#
# 1M - 2M - reserved to bootloader and other data
# 2M - BOOT_SPACE - kernel
# BOOT_SPACE - SDCARD_SIZE - rootfs
#
generate_mxs_sdcard () {
# Create partition table
parted -s ${SDCARD} mklabel msdos
parted -s ${SDCARD} mkpart primary 1MiB 2MiB
parted -s ${SDCARD} mkpart primary 2MiB ${BOOT_SPACE}
parted -s ${SDCARD} mkpart primary ${BOOT_SPACE} 100%
parted ${SDCARD} print
# Change partition type for mxs processor family
bbnote "Setting partition type to 0x53 as required for mxs' SoC family."
echo -n S | dd of=${SDCARD} bs=1 count=1 seek=450 conv=notrunc
case "${IMAGE_BOOTLOADER}" in
u-boot)
dd if=${DEPLOY_DIR_IMAGE}/u-boot-${MACHINE}.${UBOOT_SUFFIX_SDCARD} of=${SDCARD} conv=notrunc seek=1 skip=${UBOOT_PADDING} bs=1MiB
;;
*)
bberror "Unkown IMAGE_BOOTLOADER value"
exit 1
;;
esac
BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDCARD} unit b print \
| awk '/ 2 / { print substr($4, 1, length($4 -1)) / 1024 }')
mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 -C ${WORKDIR}/boot.img $BOOT_BLOCKS
mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/uImage-${MACHINE}.bin ::/uImage
dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc seek=2 bs=1MiB
dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc seek=1 bs=${BOOT_SPACE}
}
IMAGE_CMD_sdcard () {
if [ -z "${SDCARD_ROOTFS}" ]; then
bberror "SDCARD_ROOTFS is undefined. To use sdcard image from Freescale's BSP it needs to be defined."
exit 1
fi
# Initialize a sparse file
dd if=/dev/zero of=${SDCARD} bs=1 count=0 seek=$(expr 1000 \* 1000 \* ${SDCARD_SIZE})
${SDCARD_GENERATION_COMMAND}
}
|