mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-08-19 14:14:04 +00:00
Dyn flash size (#2933)
This commit is contained in:
@@ -21,35 +21,66 @@
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
set -e # exit immediatelly on any failure
|
||||
set -e # exit immediately on any failure
|
||||
|
||||
# 1. PARSE ARGUMENTS
|
||||
# We separate arguments into two lists:
|
||||
# - CMAKE_OPTS: Anything starting with -D (e.g., -DFLASH_MB_SIZE=4)
|
||||
# - BUILD_ARGS: Everything else (e.g., make, ninja, -j20)
|
||||
|
||||
CMAKE_OPTS=()
|
||||
BUILD_ARGS=()
|
||||
|
||||
for arg in "$@"; do
|
||||
if [[ "$arg" == -D* ]]; then
|
||||
CMAKE_OPTS+=("$arg")
|
||||
else
|
||||
BUILD_ARGS+=("$arg")
|
||||
fi
|
||||
done
|
||||
|
||||
# Reset the script arguments ($1, $2...) to contain only the BUILD_ARGS. This allows the original logic below to work exactly as before.
|
||||
set -- "${BUILD_ARGS[@]}"
|
||||
|
||||
build_make() {
|
||||
cd ..
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake ..
|
||||
cmake "${CMAKE_OPTS[@]}" ..
|
||||
make "$@"
|
||||
exit 0 # Report success :)
|
||||
exit 0
|
||||
}
|
||||
|
||||
build_ninja() {
|
||||
cd ..
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake -G Ninja ..
|
||||
cmake -G Ninja "${CMAKE_OPTS[@]}" ..
|
||||
ninja "$@"
|
||||
exit 0 # Report success :)
|
||||
exit 0
|
||||
}
|
||||
|
||||
if [ "$1" = 'make' ]; then # build the default (or specified) target with make
|
||||
shift # remove the first item from $@ as we consumed it, we can then pass the rest on to make
|
||||
|
||||
if [ "$1" = 'make' ]; then
|
||||
# User explicitly typed 'make'
|
||||
shift
|
||||
build_make "$@"
|
||||
elif [[ $1 == -j* ]]; then # allow passing -j without typing make_default
|
||||
# dont shift here as we wanna pass the -j
|
||||
|
||||
elif [[ $1 == -j* ]]; then
|
||||
# User passed -j20 directly (Implied make)
|
||||
build_make "$@"
|
||||
elif [ "$1" = 'ninja' ]; then # build the default (or specified) target with ninja
|
||||
shift # remove the first item from $@ as we consumed it, we can then pass the rest on to make
|
||||
|
||||
elif [ "$1" = 'ninja' ]; then
|
||||
# User explicitly typed 'ninja'
|
||||
shift
|
||||
build_ninja "$@"
|
||||
|
||||
elif [ ${#CMAKE_OPTS[@]} -gt 0 ] && [ ${#BUILD_ARGS[@]} -eq 0 ]; then
|
||||
# User passed ONLY CMake flags (e.g. "-DFLASH_MB_SIZE=4")
|
||||
# We assume they want to run a default 'make' build.
|
||||
build_make
|
||||
|
||||
fi
|
||||
|
||||
exec "$@"
|
||||
# Fallback for other commands (e.g. /bin/bash)
|
||||
exec "$@"
|
||||
@@ -36,8 +36,9 @@ from pathlib import Path
|
||||
usage_message = """
|
||||
PortaPack SPI flash image generator
|
||||
|
||||
Usage: <command> <application_path> <baseband_path> <output_path>
|
||||
Usage: <command> <application_path> <baseband_path> <output_path> <spi_size>
|
||||
Where paths refer to the .bin files for each component project.
|
||||
spi_size is the total size of the target flash (e.g. 1048576).
|
||||
"""
|
||||
|
||||
|
||||
@@ -166,13 +167,14 @@ def get_gcc_version_from_elf_files_in_giving_path_or_filename_s_path(path):
|
||||
|
||||
#^^^^^^^^gcc version check from elf file^^^^^^^^
|
||||
|
||||
if len(sys.argv) != 4:
|
||||
if len(sys.argv) != 5:
|
||||
print(usage_message)
|
||||
sys.exit(-1)
|
||||
|
||||
application_image = read_image(sys.argv[1])
|
||||
baseband_image = read_image(sys.argv[2])
|
||||
output_path = sys.argv[3]
|
||||
spi_size = int(sys.argv[4], 0)
|
||||
|
||||
print("\ncheck gcc versions from all elf target\n")
|
||||
application_gcc_versions = get_gcc_version_from_elf_files_in_giving_path_or_filename_s_path(sys.argv[1])
|
||||
@@ -207,8 +209,6 @@ except Exception as e:
|
||||
#^^^^^^^^external app linker script address check worker^^^^^^^^
|
||||
|
||||
|
||||
spi_size = 1048576
|
||||
|
||||
images = (
|
||||
{
|
||||
'name': 'application',
|
||||
|
||||
Reference in New Issue
Block a user