Makefile 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #
  2. # Copyright (C) 2011 OpenWrt.org
  3. # Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
  4. #
  5. # This is free software, licensed under the GNU General Public License v2.
  6. # See /LICENSE for more information.
  7. #
  8. include $(TOPDIR)/rules.mk
  9. LZMA_TEXT_START := 0x80a00000
  10. LOADADDR := 0x80060000
  11. LOADER := loader.bin
  12. LOADER_NAME := $(basename $(notdir $(LOADER)))
  13. LOADER_DATA :=
  14. TARGET_DIR :=
  15. FLASH_OFFS :=
  16. FLASH_MAX :=
  17. BOARD :=
  18. ifeq ($(TARGET_DIR),)
  19. TARGET_DIR := $(KDIR)
  20. endif
  21. LOADER_BIN := $(TARGET_DIR)/$(LOADER_NAME).bin
  22. LOADER_GZ := $(TARGET_DIR)/$(LOADER_NAME).gz
  23. LOADER_ELF := $(TARGET_DIR)/$(LOADER_NAME).elf
  24. PKG_NAME := lzma-loader
  25. PKG_BUILD_DIR := $(KDIR)/$(PKG_NAME)
  26. .PHONY : loader-compile loader.bin loader.elf loader.gz
  27. $(PKG_BUILD_DIR)/.prepared:
  28. mkdir $(PKG_BUILD_DIR)
  29. $(CP) ./src/* $(PKG_BUILD_DIR)/
  30. touch $@
  31. loader-compile: $(PKG_BUILD_DIR)/.prepared
  32. $(MAKE) -C $(PKG_BUILD_DIR) CROSS_COMPILE="$(TARGET_CROSS)" \
  33. LZMA_TEXT_START=$(LZMA_TEXT_START) \
  34. LOADADDR=$(LOADADDR) \
  35. LOADER_DATA=$(LOADER_DATA) \
  36. FLASH_OFFS=$(FLASH_OFFS) \
  37. FLASH_MAX=$(FLASH_MAX) \
  38. BOARD="$(BOARD)" \
  39. clean all
  40. loader.gz: $(PKG_BUILD_DIR)/loader.bin
  41. # Workaround for buggy bootloaders: Some devices
  42. # (TP-Link TL-WR1043ND v1) don't work correctly when
  43. # the uncompressed loader is too small (probably a cache
  44. # invalidation issue)
  45. dd if=$< bs=512K conv=sync | gzip -nc9 > $(LOADER_GZ)
  46. loader.elf: $(PKG_BUILD_DIR)/loader.elf
  47. $(CP) $< $(LOADER_ELF)
  48. loader.bin: $(PKG_BUILD_DIR)/loader.bin
  49. $(CP) $< $(LOADER_BIN)
  50. download:
  51. prepare: $(PKG_BUILD_DIR)/.prepared
  52. compile: loader-compile
  53. install:
  54. clean:
  55. rm -rf $(PKG_BUILD_DIR)