-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathavr_code_create.bat
More file actions
76 lines (63 loc) · 1.59 KB
/
avr_code_create.bat
File metadata and controls
76 lines (63 loc) · 1.59 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
@echo off
set mypath=%~dp0
set mypath=%mypath:~0,-1%
: dirloop
set /p directory= Enter file location (folder):
cd %directory%
if errorlevel 1 (
echo Invalid Directory...
goto dirloop
)
goto dirend
: dirend
: nameloop
set /p name= Enter file name:
if not exist %name%.c (
echo File Not Found...
goto nameloop
)
goto namend
: namend
: chiploop
set /p chip= Enter Avr model:
avr-gcc -g -Os -mmcu=%chip% -c %name%.c
if errorlevel 1 goto chiperror
goto chipend
: chiperror
echo Invalid Chip...
cd %mypath%
set /p answer= Would you like to see the supported chip codes? {y/n}:
if "%answer%" == "y" type chips.txt
cd %directory%
goto chiploop
: chipend
avr-gcc -g -mmcu=%chip% -o %name%.elf %name%.o
avr-objcopy -j .text -j .data -O ihex %name%.elf %name%.hex
set /p answer= Would you like to upload the file {y/n}?
if "%answer%" == "y" goto upload
goto end
: upload
set /p model= Enter code for chip {if you don't know press enter}:
if "%model%" == "" goto modelerr
avrdude -p %model% -P com1 -c avrisp -b 19200 -U flash:w:%name%.hex 2>&1 >nul | findstr /c:"Valid parts are:" 1>nul
if errorlevel 1 goto port
: modelerr
echo Invalid code...
set /p answer= Would you like to see the supported chip codes {y/n}?
if not "%answer%" == "y" goto upload
cd %mypath%
type codes.txt
cd %directory%
goto upload
:port
set /p port= Enter com port:
if "%port%" == "" goto porterr
avrdude -p %model% -P com%port% -c avrisp -b 19200 -U flash:w:%name%.hex 2>error.txt
set /p error= <error.txt
if not "%error%" == "" (
: porterr
echo Invalid Port
goto port
)
: end
pause