blob: c776657a5855b41bd12f5ccc67c6494b472d4794 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001#!/bin/bash
2DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3DEFAULT_TOOLPATH="$DIR/toolpaths.default"
4if [ -e "$DEFAULT_TOOLPATH" ]
5then
6 source $DEFAULT_TOOLPATH
7fi
8
9function 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
18DO_CMPCTMALLOC=0
19DO_MINIHEAP=0
20MEMSIZE=8
21
22while 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
32done
33
34shift $((OPTIND-1))
35
36if [ -z "$QEMUM4" ]; then
37 echo "QEMUM4 is not defined. Set QEMUM4='path/to/qemu-m4' inside scripts/toolpaths.local"
38 exit 1
39fi
40
41PROJECT="qemu-m4-test"
42
43ARGS=" -serial tcp::12345,server,nowait " # Logs
44ARGS+=" -serial tcp::12344,server,nowait " # Debug
45ARGS+=" -serial stdio" # Console
46ARGS+=" -machine pebble-s4-bb -cpu cortex-m4"
47ARGS+=" -pflash build-${PROJECT}/lk.bin "
48ARGS+=" -monitor tcp::12346,server,nowait"
49
50if [ $DO_CMPCTMALLOC == 1 ]; then
51 MAKE_VARS=LK_HEAP_IMPLEMENTATION=cmpctmalloc
52elif [ $DO_MINIHEAP == 1 ]; then
53 MAKE_VARS=LK_HEAP_IMPLEMENTATION=miniheap
54fi
55
56make $MAKE_VARS $PROJECT -j4 &&
57echo $QEMUM4 $ARGS $@ &&
58$QEMUM4 $ARGS $@