diff options
Diffstat (limited to 'recipes-bsp/u-boot/u-boot-target-env.inc')
| -rw-r--r-- | recipes-bsp/u-boot/u-boot-target-env.inc | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/recipes-bsp/u-boot/u-boot-target-env.inc b/recipes-bsp/u-boot/u-boot-target-env.inc new file mode 100644 index 0000000..c418a16 --- /dev/null +++ b/recipes-bsp/u-boot/u-boot-target-env.inc | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | # Handle severals environments generation for u-boot | ||
| 2 | |||
| 3 | #Env binary size | ||
| 4 | ENV_SIZE = "0x1000" | ||
| 5 | |||
| 6 | ENV_BIN_DIR = "${WORKDIR}/target_env_bin" | ||
| 7 | |||
| 8 | # Env deploy dir is the name of directory where binary envs will be deployed | ||
| 9 | ENV_DEPLOY_DIR="u-boot-envs" | ||
| 10 | |||
| 11 | # Env deploy src dir is the name of directory where txt envs will be deployed | ||
| 12 | ENV_SRC_DEPLOY_DIR="u-boot-envs-src" | ||
| 13 | |||
| 14 | do_build_mkimage_tool () { | ||
| 15 | HOSTCC="${CC}" HOSTLD="${LD}" HOSTLDFLAGS="${LDFLAGS}" HOSTSTRIP=true oe_runmake sandbox_defconfig | ||
| 16 | HOSTCC="${CC}" HOSTLD="${LD}" HOSTLDFLAGS="${LDFLAGS}" HOSTSTRIP=true oe_runmake tools | ||
| 17 | } | ||
| 18 | |||
| 19 | python do_environment_mkimage() { | ||
| 20 | import subprocess | ||
| 21 | import shutil | ||
| 22 | # list env variant target files | ||
| 23 | target_root_dir = d.getVar('WORKDIR',True) | ||
| 24 | # env files only for UBOOT_CONFIG | ||
| 25 | env_uboot_config = d.getVar('UBOOT_CONFIG',True) | ||
| 26 | env_files = [] | ||
| 27 | for f in os.listdir(target_root_dir): | ||
| 28 | if f.endswith(".env"): | ||
| 29 | env_files.append(os.path.join(target_root_dir,f)) | ||
| 30 | env_bin_dir = d.getVar("ENV_BIN_DIR",True) | ||
| 31 | # cleans if it exists env_bin directory | ||
| 32 | shutil.rmtree(env_bin_dir, ignore_errors=True) | ||
| 33 | # create env bin directory | ||
| 34 | os.mkdir(env_bin_dir) | ||
| 35 | print 'Building binary environments in : %s' % env_bin_dir | ||
| 36 | # iterate targets list to build binary environment files | ||
| 37 | for target_env in env_files : | ||
| 38 | # get only filename without path and extension | ||
| 39 | target_filename = os.path.splitext(os.path.basename(target_env))[0] | ||
| 40 | if target_filename not in env_uboot_config: | ||
| 41 | continue | ||
| 42 | # build output file path with ext | ||
| 43 | target_bin = os.path.join(env_bin_dir, | ||
| 44 | target_filename + '.bin') | ||
| 45 | # generated mkenvimage tool command line | ||
| 46 | cmd_mkimg ='cat %s | grep -v -E "^$|^\#" |' \ | ||
| 47 | ' ./tools/mkenvimage -s %s -r -o %s -' \ | ||
| 48 | % ( target_env, | ||
| 49 | d.getVar("ENV_SIZE",True), target_bin) | ||
| 50 | print 'Building binary for %s target:' % (target_filename) | ||
| 51 | print '%s' % cmd_mkimg | ||
| 52 | # execute shell command | ||
| 53 | ret = subprocess.call(cmd_mkimg, shell=True) | ||
| 54 | if ret: return ret | ||
| 55 | return 0 | ||
| 56 | } | ||
| 57 | |||
| 58 | do_deploy_append() { | ||
| 59 | install -d ${DEPLOYDIR} | ||
| 60 | # deploy binary U-boot environments | ||
| 61 | echo "Deploying U-boot Environments binary files in ${DEPLOYDIR}/${ENV_DEPLOY_DIR}" | ||
| 62 | install -d ${DEPLOYDIR}/${ENV_DEPLOY_DIR} | ||
| 63 | |||
| 64 | |||
| 65 | cp ${ENV_BIN_DIR}/*.bin ${DEPLOYDIR}/${ENV_DEPLOY_DIR} | ||
| 66 | } | ||
| 67 | |||
| 68 | addtask build_mkimage_tool after do_compile before do_environment_mkimage | ||
| 69 | addtask environment_mkimage after do_build_mkimage_tool before do_deploy | ||
