-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkconfig
executable file
·57 lines (53 loc) · 1.69 KB
/
mkconfig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh -eu
# -*- coding: utf-8; mode: sh; tab-width: 3; indent-tabs-mode: nil -*-
#
# Copyright 2022 Raffaello D. Di Napoli
#
# This file is part of RAWR.
#
# RAWR is free software: you can redistribute it and/or modify it under the terms of version 2.1 of the GNU
# Lesser General Public License as published by the Free Software Foundation.
#
# RAWR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
# for more details.
#-------------------------------------------------------------------------------------------------------------
begin_shade() {
printf '\033[1;30m' >&2
}
end_shade() {
printf '\033[0m' >&2
}
printf 'Enter %s [%s]: ' 'MCU model' 'detect with avrdude' >&2
read MCU
if [ -z "${MCU}" ]; then
begin_shade
# Note that we don’t actually use the signature bytes read, because we instead extract avrdude’s guess at
# which MCU it connected to.
MCU=$(
${AVRDUDE} -p m328 -U signature:r:-:h 2>&1 |
tee /dev/stderr |
sed -ne 's/^avrdude: Device signature = 0x[^ ]\+ (probably \([^)]\+\))$/\1/p' |
sed -ne '
s/^c/AT90CAN/p; t
s/^m/ATmega/p; t
s/^t/ATtiny/p; t
s/^usb/AT90USB/p; t
s/^x/ATxmega/p; t
s/^[0-9]/AT90S&/p; t
'
)
end_shade
if [ -z "${MCU}" ]; then
echo 'Unable to detect MCU; aborting' >&2
exit 1
fi
echo "Detected MCU: ${MCU}" >&2
fi
echo "MCU?=${MCU}"
printf 'Enter %s [%s]: ' 'in-circuit CPU frequency (F_CPU) in Hz' '1000000' >&2
read F_CPU
if [ -z "${F_CPU}" ]; then
F_CPU=1000000
fi
echo "F_CPU?=${F_CPU}"