initial version
[otheros_bootloader.git] / Makefile
blob11ddf345d268f611f52edfab3ce2c8a58de27b3a
2 CC=cc
3 LD=ld
4 OBJCOPY=objcopy
5 CFLAGS=-Wall -O2
7 SRC_otheros_bootloader_loader=otheros_bootloader_loader.S
8 OBJ_otheros_bootloader_loader=$(SRC_otheros_bootloader_loader:.S=.o)
9 TARGET_otheros_bootloader_loader=otheros_bootloader_loader.bin
11 PETITBOOT_IMAGE=dtbImage.ps3.bin
12 VFLASH_IMAGE=vflash.bin
13 VFLASH_DEV_DEFAULT=/dev/ps3vflashf
14 VFLASH_DEV_LINUX=/dev/ps3vflashh1
15 RAM_DEV=/dev/ps3ram
16 SLL_LOAD_LV2_OFFSET=0x00165e44
17 LOG2_PAGE_SIZE_OFFSET=0x000a7dd0 + 0x0000001b0
18 VFLASH_REGION_OFFSET=0x006b3f80 + 0x00000018
20 $(TARGET_otheros_bootloader_loader): $(OBJ_otheros_bootloader_loader)
21 $(OBJCOPY) -O binary $^ $@
23 SRC_mkimage=mkimage.c
24 OBJ_mkimage=$(SRC_mkimage:.c=.o)
25 TARGET_mkimage=mkimage
27 $(TARGET_mkimage): $(OBJ_mkimage)
28 $(CC) $^ -o $@
30 %.o: %.c
31 $(CC) $(CFLAGS) -c $<
33 %.o: %.S
34 $(CC) $(CFLAGS) -c $<
36 $(VFLASH_IMAGE): $(TARGET_mkimage) $(PETITBOOT_IMAGE)
37 ./$(TARGET_mkimage) $(PETITBOOT_IMAGE) $@
39 install_petitboot_default: $(VFLASH_IMAGE)
40 dd if=$< of=$(VFLASH_DEV_DEFAULT) bs=1 count=`wc -c $< | awk '{ print $$1 }'`
42 install_petitboot_linux: $(VFLASH_IMAGE)
43 dd if=$< of=$(VFLASH_DEV_LINUX) bs=1 count=`wc -c $< | awk '{ print $$1 }'`
45 install_bootloader_default: $(TARGET_otheros_bootloader_loader)
46 dd if=$< of=$(RAM_DEV) bs=1 count=`wc -c $< | awk '{ print $$1 }'` seek=$$(($(SLL_LOAD_LV2_OFFSET)))
47 perl -e 'printf "\x00\x00\x00\x00\x00\x00\x00\x1b"' | \
48 dd of=$(RAM_DEV) bs=1 count=8 seek=$$(($(LOG2_PAGE_SIZE_OFFSET)))
50 install_bootloader_linux: $(TARGET_otheros_bootloader_loader)
51 dd if=$< of=$(RAM_DEV) bs=1 count=`wc -c $< | awk '{ print $$1 }'` seek=$$(($(SLL_LOAD_LV2_OFFSET)))
52 perl -e 'printf "\x00\x00\x00\x00\x00\x00\x00\x1b"' | \
53 dd of=$(RAM_DEV) bs=1 count=8 seek=$$(($(LOG2_PAGE_SIZE_OFFSET)))
54 perl -e 'printf "\x00\x00\x00\x00\x00\x00\x00\x07"' | \
55 dd of=$(RAM_DEV) bs=1 count=8 seek=$$(($(VFLASH_REGION_OFFSET)))
57 .PHONY: clean
58 clean:
59 rm -f $(OBJ_otheros_bootloader_loader) $(TARGET_otheros_bootloader_loader)
60 rm -f $(OBJ_mkimage) $(TARGET_mkimage)
61 rm -f $(VFLASH_IMAGE)