MMCImage revision dd45d433
1# Set anyboot file name and directory defaults.
2HAIKU_MMC_NAME ?= $(HAIKU_DEFAULT_MMC_NAME) ;
3HAIKU_MMC_DIR ?= $(HAIKU_DEFAULT_MMC_DIR) ;
4HAIKU_MMC = $(HAIKU_MMC_NAME) ;
5HAIKU_MMC_LABEL ?= $(HAIKU_DEFAULT_MMC_LABEL) ;
6
7# SD/mmc image rule
8# requires mtools package on linux
9rule BuildUBootSDImage image : files
10{
11    Depends $(image) : $(files) $(TARGET_DEVICE_TREES) ;
12    SDIMAGE_BLOCK_SIZE on $(image) = 1048576 ; # 1MiB
13    SDIMAGE_MTOOLS_H on $(image) = 255 ;
14    SDIMAGE_MTOOLS_S on $(image) = 63 ;
15    SDIMAGE_MTOOLS_C on $(image) = 8 ;
16    SDIMAGE_SIZE on $(image) = $(HAIKU_BOOT_SDIMAGE_SIZE) ;
17    SDIMAGE_BEGIN on $(image) = $(HAIKU_BOOT_SDIMAGE_BEGIN:E=63) ;
18    BuildUBootSDImage1 $(image) : $(files) ;
19}
20
21actions BuildUBootSDImage1
22{
23    $(RM) $(1)
24    $(RM) $(1).mtools
25
26    # make an empty image
27    dd of=$(1) \
28        if=/dev/zero \
29        bs=$(SDIMAGE_BLOCK_SIZE) \
30        count=$(SDIMAGE_SIZE)
31    # generate mtools config
32    echo 'drive i: file="$(1)" partition=1 cylinders=$(SDIMAGE_MTOOLS_C)
33        heads=$(SDIMAGE_MTOOLS_H) sectors=$(SDIMAGE_MTOOLS_S)
34        mformat_only' > $(1).mtools
35    # partition it
36    MTOOLSRC=$(1).mtools mpartition -b$(SDIMAGE_BEGIN) -cI -T 0xc i:
37    # format the image
38    MTOOLSRC=$(1).mtools mformat -L 32 -v "HAIKU" i:
39
40    # generate u-boot environment variables
41    echo '$(HAIKU_BOARD_SDIMAGE_UBOOT_UENV)' > uEnv.txt
42    # populate
43    MTOOLSRC=$(1).mtools mcopy $(2[1-]) i:
44    MTOOLSRC=$(1).mtools mcopy uEnv.txt i:
45    # populate fdts
46    MTOOLSRC=$(1).mtools mmd i:\fdt
47    MTOOLSRC=$(1).mtools mcopy $(TARGET_DEVICE_TREES[1-]) i:\fdt\
48    # list content
49    MTOOLSRC=$(1).mtools mdir i:
50    MTOOLSRC=$(1).mtools mdir i:\fdt
51    # cleanup
52    $(RM) $(1).mtools
53    $(RM) uEnv.txt
54    # Add haiku bootstrap partition to MMC image
55    #cat $(2[0]) >> $(1)
56}
57
58# SD/mmc image targets
59BuildUBootSDImage $(HAIKU_MMC_NAME) :
60    $(HAIKU_IMAGE) haiku_loader.u-boot haiku-floppyboot.tgz.u-boot boot.scr ;
61#BlessSDImage haiku-$(TARGET_KERNEL_ARCH).mmc ;
62NotFile haiku-mmc-image ;
63Depends haiku-mmc-image : $(HAIKU_MMC_NAME) ;
64