diff options
author | Dalon Westergreen <dwesterg@gmail.com> | 2016-04-18 19:02:58 -0700 |
---|---|---|
committer | Dalon Westergreen <dwesterg@gmail.com> | 2016-04-18 19:54:20 -0700 |
commit | eb352fc6168b382bebd4587baadaecd754c96229 (patch) | |
tree | c77d7d310072d24f224f66002698b60e6bca6390 | |
parent | b27593878e1b9b51b4b3cb36639959d4744724bd (diff) | |
download | meta-altera-eb352fc6168b382bebd4587baadaecd754c96229.tar.gz |
Clean up variables for uboot
-> Moved common variables to socfpga.inc
-rw-r--r-- | classes/image_types_socfpga.bbclass | 134 | ||||
-rw-r--r-- | conf/machine/arria5.conf | 6 | ||||
-rw-r--r-- | conf/machine/cyclone5.conf | 13 | ||||
-rw-r--r-- | conf/machine/include/socfpga.inc | 9 | ||||
-rw-r--r-- | recipes-bsp/u-boot/u-boot-socfpga_2016.03.bb | 15 | ||||
-rw-r--r-- | recipes-bsp/u-boot/u-boot-target-env.inc | 69 |
6 files changed, 26 insertions, 220 deletions
diff --git a/classes/image_types_socfpga.bbclass b/classes/image_types_socfpga.bbclass deleted file mode 100644 index 609e651..0000000 --- a/classes/image_types_socfpga.bbclass +++ /dev/null | |||
@@ -1,134 +0,0 @@ | |||
1 | inherit image_types | ||
2 | |||
3 | IMAGE_BOOTLOADER ?= "u-boot-socfpga" | ||
4 | SDCARD_ROOTFS ?= "${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ext3" | ||
5 | |||
6 | # Boot partition size [in KiB] | ||
7 | IMAGE_ROOTFS_ALIGNMENT_cyclone5 ?= "2048" | ||
8 | IMAGE_ROOTFS_ALIGNMENT_arria5 ?= "2048" | ||
9 | IMAGE_ROOTFS_ALIGNMENT_arria10 ?= "10240" | ||
10 | |||
11 | BOOT_SPACE ?= "102400" | ||
12 | |||
13 | IMAGE_DEPENDS_sdcard = "parted-native:do_populate_sysroot \ | ||
14 | dosfstools-native:do_populate_sysroot \ | ||
15 | mtools-native:do_populate_sysroot \ | ||
16 | virtual/kernel:do_deploy \ | ||
17 | ${@d.getVar('IMAGE_BOOTLOADER', True) and d.getVar('IMAGE_BOOTLOADER', True) + ':do_deploy' or ''}" | ||
18 | |||
19 | SDCARD_GENERATION_COMMAND_cyclone5 = "generate_28nm_sdcard" | ||
20 | SDCARD_GENERATION_COMMAND_arria5 = "generate_28nm_sdcard" | ||
21 | |||
22 | # | ||
23 | # Generate the boot image with the boot scripts and required Device Tree | ||
24 | # files | ||
25 | _generate_boot_image() { | ||
26 | local boot_part=$1 | ||
27 | |||
28 | # Create boot partition image | ||
29 | BOOT_BLOCKS=$(LC_ALL=C parted -s ${SDCARD} unit b print \ | ||
30 | | awk "/ $boot_part / { print substr(\$4, 1, length(\$4 -1)) / 1024 }") | ||
31 | |||
32 | # mkdosfs will sometimes use FAT16 when it is not appropriate, | ||
33 | # resulting in a boot failure from SYSLINUX. Use FAT32 for | ||
34 | # images larger than 512MB, otherwise let mkdosfs decide. | ||
35 | if [ $(expr $BOOT_BLOCKS / 1024) -gt 512 ]; then | ||
36 | FATSIZE="-F 32" | ||
37 | fi | ||
38 | |||
39 | rm -f ${WORKDIR}/boot.img | ||
40 | mkfs.vfat -n "${BOOTDD_VOLUME_ID}" -S 512 ${FATSIZE} -C ${WORKDIR}/boot.img $BOOT_BLOCKS | ||
41 | |||
42 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin ::/${KERNEL_IMAGETYPE} | ||
43 | |||
44 | # Copy boot scripts | ||
45 | for item in ${BOOT_SCRIPTS}; do | ||
46 | src=`echo $item | awk -F':' '{ print $1 }'` | ||
47 | dst=`echo $item | awk -F':' '{ print $2 }'` | ||
48 | |||
49 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/$src ::/$dst | ||
50 | done | ||
51 | |||
52 | # Copy device tree file | ||
53 | if test -n "${KERNEL_DEVICETREE}"; then | ||
54 | for DTS_FILE in ${KERNEL_DEVICETREE}; do | ||
55 | DTS_BASE_NAME=`basename ${DTS_FILE} | awk -F "." '{print $1}'` | ||
56 | if [ -e "${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb" ]; then | ||
57 | kernel_bin="`readlink ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${MACHINE}.bin`" | ||
58 | kernel_bin_for_dtb="`readlink ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb | sed "s,$DTS_BASE_NAME,${MACHINE},g;s,\.dtb$,.bin,g"`" | ||
59 | if [ $kernel_bin = $kernel_bin_for_dtb ]; then | ||
60 | mcopy -i ${WORKDIR}/boot.img -s ${DEPLOY_DIR_IMAGE}/${KERNEL_IMAGETYPE}-${DTS_BASE_NAME}.dtb ::/${DTS_BASE_NAME}.dtb | ||
61 | fi | ||
62 | else | ||
63 | bbfatal "${DTS_FILE} does not exist." | ||
64 | fi | ||
65 | done | ||
66 | fi | ||
67 | } | ||
68 | |||
69 | generate_28nm_sdcard () { | ||
70 | # Create partition table | ||
71 | parted -s ${SDCARD} mklabel msdos | ||
72 | parted -s ${SDCARD} unit KiB mkpart primary fat32 ${IMAGE_ROOTFS_ALIGNMENT} $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED}) | ||
73 | parted -s ${SDCARD} unit KiB mkpart primary $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED}) $(expr ${IMAGE_ROOTFS_ALIGNMENT} \+ ${BOOT_SPACE_ALIGNED} \+ $ROOTFS_SIZE) | ||
74 | parted -s ${SDCARD} unit KiB mkpart primary 1024 2048 | ||
75 | |||
76 | #set part 3 to type a2 for spl / uboot image | ||
77 | echo -ne "\xa2" | dd of=${SDCARD} bs=1 count=1 seek=482 conv=notrunc | ||
78 | |||
79 | dd if=${DEPLOY_DIR_IMAGE}/${SPL_BINARY} of=${SDCARD} conv=notrunc seek=1 bs=$(expr 1024 \* 1024) | ||
80 | |||
81 | parted ${SDCARD} print | ||
82 | |||
83 | _generate_boot_image 1 | ||
84 | # Burn Partition | ||
85 | dd if=${WORKDIR}/boot.img of=${SDCARD} conv=notrunc,fsync seek=1 bs=$(expr ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) | ||
86 | dd if=${SDCARD_ROOTFS} of=${SDCARD} conv=notrunc,fsync seek=1 bs=$(expr ${BOOT_SPACE_ALIGNED} \* 1024 + ${IMAGE_ROOTFS_ALIGNMENT} \* 1024) | ||
87 | |||
88 | # Burn uboot env | ||
89 | if [ -e "${DEPLOY_DIR_IMAGE}/u-boot-envs/${CONFIG_TYPE}.bin" ] | ||
90 | then | ||
91 | dd of=${DEPLOY_DIR_IMAGE}/u-boot-envs/${CONFIG_TYPE}.bin of=${SDCARD} bs=1 count=1 seek=512 | ||
92 | fi | ||
93 | } | ||
94 | |||
95 | IMAGE_CMD_sdcard () { | ||
96 | if [ -z "${SDCARD_ROOTFS}" ]; then | ||
97 | bberror "SDCARD_ROOTFS is undefined. To use sdcard image from Freescale's BSP it needs to be defined." | ||
98 | exit 1 | ||
99 | fi | ||
100 | |||
101 | # Align boot partition and calculate total SD card image size | ||
102 | BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE} + ${IMAGE_ROOTFS_ALIGNMENT} - 1) | ||
103 | BOOT_SPACE_ALIGNED=$(expr ${BOOT_SPACE_ALIGNED} - ${BOOT_SPACE_ALIGNED} % ${IMAGE_ROOTFS_ALIGNMENT}) | ||
104 | SDCARD_SIZE=$(expr ${IMAGE_ROOTFS_ALIGNMENT} + ${BOOT_SPACE_ALIGNED} + $ROOTFS_SIZE + ${IMAGE_ROOTFS_ALIGNMENT}) | ||
105 | |||
106 | # Initialize a sparse file | ||
107 | SDCARD="${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.sdcard" | ||
108 | dd if=/dev/zero of=${SDCARD} bs=1 count=0 seek=$(expr 1024 \* ${SDCARD_SIZE}) | ||
109 | |||
110 | if [ "x${UBOOT_CONFIG}" != "x" ] | ||
111 | then | ||
112 | for config in ${UBOOT_MACHINE}; do | ||
113 | i=`expr $i + 1`; | ||
114 | for type in ${UBOOT_CONFIG}; do | ||
115 | j=`expr $j + 1`; | ||
116 | if [ $j -eq $i ] | ||
117 | then | ||
118 | CONFIG_TYPE="${type}" | ||
119 | UBOOT_SFP_IMAGE="${SPL_IMAGE}-${MACHINE}-${type}" | ||
120 | ${SDCARD_GENERATION_COMMAND} | ||
121 | fi | ||
122 | done | ||
123 | unset j | ||
124 | done | ||
125 | unset i | ||
126 | else | ||
127 | UBOOT_SFP_IMAGE="${SPL_IMAGE}-${MACHINE}" | ||
128 | ${SDCARD_GENERATION_COMMAND} | ||
129 | fi | ||
130 | } | ||
131 | |||
132 | # The sdcard requires the rootfs filesystem to be built before using | ||
133 | # it so we must make this dependency explicit. | ||
134 | IMAGE_TYPEDEP_sdcard = "${@d.getVar('SDCARD_ROOTFS', 1).split('.')[-1]}" \ No newline at end of file | ||
diff --git a/conf/machine/arria5.conf b/conf/machine/arria5.conf index 193403c..1cd460d 100644 --- a/conf/machine/arria5.conf +++ b/conf/machine/arria5.conf | |||
@@ -4,9 +4,13 @@ | |||
4 | 4 | ||
5 | require conf/machine/include/socfpga.inc | 5 | require conf/machine/include/socfpga.inc |
6 | 6 | ||
7 | PREFERRED_VERSION_u-boot-socfpga ?= "2016.03" | 7 | PREFERRED_VERSION_u-boot-socfpga ?= "2016.03%" |
8 | 8 | ||
9 | UBOOT_CONFIG ?= "arria5-socdk" | 9 | UBOOT_CONFIG ?= "arria5-socdk" |
10 | 10 | ||
11 | UBOOT_CONFIG[arria5-socdk] = "socfpga_arria5_defconfig,sdcard" | ||
12 | |||
11 | KMACHINE = "arria5" | 13 | KMACHINE = "arria5" |
12 | 14 | ||
15 | # Default kernel devicetrees | ||
16 | KERNEL_DEVICETREE_arria5 ?= "socfpga_arria5_socdk.dtb" | ||
diff --git a/conf/machine/cyclone5.conf b/conf/machine/cyclone5.conf index 7d0aab0..7f39d39 100644 --- a/conf/machine/cyclone5.conf +++ b/conf/machine/cyclone5.conf | |||
@@ -4,9 +4,18 @@ | |||
4 | 4 | ||
5 | require conf/machine/include/socfpga.inc | 5 | require conf/machine/include/socfpga.inc |
6 | 6 | ||
7 | PREFERRED_VERSION_u-boot-socfpga ?= "2016.03" | 7 | PREFERRED_VERSION_u-boot-socfpga ?= "2016.03%" |
8 | 8 | ||
9 | UBOOT_CONFIG ?= "cyclone5-socdk" | 9 | UBOOT_CONFIG ??= "cyclone5-socdk" |
10 | |||
11 | UBOOT_CONFIG[cyclone5-socdk] = "socfpga_cyclone5_defconfig" | ||
12 | UBOOT_CONFIG[de0-nano-soc] = "socfpga_de0_nano_soc_defconfig" | ||
13 | UBOOT_CONFIG[mcvevk] = "socfpga_mcvevk_defconfig" | ||
14 | UBOOT_CONFIG[sockit] = "socfpga_sockit_defconfig" | ||
15 | UBOOT_CONFIG[socrates] = "socfpga_socrates_defconfig" | ||
16 | UBOOT_CONFIG[sr1500] = "socfpga_sr1500_defconfig" | ||
10 | 17 | ||
11 | KMACHINE = "cyclone5" | 18 | KMACHINE = "cyclone5" |
12 | 19 | ||
20 | # Default kernel devicetrees | ||
21 | KERNEL_DEVICETREE ?= "socfpga_cyclone5_socdk.dtb socfpga_cyclone5_sockit.dtb socfpga_cyclone5_socrates.dtb socfpga_cyclone5_de0_sockit.dtb" | ||
diff --git a/conf/machine/include/socfpga.inc b/conf/machine/include/socfpga.inc index 6932620..19106a1 100644 --- a/conf/machine/include/socfpga.inc +++ b/conf/machine/include/socfpga.inc | |||
@@ -25,3 +25,12 @@ MACHINE_FEATURES = "kernel26" | |||
25 | # file system images required | 25 | # file system images required |
26 | IMAGE_FSTYPES ?= "cpio ext3 tar.gz" | 26 | IMAGE_FSTYPES ?= "cpio ext3 tar.gz" |
27 | 27 | ||
28 | # u-boot setup | ||
29 | UBOOT_SUFFIX = "img" | ||
30 | |||
31 | # AV and CV uBoot + SPL mkpimage type binary | ||
32 | SPL_BINARY_cyclone5 = "u-boot-with-spl.sfp" | ||
33 | SPL_BINARY_arria5 = "u-boot-with-spl.sfp" | ||
34 | |||
35 | |||
36 | |||
diff --git a/recipes-bsp/u-boot/u-boot-socfpga_2016.03.bb b/recipes-bsp/u-boot/u-boot-socfpga_2016.03.bb index 1d0376e..9189715 100644 --- a/recipes-bsp/u-boot/u-boot-socfpga_2016.03.bb +++ b/recipes-bsp/u-boot/u-boot-socfpga_2016.03.bb | |||
@@ -6,23 +6,10 @@ SRCREV = "df61a74e6845ec9bdcdd48d2aff5e9c2c6debeaa" | |||
6 | LICENSE = "GPLv2+" | 6 | LICENSE = "GPLv2+" |
7 | LIC_FILES_CHKSUM = "file://Licenses/README;md5=a2c678cfd4a4d97135585cad908541c6" | 7 | LIC_FILES_CHKSUM = "file://Licenses/README;md5=a2c678cfd4a4d97135585cad908541c6" |
8 | 8 | ||
9 | PV = "v2016.03" | 9 | PV = "2016.03" |
10 | PV_append = "+git${SRCPV}" | 10 | PV_append = "+git${SRCPV}" |
11 | 11 | ||
12 | DEPENDS += "dtc-native" | 12 | DEPENDS += "dtc-native" |
13 | 13 | ||
14 | UBOOT_CONFIG ??= "cyclone5-socdk arria5-socdk de0-nano-soc sockit socrates" | ||
15 | UBOOT_CONFIG[cyclone5-socdk] = "socfpga_cyclone5_defconfig" | ||
16 | UBOOT_CONFIG[arria5-socdk] = "socfpga_arria5_defconfig" | ||
17 | UBOOT_CONFIG[de0-nano-soc] = "socfpga_de0_nano_soc_defconfig" | ||
18 | UBOOT_CONFIG[mcvevk] = "socfpga_mcvevk_defconfig" | ||
19 | UBOOT_CONFIG[sockit] = "socfpga_sockit_defconfig" | ||
20 | UBOOT_CONFIG[socrates] = "socfpga_socrates_defconfig" | ||
21 | UBOOT_CONFIG[sr1500] = "socfpga_sr1500_defconfig" | ||
22 | |||
23 | UBOOT_SUFFIX = "img" | ||
24 | |||
25 | SPL_BINARY_cyclone5 = "u-boot-with-spl.sfp" | ||
26 | SPL_BINARY_arria5 = "u-boot-with-spl.sfp" | ||
27 | 14 | ||
28 | 15 | ||
diff --git a/recipes-bsp/u-boot/u-boot-target-env.inc b/recipes-bsp/u-boot/u-boot-target-env.inc deleted file mode 100644 index c418a16..0000000 --- a/recipes-bsp/u-boot/u-boot-target-env.inc +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
1 | # Handle severals environments generation for u-boot | ||
2 | |||
3 | #Env binary size | ||
4 | ENV_SIZE = "0x1000" | ||
5 | |||
6 | ENV_BIN_DIR = "${WORKDIR}/target_env_bin" | ||
7 | |||
8 | # Env deploy dir is the name of directory where binary envs will be deployed | ||
9 | ENV_DEPLOY_DIR="u-boot-envs" | ||
10 | |||
11 | # Env deploy src dir is the name of directory where txt envs will be deployed | ||
12 | ENV_SRC_DEPLOY_DIR="u-boot-envs-src" | ||
13 | |||
14 | do_build_mkimage_tool () { | ||
15 | HOSTCC="${CC}" HOSTLD="${LD}" HOSTLDFLAGS="${LDFLAGS}" HOSTSTRIP=true oe_runmake sandbox_defconfig | ||
16 | HOSTCC="${CC}" HOSTLD="${LD}" HOSTLDFLAGS="${LDFLAGS}" HOSTSTRIP=true oe_runmake tools | ||
17 | } | ||
18 | |||
19 | python do_environment_mkimage() { | ||
20 | import subprocess | ||
21 | import shutil | ||
22 | # list env variant target files | ||
23 | target_root_dir = d.getVar('WORKDIR',True) | ||
24 | # env files only for UBOOT_CONFIG | ||
25 | env_uboot_config = d.getVar('UBOOT_CONFIG',True) | ||
26 | env_files = [] | ||
27 | for f in os.listdir(target_root_dir): | ||
28 | if f.endswith(".env"): | ||
29 | env_files.append(os.path.join(target_root_dir,f)) | ||
30 | env_bin_dir = d.getVar("ENV_BIN_DIR",True) | ||
31 | # cleans if it exists env_bin directory | ||
32 | shutil.rmtree(env_bin_dir, ignore_errors=True) | ||
33 | # create env bin directory | ||
34 | os.mkdir(env_bin_dir) | ||
35 | print 'Building binary environments in : %s' % env_bin_dir | ||
36 | # iterate targets list to build binary environment files | ||
37 | for target_env in env_files : | ||
38 | # get only filename without path and extension | ||
39 | target_filename = os.path.splitext(os.path.basename(target_env))[0] | ||
40 | if target_filename not in env_uboot_config: | ||
41 | continue | ||
42 | # build output file path with ext | ||
43 | target_bin = os.path.join(env_bin_dir, | ||
44 | target_filename + '.bin') | ||
45 | # generated mkenvimage tool command line | ||
46 | cmd_mkimg ='cat %s | grep -v -E "^$|^\#" |' \ | ||
47 | ' ./tools/mkenvimage -s %s -r -o %s -' \ | ||
48 | % ( target_env, | ||
49 | d.getVar("ENV_SIZE",True), target_bin) | ||
50 | print 'Building binary for %s target:' % (target_filename) | ||
51 | print '%s' % cmd_mkimg | ||
52 | # execute shell command | ||
53 | ret = subprocess.call(cmd_mkimg, shell=True) | ||
54 | if ret: return ret | ||
55 | return 0 | ||
56 | } | ||
57 | |||
58 | do_deploy_append() { | ||
59 | install -d ${DEPLOYDIR} | ||
60 | # deploy binary U-boot environments | ||
61 | echo "Deploying U-boot Environments binary files in ${DEPLOYDIR}/${ENV_DEPLOY_DIR}" | ||
62 | install -d ${DEPLOYDIR}/${ENV_DEPLOY_DIR} | ||
63 | |||
64 | |||
65 | cp ${ENV_BIN_DIR}/*.bin ${DEPLOYDIR}/${ENV_DEPLOY_DIR} | ||
66 | } | ||
67 | |||
68 | addtask build_mkimage_tool after do_compile before do_environment_mkimage | ||
69 | addtask environment_mkimage after do_build_mkimage_tool before do_deploy | ||