blob: 7955db60e5b7bf6cfeab8ffb155318be3187d44f [file] [log] [blame]
Lukasz Majewski27229b22016-09-17 06:57:39 +02001#! /bin/bash
2#
3# Copyright (C) 2016, Lukasz Majewski <l.majewski@majess.pl>
4#
5# SPDX-License-Identifier: GPL-2.0+
6#
7
8# This file extracts default envs from built u-boot
9# usage: get_default_envs.sh > u-boot-env-default.txt
10set -ue
11
12ENV_OBJ_FILE="env_common.o"
13ENV_OBJ_FILE_COPY="copy_${ENV_OBJ_FILE}"
14
15echoerr() { echo "$@" 1>&2; }
16
17path=$(readlink -f $0)
18env_obj_file_path=$(find ${path%/scripts*} -not -path "*/spl/*" \
19 -name "${ENV_OBJ_FILE}")
20[ -z "${env_obj_file_path}" ] && \
21 { echoerr "File '${ENV_OBJ_FILE}' not found!"; exit 1; }
22
23cp ${env_obj_file_path} ${ENV_OBJ_FILE_COPY}
24
25# NOTE: objcopy saves its output to file passed in
26# (copy_env_common.o in this case)
27objcopy -O binary -j ".rodata.default_environment" ${ENV_OBJ_FILE_COPY}
28
29# Replace default '\0' with '\n' and sort entries
30tr '\0' '\n' < ${ENV_OBJ_FILE_COPY} | sort -u
31
32rm ${ENV_OBJ_FILE_COPY}
33
34exit 0