Created
April 19, 2017 09:00
-
-
Save jfcamel/56bc42e0f52729fa25d342dce81cdf88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Environment SetUp | |
| SRC=${@} | |
| AS=/usr/bin/armv7a-hardfloat-linux-gnueabi-as | |
| LD=/usr/bin/armv7a-hardfloat-linux-gnueabi-ld | |
| OBJCOPY=/usr/bin/armv7a-hardfloat-linux-gnueabi-objcopy | |
| # CONNEX | |
| export START_ADDRESS=0x00000000 | |
| export BLOCK_SIZE_BYTE=4096 | |
| export BLOCK_COUNT=4096 | |
| # Load Variables which are able to override | |
| . config.sh | |
| # Variables for use internally | |
| TARGET=$1 | |
| OBJS=() | |
| OBJFILESIZE=0 | |
| FLASHIMG=flash.bin | |
| echo compiling $SRC... | |
| split_suffix() { | |
| IFS_ORIGIN=$IFS | |
| IFS=. | |
| arr=($1) | |
| IFS=${IFS_ORIGIN} | |
| echo ${arr[0]} | |
| } | |
| # compile assemble files | |
| while [ "x$2" != "x" ]; do | |
| out="$(split_suffix $2).o" | |
| ${AS} -o ${out} $2 | |
| OBJS[${OBJFILESIZE}]=${out} | |
| OBJFILESIZE=$((OBJFILESIZE++)) | |
| shift | |
| done | |
| # link files | |
| elf="$(split_suffix $1).elf" | |
| echo "${LD} -Ttext=${START_ADDRESS} -o ${elf} ${OBJS[@]}" | |
| ${LD} -Ttext=${START_ADDRESS} -o ${elf} ${OBJS[@]} | |
| # Convert to Binary format | |
| bin="$(split_suffix $1).bin" | |
| ${OBJCOPY} -O binary ${elf} ${bin} | |
| # Prepare flash images | |
| dd if=/dev/zero of=${FLASHIMG} bs=${BLOCK_SIZE_BYTE} count=${BLOCK_COUNT} | |
| dd if=${bin} of=${FLASHIMG} bs=${BLOCK_COUNT} conv=notrunc | |
| # execute on qemu | |
| qemu-system-arm -M connex -pflash ${FLASHIMG} -nographic -serial /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment