|  |  | 
 |  |  | #!/bin/bash | 
 |  |  |  | 
 |  |  | # Build Cortex-M FreeRTOS SDK or not | 
 |  |  | #BUILD_MCORE=yes | 
 |  |  |  | 
 |  |  | # this project absolute path | 
 |  |  | PRJ_PATH=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd) | 
 |  |  |  | 
 |  |  | 
 |  |  |     export BOARD=`jq -r ".bsp.board" $CONF_FILE | tr 'A-Z' 'a-z'` | 
 |  |  |     export BSP_VER=`jq -r ".bsp.version" $CONF_FILE | tr 'A-Z' 'a-z'` | 
 |  |  |     export GIT_URL=`jq -r ".bsp.giturl" $CONF_FILE | tr 'A-Z' 'a-z'` | 
 |  |  |     export CROSS_COMPILE=`jq -r ".bsp.cortexAtool" $CONF_FILE | tr 'A-Z' 'a-z'` | 
 |  |  |     export MCORE_COMPILE=`jq -r ".bsp.cortexMtool" $CONF_FILE | tr 'A-Z' 'a-z'` | 
 |  |  |     export CROSS_COMPILE=`jq -r ".bsp.cortexAtool" $CONF_FILE` | 
 |  |  |     export MCORE_COMPILE=`jq -r ".bsp.cortexMtool" $CONF_FILE` | 
 |  |  |  | 
 |  |  |     export BRANCH=$BSP_VER | 
 |  |  |     export JOBS=`cat /proc/cpuinfo | grep processor | wc -l` | 
 |  |  | 
 |  |  | function build_cortexM() | 
 |  |  | { | 
 |  |  |     SRC=mcore-sdk | 
 |  |  |     DEMO_PATH=boards/$MCORE_BOARD/multicore_examples/rpmsg_lite_str_echo_rtos/armgcc | 
 |  |  |  | 
 |  |  |     if [ "$BUILD_MCORE" != "yes" ] ; then | 
 |  |  |         pr_warn "Skip build Cortex-M core SDK source code '$SRC'" | 
 |  |  |         return 0; | 
 |  |  |     fi | 
 |  |  |  | 
 |  |  |     if [[ $BOARD =~ mx8mp ]] ; then | 
 |  |  |         EVK=evkmimx8mp | 
 |  |  |     fi | 
 |  |  |     DEMO_PATH=boards/$EVK/multicore_examples/rpmsg_lite_str_echo_rtos/armgcc | 
 |  |  |     DEMO_BIN=release/rpmsg_lite_str_echo_rtos.bin | 
 |  |  |     export ARMGCC_DIR=$(echo $MCORE_COMPILE | sed 's\/bin/.*\\') | 
 |  |  |     MCORE_IMAGE=cortexM-${BOARD}.bin | 
 |  |  |  | 
 |  |  |     if [ ! -d $PRJ_PATH/$SRC ] ; then | 
 |  |  |         if [ "$MCORE_BUILD" == "yes" ] ; then | 
 |  |  |             pr_error "INFO: Please download $BOARD SDK from https://mcuxpresso.nxp.com" | 
 |  |  |             pr_error "      by manual and decompress it to folder '$SRC'" | 
 |  |  |             exit; | 
 |  |  |         else | 
 |  |  |             pr_warn "Skip build Cortex-M core SDK source code '$SRC'" | 
 |  |  |             return ; | 
 |  |  |         fi | 
 |  |  |         pr_error "INFO: Please download $BOARD SDK from https://mcuxpresso.nxp.com by manual and" | 
 |  |  |         pr_error "      decompress it to folder '$PRJ_PATH/$SRC'" | 
 |  |  |         exit; | 
 |  |  |     fi | 
 |  |  |  | 
 |  |  |     pr_warn "start build $SRC" | 
 |  |  |  | 
 |  |  |     cd $PRJ_PATH/${SRC} | 
 |  |  |     cd $DEMO_PATH | 
 |  |  |     cd $PRJ_PATH/${SRC}/$DEMO_PATH | 
 |  |  |     export ARMGCC_DIR=$(echo $MCORE_COMPILE | sed 's\/bin/.*\\') | 
 |  |  |  | 
 |  |  |     #bash clean.sh | 
 |  |  |     if [ ! -s $DEMO_BIN ] ; then | 
 |  |  | 
 |  |  |     fi | 
 |  |  |  | 
 |  |  |     set -x | 
 |  |  |     cp $DEMO_BIN $MKIMG_BIN_PATH/$MCORE_IMAGE | 
 |  |  |     cp $DEMO_BIN $PRFX_PATH/$MCORE_IMAGE | 
 |  |  |     set +x | 
 |  |  | } | 
 |  |  |  | 
 |  |  | 
 |  |  |         set -x | 
 |  |  |         cp u-boot-${BOARD}.imx $PRFX_PATH | 
 |  |  |         set +x | 
 |  |  |         return ; | 
 |  |  |         return 0; | 
 |  |  |     fi | 
 |  |  |  | 
 |  |  |     set -x | 
 |  |  | 
 |  |  |     fi | 
 |  |  |  | 
 |  |  |     build_atf | 
 |  |  |     build_cortexM | 
 |  |  |     build_imxboot | 
 |  |  |     #build_cortexM | 
 |  |  | } | 
 |  |  |  | 
 |  |  | function do_install() | 
 |  |  | 
 |  |  |  | 
 |  |  |     if [[ -n "$INST_PATH" && -w $INST_PATH ]] ; then | 
 |  |  |         pr_info "install bootloader to '$INST_PATH'" | 
 |  |  |         cp $PRFX_PATH/u-boot-${BOARD}.imx $INST_PATH | 
 |  |  |         cp $PRFX_PATH/* $INST_PATH | 
 |  |  |         #sz $PRFX_PATH/u-boot-${BOARD}.imx | 
 |  |  |     fi | 
 |  |  | } |