Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add generic image_builder #206

Merged
merged 5 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
26 changes: 13 additions & 13 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,10 @@ ORIG_ENV="$(env)"
ROOTFS_OVERLAYS=""

source ./phoenix-rtos-build/build.subr
source ./build.project

# set all static output dirs before sourcing target/project build script
PREFIX_PROJECT="$(pwd)"

# Some makefiles add "$PROJECT_PATH/" to their include path so it has to be set
if [ -z "$PROJECT_PATH" ]; then
echo "PROJECT_PATH is not set (or is empty)"
exit 1;
fi

_TARGET_FOR_HOST_BUILD="host-generic-pc"

PREFIX_BUILD="$PREFIX_PROJECT/_build/$TARGET"
Expand All @@ -44,6 +38,17 @@ PREFIX_SYSROOT="" # empty by default (use toolchain sysroot)
PLO_SCRIPT_DIR="$PREFIX_BUILD/plo-scripts"

PREFIX_ROOTFS="$PREFIX_FS/root/"

export TARGET TARGET_FAMILY TARGET_SUBFAMILY TARGET_PROJECT PROJECT_PATH PREFIX_PROJECT PREFIX_BUILD\
PREFIX_BUILD_HOST PREFIX_FS PREFIX_BOOT PREFIX_PROG PREFIX_PROG_STRIPPED PREFIX_A\
PREFIX_H PREFIX_ROOTFS CROSS CFLAGS CXXFLAGS LDFLAGS CC LD AR AS MAKEFLAGS DEVICE_FLAGS PLO_SCRIPT_DIR\
PREFIX_SYSROOT LIBPHOENIX_DEVEL_MODE

source ./build.project

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 [shellcheck] reported by reviewdog 🐶
Not following: ./build.project: openBinaryFile: does not exist (No such file or directory) SC1091


# Some makefiles add "$PROJECT_PATH/" to their include path so it has to be set
[ -z "$PROJECT_PATH" ] && b_die "PROJECT_PATH is not set (or is empty)"

: "${PREFIX_ROOTSKEL:="$PREFIX_PROJECT/_fs/root-skel/"}"


Expand All @@ -67,11 +72,6 @@ AR=${CROSS}ar

MAKEFLAGS="--no-print-directory -j 9"

export TARGET TARGET_FAMILY TARGET_SUBFAMILY TARGET_PROJECT PROJECT_PATH PREFIX_PROJECT PREFIX_BUILD\
PREFIX_BUILD_HOST PREFIX_FS PREFIX_BOOT PREFIX_PROG PREFIX_PROG_STRIPPED PREFIX_A\
PREFIX_H PREFIX_ROOTFS CROSS CFLAGS CXXFLAGS LDFLAGS CC LD AR AS MAKEFLAGS DEVICE_FLAGS PLO_SCRIPT_DIR\
PREFIX_SYSROOT LIBPHOENIX_DEVEL_MODE

# export flags for ports - call make only after all necessary env variables are already set
EXPORT_CFLAGS="$(make -f phoenix-rtos-build/Makefile.common export-cflags)"
EXPORT_LDFLAGS="$(make -f phoenix-rtos-build/Makefile.common export-ldflags)"
Expand Down Expand Up @@ -200,7 +200,7 @@ fi
if [ "${B_HOST}" = "y" ]; then
if [ "$TARGET" != "$_TARGET_FOR_HOST_BUILD" ]; then
# if not already building for host - re-exec with clean env
(env "$ORIG_ENV" TARGET=$_TARGET_FOR_HOST_BUILD ./phoenix-rtos-build/build.sh host)
(env "$ORIG_ENV" NOSAN=1 TARGET=$_TARGET_FOR_HOST_BUILD ./phoenix-rtos-build/build.sh host)
else
source ./phoenix-rtos-build/build-host-tools.sh
fi
Expand Down
10 changes: 3 additions & 7 deletions scripts/gr716-bch.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def parse_args():
)
parser.add_argument("input", help="file to convert")
parser.add_argument("output", help="output file")
parser.add_argument("-s", "--size", help="size of the flash memory (default 16 MiB)")
parser.add_argument("-s", "--size", type=int, default=(16*1024*1024),
help="size of the flash memory in bytes (default %(default)s)")
return parser.parse_args()


Expand Down Expand Up @@ -60,11 +61,6 @@ def generate_bch(data: bytearray):

def main():
args = parse_args()
try:
size = int(args.size) if args.size else 16 * 1024 * 1024
except:
print(f'Error: invalid size "{args.size}"')
exit(1)

validate_file(args.input)

Expand All @@ -83,7 +79,7 @@ def main():
f.write(bch)

print(f"Generated BCH of {args.input} to {args.output}")
print(f"{BOLD}{GREEN}Please load the BCH file to the SPI flash at offset {hex(size - len(bch))}{NORMAL}")
print(f"{BOLD}{GREEN}Please load the BCH file to the SPI flash at offset {args.size - len(bch):#x}{NORMAL}")


if __name__ == "__main__":
Expand Down
Loading
Loading