diff --git a/.gitignore b/.gitignore index 490a572292..773a9c730b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,19 @@ -fexc -bin2fex -fex2bin -bootinfo -fel -pio -nand-part -meminfo *.o +*.elf *.swp +tools/bootinfo/bootinfo +tools/fel/fel +tools/fexc/bin2fex +tools/fexc/fecx +tools/fexc/fex2bin +tools/nand_part/nand-part +tools/phoenix_info/phoenix_info +tools/pio/pio +baremetal/boot_head/boot_head_sun3i.bin +baremetal/boot_head/boot_head_sun4i.bin +baremetal/boot_head/boot_head_sun5i.bin +baremetal/fel-copy/fel-copy.bin +baremetal/fel-pio/fel-pio.bin +baremetal/fel-pio/fel-pio.nm +baremetal/fel-sdboot/fel-sdboot.bin +baremetal/jtag-loop/jtag-loop.bin diff --git a/Makefile b/Makefile index 922da8f83a..77e36ee928 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ -# Copyright (C) 2012 Alejandro Mery -# Copyright (C) 2012,2013 Henrik Nordstrom -# Copyright (C) 2013 Patrick Wood -# Copyright (C) 2013 Pat Wood +# Copyright (C) 2012 Alejandro Mery +# Copyright (C) 2012,2013 Henrik Nordstrom +# Copyright (C) 2013 Patrick Wood +# Copyright (C) 2013 Pat Wood +# Copyright (C) 2014 Alexey Edelev # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -10,111 +11,59 @@ # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see . +# along with this program. If not, see . -CC = gcc -CFLAGS = -g -O0 -Wall -Wextra -CFLAGS += -std=c99 -D_POSIX_C_SOURCE=200112L -CFLAGS += -Iinclude/ +PWD=$(shell pwd) +.PHONY:tools baremetal -TOOLS = fexc bin2fex fex2bin bootinfo fel pio -TOOLS += nand-part +TOOLS = \ + bootinfo \ + fel \ + nand_part \ + fexc \ + phoenix_info \ + pio -MISC_TOOLS = phoenix_info +CROSS_TOOLS = \ + meminfo -CROSS_COMPILE ?= arm-none-eabi- +BAREMETAL = \ + boot_head \ + fel-sdboot \ + jtag-loop \ + fel-pio \ + fel-copy -.PHONY: all clean -all: $(TOOLS) +tools:$(TOOLS) +$(TOOLS): FORCE + $(MAKE) -C tools/$@ -misc: $(MISC_TOOLS) +baremetal:$(BAREMETAL) +$(BAREMETAL): FORCE + $(MAKE) -C baremetal/$@ -clean: - @rm -vf $(TOOLS) $(MISC_TOOLS) *.o *.elf *.sunxi *.bin *.nm *.orig +cross-tools:$(CROSS_TOOLS) +$(CROSS_TOOLS):FORCE + $(MAKE) -C tools/$@ +tools-clean: + for d in $(TOOLS); do $(MAKE) -C tools/$$d clean; done -$(TOOLS): Makefile common.h +baremetal-clean: + for d in $(BAREMETAL); do $(MAKE) -C baremetal/$$d clean; done -fex2bin bin2fex: fexc - ln -s $< $@ +cross-tools-clean: + for d in $(CROSS_TOOLS); do $(MAKE) -C tools/$$d clean; done -fexc: fexc.h script.h script.c \ - script_uboot.h script_uboot.c \ - script_bin.h script_bin.c \ - script_fex.h script_fex.c +tools-install: + for d in $(TOOLS); do $(MAKE) -C tools/$$d install; done -LIBUSB = libusb-1.0 -LIBUSB_CFLAGS = `pkg-config --cflags $(LIBUSB)` -LIBUSB_LIBS = `pkg-config --libs $(LIBUSB)` +tools-uninstall: + for d in $(TOOLS); do $(MAKE) -C tools/$$d uninstall; done -fel: fel.c - $(CC) $(CFLAGS) $(LIBUSB_CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS) $(LIBUSB_LIBS) - -nand-part: nand-part-main.c nand-part.c nand-part-a10.h nand-part-a20.h - $(CC) $(CFLAGS) -c -o nand-part-main.o nand-part-main.c - $(CC) $(CFLAGS) -c -o nand-part-a10.o nand-part.c -D A10 - $(CC) $(CFLAGS) -c -o nand-part-a20.o nand-part.c -D A20 - $(CC) $(LDFLAGS) -o $@ nand-part-main.o nand-part-a10.o nand-part-a20.o $(LIBS) - -%: %.c - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(filter %.c,$^) $(LIBS) - -fel-pio.bin: fel-pio.elf fel-pio.nm - $(CROSS_COMPILE)objcopy -O binary fel-pio.elf fel-pio.bin - -fel-pio.elf: fel-pio.c fel-pio.lds - $(CROSS_COMPILE)gcc -g -Os -fpic -fno-common -fno-builtin -ffreestanding -nostdinc -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fno-toplevel-reorder fel-pio.c -nostdlib -o fel-pio.elf -T fel-pio.lds - -fel-pio.nm: fel-pio.elf - $(CROSS_COMPILE)nm fel-pio.elf | grep -v " _" >fel-pio.nm - -jtag-loop.elf: jtag-loop.c jtag-loop.lds - $(CROSS_COMPILE)gcc -g -Os -fpic -fno-common -fno-builtin -ffreestanding -nostdinc -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fno-toplevel-reorder jtag-loop.c -nostdlib -o jtag-loop.elf -T jtag-loop.lds -Wl,-N - -jtag-loop.bin: jtag-loop.elf - $(CROSS_COMPILE)objcopy -O binary jtag-loop.elf jtag-loop.bin - -jtag-loop.sunxi: jtag-loop.bin - mksunxiboot jtag-loop.bin jtag-loop.sunxi - -fel-sdboot.elf: fel-sdboot.c fel-sdboot.lds - $(CROSS_COMPILE)gcc -g -Os -fpic -fno-common -fno-builtin -ffreestanding -nostdinc -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fno-toplevel-reorder fel-sdboot.c -nostdlib -o fel-sdboot.elf -T fel-sdboot.lds -Wl,-N - -fel-sdboot.bin: fel-sdboot.elf - $(CROSS_COMPILE)objcopy -O binary fel-sdboot.elf fel-sdboot.bin - -fel-sdboot.sunxi: fel-sdboot.bin - mksunxiboot fel-sdboot.bin fel-sdboot.sunxi - -boot_head_sun3i.elf: boot_head_sun3i.S boot_head_sun3i.lds - $(CROSS_COMPILE)gcc -g -Os -fpic -fno-common -fno-builtin -ffreestanding -nostdinc -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fno-toplevel-reorder boot_head.S -nostdlib -o boot_head_sun3i.elf -T boot_head.lds -Wl,-N -DMACHID=0x1094 - -boot_head_sun3i.bin: boot_head_sun3i.elf - $(CROSS_COMPILE)objcopy -O binary boot_head_sun3i.elf boot_head_sun3i.bin - -boot_head_sun4i.elf: boot_head.S boot_head.lds - $(CROSS_COMPILE)gcc -g -Os -fpic -fno-common -fno-builtin -ffreestanding -nostdinc -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fno-toplevel-reorder boot_head.S -nostdlib -o boot_head_sun4i.elf -T boot_head.lds -Wl,-N -DMACHID=0x1008 - -boot_head_sun4i.bin: boot_head_sun4i.elf - $(CROSS_COMPILE)objcopy -O binary boot_head_sun4i.elf boot_head_sun4i.bin - -boot_head_sun5i.elf: boot_head.S boot_head.lds - $(CROSS_COMPILE)gcc -g -Os -fpic -fno-common -fno-builtin -ffreestanding -nostdinc -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fno-toplevel-reorder boot_head.S -nostdlib -o boot_head_sun5i.elf -T boot_head.lds -Wl,-N -DMACHID=0x102A - -boot_head_sun5i.bin: boot_head_sun5i.elf - $(CROSS_COMPILE)objcopy -O binary boot_head_sun5i.elf boot_head_sun5i.bin - -bootinfo: bootinfo.c - -meminfo: meminfo.c - $(CROSS_COMPILE)gcc -g -O0 -Wall -static -o $@ $^ - -.gitignore: Makefile - @for x in $(TOOLS) '*.o' '*.swp'; do \ - echo "$$x"; \ - done > $@ +FORCE: diff --git a/README b/README index e71933ffd2..fb63669b76 100644 --- a/README +++ b/README @@ -62,9 +62,15 @@ phoenix_info: meminfo: Tool for reading DRAM settings from registers. Compiled as a - static binary for use on android and other OSes. To build this, - get a toolchain, and run: - make CROSS_COMPILE=arm-linux-gnueabihf- meminfo + static binary for use on android and other OSes. + +Build instructions: + To build host sunxi-tools: + make tools [CC= CFLAGS=] + To build target sunxi-tools: + make cross-tools CROSS_COMPILE= [CC= CFLAGS=] + To build sunxi core processor tools: + make baremetal CROSS_COMPILE= [CC= CFLAGS= OBJCOPY= NM=] This software is licensed under the terms of GPLv2+ as defined by the Free Software Foundation, details can be read in the COPYING file. diff --git a/baremetal/baremetal.env b/baremetal/baremetal.env new file mode 100644 index 0000000000..05b66e5f27 --- /dev/null +++ b/baremetal/baremetal.env @@ -0,0 +1,23 @@ +# Copyright (C) 2014 Alexey Edelev +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +CC ?= gcc +OBJCOPY ?= objcopy +NM ?= nm +CROSS_COMPILE ?= arm-none-gnueabi- +override CFLAGS := $(CFLAGS) -g -Os -fpic -fno-common -fno-builtin -ffreestanding -nostdinc -mno-thumb-interwork -Wall -Wstrict-prototypes -fno-stack-protector -Wno-format-nonliteral -Wno-format-security -fno-toplevel-reorder -nostdlib +override CC := $(CROSS_COMPILE)$(CC) +override OBJCOPY := $(CROSS_COMPILE)$(OBJCOPY) +override NM := $(CROSS_COMPILE)$(NM) diff --git a/baremetal/baremetal.rules b/baremetal/baremetal.rules new file mode 100644 index 0000000000..065db0cb8f --- /dev/null +++ b/baremetal/baremetal.rules @@ -0,0 +1,28 @@ +# Copyright (C) 2014 Alexey Edelev +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +.DEFAULT: all + +all: $(TARGETS) $(EXTRA_DEPS) + +$(ELFS): $(SOURCES) $(LDSCRIPT) + $(CC) $(CFLAGS) $(SOURCES) -o $@ -T $(LDSCRIPT) -Wl,-N $(DEFINES) + +$(TARGETS): $(ELFS) + $(OBJCOPY) -O binary $(subst .bin,.elf,$@) $@ + +clean: + rm -f $(ELFS) + rm -f $(TARGETS) diff --git a/baremetal/boot_head/Makefile b/baremetal/boot_head/Makefile new file mode 100644 index 0000000000..dd244784ed --- /dev/null +++ b/baremetal/boot_head/Makefile @@ -0,0 +1,32 @@ +# Copyright (C) 2014 Alexey Edelev +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +include ../baremetal.env + +sun3i_MACHID=0x1094 +sun4i_MACHID=0x1008 +sun5i_MACHID=0x102A + +BOOT_HEADS = boot_head_sun3i \ + boot_head_sun4i \ + boot_head_sun5i + +ELFS = $(addsuffix .elf, $(BOOT_HEADS)) +TARGETS = $(addsuffix .bin, $(BOOT_HEADS)) + +SOURCES = boot_head.S +LDSCRIPT = boot_head.lds +DEFINES=-DMACHID=$($(subst boot_head_,,$(subst .elf,,$@))_MACHID) +include ../baremetal.rules diff --git a/boot_head.S b/baremetal/boot_head/boot_head.S similarity index 100% rename from boot_head.S rename to baremetal/boot_head/boot_head.S diff --git a/boot_head.lds b/baremetal/boot_head/boot_head.lds similarity index 100% rename from boot_head.lds rename to baremetal/boot_head/boot_head.lds diff --git a/baremetal/fel-copy/Makefile b/baremetal/fel-copy/Makefile new file mode 100644 index 0000000000..fcc4df97d9 --- /dev/null +++ b/baremetal/fel-copy/Makefile @@ -0,0 +1,29 @@ +# Copyright (C) 2014 Alexey Edelev +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +include ../baremetal.env + +.DEFAULT: all + +all: fel-copy.bin + +fel-copy.bin: fel-copy.o + $(OBJCOPY) -O binary fel-copy.o fel-copy.bin + +fel-copy.o: + $(CC) $(CFLAGS) -c fel-copy.c -o fel-copy.o + +clean: + rm -f fel-copy.bin fel-copy.o diff --git a/fel-copy.c b/baremetal/fel-copy/fel-copy.c similarity index 100% rename from fel-copy.c rename to baremetal/fel-copy/fel-copy.c diff --git a/baremetal/fel-pio/Makefile b/baremetal/fel-pio/Makefile new file mode 100644 index 0000000000..4e636d07da --- /dev/null +++ b/baremetal/fel-pio/Makefile @@ -0,0 +1,27 @@ +# Copyright (C) 2014 Alexey Edelev +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +include ../baremetal.env + +ELFS = fel-pio.elf +TARGETS = fel-pio.bin +EXTRA_DEPS = fel-pio.nm + +SOURCES = fel-pio.c +LDSCRIPT = fel-pio.lds + +include ../baremetal.rules +fel-pio.nm: fel-pio.elf + $(NM) $^ | grep -v " _" >$@ diff --git a/fel-pio.c b/baremetal/fel-pio/fel-pio.c similarity index 100% rename from fel-pio.c rename to baremetal/fel-pio/fel-pio.c diff --git a/fel-pio.lds b/baremetal/fel-pio/fel-pio.lds similarity index 100% rename from fel-pio.lds rename to baremetal/fel-pio/fel-pio.lds diff --git a/baremetal/fel-sdboot/Makefile b/baremetal/fel-sdboot/Makefile new file mode 100644 index 0000000000..832e7736d7 --- /dev/null +++ b/baremetal/fel-sdboot/Makefile @@ -0,0 +1,27 @@ +# Copyright (C) 2014 Alexey Edelev +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +include ../baremetal.env + +ELFS = fel-sdboot.elf +TARGETS = fel-sdboot.bin + +SOURCES = fel-sdboot.c +LDSCRIPT = fel-sdboot.lds +EXTRA_DEPS = fel-sdboot.sunxi +include ../baremetal.rules + +fel-sdboot.sunxi: fel-sdboot.bin + -if $$(which mksunxiboot); then mksunxiboot $^ $@; fi diff --git a/fel-sdboot.c b/baremetal/fel-sdboot/fel-sdboot.c similarity index 100% rename from fel-sdboot.c rename to baremetal/fel-sdboot/fel-sdboot.c diff --git a/fel-sdboot.lds b/baremetal/fel-sdboot/fel-sdboot.lds similarity index 100% rename from fel-sdboot.lds rename to baremetal/fel-sdboot/fel-sdboot.lds diff --git a/baremetal/jtag-loop/Makefile b/baremetal/jtag-loop/Makefile new file mode 100644 index 0000000000..73949bdcf9 --- /dev/null +++ b/baremetal/jtag-loop/Makefile @@ -0,0 +1,26 @@ +# Copyright (C) 2014 Alexey Edelev +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +include ../baremetal.env + +ELFS = jtag-loop.elf +TARGETS = jtag-loop.bin +EXTRA_DEPS = jtag-loop.sunxi + +SOURCES = jtag-loop.c +LDSCRIPT = jtag-loop.lds +include ../baremetal.rules +jtag-loop.sunxi: jtag-loop.bin + -if $$(which mksunxiboot); then mksunxiboot $^ $@; fi diff --git a/jtag-loop.S b/baremetal/jtag-loop/jtag-loop.S similarity index 100% rename from jtag-loop.S rename to baremetal/jtag-loop/jtag-loop.S diff --git a/jtag-loop.c b/baremetal/jtag-loop/jtag-loop.c similarity index 100% rename from jtag-loop.c rename to baremetal/jtag-loop/jtag-loop.c diff --git a/jtag-loop.lds b/baremetal/jtag-loop/jtag-loop.lds similarity index 100% rename from jtag-loop.lds rename to baremetal/jtag-loop/jtag-loop.lds diff --git a/adb-devprobe.sh b/scripts/adb-devprobe.sh similarity index 100% rename from adb-devprobe.sh rename to scripts/adb-devprobe.sh diff --git a/fel-gpio b/scripts/fel-gpio similarity index 100% rename from fel-gpio rename to scripts/fel-gpio diff --git a/usb-boot b/scripts/usb-boot similarity index 100% rename from usb-boot rename to scripts/usb-boot diff --git a/tools/bootinfo/Makefile b/tools/bootinfo/Makefile new file mode 100644 index 0000000000..f883aa4250 --- /dev/null +++ b/tools/bootinfo/Makefile @@ -0,0 +1,21 @@ +# Copyright (C) 2014 Alexey Edelev +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +include ../tools.env + +TARGET = bootinfo +SOURCES = bootinfo.c +INSTALL_DIR = bin +include ../tools.rules diff --git a/bootinfo.c b/tools/bootinfo/bootinfo.c similarity index 100% rename from bootinfo.c rename to tools/bootinfo/bootinfo.c diff --git a/tools/fel/Makefile b/tools/fel/Makefile new file mode 100644 index 0000000000..d6cf953d04 --- /dev/null +++ b/tools/fel/Makefile @@ -0,0 +1,26 @@ +# Copyright (C) 2014 Alexey Edelev +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +include ../tools.env + +LIBUSB = libusb-1.0 +override CFLAGS += `pkg-config --cflags $(LIBUSB)` +LIBS += `pkg-config --libs $(LIBUSB)` + +TARGET = fel +SOURCES = fel.c + +INSTALL_DIR = bin +include ../tools.rules diff --git a/fel.c b/tools/fel/fel.c similarity index 100% rename from fel.c rename to tools/fel/fel.c diff --git a/tools/fexc/Makefile b/tools/fexc/Makefile new file mode 100644 index 0000000000..7c93c244a5 --- /dev/null +++ b/tools/fexc/Makefile @@ -0,0 +1,46 @@ +# Copyright (C) 2014 Alexey Edelev +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +include ../tools.env + +TARGET = fecx +SOURCES = \ + fexc.c \ + script_bin.c \ + script.c \ + script_fex.c \ + script_uboot.c + +EXTRA_DEPS = \ + fex2bin \ + bin2fex + +HEADERS = \ + include/script.h \ + include/script_uboot.h \ + include/script_bin.h \ + include/script_fex.h + +INSTALL_DIR = bin + +include ../tools.rules +install: $(TARGET) fex2bin bin2fex + mkdir -p $(PREFIX)/$(INSTALL_DIR) + install -o root -m 755 -t $(PREFIX)/$(INSTALL_DIR) $(TARGET) fex2bin bin2fex +uninstall: + rm -f $(addprefix $(PREFIX)/$(INSTALL_DIR)/,$(TARGET) fex2bin bin2fex) + rmdir -p $(PREFIX)/$(INSTALL_DIR) +fex2bin bin2fex: + ln -s $(TARGET) $@ diff --git a/fexc.c b/tools/fexc/fexc.c similarity index 100% rename from fexc.c rename to tools/fexc/fexc.c diff --git a/fexc.h b/tools/fexc/include/fexc.h similarity index 100% rename from fexc.h rename to tools/fexc/include/fexc.h diff --git a/script.h b/tools/fexc/include/script.h similarity index 100% rename from script.h rename to tools/fexc/include/script.h diff --git a/script_bin.h b/tools/fexc/include/script_bin.h similarity index 100% rename from script_bin.h rename to tools/fexc/include/script_bin.h diff --git a/script_fex.h b/tools/fexc/include/script_fex.h similarity index 100% rename from script_fex.h rename to tools/fexc/include/script_fex.h diff --git a/script_uboot.h b/tools/fexc/include/script_uboot.h similarity index 100% rename from script_uboot.h rename to tools/fexc/include/script_uboot.h diff --git a/script.c b/tools/fexc/script.c similarity index 100% rename from script.c rename to tools/fexc/script.c diff --git a/script_bin.c b/tools/fexc/script_bin.c similarity index 100% rename from script_bin.c rename to tools/fexc/script_bin.c diff --git a/script_fex.c b/tools/fexc/script_fex.c similarity index 100% rename from script_fex.c rename to tools/fexc/script_fex.c diff --git a/script_uboot.c b/tools/fexc/script_uboot.c similarity index 100% rename from script_uboot.c rename to tools/fexc/script_uboot.c diff --git a/common.h b/tools/include/common.h similarity index 100% rename from common.h rename to tools/include/common.h diff --git a/include/endian_compat.h b/tools/include/endian_compat.h similarity index 100% rename from include/endian_compat.h rename to tools/include/endian_compat.h diff --git a/include/types.h b/tools/include/types.h similarity index 100% rename from include/types.h rename to tools/include/types.h diff --git a/tools/meminfo/Makefile b/tools/meminfo/Makefile new file mode 100644 index 0000000000..bdbbc35867 --- /dev/null +++ b/tools/meminfo/Makefile @@ -0,0 +1,25 @@ +# Copyright (C) 2014 Alexey Edelev +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +include ../tools.env + +TARGET = meminfo +SOURCES = \ + meminfo.c +INSTALL_DIR = bin + +override CFLAGS := $(CFLAGS) -static + +include ../tools.rules diff --git a/meminfo.c b/tools/meminfo/meminfo.c similarity index 100% rename from meminfo.c rename to tools/meminfo/meminfo.c diff --git a/tools/nand_part/Makefile b/tools/nand_part/Makefile new file mode 100644 index 0000000000..7db86a6915 --- /dev/null +++ b/tools/nand_part/Makefile @@ -0,0 +1,33 @@ +# Copyright (C) 2014 Alexey Edelev +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +include ../tools.env + +TARGET = nand-part +SOURCES = nand-part-main.c + +EXTRA_OBJECTS = nand-part-a10.o \ + nand-part-a20.o +HEADERS = include/nand-part-a20.h \ + include/nand-part-a10.h + +INSTALL_DIR = bin + +include ../tools.rules + +nand-part-a10.o: nand-part.c + $(CC) -c $(CFLAGS) $(INCLUDES) -D A10 -o $@ $^ +nand-part-a20.o: nand-part.c + $(CC) -c $(CFLAGS) $(INCLUDES) -D A20 -o $@ $^ diff --git a/nand-common.h b/tools/nand_part/include/nand-common.h similarity index 100% rename from nand-common.h rename to tools/nand_part/include/nand-common.h diff --git a/nand-part-a10.h b/tools/nand_part/include/nand-part-a10.h similarity index 100% rename from nand-part-a10.h rename to tools/nand_part/include/nand-part-a10.h diff --git a/nand-part-a20.h b/tools/nand_part/include/nand-part-a20.h similarity index 100% rename from nand-part-a20.h rename to tools/nand_part/include/nand-part-a20.h diff --git a/nand-part-main.c b/tools/nand_part/nand-part-main.c similarity index 100% rename from nand-part-main.c rename to tools/nand_part/nand-part-main.c diff --git a/nand-part.c b/tools/nand_part/nand-part.c similarity index 100% rename from nand-part.c rename to tools/nand_part/nand-part.c diff --git a/tools/phoenix_info/Makefile b/tools/phoenix_info/Makefile new file mode 100644 index 0000000000..9cb8ee0c23 --- /dev/null +++ b/tools/phoenix_info/Makefile @@ -0,0 +1,22 @@ +# Copyright (C) 2014 Alexey Edelev +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +include ../tools.env + +TARGET = phoenix_info +SOURCES = phoenix_info.c +INSTALL_DIR = bin + +include ../tools.rules diff --git a/phoenix_info.c b/tools/phoenix_info/phoenix_info.c similarity index 100% rename from phoenix_info.c rename to tools/phoenix_info/phoenix_info.c diff --git a/tools/pio/Makefile b/tools/pio/Makefile new file mode 100644 index 0000000000..946d2c02fe --- /dev/null +++ b/tools/pio/Makefile @@ -0,0 +1,22 @@ +# Copyright (C) 2014 Alexey Edelev +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +include ../tools.env + +TARGET = pio +SOURCES = pio.c +INSTALL_DIR = bin + +include ../tools.rules diff --git a/pio.c b/tools/pio/pio.c similarity index 100% rename from pio.c rename to tools/pio/pio.c diff --git a/tools/tools.env b/tools/tools.env new file mode 100644 index 0000000000..9a21c36ed5 --- /dev/null +++ b/tools/tools.env @@ -0,0 +1,24 @@ +# Copyright (C) 2014 Alexey Edelev +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +CC ?= gcc +CFLAGS ?= -O0 +override CFLAGS := $(CFLAGS) -std=c99 -Wall -Wextra -D_POSIX_C_SOURCE=200112L + +ifeq ($(DEBUG),1) + override CFLAGS := $(CFLAGS) -g +endif + +override CC := $(CROSS_COMPILE)$(CC) diff --git a/tools/tools.rules b/tools/tools.rules new file mode 100644 index 0000000000..738c213662 --- /dev/null +++ b/tools/tools.rules @@ -0,0 +1,41 @@ +# Copyright (C) 2014 Alexey Edelev +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +OBJECTS=$(SOURCES:.c=.o) +INCLUDES=-I. -Iinclude -I../include +EXTRA_DEPS += $(HEADERS) + +.DEFAULT: all + +all: $(TARGET) $(EXTRA_DEPS) + +%.o: %.c + $(CC) -c $(CFLAGS) $(INCLUDES) -o $@ $^ + +$(TARGET): $(OBJECTS) $(EXTRA_OBJECTS) + $(CC) -o $@ $^ $(LIBS) + +clean: + rm -f $(EXTRA_OBJECTS) + rm -f $(OBJECTS) + rm -f $(TARGET) + +install: $(TARGET) $(EXTRA_DEPS) + mkdir -p $(PREFIX)/$(INSTALL_DIR) + install -o root -m 755 -t $(PREFIX)/$(INSTALL_DIR) $(TARGET) + +uninstall: + rm -f $(PREFIX)/$(INSTALL_DIR)/$(TARGET) + rmdir -p $(PREFIX)/$(INSTALL_DIR)