at91: sama7: fix racy SD card image generation
[openwrt/staging/nbd.git] / target / linux / at91 / image / sama7.mk
1
2 define Device/default-nand
3 BLOCKSIZE := 128k
4 PAGESIZE := 2048
5 SUBPAGESIZE := 2048
6 MKUBIFS_OPTS := -m $$(PAGESIZE) -e 124KiB -c 2048
7 endef
8
9 define Build/at91-sdcard
10 $(if $(findstring ext4,$@), \
11 rm -f $@.boot
12 mkfs.fat -C $@.boot $(FAT32_BLOCKS)
13
14 mcopy -i $@.boot \
15 $(KDIR)/$(DEVICE_NAME)-fit-zImage.itb \
16 ::$(DEVICE_NAME)-fit.itb
17
18 mcopy -i $@.boot \
19 $(BIN_DIR)/u-boot-$(DEVICE_DTS:at91-%=%)_mmc1/u-boot.bin \
20 ::u-boot.bin
21
22 mcopy -i $@.boot \
23 $(BIN_DIR)/at91bootstrap-$(DEVICE_DTS:at91-%=%)sd_uboot/at91bootstrap.bin \
24 ::BOOT.bin
25
26 $(CP) uboot-env.txt $@-uboot-env.txt
27 sed -i '2d;3d' $@-uboot-env.txt
28 sed -i '2i board='"$(DEVICE_NAME)"'' $@-uboot-env.txt
29 sed -i '3i board_name='"$(firstword $(SUPPORTED_DEVICES))"'' $@-uboot-env.txt
30
31 mkenvimage -s 0x4000 -o $@-uboot.env $@-uboot-env.txt
32
33 mcopy -i $@.boot $@-uboot.env ::uboot.env
34
35 ./gen_at91_sdcard_img.sh \
36 $@.img \
37 $@.boot \
38 $(IMAGE_ROOTFS) \
39 $(AT91_SD_BOOT_PARTSIZE) \
40 $(CONFIG_TARGET_ROOTFS_PARTSIZE)
41
42 gzip -nc9 $@.img > $@
43
44 rm -f $@.img $@.boot $@-uboot.env $@-uboot-env.txt)
45 endef
46
47 define Device/microchip_sama7g5-ek
48 $(Device/evaluation-dtb)
49 DEVICE_VENDOR := Microchip
50 DEVICE_MODEL := SAMA7G5-EK
51 DEVICE_DTS := at91-sama7g5ek
52 SUPPORTED_DEVICES := microchip,sama7g5ek
53 KERNEL_SIZE := 6144k
54 KERNEL_LOADADDR := 0x62000000
55 $(Device/evaluation-sdimage)
56 endef
57 TARGET_DEVICES += microchip_sama7g5-ek