Merge pull request #2629 from pingu2211/hf-mifare-refacor
[RRG-proxmark3.git] / tools / build_all_firmwares.sh
blob2740d7150d893be63bd6379bf9ed501c1c14496b
1 #!/bin/bash
2 # (Need bash because of Bash Arrays)
3 #-----------------------------------------------------------------------------
4 # Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # See LICENSE.txt for the text of the license.
17 #-----------------------------------------------------------------------------
19 # These vars can be overridden by env variables
20 echo "Makefile flags: ${MKFLAGS:=-j8}"
21 echo "Destination: ${DEST:=firmware}"
22 echo "Produce stats?: ${STATS:=false}"
24 # Which parts to skip for the 256kb version?
25 SKIPS256="SKIP_HITAG=1 SKIP_LEGICRF=1 SKIP_FELICA=1 SKIP_EM4x50=1 SKIP_ISO14443b=1 SKIP_NFCBARCODE=1 SKIP_ZX8211=1 SKIP_LF=1"
27 make $MKFLAGS bootrom || exit 1
28 chmod 644 bootrom/obj/bootrom.elf
29 mkdir -p "$DEST"
30 mv bootrom/obj/bootrom.elf "$DEST/PM3BOOTROM.elf"
32 # cf armsrc/Standalone/Makefile.hal
33 STANDALONE_MODES=(LF_SKELETON)
34 STANDALONE_MODES+=(LF_EM4100EMUL LF_EM4100RSWB LF_EM4100RSWW LF_EM4100RWC LF_HIDBRUTE LF_HIDFCBRUTE LF_ICEHID LF_MULTIHID LF_NEDAP_SIM LF_NEXID LF_PROXBRUTE LF_PROX2BRUTE LF_SAMYRUN LF_THAREXDE)
35 STANDALONE_MODES+=(HF_14ASNIFF HF_14BSNIFF HF_15SNIFF HF_15SIM HF_AVEFUL HF_BOG HF_CARDHOPPER HF_COLIN HF_CRAFTBYTE HF_ICECLASS HF_LEGIC HF_LEGICSIM HF_MATTYRUN HF_MFCSIM HF_MSDSAL HF_REBLAY HF_TCPRST HF_TMUDFORD HF_UNISNIFF HF_YOUNG)
36 STANDALONE_MODES+=(DANKARMULTI)
37 STANDALONE_MODES_REQ_BT=(HF_CARDHOPPER HF_REBLAY)
38 STANDALONE_MODES_REQ_SMARTCARD=()
39 STANDALONE_MODES_REQ_FLASH=(LF_HIDFCBRUTE LF_ICEHID LF_NEXID LF_THAREXDE HF_BOG HF_COLIN HF_ICECLASS HF_LEGICSIM HF_MFCSIM)
41 # PM3GENERIC 256kb, no flash, need to skip some parts to reduce size
43 # Need to use the "recovery" target to test the size
44 make $MKFLAGS PLATFORM=PM3GENERIC PLATFORM_SIZE=256 PLATFORM_EXTRAS= STANDALONE= $SKIPS256 recovery || exit 1
45 chmod 644 armsrc/obj/fullimage.elf
46 mv armsrc/obj/fullimage.elf "$DEST/PM3GENERIC_256.elf"
48 # PM3GENERIC, no flash
50 make $MKFLAGS PLATFORM=PM3GENERIC PLATFORM_EXTRAS= STANDALONE= fullimage || exit 1
51 chmod 644 armsrc/obj/fullimage.elf
52 mv armsrc/obj/fullimage.elf "$DEST/PM3GENERIC.elf"
53 $STATS && ( echo "PM3GENERIC:" > standalones_stats.txt )
54 $STATS && ( echo " text data bss dec hex filename" >> standalones_stats.txt )
55 for mode in "${STANDALONE_MODES[@]}"; do
56 [[ " ${STANDALONE_MODES_REQ_BT[*]} " =~ " $mode " ]] && continue
57 [[ " ${STANDALONE_MODES_REQ_SMARTCARD[*]} " =~ " $mode " ]] && continue
58 [[ " ${STANDALONE_MODES_REQ_FLASH[*]} " =~ " $mode " ]] && continue
59 make $MKFLAGS PLATFORM=PM3GENERIC PLATFORM_EXTRAS= STANDALONE=$mode fullimage || exit 1
60 chmod 644 armsrc/obj/fullimage.elf
61 mv armsrc/obj/fullimage.elf "$DEST/PM3GENERIC_${mode/_/}.elf"
62 ! $STATS || ( LANG=C arm-none-eabi-size armsrc/obj/[hl]f_*.o |grep -v "filename" >> standalones_stats.txt )
63 done
65 # PM3RDV4
67 make $MKFLAGS PLATFORM=PM3RDV4 PLATFORM_EXTRAS= STANDALONE= fullimage || exit 1
68 chmod 644 armsrc/obj/fullimage.elf
69 mv armsrc/obj/fullimage.elf "$DEST/PM3RDV4.elf"
70 $STATS && ( echo "PM3RDV4:" >> standalones_stats.txt )
71 $STATS && ( echo " text data bss dec hex filename" >> standalones_stats.txt )
72 for mode in "${STANDALONE_MODES[@]}"; do
73 [[ " ${STANDALONE_MODES_REQ_BT[*]} " =~ " $mode " ]] && continue
74 make $MKFLAGS PLATFORM=PM3RDV4 PLATFORM_EXTRAS= STANDALONE=$mode fullimage || exit 1
75 chmod 644 armsrc/obj/fullimage.elf
76 mv armsrc/obj/fullimage.elf "$DEST/PM3RDV4_${mode/_/}.elf"
77 ! $STATS || ( LANG=C arm-none-eabi-size armsrc/obj/[hl]f_*.o |grep -v "filename" >> standalones_stats.txt )
78 done
80 # PM4RDV4 + BTADDON
82 make $MKFLAGS PLATFORM=PM3RDV4 PLATFORM_EXTRAS=BTADDON STANDALONE= fullimage || exit 1
83 chmod 644 armsrc/obj/fullimage.elf
84 mv armsrc/obj/fullimage.elf "$DEST/PM3RDV4_BTADDON.elf"
85 $STATS && ( echo "PM3RDV4 + BTADDON:" >> standalones_stats.txt )
86 $STATS && ( echo " text data bss dec hex filename" >> standalones_stats.txt )
87 for mode in "${STANDALONE_MODES[@]}"; do
88 make $MKFLAGS PLATFORM=PM3RDV4 PLATFORM_EXTRAS=BTADDON STANDALONE=$mode fullimage || exit 1
89 chmod 644 armsrc/obj/fullimage.elf
90 mv armsrc/obj/fullimage.elf "$DEST/PM3RDV4_BTADDON_${mode/_/}.elf"
91 ! $STATS || ( LANG=C arm-none-eabi-size armsrc/obj/[hl]f_*.o |grep -v "filename" >> standalones_stats.txt )
92 done