xref: /haiku/build/jam/images/MMCImage (revision d12bb8b14803d030b4a8fba91131e4bb96c4f406)
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
9# Files must be in this order: loader floppyboot everything_else
10rule BuildUBootSDImage image : files
11{
12    Depends $(image) : $(files) $(TARGET_DEVICE_TREES) ;
13    SDIMAGE_BLOCK_SIZE on $(image) = 1048576 ; # 1MiB
14    SDIMAGE_MTOOLS_H on $(image) = 255 ;
15    SDIMAGE_MTOOLS_S on $(image) = 63 ;
16    SDIMAGE_MTOOLS_C on $(image) = 8 ;
17    SDIMAGE_SIZE on $(image) = $(HAIKU_BOOT_SDIMAGE_SIZE) ;
18    SDIMAGE_BEGIN on $(image) = $(HAIKU_BOOT_SDIMAGE_BEGIN:E=63) ;
19    BuildUBootSDImage1 $(image) : $(files) ;
20}
21
22actions BuildUBootSDImage1
23{
24    $(RM) $(1)
25    $(RM) $(1).mtools
26
27    # make an empty image
28    dd of=$(1) \
29        if=/dev/zero \
30        bs=$(SDIMAGE_BLOCK_SIZE) \
31        count=$(SDIMAGE_SIZE)
32    # generate mtools config
33    echo 'drive i: file="$(1)" partition=1 cylinders=$(SDIMAGE_MTOOLS_C)
34        heads=$(SDIMAGE_MTOOLS_H) sectors=$(SDIMAGE_MTOOLS_S)
35        mformat_only' > $(1).mtools
36    # partition it
37    MTOOLSRC=$(1).mtools mpartition -b$(SDIMAGE_BEGIN) -cI -T 0xc i:
38    # format the image
39    MTOOLSRC=$(1).mtools mformat -L 32 -v "HAIKU" i:
40
41    # generate u-boot environment variables
42    echo 'os=haiku' > uEnv.txt
43    # populate
44    $(CP) $(2[2-2]) haiku_loader.ub
45    MTOOLSRC=$(1).mtools mcopy haiku_loader.ub i:
46    $(RM) haiku_loader.ub
47    $(CP) $(2[3-3]) haiku_floppyboot.ub
48    MTOOLSRC=$(1).mtools mcopy haiku_floppyboot.ub i:
49    $(RM) haiku_floppyboot.ub
50    MTOOLSRC=$(1).mtools mcopy $(2[4-]) i:
51    MTOOLSRC=$(1).mtools mcopy uEnv.txt i:
52    # populate fdts
53    MTOOLSRC=$(1).mtools mmd i:\fdt
54    MTOOLSRC=$(1).mtools mcopy $(TARGET_DEVICE_TREES[1-]) i:\fdt\
55    # list content
56    MTOOLSRC=$(1).mtools mdir i:
57    MTOOLSRC=$(1).mtools mdir i:\fdt
58    # cleanup
59    $(RM) $(1).mtools
60    $(RM) uEnv.txt
61    $(RM) boot.scr
62    # Add haiku bootstrap partition to MMC image
63    cat $(2[0]) >> $(1)
64}
65
66# SD/mmc image targets
67BuildUBootSDImage $(HAIKU_MMC_NAME) :
68    $(HAIKU_IMAGE) haiku_loader.u-boot haiku-floppyboot.tgz.u-boot boot.scr ;
69#BlessSDImage haiku-$(TARGET_KERNEL_ARCH).mmc ;
70NotFile haiku-mmc-image ;
71Depends haiku-mmc-image : $(HAIKU_MMC_NAME) ;
72