rel_1.6.0 init

This commit is contained in:
guocheng.kgc 2020-06-18 20:06:52 +08:00 committed by shengdong.dsd
commit 27b3e2883d
19359 changed files with 8093121 additions and 0 deletions

160
tools/5981a.sh Executable file
View file

@ -0,0 +1,160 @@
tempapp="example/$2"
function files_cp()
{
## rda5981x ##
cd -
rm -rf prebuild/*
mkdir -p prebuild/lib; mkdir -p prebuild/include
cp Living_SDK/out/$2@$3/libraries/*.a prebuild/lib/
cp Living_SDK/framework/protocol/linkkit/sdk/lib/Cortex-M4/awss_security.a prebuild/lib/
cp Living_SDK/framework/protocol/linkkit/sdk/lib/Cortex-M4/libaiotss.a prebuild/lib/
if [ $3 != uno-91h ]; then
cp Living_SDK/board/$3/hfilop/hfilop.a prebuild/lib/
fi
cp Living_SDK/board/$3/$3.ld prebuild/lib/
cp Living_SDK/platform/mcu/rda5981x/wifi/lib/TOOLCHAIN_GCC_ARM/libwifi_sta_ap.a prebuild/lib/
rm -f prebuild/lib/$2.a
cp -rfa Living_SDK/include/* prebuild/include
cp -rfa Living_SDK/utility/cjson/include/* prebuild/include
cp -rfa Living_SDK/framework/uOTA/inc/ota_service.h prebuild/include
cp -rfa Living_SDK/framework/protocol/linkkit/sdk/iotx-sdk-c_clone/include/* prebuild/include
cp -rfa Living_SDK/framework/protocol/linkkit/sdk/iotx-sdk-c_clone/src/infra/utils/misc/*.h prebuild/include
cp -rfa Living_SDK/framework/protocol/linkkit/sdk/iotx-sdk-c_clone/src/infra/log/*.h prebuild/include
cp --parents Living_SDK/kernel/rhino/core/include/* prebuild/include
cp --parents Living_SDK/kernel/vfs/include/*.h prebuild/include
mv prebuild/include/Living_SDK/kernel prebuild/include
cp --parents Living_SDK/framework/netmgr/include/*.h prebuild/include
mv prebuild/include/Living_SDK/framework prebuild/include
cp --parents Living_SDK/platform/arch/arm/armv7m/gcc/m4/*.h prebuild/include
mv prebuild/include/Living_SDK/platform prebuild/include
cp --parents Living_SDK/board/$3/*.h prebuild/include
if [ $3 != uno-91h ]; then
cp --parents Living_SDK/board/$3/hfilop/*.h prebuild/include
fi
mv prebuild/include/Living_SDK/board prebuild/include
rm -rf prebuild/include/Living_SDK
cp -f Products/$1/$2/$2.mk_old Products/$1/$2/$2.mk
}
function build_bin()
{
mkdir -p out
OUT=out/$2@$3
rm -rf $OUT
mkdir -p $OUT
app_ver=$(sed -n '/CONFIG_FIRMWARE_VERSION\ =/p' Products/$1/$2/$2.mk| sed -e 's/ //g' -e 's/\r//g')
echo "make version--framework.a $1 APP_NAME=$2 BOARD=$3 ARGS=$7 $app_ver"
cd Service/version
make clean; make APP=$2 PLATFORM=$3 BOARD=$3 CONFIG_SERVER_REGION=$4 CONFIG_SERVER_ENV=$5 CONFIG_DEBUG=$6 $app_ver $7
cd -
echo "make app APP=$2 PLATFORM=$3 BOARD=$3 CONFIG_SERVER_REGION=$4 CONFIG_SERVER_ENV=$5 CONFIG_DEBUG=$6 $7"
cd Products/$1/$2
make clean; make APP=$2 PLATFORM=$3 BOARD=$3 CONFIG_SERVER_REGION=$4 CONFIG_SERVER_ENV=$5 CONFIG_DEBUG=$6 $7
cd -
## build elf
cd prebuild/lib
CHIP=RDA5981x
CC=arm-none-eabi-gcc
OBJCOPY=arm-none-eabi-objcopy
STRIP=arm-none-eabi-strip
ARCH=arch_armv7m
p=prebuild/lib
if [ $3 != uno-91h ]; then
CHIP_LIBS="-Wl,--end-group -Wl,-no-whole-archive -Wl,--gc-sections -Wl,--cref -L ./$p/ ./$p/hfilop.a -T $3.ld -mcpu=cortex-m4 -mthumb -mthumb-interwork -mlittle-endian -nostartfiles --specs=nosys.specs --specs=nano.specs -u _printf_float $p/libwifi_sta_ap.a "
else
CHIP_LIBS="-Wl,--end-group -Wl,-no-whole-archive -Wl,--gc-sections -Wl,--cref -L ./$p/ -T $3.ld -mcpu=cortex-m4 -mthumb -mthumb-interwork -mlittle-endian -nostartfiles --specs=nosys.specs --specs=nano.specs -u _printf_float $p/libwifi_sta_ap.a "
fi
if [[ "$2" == httpapp ]] || [[ "$2" == coapapp ]];then
COMMON_LIBS="$p/$2.a $p/board_$3.a $p/$CHIP.a $p/vcall.a $p/kernel_init.a $p/auto_component.a $p/libiot_sdk.a $p/iotx-hal.a $p/netmgr.a $p/framework.a $p/cjson.a $p/cli.a $p/ota_hal.a $p/$ARCH.a $p/newlib_stub.a $p/rhino.a $p/digest_algorithm.a $p/net.a $p/log.a $p/activation.a $p/chip_code.a $p/imbedtls.a $p/kv.a $p/yloop.a $p/hal.a $p/base64.a $p/alicrypto.a $p/vfs.a $p/vfs_device.a $p/awss_security.a $p/libaiotss.a "
else
COMMON_LIBS="$p/$2.a $p/board_$3.a $p/$CHIP.a $p/vcall.a $p/kernel_init.a $p/auto_component.a $p/libiot_sdk.a $p/iotx-hal.a $p/netmgr.a $p/framework.a $p/cjson.a $p/ota.a $p/cli.a $p/ota_hal.a $p/$ARCH.a $p/newlib_stub.a $p/rhino.a $p/digest_algorithm.a $p/net.a $p/log.a $p/activation.a $p/chip_code.a $p/imbedtls.a $p/kv.a $p/yloop.a $p/hal.a $p/ota_transport.a $p/ota_download.a $p/ota_verify.a $p/base64.a $p/alicrypto.a $p/vfs.a $p/vfs_device.a $p/awss_security.a $p/libaiotss.a "
fi
cd -
$CC --static -Wl,-static -Wl,--warn-common -Wl,-Map,$OUT/$2@$3.map -Wl,--whole-archive -Wl,--start-group ${COMMON_LIBS} ${CHIP_LIBS} -o $OUT/$2@$3.elf
## generate map & strip elf
./tools/scripts/map_parse_gcc.py $OUT/$2@$3.map > $OUT/$2@$3_map.csv
$STRIP -o $OUT/$2@$3.stripped.elf $OUT/$2@$3.elf
./tools/scripts/map_parse_gcc.py $OUT/$2@$3.map
## gen bin
$OBJCOPY -O binary -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes $OUT/$2@$3.stripped.elf $OUT/$2@$3.bin
$OBJCOPY -O ihex -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes $OUT/$2@$3.stripped.elf $OUT/$2@$3.hex
cp -f $OUT/$2@$3.bin $OUT/$2@$3.bin.org
./Living_SDK/build/cmd/linux64/xz --format=lzma -A -z -k -f -v $OUT/$2@$3.bin
## ALI BOOTLOADER
/usr/bin/python tools/rda5981/gen_firmware_img.py $OUT/$2@$3.bin 0 tools/rda5981/bootloader.bin NONE $OUT/factory.bin
/usr/bin/python tools/scripts/ota_gen_md5_bin.py $OUT/$2@$3_ota.bin
cp -f $OUT/$2@$3_ota.bin $OUT/$2@$3_ali_ota.bin
cp -f $OUT/$2@$3.bin.lzma $OUT/$2@$3.bin.ali.lzma
# HF BOOTLORDER
./Living_SDK/build/cmd/linux64/xz --format=lzma -a -z -k -f -v $OUT/$2@$3.bin
/usr/bin/python tools/rda5981/gen_firmware_img.py $OUT/$2@$3.bin 0 tools/rda5981/bootloader.bin HF $OUT/factory.bin
/usr/bin/python tools/scripts/ota_gen_md5_bin.py $OUT/$2@$3_ota.bin
mv out/readme.txt $OUT
}
## check toolchain ##
if [ ! -f Living_SDK/build/compiler/gcc-arm-none-eabi/Linux64/bin/arm-none-eabi-gcc ];then
echo "download toolchain"
mkdir -p Living_SDK;mkdir -p Living_SDK/build;mkdir -p Living_SDK/build/compiler;mkdir -p Living_SDK/build/compiler/gcc-arm-none-eabi
cd tools && git clone --depth=1 https://gitee.com/alios-things/gcc-arm-none-eabi-linux.git && mv gcc-arm-none-eabi-linux/main ../Living_SDK/build/compiler/gcc-arm-none-eabi/ && mv ../Living_SDK/build/compiler/gcc-arm-none-eabi/main ../Living_SDK/build/compiler/gcc-arm-none-eabi/Linux64 && rm -rf gcc-arm-none-eabi-linux && cd -
fi
## build aos ##
if [[ ! -d Living_SDK/example/$2 ]] || [[ ! -d Living_SDK/out/$2@$3 ]]; then
if [[ -d Living_SDK/example ]] && [[ -d Products/$1 ]] && [[ -d Products/$1/$2 ]]; then
echo "do cp"
rm -rf Living_SDK/example/$2
#cp -rf Products/$1/$2 Living_SDK/example/$2
mv -f Products/$1/$2/$2.mk Products/$1/$2/$2.mk_old
cd Living_SDK/example
ln -s ../../Products/$1/$2 .
cd -
./tools/cmd/linux64/awk '{ gsub("'./make.settings'","example/${APP_FULL}/make.settings"); gsub("'"\?= MAINLAND"'","'"?= $4"'"); gsub("'"\?= ONLINE"'","'"?= $5"'"); gsub("'"CONFIG_DEBUG\ \?=\ 0"'","'"CONFIG_DEBUG ?= $6"'"); print $0 }' Products/$1/$2/$2.mk_old > Living_SDK/${tempapp}/$2.mk
echo "make aos sdk"
cd Living_SDK
aos make clean
aos make $2@$3 CONFIG_SERVER_REGION=$4 CONFIG_SERVER_ENV=$5 CONFIG_DEBUG=$6 $7
echo "cp libs and incs..."
files_cp $1 $2 $3
else
echo "folder Living_SDK/example or Products/$1/$2 is not existed!"
fi
else
if [ -d Living_SDK/example ]; then
echo "$2 folder is existed! check $2.mk file."
diff Living_SDK/${tempapp}/$2.mk Living_SDK/${tempapp}/$2.mk_old > Living_SDK/diff.txt
if [[ -s Living_SDK/diff.txt ]] || [[ ! -f prebuild/lib/board_$3.a ]]; then
echo "need rebuild all again!"
mv -f Products/$1/$2/$2.mk Products/$1/$2/$2.mk_old
./tools/cmd/linux64/awk '{ gsub("'./make.settings'","example/${APP_FULL}/make.settings"); gsub("'"\?= MAINLAND"'","'"?= $4"'"); gsub("'"\?= ONLINE"'","'"?= $5"'"); gsub("'"CONFIG_DEBUG\ \?=\ 0"'","'"CONFIG_DEBUG ?= $6"'"); print $0 }' Products/$1/$2/$2.mk_old > Living_SDK/${tempapp}/$2.mk
cd Living_SDK
aos make clean
aos make $2@$3 CONFIG_SERVER_REGION=$4 CONFIG_SERVER_ENV=$5 CONFIG_DEBUG=$6 $7
echo "cp libs and incs..."
files_cp $1 $2 $3
fi
fi
fi
echo "start to build app......"
build_bin $1 $2 $3 $4 $5 $6 "$7"

148
tools/amebaz_dev.sh Executable file
View file

@ -0,0 +1,148 @@
tempapp="example/$2"
function files_cp()
{
cd -
rm -rf prebuild/*
mkdir -p prebuild/lib; mkdir -p prebuild/include
cp Living_SDK/out/$2@$3/libraries/*.a prebuild/lib/
cp Living_SDK/framework/protocol/linkkit/sdk/lib/Cortex-M4/awss_security.a prebuild/lib/
cp Living_SDK/framework/protocol/linkkit/sdk/lib/Cortex-M4/libaiotss.a prebuild/lib/
cp Living_SDK/platform/mcu/rtl8710bn/lib/*.a prebuild/lib/
cp -rf Living_SDK/platform/mcu/rtl8710bn/script prebuild/lib/
rm -f prebuild/lib/$2.a
cp -rfa Living_SDK/include/* prebuild/include
cp -rfa Living_SDK/utility/cjson/include/* prebuild/include
cp -rfa Living_SDK/framework/uOTA/inc/ota_service.h prebuild/include
cp -rfa Living_SDK/framework/protocol/linkkit/sdk/iotx-sdk-c_clone/include/* prebuild/include
cp -rfa Living_SDK/framework/protocol/linkkit/sdk/iotx-sdk-c_clone/src/infra/utils/misc/*.h prebuild/include
cp -rfa Living_SDK/framework/protocol/linkkit/sdk/iotx-sdk-c_clone/src/infra/log/*.h prebuild/include
cp --parents Living_SDK/kernel/rhino/core/include/* prebuild/include
cp --parents Living_SDK/kernel/vfs/include/*.h prebuild/include
mv prebuild/include/Living_SDK/kernel prebuild/include
cp --parents Living_SDK/framework/netmgr/include/*.h prebuild/include
mv prebuild/include/Living_SDK/framework prebuild/include
cp --parents Living_SDK/platform/mcu/include/* prebuild/include
cp --parents Living_SDK/platform/arch/arm/armv7m/gcc/m4/*.h prebuild/include
mv prebuild/include/Living_SDK/platform prebuild/include
cp --parents Living_SDK/board/$3/*.h prebuild/include
mv prebuild/include/Living_SDK/board prebuild/include
rm -rf prebuild/include/Living_SDK
cp -f Products/$1/$2/$2.mk_old Products/$1/$2/$2.mk
}
function build_bin()
{
mkdir -p out
OUT=out/$2@$3
rm -rf $OUT
mkdir -p $OUT
echo "make version--framework.a"
cd Service/version
#make clean; make APP=$2 PLATFORM=$3 BOARD=$3 CONFIG_SERVER_REGION=$4 CONFIG_SERVER_ENV=$5 CONFIG_DEBUG=$6 $7
cd -
echo "make app"
cd Products/$1/$2
make clean; make APP=$2 PLATFORM=$3 BOARD=$3 CONFIG_SERVER_REGION=$4 CONFIG_SERVER_ENV=$5 CONFIG_DEBUG=$6 $7
cd -
## build elf
cd prebuild/lib
CHIP=rtl8710bn
CC=arm-none-eabi-gcc
OBJCOPY=arm-none-eabi-objcopy
STRIP=arm-none-eabi-strip
ARCH=arch_armv7m
p=prebuild/lib
CHIP_LIBS="-Wl,--end-group -Wl,-no-whole-archive -Wl,--gc-sections -Wl,--cref -L ./$p/ -l_platform -l_wlan -l_wps -l_p2p -l_rtlstd -T ./$p/script/rlx8711B-symbol-v02-img2_xip1.ld -mcpu=cortex-m4 -mthumb -Os -nostartfiles -Wl,--no-enum-size-warning -Wl,--no-wchar-size-warning -Wl,--gc-sections -Wl,--cref --specs=nano.specs -u _printf_float "
if [[ "$2" == httpapp ]] || [[ "$2" == coapapp ]];then
COMMON_LIBS="$p/$2.a $p/board_$3.a $p/$CHIP.a $p/vcall.a $p/kernel_init.a $p/auto_component.a $p/libiot_sdk.a $p/iotx-hal.a $p/netmgr.a $p/framework.a $p/cjson.a $p/cli.a $p/$ARCH.a $p/newlib_stub.a $p/rhino.a $p/digest_algorithm.a $p/net.a $p/rtl8710bn_SDK.a $p/rtl8710bn_Peripheral_Drivers.a $p/log.a $p/activation.a $p/chip_code.a $p/imbedtls.a $p/kv.a $p/yloop.a $p/hal.a $p/alicrypto.a $p/vfs.a $p/vfs_device.a $p/awss_security.a $p/libaiotss.a "
else
COMMON_LIBS="$p/$2.a $p/board_$3.a $p/$CHIP.a $p/vcall.a $p/kernel_init.a $p/auto_component.a $p/libiot_sdk.a $p/iotx-hal.a $p/netmgr.a $p/framework.a $p/cjson.a $p/ota.a $p/cli.a $p/ota_hal.a $p/$ARCH.a $p/newlib_stub.a $p/rhino.a $p/digest_algorithm.a $p/net.a $p/rtl8710bn_SDK.a $p/rtl8710bn_Peripheral_Drivers.a $p/log.a $p/activation.a $p/chip_code.a $p/imbedtls.a $p/kv.a $p/yloop.a $p/hal.a $p/ota_transport.a $p/ota_download.a $p/ota_verify.a $p/base64.a $p/alicrypto.a $p/vfs.a $p/vfs_device.a $p/awss_security.a $p/libaiotss.a "
fi
cd -
$CC -Wl,-Map,$OUT/$2@$3.map -Wl,--whole-archive -Wl,--start-group ${COMMON_LIBS} ${CHIP_LIBS} -o $OUT/$2@$3.elf
## generate map & strip elf
/usr/bin/python ./tools/scripts/map_parse_gcc.py $OUT/$2@$3.map > $OUT/$2@$3_map.csv
$STRIP -o $OUT/$2@$3.stripped.elf $OUT/$2@$3.elf
/usr/bin/python ./tools/scripts/map_parse_gcc.py $OUT/$2@$3.map
## gen bin
$OBJCOPY -O binary -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes $OUT/$2@$3.stripped.elf $OUT/$2@$3.bin
$OBJCOPY -O ihex -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes $OUT/$2@$3.stripped.elf $OUT/$2@$3.hex
$OBJCOPY -j .xip_image2.text -Obinary $OUT/$2@$3.elf $OUT/$2@$3.text.bin
$OBJCOPY -j .ram_image2.entry -j .ram_image2.text -j .ram_image2.data -Obinary $OUT/$2@$3.elf $OUT/$2@$3.data.bin
/usr/bin/python ./tools/rtl8710bn/pick.py $OUT/$2@$3.text.bin $OUT/$2@$3.data.bin $OUT/$2@$3.bin
./tools/amebaz_dev/manipulate_image.sh 1 ./Living_SDK $2 $3 ./Living_SDK/build/compiler/gcc-arm-none-eabi/linux64/bin
#./tools/amebaz_dev/manipulate_image.sh 2 ./Living_SDK $2 $3 ./Living_SDK/build/compiler/gcc-arm-none-eabi/linux64/bin
/usr/bin/python ./tools/scripts/gen_common_bin_output_file.py -o $OUT/$2@$3.all.bin -f 0x000000 ./Living_SDK/platform/mcu/rtl8710bn/bin/boot_all.bin
/usr/bin/python ./tools/scripts/gen_common_bin_output_file.py -o $OUT/$2@$3.all.bin -f 0x009000 ./Living_SDK/board/$3/system.bin
/usr/bin/python ./tools/scripts/gen_common_bin_output_file.py -o $OUT/$2@$3.all.bin -f 0x00B000 $OUT/image2_all_app1.bin
/usr/bin/python ./tools/scripts/ota_gen_md5_bin.py $OUT/$2@$3.bin
cp -f $OUT/$2@$3.bin $OUT/$2@$3.ota.bin
/usr/bin/python ./tools/scripts/ota_gen_md5_bin.py $OUT/$2@$3.bin
mv out/readme.txt $OUT
}
## check toolchain ##
if [ ! -f Living_SDK/build/compiler/gcc-arm-none-eabi/Linux64/bin/arm-none-eabi-gcc ];then
echo "download toolchain"
mkdir -p Living_SDK;mkdir -p Living_SDK/build;mkdir -p Living_SDK/build/compiler;mkdir -p Living_SDK/build/compiler/gcc-arm-none-eabi
cd tools && git clone --depth=1 https://gitee.com/alios-things/gcc-arm-none-eabi-linux.git && mv gcc-arm-none-eabi-linux/main ../Living_SDK/build/compiler/gcc-arm-none-eabi/ && mv ../Living_SDK/build/compiler/gcc-arm-none-eabi/main ../Living_SDK/build/compiler/gcc-arm-none-eabi/Linux64 && rm -rf gcc-arm-none-eabi-linux && cd -
fi
## build aos ##
if [[ ! -d Living_SDK/example/$2 ]] || [[ ! -d Living_SDK/out/$2@$3 ]]; then
if [[ -d Living_SDK/example ]] && [[ -d Products/$1 ]] && [[ -d Products/$1/$2 ]]; then
echo "do cp"
rm -rf Living_SDK/example/$2
#cp -rf Products/$1/$2 Living_SDK/example/$2
mv -f Products/$1/$2/$2.mk Products/$1/$2/$2.mk_old
cd Living_SDK/example
ln -s ../../Products/$1/$2 .
cd -
./tools/cmd/linux64/awk '{ gsub("'./make.settings'","example/${APP_FULL}/make.settings"); gsub("'"\?= MAINLAND"'","'"?= $4"'"); gsub("'"\?= ONLINE"'","'"?= $5"'"); gsub("'"CONFIG_DEBUG\ \?=\ 0"'","'"CONFIG_DEBUG ?= $6"'"); print $0 }' Products/$1/$2/$2.mk_old > Living_SDK/${tempapp}/$2.mk
echo "make aos sdk: $2@$3 CONFIG_SERVER_REGION=$4 CONFIG_SERVER_ENV=$5 CONFIG_DEBUG=$6 $7"
cd Living_SDK
aos make clean
aos make $2@$3 CONFIG_SERVER_REGION=$4 CONFIG_SERVER_ENV=$5 CONFIG_DEBUG=$6 $7
echo "cp libs and incs..."
files_cp $1 $2 $3
else
echo "folder Living_SDK/example or Products/$1/$2 is not existed!"
fi
else
if [ -d Living_SDK/example ]; then
echo "$2 folder is existed! check $2.mk file."
diff Living_SDK/${tempapp}/$2.mk Living_SDK/${tempapp}/$2.mk_old > Living_SDK/diff.txt
if [[ -s Living_SDK/diff.txt ]] || [[ ! -f prebuild/lib/board_$3.a ]]; then
echo "need rebuild all again!"
mv -f Products/$1/$2/$2.mk Products/$1/$2/$2.mk_old
./tools/cmd/linux64/awk '{ gsub("'./make.settings'","example/${APP_FULL}/make.settings"); gsub("'"\?= MAINLAND"'","'"?= $4"'"); gsub("'"\?= ONLINE"'","'"?= $5"'"); gsub("'"CONFIG_DEBUG\ \?=\ 0"'","'"CONFIG_DEBUG ?= $6"'"); print $0 }' Products/$1/$2/$2.mk_old > Living_SDK/${tempapp}/$2.mk
cd Living_SDK
aos make clean
aos make $2@$3 CONFIG_SERVER_REGION=$4 CONFIG_SERVER_ENV=$5 CONFIG_DEBUG=$6 $7
echo "cp libs and incs..."
files_cp $1 $2 $3
fi
fi
fi
echo "start to build app......"
build_bin $1 $2 $3 $4 $5 $6 "$7"

View file

@ -0,0 +1,82 @@
#!/bin/sh
export PATH=${PATH}:$5
ota_idx=$1
#dir=/home/cwhaiyi/pcshare/rualxw/AliOS-Things/platform/mcu/rtl8710bn
platform_dir=$2/platform/mcu/rtl8710bn
if [ ! -d "${platform_dir}/Debug/Exe" ]; then
mkdir -p ${platform_dir}/Debug/Exe
fi
BIN_DIR=${platform_dir}/Debug/Exe
outputname=$3@$4
outputdir=./out/${outputname}
OS=`uname -s`
PICK=${platform_dir}/tools/pick
PAD=${platform_dir}/tools/padding
CHKSUM=${platform_dir}/tools/checksum
OTA=${platform_dir}/tools/ota
echo ${platform_dir}
echo ""
echo -n "install dependent software packages ..."
if [ "$OS" = "Darwin" ]; then
if [ "`which gawk`" = "" ];then
sudo easy_install gawk > /dev/null
fi
else #Some Linux version
if [ "`which apt-get`" != "" ]; then
if [ "`which gawk`" = "" ];then
sudo sudo apt-get -y install gawk > /dev/null
fi
fi
fi
find ${BIN_DIR}/ -name "*.axf" | xargs rm -rf
find ${BIN_DIR}/ -name "*.map" | xargs rm -rf
if [ "${ota_idx}" = "1" ]; then
cp ${outputdir}/${outputname}.elf ${BIN_DIR}/${outputname}.axf
else
cp ${outputdir}/${outputname}.xip2.elf ${BIN_DIR}/${outputname}.axf
fi
arm-none-eabi-nm ${BIN_DIR}/${outputname}.axf | sort > ${BIN_DIR}/${outputname}.nmap
arm-none-eabi-objcopy -j .ram_image2.entry -j .ram_image2.data -j .ram_image2.text -j .ram_image2.bss -j .ram_image2.skb.bss -j .ram_heap.data -Obinary ${BIN_DIR}/${outputname}.axf ${BIN_DIR}/ram_2.r.bin
arm-none-eabi-objcopy -j .xip_image2.text -Obinary ${BIN_DIR}/${outputname}.axf ${BIN_DIR}/xip_image2.bin
arm-none-eabi-objcopy -j .ram_rdp.text -Obinary ${BIN_DIR}/${outputname}.axf ${BIN_DIR}/rdp.bin
if [ ! -f "${BIN_DIR}/bin/boot_all.bin" ]; then
cp ${platform_dir}/bin/boot_all.bin ${BIN_DIR}/boot_all.bin
fi
chmod 777 ${BIN_DIR}/boot_all.bin
chmod +rx ${PICK} ${CHKSUM} ${PAD} ${OTA}
${PICK} 0x`grep __ram_image2_text_start__ ${BIN_DIR}/${outputname}.nmap | gawk '{print $1}'` 0x`grep __ram_image2_text_end__ ${BIN_DIR}/${outputname}.nmap | gawk '{print $1}'` ${BIN_DIR}/ram_2.r.bin ${BIN_DIR}/ram_2.bin raw
${PICK} 0x`grep __ram_image2_text_start__ ${BIN_DIR}/${outputname}.nmap | gawk '{print $1}'` 0x`grep __ram_image2_text_end__ ${BIN_DIR}/${outputname}.nmap | gawk '{print $1}'` ${BIN_DIR}/ram_2.bin ${BIN_DIR}/ram_2.p.bin
${PICK} 0x`grep __xip_image2_start__ ${BIN_DIR}/${outputname}.nmap | gawk '{print $1}'` 0x`grep __xip_image2_start__ ${BIN_DIR}/${outputname}.nmap | gawk '{print $1}'` ${BIN_DIR}/xip_image2.bin ${BIN_DIR}/xip_image2.p.bin
IMAGE2_OTA1=image2_all_app1.bin
IMAGE2_OTA2=image2_all_app2.bin
OTA_ALL=ota_all.bin
if [ "${ota_idx}" = "1" ]; then
cat ${BIN_DIR}/xip_image2.p.bin > ${BIN_DIR}/${IMAGE2_OTA1}
chmod 777 ${BIN_DIR}/${IMAGE2_OTA1}
cat ${BIN_DIR}/ram_2.p.bin >> ${BIN_DIR}/${IMAGE2_OTA1}
${CHKSUM} ${BIN_DIR}/${IMAGE2_OTA1} || true
rm ${BIN_DIR}/xip_image2.p.bin ${BIN_DIR}/ram_2.p.bin
cp ${platform_dir}/bin/boot_all.bin ${outputdir}/boot_all.bin
cp ${BIN_DIR}/${IMAGE2_OTA1} ${outputdir}/${IMAGE2_OTA1}
elif [ "${ota_idx}" = "2" ]; then
cat ${BIN_DIR}/xip_image2.p.bin > ${BIN_DIR}/${IMAGE2_OTA2}
chmod 777 ${BIN_DIR}/${IMAGE2_OTA2}
cat ${BIN_DIR}/ram_2.p.bin >> ${BIN_DIR}/${IMAGE2_OTA2}
${CHKSUM} ${BIN_DIR}/${IMAGE2_OTA2} || true
${OTA} ${BIN_DIR}/${IMAGE2_OTA1} 0x800B000 ${BIN_DIR}/${IMAGE2_OTA2} 0x08100000 0x20170111 ${BIN_DIR}/${OTA_ALL}
cp ${platform_dir}/bin/boot_all.bin ${outputdir}/boot_all.bin
cp ${BIN_DIR}/${IMAGE2_OTA2} ${outputdir}/${IMAGE2_OTA2}
cp ${BIN_DIR}/${OTA_ALL} ${outputdir}/${OTA_ALL}
else
echo===========================================================
echo “ota_idx must be "1" or "2"
echo===========================================================
fi
#rm -f ${BIN_DIR}/ram_2.bin ${BIN_DIR}/ram_2.p.bin ${BIN_DIR}/ram_2.r.bin ${BIN_DIR}/xip_image2.bin ${BIN_DIR}/xip_image2.p.bin

139
tools/asr5501.sh Executable file
View file

@ -0,0 +1,139 @@
tempapp="example/$2"
function files_cp()
{
## asr5501 ##
cd -
rm -rf prebuild/*
mkdir -p prebuild/lib; mkdir -p prebuild/include
cp Living_SDK/out/$2@$3/libraries/*.a prebuild/lib/
cp Living_SDK/framework/protocol/linkkit/sdk/lib/Cortex-M4/awss_security.a prebuild/lib/
cp Living_SDK/framework/protocol/linkkit/sdk/lib/Cortex-M4/libaiotss.a prebuild/lib/
cp Living_SDK/board/$3/gcc_a0v2.ld prebuild/lib/
cp Living_SDK/platform/mcu/asr5501/drivers/libs/Cortex-M4/mcu_52m/libasr_wifi.a prebuild/lib/
cp Living_SDK/platform/mcu/asr5501/drivers/libs/Cortex-M4/libota_port.a prebuild/lib/
rm -f prebuild/lib/$2.a
cp -rfa Living_SDK/include/* prebuild/include
cp -rfa Living_SDK/utility/cjson/include/* prebuild/include
cp -rfa Living_SDK/framework/uOTA/inc/ota_service.h prebuild/include
cp -rfa Living_SDK/framework/protocol/linkkit/sdk/iotx-sdk-c_clone/include/* prebuild/include
cp -rfa Living_SDK/framework/protocol/linkkit/sdk/iotx-sdk-c_clone/src/infra/utils/misc/*.h prebuild/include
cp -rfa Living_SDK/framework/protocol/linkkit/sdk/iotx-sdk-c_clone/src/infra/log/*.h prebuild/include
cp --parents Living_SDK/kernel/rhino/core/include/* prebuild/include
cp --parents Living_SDK/kernel/vfs/include/*.h prebuild/include
mv prebuild/include/Living_SDK/kernel prebuild/include
cp --parents Living_SDK/framework/netmgr/include/*.h prebuild/include
mv prebuild/include/Living_SDK/framework prebuild/include
cp --parents Living_SDK/platform/arch/arm/armv7m/gcc/m4/*.h prebuild/include
mv prebuild/include/Living_SDK/platform prebuild/include
cp --parents Living_SDK/board/$3/config/*.h prebuild/include
mv prebuild/include/Living_SDK/board prebuild/include
mv prebuild/include/board/$3/config/*.h prebuild/include/board/$3
rm -rf prebuild/include/Living_SDK
cp -f Products/$1/$2/$2.mk_old Products/$1/$2/$2.mk
}
function build_bin()
{
mkdir -p out
OUT=out/$2@$3
rm -rf $OUT
mkdir -p $OUT
app_ver=$(sed -n '/CONFIG_FIRMWARE_VERSION\ =/p' Products/$1/$2/$2.mk| sed -e 's/ //g' -e 's/\r//g')
echo "make version--framework.a $1 APP_NAME=$2 BOARD=$3 ARGS=$4 $app_ver"
cd Service/version
make clean; make APP=$2 PLATFORM=$3 BOARD=$3 CONFIG_SERVER_REGION=$4 CONFIG_SERVER_ENV=$5 CONFIG_DEBUG=$6 $app_ver $7
cd -
echo "make app"
cd Products/$1/$2
make clean; make APP=$2 PLATFORM=$3 BOARD=$3 CONFIG_SERVER_REGION=$4 CONFIG_SERVER_ENV=$5 CONFIG_DEBUG=$6 $7
cd -
## build elf
cd prebuild/lib
CHIP=asr5501
CC=arm-none-eabi-gcc
OBJCOPY=arm-none-eabi-objcopy
STRIP=arm-none-eabi-strip
ARCH=arch_armv7m
p=prebuild/lib
CHIP_LIBS="-Wl,--end-group -Wl,-no-whole-archive -Wl,--gc-sections -Wl,--cref -mcpu=cortex-m4 -mthumb -Wl,-gc-sections -T gcc_a0v2.ld -L ./$p/ "
if [[ "$2" == httpapp ]] || [[ "$2" == coapapp ]];then
COMMON_LIBS="$p/$2.a $p/board_$3.a $p/$CHIP.a $p/vcall.a $p/kernel_init.a $p/auto_component.a $p/libiot_sdk.a $p/iotx-hal.a $p/netmgr.a $p/framework.a $p/cjson.a $p/cli.a $p/$ARCH.a $p/newlib_stub.a $p/rhino.a $p/digest_algorithm.a $p/net.a $p/log.a $p/activation.a $p/chip_code.a $p/imbedtls.a $p/kv.a $p/yloop.a $p/hal.a $p/alicrypto.a $p/vfs.a $p/vfs_device.a $p/awss_security.a $p/libaiotss.a $p/libasr_wifi.a $p/libota_port.a"
else
COMMON_LIBS="$p/$2.a $p/board_$3.a $p/$CHIP.a $p/vcall.a $p/kernel_init.a $p/auto_component.a $p/libiot_sdk.a $p/iotx-hal.a $p/netmgr.a $p/framework.a $p/cjson.a $p/ota.a $p/cli.a $p/ota_hal.a $p/$ARCH.a $p/newlib_stub.a $p/rhino.a $p/digest_algorithm.a $p/net.a $p/log.a $p/activation.a $p/chip_code.a $p/imbedtls.a $p/kv.a $p/yloop.a $p/hal.a $p/ota_transport.a $p/ota_download.a $p/ota_verify.a $p/base64.a $p/alicrypto.a $p/vfs.a $p/vfs_device.a $p/awss_security.a $p/libaiotss.a $p/libasr_wifi.a $p/libota_port.a"
fi
cd -
$CC --static -Wl,-static -Wl,--warn-common -Wl,-Map,$OUT/$2@$3.map -Wl,--whole-archive -Wl,--start-group ${COMMON_LIBS} ${CHIP_LIBS} -o $OUT/$2@$3.elf
## generate map & strip elf
/usr/bin/python ./tools/scripts/map_parse_gcc.py $OUT/$2@$3.map > $OUT/$2@$3_map.csv
$STRIP -o $OUT/$2@$3.stripped.elf $OUT/$2@$3.elf
/usr/bin/python ./tools/scripts/map_parse_gcc.py $OUT/$2@$3.map
## gen bin
$OBJCOPY -O binary -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes $OUT/$2@$3.stripped.elf $OUT/$2@$3.bin
$OBJCOPY -O ihex -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes $OUT/$2@$3.stripped.elf $OUT/$2@$3.hex
tools/asr5501/image_gen_header $OUT/$2@$3.bin "image_compress"
/usr/bin/python tools/scripts/ota_gen_md5_bin.py $OUT/$2@$3.bin
mv out/readme.txt $OUT
}
## check toolchain ##
if [ ! -f Living_SDK/build/compiler/gcc-arm-none-eabi/Linux64/bin/arm-none-eabi-gcc ];then
echo "download toolchain"
mkdir -p Living_SDK;mkdir -p Living_SDK/build;mkdir -p Living_SDK/build/compiler;mkdir -p Living_SDK/build/compiler/gcc-arm-none-eabi
cd tools && git clone --depth=1 https://gitee.com/alios-things/gcc-arm-none-eabi-linux.git && mv gcc-arm-none-eabi-linux/main ../Living_SDK/build/compiler/gcc-arm-none-eabi/ && mv ../Living_SDK/build/compiler/gcc-arm-none-eabi/main ../Living_SDK/build/compiler/gcc-arm-none-eabi/Linux64 && rm -rf gcc-arm-none-eabi-linux && cd -
fi
## build aos ##
if [[ ! -d Living_SDK/example/$2 ]] || [[ ! -d Living_SDK/out/$2@$3 ]]; then
if [[ -d Living_SDK/example ]] && [[ -d Products/$1 ]] && [[ -d Products/$1/$2 ]]; then
echo "do cp"
rm -rf Living_SDK/example/$2
#cp -rf Products/$1/$2 Living_SDK/example/$2
mv -f Products/$1/$2/$2.mk Products/$1/$2/$2.mk_old
cd Living_SDK/example
ln -s ../../Products/$1/$2 .
cd -
./tools/cmd/linux64/awk '{ gsub("'./make.settings'","example/${APP_FULL}/make.settings"); gsub("'"\?= MAINLAND"'","'"?= $4"'"); gsub("'"\?= ONLINE"'","'"?= $5"'"); gsub("'"CONFIG_DEBUG\ \?=\ 0"'","'"CONFIG_DEBUG ?= $6"'"); print $0 }' Products/$1/$2/$2.mk_old > Living_SDK/${tempapp}/$2.mk
echo "make aos sdk"
cd Living_SDK
aos make clean
aos make $2@$3 CONFIG_SERVER_REGION=$4 CONFIG_SERVER_ENV=$5 CONFIG_DEBUG=$6 $7
echo "cp libs and incs..."
files_cp $1 $2 $3
else
echo "folder Living_SDK/example or Products/$1/$2 is not existed!"
fi
else
if [ -d Living_SDK/example ]; then
echo "$2 folder is existed! check $2.mk file."
diff Living_SDK/${tempapp}/$2.mk Living_SDK/${tempapp}/$2.mk_old > Living_SDK/diff.txt
if [[ -s Living_SDK/diff.txt ]] || [[ ! -f prebuild/lib/board_$3.a ]]; then
echo "need rebuild all again!"
mv -f Products/$1/$2/$2.mk Products/$1/$2/$2.mk_old
./tools/cmd/linux64/awk '{ gsub("'./make.settings'","example/${APP_FULL}/make.settings"); gsub("'"\?= MAINLAND"'","'"?= $4"'"); gsub("'"\?= ONLINE"'","'"?= $5"'"); gsub("'"CONFIG_DEBUG\ \?=\ 0"'","'"CONFIG_DEBUG ?= $6"'"); print $0 }' Products/$1/$2/$2.mk_old > Living_SDK/${tempapp}/$2.mk
cd Living_SDK
aos make clean
aos make $2@$3 CONFIG_SERVER_REGION=$4 CONFIG_SERVER_ENV=$5 CONFIG_DEBUG=$6 $7
echo "cp libs and incs..."
files_cp $1 $2 $3
fi
fi
fi
echo "start to build app......"
build_bin $1 $2 $3 $4 $5 $6 "$7"

13
tools/asr5501/add_md5.py Normal file
View file

@ -0,0 +1,13 @@
import sys, hashlib
def MD5(bytes):
md5 = hashlib.md5()
md5.update(bytes)
return md5.hexdigest().decode('hex')
ota_bin = sys.argv[1]
with open(ota_bin, 'rb') as file:
ota_md5_bytes = MD5(file.read())
with open(ota_bin, 'ab') as file:
file.write(ota_md5_bytes)

BIN
tools/asr5501/image_gen_header Executable file

Binary file not shown.

18
tools/asr5501/ota.py Normal file
View file

@ -0,0 +1,18 @@
import os
import sys
import struct
import shutil
workdir = os.path.dirname(os.path.abspath(sys.argv[0]))
if sys.platform == 'linux2':
xzpath = 'xz'
else:
xzpath = os.path.join(workdir, 'xz', 'osx/xz' if sys.platform == 'darwin' else 'win/xz.exe').replace('\\', '/')
rawfile = sys.argv[1]
rawsize = os.path.getsize(rawfile)
xzfile = rawfile.replace('.bin', '.bin.xz')
otafile = rawfile.replace('.bin', '.ota.bin')
os.system('%s --lzma2=dict=32KiB --check=crc32 -k %s' % (xzpath, rawfile))
open(xzfile, 'ab').write(struct.pack('<L', rawsize))
shutil.move(xzfile, otafile)

BIN
tools/bk7231u/encrypt_linux Executable file

Binary file not shown.

View file

@ -0,0 +1,39 @@
import os
import sys
import struct
import zlib
import time
def pack_image(fw_file, boot_file):
print 'app file_name:', fw_file
print 'boot file_name:', boot_file
fname = os.path.splitext(fw_file)
f = file(boot_file, 'rb')
bootloader = f.read()
f.close()
f = file(fw_file, 'rb')
data_fw = f.read()
f.close()
f = file(fname[0] + '_all.bin', 'wb')
i = len(bootloader)
f.write(bootloader)
j = 0x11000 - i
i = 0
while i < j:
i += 1
f.write("\xff")
f.write(data_fw)
f.close();
if __name__ == "__main__":
if len(sys.argv) < 2:
print sys.argv[0], "firmware file"
exit(0)
pack_image(sys.argv[1], sys.argv[2])

158
tools/bk7231udevkitc.sh Executable file
View file

@ -0,0 +1,158 @@
tempapp="example/$2"
function files_cp()
{
cd -
rm -rf prebuild/*
mkdir -p prebuild/lib; mkdir -p prebuild/include
cp Living_SDK/out/$2@$3/libraries/*.a prebuild/lib/
cp Living_SDK/out/$2@$3/libraries/board_bk7231u.a prebuild/lib/board_bk7231udevkitc.a
#cp Living_SDK/out/$2@$3/ld/* prebuild/lib/
cp Living_SDK/platform/mcu/bk7231u/bk7231u.ld prebuild/lib/bk7231u.ld.S
cp Living_SDK/platform/mcu/bk7231u/beken/beken.a prebuild/lib/
cp Living_SDK/platform/mcu/bk7231u/beken/ip/ip.a prebuild/lib/
cp Living_SDK/platform/mcu/bk7231u/beken/driver/ble/ble_lib.a prebuild/lib/
#cp Living_SDK/platform/mcu/bk7231u/beken/alios/entry/entry.a prebuild/lib/
cp Living_SDK/security/irot/km/lib/ARM968E-S/libkm.a prebuild/lib
cp Living_SDK/framework/protocol/linkkit/sdk/lib/ARM968E-S/*.a prebuild/lib
rm -f prebuild/lib/$2.a
cp -rfa Living_SDK/include/* prebuild/include
cp -rfa Living_SDK/utility/cjson/include/* prebuild/include
cp -rfa Living_SDK/framework/uOTA/inc/ota_service.h prebuild/include
cp -rfa Living_SDK/framework/protocol/linkkit/sdk/iotx-sdk-c_clone/include/* prebuild/include
cp -rfa Living_SDK/framework/protocol/linkkit/sdk/iotx-sdk-c_clone/src/infra/utils/misc/*.h prebuild/include
cp -rfa Living_SDK/framework/protocol/linkkit/sdk/iotx-sdk-c_clone/src/infra/log/*.h prebuild/include
cp -rfa Living_SDK/framework/bluetooth/breeze/api/breeze_export.h prebuild/include
cp -rfa Living_SDK/framework/bluetooth/breeze/include/bzopt.h prebuild/include
cp --parents Living_SDK/kernel/rhino/core/include/* prebuild/include
cp --parents Living_SDK/kernel/vfs/include/*.h prebuild/include
mv prebuild/include/Living_SDK/kernel prebuild/include
cp --parents Living_SDK/framework/netmgr/include/*.h prebuild/include
mv prebuild/include/Living_SDK/framework prebuild/include
#cp --parents Living_SDK/platform/mcu/bk7231u/include/*.h prebuild/include
cp --parents Living_SDK/platform/arch/arm/armv7m/gcc/m4/*.h prebuild/include
mv prebuild/include/Living_SDK/platform prebuild/include
cp --parents Living_SDK/board/$3/*.h prebuild/include
mv prebuild/include/Living_SDK/board prebuild/include
rm -rf prebuild/include/Living_SDK
cp -f Products/$1/$2/$2.mk_old Products/$1/$2/$2.mk
}
function build_bin()
{
mkdir -p out
OUT=out/$2@$3
rm -rf $OUT
mkdir -p $OUT
app_ver=$(sed -n '/CONFIG_FIRMWARE_VERSION\ =/p' Products/$1/$2/$2.mk| sed -e 's/ //g' -e 's/\r//g')
echo "make version--framework.a $1 APP_NAME=$2 BOARD=$3 ARGS=$4 $app_ver"
cd Service/version
make clean; make APP=$2 PLATFORM=$3 BOARD=$3 CONFIG_SERVER_REGION=$4 CONFIG_SERVER_ENV=$5 CONFIG_DEBUG=$6 $app_ver $7
cd -
echo "make app APP=$2 PLATFORM=$3 BOARD=$3 CONFIG_SERVER_REGION=$4 CONFIG_SERVER_ENV=$5 CONFIG_DEBUG=$6 $7"
cd Products/$1/$2
make clean; make APP=$2 PLATFORM=$3 BOARD=$3 CONFIG_SERVER_REGION=$4 CONFIG_SERVER_ENV=$5 CONFIG_DEBUG=$6 $7
cd -
## build elf
cd prebuild/lib
CHIP=bk7231u
CC=arm-none-eabi-gcc
OBJCOPY=arm-none-eabi-objcopy
STRIP=arm-none-eabi-strip
ARCH=arch_armv5
p=prebuild/lib
CHIP_LIBS="$p/framework_runtime.a $p/app_runtime.a $p/bk7231u.a $p/beken.a $p/ip.a $p/ble_lib.a $p/entry.a $p/libkm.a -Wl,--end-group -Wl,-no-whole-archive -Wl,--gc-sections -Wl,--cref -mcpu=arm968e-s -march=armv5te -mthumb -mthumb-interwork -mlittle-endian --specs=nosys.specs -nostartfiles --specs=nano.specs -u _printf_float -Wl,--wrap=boot_undefined -Wl,--wrap=boot_pabort -Wl,--wrap=boot_dabort -uframework_info -uapp_info -T $p/bk7231u.ld -L ./$p "
if [[ "$2" == comboapp ]] || [[ "$2" == smart_led_bulb ]] || [[ "$2" == smart_outlet ]] || [[ "$2" == smart_led_strip ]] || [[ "$2" == smart_outlet_meter ]];then
BREEZE_LIB="$p/breeze.a"
fi
if [[ "$2" == httpapp ]] || [[ "$2" == coapapp ]];then
COMMON_LIBS="$p/$2.a $p/board_bk7231u.a $p/vcall.a $p/kernel_init.a $p/auto_component.a $p/libiot_sdk.a $p/iotx-hal.a $p/hal_init.a $p/netmgr.a $p/framework.a $p/cjson.a $p/cli.a $p/$ARCH.a $p/newlib_stub.a $p/rhino.a $p/digest_algorithm.a $p/net.a $p/log.a $p/activation.a $p/chip_code.a $p/imbedtls.a $p/kv.a $p/yloop.a $p/hal.a $p/alicrypto.a $p/vfs.a $p/vfs_device.a $p/awss_security.a $p/libaiotss.a "
else
COMMON_LIBS="$p/$2.a $p/board_bk7231u.a $p/vcall.a $p/kernel_init.a $p/auto_component.a $p/libiot_sdk.a $p/iotx-hal.a $p/hal_init.a $p/netmgr.a $p/framework.a $p/cjson.a $p/ota.a $p/cli.a $p/ota_hal.a $p/$ARCH.a $p/newlib_stub.a $p/rhino.a $p/digest_algorithm.a $p/net.a $p/log.a $p/activation.a $p/chip_code.a $p/imbedtls.a $p/kv.a $p/yloop.a $p/hal.a $p/ota_transport.a $p/ota_download.a $p/ota_verify.a $p/base64.a $p/alicrypto.a $p/vfs.a $p/vfs_device.a $p/awss_security.a $p/libaiotss.a "
fi
cd -
## generate map & strip elf
./tools/cmd/linux64/awk '{ gsub("'INCLUDE\ \board/bk7231udevkitc/bk7231udevkitc.ld'","INCLUDE Living_SDK/board/bk7231udevkitc/bk7231udevkitc.ld"); print $0 }' $p/bk7231u.ld.S > $p/bk7231u.ld
$CC -Wl,-Map,$OUT/$2@$3.map -Wl,--whole-archive -Wl,--start-group ${COMMON_LIBS} ${BREEZE_LIB} ${CHIP_LIBS} -o $OUT/$2@$3.elf
## generate map & strip elf
/usr/bin/python ./tools/scripts/map_parse_gcc.py $OUT/$2@$3.map > $OUT/$2@$3_map.csv
$STRIP -o $OUT/$2@$3.stripped.elf $OUT/$2@$3.elf
/usr/bin/python ./tools/scripts/map_parse_gcc.py $OUT/$2@$3.map
## gen bin
$OBJCOPY -O binary -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes $OUT/$2@$3.stripped.elf $OUT/$2@$3.bin
$OBJCOPY -O ihex -R .eh_frame -R .init -R .fini -R .comment -R .ARM.attributes $OUT/$2@$3.stripped.elf $OUT/$2@$3.hex
if [[ "$CHIP" == "bk7231u" ]]; then
./tools/bk7231u/encrypt_linux $OUT/$2@$3.bin 0 0 0 0
cp -f $OUT/$2@$3_crc.bin $OUT/$2@$3.bin
fi
./Living_SDK/build/cmd/linux64/xz -f --lzma2=dict=32KiB --check=crc32 -k $OUT/$2@$3.bin
cp $OUT/$2@$3.bin.xz $OUT/$2@$3_ota.bin
/usr/bin/python tools/scripts/ota_gen_md5_bin.py $OUT/$2@$3_ota.bin
## gen all bin (bootloader + application)
cp Living_SDK/platform/mcu/bk7231u/bootloader_bk7231u.bin $OUT/
/usr/bin/python tools/bk7231u/gen_firmware_img.py $OUT/$2@$3_crc.bin $OUT/bootloader_bk7231u.bin
mv out/readme.txt $OUT
}
## check toolchain ##
if [ ! -f Living_SDK/build/compiler/gcc-arm-none-eabi/Linux64/bin/arm-none-eabi-gcc ];then
echo "download toolchain"
mkdir -p Living_SDK;mkdir -p Living_SDK/build;mkdir -p Living_SDK/build/compiler;mkdir -p Living_SDK/build/compiler/gcc-arm-none-eabi
cd tools && git clone --depth=1 https://gitee.com/alios-things/gcc-arm-none-eabi-linux.git && mv gcc-arm-none-eabi-linux/main ../Living_SDK/build/compiler/gcc-arm-none-eabi/ && mv ../Living_SDK/build/compiler/gcc-arm-none-eabi/main ../Living_SDK/build/compiler/gcc-arm-none-eabi/Linux64 && rm -rf gcc-arm-none-eabi-linux && cd -
fi
## build aos ##
if [ ! -d Living_SDK/example/$2 ] || [ ! -d Living_SDK/out/$2@$3 ]; then
if [ -d Living_SDK/example ] && [ -d Products/$1 ] && [ -d Products/$1/$2 ]; then
echo "do cp"
rm -rf Living_SDK/example/$2
#cp -rf Products/$1/$2 Living_SDK/example/$2
mv -f Products/$1/$2/$2.mk Products/$1/$2/$2.mk_old
cd Living_SDK/example
ln -s ../../Products/$1/$2 .
cd -
./tools/cmd/linux64/awk '{ gsub("'./make.settings'","example/${APP_FULL}/make.settings"); gsub("'"\?= MAINLAND"'","'"?= $4"'"); gsub("'"\?= ONLINE"'","'"?= $5"'"); gsub("'"CONFIG_DEBUG\ \?=\ 0"'","'"CONFIG_DEBUG ?= $6"'"); print $0 }' Products/$1/$2/$2.mk_old > Living_SDK/${tempapp}/$2.mk
echo "make aos sdk"
cd Living_SDK
aos make clean
aos make $2@$3 CONFIG_SERVER_REGION=$4 CONFIG_SERVER_ENV=$5 CONFIG_DEBUG=$6 $7
echo "cp libs and incs..."
files_cp $1 $2 $3
else
echo "folder Living_SDK/example or Products/$1/$2 is not existed!"
fi
else
if [ -d Living_SDK/example ]; then
echo "$2 folder is existed! check $2.mk file."
diff Living_SDK/${tempapp}/$2.mk Living_SDK/${tempapp}/$2.mk_old > Living_SDK/diff.txt
if [[ -s Living_SDK/diff.txt ]] || [[ ! -f prebuild/lib/board_bk7231u.a ]]; then
echo "need rebuild all again!"
mv -f Products/$1/$2/$2.mk Products/$1/$2/$2.mk_old
./tools/cmd/linux64/awk '{ gsub("'./make.settings'","example/${APP_FULL}/make.settings"); gsub("'"\?= MAINLAND"'","'"?= $4"'"); gsub("'"\?= ONLINE"'","'"?= $5"'"); gsub("'"CONFIG_DEBUG\ \?=\ 0"'","'"CONFIG_DEBUG ?= $6"'"); print $0 }' Products/$1/$2/$2.mk_old > Living_SDK/${tempapp}/$2.mk
cd Living_SDK
aos make clean
aos make $2@$3 CONFIG_SERVER_REGION=$4 CONFIG_SERVER_ENV=$5 CONFIG_DEBUG=$6 $7
echo "cp libs and incs..."
files_cp $1 $2 $3
fi
fi
fi
echo "start to build app......"
build_bin $1 $2 $3 $4 $5 $6 "$7"

BIN
tools/cmd/etc/._readme.txt Normal file

Binary file not shown.

3
tools/cmd/etc/readme.txt Normal file
View file

@ -0,0 +1,3 @@
This directory is needed due to the MinGW version of uname.exe.
The program seems to reference the ../etc directory even though it is empty.
Without this directory uname.exe prints nothing.

Binary file not shown.

BIN
tools/cmd/linux32/._bin2c Executable file

Binary file not shown.

BIN
tools/cmd/linux32/._bin2c.c Normal file

Binary file not shown.

BIN
tools/cmd/linux32/._cat Executable file

Binary file not shown.

BIN
tools/cmd/linux32/._cp Executable file

Binary file not shown.

BIN
tools/cmd/linux32/._dash Executable file

Binary file not shown.

BIN
tools/cmd/linux32/._echo Executable file

Binary file not shown.

Binary file not shown.

BIN
tools/cmd/linux32/._make Executable file

Binary file not shown.

BIN
tools/cmd/linux32/._mkdir Executable file

Binary file not shown.

BIN
tools/cmd/linux32/._rm Executable file

Binary file not shown.

BIN
tools/cmd/linux32/._uname Executable file

Binary file not shown.

Binary file not shown.

BIN
tools/cmd/linux32/bin2c Executable file

Binary file not shown.

281
tools/cmd/linux32/bin2c.c Normal file
View file

@ -0,0 +1,281 @@
#pragma warning(disable:4996) // Disable MSVC++ warnings about unsafe functions
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#if defined( _MSC_VER )
int getopt(int argc, char *argv[], const char *optstring);
char *optarg;
int optind = 0;
extern int getopt(int ac, char *av[], const char *optstring);
extern int optind;
extern char *optarg;
#elif defined __GNUC__
#define _GNU_SOURCE
#include <getopt.h>
#else
#error Need definition for getopt
#endif
#include <sys/stat.h>
int opt_bigendian = 0;
int opt_word = 0;
int opt_indent = 8;
int opt_maxcol = 79;
char *opt_utype = NULL;
#define SWAP32(x) ((((x) >> 24) & 0x000000ff) | \
(((x) >> 8) & 0x0000ff00) | \
(((x) << 8) & 0x00ff0000) | \
(((x) << 24) & 0xff000000))
int
convert(char *ifn, char *ofn, char *array_name)
{
FILE *ifp, *ofp;
int c, lc;
struct stat istat;
char *array_type;
int array_len;
if (stat(ifn, &istat) < 0) {
fprintf(stderr, "error: could not stat input file %s: %s\n",
ifn, strerror(errno));
return -1;
}
array_type = (opt_word ? "const unsigned int" : "const unsigned char");
array_len = (opt_word ? ((int)istat.st_size + 3) / 4 : (int)istat.st_size);
if ((ifp = fopen(ifn, "rb")) == NULL) {
fprintf(stderr, "error: could not open input file %s: %s\n",
ifn, strerror(errno));
return -1;
}
if ((ofp = fopen(ofn, "w")) == NULL) {
fclose(ifp);
fprintf(stderr, "error: could not open output file %s: %s\n",
ofn, strerror(errno));
return -1;
}
fprintf(ofp, "/* FILE-CSTYLED */\n");
if (opt_utype != NULL) {
fprintf(ofp,
"#define %s %s_align._%s\n"
"union %s_u {\n"
"%*s%s _%s[%d];\n"
"%*s%s align;\n"
"} %s_align = {{\n",
array_name, array_name, array_name,
array_name,
opt_indent, "", array_type, array_name, array_len,
opt_indent, "", opt_utype,
array_name);
} else {
fprintf(ofp,
"%s %s[%d] = {\n",
array_type, array_name, array_len);
}
lc = 0;
if (opt_word) {
while ((c = fgetc(ifp)) != EOF) {
int i;
unsigned int val = (unsigned int)c;
for (i = 0; i < 3; i++) {
if ((c = getc(ifp)) == EOF)
c = 0;
val = (val << 8) | (unsigned int)c;
}
if (!opt_bigendian)
val = SWAP32(val);
if (lc > 0 && lc >= opt_maxcol - 12) {
fprintf(ofp, ",\n");
lc = 0;
}
if (lc == 0)
lc += fprintf(ofp, "%*s0x%08x", opt_indent, "", val);
else
lc += fprintf(ofp, ", 0x%08x", val);
}
} else {
while ((c = getc(ifp)) != EOF) {
if (lc > 0 && lc >= opt_maxcol - 5) {
fprintf(ofp, ",\n");
lc = 0;
}
if (lc == 0)
lc += fprintf(ofp, "%*s%d", opt_indent, "", c);
else
lc += fprintf(ofp, ", %d", c);
}
}
if (lc > 0)
fprintf(ofp, "\n");
if (opt_utype != NULL)
fprintf(ofp, "}");
fprintf(ofp, "};\n");
(void)fclose(ifp);
if (fclose(ofp) < 0) {
fprintf(stderr, "error: could not close output file %s: %s\n",
ofn, strerror(errno));
return -1;
}
return 0;
}
void
usage(void)
{
fprintf(stderr,
"Usage: bin2c [-w] [-eb] [-u type] [-i indent] [-m maxcol]\n"
" <input> <output> <arrayname>\n"
" -w Output 32-bit ints instead of bytes\n"
" -eb Output for big-endian CPU (when used with -w)\n"
" -u type Output a union with specified alignment type\n"
" -i indent Indentation amount\n"
" -m maxcol Maximum output columns to use\n");
exit(1);
}
int
main(int argc, char **argv)
{
int c;
while ((c = getopt(argc, argv, "we:u:i:m:")) > 0)
switch (c) {
case 'w':
opt_word = 1;
break;
case 'e':
opt_bigendian = (optarg[0] == 'b');
break;
case 'u':
opt_utype = optarg;
break;
case 'i':
opt_indent = atoi(optarg);
break;
case 'm':
opt_maxcol = atoi(optarg);
break;
default:
usage();
}
if (optind + 3 != argc)
usage();
if (convert(argv[optind], argv[optind + 1], argv[optind + 2]) < 0)
exit(1);
exit(0);
}
#if defined( _MSC_VER )
// From XGetopt.cpp Version 1.2
//
// Author: Hans Dietrich
// hdietrich2@hotmail.com
//
// Description:
// XGetopt.cpp implements getopt(), a function to parse command lines.
//
// History
// Version 1.2 - 2003 May 17
// - Added Unicode support
//
// Version 1.1 - 2002 March 10
// - Added example to XGetopt.cpp module header
//
// This software is released into the public domain.
// You are free to use it in any way you like.
//
// This software is provided "as is" with no expressed
// or implied warranty. I accept no liability for any
// damage or loss of business that this software may cause.
//
///////////////////////////////////////////////////////////////////////////////
int getopt(int argc, char *argv[], const char *optstring)
{
char c;
char *cp;
static char *next = NULL;
if (optind == 0)
next = NULL;
optarg = NULL;
if (next == NULL || *next == '\0')
{
if (optind == 0)
optind++;
if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0')
{
optarg = NULL;
if (optind < argc)
optarg = argv[optind];
return EOF;
}
if (strcmp(argv[optind], "--") == 0)
{
optind++;
optarg = NULL;
if (optind < argc)
optarg = argv[optind];
return EOF;
}
next = argv[optind];
next++; // skip past -
optind++;
}
c = *next++;
cp = strchr(optstring, c);
if (( cp == NULL ) || ( c == ':') )
return '?';
cp++;
if ( *cp == ':')
{
if (*next != '\0')
{
optarg = next;
next = NULL;
}
else if (optind < argc)
{
optarg = argv[optind];
optind++;
}
else
{
return '?';
}
}
return c;
}
#endif /* if defined( _MSC_VER ) */

BIN
tools/cmd/linux32/cat Executable file

Binary file not shown.

BIN
tools/cmd/linux32/cp Executable file

Binary file not shown.

BIN
tools/cmd/linux32/dash Executable file

Binary file not shown.

8
tools/cmd/linux32/echo Executable file
View file

@ -0,0 +1,8 @@
#!/bin/sh
# Copyright (C) 2002, Earnie Boyd
# mailto:earnie@users.sf.net
# This file is part of MSYS
# http://www.mingw.org/msys.shtml
# File: echo
echo "$@"

Binary file not shown.

BIN
tools/cmd/linux32/make Executable file

Binary file not shown.

BIN
tools/cmd/linux32/mkdir Executable file

Binary file not shown.

BIN
tools/cmd/linux32/rm Executable file

Binary file not shown.

BIN
tools/cmd/linux32/uname Executable file

Binary file not shown.

BIN
tools/cmd/linux64/._aes_cbc_128 Executable file

Binary file not shown.

BIN
tools/cmd/linux64/._bin2c Executable file

Binary file not shown.

BIN
tools/cmd/linux64/._bin2c.c Normal file

Binary file not shown.

BIN
tools/cmd/linux64/._cat Executable file

Binary file not shown.

BIN
tools/cmd/linux64/._cp Executable file

Binary file not shown.

BIN
tools/cmd/linux64/._dash Executable file

Binary file not shown.

BIN
tools/cmd/linux64/._echo Executable file

Binary file not shown.

BIN
tools/cmd/linux64/._hmac_sha256 Executable file

Binary file not shown.

BIN
tools/cmd/linux64/._make Executable file

Binary file not shown.

BIN
tools/cmd/linux64/._mkdir Executable file

Binary file not shown.

BIN
tools/cmd/linux64/._rm Executable file

Binary file not shown.

BIN
tools/cmd/linux64/._uname Executable file

Binary file not shown.

BIN
tools/cmd/linux64/aes_cbc_128 Executable file

Binary file not shown.

BIN
tools/cmd/linux64/awk Executable file

Binary file not shown.

BIN
tools/cmd/linux64/bin2c Executable file

Binary file not shown.

280
tools/cmd/linux64/bin2c.c Normal file
View file

@ -0,0 +1,280 @@
#pragma warning(disable:4996) // Disable MSVC++ warnings about unsafe functions
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#if defined( _MSC_VER )
int getopt(int argc, char *argv[], const char *optstring);
char *optarg;
int optind = 0;
extern int getopt(int ac, char *av[], const char *optstring);
extern int optind;
extern char *optarg;
#elif defined __GNUC__
#define _GNU_SOURCE
#include <getopt.h>
#else
#error Need definition for getopt
#endif
#include <sys/stat.h>
int opt_bigendian = 0;
int opt_word = 0;
int opt_indent = 8;
int opt_maxcol = 79;
char *opt_utype = NULL;
#define SWAP32(x) ((((x) >> 24) & 0x000000ff) | \
(((x) >> 8) & 0x0000ff00) | \
(((x) << 8) & 0x00ff0000) | \
(((x) << 24) & 0xff000000))
int
convert(char *ifn, char *ofn, char *array_name)
{
FILE *ifp, *ofp;
int c, lc;
struct stat istat;
char *array_type;
int array_len;
if (stat(ifn, &istat) < 0) {
fprintf(stderr, "error: could not stat input file %s: %s\n",
ifn, strerror(errno));
return -1;
}
array_type = (opt_word ? "const unsigned int" : "const unsigned char");
array_len = (opt_word ? ((int)istat.st_size + 3) / 4 : (int)istat.st_size);
if ((ifp = fopen(ifn, "rb")) == NULL) {
fprintf(stderr, "error: could not open input file %s: %s\n",
ifn, strerror(errno));
return -1;
}
if ((ofp = fopen(ofn, "w")) == NULL) {
fclose(ifp);
fprintf(stderr, "error: could not open output file %s: %s\n",
ofn, strerror(errno));
return -1;
}
fprintf(ofp, "/* FILE-CSTYLED */\n");
if (opt_utype != NULL) {
fprintf(ofp,
"#define %s %s_align._%s\n"
"union %s_u {\n"
"%*s%s _%s[%d];\n"
"%*s%s align;\n"
"} %s_align = {{\n",
array_name, array_name, array_name,
array_name,
opt_indent, "", array_type, array_name, array_len,
opt_indent, "", opt_utype,
array_name);
} else {
fprintf(ofp,
"%s %s[%d] = {\n",
array_type, array_name, array_len);
}
lc = 0;
if (opt_word) {
while ((c = fgetc(ifp)) != EOF) {
int i;
unsigned int val = (unsigned int)c;
for (i = 0; i < 3; i++) {
if ((c = getc(ifp)) == EOF)
c = 0;
val = (val << 8) | (unsigned int)c;
}
if (!opt_bigendian)
val = SWAP32(val);
if (lc > 0 && lc >= opt_maxcol - 12) {
fprintf(ofp, ",\n");
lc = 0;
}
if (lc == 0)
lc += fprintf(ofp, "%*s0x%08x", opt_indent, "", val);
else
lc += fprintf(ofp, ", 0x%08x", val);
}
} else {
while ((c = getc(ifp)) != EOF) {
if (lc > 0 && lc >= opt_maxcol - 5) {
fprintf(ofp, ",\n");
lc = 0;
}
if (lc == 0)
lc += fprintf(ofp, "%*s%d", opt_indent, "", c);
else
lc += fprintf(ofp, ", %d", c);
}
}
if (lc > 0)
fprintf(ofp, "\n");
if (opt_utype != NULL)
fprintf(ofp, "}");
fprintf(ofp, "};\n");
(void)fclose(ifp);
if (fclose(ofp) < 0) {
fprintf(stderr, "error: could not close output file %s: %s\n",
ofn, strerror(errno));
return -1;
}
return 0;
}
void
usage(void)
{
fprintf(stderr,
"Usage: bin2c [-w] [-eb] [-u type] [-i indent] [-m maxcol]\n"
" <input> <output> <arrayname>\n"
" -w Output 32-bit ints instead of bytes\n"
" -eb Output for big-endian CPU (when used with -w)\n"
" -u type Output a union with specified alignment type\n"
" -i indent Indentation amount\n"
" -m maxcol Maximum output columns to use\n");
exit(1);
}
int
main(int argc, char **argv)
{
int c;
while ((c = getopt(argc, argv, "we:u:i:m:")) > 0)
switch (c) {
case 'w':
opt_word = 1;
break;
case 'e':
opt_bigendian = (optarg[0] == 'b');
break;
case 'u':
opt_utype = optarg;
break;
case 'i':
opt_indent = atoi(optarg);
break;
case 'm':
opt_maxcol = atoi(optarg);
break;
default:
usage();
}
if (optind + 3 != argc)
usage();
if (convert(argv[optind], argv[optind + 1], argv[optind + 2]) < 0)
exit(1);
exit(0);
}
#if defined( _MSC_VER )
// From XGetopt.cpp Version 1.2
//
// Author: Hans Dietrich
// hdietrich2@hotmail.com
//
// Description:
// XGetopt.cpp implements getopt(), a function to parse command lines.
//
// History
// Version 1.2 - 2003 May 17
// - Added Unicode support
//
// Version 1.1 - 2002 March 10
// - Added example to XGetopt.cpp module header
//
// This software is released into the public domain.
// You are free to use it in any way you like.
//
// This software is provided "as is" with no expressed
// or implied warranty. I accept no liability for any
// damage or loss of business that this software may cause.
//
///////////////////////////////////////////////////////////////////////////////
int getopt(int argc, char *argv[], const char *optstring)
{
char c;
char *cp;
static char *next = NULL;
if (optind == 0)
next = NULL;
optarg = NULL;
if (next == NULL || *next == '\0')
{
if (optind == 0)
optind++;
if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0')
{
optarg = NULL;
if (optind < argc)
optarg = argv[optind];
return EOF;
}
if (strcmp(argv[optind], "--") == 0)
{
optind++;
optarg = NULL;
if (optind < argc)
optarg = argv[optind];
return EOF;
}
next = argv[optind];
next++; // skip past -
optind++;
}
c = *next++;
cp = strchr(optstring, c);
if (( cp == NULL ) || ( c == ':') )
return '?';
cp++;
if ( *cp == ':')
{
if (*next != '\0')
{
optarg = next;
next = NULL;
}
else if (optind < argc)
{
optarg = argv[optind];
optind++;
}
else
{
return '?';
}
}
return c;
}
#endif /* if defined( _MSC_VER ) */

BIN
tools/cmd/linux64/cat Executable file

Binary file not shown.

BIN
tools/cmd/linux64/cp Executable file

Binary file not shown.

BIN
tools/cmd/linux64/dash Executable file

Binary file not shown.

BIN
tools/cmd/linux64/echo Executable file

Binary file not shown.

BIN
tools/cmd/linux64/grep Executable file

Binary file not shown.

BIN
tools/cmd/linux64/hmac_sha256 Executable file

Binary file not shown.

BIN
tools/cmd/linux64/make Executable file

Binary file not shown.

BIN
tools/cmd/linux64/mkdir Executable file

Binary file not shown.

BIN
tools/cmd/linux64/rm Executable file

Binary file not shown.

BIN
tools/cmd/linux64/st-flash Executable file

Binary file not shown.

BIN
tools/cmd/linux64/st-info Executable file

Binary file not shown.

BIN
tools/cmd/linux64/st-util Executable file

Binary file not shown.

BIN
tools/cmd/linux64/uname Executable file

Binary file not shown.

BIN
tools/cmd/linux64/xz Executable file

Binary file not shown.

BIN
tools/cmd/osx/._aes_cbc_128 Normal file

Binary file not shown.

BIN
tools/cmd/osx/._bin2c Executable file

Binary file not shown.

BIN
tools/cmd/osx/._bin2c.c Normal file

Binary file not shown.

BIN
tools/cmd/osx/._cat Executable file

Binary file not shown.

BIN
tools/cmd/osx/._cp Executable file

Binary file not shown.

BIN
tools/cmd/osx/._dash Executable file

Binary file not shown.

BIN
tools/cmd/osx/._echo Executable file

Binary file not shown.

BIN
tools/cmd/osx/._hmac_sha256 Normal file

Binary file not shown.

BIN
tools/cmd/osx/._mkdir Executable file

Binary file not shown.

BIN
tools/cmd/osx/._uname Executable file

Binary file not shown.

BIN
tools/cmd/osx/aes_cbc_128 Normal file

Binary file not shown.

BIN
tools/cmd/osx/awk Executable file

Binary file not shown.

BIN
tools/cmd/osx/bin2c Executable file

Binary file not shown.

280
tools/cmd/osx/bin2c.c Normal file
View file

@ -0,0 +1,280 @@
#pragma warning(disable:4996) // Disable MSVC++ warnings about unsafe functions
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#if defined( _MSC_VER )
int getopt(int argc, char *argv[], const char *optstring);
char *optarg;
int optind = 0;
extern int getopt(int ac, char *av[], const char *optstring);
extern int optind;
extern char *optarg;
#elif defined __GNUC__
#define _GNU_SOURCE
#include <getopt.h>
#else
#error Need definition for getopt
#endif
#include <sys/stat.h>
int opt_bigendian = 0;
int opt_word = 0;
int opt_indent = 8;
int opt_maxcol = 79;
char *opt_utype = NULL;
#define SWAP32(x) ((((x) >> 24) & 0x000000ff) | \
(((x) >> 8) & 0x0000ff00) | \
(((x) << 8) & 0x00ff0000) | \
(((x) << 24) & 0xff000000))
int
convert(char *ifn, char *ofn, char *array_name)
{
FILE *ifp, *ofp;
int c, lc;
struct stat istat;
char *array_type;
int array_len;
if (stat(ifn, &istat) < 0) {
fprintf(stderr, "error: could not stat input file %s: %s\n",
ifn, strerror(errno));
return -1;
}
array_type = (opt_word ? "const unsigned int" : "const unsigned char");
array_len = (opt_word ? ((int)istat.st_size + 3) / 4 : (int)istat.st_size);
if ((ifp = fopen(ifn, "rb")) == NULL) {
fprintf(stderr, "error: could not open input file %s: %s\n",
ifn, strerror(errno));
return -1;
}
if ((ofp = fopen(ofn, "w")) == NULL) {
fclose(ifp);
fprintf(stderr, "error: could not open output file %s: %s\n",
ofn, strerror(errno));
return -1;
}
fprintf(ofp, "/* FILE-CSTYLED */\n");
if (opt_utype != NULL) {
fprintf(ofp,
"#define %s %s_align._%s\n"
"union %s_u {\n"
"%*s%s _%s[%d];\n"
"%*s%s align;\n"
"} %s_align = {{\n",
array_name, array_name, array_name,
array_name,
opt_indent, "", array_type, array_name, array_len,
opt_indent, "", opt_utype,
array_name);
} else {
fprintf(ofp,
"%s %s[%d] = {\n",
array_type, array_name, array_len);
}
lc = 0;
if (opt_word) {
while ((c = fgetc(ifp)) != EOF) {
int i;
unsigned int val = (unsigned int)c;
for (i = 0; i < 3; i++) {
if ((c = getc(ifp)) == EOF)
c = 0;
val = (val << 8) | (unsigned int)c;
}
if (!opt_bigendian)
val = SWAP32(val);
if (lc > 0 && lc >= opt_maxcol - 12) {
fprintf(ofp, ",\n");
lc = 0;
}
if (lc == 0)
lc += fprintf(ofp, "%*s0x%08x", opt_indent, "", val);
else
lc += fprintf(ofp, ", 0x%08x", val);
}
} else {
while ((c = getc(ifp)) != EOF) {
if (lc > 0 && lc >= opt_maxcol - 5) {
fprintf(ofp, ",\n");
lc = 0;
}
if (lc == 0)
lc += fprintf(ofp, "%*s%d", opt_indent, "", c);
else
lc += fprintf(ofp, ", %d", c);
}
}
if (lc > 0)
fprintf(ofp, "\n");
if (opt_utype != NULL)
fprintf(ofp, "}");
fprintf(ofp, "};\n");
(void)fclose(ifp);
if (fclose(ofp) < 0) {
fprintf(stderr, "error: could not close output file %s: %s\n",
ofn, strerror(errno));
return -1;
}
return 0;
}
void
usage(void)
{
fprintf(stderr,
"Usage: bin2c [-w] [-eb] [-u type] [-i indent] [-m maxcol]\n"
" <input> <output> <arrayname>\n"
" -w Output 32-bit ints instead of bytes\n"
" -eb Output for big-endian CPU (when used with -w)\n"
" -u type Output a union with specified alignment type\n"
" -i indent Indentation amount\n"
" -m maxcol Maximum output columns to use\n");
exit(1);
}
int
main(int argc, char **argv)
{
int c;
while ((c = getopt(argc, argv, "we:u:i:m:")) > 0)
switch (c) {
case 'w':
opt_word = 1;
break;
case 'e':
opt_bigendian = (optarg[0] == 'b');
break;
case 'u':
opt_utype = optarg;
break;
case 'i':
opt_indent = atoi(optarg);
break;
case 'm':
opt_maxcol = atoi(optarg);
break;
default:
usage();
}
if (optind + 3 != argc)
usage();
if (convert(argv[optind], argv[optind + 1], argv[optind + 2]) < 0)
exit(1);
exit(0);
}
#if defined( _MSC_VER )
// From XGetopt.cpp Version 1.2
//
// Author: Hans Dietrich
// hdietrich2@hotmail.com
//
// Description:
// XGetopt.cpp implements getopt(), a function to parse command lines.
//
// History
// Version 1.2 - 2003 May 17
// - Added Unicode support
//
// Version 1.1 - 2002 March 10
// - Added example to XGetopt.cpp module header
//
// This software is released into the public domain.
// You are free to use it in any way you like.
//
// This software is provided "as is" with no expressed
// or implied warranty. I accept no liability for any
// damage or loss of business that this software may cause.
//
///////////////////////////////////////////////////////////////////////////////
int getopt(int argc, char *argv[], const char *optstring)
{
char c;
char *cp;
static char *next = NULL;
if (optind == 0)
next = NULL;
optarg = NULL;
if (next == NULL || *next == '\0')
{
if (optind == 0)
optind++;
if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0')
{
optarg = NULL;
if (optind < argc)
optarg = argv[optind];
return EOF;
}
if (strcmp(argv[optind], "--") == 0)
{
optind++;
optarg = NULL;
if (optind < argc)
optarg = argv[optind];
return EOF;
}
next = argv[optind];
next++; // skip past -
optind++;
}
c = *next++;
cp = strchr(optstring, c);
if (( cp == NULL ) || ( c == ':') )
return '?';
cp++;
if ( *cp == ':')
{
if (*next != '\0')
{
optarg = next;
next = NULL;
}
else if (optind < argc)
{
optarg = argv[optind];
optind++;
}
else
{
return '?';
}
}
return c;
}
#endif /* if defined( _MSC_VER ) */

BIN
tools/cmd/osx/cat Executable file

Binary file not shown.

BIN
tools/cmd/osx/cp Executable file

Binary file not shown.

BIN
tools/cmd/osx/dash Executable file

Binary file not shown.

BIN
tools/cmd/osx/echo Executable file

Binary file not shown.

BIN
tools/cmd/osx/grep Executable file

Binary file not shown.

BIN
tools/cmd/osx/hmac_sha256 Normal file

Binary file not shown.

BIN
tools/cmd/osx/make Executable file

Binary file not shown.

BIN
tools/cmd/osx/mkdir Executable file

Binary file not shown.

BIN
tools/cmd/osx/rm Executable file

Binary file not shown.

BIN
tools/cmd/osx/st-flash Executable file

Binary file not shown.

BIN
tools/cmd/osx/st-info Executable file

Binary file not shown.

BIN
tools/cmd/osx/st-util Executable file

Binary file not shown.

BIN
tools/cmd/osx/uname Executable file

Binary file not shown.

BIN
tools/cmd/osx/xz Executable file

Binary file not shown.

Binary file not shown.

BIN
tools/cmd/win32/._bin2c.c Normal file

Binary file not shown.

BIN
tools/cmd/win32/._bin2c.exe Normal file

Binary file not shown.

BIN
tools/cmd/win32/._bzip2.exe Normal file

Binary file not shown.

BIN
tools/cmd/win32/._cp.exe Executable file

Binary file not shown.

BIN
tools/cmd/win32/._echo.exe Executable file

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show more