Skip to content

Commit

Permalink
FREERTOS_INTRO_QEMU_TERM environment variable given it will auto scre…
Browse files Browse the repository at this point in the history
…en hw
  • Loading branch information
aslansq committed Dec 29, 2024
1 parent 1665b74 commit d05e79a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
1 change: 1 addition & 0 deletions 3_task_scheduling_challenge/demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ static void _taskInput( void * parameter ) {
inledDelay = atoi(buf);
_ledDelay = inledDelay;
demo_hw_term_printf("Led delay updated to(ms): %d", _ledDelay);
demo_hw_term_writeChar('\n');
}
}
}
Expand Down
21 changes: 15 additions & 6 deletions shell/run_qemu.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
#!/bin/bash
# This script is used to run a demo
# Usage: ./run_qemu.sh <demo binary file> <optional: debug>
demo="$1"
# This script is used to run a demoBin
# Usage: ./run_qemu.sh <demoBin binary file> <optional: debug>
demoBin="$1"
debug="$2"

thisPath=$(realpath "$0")
thisDirPath=$(dirname "$thisPath")
source "${thisDirPath}/util.sh"

if [ ! -f "$demo" ]
if [ ! -f "$demoBin" ]
then
echoerr "Demo binary does not exist: $demo"
echoerr "demoBin binary does not exist: $demoBin"
ungracefulExit
fi

buildPath=$(dirname "${demoBin}")
logFile=${buildPath}/log.txt

debugFlags=""

if [ "$debug" == "debug" ]
Expand All @@ -28,5 +31,11 @@ else
ungracefulExit
fi

if [ -z ${FREERTOS_INTRO_QEMU_TERM} ]
then
echo CONNECT below serial port to see simulated hardware:
qemu-system-arm -machine mps2-an385 -cpu cortex-m3 -kernel "$demo" -monitor none -nographic -serial stdio -serial pty $debugFlags
qemu-system-arm -machine mps2-an385 -cpu cortex-m3 -kernel "$demoBin" -monitor none -nographic -serial stdio -serial pty $debugFlags | tee ${logFile}
else
${FREERTOS_INTRO_QEMU_TERM} -- bash -c "${thisDirPath}/screen_hw.sh ${logFile}"
qemu-system-arm -machine mps2-an385 -cpu cortex-m3 -kernel "$demoBin" -monitor none -nographic -serial stdio -serial pty $debugFlags | tee ${logFile}
fi
14 changes: 14 additions & 0 deletions shell/screen_hw.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
logFile=$1
serialPort=""
while [ 1 == 1 ]
do
line=$(cat $logFile | grep 'char device redirected to ')
if [ ! -z "$line" ]
then
serialPort=$(echo $line | awk '{print $5}')
echo Found $serialPort
break
fi
done

screen $serialPort

0 comments on commit d05e79a

Please sign in to comment.