rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 3 | DEFAULT_TOOLPATH="$DIR/toolpaths.default" |
| 4 | if [ -e "$DEFAULT_TOOLPATH" ] |
| 5 | then |
| 6 | source $DEFAULT_TOOLPATH |
| 7 | fi |
| 8 | |
| 9 | function HELP { |
| 10 | echo "help:" |
| 11 | echo "-c cmpctmalloc instead of dlmalloc" |
| 12 | echo "-M miniheap instead of dlmalloc" |
| 13 | echo "-h for help" |
| 14 | echo "all arguments after -- are passed to qemu directly" |
| 15 | exit 1 |
| 16 | } |
| 17 | |
| 18 | DO_CMPCTMALLOC=0 |
| 19 | DO_MINIHEAP=0 |
| 20 | MEMSIZE=8 |
| 21 | |
| 22 | while getopts bdhm:cMnt6 FLAG; do |
| 23 | case $FLAG in |
| 24 | c) DO_CMPCTMALLOC=1;; |
| 25 | M) DO_MINIHEAP=1;; |
| 26 | M) DO_MINIHEAP=1;; |
| 27 | h) HELP;; |
| 28 | \?) |
| 29 | echo unrecognized option |
| 30 | HELP |
| 31 | esac |
| 32 | done |
| 33 | |
| 34 | shift $((OPTIND-1)) |
| 35 | |
| 36 | if [ -z "$QEMUM4" ]; then |
| 37 | echo "QEMUM4 is not defined. Set QEMUM4='path/to/qemu-m4' inside scripts/toolpaths.local" |
| 38 | exit 1 |
| 39 | fi |
| 40 | |
| 41 | PROJECT="qemu-m4-test" |
| 42 | |
| 43 | ARGS=" -serial tcp::12345,server,nowait " # Logs |
| 44 | ARGS+=" -serial tcp::12344,server,nowait " # Debug |
| 45 | ARGS+=" -serial stdio" # Console |
| 46 | ARGS+=" -machine pebble-s4-bb -cpu cortex-m4" |
| 47 | ARGS+=" -pflash build-${PROJECT}/lk.bin " |
| 48 | ARGS+=" -monitor tcp::12346,server,nowait" |
| 49 | |
| 50 | if [ $DO_CMPCTMALLOC == 1 ]; then |
| 51 | MAKE_VARS=LK_HEAP_IMPLEMENTATION=cmpctmalloc |
| 52 | elif [ $DO_MINIHEAP == 1 ]; then |
| 53 | MAKE_VARS=LK_HEAP_IMPLEMENTATION=miniheap |
| 54 | fi |
| 55 | |
| 56 | make $MAKE_VARS $PROJECT -j4 && |
| 57 | echo $QEMUM4 $ARGS $@ && |
| 58 | $QEMUM4 $ARGS $@ |