2021-10-07 05:00:20 +08:00
|
|
|
#!/bin/bash
|
|
|
|
# (Need bash because of Bash Arrays)
|
2022-01-08 08:12:13 +08:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Copyright (C) Proxmark3 contributors. See AUTHORS.md for details.
|
|
|
|
#
|
|
|
|
# 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 3 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.
|
|
|
|
#
|
|
|
|
# See LICENSE.txt for the text of the license.
|
|
|
|
#-----------------------------------------------------------------------------
|
2021-10-07 05:00:20 +08:00
|
|
|
|
2021-10-17 05:43:31 +08:00
|
|
|
# These vars can be overridden by env variables
|
2021-10-07 05:00:20 +08:00
|
|
|
echo "Makefile flags: ${MKFLAGS:=-j8}"
|
2021-10-12 06:00:46 +08:00
|
|
|
echo "Destination: ${DEST:=firmware}"
|
2021-10-07 05:00:20 +08:00
|
|
|
echo "Produce stats?: ${STATS:=false}"
|
|
|
|
|
|
|
|
# Which parts to skip for the 256kb version?
|
2022-08-23 20:35:13 +08:00
|
|
|
SKIPS256="SKIP_HITAG=1 SKIP_LEGICRF=1 SKIP_FELICA=1 SKIP_EM4x50=1 SKIP_ISO14443b=1"
|
2021-10-07 05:00:20 +08:00
|
|
|
|
|
|
|
make $MKFLAGS bootrom || exit 1
|
2021-10-07 06:54:23 +08:00
|
|
|
chmod 644 bootrom/obj/bootrom.elf
|
|
|
|
mkdir -p "$DEST"
|
2021-10-07 05:00:20 +08:00
|
|
|
mv bootrom/obj/bootrom.elf "$DEST/PM3BOOTROM.elf"
|
|
|
|
|
|
|
|
# cf armsrc/Standalone/Makefile.hal
|
2022-02-11 00:39:25 +08:00
|
|
|
STANDALONE_MODES=(LF_SKELETON LF_EM4100EMUL LF_EM4100RSWB LF_EM4100RSWW LF_EM4100RWC LF_HIDBRUTE LF_HIDFCBRUTE LF_ICEHID LF_PROXBRUTE LF_SAMYRUN LF_THAREXDE LF_NEXID)
|
2022-04-03 12:23:19 +08:00
|
|
|
STANDALONE_MODES+=(HF_14ASNIFF HF_14BSNIFF HF_15SNIFF HF_AVEFUL HF_BOG HF_COLIN HF_CRAFTBYTE HF_ICECLASS HF_LEGIC HF_LEGICSIM HF_MATTYRUN HF_MFCSIM HF_MSDSAL HF_TCPRST HF_TMUDFORD HF_YOUNG HF_REBLAY DANKARMULTI)
|
2021-10-07 05:00:20 +08:00
|
|
|
STANDALONE_MODES_REQ_BT=(HF_REBLAY)
|
|
|
|
STANDALONE_MODES_REQ_SMARTCARD=()
|
2022-08-23 20:35:13 +08:00
|
|
|
STANDALONE_MODES_REQ_FLASH=(LF_HIDFCBRUTE LF_ICEHID LF_NEXID LF_THAREXDE HF_14ASNIFF HF_15SNIFF HF_BOG HF_COLIN HF_ICECLASS HF_LEGICSIM HF_MFCSIM)
|
2021-10-07 05:00:20 +08:00
|
|
|
|
|
|
|
# PM3GENERIC 256kb, no flash, need to skip some parts to reduce size
|
|
|
|
|
|
|
|
# Need to use the "recovery" target to test the size
|
|
|
|
make $MKFLAGS PLATFORM=PM3GENERIC PLATFORM_SIZE=256 PLATFORM_EXTRAS= STANDALONE= $SKIPS256 recovery || exit 1
|
2021-10-07 06:54:23 +08:00
|
|
|
chmod 644 armsrc/obj/fullimage.elf
|
2021-10-07 05:00:20 +08:00
|
|
|
mv armsrc/obj/fullimage.elf "$DEST/PM3GENERIC_256.elf"
|
|
|
|
|
|
|
|
# PM3GENERIC, no flash
|
|
|
|
|
|
|
|
make $MKFLAGS PLATFORM=PM3GENERIC PLATFORM_EXTRAS= STANDALONE= fullimage || exit 1
|
2021-10-07 06:54:23 +08:00
|
|
|
chmod 644 armsrc/obj/fullimage.elf
|
2021-10-07 05:00:20 +08:00
|
|
|
mv armsrc/obj/fullimage.elf "$DEST/PM3GENERIC.elf"
|
|
|
|
$STATS && ( echo "PM3GENERIC:" > standalones_stats.txt )
|
|
|
|
$STATS && ( echo " text data bss dec hex filename" >> standalones_stats.txt )
|
|
|
|
for mode in "${STANDALONE_MODES[@]}"; do
|
|
|
|
[[ " ${STANDALONE_MODES_REQ_BT[*]} " =~ " $mode " ]] && continue
|
|
|
|
[[ " ${STANDALONE_MODES_REQ_SMARTCARD[*]} " =~ " $mode " ]] && continue
|
|
|
|
[[ " ${STANDALONE_MODES_REQ_FLASH[*]} " =~ " $mode " ]] && continue
|
|
|
|
make $MKFLAGS PLATFORM=PM3GENERIC PLATFORM_EXTRAS= STANDALONE=$mode fullimage || exit 1
|
2021-10-07 06:54:23 +08:00
|
|
|
chmod 644 armsrc/obj/fullimage.elf
|
2021-10-07 05:00:20 +08:00
|
|
|
mv armsrc/obj/fullimage.elf "$DEST/PM3GENERIC_${mode/_/}.elf"
|
2021-10-08 20:43:23 +08:00
|
|
|
! $STATS || ( LANG=C arm-none-eabi-size armsrc/obj/[hl]f_*.o |grep -v "filename" >> standalones_stats.txt )
|
2021-10-07 05:00:20 +08:00
|
|
|
done
|
|
|
|
|
|
|
|
# PM3RDV4
|
|
|
|
|
|
|
|
make $MKFLAGS PLATFORM=PM3RDV4 PLATFORM_EXTRAS= STANDALONE= fullimage || exit 1
|
2021-10-07 06:54:23 +08:00
|
|
|
chmod 644 armsrc/obj/fullimage.elf
|
2021-10-07 05:00:20 +08:00
|
|
|
mv armsrc/obj/fullimage.elf "$DEST/PM3RDV4.elf"
|
|
|
|
$STATS && ( echo "PM3RDV4:" >> standalones_stats.txt )
|
|
|
|
$STATS && ( echo " text data bss dec hex filename" >> standalones_stats.txt )
|
|
|
|
for mode in "${STANDALONE_MODES[@]}"; do
|
|
|
|
[[ " ${STANDALONE_MODES_REQ_BT[*]} " =~ " $mode " ]] && continue
|
|
|
|
make $MKFLAGS PLATFORM=PM3RDV4 PLATFORM_EXTRAS= STANDALONE=$mode fullimage || exit 1
|
2021-10-07 06:54:23 +08:00
|
|
|
chmod 644 armsrc/obj/fullimage.elf
|
2021-10-07 05:00:20 +08:00
|
|
|
mv armsrc/obj/fullimage.elf "$DEST/PM3RDV4_${mode/_/}.elf"
|
2021-10-08 20:43:23 +08:00
|
|
|
! $STATS || ( LANG=C arm-none-eabi-size armsrc/obj/[hl]f_*.o |grep -v "filename" >> standalones_stats.txt )
|
2021-10-07 05:00:20 +08:00
|
|
|
done
|
|
|
|
|
|
|
|
# PM4RDV4 + BTADDON
|
|
|
|
|
|
|
|
make $MKFLAGS PLATFORM=PM3RDV4 PLATFORM_EXTRAS=BTADDON STANDALONE= fullimage || exit 1
|
2021-10-07 06:54:23 +08:00
|
|
|
chmod 644 armsrc/obj/fullimage.elf
|
2021-10-07 05:00:20 +08:00
|
|
|
mv armsrc/obj/fullimage.elf "$DEST/PM3RDV4_BTADDON.elf"
|
|
|
|
$STATS && ( echo "PM3RDV4 + BTADDON:" >> standalones_stats.txt )
|
|
|
|
$STATS && ( echo " text data bss dec hex filename" >> standalones_stats.txt )
|
|
|
|
for mode in "${STANDALONE_MODES[@]}"; do
|
|
|
|
make $MKFLAGS PLATFORM=PM3RDV4 PLATFORM_EXTRAS=BTADDON STANDALONE=$mode fullimage || exit 1
|
2021-10-07 06:54:23 +08:00
|
|
|
chmod 644 armsrc/obj/fullimage.elf
|
2021-10-07 05:00:20 +08:00
|
|
|
mv armsrc/obj/fullimage.elf "$DEST/PM3RDV4_BTADDON_${mode/_/}.elf"
|
2021-10-08 20:43:23 +08:00
|
|
|
! $STATS || ( LANG=C arm-none-eabi-size armsrc/obj/[hl]f_*.o |grep -v "filename" >> standalones_stats.txt )
|
2021-10-07 05:00:20 +08:00
|
|
|
done
|