OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [sw/] [image_gen/] [uart_upload.sh] - Blame information for rev 62

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 34 zero_gravi
#!/bin/sh
2
 
3
set -e
4
 
5
# Simple script to upload executable to bootloader
6
 
7
if [ $# -ne 2 ]
8
then
9
  echo "Upload image via serial port (UART) to the NEORV32 bootloader."
10
  echo "Reset processor before starting the upload."
11 62 zero_gravi
  echo "Usage:   [sudo] sh uart_upload.sh <port> <NEORV32 executable>"
12 34 zero_gravi
  echo "Example: sh uart_upload.sh /dev/ttyS6 neorv32_exe.bin"
13
  exit
14
fi
15
 
16
# configure serial port
17
stty -F "$1" 19200 -hup raw -echo -echoe -echok -echoctl -echoke -crtscts cs8 -cstopb noflsh clocal cread
18
 
19
# trigger fast upload mode and get response
20
exec 3<$1                              # redirect serial output to fd 3
21
  cat <&3 > uart_upload.response.dat & # redirect serial output to file
22
  PID=$!                               # save pid to kill cat
23 62 zero_gravi
    printf "u" > $1                    # send upload command to serial port
24 34 zero_gravi
    sleep 0.5s                         # wait for bootloader response
25
  kill $PID                            # kill cat process
26
 
27
exec 3<&- # free fd 3
28
 
29
# check response
30
if ! grep -Fq "Awaiting neorv32_exe.bin" uart_upload.response.dat;
31
then
32
  echo "Bootloader response error."
33
  echo "Reset processor before starting the upload."
34
  rm -f uart_upload.response.dat
35
  exit
36
fi
37
 
38
# send executable and get repsonse
39
echo -n "Uploading... "
40
exec 3<$1                              # redirect serial output to fd 3
41
  cat <&3 > uart_upload.response.dat & # redirect serial output to file
42
  PID=$!                               # save pid to kill cat
43
    cat "$2" > "$1"                    # send executable to serial port
44
    sleep 3s                           # wait for bootloader response
45
  kill $PID                            # kill cat process
46
 
47
exec 3<&- # free fd 3
48
 
49
# check response
50
if ! grep -Fq "OK" uart_upload.response.dat;
51
then
52
  echo "Upload error."
53
  rm -f uart_upload.response.dat
54
  exit
55
fi
56
 
57
rm -f uart_upload.response.dat
58
echo "Done."

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.