mirror of
https://github.com/mariusgreuel/avrdude.git
synced 2026-06-18 05:33:36 +00:00
Compare commits
279 Commits
v7.0-rc0
...
v7.0-windo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15fe12b1a9 | ||
|
|
b8420ee52d | ||
|
|
6ebbd4e162 | ||
|
|
4b2bf38849 | ||
|
|
9d6420e723 | ||
|
|
bc9b67a153 | ||
|
|
93b2a56c0e | ||
|
|
a855692d97 | ||
|
|
ec50337434 | ||
|
|
a2e456ca8a | ||
|
|
43ddea9102 | ||
|
|
a4c9fcdcd7 | ||
|
|
28ccd82edc | ||
|
|
ca16fc2ce6 | ||
|
|
d7c59ca2f9 | ||
|
|
4bcd0eaa1d | ||
|
|
08ad5ea445 | ||
|
|
5a3ff78844 | ||
|
|
74a92d7991 | ||
|
|
9d025e6a70 | ||
|
|
b99a145b9f | ||
|
|
60960ba590 | ||
|
|
99a75701b1 | ||
|
|
abe7180bb8 | ||
|
|
157b6a63c1 | ||
|
|
1363c7fe76 | ||
|
|
7e26a15375 | ||
|
|
e84210c6b0 | ||
|
|
08bd5fa938 | ||
|
|
17b67da03e | ||
|
|
795dd91575 | ||
|
|
8f100f5df3 | ||
|
|
f0f9059ade | ||
|
|
e069871c8e | ||
|
|
0aa43968a0 | ||
|
|
f22bc62b06 | ||
|
|
d09a4e93a2 | ||
|
|
aa7ae7bb87 | ||
|
|
1d0cbc2246 | ||
|
|
79c4137289 | ||
|
|
8697f6def7 | ||
|
|
981a6f1f20 | ||
|
|
c64db5fb76 | ||
|
|
50c373bf71 | ||
|
|
0c722bf288 | ||
|
|
28d1442fc8 | ||
|
|
75e4d06463 | ||
|
|
99f191a0ca | ||
|
|
33bace0cee | ||
|
|
0c912a201f | ||
|
|
31feb9ff75 | ||
|
|
c5a28eedc0 | ||
|
|
29a01c1047 | ||
|
|
426ea1fa78 | ||
|
|
6a5988ad64 | ||
|
|
dcf771424b | ||
|
|
67b56d322b | ||
|
|
27d201acb1 | ||
|
|
ded30f86bc | ||
|
|
9bc4a2463d | ||
|
|
8ad55e07ac | ||
|
|
d89817ddb9 | ||
|
|
fc6a71a142 | ||
|
|
da1271642e | ||
|
|
0e441013e9 | ||
|
|
c5f7939fca | ||
|
|
297d81818a | ||
|
|
7391e569b3 | ||
|
|
67ab74cd6a | ||
|
|
631f671fe8 | ||
|
|
248b554e8d | ||
|
|
40e3aa1790 | ||
|
|
dca5fc92bf | ||
|
|
4e05a8fa41 | ||
|
|
1299d6b8bd | ||
|
|
da315d7323 | ||
|
|
416c465ec0 | ||
|
|
41f524c1ba | ||
|
|
5ebb9047be | ||
|
|
fde7881611 | ||
|
|
1c94c95f1c | ||
|
|
e2995857ac | ||
|
|
a4cbd5c6fc | ||
|
|
87b39637ff | ||
|
|
34168759b0 | ||
|
|
c746c9bc9e | ||
|
|
65618ed655 | ||
|
|
00ea962abe | ||
|
|
d62f309a00 | ||
|
|
92a5ae20a6 | ||
|
|
5cbc9c37fc | ||
|
|
0f4b5b223b | ||
|
|
0b82b5c573 | ||
|
|
9355d67e0f | ||
|
|
d9c52249a9 | ||
|
|
c7174d7678 | ||
|
|
df6e2eea12 | ||
|
|
0d58adb10a | ||
|
|
ebb1849724 | ||
|
|
0c8b42524e | ||
|
|
b688b1f601 | ||
|
|
d89f695c31 | ||
|
|
1f2b570216 | ||
|
|
64cc54ac35 | ||
|
|
e2e5e44bab | ||
|
|
07ea8f5e09 | ||
|
|
0269817217 | ||
|
|
fe6290072a | ||
|
|
008f95f6ff | ||
|
|
a73567893b | ||
|
|
fa706f0d01 | ||
|
|
3532c567ac | ||
|
|
14f646822c | ||
|
|
bb73ade70b | ||
|
|
bb99a36a14 | ||
|
|
0d7d034d24 | ||
|
|
c7d1ebcf1f | ||
|
|
b891b7c64b | ||
|
|
a9b756e5c7 | ||
|
|
cf67a76c23 | ||
|
|
0e29b43bd0 | ||
|
|
4b9219edee | ||
|
|
428cd89e8d | ||
|
|
3efd3b2052 | ||
|
|
7c65adba26 | ||
|
|
75ab3c418e | ||
|
|
62f3b84eee | ||
|
|
066f54fbfa | ||
|
|
de19f203e0 | ||
|
|
d054c68b19 | ||
|
|
5c90fbbaae | ||
|
|
c2fe68ef7d | ||
|
|
c345985928 | ||
|
|
c1ec836fbd | ||
|
|
ba01fd7e30 | ||
|
|
59ecd4cc65 | ||
|
|
e31be88ce0 | ||
|
|
6e7f38e81f | ||
|
|
10e05eed21 | ||
|
|
551046052e | ||
|
|
2a92b8cce4 | ||
|
|
c007dc7d24 | ||
|
|
2589b17640 | ||
|
|
19e2cae053 | ||
|
|
932f68f24c | ||
|
|
b1d34a510c | ||
|
|
f2bdcbe977 | ||
|
|
7b79b72794 | ||
|
|
76a17be4d0 | ||
|
|
80f1d96e07 | ||
|
|
09fe08e51c | ||
|
|
f2c73c2bb8 | ||
|
|
b581d14823 | ||
|
|
354a1c4f1f | ||
|
|
23a09a6197 | ||
|
|
3fc39c47ad | ||
|
|
d6ccf7a3ff | ||
|
|
452f673f38 | ||
|
|
38a3af37e2 | ||
|
|
d134dc8fff | ||
|
|
ba314f23e9 | ||
|
|
a43f220ef9 | ||
|
|
1c0b70da89 | ||
|
|
b6a6c681df | ||
|
|
3eda1d15f9 | ||
|
|
c6438532f0 | ||
|
|
6fd68ed7fe | ||
|
|
36de84ab48 | ||
|
|
8c6c6a14ec | ||
|
|
7ed3632902 | ||
|
|
e28e28d7c3 | ||
|
|
a3868a8260 | ||
|
|
e0bc6a8bd6 | ||
|
|
69177dfe3f | ||
|
|
b84e6862a7 | ||
|
|
7144a9f2ae | ||
|
|
28be45d8b6 | ||
|
|
4ff72ac462 | ||
|
|
4ea4ff7fba | ||
|
|
7e7c4e630e | ||
|
|
39deb3a600 | ||
|
|
dd8c3ff830 | ||
|
|
ad6eff0f76 | ||
|
|
286c0f5e2a | ||
|
|
f6bbaadfa6 | ||
|
|
acee6afa4e | ||
|
|
42a154dddf | ||
|
|
de3d7c1659 | ||
|
|
a8f7e96222 | ||
|
|
37b0659951 | ||
|
|
4538d91091 | ||
|
|
6d762a835b | ||
|
|
cce7a934d6 | ||
|
|
490558049e | ||
|
|
512cce405c | ||
|
|
e5ac9e943c | ||
|
|
0b1db09daf | ||
|
|
1b8b1d69e7 | ||
|
|
d401b2224e | ||
|
|
950583323f | ||
|
|
0682af212c | ||
|
|
b1cbbfc9f0 | ||
|
|
dbac0ecf8c | ||
|
|
325604f970 | ||
|
|
8be18c788e | ||
|
|
090920298d | ||
|
|
fa58267643 | ||
|
|
44b0c0715f | ||
|
|
7b9f258806 | ||
|
|
0e451f73cf | ||
|
|
b3c76f3e54 | ||
|
|
54d143d4a5 | ||
|
|
4453d54296 | ||
|
|
9c08c0c164 | ||
|
|
628c48aff6 | ||
|
|
8e47768600 | ||
|
|
e5edecf95e | ||
|
|
b99687f33c | ||
|
|
153031d6d6 | ||
|
|
c31578cbbd | ||
|
|
310fe49b73 | ||
|
|
5c264992fc | ||
|
|
77a5703c5c | ||
|
|
822578cffd | ||
|
|
d1634e4d96 | ||
|
|
99d8fa5d88 | ||
|
|
cc77f89953 | ||
|
|
7064447378 | ||
|
|
77ed8b98c5 | ||
|
|
32232faa2b | ||
|
|
ab57f38387 | ||
|
|
90d0fa7346 | ||
|
|
956a274abd | ||
|
|
3fbac230b3 | ||
|
|
0ba4d2eaee | ||
|
|
1faa02b9cb | ||
|
|
dc2f5b25a2 | ||
|
|
65d5cfadc1 | ||
|
|
1049777283 | ||
|
|
4e1bbf07ac | ||
|
|
e72fa01073 | ||
|
|
60bda0bcc4 | ||
|
|
2d833e7ceb | ||
|
|
8374564665 | ||
|
|
b33709bc04 | ||
|
|
c7f7fcda8e | ||
|
|
6870417860 | ||
|
|
829425f246 | ||
|
|
22e6c4b325 | ||
|
|
a3bf6cc4c5 | ||
|
|
b1b80bfa4a | ||
|
|
0a4193f742 | ||
|
|
48bcc269e2 | ||
|
|
cf35b7fe32 | ||
|
|
fa8a31740f | ||
|
|
92a3eb1080 | ||
|
|
ea29434568 | ||
|
|
5746bb2670 | ||
|
|
f043e1b484 | ||
|
|
2fd967866c | ||
|
|
1a85e01b63 | ||
|
|
f67cb3c224 | ||
|
|
1297098eae | ||
|
|
40f0fae5a4 | ||
|
|
cffa6c7ca0 | ||
|
|
112b6edd1c | ||
|
|
8f16c2a1e4 | ||
|
|
a182ef5a26 | ||
|
|
a447673b07 | ||
|
|
a8de8b8b8f | ||
|
|
4a26aac5c8 | ||
|
|
b70fe0e956 | ||
|
|
e3338c428f | ||
|
|
f1dbb2aae8 | ||
|
|
b13c61893b | ||
|
|
d2ae6a824f | ||
|
|
21d7fc58b6 | ||
|
|
1631fc4dd8 | ||
|
|
a61707bb65 |
@@ -4,14 +4,14 @@ root = true
|
|||||||
|
|
||||||
[{CMakeLists.txt,*.cmake}]
|
[{CMakeLists.txt,*.cmake}]
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
tab_width = 8
|
tab_width = 4
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
indent_style = space
|
indent_style = space
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
[{bootstrap,configure.ac,avrdude.spec.in,Makefile.am}]
|
[{bootstrap,configure.ac,avrdude.spec.in,Makefile.am}]
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
tab_width = 8
|
tab_width = 4
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ indent_size = 4
|
|||||||
indent_style = space
|
indent_style = space
|
||||||
|
|
||||||
[*.{c,h,cpp,y}]
|
[*.{c,h,cpp,y}]
|
||||||
tab_width = 8
|
tab_width = 4
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
indent_style = space
|
indent_style = space
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
|
|||||||
102
.github/workflows/build.yml
vendored
102
.github/workflows/build.yml
vendored
@@ -20,7 +20,11 @@ name: Build
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
|
branches-ignore:
|
||||||
|
- 'onlinedocs'
|
||||||
pull_request:
|
pull_request:
|
||||||
|
branches-ignore:
|
||||||
|
- 'onlinedocs'
|
||||||
workflow_call:
|
workflow_call:
|
||||||
|
|
||||||
env:
|
env:
|
||||||
@@ -29,9 +33,6 @@ env:
|
|||||||
jobs:
|
jobs:
|
||||||
linux-x86_64:
|
linux-x86_64:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: ./src
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Install prerequisites
|
- name: Install prerequisites
|
||||||
@@ -46,31 +47,36 @@ jobs:
|
|||||||
libusb-1.0-0-dev
|
libusb-1.0-0-dev
|
||||||
libhidapi-dev
|
libhidapi-dev
|
||||||
libftdi1-dev
|
libftdi1-dev
|
||||||
libreadline-dev
|
|
||||||
- name: Configure
|
- name: Configure
|
||||||
run: >-
|
run: >-
|
||||||
cmake
|
cmake
|
||||||
-D DEBUG_CMAKE=1
|
-D DEBUG_CMAKE=1
|
||||||
|
-D HAVE_LINUXGPIO=1
|
||||||
|
-D HAVE_LINUXSPI=1
|
||||||
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
-B ../build
|
-B build
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ../build
|
run: cmake --build build
|
||||||
- name: Archive build artifacts
|
- name: Archive build artifacts
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: linux-x86_64
|
name: build-linux-x86_64
|
||||||
path: |
|
path: |
|
||||||
build/
|
build/
|
||||||
!**/*.d
|
!**/*.d
|
||||||
!**/*.o
|
!**/*.o
|
||||||
|
- name: Archive executables
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: avrdude-linux-x86_64
|
||||||
|
path: |
|
||||||
|
build/src/avrdude
|
||||||
|
build/src/avrdude.conf
|
||||||
|
|
||||||
linux:
|
linux:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: debian:11
|
container: debian:11
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: ./src
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
@@ -96,11 +102,12 @@ jobs:
|
|||||||
libusb-1.0-0-dev:${{matrix.arch}}
|
libusb-1.0-0-dev:${{matrix.arch}}
|
||||||
libhidapi-dev:${{matrix.arch}}
|
libhidapi-dev:${{matrix.arch}}
|
||||||
libftdi1-dev:${{matrix.arch}}
|
libftdi1-dev:${{matrix.arch}}
|
||||||
libreadline-dev:${{matrix.arch}}
|
|
||||||
- name: Configure
|
- name: Configure
|
||||||
run: >-
|
run: >-
|
||||||
cmake
|
cmake
|
||||||
-D DEBUG_CMAKE=1
|
-D DEBUG_CMAKE=1
|
||||||
|
-D HAVE_LINUXGPIO=1
|
||||||
|
-D HAVE_LINUXSPI=1
|
||||||
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
-D CMAKE_SYSTEM_NAME=Linux
|
-D CMAKE_SYSTEM_NAME=Linux
|
||||||
-D CMAKE_SYSTEM_PROCESSOR=${{matrix.processor}}
|
-D CMAKE_SYSTEM_PROCESSOR=${{matrix.processor}}
|
||||||
@@ -108,24 +115,28 @@ jobs:
|
|||||||
-D CMAKE_FIND_ROOT_PATH=/usr/${{matrix.prefix}}
|
-D CMAKE_FIND_ROOT_PATH=/usr/${{matrix.prefix}}
|
||||||
-D CMAKE_INCLUDE_PATH=/usr/include/${{matrix.inc-lib}}
|
-D CMAKE_INCLUDE_PATH=/usr/include/${{matrix.inc-lib}}
|
||||||
-D CMAKE_LIBRARY_PATH=/usr/lib/${{matrix.inc-lib}}
|
-D CMAKE_LIBRARY_PATH=/usr/lib/${{matrix.inc-lib}}
|
||||||
-B ../build
|
-B build
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ../build
|
run: cmake --build build
|
||||||
- name: Archive build artifacts
|
- name: Archive build artifacts
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: linux-${{matrix.processor}}
|
name: build-linux-${{matrix.processor}}
|
||||||
path: |
|
path: |
|
||||||
build/
|
build/
|
||||||
!**/*.d
|
!**/*.d
|
||||||
!**/*.o
|
!**/*.o
|
||||||
|
- name: Archive executables
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: avrdude-linux-${{matrix.processor}}
|
||||||
|
path: |
|
||||||
|
build/src/avrdude
|
||||||
|
build/src/avrdude.conf
|
||||||
|
|
||||||
macos-x86_64:
|
macos-x86_64:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: ./src
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Install prerequisites
|
- name: Install prerequisites
|
||||||
@@ -145,24 +156,28 @@ jobs:
|
|||||||
-D CMAKE_EXE_LINKER_FLAGS=-L/usr/local/Cellar
|
-D CMAKE_EXE_LINKER_FLAGS=-L/usr/local/Cellar
|
||||||
-D DEBUG_CMAKE=1
|
-D DEBUG_CMAKE=1
|
||||||
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
-B ../build
|
-B build
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ../build
|
run: cmake --build build
|
||||||
- name: Archive build artifacts
|
- name: Archive build artifacts
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: macos-x86_64
|
name: build-macos-x86_64
|
||||||
path: |
|
path: |
|
||||||
build/
|
build/
|
||||||
!**/*.d
|
!**/*.d
|
||||||
!**/*.o
|
!**/*.o
|
||||||
|
- name: Archive executables
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: avrdude-macos-x86_64
|
||||||
|
path: |
|
||||||
|
build/src/avrdude
|
||||||
|
build/src/avrdude.conf
|
||||||
|
|
||||||
msvc:
|
msvc:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
working-directory: ./src
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
@@ -172,7 +187,12 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Install prerequisites
|
- name: Install prerequisites
|
||||||
run: choco install winflexbison3
|
# As Chocolatey is notoriously unreliable, install winflexbison3 directly from GitHub.
|
||||||
|
# run: choco install winflexbison3
|
||||||
|
run: |
|
||||||
|
curl https://github.com/lexxmark/winflexbison/releases/download/v2.5.24/win_flex_bison-2.5.24.zip --location --output winflexbison.zip
|
||||||
|
unzip winflexbison.zip -d ${{github.workspace}}\winflexbison
|
||||||
|
echo "${{github.workspace}}\winflexbison" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||||
- name: Configure
|
- name: Configure
|
||||||
run: >-
|
run: >-
|
||||||
cmake
|
cmake
|
||||||
@@ -184,25 +204,36 @@ jobs:
|
|||||||
-D CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO="/DEBUG /INCREMENTAL:NO /LTCG /OPT:REF /OPT:ICF"
|
-D CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO="/DEBUG /INCREMENTAL:NO /LTCG /OPT:REF /OPT:ICF"
|
||||||
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
-D USE_EXTERNAL=1
|
-D USE_EXTERNAL=1
|
||||||
-B ../build
|
-B build
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ../build --config ${{env.BUILD_TYPE}}
|
run: cmake --build build --config ${{env.BUILD_TYPE}}
|
||||||
- name: Archive build artifacts
|
- name: Archive build artifacts
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: msvc-${{matrix.arch}}
|
name: build-msvc-${{matrix.arch}}
|
||||||
path: |
|
path: |
|
||||||
build/
|
build/
|
||||||
!**/_deps/
|
!**/_deps/
|
||||||
!**/*.obj
|
!**/*.obj
|
||||||
|
- name: Move executables
|
||||||
|
run: |
|
||||||
|
mv build/src/RelWithDebInfo/avrdude.exe build/src
|
||||||
|
mv build/src/RelWithDebInfo/avrdude.pdb build/src
|
||||||
|
- name: Archive executables
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: avrdude-msvc-${{matrix.arch}}
|
||||||
|
path: |
|
||||||
|
build/src/avrdude.exe
|
||||||
|
build/src/avrdude.pdb
|
||||||
|
build/src/avrdude.conf
|
||||||
|
|
||||||
mingw:
|
mingw:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
defaults:
|
defaults:
|
||||||
run:
|
run:
|
||||||
shell: msys2 {0}
|
shell: msys2 {0}
|
||||||
working-directory: ./src
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
include:
|
||||||
@@ -229,13 +260,20 @@ jobs:
|
|||||||
-G"MSYS Makefiles"
|
-G"MSYS Makefiles"
|
||||||
-D DEBUG_CMAKE=1
|
-D DEBUG_CMAKE=1
|
||||||
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
||||||
-B ../build
|
-B build
|
||||||
- name: Build
|
- name: Build
|
||||||
run: cmake --build ../build
|
run: cmake --build build
|
||||||
- name: Archive build artifacts
|
- name: Archive build artifacts
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: mingw-${{matrix.env}}
|
name: build-mingw-${{matrix.env}}
|
||||||
path: |
|
path: |
|
||||||
${{github.workspace}}/build/*
|
build/
|
||||||
|
- name: Archive executables
|
||||||
|
uses: actions/upload-artifact@v2
|
||||||
|
with:
|
||||||
|
name: avrdude-mingw-${{matrix.env}}
|
||||||
|
path: |
|
||||||
|
build/src/avrdude.exe
|
||||||
|
build/src/avrdude.conf
|
||||||
|
|||||||
51
.github/workflows/build_extra.yml
vendored
51
.github/workflows/build_extra.yml
vendored
@@ -1,51 +0,0 @@
|
|||||||
#
|
|
||||||
# build_extra.yml - GitHub build action for AVRDUDE
|
|
||||||
# Copyright (C) 2021 Marius Greuel
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program 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 General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
#
|
|
||||||
|
|
||||||
name: Build Extra
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
pull_request:
|
|
||||||
workflow_call:
|
|
||||||
|
|
||||||
env:
|
|
||||||
BUILD_TYPE: RelWithDebInfo
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
freebsd-x86_64:
|
|
||||||
runs-on: macos-10.15
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Build
|
|
||||||
id: build
|
|
||||||
uses: vmactions/freebsd-vm@v0.1.5
|
|
||||||
with:
|
|
||||||
prepare: pkg install -y git cmake flex bison libftdi1 hidapi
|
|
||||||
run: |
|
|
||||||
cd src
|
|
||||||
cmake -D DEBUG_CMAKE=1 -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -D CMAKE_C_FLAGS=-I/usr/local/include -D CMAKE_EXE_LINKER_FLAGS=-L/usr/local/lib -B ../build
|
|
||||||
cmake --build ../build
|
|
||||||
- name: Archive build artifacts
|
|
||||||
if: always()
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: freebsd-x86_64
|
|
||||||
path: |
|
|
||||||
build/
|
|
||||||
!**/*.d
|
|
||||||
!**/*.o
|
|
||||||
8
.github/workflows/deploy.yml
vendored
8
.github/workflows/deploy.yml
vendored
@@ -41,7 +41,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
tag_name: ${{github.ref}}
|
tag_name: ${{github.ref}}
|
||||||
release_name: AVRDUDE ${{github.ref}}
|
release_name: AVRDUDE ${{github.ref}}
|
||||||
body: "**[Release Notes:](https://github.com/avrdudes/avrdude/blob/main/NEWS)**"
|
body: "See **[Release Notes](https://github.com/avrdudes/avrdude/blob/main/NEWS)** for changes"
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
|
|
||||||
@@ -58,13 +58,13 @@ jobs:
|
|||||||
- name: Download artifact
|
- name: Download artifact
|
||||||
uses: actions/download-artifact@v2
|
uses: actions/download-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: msvc-${{matrix.arch}}
|
name: avrdude-msvc-${{matrix.arch}}
|
||||||
|
|
||||||
- name: Create release asset
|
- name: Create release asset
|
||||||
run: >-
|
run: >-
|
||||||
zip -j asset.zip
|
zip -j asset.zip
|
||||||
RelWithDebInfo/avrdude.exe
|
avrdude.exe
|
||||||
RelWithDebInfo/avrdude.pdb
|
avrdude.pdb
|
||||||
avrdude.conf
|
avrdude.conf
|
||||||
|
|
||||||
- name: Upload release asset
|
- name: Upload release asset
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -14,6 +14,7 @@ INSTALL
|
|||||||
Makefile.in
|
Makefile.in
|
||||||
Makefile
|
Makefile
|
||||||
ac_cfg.h.in
|
ac_cfg.h.in
|
||||||
|
ac_cfg.h.in~
|
||||||
aclocal.m4
|
aclocal.m4
|
||||||
autom4te.cache
|
autom4te.cache
|
||||||
configure
|
configure
|
||||||
@@ -38,6 +39,7 @@ libtool
|
|||||||
ltmain.sh
|
ltmain.sh
|
||||||
ylwrap
|
ylwrap
|
||||||
tags
|
tags
|
||||||
|
cscope.out
|
||||||
|
|
||||||
*.o
|
*.o
|
||||||
*.lo
|
*.lo
|
||||||
|
|||||||
3
AUTHORS
3
AUTHORS
@@ -26,6 +26,9 @@ Contributors:
|
|||||||
Jan Egil Ruud <janegil.ruud@microchip.com>
|
Jan Egil Ruud <janegil.ruud@microchip.com>
|
||||||
David Mosberger <davidm@egauge.net>
|
David Mosberger <davidm@egauge.net>
|
||||||
David Sainty
|
David Sainty
|
||||||
|
Marius Greuel <greuelm@mgtek.com>
|
||||||
|
Dawid Buchwald <dawid.buchwald@hotmail.com>
|
||||||
|
Hans Eirik Bull
|
||||||
|
|
||||||
Contributors to code no longer present:
|
Contributors to code no longer present:
|
||||||
|
|
||||||
|
|||||||
397
CMakeLists.txt
Normal file
397
CMakeLists.txt
Normal file
@@ -0,0 +1,397 @@
|
|||||||
|
#
|
||||||
|
# CMakeLists.txt - CMake project for AVRDUDE
|
||||||
|
# Copyright (C) 2021 Marius Greuel
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program 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 General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
# Typical usage:
|
||||||
|
# cmake -B build
|
||||||
|
# cmake --build build
|
||||||
|
|
||||||
|
cmake_minimum_required(VERSION 3.12)
|
||||||
|
project(avrdude VERSION 7.0)
|
||||||
|
|
||||||
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
set(CMAKE_C_STANDARD_REQUIRED True)
|
||||||
|
|
||||||
|
option(BUILD_DOC "Enable building documents" OFF)
|
||||||
|
option(HAVE_LINUXGPIO "Enable Linux sysfs GPIO support" OFF)
|
||||||
|
option(HAVE_LINUXSPI "Enable Linux SPI support" OFF)
|
||||||
|
option(HAVE_PARPORT "Enable parallel port support" OFF)
|
||||||
|
option(USE_EXTERNAL "Use external libraries from AVRDUDE GitHub repositories" OFF)
|
||||||
|
option(USE_LIBUSBWIN32 "Prefer libusb-win32 over libusb" OFF)
|
||||||
|
option(DEBUG_CMAKE "Enable debugging output for this CMake project" OFF)
|
||||||
|
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
|
||||||
|
|
||||||
|
include(CheckIncludeFile)
|
||||||
|
include(CheckSymbolExists)
|
||||||
|
include(FetchContent)
|
||||||
|
include(FindPackageMessage)
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
set(CONFIG_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}")
|
||||||
|
set(AVRDUDE_FULL_VERSION ${CMAKE_PROJECT_VERSION})
|
||||||
|
|
||||||
|
# =====================================
|
||||||
|
# Get Git commit info
|
||||||
|
# =====================================
|
||||||
|
|
||||||
|
# GIT_COMMIT_HASH -> hash of latest commit, e.g. b8b859f5
|
||||||
|
# GIT_COMMIT_DATE -> date of latest commit, e.g. 20201231
|
||||||
|
# GIT_COMMIT_YEAR -> year of latest commit, e.g. 2020
|
||||||
|
|
||||||
|
find_package(Git)
|
||||||
|
if(Git_FOUND)
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%h
|
||||||
|
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||||
|
OUTPUT_VARIABLE GIT_COMMIT_HASH
|
||||||
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%ad --date=format:%Y%m%d
|
||||||
|
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||||
|
OUTPUT_VARIABLE GIT_COMMIT_DATE
|
||||||
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%ad --date=format:%Y
|
||||||
|
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||||
|
OUTPUT_VARIABLE GIT_COMMIT_YEAR
|
||||||
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${GIT_EXECUTABLE}" log -1 --tags --format=%h
|
||||||
|
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||||
|
OUTPUT_VARIABLE GIT_TAG_HASH
|
||||||
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
|
||||||
|
# If the commit is not tagged, include the date and commit hash in the full version string.
|
||||||
|
if(NOT GIT_COMMIT_HASH STREQUAL GIT_TAG_HASH)
|
||||||
|
set(AVRDUDE_FULL_VERSION "${CMAKE_PROJECT_VERSION}-${GIT_COMMIT_DATE} (${GIT_COMMIT_HASH})")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(FLEX)
|
||||||
|
if(NOT FLEX_FOUND)
|
||||||
|
message(SEND_ERROR "This CMake project requires 'flex', which is not installed on your system." )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_package(BISON QUIET)
|
||||||
|
if(BISON_FOUND)
|
||||||
|
find_package_message(BISON "Found BISON: ${BISON_EXECUTABLE} (found version \"${BISON_VERSION}\")" "[${BISON_EXECUTABLE}][${BISON_VERSION}]")
|
||||||
|
else()
|
||||||
|
find_program(YACC_EXECUTABLE NAMES yacc byacc DOC "path to the yacc executable")
|
||||||
|
mark_as_advanced(YACC_EXECUTABLE)
|
||||||
|
if(YACC_EXECUTABLE)
|
||||||
|
find_package_message(YACC "Found YACC: ${YACC_EXECUTABLE}" "[${YACC_EXECUTABLE}]")
|
||||||
|
else()
|
||||||
|
message(SEND_ERROR "This CMake project requires 'bison', 'yacc', or 'byacc', which is not installed on your system." )
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# =====================================
|
||||||
|
# Detect installed libraries
|
||||||
|
# =====================================
|
||||||
|
|
||||||
|
# Prefer static libraries over DLLs on Windows
|
||||||
|
if(WIN32)
|
||||||
|
set(PREFERRED_LIBELF libelf.a elf)
|
||||||
|
set(PREFERRED_LIBUSB libusb.a usb)
|
||||||
|
set(PREFERRED_LIBUSB_1_0 libusb-1.0.a usb-1.0)
|
||||||
|
set(PREFERRED_LIBHIDAPI libhidapi.a libhidapi-libusb.a libhidapi-hidraw.a hidapi hidapi-libusb hidapi-hidraw)
|
||||||
|
set(PREFERRED_LIBFTDI libftdi.a ftdi)
|
||||||
|
set(PREFERRED_LIBFTDI1 libftdi1.a ftdi1)
|
||||||
|
else()
|
||||||
|
set(PREFERRED_LIBELF elf)
|
||||||
|
set(PREFERRED_LIBUSB usb)
|
||||||
|
set(PREFERRED_LIBUSB_1_0 usb-1.0)
|
||||||
|
set(PREFERRED_LIBHIDAPI hidapi hidapi-libusb hidapi-hidraw)
|
||||||
|
set(PREFERRED_LIBFTDI ftdi)
|
||||||
|
set(PREFERRED_LIBFTDI1 ftdi1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# -------------------------------------
|
||||||
|
# Find libelf
|
||||||
|
|
||||||
|
find_library(HAVE_LIBELF NAMES ${PREFERRED_LIBELF})
|
||||||
|
if(HAVE_LIBELF)
|
||||||
|
set(LIB_LIBELF ${HAVE_LIBELF})
|
||||||
|
check_include_file(libelf.h HAVE_LIBELF_H)
|
||||||
|
check_include_file(libelf/libelf.h HAVE_LIBELF_LIBELF_H)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# -------------------------------------
|
||||||
|
# Find libusb
|
||||||
|
|
||||||
|
find_library(HAVE_LIBUSB NAMES ${PREFERRED_LIBUSB})
|
||||||
|
if(HAVE_LIBUSB)
|
||||||
|
set(LIB_LIBUSB ${HAVE_LIBUSB})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_library(HAVE_LIBUSB_1_0 NAMES ${PREFERRED_LIBUSB_1_0})
|
||||||
|
if(HAVE_LIBUSB_1_0)
|
||||||
|
set(LIB_LIBUSB_1_0 ${HAVE_LIBUSB_1_0})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# FreeBSD's library 'libusb' supports both the libusb-0.1 and libusb-1.0 API.
|
||||||
|
if (HAVE_LIBUSB AND CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
||||||
|
set(HAVE_LIBUSB_1_0 ${HAVE_LIBUSB})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_library(HAVE_LIBUSB_WIN32 NAMES libusb0.a usb0)
|
||||||
|
|
||||||
|
if(HAVE_LIBUSB OR HAVE_LIBUSB_1_0 OR HAVE_LIBUSB_WIN32)
|
||||||
|
check_include_file(usb.h HAVE_USB_H)
|
||||||
|
check_include_file(lusb0_usb.h HAVE_LUSB0_USB_H)
|
||||||
|
check_include_file(libusb.h HAVE_LIBUSB_H)
|
||||||
|
check_include_file(libusb-1.0/libusb.h HAVE_LIBUSB_1_0_LIBUSB_H)
|
||||||
|
|
||||||
|
if((USE_LIBUSBWIN32 OR NOT HAVE_LIBUSB) AND HAVE_LIBUSB_WIN32)
|
||||||
|
set(HAVE_LIBUSB ${HAVE_LIBUSB_WIN32})
|
||||||
|
set(LIB_LIBUSB ${HAVE_LIBUSB_WIN32})
|
||||||
|
unset(HAVE_USB_H CACHE)
|
||||||
|
elseif(NOT HAVE_USB_H)
|
||||||
|
find_path(LIBUSB_COMPAT_DIR libusb-compat/usb.h)
|
||||||
|
if(LIBUSB_COMPAT_DIR)
|
||||||
|
set(LIBUSB_COMPAT_DIR ${LIBUSB_COMPAT_DIR}/libusb-compat)
|
||||||
|
set(HAVE_USB_H 1)
|
||||||
|
else()
|
||||||
|
unset(LIBUSB_COMPAT_DIR CACHE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# -------------------------------------
|
||||||
|
# Find libhidapi
|
||||||
|
|
||||||
|
find_library(HAVE_LIBHID NAMES hid)
|
||||||
|
if(HAVE_LIBHID)
|
||||||
|
set(LIB_LIBHID ${HAVE_LIBHID})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_library(HAVE_LIBHIDAPI NAMES ${PREFERRED_LIBHIDAPI})
|
||||||
|
if(HAVE_LIBHIDAPI)
|
||||||
|
set(LIB_LIBHIDAPI ${HAVE_LIBHIDAPI})
|
||||||
|
check_include_file(hidapi/hidapi.h HAVE_HIDAPI_HIDAPI_H)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# -------------------------------------
|
||||||
|
# Find libftdi
|
||||||
|
|
||||||
|
find_library(HAVE_LIBFTDI NAMES ${PREFERRED_LIBFTDI})
|
||||||
|
if(HAVE_LIBFTDI)
|
||||||
|
set(LIB_LIBFTDI ${HAVE_LIBFTDI})
|
||||||
|
set(HAVE_LIBFTDI_TYPE_232H 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_library(HAVE_LIBFTDI1 NAMES ${PREFERRED_LIBFTDI1})
|
||||||
|
if(HAVE_LIBFTDI1)
|
||||||
|
set(LIB_LIBFTDI1 ${HAVE_LIBFTDI1})
|
||||||
|
set(HAVE_LIBFTDI_TYPE_232H 1)
|
||||||
|
set(CMAKE_REQUIRED_LIBRARIES ${LIB_LIBFTDI1} ${LIB_LIBUSB} ${LIB_LIBUSB_1_0})
|
||||||
|
check_symbol_exists(ftdi_tcioflush "libftdi1/ftdi.h" HAVE_FTDI_TCIOFLUSH)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# -------------------------------------
|
||||||
|
# Find libreadline
|
||||||
|
|
||||||
|
find_library(HAVE_LIBREADLINE NAMES readline)
|
||||||
|
if(HAVE_LIBREADLINE)
|
||||||
|
set(LIB_LIBREADLINE ${HAVE_LIBREADLINE})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# =====================================
|
||||||
|
# Use external libraries if requested
|
||||||
|
# =====================================
|
||||||
|
|
||||||
|
if(USE_EXTERNAL)
|
||||||
|
FetchContent_Declare(libelf
|
||||||
|
GIT_REPOSITORY https://github.com/avrdudes/libelf.git
|
||||||
|
GIT_TAG e5a39bf19bd6598c42e09172be5a78ceec2a065c
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_Declare(libusb
|
||||||
|
GIT_REPOSITORY https://github.com/avrdudes/libusb.git
|
||||||
|
GIT_TAG 632bc25d04eff563cc00de29435b9a7ed6f4654c
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_Declare(libhidapi
|
||||||
|
GIT_REPOSITORY https://github.com/avrdudes/libhidapi.git
|
||||||
|
GIT_TAG e3700e951f762ef92871ff4fc94586e4d1c042a6
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_Declare(libftdi
|
||||||
|
GIT_REPOSITORY https://github.com/avrdudes/libftdi.git
|
||||||
|
GIT_TAG f3a54da710002a7d25a32a69e667a69ef84cc120
|
||||||
|
)
|
||||||
|
|
||||||
|
message(STATUS "Fetching external libraries, please wait...")
|
||||||
|
FetchContent_MakeAvailable(
|
||||||
|
libelf
|
||||||
|
libusb
|
||||||
|
libhidapi
|
||||||
|
libftdi
|
||||||
|
)
|
||||||
|
|
||||||
|
message(STATUS "Using external library 'libelf'")
|
||||||
|
set(LIB_LIBELF libelf)
|
||||||
|
set(HAVE_LIBELF 1)
|
||||||
|
set(HAVE_LIBELF_H 1)
|
||||||
|
|
||||||
|
message(STATUS "Using external library 'libusb'")
|
||||||
|
set(LIB_LIBUSB libusb)
|
||||||
|
set(HAVE_LIBUSB 1)
|
||||||
|
set(HAVE_LUSB0_USB_H 1)
|
||||||
|
|
||||||
|
message(STATUS "Using external library 'libhidapi'")
|
||||||
|
set(LIB_LIBHIDAPI libhidapi)
|
||||||
|
set(HAVE_LIBHIDAPI 1)
|
||||||
|
set(HAVE_HIDAPI_HIDAPI_H 1)
|
||||||
|
|
||||||
|
message(STATUS "Using external library 'libftdi'")
|
||||||
|
set(LIB_LIBFTDI libftdi)
|
||||||
|
set(HAVE_LIBFTDI 1)
|
||||||
|
set(HAVE_LIBFTDI_TYPE_232H 1)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
# =====================================
|
||||||
|
# Setup default port names
|
||||||
|
# =====================================
|
||||||
|
|
||||||
|
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
|
set(DEFAULT_PAR_PORT "/dev/parport0")
|
||||||
|
set(DEFAULT_SER_PORT "/dev/ttyS0")
|
||||||
|
elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
||||||
|
set(DEFAULT_PAR_PORT "/dev/ppi0")
|
||||||
|
set(DEFAULT_SER_PORT "/dev/cuad0")
|
||||||
|
elseif (CMAKE_SYSTEM_NAME STREQUAL "Solaris")
|
||||||
|
set(DEFAULT_PAR_PORT "/dev/printers/0")
|
||||||
|
set(DEFAULT_SER_PORT "/dev/term/a")
|
||||||
|
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
|
set(DEFAULT_PAR_PORT "lpt1")
|
||||||
|
set(DEFAULT_SER_PORT "com1")
|
||||||
|
else()
|
||||||
|
set(DEFAULT_PAR_PORT "unknown")
|
||||||
|
set(DEFAULT_SER_PORT "unknown")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# =====================================
|
||||||
|
# Configuration
|
||||||
|
# =====================================
|
||||||
|
|
||||||
|
message(STATUS "Configuration summary:")
|
||||||
|
message(STATUS "----------------------")
|
||||||
|
|
||||||
|
if (DEBUG_CMAKE)
|
||||||
|
message(STATUS "CMAKE_HOST_SYSTEM: ${CMAKE_HOST_SYSTEM}")
|
||||||
|
message(STATUS "CMAKE_SYSTEM: ${CMAKE_SYSTEM}")
|
||||||
|
message(STATUS "CMAKE_FIND_ROOT_PATH: ${CMAKE_FIND_ROOT_PATH}")
|
||||||
|
message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
|
||||||
|
message(STATUS "CONFIG_DIR: ${CONFIG_DIR}")
|
||||||
|
message(STATUS "AVRDUDE_FULL_VERSION: ${AVRDUDE_FULL_VERSION}")
|
||||||
|
message(STATUS "USE_EXTERNAL: ${USE_EXTERNAL}")
|
||||||
|
message(STATUS "USE_LIBUSBWIN32: ${USE_LIBUSBWIN32}")
|
||||||
|
message(STATUS "HAVE_LIBELF: ${HAVE_LIBELF}")
|
||||||
|
message(STATUS "HAVE_LIBUSB: ${HAVE_LIBUSB}")
|
||||||
|
message(STATUS "HAVE_LIBUSB_1_0: ${HAVE_LIBUSB_1_0}")
|
||||||
|
message(STATUS "HAVE_LIBUSB_WIN32: ${HAVE_LIBUSB_WIN32}")
|
||||||
|
message(STATUS "HAVE_LIBHID: ${HAVE_LIBHID}")
|
||||||
|
message(STATUS "HAVE_LIBHIDAPI: ${HAVE_LIBHIDAPI}")
|
||||||
|
message(STATUS "HAVE_LIBFTDI: ${HAVE_LIBFTDI}")
|
||||||
|
message(STATUS "HAVE_LIBFTDI1: ${HAVE_LIBFTDI1}")
|
||||||
|
message(STATUS "HAVE_LIBREADLINE: ${HAVE_LIBREADLINE}")
|
||||||
|
message(STATUS "HAVE_LIBELF_H: ${HAVE_LIBELF_H}")
|
||||||
|
message(STATUS "HAVE_LIBELF_LIBELF_H: ${HAVE_LIBELF_LIBELF_H}")
|
||||||
|
message(STATUS "HAVE_USB_H: ${HAVE_USB_H}")
|
||||||
|
message(STATUS "HAVE_LUSB0_USB_H: ${HAVE_LUSB0_USB_H}")
|
||||||
|
message(STATUS "HAVE_LIBUSB_H: ${HAVE_LIBUSB_H}")
|
||||||
|
message(STATUS "HAVE_LIBUSB_1_0_LIBUSB_H: ${HAVE_LIBUSB_1_0_LIBUSB_H}")
|
||||||
|
message(STATUS "HAVE_HIDAPI_HIDAPI_H: ${HAVE_HIDAPI_HIDAPI_H}")
|
||||||
|
message(STATUS "LIBUSB_COMPAT_DIR: ${LIBUSB_COMPAT_DIR}")
|
||||||
|
message(STATUS "----------------------")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(HAVE_LIBELF)
|
||||||
|
message(STATUS "DO HAVE libelf")
|
||||||
|
else()
|
||||||
|
message(STATUS "DON'T HAVE libelf")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(HAVE_LIBUSB)
|
||||||
|
message(STATUS "DO HAVE libusb")
|
||||||
|
else()
|
||||||
|
message(STATUS "DON'T HAVE libusb")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(HAVE_LIBUSB_1_0)
|
||||||
|
message(STATUS "DO HAVE libusb_1_0")
|
||||||
|
else()
|
||||||
|
message(STATUS "DON'T HAVE libusb_1_0")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(HAVE_LIBHIDAPI)
|
||||||
|
message(STATUS "DO HAVE libhidapi")
|
||||||
|
else()
|
||||||
|
message(STATUS "DON'T HAVE libhidapi")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(HAVE_LIBFTDI)
|
||||||
|
if(HAVE_LIBFTDI1)
|
||||||
|
message(STATUS "DO HAVE libftdi (but prefer to use libftdi1)")
|
||||||
|
else()
|
||||||
|
message(STATUS "DO HAVE libftdi")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(STATUS "DON'T HAVE libftdi")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(HAVE_LIBFTDI1)
|
||||||
|
message(STATUS "DO HAVE libftdi1")
|
||||||
|
else()
|
||||||
|
message(STATUS "DON'T HAVE libftdi1")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(BUILD_DOC)
|
||||||
|
message(STATUS "ENABLED doc")
|
||||||
|
else()
|
||||||
|
message(STATUS "DISABLED doc")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(HAVE_PARPORT)
|
||||||
|
message(STATUS "ENABLED parport")
|
||||||
|
else()
|
||||||
|
message(STATUS "DISABLED parport")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(HAVE_LINUXGPIO)
|
||||||
|
message(STATUS "ENABLED linuxgpio")
|
||||||
|
else()
|
||||||
|
message(STATUS "DISABLED linuxgpio")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(HAVE_LINUXSPI)
|
||||||
|
message(STATUS "ENABLED linuxspi")
|
||||||
|
else()
|
||||||
|
message(STATUS "DISABLED linuxspi")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "----------------------")
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "x86-Debug",
|
"name": "x86-Debug",
|
||||||
"generator": "Visual Studio 16 2019",
|
"generator": "Visual Studio 17 2022",
|
||||||
"configurationType": "Debug",
|
"configurationType": "Debug",
|
||||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "x86-Release",
|
"name": "x86-Release",
|
||||||
"generator": "Visual Studio 16 2019",
|
"generator": "Ninja",
|
||||||
"configurationType": "RelWithDebInfo",
|
"configurationType": "RelWithDebInfo",
|
||||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||||
@@ -63,7 +63,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "x64-Debug",
|
"name": "x64-Debug",
|
||||||
"generator": "Visual Studio 16 2019 Win64",
|
"generator": "Visual Studio 17 2022 Win64",
|
||||||
"configurationType": "Debug",
|
"configurationType": "Debug",
|
||||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||||
@@ -86,7 +86,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "x64-Release",
|
"name": "x64-Release",
|
||||||
"generator": "Visual Studio 16 2019 Win64",
|
"generator": "Ninja",
|
||||||
"configurationType": "RelWithDebInfo",
|
"configurationType": "RelWithDebInfo",
|
||||||
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
"buildRoot": "${projectDir}\\out\\build\\${name}",
|
||||||
"installRoot": "${projectDir}\\out\\install\\${name}",
|
"installRoot": "${projectDir}\\out\\install\\${name}",
|
||||||
124
NEWS
124
NEWS
@@ -5,16 +5,44 @@ Approximate change log for AVRDUDE by version.
|
|||||||
(For detailed changes, see the version control system logs.)
|
(For detailed changes, see the version control system logs.)
|
||||||
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Changes since version 6.4:
|
Changes in version 7.0:
|
||||||
|
|
||||||
* Major changes compared to the previous version:
|
* Major changes compared to the previous version:
|
||||||
|
|
||||||
- Completely revamped Windows support, including MSVC
|
- Completely revamped Windows support, including MSVC
|
||||||
- Started to add CMake (by now, parallel with autoconf/automake)
|
- Started to add CMake (by now, parallel with autoconf/automake)
|
||||||
|
- New-architecture devices (AVR8X mega and tiny) can access all
|
||||||
|
fuses, and memory display shows meaningful alias names
|
||||||
|
- The "safemode" feature has been removed. The major class of
|
||||||
|
programmers it has been designed for (lowlevel bitbang
|
||||||
|
programmers on parallel or serial ports) virtually doesn't exist
|
||||||
|
anymore, and the fuse combination that was covered by it do not
|
||||||
|
match the fuses of modern AVR devices anyway.
|
||||||
|
- avrdude.conf is now being looked up in the location of the
|
||||||
|
executable file first, before considering the configured default
|
||||||
|
location; this eases a "portable use" where the entire suite is
|
||||||
|
not installed into its configured default location. (Basically
|
||||||
|
only relevant for unixoid systems; on Windows, this search order
|
||||||
|
has been used for many years already.)
|
||||||
|
|
||||||
* New devices supported:
|
* New devices supported:
|
||||||
|
|
||||||
- ATtiny828, ATtiny87, ATtiny167, ATtiny48, ATtiny102, ATtiny104
|
- ATtiny828, ATtiny87, ATtiny167, ATtiny48, ATtiny102, ATtiny104
|
||||||
|
- LGT8F88P, LGT8F168P, LGT8F328P (fixed names of these parts)
|
||||||
|
- ATmeg164A, ATmega169A, ATmega169P, ATmega169PA, ATmega329A,
|
||||||
|
ATmega329PA, ATmega3290, ATmega3290A, ATmega3290PA, ATmega649A,
|
||||||
|
ATmega649P, ATmega6490A, ATmega6490P, ATmega165, ATmega165A,
|
||||||
|
ATmega165P, ATmega165PA, ATmega325A, ATmega325P, ATmega325PA,
|
||||||
|
ATmega645A, ATmega645P, ATmega3250A, ATmega3250P, ATmega3250PA,
|
||||||
|
ATmega6450A, ATmega6450P
|
||||||
|
- ATmega48A/48PA/88A/88PA/168A/168PA, ATmega164A/644A/644PA,
|
||||||
|
ATmega16A/32A/64A/128A, ATtiny13A, ATtiny24A/44A/84A,
|
||||||
|
ATtiny261A/461A/861A, ATtiny828R, ATtiny2313A, ATtiny1634R
|
||||||
|
- ATtiny3224, ATtiny3226 and ATtiny3227
|
||||||
|
- AVR16DD14/20/28/32, AVR32DD14/20/28/32 and AVR64DD14/20/28/32
|
||||||
|
- AVR8EA28/32, AVR16EA28/32/48, AVR32EA28/32/48 and AVR64EA28/32/64
|
||||||
|
- ATmega16U4
|
||||||
|
|
||||||
|
|
||||||
* New programmers supported:
|
* New programmers supported:
|
||||||
|
|
||||||
@@ -22,6 +50,10 @@ Changes since version 6.4:
|
|||||||
passive parts)
|
passive parts)
|
||||||
- PicKit4 / SNAP (now also in ISP and PDI mode)
|
- PicKit4 / SNAP (now also in ISP and PDI mode)
|
||||||
- Teensy bootloader (PR #802)
|
- Teensy bootloader (PR #802)
|
||||||
|
- Micronucleus bootloader (PR #786)
|
||||||
|
- ft232h (generic variant, PR #842)
|
||||||
|
- Kristech KT-LINK FT2232H interface with IO switching and voltage
|
||||||
|
buffers (PR #930)
|
||||||
|
|
||||||
* Issues fixed:
|
* Issues fixed:
|
||||||
|
|
||||||
@@ -36,6 +68,31 @@ Changes since version 6.4:
|
|||||||
- [bug #26007] ATTiny167 not supported #150
|
- [bug #26007] ATTiny167 not supported #150
|
||||||
- [bug #47375] ATtiny102/104 descriptions missing in configuration
|
- [bug #47375] ATtiny102/104 descriptions missing in configuration
|
||||||
file #409
|
file #409
|
||||||
|
- No error message when connecting to a not-connected AVRISP mkII
|
||||||
|
programmer #813
|
||||||
|
- [bug #53180] missing programmer or bad -P option argument
|
||||||
|
doesn't result in error message #471
|
||||||
|
- ATmega328P reported as lgt8fx328p #812
|
||||||
|
- [bug #48004] Dead link for linuxgpio in avrdude description #419
|
||||||
|
- Segmentation fault when writing ATtiny104 fuse #823
|
||||||
|
- USBasp returns ERANGE for unknown error #848
|
||||||
|
- Compiler warnings #856
|
||||||
|
- Can't get serialupdi to work #874
|
||||||
|
- Rework HID support for Windows #881
|
||||||
|
- List of signing keys? #884
|
||||||
|
- Pickit4 UPDI is writing at offset 0x4000 into flash instead of 0x0000. #892
|
||||||
|
- SerialUPDI programmer can't write to usersig/userrow in terminal mode #889
|
||||||
|
- Signature read command for ATmega165* was wrong (no-id)
|
||||||
|
- Cannot use non-standard baud rates for uploading on MacOS #771
|
||||||
|
- Wrong values in avrdude.conf #897
|
||||||
|
- AVR-Eclipse plugin broken by missing -u commandline option #890
|
||||||
|
- Timeout passed to hid_read_timeout() is too short for instances
|
||||||
|
where the EDBG AVRISP 'Enter Programming Mode' command fails #900
|
||||||
|
- Terminal write mode doesn't support string input (yet) #913
|
||||||
|
- Terminal mode: memory fill with strings may cause Avrdude to crash. #922
|
||||||
|
- Some parts have wrong or missing ISP commands #915
|
||||||
|
- Incorrect -b conversion for linuxspi programmer #927
|
||||||
|
- ATtiny43U calibration memory size #921
|
||||||
|
|
||||||
* Pull requests:
|
* Pull requests:
|
||||||
|
|
||||||
@@ -64,10 +121,73 @@ Changes since version 6.4:
|
|||||||
- Fix typos all over the code #807
|
- Fix typos all over the code #807
|
||||||
- Add MSVC builds and better WinUSB/FTDI support #798
|
- Add MSVC builds and better WinUSB/FTDI support #798
|
||||||
- buspirate: fix invalidScanfArgType_int warning #808
|
- buspirate: fix invalidScanfArgType_int warning #808
|
||||||
|
- Ignore ac_cfg.h.in~ #810
|
||||||
|
- Notify open failure #814
|
||||||
|
- Print expected part #817
|
||||||
|
- pindefs: conform to the function declaration #818
|
||||||
|
- Add support for Micronucleus bootloader #786
|
||||||
|
- Remove ac_cfg.h from libavrdude.h #820
|
||||||
|
- CMake: enable dynamic-link library for libavrdude #826
|
||||||
|
- Fix for TPI fuse write (issue #823) #828
|
||||||
|
- Add missing ATmega__5 and ATmega__9 targets to avrdude.conf #809
|
||||||
|
- Add missing ATmega and ATtiny targets #832
|
||||||
|
- Added missing RTS/DTR management feature to serialupdi
|
||||||
|
programmer #811
|
||||||
|
- Add missing tinyAVR-2, AVR DD and AVR EA targets #836
|
||||||
|
- Add a new programmer ft232h #842
|
||||||
|
- Reduce verbosity when setting fuses and uploading programs #845
|
||||||
|
- jtagmkii: Reduce the number of sync attempts to 10 + print
|
||||||
|
number of attempts #844
|
||||||
|
- CMake: add initial support for installing lib and include files #829
|
||||||
|
- Add SPI support to USBtiny #816
|
||||||
|
- Add more memory sections to read from #815
|
||||||
|
- Add a build script for Unix-like systems #849
|
||||||
|
- Fix receive buffer implementation in ftdi_syncbb programmer #843
|
||||||
|
- CMake: split configuration in two files #852
|
||||||
|
- Set number of connection retry attempts for Arduino/STK500
|
||||||
|
programmer #854
|
||||||
|
- Fix libusb-1.0 error strings #850
|
||||||
|
- Assign proper type to msg[] in errstr() #857
|
||||||
|
- Fix Arduino retry attempts #855
|
||||||
|
- CMake: use CMAKE_CURRENT_BINARY_DIR to locate avrdude.conf #858
|
||||||
|
- Remove the "safemode" feature. #859
|
||||||
|
- Add support for reading from more memory sections #863
|
||||||
|
- Alias keyword #868
|
||||||
|
- Add fuse name aliases to avrdude.conf + tweak update.c #869
|
||||||
|
- Print JTAG3 clocks after configuration + string formatting #853
|
||||||
|
- Tweak programmer info formatting strings #872
|
||||||
|
- Remove libhid support in ser_avrdoper.c in favor of libhidapi #882
|
||||||
|
- Reduce jtag3 output verbosity #877
|
||||||
|
- Fix Curiosity Nano target voltage #878
|
||||||
|
- Smallest possible fix for PL2303HX #885
|
||||||
|
- Add missing USBtiny derived programmers #873
|
||||||
|
- Cleanup of POSIX serial init code #886
|
||||||
|
- Avrdude terminal write improvements #880
|
||||||
|
- Add userrow and usersig aliases #888
|
||||||
|
- For UPDI devices do not add offset when accessing flash. #895
|
||||||
|
- Support both userrow and usersig names #893
|
||||||
|
- Fix ugly terminal write bug #896
|
||||||
|
- Improve terminal read functionality #894
|
||||||
|
- Macos nonstandard baudrates #898
|
||||||
|
- Fix errors in Avrdude.conf #899
|
||||||
|
- Minor terminal write improvements #902
|
||||||
|
- Term docs #903
|
||||||
|
- Add progressbar for read and write command #912
|
||||||
|
- Add MacOS serial/parallel port note #908
|
||||||
|
- Add ATmega16U4 to avrdude.conf #910
|
||||||
|
- Mask out unused ATmega32U4 efuse bits #909
|
||||||
|
- Increased timeout passed to hid_read_timeout() #901
|
||||||
|
- Add terminal write string functionality #914
|
||||||
|
- Update documentation link to new URL #929
|
||||||
|
- Fix terminal write buffer overflow issue #924
|
||||||
|
- Fix linuxspi baud to clock period calculation #931
|
||||||
|
- Added KT-LINK FT2232H interface with IO switching and voltage buffers. #930
|
||||||
|
|
||||||
* Internals:
|
* Internals:
|
||||||
|
|
||||||
- Development moved to Github
|
- Development moved to Github
|
||||||
|
- Addition of "alias" keyword to avrdude.conf.in syntax; used
|
||||||
|
for fuse name aliases right now
|
||||||
|
|
||||||
|
|
||||||
Version 6.4:
|
Version 6.4:
|
||||||
@@ -808,7 +928,7 @@ Version 4.3.0:
|
|||||||
* Added "Troubleshooting"-Appendix to the manual.
|
* Added "Troubleshooting"-Appendix to the manual.
|
||||||
|
|
||||||
* Add ATmega8515 support.
|
* Add ATmega8515 support.
|
||||||
Contributed by: Matthias Weißer <matthias@matwei.de>
|
Contributed by: Matthias Weißer <matthias@matwei.de>
|
||||||
|
|
||||||
* Add ATmega64 support.
|
* Add ATmega64 support.
|
||||||
Contributed by: Erik Christiansen <erik@dd.nec.com.au>
|
Contributed by: Erik Christiansen <erik@dd.nec.com.au>
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ with the help of [various contributors](./AUTHORS).
|
|||||||
The latest version of AVRDUDE is always available here:\
|
The latest version of AVRDUDE is always available here:\
|
||||||
<https://github.com/avrdudes/avrdude>
|
<https://github.com/avrdudes/avrdude>
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
Documentation for current and previous releases is [on Github Pages](https://avrdudes.github.io/avrdude/).
|
||||||
|
|
||||||
## Getting AVRDUDE for Windows
|
## Getting AVRDUDE for Windows
|
||||||
|
|
||||||
To get AVRDUDE for Windows, install the latest version from the [Releases](http://download.savannah.gnu.org/releases/avrdude/) page.
|
To get AVRDUDE for Windows, install the latest version from the [Releases](http://download.savannah.gnu.org/releases/avrdude/) page.
|
||||||
@@ -57,4 +61,4 @@ avrdude -c arduino -P COM1 -b 115200 -p atmega328p -D -U flash:w:objs/blink.hex:
|
|||||||
|
|
||||||
There are many different programmers and options that may be required for the programming to succeed.
|
There are many different programmers and options that may be required for the programming to succeed.
|
||||||
|
|
||||||
For more information, refer to the [AVRDUDE documentation](http://download.savannah.gnu.org/releases/avrdude/avrdude-doc-6.4.pdf).
|
For more information, refer to the [AVRDUDE documentation](https://avrdudes.github.io/avrdude/).
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[](https://github.com/mariusgreuel/avrdude/actions/workflows/build.yml)
|
[](https://github.com/mariusgreuel/avrdude/actions/workflows/build.yml)
|
||||||
|
|
||||||
This is a fork of AVRDUDE 6.4 from <https://github.com/avrdudes/avrdude>.
|
This is a fork of AVRDUDE 7.0 from <https://github.com/avrdudes/avrdude>.
|
||||||
|
|
||||||
The purpose of this fork is to add better support for Windows to bring it on par with the Linux version of AVRDUDE.
|
The purpose of this fork is to add better support for Windows to bring it on par with the Linux version of AVRDUDE.
|
||||||
|
|
||||||
@@ -19,7 +19,11 @@ Noteable changes include:
|
|||||||
- [Support Visual Studio](#support-visual-studio)
|
- [Support Visual Studio](#support-visual-studio)
|
||||||
- [Miscellaneous bug-fixes and patches](#miscellaneous-bug-fixes-and-patches)
|
- [Miscellaneous bug-fixes and patches](#miscellaneous-bug-fixes-and-patches)
|
||||||
|
|
||||||
The original AVRDUDE project homepage can be found here <https://savannah.nongnu.org/projects/avrdude>.
|
The original AVRDUDE project homepage can be found here <https://github.com/avrdudes/avrdude>.
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
Documentation for current and previous releases is [on Github Pages](https://avrdudes.github.io/avrdude/).
|
||||||
|
|
||||||
## Download
|
## Download
|
||||||
|
|
||||||
|
|||||||
77
build.sh
Executable file
77
build.sh
Executable file
@@ -0,0 +1,77 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Build script for Unix-like systems, using the CMake subsystem
|
||||||
|
#
|
||||||
|
# This script covers some common cases. It does *not* install any
|
||||||
|
# prerequisites though.
|
||||||
|
#
|
||||||
|
# For documentation of AVRDUDE's build system, please refer to the
|
||||||
|
# Wiki:
|
||||||
|
#
|
||||||
|
# https://github.com/avrdudes/avrdude/wiki
|
||||||
|
|
||||||
|
# Determine OS type
|
||||||
|
#
|
||||||
|
# So far, this script tries to handle three different Unix-like
|
||||||
|
# systems:
|
||||||
|
#
|
||||||
|
# Linux
|
||||||
|
# FreeBSD
|
||||||
|
# Darwin (aka. MacOS)
|
||||||
|
#
|
||||||
|
# On Linux, if the machine is ARM-based, LINUXSPI and LINUXGPIO are
|
||||||
|
# enabled.
|
||||||
|
# On MacOS, an attempt is made to find out whether Mac ports or brew
|
||||||
|
# are in place, and are assumed to have install the prerequisites.
|
||||||
|
|
||||||
|
ostype=$(uname | tr '[A-Z]' '[a-z]')
|
||||||
|
|
||||||
|
build_type=RelWithDebInfo
|
||||||
|
# build_type=Release # no debug info
|
||||||
|
|
||||||
|
extra_enable=""
|
||||||
|
build_flags=""
|
||||||
|
|
||||||
|
case "${ostype}" in
|
||||||
|
linux)
|
||||||
|
# try to find out whether this is an Embedded Linux
|
||||||
|
# platform (e.g. Raspberry Pi)
|
||||||
|
machine=$(uname -m)
|
||||||
|
if expr "${machine}" : 'arm' >/dev/null
|
||||||
|
then
|
||||||
|
extra_enable="${extra_enable} -D HAVE_LINUXGPIO=ON -D HAVE_LINUXSPI=ON"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
darwin)
|
||||||
|
# determine whether we are running using Mac Ports
|
||||||
|
# if not, assume Mac Brew
|
||||||
|
if [ -f /opt/local/bin/port ]
|
||||||
|
then
|
||||||
|
build_flags="${build_flags} -D CMAKE_C_FLAGS=-I/opt/local/include -D CMAKE_EXE_LINKER_FLAGS=-L/opt/local/lib"
|
||||||
|
else
|
||||||
|
build_flags="${build_flags} -D CMAKE_C_FLAGS=-I/usr/local/include -D CMAKE_EXE_LINKER_FLAGS=-L/usr/local/Cellar"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
freebsd)
|
||||||
|
build_flags="${build_flags} -D CMAKE_C_FLAGS=-I/usr/local/include -D CMAKE_EXE_LINKER_FLAGS=-L/usr/local/lib"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
cmake ${build_flags} ${extra_enable} -D CMAKE_BUILD_TYPE=${build_type} -B build_${ostype} ||\
|
||||||
|
{ echo "CMake failed."; exit 1; }
|
||||||
|
cmake --build build_${ostype} ||\
|
||||||
|
{ echo "Build failed."; exit 1; }
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
|
||||||
|
Build succeeded.
|
||||||
|
|
||||||
|
Run
|
||||||
|
|
||||||
|
sudo cmake --build build_${ostype} --target install
|
||||||
|
|
||||||
|
to install.
|
||||||
|
|
||||||
|
EOF
|
||||||
@@ -16,101 +16,23 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
# Typical usage:
|
|
||||||
# cmake -B build
|
|
||||||
# cmake --build build
|
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.12)
|
|
||||||
project(avrdude VERSION 6.99)
|
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 11)
|
|
||||||
set(CMAKE_C_STANDARD_REQUIRED True)
|
|
||||||
|
|
||||||
option(BUILD_DOC "Enable building documents" OFF)
|
|
||||||
option(HAVE_LINUXGPIO "Enable Linux sysfs GPIO support" OFF)
|
|
||||||
option(HAVE_LINUXSPI "Enable Linux SPI support" OFF)
|
|
||||||
option(HAVE_PARPORT "Enable parallel port support" OFF)
|
|
||||||
option(USE_EXTERNAL "Use external libraries from AVRDUDE GitHub repositories" OFF)
|
|
||||||
option(USE_LIBUSBWIN32 "Prefer libusb-win32 over libusb" OFF)
|
|
||||||
option(DEBUG_CMAKE "Enable debugging output for this CMake project" OFF)
|
|
||||||
|
|
||||||
include(CheckIncludeFile)
|
|
||||||
include(CheckSymbolExists)
|
|
||||||
include(FetchContent)
|
|
||||||
include(FindPackageMessage)
|
|
||||||
include(GNUInstallDirs)
|
|
||||||
|
|
||||||
set(CONFIG_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}")
|
|
||||||
set(AVRDUDE_FULL_VERSION ${CMAKE_PROJECT_VERSION})
|
|
||||||
|
|
||||||
# =====================================
|
# =====================================
|
||||||
# Get Git commit info
|
# Set up flex target
|
||||||
# =====================================
|
# =====================================
|
||||||
|
|
||||||
# GIT_COMMIT_HASH -> hash of latest commit, e.g. b8b859f5
|
FLEX_TARGET(Parser "lexer.l" "${PROJECT_BINARY_DIR}/lexer.c")
|
||||||
# GIT_COMMIT_DATE -> date of latest commit, e.g. 20201231
|
|
||||||
# GIT_COMMIT_YEAR -> year of latest commit, e.g. 2020
|
|
||||||
|
|
||||||
find_package(Git)
|
if (FLEX_VERSION VERSION_GREATER_EQUAL 2.5.9)
|
||||||
if(Git_FOUND)
|
|
||||||
execute_process(
|
|
||||||
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%h
|
|
||||||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
|
||||||
OUTPUT_VARIABLE GIT_COMMIT_HASH
|
|
||||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
)
|
|
||||||
|
|
||||||
execute_process(
|
|
||||||
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%ad --date=format:%Y%m%d
|
|
||||||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
|
||||||
OUTPUT_VARIABLE GIT_COMMIT_DATE
|
|
||||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
)
|
|
||||||
|
|
||||||
execute_process(
|
|
||||||
COMMAND "${GIT_EXECUTABLE}" log -1 --format=%ad --date=format:%Y
|
|
||||||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
|
||||||
OUTPUT_VARIABLE GIT_COMMIT_YEAR
|
|
||||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
)
|
|
||||||
|
|
||||||
execute_process(
|
|
||||||
COMMAND "${GIT_EXECUTABLE}" log -1 --tags --format=%h
|
|
||||||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
|
||||||
OUTPUT_VARIABLE GIT_TAG_HASH
|
|
||||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
||||||
)
|
|
||||||
|
|
||||||
# If the commit is not tagged, include the date and commit hash in the full version string.
|
|
||||||
if(NOT GIT_COMMIT_HASH STREQUAL GIT_TAG_HASH)
|
|
||||||
set(AVRDUDE_FULL_VERSION "${CMAKE_PROJECT_VERSION}-${GIT_COMMIT_DATE} (${GIT_COMMIT_HASH})")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# =====================================
|
|
||||||
# Detect flex and yacc/bison
|
|
||||||
# =====================================
|
|
||||||
|
|
||||||
find_package(FLEX)
|
|
||||||
if(FLEX_FOUND)
|
|
||||||
FLEX_TARGET(Parser lexer.l "${PROJECT_BINARY_DIR}/lexer.c")
|
|
||||||
|
|
||||||
if (FLEX_VERSION VERSION_GREATER_EQUAL 2.5.9)
|
|
||||||
set(HAVE_YYLEX_DESTROY 1)
|
set(HAVE_YYLEX_DESTROY 1)
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
message(SEND_ERROR "This CMake project requires 'flex', which is not installed on your system." )
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(BISON QUIET)
|
# =====================================
|
||||||
|
# Set up yacc/bison target
|
||||||
|
# =====================================
|
||||||
|
|
||||||
if(BISON_FOUND)
|
if(BISON_FOUND)
|
||||||
find_package_message(BISON "Found BISON: ${BISON_EXECUTABLE} (found version \"${BISON_VERSION}\")" "[${BISON_EXECUTABLE}][${BISON_VERSION}]")
|
|
||||||
BISON_TARGET(Parser config_gram.y "${PROJECT_BINARY_DIR}/config_gram.c" DEFINES_FILE "${PROJECT_BINARY_DIR}/config_gram.h")
|
BISON_TARGET(Parser config_gram.y "${PROJECT_BINARY_DIR}/config_gram.c" DEFINES_FILE "${PROJECT_BINARY_DIR}/config_gram.h")
|
||||||
else()
|
else()
|
||||||
find_program(YACC_EXECUTABLE NAMES yacc byacc DOC "path to the yacc executable")
|
|
||||||
mark_as_advanced(YACC_EXECUTABLE)
|
|
||||||
if(YACC_EXECUTABLE)
|
|
||||||
find_package_message(YACC "Found YACC: ${YACC_EXECUTABLE}" "[${YACC_EXECUTABLE}]")
|
|
||||||
set(YACC_TARGET_outputs "${PROJECT_BINARY_DIR}/config_gram.c")
|
set(YACC_TARGET_outputs "${PROJECT_BINARY_DIR}/config_gram.c")
|
||||||
add_custom_command(OUTPUT ${YACC_TARGET_outputs}
|
add_custom_command(OUTPUT ${YACC_TARGET_outputs}
|
||||||
COMMAND ${YACC_EXECUTABLE} -d -o ${YACC_TARGET_outputs} config_gram.y
|
COMMAND ${YACC_EXECUTABLE} -d -o ${YACC_TARGET_outputs} config_gram.y
|
||||||
@@ -119,181 +41,17 @@ else()
|
|||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
set(BISON_Parser_OUTPUTS ${YACC_TARGET_outputs})
|
set(BISON_Parser_OUTPUTS ${YACC_TARGET_outputs})
|
||||||
else()
|
|
||||||
message(SEND_ERROR "This CMake project requires 'bison', 'yacc', or 'byacc', which is not installed on your system." )
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# =====================================
|
|
||||||
# Detect installed libraries
|
|
||||||
# =====================================
|
|
||||||
|
|
||||||
# Prefer static libraries over DLLs on Windows
|
|
||||||
if(WIN32)
|
|
||||||
set(PREFERRED_LIBELF libelf.a elf)
|
|
||||||
set(PREFERRED_LIBUSB libusb.a usb)
|
|
||||||
set(PREFERRED_LIBUSB_1_0 libusb-1.0.a usb-1.0)
|
|
||||||
set(PREFERRED_LIBHIDAPI libhidapi.a libhidapi-libusb.a libhidapi-hidraw.a hidapi hidapi-libusb hidapi-hidraw)
|
|
||||||
set(PREFERRED_LIBFTDI libftdi.a ftdi)
|
|
||||||
set(PREFERRED_LIBFTDI1 libftdi1.a ftdi1)
|
|
||||||
else()
|
|
||||||
set(PREFERRED_LIBELF elf)
|
|
||||||
set(PREFERRED_LIBUSB usb)
|
|
||||||
set(PREFERRED_LIBUSB_1_0 usb-1.0)
|
|
||||||
set(PREFERRED_LIBHIDAPI hidapi hidapi-libusb hidapi-hidraw)
|
|
||||||
set(PREFERRED_LIBFTDI ftdi)
|
|
||||||
set(PREFERRED_LIBFTDI1 ftdi1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# -------------------------------------
|
|
||||||
# Find libelf
|
|
||||||
|
|
||||||
find_library(HAVE_LIBELF NAMES ${PREFERRED_LIBELF})
|
|
||||||
if(HAVE_LIBELF)
|
|
||||||
set(LIB_LIBELF ${HAVE_LIBELF})
|
|
||||||
check_include_file(libelf.h HAVE_LIBELF_H)
|
|
||||||
check_include_file(libelf/libelf.h HAVE_LIBELF_LIBELF_H)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# -------------------------------------
|
|
||||||
# Find libusb
|
|
||||||
|
|
||||||
find_library(HAVE_LIBUSB NAMES ${PREFERRED_LIBUSB})
|
|
||||||
if(HAVE_LIBUSB)
|
|
||||||
set(LIB_LIBUSB ${HAVE_LIBUSB})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_library(HAVE_LIBUSB_1_0 NAMES ${PREFERRED_LIBUSB_1_0})
|
|
||||||
if(HAVE_LIBUSB_1_0)
|
|
||||||
set(LIB_LIBUSB_1_0 ${HAVE_LIBUSB_1_0})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# FreeBSD's library 'libusb' supports both the libusb-0.1 and libusb-1.0 API.
|
|
||||||
if (HAVE_LIBUSB AND CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
|
||||||
set(HAVE_LIBUSB_1_0 ${HAVE_LIBUSB})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_library(HAVE_LIBUSB_WIN32 NAMES libusb0.a usb0)
|
|
||||||
|
|
||||||
if(HAVE_LIBUSB OR HAVE_LIBUSB_1_0 OR HAVE_LIBUSB_WIN32)
|
|
||||||
check_include_file(usb.h HAVE_USB_H)
|
|
||||||
check_include_file(lusb0_usb.h HAVE_LUSB0_USB_H)
|
|
||||||
check_include_file(libusb.h HAVE_LIBUSB_H)
|
|
||||||
check_include_file(libusb-1.0/libusb.h HAVE_LIBUSB_1_0_LIBUSB_H)
|
|
||||||
|
|
||||||
if((USE_LIBUSBWIN32 OR NOT HAVE_LIBUSB) AND HAVE_LIBUSB_WIN32)
|
|
||||||
set(HAVE_LIBUSB ${HAVE_LIBUSB_WIN32})
|
|
||||||
set(LIB_LIBUSB ${HAVE_LIBUSB_WIN32})
|
|
||||||
unset(HAVE_USB_H CACHE)
|
|
||||||
elseif(NOT HAVE_USB_H)
|
|
||||||
find_path(LIBUSB_COMPAT_DIR libusb-compat/usb.h)
|
|
||||||
if(LIBUSB_COMPAT_DIR)
|
|
||||||
set(LIBUSB_COMPAT_DIR ${LIBUSB_COMPAT_DIR}/libusb-compat)
|
|
||||||
set(HAVE_USB_H 1)
|
|
||||||
else()
|
|
||||||
unset(LIBUSB_COMPAT_DIR CACHE)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# -------------------------------------
|
|
||||||
# Find libhidapi
|
|
||||||
|
|
||||||
find_library(HAVE_LIBHID NAMES hid)
|
|
||||||
|
|
||||||
find_library(HAVE_LIBHIDAPI NAMES ${PREFERRED_LIBHIDAPI})
|
|
||||||
if(HAVE_LIBHIDAPI)
|
|
||||||
set(LIB_LIBHIDAPI ${HAVE_LIBHIDAPI})
|
|
||||||
check_include_file(hidapi/hidapi.h HAVE_HIDAPI_HIDAPI_H)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# -------------------------------------
|
|
||||||
# Find libftdi
|
|
||||||
|
|
||||||
find_library(HAVE_LIBFTDI NAMES ${PREFERRED_LIBFTDI})
|
|
||||||
if(HAVE_LIBFTDI)
|
|
||||||
set(LIB_LIBFTDI ${HAVE_LIBFTDI})
|
|
||||||
set(HAVE_LIBFTDI_TYPE_232H 1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_library(HAVE_LIBFTDI1 NAMES ${PREFERRED_LIBFTDI1})
|
|
||||||
if(HAVE_LIBFTDI1)
|
|
||||||
set(LIB_LIBFTDI1 ${HAVE_LIBFTDI1})
|
|
||||||
set(HAVE_LIBFTDI_TYPE_232H 1)
|
|
||||||
set(CMAKE_REQUIRED_LIBRARIES ${LIB_LIBFTDI1} ${LIB_LIBUSB} ${LIB_LIBUSB_1_0})
|
|
||||||
check_symbol_exists(ftdi_tcioflush "libftdi1/ftdi.h" HAVE_FTDI_TCIOFLUSH)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# -------------------------------------
|
|
||||||
# Find libreadline
|
|
||||||
|
|
||||||
find_library(HAVE_LIBREADLINE NAMES readline)
|
|
||||||
if(HAVE_LIBREADLINE)
|
|
||||||
set(LIB_LIBREADLINE ${HAVE_LIBREADLINE})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# =====================================
|
|
||||||
# Use external libraries if requested
|
|
||||||
# =====================================
|
|
||||||
|
|
||||||
if(USE_EXTERNAL)
|
|
||||||
FetchContent_Declare(libelf
|
|
||||||
GIT_REPOSITORY https://github.com/avrdudes/libelf.git
|
|
||||||
GIT_TAG e5a39bf19bd6598c42e09172be5a78ceec2a065c
|
|
||||||
)
|
|
||||||
|
|
||||||
FetchContent_Declare(libusb
|
|
||||||
GIT_REPOSITORY https://github.com/avrdudes/libusb.git
|
|
||||||
GIT_TAG 632bc25d04eff563cc00de29435b9a7ed6f4654c
|
|
||||||
)
|
|
||||||
|
|
||||||
FetchContent_Declare(libhidapi
|
|
||||||
GIT_REPOSITORY https://github.com/avrdudes/libhidapi.git
|
|
||||||
GIT_TAG e3700e951f762ef92871ff4fc94586e4d1c042a6
|
|
||||||
)
|
|
||||||
|
|
||||||
FetchContent_Declare(libftdi
|
|
||||||
GIT_REPOSITORY https://github.com/avrdudes/libftdi.git
|
|
||||||
GIT_TAG f3a54da710002a7d25a32a69e667a69ef84cc120
|
|
||||||
)
|
|
||||||
|
|
||||||
message(STATUS "Fetching external libraries, please wait...")
|
|
||||||
FetchContent_MakeAvailable(
|
|
||||||
libelf
|
|
||||||
libusb
|
|
||||||
libhidapi
|
|
||||||
libftdi
|
|
||||||
)
|
|
||||||
|
|
||||||
message(STATUS "Using external library 'libelf'")
|
|
||||||
set(LIB_LIBELF libelf)
|
|
||||||
set(HAVE_LIBELF 1)
|
|
||||||
set(HAVE_LIBELF_H 1)
|
|
||||||
|
|
||||||
message(STATUS "Using external library 'libusb'")
|
|
||||||
set(LIB_LIBUSB libusb)
|
|
||||||
set(HAVE_LIBUSB 1)
|
|
||||||
set(HAVE_LUSB0_USB_H 1)
|
|
||||||
|
|
||||||
message(STATUS "Using external library 'libhidapi'")
|
|
||||||
set(LIB_LIBHIDAPI libhidapi)
|
|
||||||
set(HAVE_LIBHIDAPI 1)
|
|
||||||
set(HAVE_HIDAPI_HIDAPI_H 1)
|
|
||||||
|
|
||||||
message(STATUS "Using external library 'libftdi'")
|
|
||||||
set(LIB_LIBFTDI libftdi)
|
|
||||||
set(HAVE_LIBFTDI 1)
|
|
||||||
set(HAVE_LIBFTDI_TYPE_232H 1)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# =====================================
|
# =====================================
|
||||||
# Setup target specific options
|
# Setup target specific options
|
||||||
# =====================================
|
# =====================================
|
||||||
|
|
||||||
|
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
add_compile_definitions(CONFIG_DIR=\"${CONFIG_DIR}\")
|
add_compile_definitions(CONFIG_DIR=\"${CONFIG_DIR}\")
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(EXTRA_WINDOWS_SOURCES "${PROJECT_BINARY_DIR}/windows.rc")
|
set(EXTRA_WINDOWS_SOURCES "${PROJECT_BINARY_DIR}/src/windows.rc")
|
||||||
set(EXTRA_WINDOWS_LIBRARIES setupapi ws2_32)
|
set(EXTRA_WINDOWS_LIBRARIES setupapi ws2_32)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -314,140 +72,16 @@ if(MSVC)
|
|||||||
add_compile_options(/wd6255) # warning C6255: _alloca indicates failure by raising a stack overflow exception. Consider using _malloca instead
|
add_compile_options(/wd6255) # warning C6255: _alloca indicates failure by raising a stack overflow exception. Consider using _malloca instead
|
||||||
|
|
||||||
set(EXTRA_WINDOWS_SOURCES ${EXTRA_WINDOWS_SOURCES}
|
set(EXTRA_WINDOWS_SOURCES ${EXTRA_WINDOWS_SOURCES}
|
||||||
"${PROJECT_SOURCE_DIR}/msvc/getopt.c"
|
"msvc/getopt.c"
|
||||||
"${PROJECT_SOURCE_DIR}/msvc/gettimeofday.c"
|
"msvc/gettimeofday.c"
|
||||||
"${PROJECT_SOURCE_DIR}/msvc/usleep.cpp"
|
"msvc/usleep.cpp"
|
||||||
"${PROJECT_SOURCE_DIR}/msvc/usb_com_helper.cpp"
|
"msvc/usb_com_helper.cpp"
|
||||||
)
|
)
|
||||||
set(EXTRA_WINDOWS_INCLUDES ${EXTRA_WINDOWS_INCLUDES}
|
set(EXTRA_WINDOWS_INCLUDES ${EXTRA_WINDOWS_INCLUDES}
|
||||||
"${PROJECT_SOURCE_DIR}/msvc"
|
"msvc"
|
||||||
"${PROJECT_SOURCE_DIR}/msvc/generated"
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# =====================================
|
|
||||||
# Setup default port names
|
|
||||||
# =====================================
|
|
||||||
|
|
||||||
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
||||||
set(DEFAULT_PAR_PORT "/dev/parport0")
|
|
||||||
set(DEFAULT_SER_PORT "/dev/ttyS0")
|
|
||||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
|
||||||
set(DEFAULT_PAR_PORT "/dev/ppi0")
|
|
||||||
set(DEFAULT_SER_PORT "/dev/cuad0")
|
|
||||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "Solaris")
|
|
||||||
set(DEFAULT_PAR_PORT "/dev/printers/0")
|
|
||||||
set(DEFAULT_SER_PORT "/dev/term/a")
|
|
||||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
|
||||||
set(DEFAULT_PAR_PORT "lpt1")
|
|
||||||
set(DEFAULT_SER_PORT "com1")
|
|
||||||
else()
|
|
||||||
set(DEFAULT_PAR_PORT "unknown")
|
|
||||||
set(DEFAULT_SER_PORT "unknown")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# =====================================
|
|
||||||
# Configuration
|
|
||||||
# =====================================
|
|
||||||
|
|
||||||
message(STATUS "Configuration summary:")
|
|
||||||
message(STATUS "----------------------")
|
|
||||||
|
|
||||||
if (DEBUG_CMAKE)
|
|
||||||
message(STATUS "CMAKE_HOST_SYSTEM: ${CMAKE_HOST_SYSTEM}")
|
|
||||||
message(STATUS "CMAKE_SYSTEM: ${CMAKE_SYSTEM}")
|
|
||||||
message(STATUS "CMAKE_FIND_ROOT_PATH: ${CMAKE_FIND_ROOT_PATH}")
|
|
||||||
message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
|
|
||||||
message(STATUS "CONFIG_DIR: ${CONFIG_DIR}")
|
|
||||||
message(STATUS "AVRDUDE_FULL_VERSION: ${AVRDUDE_FULL_VERSION}")
|
|
||||||
message(STATUS "USE_EXTERNAL: ${USE_EXTERNAL}")
|
|
||||||
message(STATUS "USE_LIBUSBWIN32: ${USE_LIBUSBWIN32}")
|
|
||||||
message(STATUS "HAVE_LIBELF: ${HAVE_LIBELF}")
|
|
||||||
message(STATUS "HAVE_LIBUSB: ${HAVE_LIBUSB}")
|
|
||||||
message(STATUS "HAVE_LIBUSB_1_0: ${HAVE_LIBUSB_1_0}")
|
|
||||||
message(STATUS "HAVE_LIBUSB_WIN32: ${HAVE_LIBUSB_WIN32}")
|
|
||||||
message(STATUS "HAVE_LIBHID: ${HAVE_LIBHID}")
|
|
||||||
message(STATUS "HAVE_LIBHIDAPI: ${HAVE_LIBHIDAPI}")
|
|
||||||
message(STATUS "HAVE_LIBFTDI: ${HAVE_LIBFTDI}")
|
|
||||||
message(STATUS "HAVE_LIBFTDI1: ${HAVE_LIBFTDI1}")
|
|
||||||
message(STATUS "HAVE_LIBREADLINE: ${HAVE_LIBREADLINE}")
|
|
||||||
message(STATUS "HAVE_LIBELF_H: ${HAVE_LIBELF_H}")
|
|
||||||
message(STATUS "HAVE_LIBELF_LIBELF_H: ${HAVE_LIBELF_LIBELF_H}")
|
|
||||||
message(STATUS "HAVE_USB_H: ${HAVE_USB_H}")
|
|
||||||
message(STATUS "HAVE_LUSB0_USB_H: ${HAVE_LUSB0_USB_H}")
|
|
||||||
message(STATUS "HAVE_LIBUSB_H: ${HAVE_LIBUSB_H}")
|
|
||||||
message(STATUS "HAVE_LIBUSB_1_0_LIBUSB_H: ${HAVE_LIBUSB_1_0_LIBUSB_H}")
|
|
||||||
message(STATUS "HAVE_HIDAPI_HIDAPI_H: ${HAVE_HIDAPI_HIDAPI_H}")
|
|
||||||
message(STATUS "LIBUSB_COMPAT_DIR: ${LIBUSB_COMPAT_DIR}")
|
|
||||||
message(STATUS "----------------------")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(HAVE_LIBELF)
|
|
||||||
message(STATUS "DO HAVE libelf")
|
|
||||||
else()
|
|
||||||
message(STATUS "DON'T HAVE libelf")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(HAVE_LIBUSB)
|
|
||||||
message(STATUS "DO HAVE libusb")
|
|
||||||
else()
|
|
||||||
message(STATUS "DON'T HAVE libusb")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(HAVE_LIBUSB_1_0)
|
|
||||||
message(STATUS "DO HAVE libusb_1_0")
|
|
||||||
else()
|
|
||||||
message(STATUS "DON'T HAVE libusb_1_0")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(HAVE_LIBHIDAPI)
|
|
||||||
message(STATUS "DO HAVE libhidapi")
|
|
||||||
else()
|
|
||||||
message(STATUS "DON'T HAVE libhidapi")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(HAVE_LIBFTDI)
|
|
||||||
if(HAVE_LIBFTDI1)
|
|
||||||
message(STATUS "DO HAVE libftdi (but prefer to use libftdi1)")
|
|
||||||
else()
|
|
||||||
message(STATUS "DO HAVE libftdi")
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
message(STATUS "DON'T HAVE libftdi")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(HAVE_LIBFTDI1)
|
|
||||||
message(STATUS "DO HAVE libftdi1")
|
|
||||||
else()
|
|
||||||
message(STATUS "DON'T HAVE libftdi1")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(BUILD_DOC)
|
|
||||||
message(STATUS "ENABLED doc")
|
|
||||||
else()
|
|
||||||
message(STATUS "DISABLED doc")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(HAVE_PARPORT)
|
|
||||||
message(STATUS "ENABLED parport")
|
|
||||||
else()
|
|
||||||
message(STATUS "DISABLED parport")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(HAVE_LINUXGPIO)
|
|
||||||
message(STATUS "ENABLED linuxgpio")
|
|
||||||
else()
|
|
||||||
message(STATUS "DISABLED linuxgpio")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(HAVE_LINUXSPI)
|
|
||||||
message(STATUS "ENABLED linuxspi")
|
|
||||||
else()
|
|
||||||
message(STATUS "DISABLED linuxspi")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
message(STATUS "----------------------")
|
|
||||||
|
|
||||||
# =====================================
|
# =====================================
|
||||||
# Configure files
|
# Configure files
|
||||||
# =====================================
|
# =====================================
|
||||||
@@ -477,7 +111,7 @@ endif()
|
|||||||
# Project
|
# Project
|
||||||
# =====================================
|
# =====================================
|
||||||
|
|
||||||
add_library(libavrdude STATIC
|
add_library(libavrdude
|
||||||
ac_cfg.h
|
ac_cfg.h
|
||||||
arduino.h
|
arduino.h
|
||||||
arduino.c
|
arduino.c
|
||||||
@@ -540,7 +174,6 @@ add_library(libavrdude STATIC
|
|||||||
ppi.c
|
ppi.c
|
||||||
ppi.h
|
ppi.h
|
||||||
ppiwin.c
|
ppiwin.c
|
||||||
safemode.c
|
|
||||||
serbb.h
|
serbb.h
|
||||||
serbb_posix.c
|
serbb_posix.c
|
||||||
serbb_win32.c
|
serbb_win32.c
|
||||||
@@ -586,6 +219,13 @@ add_library(libavrdude STATIC
|
|||||||
${BISON_Parser_OUTPUTS}
|
${BISON_Parser_OUTPUTS}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set_target_properties(libavrdude PROPERTIES
|
||||||
|
PREFIX ""
|
||||||
|
PUBLIC_HEADER "libavrdude.h"
|
||||||
|
VERSION 1.0.0
|
||||||
|
SOVERSION 1
|
||||||
|
)
|
||||||
|
|
||||||
target_include_directories(libavrdude
|
target_include_directories(libavrdude
|
||||||
PUBLIC
|
PUBLIC
|
||||||
"${PROJECT_SOURCE_DIR}"
|
"${PROJECT_SOURCE_DIR}"
|
||||||
@@ -600,6 +240,7 @@ target_link_libraries(libavrdude
|
|||||||
${LIB_LIBELF}
|
${LIB_LIBELF}
|
||||||
${LIB_LIBUSB}
|
${LIB_LIBUSB}
|
||||||
${LIB_LIBUSB_1_0}
|
${LIB_LIBUSB_1_0}
|
||||||
|
${LIB_LIBHID}
|
||||||
${LIB_LIBHIDAPI}
|
${LIB_LIBHIDAPI}
|
||||||
${LIB_LIBFTDI}
|
${LIB_LIBFTDI}
|
||||||
${LIB_LIBFTDI1}
|
${LIB_LIBFTDI1}
|
||||||
@@ -623,5 +264,10 @@ target_link_libraries(avrdude PUBLIC libavrdude)
|
|||||||
# =====================================
|
# =====================================
|
||||||
|
|
||||||
install(TARGETS avrdude DESTINATION bin)
|
install(TARGETS avrdude DESTINATION bin)
|
||||||
install(FILES "${PROJECT_BINARY_DIR}/avrdude.conf" TYPE SYSCONF)
|
install(TARGETS libavrdude
|
||||||
|
LIBRARY DESTINATION lib
|
||||||
|
ARCHIVE DESTINATION lib
|
||||||
|
PUBLIC_HEADER DESTINATION include COMPONENT dev
|
||||||
|
)
|
||||||
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/avrdude.conf" TYPE SYSCONF)
|
||||||
install(FILES avrdude.1 TYPE MAN)
|
install(FILES avrdude.1 TYPE MAN)
|
||||||
|
|||||||
@@ -148,7 +148,6 @@ libavrdude_a_SOURCES = \
|
|||||||
ppi.c \
|
ppi.c \
|
||||||
ppi.h \
|
ppi.h \
|
||||||
ppiwin.c \
|
ppiwin.c \
|
||||||
safemode.c \
|
|
||||||
serbb.h \
|
serbb.h \
|
||||||
serbb_posix.c \
|
serbb_posix.c \
|
||||||
serbb_win32.c \
|
serbb_win32.c \
|
||||||
|
|||||||
34
src/avr.c
34
src/avr.c
@@ -791,30 +791,6 @@ int avr_write_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||||||
int avr_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
int avr_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||||
unsigned long addr, unsigned char data)
|
unsigned long addr, unsigned char data)
|
||||||
{
|
{
|
||||||
|
|
||||||
unsigned char safemode_lfuse;
|
|
||||||
unsigned char safemode_hfuse;
|
|
||||||
unsigned char safemode_efuse;
|
|
||||||
unsigned char safemode_fuse;
|
|
||||||
|
|
||||||
/* If we write the fuses, then we need to tell safemode that they *should* change */
|
|
||||||
safemode_memfuses(0, &safemode_lfuse, &safemode_hfuse, &safemode_efuse, &safemode_fuse);
|
|
||||||
|
|
||||||
if (strcmp(mem->desc, "fuse")==0) {
|
|
||||||
safemode_fuse = data;
|
|
||||||
}
|
|
||||||
if (strcmp(mem->desc, "lfuse")==0) {
|
|
||||||
safemode_lfuse = data;
|
|
||||||
}
|
|
||||||
if (strcmp(mem->desc, "hfuse")==0) {
|
|
||||||
safemode_hfuse = data;
|
|
||||||
}
|
|
||||||
if (strcmp(mem->desc, "efuse")==0) {
|
|
||||||
safemode_efuse = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
safemode_memfuses(1, &safemode_lfuse, &safemode_hfuse, &safemode_efuse, &safemode_fuse);
|
|
||||||
|
|
||||||
return pgm->write_byte(pgm, p, mem, addr, data);
|
return pgm->write_byte(pgm, p, mem, addr, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -867,6 +843,11 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
|
|||||||
if ((p->flags & AVRPART_HAS_TPI) && m->page_size > 1 &&
|
if ((p->flags & AVRPART_HAS_TPI) && m->page_size > 1 &&
|
||||||
pgm->cmd_tpi != NULL) {
|
pgm->cmd_tpi != NULL) {
|
||||||
|
|
||||||
|
if (wsize == 1) {
|
||||||
|
/* fuse (configuration) memory: only single byte to write */
|
||||||
|
return avr_write_byte(pgm, p, m, 0, m->buf[0]) == 0? 1: -1;
|
||||||
|
}
|
||||||
|
|
||||||
while (avr_tpi_poll_nvmbsy(pgm));
|
while (avr_tpi_poll_nvmbsy(pgm));
|
||||||
|
|
||||||
/* setup for WORD_WRITE */
|
/* setup for WORD_WRITE */
|
||||||
@@ -1074,6 +1055,11 @@ static uint8_t get_fuse_bitmask(AVRMEM * m) {
|
|||||||
return 0xFF;
|
return 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m->op[AVR_OP_WRITE] == NULL ||
|
||||||
|
m->op[AVR_OP_READ] == NULL)
|
||||||
|
// no memory operations provided by configuration, compare directly
|
||||||
|
return 0xFF;
|
||||||
|
|
||||||
// For fuses, only compare bytes that are actually written *and* read.
|
// For fuses, only compare bytes that are actually written *and* read.
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
if (m->op[AVR_OP_WRITE]->bit[i].type == AVR_CMDBIT_INPUT)
|
if (m->op[AVR_OP_WRITE]->bit[i].type == AVR_CMDBIT_INPUT)
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ be taken about voltage level compatibility. Also, although not strictrly
|
|||||||
required, it is strongly advisable to protect the GPIO pins from
|
required, it is strongly advisable to protect the GPIO pins from
|
||||||
overcurrent situations in some way. The simplest would be to just put
|
overcurrent situations in some way. The simplest would be to just put
|
||||||
some resistors in series or better yet use a 3-state buffer driver like
|
some resistors in series or better yet use a 3-state buffer driver like
|
||||||
the 74HC244. Have a look at http://kolev.info/avrdude-linuxgpio for a more
|
the 74HC244. Have a look at http://kolev.info/blog/2013/01/06/avrdude-linuxgpio/ for a more
|
||||||
detailed tutorial about using this programmer type.
|
detailed tutorial about using this programmer type.
|
||||||
.Pp
|
.Pp
|
||||||
Under a Linux installation with direct access to the SPI bus and GPIO
|
Under a Linux installation with direct access to the SPI bus and GPIO
|
||||||
@@ -150,7 +150,7 @@ program memory, but no true chip erase can be performed.
|
|||||||
.Pp
|
.Pp
|
||||||
The Arduino (which is very similar to the STK500 1.x) is supported via
|
The Arduino (which is very similar to the STK500 1.x) is supported via
|
||||||
its own programmer type specification ``arduino''. This programmer works for
|
its own programmer type specification ``arduino''. This programmer works for
|
||||||
the Arduino Uno Rev3.
|
the Arduino Uno Rev3 or any AVR that runs the Optiboot bootloader.
|
||||||
.Pp
|
.Pp
|
||||||
The BusPirate is a versatile tool that can also be used as an AVR programmer.
|
The BusPirate is a versatile tool that can also be used as an AVR programmer.
|
||||||
A single BusPirate can be connected to up to 3 independent AVRs. See
|
A single BusPirate can be connected to up to 3 independent AVRs. See
|
||||||
@@ -607,40 +607,11 @@ Posix systems (by now).
|
|||||||
.It Fl q
|
.It Fl q
|
||||||
Disable (or quell) output of the progress bar while reading or writing
|
Disable (or quell) output of the progress bar while reading or writing
|
||||||
to the device. Specify it a second time for even quieter operation.
|
to the device. Specify it a second time for even quieter operation.
|
||||||
.It Fl s
|
|
||||||
Disable safemode prompting. When safemode discovers that one or more
|
|
||||||
fuse bits have unintentionally changed, it will prompt for
|
|
||||||
confirmation regarding whether or not it should attempt to recover the
|
|
||||||
fuse bit(s). Specifying this flag disables the prompt and assumes
|
|
||||||
that the fuse bit(s) should be recovered without asking for
|
|
||||||
confirmation first.
|
|
||||||
.It Fl t
|
.It Fl t
|
||||||
Tells
|
Tells
|
||||||
.Nm
|
.Nm
|
||||||
to enter the interactive ``terminal'' mode instead of up- or downloading
|
to enter the interactive ``terminal'' mode instead of up- or downloading
|
||||||
files. See below for a detailed description of the terminal mode.
|
files. See below for a detailed description of the terminal mode.
|
||||||
.It Fl u
|
|
||||||
Disable the safemode fuse bit checks. Safemode is enabled by default
|
|
||||||
and is intended to prevent unintentional fuse bit changes. When
|
|
||||||
enabled, safemode will issue a warning if the any fuse bits are found
|
|
||||||
to be different at program exit than they were when
|
|
||||||
.Nm
|
|
||||||
was invoked. Safemode won't alter fuse bits itself, but rather will
|
|
||||||
prompt for instructions, unless the terminal is non-interactive, in
|
|
||||||
which case safemode is disabled. See the
|
|
||||||
.Fl s
|
|
||||||
option to disable safemode prompting.
|
|
||||||
.Pp
|
|
||||||
If one of the configuration files has a line
|
|
||||||
.Dl "default_safemode = no;"
|
|
||||||
safemode is disabled by default.
|
|
||||||
The
|
|
||||||
.Fl u
|
|
||||||
option's effect is negated in that case, i. e. it
|
|
||||||
.Em enables
|
|
||||||
safemode.
|
|
||||||
.Pp
|
|
||||||
Safemode is always disabled for AVR32, Xmega and TPI devices.
|
|
||||||
.It Xo Fl U Ar memtype Ns
|
.It Xo Fl U Ar memtype Ns
|
||||||
.Ar \&: Ns Ar op Ns
|
.Ar \&: Ns Ar op Ns
|
||||||
.Ar \&: Ns Ar filename Ns
|
.Ar \&: Ns Ar filename Ns
|
||||||
@@ -838,7 +809,7 @@ Display the device signature bytes.
|
|||||||
Enter direct SPI mode. The
|
Enter direct SPI mode. The
|
||||||
.Em pgmled
|
.Em pgmled
|
||||||
pin acts as slave select.
|
pin acts as slave select.
|
||||||
.Em Only supported on parallel bitbang programmers.
|
.Em Only supported on parallel bitbang programmers, and partially by USBtiny.
|
||||||
.It Ar part
|
.It Ar part
|
||||||
Display the current part settings and parameters. Includes chip
|
Display the current part settings and parameters. Includes chip
|
||||||
specific information including all memory types supported by the
|
specific information including all memory types supported by the
|
||||||
@@ -1030,6 +1001,12 @@ only if your
|
|||||||
.Ar AVR910
|
.Ar AVR910
|
||||||
programmer creates errors during initial sequence.
|
programmer creates errors during initial sequence.
|
||||||
.El
|
.El
|
||||||
|
.It Ar Arduino
|
||||||
|
.Bl -tag -offset indent -width indent
|
||||||
|
.It Ar attemps[=<1..99>]
|
||||||
|
Specify how many connection retry attemps to perform before exiting.
|
||||||
|
Defaults to 10 if not specified.
|
||||||
|
.El
|
||||||
.It Ar buspirate
|
.It Ar buspirate
|
||||||
.Bl -tag -offset indent -width indent
|
.Bl -tag -offset indent -width indent
|
||||||
.It Ar reset={cs,aux,aux2}
|
.It Ar reset={cs,aux,aux2}
|
||||||
@@ -1186,6 +1163,23 @@ line, and the XBee DIN pin (pin 3) must be connected to the MCU's
|
|||||||
.Ql TXD
|
.Ql TXD
|
||||||
line.
|
line.
|
||||||
.El
|
.El
|
||||||
|
.It Ar STK500
|
||||||
|
.Bl -tag -offset indent -width indent
|
||||||
|
.It Ar attemps[=<1..99>]
|
||||||
|
Specify how many connection retry attemps to perform before exiting.
|
||||||
|
Defaults to 10 if not specified.
|
||||||
|
.El
|
||||||
|
.It Ar serialupdi
|
||||||
|
Extended parameters:
|
||||||
|
.Bl -tag -offset indent -width indent
|
||||||
|
.It Ar rtsdtr=low|high
|
||||||
|
Forces RTS/DTR lines to assume low or high state during the whole
|
||||||
|
programming session. Some programmers might use this signal to
|
||||||
|
indicate UPDI programming state, but this is strictly hardware
|
||||||
|
specific.
|
||||||
|
.Pp
|
||||||
|
When not provided, driver/OS default value will be used.
|
||||||
|
.El
|
||||||
.El
|
.El
|
||||||
.Sh FILES
|
.Sh FILES
|
||||||
.Bl -tag -offset indent -width /dev/ppi0XXX
|
.Bl -tag -offset indent -width /dev/ppi0XXX
|
||||||
@@ -1256,7 +1250,7 @@ This man page by
|
|||||||
.el Joerg Wunsch.
|
.el Joerg Wunsch.
|
||||||
.Sh BUGS
|
.Sh BUGS
|
||||||
Please report bugs via
|
Please report bugs via
|
||||||
.Dl "http://savannah.nongnu.org/bugs/?group=avrdude" .
|
.Dl "https://github.com/avrdudes/avrdude/issues"
|
||||||
.Pp
|
.Pp
|
||||||
The JTAG ICE programmers currently cannot write to the flash ROM
|
The JTAG ICE programmers currently cannot write to the flash ROM
|
||||||
one byte at a time.
|
one byte at a time.
|
||||||
@@ -1273,6 +1267,9 @@ The USBasp and USBtinyISP drivers do not offer any option to distinguish multipl
|
|||||||
devices connected simultaneously, so effectively only a single device
|
devices connected simultaneously, so effectively only a single device
|
||||||
is supported.
|
is supported.
|
||||||
.Pp
|
.Pp
|
||||||
|
Slave Select must be externally held low for direct SPI when
|
||||||
|
using USBtinyISP, and send must be a multiple of four bytes.
|
||||||
|
.Pp
|
||||||
The avrftdi driver allows one to select specific devices using any combination of vid,pid
|
The avrftdi driver allows one to select specific devices using any combination of vid,pid
|
||||||
serial number (usbsn) vendor description (usbvendoror part description (usbproduct)
|
serial number (usbsn) vendor description (usbvendoror part description (usbproduct)
|
||||||
as seen with lsusb or whatever tool used to view USB device information. Multiple
|
as seen with lsusb or whatever tool used to view USB device information. Multiple
|
||||||
|
|||||||
2231
src/avrdude.conf.in
2231
src/avrdude.conf.in
File diff suppressed because it is too large
Load Diff
@@ -103,11 +103,28 @@ avrftdi_tpi_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||||||
|
|
||||||
#define TPI_PARITY_MASK 0x2000
|
#define TPI_PARITY_MASK 0x2000
|
||||||
|
|
||||||
|
static inline int count1s(unsigned int x)
|
||||||
|
{
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
return __builtin_popcount(x);
|
||||||
|
#else
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
while (x)
|
||||||
|
{
|
||||||
|
count += x & 1;
|
||||||
|
x >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static uint16_t
|
static uint16_t
|
||||||
tpi_byte2frame(uint8_t byte)
|
tpi_byte2frame(uint8_t byte)
|
||||||
{
|
{
|
||||||
uint16_t frame = 0xc00f;
|
uint16_t frame = 0xc00f;
|
||||||
int parity = __builtin_popcount(byte) & 1;
|
int parity = count1s(byte) & 1;
|
||||||
|
|
||||||
frame |= ((byte << 5) & 0x1fe0);
|
frame |= ((byte << 5) & 0x1fe0);
|
||||||
|
|
||||||
@@ -123,7 +140,7 @@ tpi_frame2byte(uint16_t frame, uint8_t * byte)
|
|||||||
/* drop idle and start bit(s) */
|
/* drop idle and start bit(s) */
|
||||||
*byte = (frame >> 5) & 0xff;
|
*byte = (frame >> 5) & 0xff;
|
||||||
|
|
||||||
int parity = __builtin_popcount(*byte) & 1;
|
int parity = count1s(*byte) & 1;
|
||||||
int parity_rcvd = (frame & TPI_PARITY_MASK) ? 1 : 0;
|
int parity_rcvd = (frame & TPI_PARITY_MASK) ? 1 : 0;
|
||||||
|
|
||||||
return parity != parity_rcvd;
|
return parity != parity_rcvd;
|
||||||
|
|||||||
223
src/avrpart.c
223
src/avrpart.c
@@ -23,6 +23,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "ac_cfg.h"
|
||||||
#include "avrdude.h"
|
#include "avrdude.h"
|
||||||
#include "libavrdude.h"
|
#include "libavrdude.h"
|
||||||
|
|
||||||
@@ -259,6 +260,21 @@ AVRMEM * avr_new_memtype(void)
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AVRMEM_ALIAS * avr_new_memalias(void)
|
||||||
|
{
|
||||||
|
AVRMEM_ALIAS * m;
|
||||||
|
|
||||||
|
m = (AVRMEM_ALIAS *)malloc(sizeof(*m));
|
||||||
|
if (m == NULL) {
|
||||||
|
avrdude_message(MSG_INFO, "avr_new_memalias(): out of memory\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(m, 0, sizeof(*m));
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate and initialize memory buffers for each of the device's
|
* Allocate and initialize memory buffers for each of the device's
|
||||||
@@ -325,6 +341,17 @@ AVRMEM * avr_dup_mem(AVRMEM * m)
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AVRMEM_ALIAS * avr_dup_memalias(AVRMEM_ALIAS * m)
|
||||||
|
{
|
||||||
|
AVRMEM_ALIAS * n;
|
||||||
|
|
||||||
|
n = avr_new_memalias();
|
||||||
|
|
||||||
|
*n = *m;
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
void avr_free_mem(AVRMEM * m)
|
void avr_free_mem(AVRMEM * m)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -347,7 +374,36 @@ void avr_free_mem(AVRMEM * m)
|
|||||||
free(m);
|
free(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
AVRMEM * avr_locate_mem(AVRPART * p, char * desc)
|
void avr_free_memalias(AVRMEM_ALIAS * m)
|
||||||
|
{
|
||||||
|
free(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
AVRMEM_ALIAS * avr_locate_memalias(AVRPART * p, char * desc)
|
||||||
|
{
|
||||||
|
AVRMEM_ALIAS * m, * match;
|
||||||
|
LNODEID ln;
|
||||||
|
int matches;
|
||||||
|
int l;
|
||||||
|
|
||||||
|
l = strlen(desc);
|
||||||
|
matches = 0;
|
||||||
|
match = NULL;
|
||||||
|
for (ln=lfirst(p->mem_alias); ln; ln=lnext(ln)) {
|
||||||
|
m = ldata(ln);
|
||||||
|
if (strncmp(desc, m->desc, l) == 0) {
|
||||||
|
match = m;
|
||||||
|
matches++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matches == 1)
|
||||||
|
return match;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
AVRMEM * avr_locate_mem_noalias(AVRPART * p, char * desc)
|
||||||
{
|
{
|
||||||
AVRMEM * m, * match;
|
AVRMEM * m, * match;
|
||||||
LNODEID ln;
|
LNODEID ln;
|
||||||
@@ -372,30 +428,88 @@ AVRMEM * avr_locate_mem(AVRPART * p, char * desc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void avr_mem_display(const char * prefix, FILE * f, AVRMEM * m, int type,
|
AVRMEM * avr_locate_mem(AVRPART * p, char * desc)
|
||||||
int verbose)
|
|
||||||
{
|
{
|
||||||
|
AVRMEM * m, * match;
|
||||||
|
AVRMEM_ALIAS * alias;
|
||||||
|
LNODEID ln;
|
||||||
|
int matches;
|
||||||
|
int l;
|
||||||
|
|
||||||
|
l = strlen(desc);
|
||||||
|
matches = 0;
|
||||||
|
match = NULL;
|
||||||
|
for (ln=lfirst(p->mem); ln; ln=lnext(ln)) {
|
||||||
|
m = ldata(ln);
|
||||||
|
if (strncmp(desc, m->desc, l) == 0) {
|
||||||
|
match = m;
|
||||||
|
matches++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matches == 1)
|
||||||
|
return match;
|
||||||
|
|
||||||
|
/* not yet found: look for matching alias name */
|
||||||
|
alias = avr_locate_memalias(p, desc);
|
||||||
|
if (alias != NULL)
|
||||||
|
return alias->aliased_mem;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
AVRMEM_ALIAS * avr_find_memalias(AVRPART * p, AVRMEM * m_orig)
|
||||||
|
{
|
||||||
|
AVRMEM_ALIAS * m;
|
||||||
|
LNODEID ln;
|
||||||
|
|
||||||
|
for (ln=lfirst(p->mem_alias); ln; ln=lnext(ln)) {
|
||||||
|
m = ldata(ln);
|
||||||
|
if (m->aliased_mem == m_orig)
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void avr_mem_display(const char * prefix, FILE * f, AVRMEM * m, AVRPART * p,
|
||||||
|
int type, int verbose)
|
||||||
|
{
|
||||||
|
static unsigned int prev_mem_offset, prev_mem_size;
|
||||||
int i, j;
|
int i, j;
|
||||||
char * optr;
|
char * optr;
|
||||||
|
|
||||||
if (m == NULL) {
|
if (m == NULL) {
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"%s Block Poll Page Polled\n"
|
"%s Block Poll Page Polled\n"
|
||||||
"%sMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack\n"
|
"%sMemory Type Alias Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack\n"
|
||||||
"%s----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------\n",
|
"%s----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------\n",
|
||||||
prefix, prefix, prefix);
|
prefix, prefix, prefix);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (verbose > 2) {
|
if (verbose > 2) {
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"%s Block Poll Page Polled\n"
|
"%s Block Poll Page Polled\n"
|
||||||
"%sMemory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack\n"
|
"%sMemory Type Alias Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack\n"
|
||||||
"%s----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------\n",
|
"%s----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------\n",
|
||||||
prefix, prefix, prefix);
|
prefix, prefix, prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Only print memory section if the previous section printed isn't identical
|
||||||
|
if(prev_mem_offset != m->offset || prev_mem_size != m->size || (strcmp(p->family_id, "") == 0)) {
|
||||||
|
prev_mem_offset = m->offset;
|
||||||
|
prev_mem_size = m->size;
|
||||||
|
AVRMEM_ALIAS *ap = avr_find_memalias(p, m);
|
||||||
|
/* Show alias if the current and the next memory section has the same offset
|
||||||
|
and size, we're not out of band and a family_id is present */
|
||||||
|
char * mem_desc_alias = ap? ap->desc: "";
|
||||||
fprintf(f,
|
fprintf(f,
|
||||||
"%s%-11s %4d %5d %5d %4d %-6s %6d %4d %6d %5d %5d 0x%02x 0x%02x\n",
|
"%s%-11s %-8s %4d %5d %5d %4d %-6s %6d %4d %6d %5d %5d 0x%02x 0x%02x\n",
|
||||||
prefix, m->desc, m->mode, m->delay, m->blocksize, m->pollindex,
|
prefix,
|
||||||
|
m->desc,
|
||||||
|
mem_desc_alias,
|
||||||
|
m->mode, m->delay, m->blocksize, m->pollindex,
|
||||||
m->paged ? "yes" : "no",
|
m->paged ? "yes" : "no",
|
||||||
m->size,
|
m->size,
|
||||||
m->page_size,
|
m->page_size,
|
||||||
@@ -404,6 +518,7 @@ void avr_mem_display(const char * prefix, FILE * f, AVRMEM * m, int type,
|
|||||||
m->max_write_delay,
|
m->max_write_delay,
|
||||||
m->readback[0],
|
m->readback[0],
|
||||||
m->readback[1]);
|
m->readback[1]);
|
||||||
|
}
|
||||||
if (verbose > 4) {
|
if (verbose > 4) {
|
||||||
avrdude_message(MSG_TRACE2, "%s Memory Ops:\n"
|
avrdude_message(MSG_TRACE2, "%s Memory Ops:\n"
|
||||||
"%s Oeration Inst Bit Bit Type Bitno Value\n"
|
"%s Oeration Inst Bit Bit Type Bitno Value\n"
|
||||||
@@ -460,6 +575,7 @@ AVRPART * avr_new_part(void)
|
|||||||
p->ocdrev = -1;
|
p->ocdrev = -1;
|
||||||
|
|
||||||
p->mem = lcreat(NULL, 0);
|
p->mem = lcreat(NULL, 0);
|
||||||
|
p->mem_alias = lcreat(NULL, 0);
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@@ -468,19 +584,35 @@ AVRPART * avr_new_part(void)
|
|||||||
AVRPART * avr_dup_part(AVRPART * d)
|
AVRPART * avr_dup_part(AVRPART * d)
|
||||||
{
|
{
|
||||||
AVRPART * p;
|
AVRPART * p;
|
||||||
LISTID save;
|
LISTID save, save2;
|
||||||
LNODEID ln;
|
LNODEID ln, ln2;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
p = avr_new_part();
|
p = avr_new_part();
|
||||||
save = p->mem;
|
save = p->mem;
|
||||||
|
save2 = p->mem_alias;
|
||||||
|
|
||||||
*p = *d;
|
*p = *d;
|
||||||
|
|
||||||
p->mem = save;
|
p->mem = save;
|
||||||
|
p->mem_alias = save2;
|
||||||
|
|
||||||
for (ln=lfirst(d->mem); ln; ln=lnext(ln)) {
|
for (ln=lfirst(d->mem); ln; ln=lnext(ln)) {
|
||||||
ladd(p->mem, avr_dup_mem(ldata(ln)));
|
AVRMEM *m = ldata(ln);
|
||||||
|
AVRMEM *m2 = avr_dup_mem(m);
|
||||||
|
ladd(p->mem, m2);
|
||||||
|
// see if there is any alias for it
|
||||||
|
for (ln2=lfirst(d->mem_alias); ln2; ln2=lnext(ln2)) {
|
||||||
|
AVRMEM_ALIAS *a = ldata(ln2);
|
||||||
|
if (a->aliased_mem == m) {
|
||||||
|
// yes, duplicate it
|
||||||
|
AVRMEM_ALIAS *a2 = avr_dup_memalias(a);
|
||||||
|
// ... adjust the pointer ...
|
||||||
|
a2->aliased_mem = m2;
|
||||||
|
// ... and add to new list
|
||||||
|
ladd(p->mem_alias, a2);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < AVR_OP_MAX; i++) {
|
for (i = 0; i < AVR_OP_MAX; i++) {
|
||||||
@@ -495,6 +627,8 @@ void avr_free_part(AVRPART * d)
|
|||||||
int i;
|
int i;
|
||||||
ldestroy_cb(d->mem, (void(*)(void *))avr_free_mem);
|
ldestroy_cb(d->mem, (void(*)(void *))avr_free_mem);
|
||||||
d->mem = NULL;
|
d->mem = NULL;
|
||||||
|
ldestroy_cb(d->mem_alias, (void(*)(void *))avr_free_memalias);
|
||||||
|
d->mem_alias = NULL;
|
||||||
for(i=0;i<sizeof(d->op)/sizeof(d->op[0]);i++)
|
for(i=0;i<sizeof(d->op)/sizeof(d->op[0]);i++)
|
||||||
{
|
{
|
||||||
if (d->op[i] != NULL)
|
if (d->op[i] != NULL)
|
||||||
@@ -621,40 +755,33 @@ void avr_display(FILE * f, AVRPART * p, const char * prefix, int verbose)
|
|||||||
LNODEID ln;
|
LNODEID ln;
|
||||||
AVRMEM * m;
|
AVRMEM * m;
|
||||||
|
|
||||||
fprintf(f,
|
fprintf( f, "%sAVR Part : %s\n", prefix, p->desc);
|
||||||
"%sAVR Part : %s\n"
|
if (p->chip_erase_delay)
|
||||||
"%sChip Erase delay : %d us\n"
|
fprintf(f, "%sChip Erase delay : %d us\n", prefix, p->chip_erase_delay);
|
||||||
"%sPAGEL : P%02X\n"
|
if (p->pagel)
|
||||||
"%sBS2 : P%02X\n"
|
fprintf(f, "%sPAGEL : P%02X\n", prefix, p->pagel);
|
||||||
"%sRESET disposition : %s\n"
|
if (p->bs2)
|
||||||
"%sRETRY pulse : %s\n"
|
fprintf(f, "%sBS2 : P%02X\n", prefix, p->bs2);
|
||||||
"%sserial program mode : %s\n"
|
fprintf( f, "%sRESET disposition : %s\n", prefix, reset_disp_str(p->reset_disposition));
|
||||||
"%sparallel program mode : %s\n"
|
fprintf( f, "%sRETRY pulse : %s\n", prefix, avr_pin_name(p->retry_pulse));
|
||||||
"%sTimeout : %d\n"
|
fprintf( f, "%sSerial program mode : %s\n", prefix, (p->flags & AVRPART_SERIALOK) ? "yes" : "no");
|
||||||
"%sStabDelay : %d\n"
|
fprintf( f, "%sParallel program mode : %s\n", prefix, (p->flags & AVRPART_PARALLELOK) ?
|
||||||
"%sCmdexeDelay : %d\n"
|
((p->flags & AVRPART_PSEUDOPARALLEL) ? "pseudo" : "yes") : "no");
|
||||||
"%sSyncLoops : %d\n"
|
if(p->timeout)
|
||||||
"%sByteDelay : %d\n"
|
fprintf(f, "%sTimeout : %d\n", prefix, p->timeout);
|
||||||
"%sPollIndex : %d\n"
|
if(p->stabdelay)
|
||||||
"%sPollValue : 0x%02x\n"
|
fprintf(f, "%sStabDelay : %d\n", prefix, p->stabdelay);
|
||||||
"%sMemory Detail :\n\n",
|
if(p->cmdexedelay)
|
||||||
prefix, p->desc,
|
fprintf(f, "%sCmdexeDelay : %d\n", prefix, p->cmdexedelay);
|
||||||
prefix, p->chip_erase_delay,
|
if(p->synchloops)
|
||||||
prefix, p->pagel,
|
fprintf(f, "%sSyncLoops : %d\n", prefix, p->synchloops);
|
||||||
prefix, p->bs2,
|
if(p->bytedelay)
|
||||||
prefix, reset_disp_str(p->reset_disposition),
|
fprintf(f, "%sByteDelay : %d\n", prefix, p->bytedelay);
|
||||||
prefix, avr_pin_name(p->retry_pulse),
|
if(p->pollindex)
|
||||||
prefix, (p->flags & AVRPART_SERIALOK) ? "yes" : "no",
|
fprintf(f, "%sPollIndex : %d\n", prefix, p->pollindex);
|
||||||
prefix, (p->flags & AVRPART_PARALLELOK) ?
|
if(p->pollvalue)
|
||||||
((p->flags & AVRPART_PSEUDOPARALLEL) ? "pseudo" : "yes") : "no",
|
fprintf(f, "%sPollValue : 0x%02x\n", prefix, p->pollvalue);
|
||||||
prefix, p->timeout,
|
fprintf( f, "%sMemory Detail :\n\n", prefix);
|
||||||
prefix, p->stabdelay,
|
|
||||||
prefix, p->cmdexedelay,
|
|
||||||
prefix, p->synchloops,
|
|
||||||
prefix, p->bytedelay,
|
|
||||||
prefix, p->pollindex,
|
|
||||||
prefix, p->pollvalue,
|
|
||||||
prefix);
|
|
||||||
|
|
||||||
px = prefix;
|
px = prefix;
|
||||||
i = strlen(prefix) + 5;
|
i = strlen(prefix) + 5;
|
||||||
@@ -669,11 +796,11 @@ void avr_display(FILE * f, AVRPART * p, const char * prefix, int verbose)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (verbose <= 2) {
|
if (verbose <= 2) {
|
||||||
avr_mem_display(px, f, NULL, 0, verbose);
|
avr_mem_display(px, f, NULL, p, 0, verbose);
|
||||||
}
|
}
|
||||||
for (ln=lfirst(p->mem); ln; ln=lnext(ln)) {
|
for (ln=lfirst(p->mem); ln; ln=lnext(ln)) {
|
||||||
m = ldata(ln);
|
m = ldata(ln);
|
||||||
avr_mem_display(px, f, m, i, verbose);
|
avr_mem_display(px, f, m, p, i, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buf)
|
if (buf)
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ char default_programmer[MAX_STR_CONST];
|
|||||||
char default_parallel[PATH_MAX];
|
char default_parallel[PATH_MAX];
|
||||||
char default_serial[PATH_MAX];
|
char default_serial[PATH_MAX];
|
||||||
double default_bitclock;
|
double default_bitclock;
|
||||||
int default_safemode;
|
|
||||||
|
|
||||||
char string_buf[MAX_STR_CONST];
|
char string_buf[MAX_STR_CONST];
|
||||||
char *string_buf_ptr;
|
char *string_buf_ptr;
|
||||||
@@ -48,6 +47,7 @@ AVRPART * current_part;
|
|||||||
AVRMEM * current_mem;
|
AVRMEM * current_mem;
|
||||||
LISTID part_list;
|
LISTID part_list;
|
||||||
LISTID programmers;
|
LISTID programmers;
|
||||||
|
bool is_alias;
|
||||||
|
|
||||||
int lineno;
|
int lineno;
|
||||||
const char * infile;
|
const char * infile;
|
||||||
@@ -73,6 +73,7 @@ int init_config(void)
|
|||||||
current_mem = NULL;
|
current_mem = NULL;
|
||||||
part_list = lcreat(NULL, 0);
|
part_list = lcreat(NULL, 0);
|
||||||
programmers = lcreat(NULL, 0);
|
programmers = lcreat(NULL, 0);
|
||||||
|
is_alias = false;
|
||||||
|
|
||||||
lineno = 1;
|
lineno = 1;
|
||||||
infile = NULL;
|
infile = NULL;
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ extern int lineno;
|
|||||||
extern const char * infile;
|
extern const char * infile;
|
||||||
extern LISTID string_list;
|
extern LISTID string_list;
|
||||||
extern LISTID number_list;
|
extern LISTID number_list;
|
||||||
|
extern bool is_alias; // current entry is alias
|
||||||
|
|
||||||
|
|
||||||
#if !defined(HAS_YYSTYPE)
|
#if !defined(HAS_YYSTYPE)
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ static int pin_name;
|
|||||||
%token K_PAGE_SIZE
|
%token K_PAGE_SIZE
|
||||||
%token K_PAGED
|
%token K_PAGED
|
||||||
|
|
||||||
|
%token K_ALIAS
|
||||||
%token K_BAUDRATE
|
%token K_BAUDRATE
|
||||||
%token K_BS2
|
%token K_BS2
|
||||||
%token K_BUFF
|
%token K_BUFF
|
||||||
@@ -77,7 +78,6 @@ static int pin_name;
|
|||||||
%token K_DEFAULT_BITCLOCK
|
%token K_DEFAULT_BITCLOCK
|
||||||
%token K_DEFAULT_PARALLEL
|
%token K_DEFAULT_PARALLEL
|
||||||
%token K_DEFAULT_PROGRAMMER
|
%token K_DEFAULT_PROGRAMMER
|
||||||
%token K_DEFAULT_SAFEMODE
|
|
||||||
%token K_DEFAULT_SERIAL
|
%token K_DEFAULT_SERIAL
|
||||||
%token K_DESC
|
%token K_DESC
|
||||||
%token K_FAMILY_ID
|
%token K_FAMILY_ID
|
||||||
@@ -257,14 +257,6 @@ def :
|
|||||||
K_DEFAULT_BITCLOCK TKN_EQUAL number_real TKN_SEMI {
|
K_DEFAULT_BITCLOCK TKN_EQUAL number_real TKN_SEMI {
|
||||||
default_bitclock = $3->value.number_real;
|
default_bitclock = $3->value.number_real;
|
||||||
free_token($3);
|
free_token($3);
|
||||||
} |
|
|
||||||
|
|
||||||
K_DEFAULT_SAFEMODE TKN_EQUAL yesno TKN_SEMI {
|
|
||||||
if ($3->primary == K_YES)
|
|
||||||
default_safemode = 1;
|
|
||||||
else if ($3->primary == K_NO)
|
|
||||||
default_safemode = 0;
|
|
||||||
free_token($3);
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -294,7 +286,7 @@ prog_def :
|
|||||||
lrmv_d(programmers, existing_prog);
|
lrmv_d(programmers, existing_prog);
|
||||||
pgm_free(existing_prog);
|
pgm_free(existing_prog);
|
||||||
}
|
}
|
||||||
PUSH(programmers, current_prog);
|
LISTADD(programmers, current_prog);
|
||||||
// pgm_fill_old_pins(current_prog); // TODO to be removed if old pin data no longer needed
|
// pgm_fill_old_pins(current_prog); // TODO to be removed if old pin data no longer needed
|
||||||
// pgm_display_generic(current_prog, id);
|
// pgm_display_generic(current_prog, id);
|
||||||
current_prog = NULL;
|
current_prog = NULL;
|
||||||
@@ -387,7 +379,7 @@ part_def :
|
|||||||
lrmv_d(part_list, existing_part);
|
lrmv_d(part_list, existing_part);
|
||||||
avr_free_part(existing_part);
|
avr_free_part(existing_part);
|
||||||
}
|
}
|
||||||
PUSH(part_list, current_part);
|
LISTADD(part_list, current_part);
|
||||||
current_part = NULL;
|
current_part = NULL;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@@ -1248,12 +1240,17 @@ part_parm :
|
|||||||
{
|
{
|
||||||
AVRMEM * existing_mem;
|
AVRMEM * existing_mem;
|
||||||
|
|
||||||
existing_mem = avr_locate_mem(current_part, current_mem->desc);
|
existing_mem = avr_locate_mem_noalias(current_part, current_mem->desc);
|
||||||
if (existing_mem != NULL) {
|
if (existing_mem != NULL) {
|
||||||
lrmv_d(current_part->mem, existing_mem);
|
lrmv_d(current_part->mem, existing_mem);
|
||||||
avr_free_mem(existing_mem);
|
avr_free_mem(existing_mem);
|
||||||
}
|
}
|
||||||
|
if (is_alias) {
|
||||||
|
avr_free_mem(current_mem); // alias mem has been already entered below
|
||||||
|
is_alias = false;
|
||||||
|
} else {
|
||||||
ladd(current_part->mem, current_mem);
|
ladd(current_part->mem, current_mem);
|
||||||
|
}
|
||||||
current_mem = NULL;
|
current_mem = NULL;
|
||||||
} |
|
} |
|
||||||
|
|
||||||
@@ -1290,6 +1287,7 @@ yesno :
|
|||||||
|
|
||||||
mem_specs :
|
mem_specs :
|
||||||
mem_spec TKN_SEMI |
|
mem_spec TKN_SEMI |
|
||||||
|
mem_alias TKN_SEMI |
|
||||||
mem_specs mem_spec TKN_SEMI
|
mem_specs mem_spec TKN_SEMI
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -1419,6 +1417,38 @@ mem_spec :
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
mem_alias :
|
||||||
|
K_ALIAS TKN_STRING
|
||||||
|
{
|
||||||
|
AVRMEM * existing_mem;
|
||||||
|
|
||||||
|
existing_mem = avr_locate_mem(current_part, $2->value.string);
|
||||||
|
if (existing_mem == NULL) {
|
||||||
|
yyerror("%s alias to non-existent memory %s",
|
||||||
|
current_mem->desc, $2->value.string);
|
||||||
|
free_token($2);
|
||||||
|
YYABORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if this alias does already exist, drop the old one
|
||||||
|
AVRMEM_ALIAS * alias = avr_locate_memalias(current_part, current_mem->desc);
|
||||||
|
if (alias) {
|
||||||
|
lrmv_d(current_part->mem_alias, alias);
|
||||||
|
avr_free_memalias(alias);
|
||||||
|
}
|
||||||
|
|
||||||
|
is_alias = true;
|
||||||
|
alias = avr_new_memalias();
|
||||||
|
|
||||||
|
// alias->desc and current_mem->desc have the same length
|
||||||
|
// definition, thus no need to check for length here
|
||||||
|
strcpy(alias->desc, current_mem->desc);
|
||||||
|
alias->aliased_mem = existing_mem;
|
||||||
|
ladd(current_part->mem_alias, alias);
|
||||||
|
|
||||||
|
free_token($2);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
# Process this file with autoconf to produce a configure script.
|
# Process this file with autoconf to produce a configure script.
|
||||||
|
|
||||||
AC_PREREQ(2.60)
|
AC_PREREQ(2.60)
|
||||||
AC_INIT(avrdude, 6.99-20211218, avrdude-dev@nongnu.org)
|
AC_INIT(avrdude, 7.0, avrdude-dev@nongnu.org)
|
||||||
|
|
||||||
AC_CANONICAL_BUILD
|
AC_CANONICAL_BUILD
|
||||||
AC_CANONICAL_HOST
|
AC_CANONICAL_HOST
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "ac_cfg.h"
|
||||||
#include "avrdude.h"
|
#include "avrdude.h"
|
||||||
#include "libavrdude.h"
|
#include "libavrdude.h"
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ all-local: info html ps pdf
|
|||||||
html: avrdude-html/avrdude.html
|
html: avrdude-html/avrdude.html
|
||||||
|
|
||||||
avrdude-html/avrdude.html: $(srcdir)/$(info_TEXINFOS) $(GENERATED_TEXINFOS)
|
avrdude-html/avrdude.html: $(srcdir)/$(info_TEXINFOS) $(GENERATED_TEXINFOS)
|
||||||
texi2html -split_node $(srcdir)/$(info_TEXINFOS)
|
texi2html --split=node --css-include=$(srcdir)/avrdude.css $(srcdir)/$(info_TEXINFOS)
|
||||||
if [ -e ./avrdude.html -o -e ./avrdude_1.html ]; then \
|
if [ -e ./avrdude.html -o -e ./avrdude_1.html ]; then \
|
||||||
mkdir -p avrdude-html ; \
|
mkdir -p avrdude-html ; \
|
||||||
mv -f *.html avrdude-html ; \
|
mv -f *.html avrdude-html ; \
|
||||||
|
|||||||
20
src/doc/avrdude.css
Normal file
20
src/doc/avrdude.css
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
body { background-color: #ffd; }
|
||||||
|
h1 { text-shadow: .05em .05em #ccc; }
|
||||||
|
table {
|
||||||
|
border: 3px solid #ccf;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
div.smallexample {
|
||||||
|
background-color: #dfd;
|
||||||
|
border: 3px solid #cfc;
|
||||||
|
}
|
||||||
|
div.example {
|
||||||
|
background-color: #dfd;
|
||||||
|
border: 3px solid #cfc;
|
||||||
|
}
|
||||||
|
samp {
|
||||||
|
color: blue;
|
||||||
|
}
|
||||||
|
code {
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
@@ -28,9 +28,7 @@ This file documents the avrdude program.
|
|||||||
|
|
||||||
For avrdude version @value{VERSION}, @value{UPDATED}.
|
For avrdude version @value{VERSION}, @value{UPDATED}.
|
||||||
|
|
||||||
Copyright @copyright{} 2003, 2005 Brian Dean
|
Copyright @copyright{} Brian Dean, J@"org Wunsch
|
||||||
|
|
||||||
Copyright @copyright{} 2006 - 2021 J@"org Wunsch
|
|
||||||
|
|
||||||
Permission is granted to make and distribute verbatim copies of
|
Permission is granted to make and distribute verbatim copies of
|
||||||
this manual provided the copyright notice and this permission notice
|
this manual provided the copyright notice and this permission notice
|
||||||
@@ -64,13 +62,10 @@ the terms of the GNU Free Documentation License (FDL), version 1.3.
|
|||||||
@author by Brian S. Dean
|
@author by Brian S. Dean
|
||||||
|
|
||||||
@page
|
@page
|
||||||
Send comments on AVRDUDE to @w{@email{avrdude-dev@@nongnu.org}}.
|
|
||||||
|
|
||||||
Use @uref{http://savannah.nongnu.org/bugs/?group=avrdude} to report bugs.
|
Use @uref{https://github.com/avrdudes/avrdude/issues} to report bugs and ask questions.
|
||||||
|
|
||||||
Copyright @copyright{} 2003,2005 Brian S. Dean
|
Copyright @copyright{} Brian S. Dean, J@"org Wunsch
|
||||||
|
|
||||||
Copyright @copyright{} 2006 - 2013 J@"org Wunsch
|
|
||||||
@sp 2
|
@sp 2
|
||||||
|
|
||||||
Permission is granted to make and distribute verbatim copies of
|
Permission is granted to make and distribute verbatim copies of
|
||||||
@@ -102,13 +97,9 @@ programs to Atmel AVR microcontrollers.
|
|||||||
|
|
||||||
For avrdude version @value{VERSION}, @value{UPDATED}.
|
For avrdude version @value{VERSION}, @value{UPDATED}.
|
||||||
|
|
||||||
Send comments on AVRDUDE to @w{@email{avrdude-dev@@nongnu.org}}.
|
Use @uref{https://github.com/avrdudes/avrdude/issues} to report bugs and ask questions.
|
||||||
|
|
||||||
Use @uref{http://savannah.nongnu.org/bugs/?group=avrdude} to report bugs.
|
Copyright @copyright{} Brian S. Dean, J@"org Wunsch
|
||||||
|
|
||||||
Copyright @copyright{} 2003,2005 Brian S. Dean
|
|
||||||
|
|
||||||
Copyright @copyright{} 2006 J@"org Wunsch
|
|
||||||
@end ifinfo
|
@end ifinfo
|
||||||
|
|
||||||
@menu
|
@menu
|
||||||
@@ -119,6 +110,7 @@ Copyright @copyright{} 2006 J@"org Wunsch
|
|||||||
* Programmer Specific Information::
|
* Programmer Specific Information::
|
||||||
* Platform Dependent Information::
|
* Platform Dependent Information::
|
||||||
* Troubleshooting::
|
* Troubleshooting::
|
||||||
|
* Index::
|
||||||
@end menu
|
@end menu
|
||||||
|
|
||||||
@c
|
@c
|
||||||
@@ -127,7 +119,7 @@ Copyright @copyright{} 2006 J@"org Wunsch
|
|||||||
@node Introduction, Command Line Options, Top, Top
|
@node Introduction, Command Line Options, Top, Top
|
||||||
@comment node-name, next, previous, up
|
@comment node-name, next, previous, up
|
||||||
@chapter Introduction
|
@chapter Introduction
|
||||||
@cindex introduction
|
@cindex Introduction
|
||||||
|
|
||||||
AVRDUDE - AVR Downloader Uploader - is a program for downloading and
|
AVRDUDE - AVR Downloader Uploader - is a program for downloading and
|
||||||
uploading the on-chip memories of Atmel's AVR microcontrollers. It can
|
uploading the on-chip memories of Atmel's AVR microcontrollers. It can
|
||||||
@@ -145,6 +137,8 @@ from the contents of a file, while interactive mode is useful for
|
|||||||
exploring memory contents, modifying individual bytes of eeprom,
|
exploring memory contents, modifying individual bytes of eeprom,
|
||||||
programming fuse/lock bits, etc.
|
programming fuse/lock bits, etc.
|
||||||
|
|
||||||
|
@cindex Programmers supported
|
||||||
|
|
||||||
AVRDUDE supports the following basic programmer types: Atmel's STK500,
|
AVRDUDE supports the following basic programmer types: Atmel's STK500,
|
||||||
Atmel's AVRISP and AVRISP mkII devices,
|
Atmel's AVRISP and AVRISP mkII devices,
|
||||||
Atmel's STK600,
|
Atmel's STK600,
|
||||||
@@ -177,7 +171,7 @@ be taken about voltage level compatibility. Also, although not strictly
|
|||||||
required, it is strongly advisable to protect the GPIO pins from
|
required, it is strongly advisable to protect the GPIO pins from
|
||||||
overcurrent situations in some way. The simplest would be to just put
|
overcurrent situations in some way. The simplest would be to just put
|
||||||
some resistors in series or better yet use a 3-state buffer driver like
|
some resistors in series or better yet use a 3-state buffer driver like
|
||||||
the 74HC244. Have a look at http://kolev.info/avrdude-linuxgpio for a more
|
the 74HC244. Have a look at http://kolev.info/blog/2013/01/06/avrdude-linuxgpio/ for a more
|
||||||
detailed tutorial about using this programmer type.
|
detailed tutorial about using this programmer type.
|
||||||
|
|
||||||
Under a Linux installation with direct access to the SPI bus and GPIO
|
Under a Linux installation with direct access to the SPI bus and GPIO
|
||||||
@@ -286,7 +280,11 @@ be performed.
|
|||||||
|
|
||||||
The Arduino (which is very similar to the STK500 1.x) is supported via
|
The Arduino (which is very similar to the STK500 1.x) is supported via
|
||||||
its own programmer type specification ``arduino''. This programmer works for
|
its own programmer type specification ``arduino''. This programmer works for
|
||||||
the Arduino Uno Rev3.
|
the Arduino Uno Rev3 or any AVR that runs the Optiboot bootloader.
|
||||||
|
The number of connection retry attempts can be specified as an
|
||||||
|
extended parameter. See the section on
|
||||||
|
@emph{extended parameters}
|
||||||
|
below for details.
|
||||||
|
|
||||||
The BusPirate is a versatile tool that can also be used as an AVR programmer.
|
The BusPirate is a versatile tool that can also be used as an AVR programmer.
|
||||||
A single BusPirate can be connected to up to 3 independent AVRs. See
|
A single BusPirate can be connected to up to 3 independent AVRs. See
|
||||||
@@ -310,7 +308,7 @@ Board'', thus the name @code{pkobn_updi}.
|
|||||||
SerialUPDI programmer implementation is based on Microchip's
|
SerialUPDI programmer implementation is based on Microchip's
|
||||||
@emph{pymcuprog} (@url{https://github.com/microchip-pic-avr-tools/pymcuprog})
|
@emph{pymcuprog} (@url{https://github.com/microchip-pic-avr-tools/pymcuprog})
|
||||||
utility, but it also contains some performance improvements included in
|
utility, but it also contains some performance improvements included in
|
||||||
Spence Kohde's @emph{DxCore} Arduino core (@url{https://github.com/SpenceKonde/DxCore}).
|
Spence Konde's @emph{DxCore} Arduino core (@url{https://github.com/SpenceKonde/DxCore}).
|
||||||
In a nutshell, this programmer consists of simple USB->UART adapter, diode
|
In a nutshell, this programmer consists of simple USB->UART adapter, diode
|
||||||
and couple of resistors. It uses serial connection to provide UPDI interface.
|
and couple of resistors. It uses serial connection to provide UPDI interface.
|
||||||
@xref{SerialUPDI programmer} for more details and known issues.
|
@xref{SerialUPDI programmer} for more details and known issues.
|
||||||
@@ -341,6 +339,7 @@ below for Teensy specific options.
|
|||||||
@c Node
|
@c Node
|
||||||
@c
|
@c
|
||||||
@node History, , Introduction, Introduction
|
@node History, , Introduction, Introduction
|
||||||
|
@cindex History
|
||||||
@section History and Credits
|
@section History and Credits
|
||||||
|
|
||||||
AVRDUDE was written by Brian S. Dean under the name of AVRPROG to run on
|
AVRDUDE was written by Brian S. Dean under the name of AVRPROG to run on
|
||||||
@@ -349,13 +348,15 @@ AVRDUDE when interest grew in a Windows port of the software so that the
|
|||||||
name did not conflict with AVRPROG.EXE which is the name of Atmel's
|
name did not conflict with AVRPROG.EXE which is the name of Atmel's
|
||||||
Windows programming software.
|
Windows programming software.
|
||||||
|
|
||||||
The AVRDUDE source now resides in the public CVS repository on
|
For many years, the AVRDUDE source resided in public repositories on
|
||||||
savannah.gnu.org (@url{http://savannah.gnu.org/projects/avrdude/}),
|
savannah.nongnu.org,
|
||||||
where it continues to be enhanced and ported to other systems. In
|
where it continued to be enhanced and ported to other systems. In
|
||||||
addition to FreeBSD, AVRDUDE now runs on Linux and Windows. The
|
addition to FreeBSD, AVRDUDE now runs on Linux and Windows. The
|
||||||
developers behind the porting effort primarily were Ted Roth, Eric
|
developers behind the porting effort primarily were Ted Roth, Eric
|
||||||
Weddington, and Joerg Wunsch.
|
Weddington, and Joerg Wunsch.
|
||||||
|
|
||||||
|
In 2022, the project moved to Github (@url{https://github.com/avrdudes/avrdude/}).
|
||||||
|
|
||||||
And in the spirit of many open source projects, this manual also draws
|
And in the spirit of many open source projects, this manual also draws
|
||||||
on the work of others. The initial revision was composed of parts of
|
on the work of others. The initial revision was composed of parts of
|
||||||
the original Unix manual page written by Joerg Wunsch, the original web
|
the original Unix manual page written by Joerg Wunsch, the original web
|
||||||
@@ -370,7 +371,6 @@ Roth.
|
|||||||
@c
|
@c
|
||||||
@node Command Line Options, Terminal Mode Operation, Introduction, Top
|
@node Command Line Options, Terminal Mode Operation, Introduction, Top
|
||||||
@chapter Command Line Options
|
@chapter Command Line Options
|
||||||
@cindex options
|
|
||||||
|
|
||||||
@menu
|
@menu
|
||||||
* Option Descriptions::
|
* Option Descriptions::
|
||||||
@@ -382,6 +382,7 @@ Roth.
|
|||||||
@c Node
|
@c Node
|
||||||
@c
|
@c
|
||||||
@node Option Descriptions, Programmers accepting extended parameters, Command Line Options, Command Line Options
|
@node Option Descriptions, Programmers accepting extended parameters, Command Line Options, Command Line Options
|
||||||
|
@cindex Options (command-line)
|
||||||
@section Option Descriptions
|
@section Option Descriptions
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
@@ -406,6 +407,8 @@ but it can be added to the configuration file if you have the Atmel
|
|||||||
datasheet so that you can enter the programming specifications.
|
datasheet so that you can enter the programming specifications.
|
||||||
Currently, the following MCU types are understood:
|
Currently, the following MCU types are understood:
|
||||||
|
|
||||||
|
@cindex Device support
|
||||||
|
|
||||||
@multitable @columnfractions .15 .3
|
@multitable @columnfractions .15 .3
|
||||||
@include parts.texi
|
@include parts.texi
|
||||||
@end multitable
|
@end multitable
|
||||||
@@ -457,6 +460,8 @@ file without any code changes to AVRDUDE. Simply copy an existing entry
|
|||||||
and change the pin definitions to match that of the unknown programmer.
|
and change the pin definitions to match that of the unknown programmer.
|
||||||
Currently, the following programmer ids are understood and supported:
|
Currently, the following programmer ids are understood and supported:
|
||||||
|
|
||||||
|
@cindex Programmer support
|
||||||
|
|
||||||
@multitable @columnfractions .2 .6
|
@multitable @columnfractions .2 .6
|
||||||
@include programmers.texi
|
@include programmers.texi
|
||||||
@end multitable
|
@end multitable
|
||||||
@@ -677,32 +682,6 @@ Posix systems (by now).
|
|||||||
Disable (or quell) output of the progress bar while reading or writing
|
Disable (or quell) output of the progress bar while reading or writing
|
||||||
to the device. Specify it a second time for even quieter operation.
|
to the device. Specify it a second time for even quieter operation.
|
||||||
|
|
||||||
@item -u
|
|
||||||
Disables the default behaviour of reading out the fuses three times before
|
|
||||||
programming, then verifying at the end of programming that the fuses have not
|
|
||||||
changed. If you want to change fuses you will need to specify this option,
|
|
||||||
as avrdude will see the fuses have changed (even though you wanted to) and
|
|
||||||
will change them back for your "safety". This option was designed to
|
|
||||||
prevent cases of fuse bits magically changing (usually called @emph{safemode}).
|
|
||||||
|
|
||||||
If one of the configuration files contains a line
|
|
||||||
|
|
||||||
@code{default_safemode = no;}
|
|
||||||
|
|
||||||
safemode is disabled by default.
|
|
||||||
The @option{-u} option's effect is negated in that case, i. e. it
|
|
||||||
@emph{enables} safemode.
|
|
||||||
|
|
||||||
Safemode is always disabled for AVR32, Xmega and TPI devices.
|
|
||||||
|
|
||||||
@item -s
|
|
||||||
Disable safemode prompting. When safemode discovers that one or more
|
|
||||||
fuse bits have unintentionally changed, it will prompt for
|
|
||||||
confirmation regarding whether or not it should attempt to recover the
|
|
||||||
fuse bit(s). Specifying this flag disables the prompt and assumes
|
|
||||||
that the fuse bit(s) should be recovered without asking for
|
|
||||||
confirmation first.
|
|
||||||
|
|
||||||
@item -t
|
@item -t
|
||||||
Tells AVRDUDE to enter the interactive ``terminal'' mode instead of up-
|
Tells AVRDUDE to enter the interactive ``terminal'' mode instead of up-
|
||||||
or downloading files. See below for a detailed description of the
|
or downloading files. See below for a detailed description of the
|
||||||
@@ -860,7 +839,7 @@ accepting extended parameters.
|
|||||||
@c
|
@c
|
||||||
@node Programmers accepting extended parameters, Example Command Line Invocations, Option Descriptions, Command Line Options
|
@node Programmers accepting extended parameters, Example Command Line Invocations, Option Descriptions, Command Line Options
|
||||||
@section Programmers accepting extended parameters
|
@section Programmers accepting extended parameters
|
||||||
|
@cindex @code{-x} AVR Dragon
|
||||||
@table @code
|
@table @code
|
||||||
|
|
||||||
@item JTAG ICE mkII/3
|
@item JTAG ICE mkII/3
|
||||||
@@ -877,6 +856,7 @@ Each AVR unit within the chain shifts by 4 bits.
|
|||||||
Other JTAG units might require a different bit shift count.
|
Other JTAG units might require a different bit shift count.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@cindex @code{-x} AVR910
|
||||||
@item AVR910
|
@item AVR910
|
||||||
|
|
||||||
The AVR910 programmer type accepts the following extended parameter:
|
The AVR910 programmer type accepts the following extended parameter:
|
||||||
@@ -897,6 +877,16 @@ Use
|
|||||||
programmer creates errors during initial sequence.
|
programmer creates errors during initial sequence.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@cindex @code{-x} Arduino
|
||||||
|
@item Arduino
|
||||||
|
|
||||||
|
The Arduino programmer type accepts the following extended parameter:
|
||||||
|
@table @code
|
||||||
|
@item @samp{attemps=VALUE}
|
||||||
|
Overide the default number of connection retry attempt by using @var{VALUE}.
|
||||||
|
@end table
|
||||||
|
|
||||||
|
@cindex @code{-x} Buspirate
|
||||||
@item BusPirate
|
@item BusPirate
|
||||||
|
|
||||||
The BusPirate programmer type accepts the following extended parameters:
|
The BusPirate programmer type accepts the following extended parameters:
|
||||||
@@ -986,6 +976,7 @@ The default value is 100ms. Using 10ms might work in most cases.
|
|||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@cindex @code{-x} Micronucleus bootloader
|
||||||
@item Micronucleus bootloader
|
@item Micronucleus bootloader
|
||||||
|
|
||||||
When using the Micronucleus programmer type, the
|
When using the Micronucleus programmer type, the
|
||||||
@@ -998,6 +989,7 @@ If no time-out is specified, AVRDUDE will wait indefinitely until the
|
|||||||
device is plugged in.
|
device is plugged in.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@cindex @code{-x} Teensy bootloader
|
||||||
@item Teensy bootloader
|
@item Teensy bootloader
|
||||||
|
|
||||||
When using the Teensy programmer type, the
|
When using the Teensy programmer type, the
|
||||||
@@ -1010,6 +1002,7 @@ If no time-out is specified, AVRDUDE will wait indefinitely until the
|
|||||||
device is plugged in.
|
device is plugged in.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@cindex @code{-x} Wiring
|
||||||
@item Wiring
|
@item Wiring
|
||||||
|
|
||||||
When using the Wiring programmer type, the
|
When using the Wiring programmer type, the
|
||||||
@@ -1021,6 +1014,7 @@ After performing the port open phase, AVRDUDE will wait/snooze for
|
|||||||
No toggling of DTR/RTS is performed if @var{snooze} > 0.
|
No toggling of DTR/RTS is performed if @var{snooze} > 0.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@cindex @code{-x} PICkit2
|
||||||
@item PICkit2
|
@item PICkit2
|
||||||
Connection to the PICkit2 programmer:
|
Connection to the PICkit2 programmer:
|
||||||
@multitable @columnfractions .05 .3
|
@multitable @columnfractions .05 .3
|
||||||
@@ -1041,6 +1035,7 @@ Sets the SPI clocking rate in Hz (default is 100kHz). Alternately the -B or -i o
|
|||||||
Sets the timeout for USB reads and writes in milliseconds (default is 1500 ms).
|
Sets the timeout for USB reads and writes in milliseconds (default is 1500 ms).
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@cindex @code{-x} USBasp
|
||||||
@item USBasp
|
@item USBasp
|
||||||
Extended parameters:
|
Extended parameters:
|
||||||
@table @code
|
@table @code
|
||||||
@@ -1051,6 +1046,7 @@ rather than entire chip.
|
|||||||
Only applicable to TPI devices (ATtiny 4/5/9/10/20/40).
|
Only applicable to TPI devices (ATtiny 4/5/9/10/20/40).
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@cindex @code{-x} xbee
|
||||||
@item xbee
|
@item xbee
|
||||||
Extended parameters:
|
Extended parameters:
|
||||||
@table @code
|
@table @code
|
||||||
@@ -1067,6 +1063,19 @@ The remaining two necessary XBee-to-MCU connections are not selectable
|
|||||||
the MCU's ‘TXD’ line.
|
the MCU's ‘TXD’ line.
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
@cindex @code{-x} serialupdi
|
||||||
|
@item serialupdi
|
||||||
|
Extended parameters:
|
||||||
|
@table @code
|
||||||
|
@item @samp{rtsdtr=low|high}
|
||||||
|
Forces RTS/DTR lines to assume low or high state during the whole
|
||||||
|
programming session. Some programmers might use this signal to
|
||||||
|
indicate UPDI programming state, but this is strictly hardware
|
||||||
|
specific.
|
||||||
|
|
||||||
|
When not provided, driver/OS default value will be used.
|
||||||
|
@end table
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
@page
|
@page
|
||||||
@@ -1110,8 +1119,6 @@ Reading | ################################################## | 100% 6.83s
|
|||||||
avrdude: verifying ...
|
avrdude: verifying ...
|
||||||
avrdude: 19278 bytes of flash verified
|
avrdude: 19278 bytes of flash verified
|
||||||
|
|
||||||
avrdude: safemode: Fuses OK
|
|
||||||
|
|
||||||
avrdude done. Thank you.
|
avrdude done. Thank you.
|
||||||
|
|
||||||
%
|
%
|
||||||
@@ -1139,8 +1146,6 @@ Reading | ################################################## | 100% 46.10s
|
|||||||
|
|
||||||
avrdude: writing output file "c:/diag flash.bin"
|
avrdude: writing output file "c:/diag flash.bin"
|
||||||
|
|
||||||
avrdude: safemode: Fuses OK
|
|
||||||
|
|
||||||
avrdude done. Thank you.
|
avrdude done. Thank you.
|
||||||
|
|
||||||
%
|
%
|
||||||
@@ -1261,6 +1266,7 @@ commands can be recalled and edited.
|
|||||||
@end menu
|
@end menu
|
||||||
|
|
||||||
@node Terminal Mode Commands, Terminal Mode Examples, Terminal Mode Operation, Terminal Mode Operation
|
@node Terminal Mode Commands, Terminal Mode Examples, Terminal Mode Operation, Terminal Mode Operation
|
||||||
|
@cindex Terminal Mode
|
||||||
@section Terminal Mode Commands
|
@section Terminal Mode Commands
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
@@ -1268,20 +1274,83 @@ The following commands are implemented:
|
|||||||
|
|
||||||
@table @code
|
@table @code
|
||||||
|
|
||||||
@item dump @var{memtype} @var{addr} @var{nbytes}
|
@item dump @var{memtype} [@var{start_addr} [@var{nbytes}]]
|
||||||
Read @var{nbytes} from the specified memory area, and display them in
|
Read @var{nbytes} from the specified memory area, and display them in
|
||||||
the usual hexadecimal and ASCII form.
|
the usual hexadecimal and ASCII form.
|
||||||
|
|
||||||
@item dump
|
@item dump @var{memtype} [@var{start_addr}] @dots{}
|
||||||
|
Start reading from @var{start_addr}, all the way to the last memory address.
|
||||||
|
|
||||||
|
@item dump @var{memtype}
|
||||||
Continue dumping the memory contents for another @var{nbytes} where the
|
Continue dumping the memory contents for another @var{nbytes} where the
|
||||||
previous dump command left off.
|
previous dump command left off.
|
||||||
|
|
||||||
@item write @var{memtype} @var{addr} @var{byte1} @dots{} @var{byteN}
|
@item write @var{memtype} @var{start_addr} @var{data1} @var{data2} @dots{} @var{dataN}
|
||||||
Manually program the respective memory cells, starting at address addr,
|
Manually program the respective memory cells, starting at address @var{start_addr},
|
||||||
using the values @var{byte1} through @var{byteN}. This feature is not
|
using the values @var{data1} through @var{dataN}. This feature is not
|
||||||
implemented for bank-addressed memories such as the flash memory of
|
implemented for bank-addressed memories such as the flash memory of
|
||||||
ATMega devices.
|
ATMega devices.
|
||||||
|
|
||||||
|
Items @var{dataN} can have the following formats:
|
||||||
|
|
||||||
|
@multitable @columnfractions .3 .4 .3
|
||||||
|
@item @strong{Type}
|
||||||
|
@tab @strong{Example}
|
||||||
|
@tab @strong{Size (bytes)}
|
||||||
|
|
||||||
|
@item Character
|
||||||
|
@tab @code{'A'}
|
||||||
|
@tab 1
|
||||||
|
|
||||||
|
@item Decimal integer
|
||||||
|
@tab 12345
|
||||||
|
@tab 1, 2, 4, or 8 (see below)
|
||||||
|
|
||||||
|
@item Octal integer
|
||||||
|
@tab 012345
|
||||||
|
@tab 1, 2, 4, or 8 (see below)
|
||||||
|
|
||||||
|
@item Hexadecimal integer
|
||||||
|
@tab 0x12345
|
||||||
|
@tab 1, 2, 4, or 8 (see below)
|
||||||
|
|
||||||
|
@item Float
|
||||||
|
@tab 3.1415926
|
||||||
|
@tab 4
|
||||||
|
|
||||||
|
@end multitable
|
||||||
|
|
||||||
|
Integer constants can be 1, 2, 4, or 8 bytes long.
|
||||||
|
By default, the smallest possible size will be used where
|
||||||
|
the specified number just fits into.
|
||||||
|
A specific size can be denoted by appending one of these suffixes:
|
||||||
|
|
||||||
|
@table @code
|
||||||
|
@item LL
|
||||||
|
@itemx ll
|
||||||
|
8 bytes / 64 bits
|
||||||
|
@item L
|
||||||
|
@itemx l
|
||||||
|
4 bytes / 32 bits
|
||||||
|
@item H
|
||||||
|
@itemx h
|
||||||
|
@itemx S
|
||||||
|
@itemx s
|
||||||
|
2 bytes / 16 bits
|
||||||
|
@item HH
|
||||||
|
@itemx hh
|
||||||
|
1 byte / 8 bits
|
||||||
|
@end table
|
||||||
|
|
||||||
|
Similarly, floating-point constants can have an @code{F} or @code{f}
|
||||||
|
appended, but only 32-bit floating-point values are supported.
|
||||||
|
|
||||||
|
@item write @var{memtype} @var{start_addr} @var{length} @var{data1} @var{data2} @var{dataN} @dots{}
|
||||||
|
|
||||||
|
Similar to the above, but @var{length} byte of the memory are written.
|
||||||
|
For that purpose, after writing the initial items, @var{dataN} is
|
||||||
|
replicated as many times as needed.
|
||||||
|
|
||||||
@item erase
|
@item erase
|
||||||
Perform a chip erase.
|
Perform a chip erase.
|
||||||
|
|
||||||
@@ -1297,7 +1366,9 @@ Display the device signature bytes.
|
|||||||
|
|
||||||
@item spi
|
@item spi
|
||||||
Enter direct SPI mode. The @emph{pgmled} pin acts as slave select.
|
Enter direct SPI mode. The @emph{pgmled} pin acts as slave select.
|
||||||
@emph{Only supported on parallel bitbang programmers.}
|
@emph{Only supported on parallel bitbang programmers, and partially by USBtiny.}
|
||||||
|
Slave Select must be externally held low for direct SPI when
|
||||||
|
using USBtinyISP, and send must be a multiple of four bytes.
|
||||||
|
|
||||||
@item part
|
@item part
|
||||||
Display the current part settings and parameters. Includes chip
|
Display the current part settings and parameters. Includes chip
|
||||||
@@ -1372,6 +1443,7 @@ Display the current target supply voltage and JTAG bit clock rate/period.
|
|||||||
@c Node
|
@c Node
|
||||||
@c
|
@c
|
||||||
@node Terminal Mode Examples, , Terminal Mode Commands, Terminal Mode Operation
|
@node Terminal Mode Examples, , Terminal Mode Commands, Terminal Mode Operation
|
||||||
|
@cindex Terminal Mode
|
||||||
@section Terminal Mode Examples
|
@section Terminal Mode Examples
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
@@ -1383,7 +1455,6 @@ Display part parameters, modify eeprom cells, perform a chip erase:
|
|||||||
|
|
||||||
avrdude: AVR device initialized and ready to accept instructions
|
avrdude: AVR device initialized and ready to accept instructions
|
||||||
avrdude: Device signature = 0x1e9702
|
avrdude: Device signature = 0x1e9702
|
||||||
avrdude: current erase-rewrite cycle count is 52 (if being tracked)
|
|
||||||
avrdude> part
|
avrdude> part
|
||||||
>>> part
|
>>> part
|
||||||
|
|
||||||
@@ -1445,7 +1516,6 @@ display the factory defaults, then reprogram:
|
|||||||
|
|
||||||
avrdude: AVR device initialized and ready to accept instructions
|
avrdude: AVR device initialized and ready to accept instructions
|
||||||
avrdude: Device signature = 0x1e9702
|
avrdude: Device signature = 0x1e9702
|
||||||
avrdude: current erase-rewrite cycle count is 52 (if being tracked)
|
|
||||||
avrdude> d efuse
|
avrdude> d efuse
|
||||||
>>> d efuse
|
>>> d efuse
|
||||||
0000 fd |. |
|
0000 fd |. |
|
||||||
@@ -1471,11 +1541,56 @@ avrdude>
|
|||||||
@end cartouche
|
@end cartouche
|
||||||
@end smallexample
|
@end smallexample
|
||||||
|
|
||||||
|
@smallexample
|
||||||
|
@cartouche
|
||||||
|
% avrdude -c pkobn_updi -p avr128db48 -t
|
||||||
|
|
||||||
|
Vtarget : 4.71 V
|
||||||
|
PDI/UPDI clock Xmega/megaAVR : 100 kHz
|
||||||
|
|
||||||
|
avrdude: AVR device initialized and ready to accept instructions
|
||||||
|
|
||||||
|
Reading | ################################################## | 100% 0.01s
|
||||||
|
|
||||||
|
avrdude: Device signature = 0x1e970c (probably avr128db48)
|
||||||
|
avrdude> write eeprom 0 1234567890 'A' 'V' 'R' 2.718282 "Hello World!"
|
||||||
|
>>> write eeprom 0 1234567890 'A' 'V' 'R' 2.718282 "Hello World!"
|
||||||
|
Warning: no size suffix specified for "1234567890". Writing 4 byte(s)
|
||||||
|
Info: Writing 24 bytes starting from address 0x00
|
||||||
|
|
||||||
|
avrdude> dump eeprom 0 32
|
||||||
|
>>> dump eeprom 0 32
|
||||||
|
|
||||||
|
0000 d2 02 96 49 41 56 52 55 f8 2d 40 48 65 6c 6c 6f |...IAVRU.-@@Hello|
|
||||||
|
0010 20 57 6f 72 6c 64 21 00 ff ff ff ff ff ff ff ff | World!.........|
|
||||||
|
|
||||||
|
avrdude> q
|
||||||
|
@end cartouche
|
||||||
|
@end smallexample
|
||||||
|
|
||||||
|
The following example demonstrates the second form of the @code{write}
|
||||||
|
command where the last data value provided is used to fill up the
|
||||||
|
indicated memory range.
|
||||||
|
|
||||||
|
@smallexample
|
||||||
|
@cartouche
|
||||||
|
avrdude> write eeprom 0x00 0x20 'a' 'b' 'c' 0x11 0xcafe 0x55 ...
|
||||||
|
>>> write eeprom 0x00 0x20 'a' 'b' 'c' 0x11 0xcafe 0x55 ...
|
||||||
|
|
||||||
|
avrdude> dump eeprom 0 0x30
|
||||||
|
>>> dump eeprom 0 0x30
|
||||||
|
0000 61 62 63 11 fe ca 55 55 55 55 55 55 55 55 55 55 |abc...UUUUUUUUUU|
|
||||||
|
0010 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 55 |UUUUUUUUUUUUUUUU|
|
||||||
|
0020 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
|
||||||
|
@end cartouche
|
||||||
|
@end smallexample
|
||||||
|
|
||||||
@c
|
@c
|
||||||
@c Node
|
@c Node
|
||||||
@c
|
@c
|
||||||
@node Configuration File, Programmer Specific Information, Terminal Mode Operation, Top
|
@node Configuration File, Programmer Specific Information, Terminal Mode Operation, Top
|
||||||
|
@cindex Configuration File
|
||||||
|
@cindex @code{avrdude.conf}
|
||||||
@chapter Configuration File
|
@chapter Configuration File
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
@@ -1820,9 +1935,6 @@ flash pages of the application section.
|
|||||||
|
|
||||||
Reading fuse and lock bits is fully supported.
|
Reading fuse and lock bits is fully supported.
|
||||||
|
|
||||||
Note that due to the inability to write the fuse bits, the safemode
|
|
||||||
functionality does not make sense for these boot loaders.
|
|
||||||
|
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
@c
|
@c
|
||||||
@@ -1841,6 +1953,7 @@ functionality does not make sense for these boot loaders.
|
|||||||
@c Node
|
@c Node
|
||||||
@c
|
@c
|
||||||
@node Atmel STK600, Atmel DFU bootloader using FLIP version 1, Programmer Specific Information, Programmer Specific Information
|
@node Atmel STK600, Atmel DFU bootloader using FLIP version 1, Programmer Specific Information, Programmer Specific Information
|
||||||
|
@cindex STK600
|
||||||
@section Atmel STK600
|
@section Atmel STK600
|
||||||
|
|
||||||
@c
|
@c
|
||||||
@@ -1937,6 +2050,7 @@ least 4.5 V in order to work. This can be done using
|
|||||||
@c Node
|
@c Node
|
||||||
@c
|
@c
|
||||||
@node Atmel DFU bootloader using FLIP version 1, SerialUPDI programmer , Atmel STK600, Programmer Specific Information
|
@node Atmel DFU bootloader using FLIP version 1, SerialUPDI programmer , Atmel STK600, Programmer Specific Information
|
||||||
|
@cindex DFU bootloader
|
||||||
@section Atmel DFU bootloader using FLIP version 1
|
@section Atmel DFU bootloader using FLIP version 1
|
||||||
|
|
||||||
Bootloaders using the FLIP protocol version 1 experience some very
|
Bootloaders using the FLIP protocol version 1 experience some very
|
||||||
@@ -1965,6 +2079,7 @@ versions of the bootloader.
|
|||||||
@c Node
|
@c Node
|
||||||
@c
|
@c
|
||||||
@node SerialUPDI programmer, , Atmel DFU bootloader using FLIP version 1, Programmer Specific Information
|
@node SerialUPDI programmer, , Atmel DFU bootloader using FLIP version 1, Programmer Specific Information
|
||||||
|
@cindex SerialUPDI
|
||||||
@section SerialUPDI programmer
|
@section SerialUPDI programmer
|
||||||
|
|
||||||
SerialUPDI programmer can be used for programming UPDI-only devices
|
SerialUPDI programmer can be used for programming UPDI-only devices
|
||||||
@@ -1996,9 +2111,6 @@ fuse, extended fuse) have no meaning whatsoever, as they have been
|
|||||||
simply replaced by array of fuses: fuse0..9. Therefore you can simply
|
simply replaced by array of fuses: fuse0..9. Therefore you can simply
|
||||||
ignore this particular line of AVRDUDE output.
|
ignore this particular line of AVRDUDE output.
|
||||||
|
|
||||||
In connection to the above, @emph{safemode} has no meaning in context
|
|
||||||
of UPDI devices and should be ignored.
|
|
||||||
|
|
||||||
Currently available devices support only UPDI NVM programming model 0
|
Currently available devices support only UPDI NVM programming model 0
|
||||||
and 2, but there is also experimental implementation of model 3 - not
|
and 2, but there is also experimental implementation of model 3 - not
|
||||||
yet tested.
|
yet tested.
|
||||||
@@ -2218,6 +2330,8 @@ configuration file will be always be @code{/etc/avrdude.conf}.
|
|||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
The parallel and serial port device file names are system specific.
|
The parallel and serial port device file names are system specific.
|
||||||
|
MacOS has no default serial or parallel port names, but available
|
||||||
|
ports can be found under @code{/dev/cu.*}.
|
||||||
The following table lists the default names for a given system.
|
The following table lists the default names for a given system.
|
||||||
|
|
||||||
@multitable @columnfractions .30 .30 .30
|
@multitable @columnfractions .30 .30 .30
|
||||||
@@ -2450,13 +2564,13 @@ such as @option{--prefix} and @option{--datadir}.
|
|||||||
@c
|
@c
|
||||||
@c Node
|
@c Node
|
||||||
@c
|
@c
|
||||||
@node Troubleshooting, ,Platform Dependent Information ,Top
|
@node Troubleshooting,Index ,Platform Dependent Information ,Top
|
||||||
@appendix Troubleshooting
|
@appendix Troubleshooting
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
In general, please report any bugs encountered via
|
In general, please report any bugs encountered via
|
||||||
@*
|
@*
|
||||||
@url{http://savannah.nongnu.org/bugs/?group=avrdude}.
|
@url{https://github.com/avrdudes/avrdude/issues}.
|
||||||
|
|
||||||
|
|
||||||
@itemize @bullet
|
@itemize @bullet
|
||||||
@@ -2761,7 +2875,11 @@ erase cycle.
|
|||||||
|
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
|
@node Index, , Troubleshooting, Top
|
||||||
|
|
||||||
|
@unnumbered Concept Index
|
||||||
|
|
||||||
|
@printindex cp
|
||||||
|
|
||||||
@bye
|
@bye
|
||||||
|
|
||||||
|
|||||||
44
src/ft245r.c
44
src/ft245r.c
@@ -147,6 +147,7 @@ static struct {
|
|||||||
static struct {
|
static struct {
|
||||||
int discard; // # of bytes to discard during read
|
int discard; // # of bytes to discard during read
|
||||||
int pending; // # of bytes that have been written since last read
|
int pending; // # of bytes that have been written since last read
|
||||||
|
int len; // # of bytes in receive buffer
|
||||||
int wr; // write pointer
|
int wr; // write pointer
|
||||||
int rd; // read pointer
|
int rd; // read pointer
|
||||||
uint8_t buf[FT245R_BUFSIZE]; // receive ring buffer
|
uint8_t buf[FT245R_BUFSIZE]; // receive ring buffer
|
||||||
@@ -159,16 +160,19 @@ static int ft245r_tpi_rx(PROGRAMMER * pgm, uint8_t *bytep);
|
|||||||
|
|
||||||
// Discard all data from the receive buffer.
|
// Discard all data from the receive buffer.
|
||||||
static void ft245r_rx_buf_purge(PROGRAMMER * pgm) {
|
static void ft245r_rx_buf_purge(PROGRAMMER * pgm) {
|
||||||
|
rx.len = 0;
|
||||||
rx.rd = rx.wr = 0;
|
rx.rd = rx.wr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ft245r_rx_buf_put(PROGRAMMER * pgm, uint8_t byte) {
|
static void ft245r_rx_buf_put(PROGRAMMER * pgm, uint8_t byte) {
|
||||||
|
rx.len++;
|
||||||
rx.buf[rx.wr++] = byte;
|
rx.buf[rx.wr++] = byte;
|
||||||
if (rx.wr >= sizeof(rx.buf))
|
if (rx.wr >= sizeof(rx.buf))
|
||||||
rx.wr = 0;
|
rx.wr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t ft245r_rx_buf_get(PROGRAMMER * pgm) {
|
static uint8_t ft245r_rx_buf_get(PROGRAMMER * pgm) {
|
||||||
|
rx.len--;
|
||||||
uint8_t byte = rx.buf[rx.rd++];
|
uint8_t byte = rx.buf[rx.rd++];
|
||||||
if (rx.rd >= sizeof(rx.buf))
|
if (rx.rd >= sizeof(rx.buf))
|
||||||
rx.rd = 0;
|
rx.rd = 0;
|
||||||
@@ -193,6 +197,20 @@ static int ft245r_fill(PROGRAMMER * pgm) {
|
|||||||
return nread;
|
return nread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ft245r_rx_buf_fill_and_get(PROGRAMMER* pgm)
|
||||||
|
{
|
||||||
|
while (rx.len == 0)
|
||||||
|
{
|
||||||
|
int result = ft245r_fill(pgm);
|
||||||
|
if (result < 0)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ft245r_rx_buf_get(pgm);
|
||||||
|
}
|
||||||
|
|
||||||
/* Flush pending TX data to the FTDI send FIFO. */
|
/* Flush pending TX data to the FTDI send FIFO. */
|
||||||
static int ft245r_flush(PROGRAMMER * pgm) {
|
static int ft245r_flush(PROGRAMMER * pgm) {
|
||||||
int rv, len = tx.len, avail;
|
int rv, len = tx.len, avail;
|
||||||
@@ -269,14 +287,32 @@ static int ft245r_recv(PROGRAMMER * pgm, unsigned char * buf, size_t len) {
|
|||||||
__func__, rx.discard, len);
|
__func__, rx.discard, len);
|
||||||
#endif
|
#endif
|
||||||
while (rx.discard > 0) {
|
while (rx.discard > 0) {
|
||||||
ft245r_rx_buf_get(pgm);
|
int result = ft245r_rx_buf_fill_and_get(pgm);
|
||||||
|
if (result < 0)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
--rx.discard;
|
--rx.discard;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < len; ++i) {
|
for (i = 0; i < len; ++i)
|
||||||
buf[i] = ft245r_rx_buf_get(pgm);
|
{
|
||||||
|
int result = ft245r_rx_buf_fill_and_get(pgm);
|
||||||
|
if (result < 0)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf[i] = (uint8_t)result;
|
||||||
for (j = 1; j < baud_multiplier; ++j)
|
for (j = 1; j < baud_multiplier; ++j)
|
||||||
ft245r_rx_buf_get(pgm);
|
{
|
||||||
|
result = ft245r_rx_buf_fill_and_get(pgm);
|
||||||
|
if (result < 0)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
134
src/jtag3.c
134
src/jtag3.c
@@ -493,7 +493,7 @@ static int jtag3_edbg_send(PROGRAMMER * pgm, unsigned char * data, size_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (serial_send(&pgm->fd, buf, max_xfer) != 0) {
|
if (serial_send(&pgm->fd, buf, max_xfer) != 0) {
|
||||||
avrdude_message(MSG_INFO, "%s: jtag3_edbg_send(): failed to send command to serial port\n",
|
avrdude_message(MSG_NOTICE, "%s: jtag3_edbg_send(): failed to send command to serial port\n",
|
||||||
progname);
|
progname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -509,7 +509,7 @@ static int jtag3_edbg_send(PROGRAMMER * pgm, unsigned char * data, size_t len)
|
|||||||
(frag == nfragments - 1 && status[1] != 0x01))
|
(frag == nfragments - 1 && status[1] != 0x01))
|
||||||
{
|
{
|
||||||
/* what to do in this case? */
|
/* what to do in this case? */
|
||||||
avrdude_message(MSG_INFO, "%s: jtag3_edbg_send(): Unexpected response 0x%02x, 0x%02x\n",
|
avrdude_message(MSG_NOTICE, "%s: jtag3_edbg_send(): Unexpected response 0x%02x, 0x%02x\n",
|
||||||
progname, status[0], status[1]);
|
progname, status[0], status[1]);
|
||||||
}
|
}
|
||||||
data += this_len;
|
data += this_len;
|
||||||
@@ -596,36 +596,36 @@ static int jtag3_edbg_signoff(PROGRAMMER * pgm)
|
|||||||
buf[1] = CMSISDAP_LED_CONNECT;
|
buf[1] = CMSISDAP_LED_CONNECT;
|
||||||
buf[2] = 0;
|
buf[2] = 0;
|
||||||
if (serial_send(&pgm->fd, buf, pgm->fd.usb.max_xfer) != 0) {
|
if (serial_send(&pgm->fd, buf, pgm->fd.usb.max_xfer) != 0) {
|
||||||
avrdude_message(MSG_INFO, "%s: jtag3_edbg_signoff(): failed to send command to serial port\n",
|
avrdude_message(MSG_NOTICE, "%s: jtag3_edbg_signoff(): failed to send command to serial port\n",
|
||||||
progname);
|
progname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
rv = serial_recv(&pgm->fd, status, pgm->fd.usb.max_xfer);
|
rv = serial_recv(&pgm->fd, status, pgm->fd.usb.max_xfer);
|
||||||
if (rv != pgm->fd.usb.max_xfer) {
|
if (rv != pgm->fd.usb.max_xfer) {
|
||||||
avrdude_message(MSG_INFO, "%s: jtag3_edbg_signoff(): failed to read from serial port (%d)\n",
|
avrdude_message(MSG_NOTICE, "%s: jtag3_edbg_signoff(): failed to read from serial port (%d)\n",
|
||||||
progname, rv);
|
progname, rv);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (status[0] != CMSISDAP_CMD_LED ||
|
if (status[0] != CMSISDAP_CMD_LED ||
|
||||||
status[1] != 0)
|
status[1] != 0)
|
||||||
avrdude_message(MSG_INFO, "%s: jtag3_edbg_signoff(): unexpected response 0x%02x, 0x%02x\n",
|
avrdude_message(MSG_NOTICE, "%s: jtag3_edbg_signoff(): unexpected response 0x%02x, 0x%02x\n",
|
||||||
progname, status[0], status[1]);
|
progname, status[0], status[1]);
|
||||||
|
|
||||||
buf[0] = CMSISDAP_CMD_DISCONNECT;
|
buf[0] = CMSISDAP_CMD_DISCONNECT;
|
||||||
if (serial_send(&pgm->fd, buf, pgm->fd.usb.max_xfer) != 0) {
|
if (serial_send(&pgm->fd, buf, pgm->fd.usb.max_xfer) != 0) {
|
||||||
avrdude_message(MSG_INFO, "%s: jtag3_edbg_signoff(): failed to send command to serial port\n",
|
avrdude_message(MSG_NOTICE, "%s: jtag3_edbg_signoff(): failed to send command to serial port\n",
|
||||||
progname);
|
progname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
rv = serial_recv(&pgm->fd, status, pgm->fd.usb.max_xfer);
|
rv = serial_recv(&pgm->fd, status, pgm->fd.usb.max_xfer);
|
||||||
if (rv != pgm->fd.usb.max_xfer) {
|
if (rv != pgm->fd.usb.max_xfer) {
|
||||||
avrdude_message(MSG_INFO, "%s: jtag3_edbg_signoff(): failed to read from serial port (%d)\n",
|
avrdude_message(MSG_NOTICE, "%s: jtag3_edbg_signoff(): failed to read from serial port (%d)\n",
|
||||||
progname, rv);
|
progname, rv);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (status[0] != CMSISDAP_CMD_DISCONNECT ||
|
if (status[0] != CMSISDAP_CMD_DISCONNECT ||
|
||||||
status[1] != 0)
|
status[1] != 0)
|
||||||
avrdude_message(MSG_INFO, "%s: jtag3_edbg_signoff(): unexpected response 0x%02x, 0x%02x\n",
|
avrdude_message(MSG_NOTICE, "%s: jtag3_edbg_signoff(): unexpected response 0x%02x, 0x%02x\n",
|
||||||
progname, status[0], status[1]);
|
progname, status[0], status[1]);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -686,12 +686,12 @@ static int jtag3_edbg_recv_frame(PROGRAMMER * pgm, unsigned char **msg) {
|
|||||||
avrdude_message(MSG_TRACE, "%s: jtag3_edbg_recv():\n", progname);
|
avrdude_message(MSG_TRACE, "%s: jtag3_edbg_recv():\n", progname);
|
||||||
|
|
||||||
if ((buf = malloc(USBDEV_MAX_XFER_3)) == NULL) {
|
if ((buf = malloc(USBDEV_MAX_XFER_3)) == NULL) {
|
||||||
avrdude_message(MSG_INFO, "%s: jtag3_edbg_recv(): out of memory\n",
|
avrdude_message(MSG_NOTICE, "%s: jtag3_edbg_recv(): out of memory\n",
|
||||||
progname);
|
progname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if ((request = malloc(pgm->fd.usb.max_xfer)) == NULL) {
|
if ((request = malloc(pgm->fd.usb.max_xfer)) == NULL) {
|
||||||
avrdude_message(MSG_INFO, "%s: jtag3_edbg_recv(): out of memory\n",
|
avrdude_message(MSG_NOTICE, "%s: jtag3_edbg_recv(): out of memory\n",
|
||||||
progname);
|
progname);
|
||||||
free(buf);
|
free(buf);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -706,7 +706,7 @@ static int jtag3_edbg_recv_frame(PROGRAMMER * pgm, unsigned char **msg) {
|
|||||||
request[0] = EDBG_VENDOR_AVR_RSP;
|
request[0] = EDBG_VENDOR_AVR_RSP;
|
||||||
|
|
||||||
if (serial_send(&pgm->fd, request, pgm->fd.usb.max_xfer) != 0) {
|
if (serial_send(&pgm->fd, request, pgm->fd.usb.max_xfer) != 0) {
|
||||||
avrdude_message(MSG_INFO, "%s: jtag3_edbg_recv(): error sending CMSIS-DAP vendor command\n",
|
avrdude_message(MSG_NOTICE, "%s: jtag3_edbg_recv(): error sending CMSIS-DAP vendor command\n",
|
||||||
progname);
|
progname);
|
||||||
free(request);
|
free(request);
|
||||||
free(*msg);
|
free(*msg);
|
||||||
@@ -725,7 +725,7 @@ static int jtag3_edbg_recv_frame(PROGRAMMER * pgm, unsigned char **msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (buf[0] != EDBG_VENDOR_AVR_RSP) {
|
if (buf[0] != EDBG_VENDOR_AVR_RSP) {
|
||||||
avrdude_message(MSG_INFO, "%s: jtag3_edbg_recv(): Unexpected response 0x%02x\n",
|
avrdude_message(MSG_NOTICE, "%s: jtag3_edbg_recv(): Unexpected response 0x%02x\n",
|
||||||
progname, buf[0]);
|
progname, buf[0]);
|
||||||
free(*msg);
|
free(*msg);
|
||||||
free(request);
|
free(request);
|
||||||
@@ -736,7 +736,7 @@ static int jtag3_edbg_recv_frame(PROGRAMMER * pgm, unsigned char **msg) {
|
|||||||
// Documentation says:
|
// Documentation says:
|
||||||
// "FragmentInfo 0x00 indicates that no response data is
|
// "FragmentInfo 0x00 indicates that no response data is
|
||||||
// available, and the rest of the packet is ignored."
|
// available, and the rest of the packet is ignored."
|
||||||
avrdude_message(MSG_INFO,
|
avrdude_message(MSG_NOTICE,
|
||||||
"%s: jtag3_edbg_recv(): "
|
"%s: jtag3_edbg_recv(): "
|
||||||
"No response available\n",
|
"No response available\n",
|
||||||
progname);
|
progname);
|
||||||
@@ -752,7 +752,7 @@ static int jtag3_edbg_recv_frame(PROGRAMMER * pgm, unsigned char **msg) {
|
|||||||
thisfrag = 1;
|
thisfrag = 1;
|
||||||
} else {
|
} else {
|
||||||
if (nfrags != (buf[1] & 0x0F)) {
|
if (nfrags != (buf[1] & 0x0F)) {
|
||||||
avrdude_message(MSG_INFO,
|
avrdude_message(MSG_NOTICE,
|
||||||
"%s: jtag3_edbg_recv(): "
|
"%s: jtag3_edbg_recv(): "
|
||||||
"Inconsistent # of fragments; had %d, now %d\n",
|
"Inconsistent # of fragments; had %d, now %d\n",
|
||||||
progname, nfrags, (buf[1] & 0x0F));
|
progname, nfrags, (buf[1] & 0x0F));
|
||||||
@@ -762,7 +762,7 @@ static int jtag3_edbg_recv_frame(PROGRAMMER * pgm, unsigned char **msg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (thisfrag != ((buf[1] >> 4) & 0x0F)) {
|
if (thisfrag != ((buf[1] >> 4) & 0x0F)) {
|
||||||
avrdude_message(MSG_INFO,
|
avrdude_message(MSG_NOTICE,
|
||||||
"%s: jtag3_edbg_recv(): "
|
"%s: jtag3_edbg_recv(): "
|
||||||
"Inconsistent fragment number; expect %d, got %d\n",
|
"Inconsistent fragment number; expect %d, got %d\n",
|
||||||
progname, thisfrag, ((buf[1] >> 4) & 0x0F));
|
progname, thisfrag, ((buf[1] >> 4) & 0x0F));
|
||||||
@@ -773,12 +773,12 @@ static int jtag3_edbg_recv_frame(PROGRAMMER * pgm, unsigned char **msg) {
|
|||||||
|
|
||||||
int thislen = (buf[2] << 8) | buf[3];
|
int thislen = (buf[2] << 8) | buf[3];
|
||||||
if (thislen > rv + 4) {
|
if (thislen > rv + 4) {
|
||||||
avrdude_message(MSG_INFO, "%s: jtag3_edbg_recv(): Unexpected length value (%d > %d)\n",
|
avrdude_message(MSG_NOTICE, "%s: jtag3_edbg_recv(): Unexpected length value (%d > %d)\n",
|
||||||
progname, thislen, rv + 4);
|
progname, thislen, rv + 4);
|
||||||
thislen = rv + 4;
|
thislen = rv + 4;
|
||||||
}
|
}
|
||||||
if (len + thislen > USBDEV_MAX_XFER_3) {
|
if (len + thislen > USBDEV_MAX_XFER_3) {
|
||||||
avrdude_message(MSG_INFO, "%s: jtag3_edbg_recv(): Length exceeds max size (%d > %d)\n",
|
avrdude_message(MSG_NOTICE, "%s: jtag3_edbg_recv(): Length exceeds max size (%d > %d)\n",
|
||||||
progname, len + thislen, USBDEV_MAX_XFER_3);
|
progname, len + thislen, USBDEV_MAX_XFER_3);
|
||||||
thislen = USBDEV_MAX_XFER_3 - len;
|
thislen = USBDEV_MAX_XFER_3 - len;
|
||||||
}
|
}
|
||||||
@@ -865,7 +865,7 @@ int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg) {
|
|||||||
"%s: Device is locked! Chip erase required to unlock.\n",
|
"%s: Device is locked! Chip erase required to unlock.\n",
|
||||||
progname);
|
progname);
|
||||||
} else {
|
} else {
|
||||||
avrdude_message(MSG_INFO, "%s: bad response to %s command: 0x%02x\n",
|
avrdude_message(MSG_NOTICE, "%s: bad response to %s command: 0x%02x\n",
|
||||||
progname, descr, c);
|
progname, descr, c);
|
||||||
}
|
}
|
||||||
status = (*resp)[3];
|
status = (*resp)[3];
|
||||||
@@ -1129,7 +1129,7 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||||||
if (PDATA(pgm)->set_sck(pgm, parm) < 0)
|
if (PDATA(pgm)->set_sck(pgm, parm) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
jtag3_print_parms1(pgm, progbuf);
|
||||||
if (conn == PARM3_CONN_JTAG)
|
if (conn == PARM3_CONN_JTAG)
|
||||||
{
|
{
|
||||||
avrdude_message(MSG_NOTICE2, "%s: jtag3_initialize(): "
|
avrdude_message(MSG_NOTICE2, "%s: jtag3_initialize(): "
|
||||||
@@ -1174,7 +1174,8 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||||||
u32_to_b4(xd.nvm_fuse_offset, m->offset & ~7);
|
u32_to_b4(xd.nvm_fuse_offset, m->offset & ~7);
|
||||||
} else if (matches(m->desc, "lock")) {
|
} else if (matches(m->desc, "lock")) {
|
||||||
u32_to_b4(xd.nvm_lock_offset, m->offset);
|
u32_to_b4(xd.nvm_lock_offset, m->offset);
|
||||||
} else if (strcmp(m->desc, "usersig") == 0) {
|
} else if (strcmp(m->desc, "usersig") == 0 ||
|
||||||
|
strcmp(m->desc, "userrow") == 0) {
|
||||||
u32_to_b4(xd.nvm_user_sig_offset, m->offset);
|
u32_to_b4(xd.nvm_user_sig_offset, m->offset);
|
||||||
} else if (strcmp(m->desc, "prodsig") == 0) {
|
} else if (strcmp(m->desc, "prodsig") == 0) {
|
||||||
u32_to_b4(xd.nvm_prod_sig_offset, m->offset);
|
u32_to_b4(xd.nvm_prod_sig_offset, m->offset);
|
||||||
@@ -1225,7 +1226,8 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||||||
u16_to_b2(xd.eeprom_bytes, m->size);
|
u16_to_b2(xd.eeprom_bytes, m->size);
|
||||||
u16_to_b2(xd.eeprom_base, m->offset);
|
u16_to_b2(xd.eeprom_base, m->offset);
|
||||||
}
|
}
|
||||||
else if (strcmp(m->desc, "usersig") == 0)
|
else if (strcmp(m->desc, "usersig") == 0 ||
|
||||||
|
strcmp(m->desc, "userrow") == 0)
|
||||||
{
|
{
|
||||||
u16_to_b2(xd.user_sig_bytes, m->size);
|
u16_to_b2(xd.user_sig_bytes, m->size);
|
||||||
u16_to_b2(xd.user_sig_base, m->offset);
|
u16_to_b2(xd.user_sig_base, m->offset);
|
||||||
@@ -1265,7 +1267,7 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||||||
"xd->flash_page_size=%x\n\t"
|
"xd->flash_page_size=%x\n\t"
|
||||||
"xd->eeprom_page_size=%x\n\t"
|
"xd->eeprom_page_size=%x\n\t"
|
||||||
"xd->nvmctrl=%x %x\n\t"
|
"xd->nvmctrl=%x %x\n\t"
|
||||||
"xd->ocd=%x %x\n\t",
|
"xd->ocd=%x %x\n\t"
|
||||||
"xd->address_mode=%x\n",
|
"xd->address_mode=%x\n",
|
||||||
xd.prog_base_msb,
|
xd.prog_base_msb,
|
||||||
xd.prog_base[0], xd.prog_base[1],
|
xd.prog_base[0], xd.prog_base[1],
|
||||||
@@ -1351,11 +1353,12 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||||||
if ((status = jtag3_command(pgm, cmd, 4, &resp, "AVR sign-on")) >= 0)
|
if ((status = jtag3_command(pgm, cmd, 4, &resp, "AVR sign-on")) >= 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
avrdude_message(MSG_INFO, "%s: retrying with external reset applied\n",
|
avrdude_message(MSG_NOTICE, "%s: retrying with external reset applied\n",
|
||||||
progname);
|
progname);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_ext_reset > 1) {
|
if (use_ext_reset > 1) {
|
||||||
|
if(strcmp(pgm->type, "JTAGICE3") == 0 && p->flags & AVRPART_HAS_JTAG)
|
||||||
avrdude_message(MSG_INFO, "%s: JTAGEN fuse disabled?\n", progname);
|
avrdude_message(MSG_INFO, "%s: JTAGEN fuse disabled?\n", progname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -1685,9 +1688,10 @@ static int jtag3_page_erase(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||||||
cmd[3] = XMEGA_ERASE_BOOT_PAGE;
|
cmd[3] = XMEGA_ERASE_BOOT_PAGE;
|
||||||
} else if (strcmp(m->desc, "eeprom") == 0) {
|
} else if (strcmp(m->desc, "eeprom") == 0) {
|
||||||
cmd[3] = XMEGA_ERASE_EEPROM_PAGE;
|
cmd[3] = XMEGA_ERASE_EEPROM_PAGE;
|
||||||
} else if ( ( strcmp(m->desc, "usersig") == 0 ) ) {
|
} else if (strcmp(m->desc, "usersig") == 0 ||
|
||||||
|
strcmp(m->desc, "userrow") == 0) {
|
||||||
cmd[3] = XMEGA_ERASE_USERSIG;
|
cmd[3] = XMEGA_ERASE_USERSIG;
|
||||||
} else if ( ( strcmp(m->desc, "boot") == 0 ) ) {
|
} else if (strcmp(m->desc, "boot") == 0) {
|
||||||
cmd[3] = XMEGA_ERASE_BOOT_PAGE;
|
cmd[3] = XMEGA_ERASE_BOOT_PAGE;
|
||||||
} else {
|
} else {
|
||||||
cmd[3] = XMEGA_ERASE_APP_PAGE;
|
cmd[3] = XMEGA_ERASE_APP_PAGE;
|
||||||
@@ -1759,9 +1763,10 @@ static int jtag3_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||||||
}
|
}
|
||||||
cmd[3] = ( p->flags & AVRPART_HAS_PDI ) ? MTYPE_EEPROM_XMEGA : MTYPE_EEPROM_PAGE;
|
cmd[3] = ( p->flags & AVRPART_HAS_PDI ) ? MTYPE_EEPROM_XMEGA : MTYPE_EEPROM_PAGE;
|
||||||
PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L;
|
PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L;
|
||||||
} else if ( ( strcmp(m->desc, "usersig") == 0 ) ) {
|
} else if (strcmp(m->desc, "usersig") == 0 ||
|
||||||
|
strcmp(m->desc, "userrow") == 0) {
|
||||||
cmd[3] = MTYPE_USERSIG;
|
cmd[3] = MTYPE_USERSIG;
|
||||||
} else if ( ( strcmp(m->desc, "boot") == 0 ) ) {
|
} else if (strcmp(m->desc, "boot") == 0) {
|
||||||
cmd[3] = MTYPE_BOOT_FLASH;
|
cmd[3] = MTYPE_BOOT_FLASH;
|
||||||
} else if ( p->flags & AVRPART_HAS_PDI || p->flags & AVRPART_HAS_UPDI ) {
|
} else if ( p->flags & AVRPART_HAS_PDI || p->flags & AVRPART_HAS_UPDI ) {
|
||||||
cmd[3] = MTYPE_FLASH;
|
cmd[3] = MTYPE_FLASH;
|
||||||
@@ -1848,11 +1853,12 @@ static int jtag3_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||||||
cmd[3] = ( p->flags & AVRPART_HAS_PDI || p->flags & AVRPART_HAS_UPDI ) ? MTYPE_EEPROM : MTYPE_EEPROM_PAGE;
|
cmd[3] = ( p->flags & AVRPART_HAS_PDI || p->flags & AVRPART_HAS_UPDI ) ? MTYPE_EEPROM : MTYPE_EEPROM_PAGE;
|
||||||
if (pgm->flag & PGM_FL_IS_DW)
|
if (pgm->flag & PGM_FL_IS_DW)
|
||||||
return -1;
|
return -1;
|
||||||
} else if ( ( strcmp(m->desc, "prodsig") == 0 ) ) {
|
} else if (strcmp(m->desc, "prodsig") == 0) {
|
||||||
cmd[3] = MTYPE_PRODSIG;
|
cmd[3] = MTYPE_PRODSIG;
|
||||||
} else if ( ( strcmp(m->desc, "usersig") == 0 ) ) {
|
} else if (strcmp(m->desc, "usersig") == 0 ||
|
||||||
|
strcmp(m->desc, "userrow") == 0) {
|
||||||
cmd[3] = MTYPE_USERSIG;
|
cmd[3] = MTYPE_USERSIG;
|
||||||
} else if ( ( strcmp(m->desc, "boot") == 0 ) ) {
|
} else if (strcmp(m->desc, "boot") == 0) {
|
||||||
cmd[3] = MTYPE_BOOT_FLASH;
|
cmd[3] = MTYPE_BOOT_FLASH;
|
||||||
} else if ( p->flags & AVRPART_HAS_PDI ) {
|
} else if ( p->flags & AVRPART_HAS_PDI ) {
|
||||||
cmd[3] = MTYPE_FLASH;
|
cmd[3] = MTYPE_FLASH;
|
||||||
@@ -1964,10 +1970,23 @@ static int jtag3_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||||||
cmd[3] = MTYPE_FUSE_BITS;
|
cmd[3] = MTYPE_FUSE_BITS;
|
||||||
if (!(p->flags & AVRPART_HAS_UPDI))
|
if (!(p->flags & AVRPART_HAS_UPDI))
|
||||||
addr = mem->offset & 7;
|
addr = mem->offset & 7;
|
||||||
} else if (strcmp(mem->desc, "usersig") == 0) {
|
} else if (strcmp(mem->desc, "usersig") == 0 ||
|
||||||
|
strcmp(mem->desc, "userrow") == 0) {
|
||||||
cmd[3] = MTYPE_USERSIG;
|
cmd[3] = MTYPE_USERSIG;
|
||||||
} else if (strcmp(mem->desc, "prodsig") == 0) {
|
} else if (strcmp(mem->desc, "prodsig") == 0) {
|
||||||
cmd[3] = MTYPE_PRODSIG;
|
cmd[3] = MTYPE_PRODSIG;
|
||||||
|
} else if (strcmp(mem->desc, "sernum") == 0) {
|
||||||
|
cmd[3] = MTYPE_SIGN_JTAG;
|
||||||
|
} else if (strcmp(mem->desc, "osccal16") == 0) {
|
||||||
|
cmd[3] = MTYPE_SIGN_JTAG;
|
||||||
|
} else if (strcmp(mem->desc, "osccal20") == 0) {
|
||||||
|
cmd[3] = MTYPE_SIGN_JTAG;
|
||||||
|
} else if (strcmp(mem->desc, "tempsense") == 0) {
|
||||||
|
cmd[3] = MTYPE_SIGN_JTAG;
|
||||||
|
} else if (strcmp(mem->desc, "osc16err") == 0) {
|
||||||
|
cmd[3] = MTYPE_SIGN_JTAG;
|
||||||
|
} else if (strcmp(mem->desc, "osc20err") == 0) {
|
||||||
|
cmd[3] = MTYPE_SIGN_JTAG;
|
||||||
} else if (strcmp(mem->desc, "calibration") == 0) {
|
} else if (strcmp(mem->desc, "calibration") == 0) {
|
||||||
cmd[3] = MTYPE_OSCCAL_BYTE;
|
cmd[3] = MTYPE_OSCCAL_BYTE;
|
||||||
if (pgm->flag & PGM_FL_IS_DW)
|
if (pgm->flag & PGM_FL_IS_DW)
|
||||||
@@ -2113,7 +2132,8 @@ static int jtag3_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||||||
cmd[3] = MTYPE_FUSE_BITS;
|
cmd[3] = MTYPE_FUSE_BITS;
|
||||||
if (!(p->flags & AVRPART_HAS_UPDI))
|
if (!(p->flags & AVRPART_HAS_UPDI))
|
||||||
addr = mem->offset & 7;
|
addr = mem->offset & 7;
|
||||||
} else if (strcmp(mem->desc, "usersig") == 0) {
|
} else if (strcmp(mem->desc, "usersig") == 0 ||
|
||||||
|
strcmp(mem->desc, "userrow") == 0) {
|
||||||
cmd[3] = MTYPE_USERSIG;
|
cmd[3] = MTYPE_USERSIG;
|
||||||
} else if (strcmp(mem->desc, "prodsig") == 0) {
|
} else if (strcmp(mem->desc, "prodsig") == 0) {
|
||||||
cmd[3] = MTYPE_PRODSIG;
|
cmd[3] = MTYPE_PRODSIG;
|
||||||
@@ -2228,7 +2248,7 @@ int jtag3_getparm(PROGRAMMER * pgm, unsigned char scope,
|
|||||||
|
|
||||||
c = resp[1];
|
c = resp[1];
|
||||||
if (c != RSP3_DATA || status < 3) {
|
if (c != RSP3_DATA || status < 3) {
|
||||||
avrdude_message(MSG_INFO, "%s: jtag3_getparm(): "
|
avrdude_message(MSG_NOTICE, "%s: jtag3_getparm(): "
|
||||||
"bad response to %s\n",
|
"bad response to %s\n",
|
||||||
progname, descr);
|
progname, descr);
|
||||||
free(resp);
|
free(resp);
|
||||||
@@ -2313,9 +2333,8 @@ static int jtag3_set_vtarget(PROGRAMMER * pgm, double v)
|
|||||||
utarg = (unsigned)(v * 1000);
|
utarg = (unsigned)(v * 1000);
|
||||||
|
|
||||||
if (jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_VTARGET, buf, 2) < 0) {
|
if (jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_VTARGET, buf, 2) < 0) {
|
||||||
avrdude_message(MSG_INFO, "%s: jtag3_set_vtarget(): cannot obtain V[aref]\n",
|
avrdude_message(MSG_INFO, "%s: jtag3_set_vtarget(): cannot obtain V[target]\n",
|
||||||
progname);
|
progname);
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uaref = b2_to_u16(buf);
|
uaref = b2_to_u16(buf);
|
||||||
@@ -2324,8 +2343,11 @@ static int jtag3_set_vtarget(PROGRAMMER * pgm, double v)
|
|||||||
avrdude_message(MSG_INFO, "%s: jtag3_set_vtarget(): changing V[target] from %.1f to %.1f\n",
|
avrdude_message(MSG_INFO, "%s: jtag3_set_vtarget(): changing V[target] from %.1f to %.1f\n",
|
||||||
progname, uaref / 1000.0, v);
|
progname, uaref / 1000.0, v);
|
||||||
|
|
||||||
if (jtag3_setparm(pgm, SCOPE_GENERAL, 1, PARM3_VADJUST, buf, sizeof(buf)) < 0)
|
if (jtag3_setparm(pgm, SCOPE_GENERAL, 1, PARM3_VADJUST, buf, sizeof(buf)) < 0) {
|
||||||
|
avrdude_message(MSG_INFO, "%s: jtag3_set_vtarget(): cannot confirm new V[target] value\n",
|
||||||
|
progname);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -2364,14 +2386,12 @@ static void jtag3_display(PROGRAMMER * pgm, const char * p)
|
|||||||
memmove(resp, resp + 3, status - 3);
|
memmove(resp, resp + 3, status - 3);
|
||||||
resp[status - 3] = 0;
|
resp[status - 3] = 0;
|
||||||
|
|
||||||
avrdude_message(MSG_INFO, "%sICE hardware version: %d\n", p, parms[0]);
|
avrdude_message(MSG_INFO, "%sICE HW version : %d\n", p, parms[0]);
|
||||||
avrdude_message(MSG_INFO, "%sICE firmware version: %d.%02d (rel. %d)\n", p,
|
avrdude_message(MSG_INFO, "%sICE FW version : %d.%02d (rel. %d)\n", p,
|
||||||
parms[1], parms[2],
|
parms[1], parms[2],
|
||||||
(parms[3] | (parms[4] << 8)));
|
(parms[3] | (parms[4] << 8)));
|
||||||
avrdude_message(MSG_INFO, "%sSerial number : %s\n", p, resp);
|
avrdude_message(MSG_INFO, "%sSerial number : %s", p, resp);
|
||||||
free(resp);
|
free(resp);
|
||||||
|
|
||||||
jtag3_print_parms1(pgm, p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2382,28 +2402,40 @@ static void jtag3_print_parms1(PROGRAMMER * pgm, const char * p)
|
|||||||
if (jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_VTARGET, buf, 2) < 0)
|
if (jtag3_getparm(pgm, SCOPE_GENERAL, 1, PARM3_VTARGET, buf, 2) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
avrdude_message(MSG_INFO, "%sVtarget : %.2f V\n", p,
|
avrdude_message(MSG_INFO, "%sVtarget %s: %.2f V\n", p,
|
||||||
b2_to_u16(buf) / 1000.0);
|
verbose ? "" : " ", b2_to_u16(buf) / 1000.0);
|
||||||
|
|
||||||
if (jtag3_getparm(pgm, SCOPE_AVR, 1, PARM3_CLK_MEGA_PROG, buf, 2) < 0)
|
if (jtag3_getparm(pgm, SCOPE_AVR, 1, PARM3_CLK_MEGA_PROG, buf, 2) < 0)
|
||||||
return;
|
return;
|
||||||
avrdude_message(MSG_INFO, "%sJTAG clock megaAVR/program: %u kHz\n", p,
|
|
||||||
|
if (b2_to_u16(buf) > 0) {
|
||||||
|
avrdude_message(MSG_INFO, "%sJTAG clock megaAVR/program : %u kHz\n", p,
|
||||||
b2_to_u16(buf));
|
b2_to_u16(buf));
|
||||||
|
}
|
||||||
|
|
||||||
if (jtag3_getparm(pgm, SCOPE_AVR, 1, PARM3_CLK_MEGA_DEBUG, buf, 2) < 0)
|
if (jtag3_getparm(pgm, SCOPE_AVR, 1, PARM3_CLK_MEGA_DEBUG, buf, 2) < 0)
|
||||||
return;
|
return;
|
||||||
avrdude_message(MSG_INFO, "%sJTAG clock megaAVR/debug: %u kHz\n", p,
|
|
||||||
|
if (b2_to_u16(buf) > 0) {
|
||||||
|
avrdude_message(MSG_INFO, "%sJTAG clock megaAVR/debug : %u kHz\n", p,
|
||||||
b2_to_u16(buf));
|
b2_to_u16(buf));
|
||||||
|
}
|
||||||
|
|
||||||
if (jtag3_getparm(pgm, SCOPE_AVR, 1, PARM3_CLK_XMEGA_JTAG, buf, 2) < 0)
|
if (jtag3_getparm(pgm, SCOPE_AVR, 1, PARM3_CLK_XMEGA_JTAG, buf, 2) < 0)
|
||||||
return;
|
return;
|
||||||
avrdude_message(MSG_INFO, "%sJTAG clock Xmega: %u kHz\n", p,
|
|
||||||
|
if (b2_to_u16(buf) > 0) {
|
||||||
|
avrdude_message(MSG_INFO, "%sJTAG clock Xmega : %u kHz\n", p,
|
||||||
b2_to_u16(buf));
|
b2_to_u16(buf));
|
||||||
|
}
|
||||||
|
|
||||||
if (jtag3_getparm(pgm, SCOPE_AVR, 1, PARM3_CLK_XMEGA_PDI, buf, 2) < 0)
|
if (jtag3_getparm(pgm, SCOPE_AVR, 1, PARM3_CLK_XMEGA_PDI, buf, 2) < 0)
|
||||||
return;
|
return;
|
||||||
avrdude_message(MSG_INFO, "%sPDI clock Xmega : %u kHz\n", p,
|
|
||||||
|
if (b2_to_u16(buf) > 0) {
|
||||||
|
avrdude_message(MSG_INFO, "%sPDI/UPDI clock Xmega/megaAVR : %u kHz\n\n", p,
|
||||||
b2_to_u16(buf));
|
b2_to_u16(buf));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void jtag3_print_parms(PROGRAMMER * pgm)
|
static void jtag3_print_parms(PROGRAMMER * pgm)
|
||||||
@@ -2440,13 +2472,13 @@ static unsigned int jtag3_memaddr(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, uns
|
|||||||
* Non-Xmega device.
|
* Non-Xmega device.
|
||||||
*/
|
*/
|
||||||
if (p->flags & AVRPART_HAS_UPDI) {
|
if (p->flags & AVRPART_HAS_UPDI) {
|
||||||
if (strcmp(m->desc, "fuses") == 0) {
|
if (strcmp(m->desc, "flash") == 0) {
|
||||||
addr += m->offset;
|
return addr;
|
||||||
}
|
}
|
||||||
else if (matches(m->desc, "fuse")) {
|
else if (m->size == 1) {
|
||||||
addr = m->offset;
|
addr = m->offset;
|
||||||
}
|
}
|
||||||
else if (strcmp(m->desc, "flash") != 0) {
|
else if (m->size > 1) {
|
||||||
addr += m->offset;
|
addr += m->offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1275,8 +1275,8 @@ static void jtagmkI_display(PROGRAMMER * pgm, const char * p)
|
|||||||
jtagmkI_getparm(pgm, PARM_SW_VERSION, &fw) < 0)
|
jtagmkI_getparm(pgm, PARM_SW_VERSION, &fw) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
avrdude_message(MSG_INFO, "%sICE hardware version: 0x%02x\n", p, hw);
|
avrdude_message(MSG_INFO, "%sICE HW version: 0x%02x\n", p, hw);
|
||||||
avrdude_message(MSG_INFO, "%sICE firmware version: 0x%02x\n", p, fw);
|
avrdude_message(MSG_INFO, "%sICE FW version: 0x%02x\n", p, fw);
|
||||||
|
|
||||||
jtagmkI_print_parms1(pgm, p);
|
jtagmkI_print_parms1(pgm, p);
|
||||||
|
|
||||||
|
|||||||
@@ -675,7 +675,7 @@ int jtagmkII_recv(PROGRAMMER * pgm, unsigned char **msg) {
|
|||||||
|
|
||||||
int jtagmkII_getsync(PROGRAMMER * pgm, int mode) {
|
int jtagmkII_getsync(PROGRAMMER * pgm, int mode) {
|
||||||
int tries;
|
int tries;
|
||||||
#define MAXTRIES 33
|
#define MAXTRIES 10
|
||||||
unsigned char buf[3], *resp, c = 0xff;
|
unsigned char buf[3], *resp, c = 0xff;
|
||||||
int status;
|
int status;
|
||||||
unsigned int fwver, hwver;
|
unsigned int fwver, hwver;
|
||||||
@@ -696,15 +696,14 @@ int jtagmkII_getsync(PROGRAMMER * pgm, int mode) {
|
|||||||
|
|
||||||
/* Get the sign-on information. */
|
/* Get the sign-on information. */
|
||||||
buf[0] = CMND_GET_SIGN_ON;
|
buf[0] = CMND_GET_SIGN_ON;
|
||||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkII_getsync(): Sending sign-on command: ",
|
avrdude_message(MSG_NOTICE2, "%s: jtagmkII_getsync() attempt %d of %d: Sending sign-on command: ",
|
||||||
progname);
|
progname, tries + 1, MAXTRIES);
|
||||||
jtagmkII_send(pgm, buf, 1);
|
jtagmkII_send(pgm, buf, 1);
|
||||||
|
|
||||||
status = jtagmkII_recv(pgm, &resp);
|
status = jtagmkII_recv(pgm, &resp);
|
||||||
if (status <= 0) {
|
if (status <= 0) {
|
||||||
avrdude_message(MSG_INFO, "%s: jtagmkII_getsync(): sign-on command: "
|
avrdude_message(MSG_INFO, "%s: jtagmkII_getsync() attempt %d of %d: sign-on command: status %d\n",
|
||||||
"status %d\n",
|
progname, tries + 1, MAXTRIES, status);
|
||||||
progname, status);
|
|
||||||
} else if (verbose >= 3) {
|
} else if (verbose >= 3) {
|
||||||
putc('\n', stderr);
|
putc('\n', stderr);
|
||||||
jtagmkII_prmsg(pgm, resp, status);
|
jtagmkII_prmsg(pgm, resp, status);
|
||||||
@@ -1057,7 +1056,8 @@ static void jtagmkII_set_xmega_params(PROGRAMMER * pgm, AVRPART * p)
|
|||||||
u32_to_b4(sendbuf.dd.nvm_fuse_offset, m->offset & ~7);
|
u32_to_b4(sendbuf.dd.nvm_fuse_offset, m->offset & ~7);
|
||||||
} else if (strncmp(m->desc, "lock", 4) == 0) {
|
} else if (strncmp(m->desc, "lock", 4) == 0) {
|
||||||
u32_to_b4(sendbuf.dd.nvm_lock_offset, m->offset);
|
u32_to_b4(sendbuf.dd.nvm_lock_offset, m->offset);
|
||||||
} else if (strcmp(m->desc, "usersig") == 0) {
|
} else if (strcmp(m->desc, "usersig") == 0 ||
|
||||||
|
strcmp(m->desc, "userrow") == 0) {
|
||||||
u32_to_b4(sendbuf.dd.nvm_user_sig_offset, m->offset);
|
u32_to_b4(sendbuf.dd.nvm_user_sig_offset, m->offset);
|
||||||
} else if (strcmp(m->desc, "prodsig") == 0) {
|
} else if (strcmp(m->desc, "prodsig") == 0) {
|
||||||
u32_to_b4(sendbuf.dd.nvm_prod_sig_offset, m->offset);
|
u32_to_b4(sendbuf.dd.nvm_prod_sig_offset, m->offset);
|
||||||
@@ -1934,9 +1934,10 @@ static int jtagmkII_page_erase(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||||||
cmd[1] = XMEGA_ERASE_BOOT_PAGE;
|
cmd[1] = XMEGA_ERASE_BOOT_PAGE;
|
||||||
} else if (strcmp(m->desc, "eeprom") == 0) {
|
} else if (strcmp(m->desc, "eeprom") == 0) {
|
||||||
cmd[1] = XMEGA_ERASE_EEPROM_PAGE;
|
cmd[1] = XMEGA_ERASE_EEPROM_PAGE;
|
||||||
} else if ( ( strcmp(m->desc, "usersig") == 0 ) ) {
|
} else if (strcmp(m->desc, "usersig") == 0 ||
|
||||||
|
strcmp(m->desc, "userrow") == 0) {
|
||||||
cmd[1] = XMEGA_ERASE_USERSIG;
|
cmd[1] = XMEGA_ERASE_USERSIG;
|
||||||
} else if ( ( strcmp(m->desc, "boot") == 0 ) ) {
|
} else if (strcmp(m->desc, "boot") == 0) {
|
||||||
cmd[1] = XMEGA_ERASE_BOOT_PAGE;
|
cmd[1] = XMEGA_ERASE_BOOT_PAGE;
|
||||||
} else {
|
} else {
|
||||||
cmd[1] = XMEGA_ERASE_APP_PAGE;
|
cmd[1] = XMEGA_ERASE_APP_PAGE;
|
||||||
@@ -2045,13 +2046,14 @@ static int jtagmkII_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||||||
free(cmd);
|
free(cmd);
|
||||||
return n_bytes;
|
return n_bytes;
|
||||||
}
|
}
|
||||||
cmd[1] = ( p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI) ) ? MTYPE_EEPROM : MTYPE_EEPROM_PAGE;
|
cmd[1] = (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI)) ? MTYPE_EEPROM : MTYPE_EEPROM_PAGE;
|
||||||
PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L;
|
PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L;
|
||||||
} else if ( ( strcmp(m->desc, "usersig") == 0 ) ) {
|
} else if (strcmp(m->desc, "usersig") == 0 ||
|
||||||
|
strcmp(m->desc, "userrow") == 0) {
|
||||||
cmd[1] = MTYPE_USERSIG;
|
cmd[1] = MTYPE_USERSIG;
|
||||||
} else if ( ( strcmp(m->desc, "boot") == 0 ) ) {
|
} else if (strcmp(m->desc, "boot") == 0) {
|
||||||
cmd[1] = MTYPE_BOOT_FLASH;
|
cmd[1] = MTYPE_BOOT_FLASH;
|
||||||
} else if ( p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI) ) {
|
} else if (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI)) {
|
||||||
cmd[1] = MTYPE_FLASH;
|
cmd[1] = MTYPE_FLASH;
|
||||||
} else {
|
} else {
|
||||||
cmd[1] = MTYPE_SPM;
|
cmd[1] = MTYPE_SPM;
|
||||||
@@ -2157,16 +2159,17 @@ static int jtagmkII_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||||||
/* dynamically decide between flash/boot memtype */
|
/* dynamically decide between flash/boot memtype */
|
||||||
dynamic_memtype = 1;
|
dynamic_memtype = 1;
|
||||||
} else if (strcmp(m->desc, "eeprom") == 0) {
|
} else if (strcmp(m->desc, "eeprom") == 0) {
|
||||||
cmd[1] = ( p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI) ) ? MTYPE_EEPROM : MTYPE_EEPROM_PAGE;
|
cmd[1] = (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI)) ? MTYPE_EEPROM : MTYPE_EEPROM_PAGE;
|
||||||
if (pgm->flag & PGM_FL_IS_DW)
|
if (pgm->flag & PGM_FL_IS_DW)
|
||||||
return -1;
|
return -1;
|
||||||
} else if ( ( strcmp(m->desc, "prodsig") == 0 ) ) {
|
} else if (strcmp(m->desc, "prodsig") == 0) {
|
||||||
cmd[1] = MTYPE_PRODSIG;
|
cmd[1] = MTYPE_PRODSIG;
|
||||||
} else if ( ( strcmp(m->desc, "usersig") == 0 ) ) {
|
} else if (strcmp(m->desc, "usersig") == 0 ||
|
||||||
|
strcmp(m->desc, "userrow") == 0) {
|
||||||
cmd[1] = MTYPE_USERSIG;
|
cmd[1] = MTYPE_USERSIG;
|
||||||
} else if ( ( strcmp(m->desc, "boot") == 0 ) ) {
|
} else if (strcmp(m->desc, "boot") == 0) {
|
||||||
cmd[1] = MTYPE_BOOT_FLASH;
|
cmd[1] = MTYPE_BOOT_FLASH;
|
||||||
} else if ( p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI) ) {
|
} else if (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI)) {
|
||||||
cmd[1] = MTYPE_FLASH;
|
cmd[1] = MTYPE_FLASH;
|
||||||
} else {
|
} else {
|
||||||
cmd[1] = MTYPE_SPM;
|
cmd[1] = MTYPE_SPM;
|
||||||
@@ -2292,7 +2295,8 @@ static int jtagmkII_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||||||
unsupp = 1;
|
unsupp = 1;
|
||||||
} else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) {
|
} else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) {
|
||||||
cmd[1] = MTYPE_FUSE_BITS;
|
cmd[1] = MTYPE_FUSE_BITS;
|
||||||
} else if (strcmp(mem->desc, "usersig") == 0) {
|
} else if (strcmp(mem->desc, "usersig") == 0 ||
|
||||||
|
strcmp(mem->desc, "userrow") == 0) {
|
||||||
cmd[1] = MTYPE_USERSIG;
|
cmd[1] = MTYPE_USERSIG;
|
||||||
} else if (strcmp(mem->desc, "prodsig") == 0) {
|
} else if (strcmp(mem->desc, "prodsig") == 0) {
|
||||||
cmd[1] = MTYPE_PRODSIG;
|
cmd[1] = MTYPE_PRODSIG;
|
||||||
@@ -2461,7 +2465,8 @@ static int jtagmkII_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||||||
unsupp = 1;
|
unsupp = 1;
|
||||||
} else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) {
|
} else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) {
|
||||||
cmd[1] = MTYPE_FUSE_BITS;
|
cmd[1] = MTYPE_FUSE_BITS;
|
||||||
} else if (strcmp(mem->desc, "usersig") == 0) {
|
} else if (strcmp(mem->desc, "usersig") == 0 ||
|
||||||
|
strcmp(mem->desc, "userrow") == 0) {
|
||||||
cmd[1] = MTYPE_USERSIG;
|
cmd[1] = MTYPE_USERSIG;
|
||||||
} else if (strcmp(mem->desc, "prodsig") == 0) {
|
} else if (strcmp(mem->desc, "prodsig") == 0) {
|
||||||
cmd[1] = MTYPE_PRODSIG;
|
cmd[1] = MTYPE_PRODSIG;
|
||||||
@@ -2689,11 +2694,11 @@ static void jtagmkII_display(PROGRAMMER * pgm, const char * p)
|
|||||||
jtagmkII_getparm(pgm, PAR_FW_VERSION, fw) < 0)
|
jtagmkII_getparm(pgm, PAR_FW_VERSION, fw) < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
avrdude_message(MSG_INFO, "%sM_MCU hardware version: %d\n", p, hw[0]);
|
avrdude_message(MSG_INFO, "%sM_MCU HW version: %d\n", p, hw[0]);
|
||||||
avrdude_message(MSG_INFO, "%sM_MCU firmware version: %d.%02d\n", p, fw[1], fw[0]);
|
avrdude_message(MSG_INFO, "%sM_MCU FW version: %d.%02d\n", p, fw[1], fw[0]);
|
||||||
avrdude_message(MSG_INFO, "%sS_MCU hardware version: %d\n", p, hw[1]);
|
avrdude_message(MSG_INFO, "%sS_MCU HW version: %d\n", p, hw[1]);
|
||||||
avrdude_message(MSG_INFO, "%sS_MCU firmware version: %d.%02d\n", p, fw[3], fw[2]);
|
avrdude_message(MSG_INFO, "%sS_MCU FW version: %d.%02d\n", p, fw[3], fw[2]);
|
||||||
avrdude_message(MSG_INFO, "%sSerial number: %02x:%02x:%02x:%02x:%02x:%02x\n",
|
avrdude_message(MSG_INFO, "%sSerial number : %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||||
p, PDATA(pgm)->serno[0], PDATA(pgm)->serno[1], PDATA(pgm)->serno[2], PDATA(pgm)->serno[3], PDATA(pgm)->serno[4], PDATA(pgm)->serno[5]);
|
p, PDATA(pgm)->serno[0], PDATA(pgm)->serno[1], PDATA(pgm)->serno[2], PDATA(pgm)->serno[3], PDATA(pgm)->serno[4], PDATA(pgm)->serno[5]);
|
||||||
|
|
||||||
jtagmkII_print_parms1(pgm, p);
|
jtagmkII_print_parms1(pgm, p);
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include "ac_cfg.h"
|
||||||
#include "avrdude.h"
|
#include "avrdude.h"
|
||||||
#include "libavrdude.h"
|
#include "libavrdude.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@@ -116,6 +117,7 @@ SIGN [+-]
|
|||||||
<strng>\n { yyerror("unterminated character constant");
|
<strng>\n { yyerror("unterminated character constant");
|
||||||
return YYERRCODE; }
|
return YYERRCODE; }
|
||||||
|
|
||||||
|
alias { yylval=NULL; return K_ALIAS; }
|
||||||
allowfullpagebitstream { yylval=NULL; return K_ALLOWFULLPAGEBITSTREAM; }
|
allowfullpagebitstream { yylval=NULL; return K_ALLOWFULLPAGEBITSTREAM; }
|
||||||
avr910_devcode { yylval=NULL; return K_AVR910_DEVCODE; }
|
avr910_devcode { yylval=NULL; return K_AVR910_DEVCODE; }
|
||||||
bank_size { yylval=NULL; return K_PAGE_SIZE; }
|
bank_size { yylval=NULL; return K_PAGE_SIZE; }
|
||||||
@@ -136,7 +138,6 @@ dedicated { yylval=new_token(K_DEDICATED); return K_DEDICATED; }
|
|||||||
default_bitclock { yylval=NULL; return K_DEFAULT_BITCLOCK; }
|
default_bitclock { yylval=NULL; return K_DEFAULT_BITCLOCK; }
|
||||||
default_parallel { yylval=NULL; return K_DEFAULT_PARALLEL; }
|
default_parallel { yylval=NULL; return K_DEFAULT_PARALLEL; }
|
||||||
default_programmer { yylval=NULL; return K_DEFAULT_PROGRAMMER; }
|
default_programmer { yylval=NULL; return K_DEFAULT_PROGRAMMER; }
|
||||||
default_safemode { yylval=NULL; return K_DEFAULT_SAFEMODE; }
|
|
||||||
default_serial { yylval=NULL; return K_DEFAULT_SERIAL; }
|
default_serial { yylval=NULL; return K_DEFAULT_SERIAL; }
|
||||||
delay { yylval=NULL; return K_DELAY; }
|
delay { yylval=NULL; return K_DELAY; }
|
||||||
desc { yylval=NULL; return K_DESC; }
|
desc { yylval=NULL; return K_DESC; }
|
||||||
|
|||||||
@@ -21,9 +21,6 @@
|
|||||||
#ifndef libavrdude_h
|
#ifndef libavrdude_h
|
||||||
#define libavrdude_h
|
#define libavrdude_h
|
||||||
|
|
||||||
/* XXX should go away */
|
|
||||||
#include "ac_cfg.h"
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@@ -264,6 +261,7 @@ typedef struct avrpart {
|
|||||||
OPCODE * op[AVR_OP_MAX]; /* opcodes */
|
OPCODE * op[AVR_OP_MAX]; /* opcodes */
|
||||||
|
|
||||||
LISTID mem; /* avr memory definitions */
|
LISTID mem; /* avr memory definitions */
|
||||||
|
LISTID mem_alias; /* memory alias definitions */
|
||||||
char config_file[PATH_MAX]; /* config file where defined */
|
char config_file[PATH_MAX]; /* config file where defined */
|
||||||
int lineno; /* config file line number */
|
int lineno; /* config file line number */
|
||||||
} AVRPART;
|
} AVRPART;
|
||||||
@@ -295,6 +293,11 @@ typedef struct avrmem {
|
|||||||
OPCODE * op[AVR_OP_MAX]; /* opcodes */
|
OPCODE * op[AVR_OP_MAX]; /* opcodes */
|
||||||
} AVRMEM;
|
} AVRMEM;
|
||||||
|
|
||||||
|
typedef struct avrmem_alias {
|
||||||
|
char desc[AVR_MEMDESCLEN]; /* alias name ("syscfg0" etc.) */
|
||||||
|
AVRMEM *aliased_mem;
|
||||||
|
} AVRMEM_ALIAS;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@@ -310,12 +313,17 @@ int avr_get_output_index(OPCODE * op);
|
|||||||
|
|
||||||
/* Functions for AVRMEM structures */
|
/* Functions for AVRMEM structures */
|
||||||
AVRMEM * avr_new_memtype(void);
|
AVRMEM * avr_new_memtype(void);
|
||||||
|
AVRMEM_ALIAS * avr_new_memalias(void);
|
||||||
int avr_initmem(AVRPART * p);
|
int avr_initmem(AVRPART * p);
|
||||||
AVRMEM * avr_dup_mem(AVRMEM * m);
|
AVRMEM * avr_dup_mem(AVRMEM * m);
|
||||||
void avr_free_mem(AVRMEM * m);
|
void avr_free_mem(AVRMEM * m);
|
||||||
|
void avr_free_memalias(AVRMEM_ALIAS * m);
|
||||||
AVRMEM * avr_locate_mem(AVRPART * p, char * desc);
|
AVRMEM * avr_locate_mem(AVRPART * p, char * desc);
|
||||||
void avr_mem_display(const char * prefix, FILE * f, AVRMEM * m, int type,
|
AVRMEM * avr_locate_mem_noalias(AVRPART * p, char * desc);
|
||||||
int verbose);
|
AVRMEM_ALIAS * avr_locate_memalias(AVRPART * p, char * desc);
|
||||||
|
AVRMEM_ALIAS * avr_find_memalias(AVRPART * p, AVRMEM * m_orig);
|
||||||
|
void avr_mem_display(const char * prefix, FILE * f, AVRMEM * m, AVRPART * p,
|
||||||
|
int type, int verbose);
|
||||||
|
|
||||||
/* Functions for AVRPART structures */
|
/* Functions for AVRPART structures */
|
||||||
AVRPART * avr_new_part(void);
|
AVRPART * avr_new_part(void);
|
||||||
@@ -834,30 +842,6 @@ int fileio(int op, char * filename, FILEFMT format,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* formerly safemode.h */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Writes the specified fuse in fusename (can be "lfuse", "hfuse", or "efuse") and verifies it. Will try up to tries
|
|
||||||
amount of times before giving up */
|
|
||||||
int safemode_writefuse (unsigned char fuse, char * fusename, PROGRAMMER * pgm, AVRPART * p, int tries);
|
|
||||||
|
|
||||||
/* Reads the fuses three times, checking that all readings are the same. This will ensure that the before values aren't in error! */
|
|
||||||
int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse, unsigned char * efuse, unsigned char * fuse, PROGRAMMER * pgm, AVRPART * p);
|
|
||||||
|
|
||||||
/* This routine will store the current values pointed to by lfuse, hfuse, and efuse into an internal buffer in this routine
|
|
||||||
when save is set to 1. When save is 0 (or not 1 really) it will copy the values from the internal buffer into the locations
|
|
||||||
pointed to be lfuse, hfuse, and efuse. This allows you to change the fuse bits if needed from another routine (ie: have it so
|
|
||||||
if user requests fuse bits are changed, the requested value is now verified */
|
|
||||||
int safemode_memfuses (int save, unsigned char * lfuse, unsigned char * hfuse, unsigned char * efuse, unsigned char * fuse);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* formerly update.h */
|
/* formerly update.h */
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -929,7 +913,6 @@ extern char default_programmer[];
|
|||||||
extern char default_parallel[];
|
extern char default_parallel[];
|
||||||
extern char default_serial[];
|
extern char default_serial[];
|
||||||
extern double default_bitclock;
|
extern double default_bitclock;
|
||||||
extern int default_safemode;
|
|
||||||
|
|
||||||
/* This name is fixed, it's only here for symmetry with
|
/* This name is fixed, it's only here for symmetry with
|
||||||
* default_parallel and default_serial. */
|
* default_parallel and default_serial. */
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ static int linuxspi_open(PROGRAMMER *pgm, char *port)
|
|||||||
avrdude_message(MSG_INFO,
|
avrdude_message(MSG_INFO,
|
||||||
"%s: obsolete use of -b <clock> option for bit clock; use -B <clock>\n",
|
"%s: obsolete use of -b <clock> option for bit clock; use -B <clock>\n",
|
||||||
progname);
|
progname);
|
||||||
pgm->bitclock = 1E6 / pgm->baudrate;
|
pgm->bitclock = 1.0 / pgm->baudrate;
|
||||||
}
|
}
|
||||||
if (pgm->bitclock == 0) {
|
if (pgm->bitclock == 0) {
|
||||||
avrdude_message(MSG_NOTICE,
|
avrdude_message(MSG_NOTICE,
|
||||||
|
|||||||
257
src/main.c
257
src/main.c
@@ -122,9 +122,6 @@ static void usage(void)
|
|||||||
" is performed in the order specified.\n"
|
" is performed in the order specified.\n"
|
||||||
" -n Do not write anything to the device.\n"
|
" -n Do not write anything to the device.\n"
|
||||||
" -V Do not verify.\n"
|
" -V Do not verify.\n"
|
||||||
" -u Disable safemode, default when running from a script.\n"
|
|
||||||
" -s Silent safemode operation, will not ask you if\n"
|
|
||||||
" fuses should be changed back.\n"
|
|
||||||
" -t Enter terminal mode.\n"
|
" -t Enter terminal mode.\n"
|
||||||
" -E <exitspec>[,<exitspec>] List programmer exit specifications.\n"
|
" -E <exitspec>[,<exitspec>] List programmer exit specifications.\n"
|
||||||
" -x <extended_param> Pass <extended_param> to programmer.\n"
|
" -x <extended_param> Pass <extended_param> to programmer.\n"
|
||||||
@@ -349,19 +346,11 @@ int main(int argc, char * argv [])
|
|||||||
int baudrate; /* override default programmer baud rate */
|
int baudrate; /* override default programmer baud rate */
|
||||||
double bitclock; /* Specify programmer bit clock (JTAG ICE) */
|
double bitclock; /* Specify programmer bit clock (JTAG ICE) */
|
||||||
int ispdelay; /* Specify the delay for ISP clock */
|
int ispdelay; /* Specify the delay for ISP clock */
|
||||||
int safemode; /* Enable safemode, 1=safemode on, 0=normal */
|
|
||||||
int silentsafe; /* Don't ask about fuses, 1=silent, 0=normal */
|
|
||||||
int init_ok; /* Device initialization worked well */
|
int init_ok; /* Device initialization worked well */
|
||||||
int is_open; /* Device open succeeded */
|
int is_open; /* Device open succeeded */
|
||||||
char * logfile; /* Use logfile rather than stderr for diagnostics */
|
char * logfile; /* Use logfile rather than stderr for diagnostics */
|
||||||
enum updateflags uflags = UF_AUTO_ERASE; /* Flags for do_op() */
|
enum updateflags uflags = UF_AUTO_ERASE; /* Flags for do_op() */
|
||||||
unsigned char safemode_lfuse = 0xff;
|
|
||||||
unsigned char safemode_hfuse = 0xff;
|
|
||||||
unsigned char safemode_efuse = 0xff;
|
|
||||||
unsigned char safemode_fuse = 0xff;
|
|
||||||
|
|
||||||
char * safemode_response;
|
|
||||||
int fuses_updated = 0;
|
|
||||||
#if !defined(WIN32)
|
#if !defined(WIN32)
|
||||||
char * homedir;
|
char * homedir;
|
||||||
#endif
|
#endif
|
||||||
@@ -394,7 +383,6 @@ int main(int argc, char * argv [])
|
|||||||
default_parallel[0] = 0;
|
default_parallel[0] = 0;
|
||||||
default_serial[0] = 0;
|
default_serial[0] = 0;
|
||||||
default_bitclock = 0.0;
|
default_bitclock = 0.0;
|
||||||
default_safemode = -1;
|
|
||||||
|
|
||||||
init_config();
|
init_config();
|
||||||
|
|
||||||
@@ -434,8 +422,6 @@ int main(int argc, char * argv [])
|
|||||||
baudrate = 0;
|
baudrate = 0;
|
||||||
bitclock = 0.0;
|
bitclock = 0.0;
|
||||||
ispdelay = 0;
|
ispdelay = 0;
|
||||||
safemode = 1; /* Safemode on by default */
|
|
||||||
silentsafe = 0; /* Ask by default */
|
|
||||||
is_open = 0;
|
is_open = 0;
|
||||||
logfile = NULL;
|
logfile = NULL;
|
||||||
|
|
||||||
@@ -581,17 +567,13 @@ int main(int argc, char * argv [])
|
|||||||
quell_progress++ ;
|
quell_progress++ ;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's' : /* Silent safemode */
|
|
||||||
silentsafe = 1;
|
|
||||||
safemode = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 't': /* enter terminal mode */
|
case 't': /* enter terminal mode */
|
||||||
terminal = 1;
|
terminal = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'u' : /* Disable safemode */
|
case 'u':
|
||||||
safemode = 0;
|
avrdude_message(MSG_INFO, "%s: \"safemode\" feature no longer supported\n",
|
||||||
|
progname);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'U':
|
case 'U':
|
||||||
@@ -975,29 +957,6 @@ int main(int argc, char * argv [])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (default_safemode == 0) {
|
|
||||||
/* configuration disables safemode: revert meaning of -u */
|
|
||||||
if (safemode == 0)
|
|
||||||
/* -u was given: enable safemode */
|
|
||||||
safemode = 1;
|
|
||||||
else
|
|
||||||
/* -u not given: turn off */
|
|
||||||
safemode = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isatty(STDIN_FILENO) == 0 && silentsafe == 0)
|
|
||||||
safemode = 0; /* Turn off safemode if this isn't a terminal */
|
|
||||||
|
|
||||||
|
|
||||||
if(p->flags & AVRPART_AVR32) {
|
|
||||||
safemode = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_TPI)) {
|
|
||||||
safemode = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (avr_initmem(p) != 0)
|
if (avr_initmem(p) != 0)
|
||||||
{
|
{
|
||||||
avrdude_message(MSG_INFO, "\n%s: failed to initialize memories\n",
|
avrdude_message(MSG_INFO, "\n%s: failed to initialize memories\n",
|
||||||
@@ -1065,6 +1024,9 @@ int main(int argc, char * argv [])
|
|||||||
|
|
||||||
rc = pgm->open(pgm, port);
|
rc = pgm->open(pgm, port);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
|
avrdude_message(MSG_INFO,
|
||||||
|
"%s: opening programmer \"%s\" on port \"%s\" failed\n",
|
||||||
|
progname, programmer, port);
|
||||||
exitrc = 1;
|
exitrc = 1;
|
||||||
pgm->ppidata = 0; /* clear all bits at exit */
|
pgm->ppidata = 0; /* clear all bits at exit */
|
||||||
goto main_exit;
|
goto main_exit;
|
||||||
@@ -1222,12 +1184,19 @@ int main(int argc, char * argv [])
|
|||||||
if (sig->buf[i] != 0x00)
|
if (sig->buf[i] != 0x00)
|
||||||
zz = 0;
|
zz = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool signature_matches =
|
||||||
|
sig->size == 3 &&
|
||||||
|
sig->buf[0] == p->signature[0] &&
|
||||||
|
sig->buf[1] == p->signature[1] &&
|
||||||
|
sig->buf[2] == p->signature[2];
|
||||||
|
|
||||||
if (quell_progress < 2) {
|
if (quell_progress < 2) {
|
||||||
AVRPART * part;
|
AVRPART * part;
|
||||||
|
|
||||||
part = locate_part_by_signature(part_list, sig->buf, sig->size);
|
part = locate_part_by_signature(part_list, sig->buf, sig->size);
|
||||||
if (part) {
|
if (part) {
|
||||||
avrdude_message(MSG_INFO, " (probably %s)", part->id);
|
avrdude_message(MSG_INFO, " (probably %s)", signature_matches ? p->id : part->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ff || zz) {
|
if (ff || zz) {
|
||||||
@@ -1256,10 +1225,7 @@ int main(int argc, char * argv [])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sig->size != 3 ||
|
if (!signature_matches) {
|
||||||
sig->buf[0] != p->signature[0] ||
|
|
||||||
sig->buf[1] != p->signature[1] ||
|
|
||||||
sig->buf[2] != p->signature[2]) {
|
|
||||||
avrdude_message(MSG_INFO, "%s: Expected signature for %s is %02X %02X %02X\n",
|
avrdude_message(MSG_INFO, "%s: Expected signature for %s is %02X %02X %02X\n",
|
||||||
progname, p->desc,
|
progname, p->desc,
|
||||||
p->signature[0], p->signature[1], p->signature[2]);
|
p->signature[0], p->signature[1], p->signature[2]);
|
||||||
@@ -1274,36 +1240,6 @@ int main(int argc, char * argv [])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (init_ok && safemode == 1) {
|
|
||||||
/* If safemode is enabled, go ahead and read the current low, high,
|
|
||||||
and extended fuse bytes as needed */
|
|
||||||
|
|
||||||
rc = safemode_readfuses(&safemode_lfuse, &safemode_hfuse,
|
|
||||||
&safemode_efuse, &safemode_fuse, pgm, p);
|
|
||||||
|
|
||||||
if (rc != 0) {
|
|
||||||
|
|
||||||
//Check if the programmer just doesn't support reading
|
|
||||||
if (rc == -5)
|
|
||||||
{
|
|
||||||
avrdude_message(MSG_NOTICE, "%s: safemode: Fuse reading not supported by programmer.\n"
|
|
||||||
" Safemode disabled.\n", progname);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
avrdude_message(MSG_INFO, "%s: safemode: To protect your AVR the programming "
|
|
||||||
"will be aborted\n",
|
|
||||||
progname);
|
|
||||||
exitrc = 1;
|
|
||||||
goto main_exit;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//Save the fuses as default
|
|
||||||
safemode_memfuses(1, &safemode_lfuse, &safemode_hfuse, &safemode_efuse, &safemode_fuse);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (uflags & UF_AUTO_ERASE) {
|
if (uflags & UF_AUTO_ERASE) {
|
||||||
if ((p->flags & AVRPART_HAS_PDI) && pgm->page_erase != NULL &&
|
if ((p->flags & AVRPART_HAS_PDI) && pgm->page_erase != NULL &&
|
||||||
lsize(updates) > 0) {
|
lsize(updates) > 0) {
|
||||||
@@ -1379,169 +1315,6 @@ int main(int argc, char * argv [])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Right before we exit programming mode, which will make the fuse
|
|
||||||
bits active, check to make sure they are still correct */
|
|
||||||
if (safemode == 1) {
|
|
||||||
/* If safemode is enabled, go ahead and read the current low,
|
|
||||||
* high, and extended fuse bytes as needed */
|
|
||||||
unsigned char safemodeafter_lfuse = 0xff;
|
|
||||||
unsigned char safemodeafter_hfuse = 0xff;
|
|
||||||
unsigned char safemodeafter_efuse = 0xff;
|
|
||||||
unsigned char safemodeafter_fuse = 0xff;
|
|
||||||
unsigned char failures = 0;
|
|
||||||
char yes[1] = {'y'};
|
|
||||||
|
|
||||||
if (quell_progress < 2) {
|
|
||||||
avrdude_message(MSG_INFO, "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
//Restore the default fuse values
|
|
||||||
safemode_memfuses(0, &safemode_lfuse, &safemode_hfuse, &safemode_efuse, &safemode_fuse);
|
|
||||||
|
|
||||||
/* Try reading back fuses, make sure they are reliable to read back */
|
|
||||||
if (safemode_readfuses(&safemodeafter_lfuse, &safemodeafter_hfuse,
|
|
||||||
&safemodeafter_efuse, &safemodeafter_fuse, pgm, p) != 0) {
|
|
||||||
/* Uh-oh.. try once more to read back fuses */
|
|
||||||
if (safemode_readfuses(&safemodeafter_lfuse, &safemodeafter_hfuse,
|
|
||||||
&safemodeafter_efuse, &safemodeafter_fuse, pgm, p) != 0) {
|
|
||||||
avrdude_message(MSG_INFO, "%s: safemode: Sorry, reading back fuses was unreliable. "
|
|
||||||
"I have given up and exited programming mode\n",
|
|
||||||
progname);
|
|
||||||
exitrc = 1;
|
|
||||||
goto main_exit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AVRMEM * m;
|
|
||||||
|
|
||||||
/* Now check what fuses are against what they should be */
|
|
||||||
m = avr_locate_mem(p, "fuse");
|
|
||||||
if (compare_memory_masked(m, safemodeafter_fuse, safemode_fuse)) {
|
|
||||||
fuses_updated = 1;
|
|
||||||
avrdude_message(MSG_INFO, "%s: safemode: fuse changed! Was %x, and is now %x\n",
|
|
||||||
progname, safemode_fuse, safemodeafter_fuse);
|
|
||||||
|
|
||||||
|
|
||||||
/* Ask user - should we change them */
|
|
||||||
|
|
||||||
if (silentsafe == 0)
|
|
||||||
safemode_response = terminal_get_input("Would you like this fuse to be changed back? [y/n] ");
|
|
||||||
else
|
|
||||||
safemode_response = yes;
|
|
||||||
|
|
||||||
if (tolower((int)(safemode_response[0])) == 'y') {
|
|
||||||
|
|
||||||
/* Enough chit-chat, time to program some fuses and check them */
|
|
||||||
if (safemode_writefuse (safemode_fuse, "fuse", pgm, p,
|
|
||||||
10) == 0) {
|
|
||||||
avrdude_message(MSG_INFO, "%s: safemode: and is now rescued\n", progname);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
avrdude_message(MSG_INFO, "%s: and COULD NOT be changed\n", progname);
|
|
||||||
failures++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now check what fuses are against what they should be */
|
|
||||||
m = avr_locate_mem(p, "lfuse");
|
|
||||||
if (compare_memory_masked(m, safemodeafter_lfuse, safemode_lfuse)) {
|
|
||||||
fuses_updated = 1;
|
|
||||||
avrdude_message(MSG_INFO, "%s: safemode: lfuse changed! Was %x, and is now %x\n",
|
|
||||||
progname, safemode_lfuse, safemodeafter_lfuse);
|
|
||||||
|
|
||||||
|
|
||||||
/* Ask user - should we change them */
|
|
||||||
|
|
||||||
if (silentsafe == 0)
|
|
||||||
safemode_response = terminal_get_input("Would you like this fuse to be changed back? [y/n] ");
|
|
||||||
else
|
|
||||||
safemode_response = yes;
|
|
||||||
|
|
||||||
if (tolower((int)(safemode_response[0])) == 'y') {
|
|
||||||
|
|
||||||
/* Enough chit-chat, time to program some fuses and check them */
|
|
||||||
if (safemode_writefuse (safemode_lfuse, "lfuse", pgm, p,
|
|
||||||
10) == 0) {
|
|
||||||
avrdude_message(MSG_INFO, "%s: safemode: and is now rescued\n", progname);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
avrdude_message(MSG_INFO, "%s: and COULD NOT be changed\n", progname);
|
|
||||||
failures++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now check what fuses are against what they should be */
|
|
||||||
m = avr_locate_mem(p, "hfuse");
|
|
||||||
if (compare_memory_masked(m, safemodeafter_hfuse, safemode_hfuse)) {
|
|
||||||
fuses_updated = 1;
|
|
||||||
avrdude_message(MSG_INFO, "%s: safemode: hfuse changed! Was %x, and is now %x\n",
|
|
||||||
progname, safemode_hfuse, safemodeafter_hfuse);
|
|
||||||
|
|
||||||
/* Ask user - should we change them */
|
|
||||||
if (silentsafe == 0)
|
|
||||||
safemode_response = terminal_get_input("Would you like this fuse to be changed back? [y/n] ");
|
|
||||||
else
|
|
||||||
safemode_response = yes;
|
|
||||||
if (tolower((int)(safemode_response[0])) == 'y') {
|
|
||||||
|
|
||||||
/* Enough chit-chat, time to program some fuses and check them */
|
|
||||||
if (safemode_writefuse(safemode_hfuse, "hfuse", pgm, p,
|
|
||||||
10) == 0) {
|
|
||||||
avrdude_message(MSG_INFO, "%s: safemode: and is now rescued\n", progname);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
avrdude_message(MSG_INFO, "%s: and COULD NOT be changed\n", progname);
|
|
||||||
failures++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now check what fuses are against what they should be */
|
|
||||||
m = avr_locate_mem(p, "efuse");
|
|
||||||
if (compare_memory_masked(m, safemodeafter_efuse, safemode_efuse)) {
|
|
||||||
fuses_updated = 1;
|
|
||||||
avrdude_message(MSG_INFO, "%s: safemode: efuse changed! Was %x, and is now %x\n",
|
|
||||||
progname, safemode_efuse, safemodeafter_efuse);
|
|
||||||
|
|
||||||
/* Ask user - should we change them */
|
|
||||||
if (silentsafe == 0)
|
|
||||||
safemode_response = terminal_get_input("Would you like this fuse to be changed back? [y/n] ");
|
|
||||||
else
|
|
||||||
safemode_response = yes;
|
|
||||||
if (tolower((int)(safemode_response[0])) == 'y') {
|
|
||||||
|
|
||||||
/* Enough chit-chat, time to program some fuses and check them */
|
|
||||||
if (safemode_writefuse (safemode_efuse, "efuse", pgm, p,
|
|
||||||
10) == 0) {
|
|
||||||
avrdude_message(MSG_INFO, "%s: safemode: and is now rescued\n", progname);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
avrdude_message(MSG_INFO, "%s: and COULD NOT be changed\n", progname);
|
|
||||||
failures++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (quell_progress < 2) {
|
|
||||||
avrdude_message(MSG_INFO, "%s: safemode: ", progname);
|
|
||||||
if (failures == 0) {
|
|
||||||
avrdude_message(MSG_INFO, "Fuses OK (E:%02X, H:%02X, L:%02X)\n",
|
|
||||||
safemodeafter_efuse, safemodeafter_hfuse, safemodeafter_lfuse);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
avrdude_message(MSG_INFO, "Fuses not recovered, sorry\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fuses_updated) {
|
|
||||||
exitrc = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
main_exit:
|
main_exit:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -21,7 +21,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#include <intrin.h>
|
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
|
||||||
#pragma comment(lib, "advapi32.lib")
|
#pragma comment(lib, "advapi32.lib")
|
||||||
@@ -35,19 +34,6 @@
|
|||||||
|
|
||||||
#define setvbuf msvc_setvbuf
|
#define setvbuf msvc_setvbuf
|
||||||
|
|
||||||
static inline int __builtin_popcount(unsigned int v)
|
|
||||||
{
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
while (v)
|
|
||||||
{
|
|
||||||
count += v & 1;
|
|
||||||
v >>= 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int msvc_setvbuf(
|
static inline int msvc_setvbuf(
|
||||||
FILE* const public_stream,
|
FILE* const public_stream,
|
||||||
char* const buffer,
|
char* const buffer,
|
||||||
|
|||||||
@@ -1028,12 +1028,12 @@ namespace UsbComLocator
|
|||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
PrintMessage(level, format, args);
|
PrintMessageV(level, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintMessage(MessageLevel level, _In_z_ _Printf_format_string_ const char* format, va_list args)
|
void PrintMessageV(MessageLevel level, _In_z_ _Printf_format_string_ const char* format, va_list args)
|
||||||
{
|
{
|
||||||
if (m_console != nullptr)
|
if (m_console != nullptr)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "ac_cfg.h"
|
||||||
#include "avrdude.h"
|
#include "avrdude.h"
|
||||||
#include "libavrdude.h"
|
#include "libavrdude.h"
|
||||||
|
|
||||||
@@ -217,7 +218,7 @@ const char * pinmask_to_str(const pinmask_t * const pinmask) {
|
|||||||
* @param[in] size the number of entries in checklist
|
* @param[in] size the number of entries in checklist
|
||||||
* @returns 0 if all pin definitions are valid, -1 otherwise
|
* @returns 0 if all pin definitions are valid, -1 otherwise
|
||||||
*/
|
*/
|
||||||
int pins_check(const struct programmer_t * const pgm, const struct pin_checklist_t * const checklist, const int size, bool output) {
|
int pins_check(const struct programmer_t * const pgm, const struct pin_checklist_t * const checklist, const int size, const bool output) {
|
||||||
static const struct pindef_t no_valid_pins = {{0}, {0}}; // default value if check list does not contain anything else
|
static const struct pindef_t no_valid_pins = {{0}, {0}}; // default value if check list does not contain anything else
|
||||||
int rv = 0; // return value
|
int rv = 0; // return value
|
||||||
int pinname; // loop counter through pinnames
|
int pinname; // loop counter through pinnames
|
||||||
|
|||||||
318
src/safemode.c
318
src/safemode.c
@@ -1,318 +0,0 @@
|
|||||||
/*
|
|
||||||
* avrdude - A Downloader/Uploader for AVR device programmers
|
|
||||||
* avrdude is Copyright (C) 2000-2004 Brian S. Dean <bsd@bsdhome.com>
|
|
||||||
*
|
|
||||||
* This file: Copyright (C) 2005-2007 Colin O'Flynn <coflynn@newae.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program 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 General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include "ac_cfg.h"
|
|
||||||
|
|
||||||
#include "avrdude.h"
|
|
||||||
#include "libavrdude.h"
|
|
||||||
|
|
||||||
/* This value from ac_cfg.h */
|
|
||||||
/*
|
|
||||||
* Writes the specified fuse in fusename (can be "lfuse", "hfuse", or
|
|
||||||
* "efuse") and verifies it. Will try up to tries amount of times
|
|
||||||
* before giving up
|
|
||||||
*/
|
|
||||||
int safemode_writefuse (unsigned char fuse, char * fusename, PROGRAMMER * pgm,
|
|
||||||
AVRPART * p, int tries)
|
|
||||||
{
|
|
||||||
AVRMEM * m;
|
|
||||||
unsigned char fuseread;
|
|
||||||
int returnvalue = -1;
|
|
||||||
|
|
||||||
m = avr_locate_mem(p, fusename);
|
|
||||||
if (m == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Keep trying to write then read back the fuse values */
|
|
||||||
while (tries > 0) {
|
|
||||||
if (avr_write_byte(pgm, p, m, 0, fuse) != 0)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (pgm->read_byte(pgm, p, m, 0, &fuseread) != 0)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Report information to user if needed */
|
|
||||||
avrdude_message(MSG_NOTICE, "%s: safemode: Wrote %s to %x, read as %x. %d attempts left\n",
|
|
||||||
progname, fusename, fuse, fuseread, tries-1);
|
|
||||||
|
|
||||||
/* If fuse wrote OK, no need to keep going */
|
|
||||||
if (fuse == fuseread) {
|
|
||||||
tries = 0;
|
|
||||||
returnvalue = 0;
|
|
||||||
}
|
|
||||||
tries--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return returnvalue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Reads the fuses three times, checking that all readings are the
|
|
||||||
* same. This will ensure that the before values aren't in error!
|
|
||||||
*/
|
|
||||||
int safemode_readfuses (unsigned char * lfuse, unsigned char * hfuse,
|
|
||||||
unsigned char * efuse, unsigned char * fuse,
|
|
||||||
PROGRAMMER * pgm, AVRPART * p)
|
|
||||||
{
|
|
||||||
|
|
||||||
unsigned char value;
|
|
||||||
unsigned char fusegood = 0;
|
|
||||||
unsigned char allowfuseread = 1;
|
|
||||||
unsigned char safemode_lfuse;
|
|
||||||
unsigned char safemode_hfuse;
|
|
||||||
unsigned char safemode_efuse;
|
|
||||||
unsigned char safemode_fuse;
|
|
||||||
AVRMEM * m;
|
|
||||||
|
|
||||||
safemode_lfuse = *lfuse;
|
|
||||||
safemode_hfuse = *hfuse;
|
|
||||||
safemode_efuse = *efuse;
|
|
||||||
safemode_fuse = *fuse;
|
|
||||||
|
|
||||||
|
|
||||||
/* Read fuse three times */
|
|
||||||
fusegood = 2; /* If AVR device doesn't support this fuse, don't want
|
|
||||||
to generate a verify error */
|
|
||||||
m = avr_locate_mem(p, "fuse");
|
|
||||||
if (m != NULL) {
|
|
||||||
fusegood = 0; /* By default fuse is a failure */
|
|
||||||
if(pgm->read_byte(pgm, p, m, 0, &safemode_fuse) != 0)
|
|
||||||
{
|
|
||||||
allowfuseread = 0;
|
|
||||||
}
|
|
||||||
avrdude_message(MSG_DEBUG, "%s: safemode read 1, fuse value: %x\n",progname, safemode_fuse);
|
|
||||||
if(pgm->read_byte(pgm, p, m, 0, &value) != 0)
|
|
||||||
{
|
|
||||||
allowfuseread = 0;
|
|
||||||
}
|
|
||||||
avrdude_message(MSG_DEBUG, "%s: safemode read 2, fuse value: %x\n",progname, value);
|
|
||||||
if (value == safemode_fuse) {
|
|
||||||
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
|
|
||||||
{
|
|
||||||
allowfuseread = 0;
|
|
||||||
}
|
|
||||||
avrdude_message(MSG_DEBUG, "%s: safemode read 3, fuse value: %x\n",progname, value);
|
|
||||||
if (value == safemode_fuse)
|
|
||||||
{
|
|
||||||
fusegood = 1; /* Fuse read OK three times */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Programmer does not allow fuse reading.... no point trying anymore
|
|
||||||
if (allowfuseread == 0)
|
|
||||||
{
|
|
||||||
return -5;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fusegood == 0) {
|
|
||||||
avrdude_message(MSG_INFO, "%s: safemode: Verify error - unable to read fuse properly. "
|
|
||||||
"Programmer may not be reliable.\n", progname);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if (fusegood == 1) {
|
|
||||||
avrdude_message(MSG_NOTICE, "%s: safemode: fuse reads as %X\n", progname, safemode_fuse);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Read lfuse three times */
|
|
||||||
fusegood = 2; /* If AVR device doesn't support this fuse, don't want
|
|
||||||
to generate a verify error */
|
|
||||||
m = avr_locate_mem(p, "lfuse");
|
|
||||||
if (m != NULL) {
|
|
||||||
fusegood = 0; /* By default fuse is a failure */
|
|
||||||
if (pgm->read_byte(pgm, p, m, 0, &safemode_lfuse) != 0)
|
|
||||||
{
|
|
||||||
allowfuseread = 0;
|
|
||||||
}
|
|
||||||
avrdude_message(MSG_DEBUG, "%s: safemode read 1, lfuse value: %x\n",progname, safemode_lfuse);
|
|
||||||
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
|
|
||||||
{
|
|
||||||
allowfuseread = 0;
|
|
||||||
}
|
|
||||||
avrdude_message(MSG_DEBUG, "%s: safemode read 2, lfuse value: %x\n",progname, value);
|
|
||||||
if (value == safemode_lfuse) {
|
|
||||||
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
|
|
||||||
{
|
|
||||||
allowfuseread = 0;
|
|
||||||
}
|
|
||||||
avrdude_message(MSG_DEBUG, "%s: safemode read 3, lfuse value: %x\n",progname, value);
|
|
||||||
if (value == safemode_lfuse){
|
|
||||||
fusegood = 1; /* Fuse read OK three times */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Programmer does not allow fuse reading.... no point trying anymore
|
|
||||||
if (allowfuseread == 0)
|
|
||||||
{
|
|
||||||
return -5;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (fusegood == 0) {
|
|
||||||
avrdude_message(MSG_INFO, "%s: safemode: Verify error - unable to read lfuse properly. "
|
|
||||||
"Programmer may not be reliable.\n", progname);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else if (fusegood == 1) {
|
|
||||||
avrdude_message(MSG_NOTICE, "%s: safemode: lfuse reads as %X\n", progname, safemode_lfuse);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Read hfuse three times */
|
|
||||||
fusegood = 2; /* If AVR device doesn't support this fuse, don't want
|
|
||||||
to generate a verify error */
|
|
||||||
m = avr_locate_mem(p, "hfuse");
|
|
||||||
if (m != NULL) {
|
|
||||||
fusegood = 0; /* By default fuse is a failure */
|
|
||||||
if (pgm->read_byte(pgm, p, m, 0, &safemode_hfuse) != 0)
|
|
||||||
{
|
|
||||||
allowfuseread = 0;
|
|
||||||
}
|
|
||||||
avrdude_message(MSG_DEBUG, "%s: safemode read 1, hfuse value: %x\n",progname, safemode_hfuse);
|
|
||||||
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
|
|
||||||
{
|
|
||||||
allowfuseread = 0;
|
|
||||||
}
|
|
||||||
avrdude_message(MSG_DEBUG, "%s: safemode read 2, hfuse value: %x\n",progname, value);
|
|
||||||
if (value == safemode_hfuse) {
|
|
||||||
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
|
|
||||||
{
|
|
||||||
allowfuseread = 0;
|
|
||||||
}
|
|
||||||
avrdude_message(MSG_DEBUG, "%s: safemode read 3, hfuse value: %x\n",progname, value);
|
|
||||||
if (value == safemode_hfuse){
|
|
||||||
fusegood = 1; /* Fuse read OK three times */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Programmer does not allow fuse reading.... no point trying anymore
|
|
||||||
if (allowfuseread == 0)
|
|
||||||
{
|
|
||||||
return -5;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fusegood == 0) {
|
|
||||||
avrdude_message(MSG_INFO, "%s: safemode: Verify error - unable to read hfuse properly. "
|
|
||||||
"Programmer may not be reliable.\n", progname);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
else if (fusegood == 1){
|
|
||||||
avrdude_message(MSG_NOTICE, "%s: safemode: hfuse reads as %X\n", progname, safemode_hfuse);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Read efuse three times */
|
|
||||||
fusegood = 2; /* If AVR device doesn't support this fuse, don't want
|
|
||||||
to generate a verify error */
|
|
||||||
m = avr_locate_mem(p, "efuse");
|
|
||||||
if (m != NULL) {
|
|
||||||
fusegood = 0; /* By default fuse is a failure */
|
|
||||||
if (pgm->read_byte(pgm, p, m, 0, &safemode_efuse) != 0)
|
|
||||||
{
|
|
||||||
allowfuseread = 0;
|
|
||||||
}
|
|
||||||
avrdude_message(MSG_DEBUG, "%s: safemode read 1, efuse value: %x\n",progname, safemode_efuse);
|
|
||||||
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
|
|
||||||
{
|
|
||||||
allowfuseread = 0;
|
|
||||||
}
|
|
||||||
avrdude_message(MSG_DEBUG, "%s: safemode read 2, efuse value: %x\n",progname, value);
|
|
||||||
if (value == safemode_efuse) {
|
|
||||||
if (pgm->read_byte(pgm, p, m, 0, &value) != 0)
|
|
||||||
{
|
|
||||||
allowfuseread = 0;
|
|
||||||
}
|
|
||||||
avrdude_message(MSG_DEBUG, "%s: safemode read 3, efuse value: %x\n",progname, value);
|
|
||||||
if (value == safemode_efuse){
|
|
||||||
fusegood = 1; /* Fuse read OK three times */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Programmer does not allow fuse reading.... no point trying anymore
|
|
||||||
if (allowfuseread == 0)
|
|
||||||
{
|
|
||||||
return -5;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fusegood == 0) {
|
|
||||||
avrdude_message(MSG_INFO, "%s: safemode: Verify error - unable to read efuse properly. "
|
|
||||||
"Programmer may not be reliable.\n", progname);
|
|
||||||
return -3;
|
|
||||||
}
|
|
||||||
else if (fusegood == 1) {
|
|
||||||
avrdude_message(MSG_NOTICE, "%s: safemode: efuse reads as %X\n", progname, safemode_efuse);
|
|
||||||
}
|
|
||||||
|
|
||||||
*lfuse = safemode_lfuse;
|
|
||||||
*hfuse = safemode_hfuse;
|
|
||||||
*efuse = safemode_efuse;
|
|
||||||
*fuse = safemode_fuse;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This routine will store the current values pointed to by lfuse,
|
|
||||||
* hfuse, and efuse into an internal buffer in this routine when save
|
|
||||||
* is set to 1. When save is 0 (or not 1 really) it will copy the
|
|
||||||
* values from the internal buffer into the locations pointed to be
|
|
||||||
* lfuse, hfuse, and efuse. This allows you to change the fuse bits if
|
|
||||||
* needed from another routine (ie: have it so if user requests fuse
|
|
||||||
* bits are changed, the requested value is now verified
|
|
||||||
*/
|
|
||||||
int safemode_memfuses (int save, unsigned char * lfuse, unsigned char * hfuse,
|
|
||||||
unsigned char * efuse, unsigned char * fuse)
|
|
||||||
{
|
|
||||||
static unsigned char safemode_lfuse = 0xff;
|
|
||||||
static unsigned char safemode_hfuse = 0xff;
|
|
||||||
static unsigned char safemode_efuse = 0xff;
|
|
||||||
static unsigned char safemode_fuse = 0xff;
|
|
||||||
|
|
||||||
switch (save) {
|
|
||||||
|
|
||||||
/* Save the fuses as safemode setting */
|
|
||||||
case 1:
|
|
||||||
safemode_lfuse = *lfuse;
|
|
||||||
safemode_hfuse = *hfuse;
|
|
||||||
safemode_efuse = *efuse;
|
|
||||||
safemode_fuse = *fuse;
|
|
||||||
|
|
||||||
break;
|
|
||||||
/* Read back the fuses */
|
|
||||||
default:
|
|
||||||
*lfuse = safemode_lfuse;
|
|
||||||
*hfuse = safemode_hfuse;
|
|
||||||
*efuse = safemode_efuse;
|
|
||||||
*fuse = safemode_fuse;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -26,11 +26,12 @@
|
|||||||
|
|
||||||
#include "ac_cfg.h"
|
#include "ac_cfg.h"
|
||||||
|
|
||||||
#if defined(HAVE_LIBHIDAPI) || (defined(WIN32) && defined(HAVE_LIBHID))
|
#if defined(HAVE_LIBHIDAPI)
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <hidapi/hidapi.h>
|
||||||
|
|
||||||
#include "avrdude.h"
|
#include "avrdude.h"
|
||||||
#include "libavrdude.h"
|
#include "libavrdude.h"
|
||||||
@@ -64,12 +65,6 @@ static int avrdoperRxPosition = 0; /* amount of bytes already consu
|
|||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
#if defined(HAVE_LIBHIDAPI)
|
|
||||||
|
|
||||||
#include <hidapi/hidapi.h>
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
static int usbOpenDevice(union filedescriptor *fdp, int vendor, char *vendorName,
|
static int usbOpenDevice(union filedescriptor *fdp, int vendor, char *vendorName,
|
||||||
int product, char *productName, int doReportIDs)
|
int product, char *productName, int doReportIDs)
|
||||||
{
|
{
|
||||||
@@ -154,181 +149,6 @@ static int usbGetReport(union filedescriptor *fdp, int reportType, int reportNum
|
|||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
#else /* !defined(HAVE_LIBHIDAPI) */
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
|
||||||
/* ------------------------------------------------------------------------ */
|
|
||||||
/* ------------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <windows.h>
|
|
||||||
#include <setupapi.h>
|
|
||||||
#include <hidsdi.h>
|
|
||||||
#include <hidpi.h>
|
|
||||||
|
|
||||||
#ifdef USB_DEBUG
|
|
||||||
#define DEBUG_PRINT(arg) printf arg
|
|
||||||
#else
|
|
||||||
#define DEBUG_PRINT(arg)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
static void convertUniToAscii(char *buffer)
|
|
||||||
{
|
|
||||||
unsigned short *uni = (void *)buffer;
|
|
||||||
char *ascii = buffer;
|
|
||||||
|
|
||||||
while(*uni != 0){
|
|
||||||
if(*uni >= 256){
|
|
||||||
*ascii++ = '?';
|
|
||||||
uni++;
|
|
||||||
}else{
|
|
||||||
*ascii++ = *uni++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*ascii++ = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int usbOpenDevice(union filedescriptor *fdp, int vendor, char *vendorName,
|
|
||||||
int product, char *productName, int usesReportIDs)
|
|
||||||
{
|
|
||||||
GUID hidGuid; /* GUID for HID driver */
|
|
||||||
HDEVINFO deviceInfoList;
|
|
||||||
SP_DEVICE_INTERFACE_DATA deviceInfo;
|
|
||||||
SP_DEVICE_INTERFACE_DETAIL_DATA *deviceDetails = NULL;
|
|
||||||
DWORD size;
|
|
||||||
int i, openFlag = 0; /* may be FILE_FLAG_OVERLAPPED */
|
|
||||||
int errorCode = USB_ERROR_NOTFOUND;
|
|
||||||
HANDLE handle = INVALID_HANDLE_VALUE;
|
|
||||||
HIDD_ATTRIBUTES deviceAttributes;
|
|
||||||
|
|
||||||
HidD_GetHidGuid(&hidGuid);
|
|
||||||
deviceInfoList = SetupDiGetClassDevs(&hidGuid, NULL, NULL,
|
|
||||||
DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
|
|
||||||
deviceInfo.cbSize = sizeof(deviceInfo);
|
|
||||||
for(i=0;;i++){
|
|
||||||
if(handle != INVALID_HANDLE_VALUE){
|
|
||||||
CloseHandle(handle);
|
|
||||||
handle = INVALID_HANDLE_VALUE;
|
|
||||||
}
|
|
||||||
if(!SetupDiEnumDeviceInterfaces(deviceInfoList, 0, &hidGuid, i, &deviceInfo))
|
|
||||||
break; /* no more entries */
|
|
||||||
/* first do a dummy call just to determine the actual size required */
|
|
||||||
SetupDiGetDeviceInterfaceDetail(deviceInfoList, &deviceInfo, NULL, 0, &size, NULL);
|
|
||||||
if(deviceDetails != NULL)
|
|
||||||
free(deviceDetails);
|
|
||||||
deviceDetails = malloc(size);
|
|
||||||
deviceDetails->cbSize = sizeof(*deviceDetails);
|
|
||||||
/* this call is for real: */
|
|
||||||
SetupDiGetDeviceInterfaceDetail(deviceInfoList, &deviceInfo, deviceDetails,
|
|
||||||
size, &size, NULL);
|
|
||||||
DEBUG_PRINT(("checking HID path \"%s\"\n", deviceDetails->DevicePath));
|
|
||||||
/* attempt opening for R/W -- we don't care about devices which can't be accessed */
|
|
||||||
handle = CreateFile(deviceDetails->DevicePath, GENERIC_READ|GENERIC_WRITE,
|
|
||||||
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
|
|
||||||
openFlag, NULL);
|
|
||||||
if(handle == INVALID_HANDLE_VALUE){
|
|
||||||
DEBUG_PRINT(("opening failed: %d\n", (int)GetLastError()));
|
|
||||||
/* errorCode = USB_ERROR_ACCESS; opening will always fail for mouse -- ignore */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
deviceAttributes.Size = sizeof(deviceAttributes);
|
|
||||||
HidD_GetAttributes(handle, &deviceAttributes);
|
|
||||||
DEBUG_PRINT(("device attributes: vid=%d pid=%d\n",
|
|
||||||
deviceAttributes.VendorID, deviceAttributes.ProductID));
|
|
||||||
if(deviceAttributes.VendorID != vendor || deviceAttributes.ProductID != product)
|
|
||||||
continue; /* ignore this device */
|
|
||||||
errorCode = USB_ERROR_NOTFOUND;
|
|
||||||
if(vendorName != NULL && productName != NULL){
|
|
||||||
char buffer[512];
|
|
||||||
if(!HidD_GetManufacturerString(handle, buffer, sizeof(buffer))){
|
|
||||||
DEBUG_PRINT(("error obtaining vendor name\n"));
|
|
||||||
errorCode = USB_ERROR_IO;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
convertUniToAscii(buffer);
|
|
||||||
DEBUG_PRINT(("vendorName = \"%s\"\n", buffer));
|
|
||||||
if(strcmp(vendorName, buffer) != 0)
|
|
||||||
continue;
|
|
||||||
if(!HidD_GetProductString(handle, buffer, sizeof(buffer))){
|
|
||||||
DEBUG_PRINT(("error obtaining product name\n"));
|
|
||||||
errorCode = USB_ERROR_IO;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
convertUniToAscii(buffer);
|
|
||||||
DEBUG_PRINT(("productName = \"%s\"\n", buffer));
|
|
||||||
if(strcmp(productName, buffer) != 0)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break; /* we have found the device we are looking for! */
|
|
||||||
}
|
|
||||||
SetupDiDestroyDeviceInfoList(deviceInfoList);
|
|
||||||
if(deviceDetails != NULL)
|
|
||||||
free(deviceDetails);
|
|
||||||
if(handle != INVALID_HANDLE_VALUE){
|
|
||||||
fdp->pfd = (void *)handle;
|
|
||||||
errorCode = 0;
|
|
||||||
}
|
|
||||||
return errorCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
static void usbCloseDevice(union filedescriptor *fdp)
|
|
||||||
{
|
|
||||||
CloseHandle((HANDLE)fdp->pfd);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
static int usbSetReport(union filedescriptor *fdp, int reportType, char *buffer, int len)
|
|
||||||
{
|
|
||||||
HANDLE handle = (HANDLE)fdp->pfd;
|
|
||||||
BOOLEAN rval = 0;
|
|
||||||
DWORD bytesWritten;
|
|
||||||
|
|
||||||
switch(reportType){
|
|
||||||
case USB_HID_REPORT_TYPE_INPUT:
|
|
||||||
break;
|
|
||||||
case USB_HID_REPORT_TYPE_OUTPUT:
|
|
||||||
rval = WriteFile(handle, buffer, len, &bytesWritten, NULL);
|
|
||||||
break;
|
|
||||||
case USB_HID_REPORT_TYPE_FEATURE:
|
|
||||||
rval = HidD_SetFeature(handle, buffer, len);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return rval == 0 ? USB_ERROR_IO : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
|
||||||
|
|
||||||
static int usbGetReport(union filedescriptor *fdp, int reportType, int reportNumber,
|
|
||||||
char *buffer, int *len)
|
|
||||||
{
|
|
||||||
HANDLE handle = (HANDLE)fdp->pfd;
|
|
||||||
BOOLEAN rval = 0;
|
|
||||||
DWORD bytesRead;
|
|
||||||
|
|
||||||
switch(reportType){
|
|
||||||
case USB_HID_REPORT_TYPE_INPUT:
|
|
||||||
buffer[0] = reportNumber;
|
|
||||||
rval = ReadFile(handle, buffer, *len, &bytesRead, NULL);
|
|
||||||
if(rval)
|
|
||||||
*len = bytesRead;
|
|
||||||
break;
|
|
||||||
case USB_HID_REPORT_TYPE_OUTPUT:
|
|
||||||
break;
|
|
||||||
case USB_HID_REPORT_TYPE_FEATURE:
|
|
||||||
buffer[0] = reportNumber;
|
|
||||||
rval = HidD_GetFeature(handle, buffer, *len);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return rval == 0 ? USB_ERROR_IO : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* WIN32 */
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
@@ -551,4 +371,4 @@ struct serial_device avrdoper_serdev =
|
|||||||
.flags = SERDEV_FL_NONE,
|
.flags = SERDEV_FL_NONE,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(HAVE_LIBHIDAPI) || (defined(WIN32) && defined(HAVE_LIBHID)) */
|
#endif /* defined(HAVE_LIBHIDAPI) */
|
||||||
|
|||||||
132
src/ser_posix.c
132
src/ser_posix.c
@@ -28,6 +28,7 @@
|
|||||||
#include "ac_cfg.h"
|
#include "ac_cfg.h"
|
||||||
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -42,6 +43,10 @@
|
|||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
# include <IOKit/serial/ioss.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "avrdude.h"
|
#include "avrdude.h"
|
||||||
#include "libavrdude.h"
|
#include "libavrdude.h"
|
||||||
|
|
||||||
@@ -78,10 +83,12 @@ static struct baud_mapping baud_lookup_table [] = {
|
|||||||
static struct termios original_termios;
|
static struct termios original_termios;
|
||||||
static int saved_original_termios;
|
static int saved_original_termios;
|
||||||
|
|
||||||
static speed_t serial_baud_lookup(long baud)
|
static speed_t serial_baud_lookup(long baud, bool *nonstandard)
|
||||||
{
|
{
|
||||||
struct baud_mapping *map = baud_lookup_table;
|
struct baud_mapping *map = baud_lookup_table;
|
||||||
|
|
||||||
|
*nonstandard = false;
|
||||||
|
|
||||||
while (map->baud) {
|
while (map->baud) {
|
||||||
if (map->baud == baud)
|
if (map->baud == baud)
|
||||||
return map->speed;
|
return map->speed;
|
||||||
@@ -92,30 +99,20 @@ static speed_t serial_baud_lookup(long baud)
|
|||||||
* If a non-standard BAUD rate is used, issue
|
* If a non-standard BAUD rate is used, issue
|
||||||
* a warning (if we are verbose) and return the raw rate
|
* a warning (if we are verbose) and return the raw rate
|
||||||
*/
|
*/
|
||||||
avrdude_message(MSG_NOTICE, "%s: serial_baud_lookup(): Using non-standard baud rate: %ld",
|
avrdude_message(MSG_NOTICE, "%s: serial_baud_lookup(): Using non-standard baud rate: %ld\n",
|
||||||
progname, baud);
|
progname, baud);
|
||||||
|
|
||||||
return baud;
|
*nonstandard = true;
|
||||||
}
|
|
||||||
|
|
||||||
static tcflag_t translate_flags(unsigned long cflags)
|
return baud;
|
||||||
{
|
|
||||||
return ((cflags & SERIAL_CS5) ? CS5 : 0) |
|
|
||||||
((cflags & SERIAL_CS6) ? CS6 : 0) |
|
|
||||||
((cflags & SERIAL_CS7) ? CS7 : 0) |
|
|
||||||
((cflags & SERIAL_CS8) ? CS8 : 0) |
|
|
||||||
((cflags & SERIAL_CSTOPB) ? CSTOPB : 0) |
|
|
||||||
((cflags & SERIAL_CREAD) ? CREAD : 0) |
|
|
||||||
((cflags & (SERIAL_PARENB | SERIAL_PARODD)) ? PARENB : 0) |
|
|
||||||
((cflags & SERIAL_PARODD) ? PARODD : 0) |
|
|
||||||
((cflags & SERIAL_CLOCAL) ? CLOCAL : 0) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ser_setparams(union filedescriptor *fd, long baud, unsigned long cflags)
|
static int ser_setparams(union filedescriptor *fd, long baud, unsigned long cflags)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
struct termios termios;
|
struct termios termios;
|
||||||
speed_t speed = serial_baud_lookup (baud);
|
bool nonstandard;
|
||||||
|
speed_t speed = serial_baud_lookup (baud, &nonstandard);
|
||||||
|
|
||||||
if (!isatty(fd->ifd))
|
if (!isatty(fd->ifd))
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
@@ -137,15 +134,86 @@ static int ser_setparams(union filedescriptor *fd, long baud, unsigned long cfla
|
|||||||
original_termios = termios;
|
original_termios = termios;
|
||||||
}
|
}
|
||||||
|
|
||||||
termios.c_iflag = IGNBRK;
|
if (cflags & SERIAL_CREAD) {
|
||||||
termios.c_oflag = 0;
|
termios.c_cflag |= CREAD;
|
||||||
termios.c_lflag = 0;
|
}
|
||||||
termios.c_cflag = translate_flags(cflags);
|
if (cflags & SERIAL_CLOCAL) {
|
||||||
termios.c_cc[VMIN] = 1;
|
termios.c_cflag |= CLOCAL;
|
||||||
termios.c_cc[VTIME] = 0;
|
}
|
||||||
|
termios.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL | ISIG | IEXTEN);
|
||||||
|
#ifdef ECHOCTL
|
||||||
|
termios.c_lflag &= ~ECHOCTL;
|
||||||
|
#endif /* ECHOCTL */
|
||||||
|
#ifdef ECHOKE
|
||||||
|
termios.c_lflag &= ~ECHOKE;
|
||||||
|
#endif /* ECHOKE */
|
||||||
|
termios.c_oflag &= ~(OPOST | ONLCR | OCRNL);
|
||||||
|
termios.c_iflag &= ~(INLCR | IGNCR | ICRNL | IGNBRK);
|
||||||
|
#ifdef IUCLC
|
||||||
|
termios.c_iflag &= ~IUCLC;
|
||||||
|
#endif /* IUCLC */
|
||||||
|
#ifdef PARMRK
|
||||||
|
termios.c_iflag &= ~PARMRK;
|
||||||
|
#endif /* PARMRK */
|
||||||
|
|
||||||
|
// MacOS doesn't handle nonstandard baudrate values in
|
||||||
|
// normal tcsetattr(), sigh.
|
||||||
|
#ifdef __APPLE__
|
||||||
|
if (!nonstandard) {
|
||||||
|
#endif
|
||||||
cfsetospeed(&termios, speed);
|
cfsetospeed(&termios, speed);
|
||||||
cfsetispeed(&termios, speed);
|
cfsetispeed(&termios, speed);
|
||||||
|
#ifdef __APPLE__
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
termios.c_cflag &= ~CSIZE;
|
||||||
|
if (cflags & SERIAL_CS8) {
|
||||||
|
termios.c_cflag |= CS8;
|
||||||
|
}
|
||||||
|
if (cflags & SERIAL_CS7) {
|
||||||
|
termios.c_cflag |= CS7;
|
||||||
|
}
|
||||||
|
if (cflags & SERIAL_CS6) {
|
||||||
|
termios.c_cflag |= CS6;
|
||||||
|
}
|
||||||
|
if (cflags & SERIAL_CS5) {
|
||||||
|
termios.c_cflag |= CS5;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cflags & SERIAL_CSTOPB) {
|
||||||
|
termios.c_cflag |= CSTOPB;
|
||||||
|
} else {
|
||||||
|
termios.c_cflag &= ~CSTOPB;
|
||||||
|
}
|
||||||
|
|
||||||
|
termios.c_iflag &= ~(INPCK | ISTRIP);
|
||||||
|
|
||||||
|
if (cflags & (SERIAL_PARENB | SERIAL_PARODD)) {
|
||||||
|
termios.c_cflag |= PARENB;
|
||||||
|
} else {
|
||||||
|
termios.c_cflag &= ~PARENB;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cflags & SERIAL_PARODD) {
|
||||||
|
termios.c_cflag |= PARODD;
|
||||||
|
} else {
|
||||||
|
termios.c_cflag &= ~PARODD;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef IXANY
|
||||||
|
termios.c_iflag &= ~IXANY;
|
||||||
|
#endif /* IXANY */
|
||||||
|
termios.c_iflag &= ~(IXON | IXOFF);
|
||||||
|
|
||||||
|
#ifdef CRTSCTS
|
||||||
|
termios.c_iflag &= ~CRTSCTS;
|
||||||
|
#endif /* CRTSCTS */
|
||||||
|
|
||||||
|
#ifdef CNEW_RTSCTS
|
||||||
|
termios.c_iflag &= ~CNEW_RTSCTS;
|
||||||
|
#endif /* CRTSCTS */
|
||||||
|
|
||||||
|
|
||||||
rc = tcsetattr(fd->ifd, TCSANOW, &termios);
|
rc = tcsetattr(fd->ifd, TCSANOW, &termios);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
@@ -154,13 +222,18 @@ static int ser_setparams(union filedescriptor *fd, long baud, unsigned long cfla
|
|||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
#ifdef __APPLE__
|
||||||
* Everything is now set up for a local line without modem control
|
// handle nonstandard speed values the MacOS way
|
||||||
* or flow control, so clear O_NONBLOCK again.
|
if (nonstandard) {
|
||||||
*/
|
if (ioctl(fd->ifd, IOSSIOSPEED, &speed) < 0) {
|
||||||
rc = fcntl(fd->ifd, F_GETFL, 0);
|
avrdude_message(MSG_INFO, "%s: ser_setparams(): ioctrl(IOSSIOSPEED) failed\n",
|
||||||
if (rc != -1)
|
progname);
|
||||||
fcntl(fd->ifd, F_SETFL, rc & ~O_NONBLOCK);
|
return -errno;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif // __APPLE__
|
||||||
|
|
||||||
|
tcflush(fd->ifd, TCIFLUSH);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -520,3 +593,4 @@ struct serial_device serial_serdev =
|
|||||||
struct serial_device *serdev = &serial_serdev;
|
struct serial_device *serdev = &serial_serdev;
|
||||||
|
|
||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ static void serialupdi_setup(PROGRAMMER * pgm)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
memset(pgm->cookie, 0, sizeof(updi_state));
|
memset(pgm->cookie, 0, sizeof(updi_state));
|
||||||
|
updi_set_rts_mode(pgm, RTS_MODE_DEFAULT);
|
||||||
updi_set_datalink_mode(pgm, UPDI_LINK_MODE_16BIT);
|
updi_set_datalink_mode(pgm, UPDI_LINK_MODE_16BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,6 +185,10 @@ static void serialupdi_close(PROGRAMMER * pgm)
|
|||||||
if (serialupdi_leave_progmode(pgm) < 0) {
|
if (serialupdi_leave_progmode(pgm) < 0) {
|
||||||
avrdude_message(MSG_INFO, "%s: Unable to leave NVM programming mode\n", progname);
|
avrdude_message(MSG_INFO, "%s: Unable to leave NVM programming mode\n", progname);
|
||||||
}
|
}
|
||||||
|
if (updi_get_rts_mode(pgm) != RTS_MODE_DEFAULT) {
|
||||||
|
avrdude_message(MSG_INFO, "%s: Releasing DTR/RTS handshake lines\n", progname);
|
||||||
|
}
|
||||||
|
|
||||||
updi_link_close(pgm);
|
updi_link_close(pgm);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -582,6 +587,10 @@ static int serialupdi_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||||||
}
|
}
|
||||||
avrdude_message(MSG_INFO, "%s: UPDI link initialization OK\n", progname);
|
avrdude_message(MSG_INFO, "%s: UPDI link initialization OK\n", progname);
|
||||||
|
|
||||||
|
if (updi_get_rts_mode(pgm) != RTS_MODE_DEFAULT) {
|
||||||
|
avrdude_message(MSG_INFO, "%s: Forcing serial DTR/RTS handshake lines %s\n", progname, updi_get_rts_mode(pgm) == RTS_MODE_LOW ? "LOW" : "HIGH");
|
||||||
|
}
|
||||||
|
|
||||||
if (updi_read_cs(pgm, UPDI_ASI_SYS_STATUS, &value)<0) {
|
if (updi_read_cs(pgm, UPDI_ASI_SYS_STATUS, &value)<0) {
|
||||||
|
|
||||||
/* let's try reset the connection */
|
/* let's try reset the connection */
|
||||||
@@ -926,6 +935,35 @@ static int serialupdi_read_sib(PROGRAMMER * pgm, AVRPART *p, char *sib) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int serialupdi_parseextparms(PROGRAMMER * pgm, LISTID extparms)
|
||||||
|
{
|
||||||
|
LNODEID ln;
|
||||||
|
const char *extended_param;
|
||||||
|
char rts_mode[5];
|
||||||
|
int rv = 0;
|
||||||
|
|
||||||
|
for (ln = lfirst(extparms); ln; ln = lnext(ln)) {
|
||||||
|
extended_param = ldata(ln);
|
||||||
|
|
||||||
|
if (sscanf(extended_param, "rtsdtr=%4s", rts_mode) == 1) {
|
||||||
|
if (strcasecmp(rts_mode, "low") == 0) {
|
||||||
|
updi_set_rts_mode(pgm, RTS_MODE_LOW);
|
||||||
|
} else if (strcasecmp(rts_mode, "high") == 0) {
|
||||||
|
updi_set_rts_mode(pgm, RTS_MODE_HIGH);
|
||||||
|
} else {
|
||||||
|
avrdude_message(MSG_INFO, "%s: RTS/DTR mode must be LOW or HIGH\n", progname);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
avrdude_message(MSG_INFO, "%s: serialupdi_parseextparms(): invalid extended parameter '%s'\n",
|
||||||
|
progname, extended_param);
|
||||||
|
rv = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
void serialupdi_initpgm(PROGRAMMER * pgm)
|
void serialupdi_initpgm(PROGRAMMER * pgm)
|
||||||
{
|
{
|
||||||
@@ -936,6 +974,7 @@ void serialupdi_initpgm(PROGRAMMER * pgm)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
pgm->initialize = serialupdi_initialize;
|
pgm->initialize = serialupdi_initialize;
|
||||||
|
pgm->parseextparams = serialupdi_parseextparms;
|
||||||
pgm->display = serialupdi_display;
|
pgm->display = serialupdi_display;
|
||||||
pgm->enable = serialupdi_enable;
|
pgm->enable = serialupdi_enable;
|
||||||
pgm->disable = serialupdi_disable;
|
pgm->disable = serialupdi_disable;
|
||||||
|
|||||||
50
src/stk500.c
50
src/stk500.c
@@ -47,8 +47,8 @@
|
|||||||
|
|
||||||
struct pdata
|
struct pdata
|
||||||
{
|
{
|
||||||
unsigned char ext_addr_byte; /* Record ext-addr byte set in the
|
unsigned char ext_addr_byte; // Record ext-addr byte set in the target device (if used)
|
||||||
* target device (if used) */
|
int retry_attempts; // Number of connection attempts provided by the user
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PDATA(pgm) ((struct pdata *)(pgm->cookie))
|
#define PDATA(pgm) ((struct pdata *)(pgm->cookie))
|
||||||
@@ -89,6 +89,7 @@ int stk500_getsync(PROGRAMMER * pgm)
|
|||||||
{
|
{
|
||||||
unsigned char buf[32], resp[32];
|
unsigned char buf[32], resp[32];
|
||||||
int attempt;
|
int attempt;
|
||||||
|
int max_sync_attempts;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get in sync */
|
* get in sync */
|
||||||
@@ -104,16 +105,29 @@ int stk500_getsync(PROGRAMMER * pgm)
|
|||||||
stk500_send(pgm, buf, 2);
|
stk500_send(pgm, buf, 2);
|
||||||
stk500_drain(pgm, 0);
|
stk500_drain(pgm, 0);
|
||||||
|
|
||||||
for (attempt = 0; attempt < MAX_SYNC_ATTEMPTS; attempt++) {
|
if(PDATA(pgm)->retry_attempts)
|
||||||
|
max_sync_attempts = PDATA(pgm)->retry_attempts;
|
||||||
|
else
|
||||||
|
max_sync_attempts = MAX_SYNC_ATTEMPTS;
|
||||||
|
|
||||||
|
for (attempt = 0; attempt < max_sync_attempts; attempt++) {
|
||||||
|
// Restart Arduino bootloader for every sync attempt
|
||||||
|
if (strcmp(pgm->type, "Arduino") == 0 && attempt > 0) {
|
||||||
|
serial_set_dtr_rts(&pgm->fd, 0); // Set DTR and RTS low
|
||||||
|
usleep(250*1000);
|
||||||
|
serial_set_dtr_rts(&pgm->fd, 1); // Set DTR and RTS back to high
|
||||||
|
usleep(50*1000);
|
||||||
|
stk500_drain(pgm, 0);
|
||||||
|
}
|
||||||
stk500_send(pgm, buf, 2);
|
stk500_send(pgm, buf, 2);
|
||||||
stk500_recv(pgm, resp, 1);
|
stk500_recv(pgm, resp, 1);
|
||||||
if (resp[0] == Resp_STK_INSYNC){
|
if (resp[0] == Resp_STK_INSYNC){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
avrdude_message(MSG_INFO, "%s: stk500_getsync() attempt %d of %d: not in sync: resp=0x%02x\n",
|
avrdude_message(MSG_INFO, "%s: stk500_getsync() attempt %d of %d: not in sync: resp=0x%02x\n",
|
||||||
progname, attempt + 1, MAX_SYNC_ATTEMPTS, resp[0]);
|
progname, attempt + 1, max_sync_attempts, resp[0]);
|
||||||
}
|
}
|
||||||
if (attempt == MAX_SYNC_ATTEMPTS) {
|
if (attempt == max_sync_attempts) {
|
||||||
stk500_drain(pgm, 0);
|
stk500_drain(pgm, 0);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -597,6 +611,30 @@ static int stk500_initialize(PROGRAMMER * pgm, AVRPART * p)
|
|||||||
return pgm->program_enable(pgm, p);
|
return pgm->program_enable(pgm, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int stk500_parseextparms(PROGRAMMER * pgm, LISTID extparms)
|
||||||
|
{
|
||||||
|
LNODEID ln;
|
||||||
|
const char *extended_param;
|
||||||
|
int attempts;
|
||||||
|
int rv = 0;
|
||||||
|
|
||||||
|
for (ln = lfirst(extparms); ln; ln = lnext(ln)) {
|
||||||
|
extended_param = ldata(ln);
|
||||||
|
|
||||||
|
if (sscanf(extended_param, "attempts=%2d", &attempts) == 1) {
|
||||||
|
PDATA(pgm)->retry_attempts = attempts;
|
||||||
|
avrdude_message(MSG_INFO, "%s: Setting number of retry attempts to %d\n",
|
||||||
|
progname, attempts);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
avrdude_message(MSG_INFO, "%s: stk500_parseextparms(): invalid extended parameter '%s'\n",
|
||||||
|
progname, extended_param);
|
||||||
|
rv = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
static void stk500_disable(PROGRAMMER * pgm)
|
static void stk500_disable(PROGRAMMER * pgm)
|
||||||
{
|
{
|
||||||
@@ -1209,6 +1247,7 @@ static void stk500_display(PROGRAMMER * pgm, const char * p)
|
|||||||
}
|
}
|
||||||
avrdude_message(MSG_INFO, "%sTopcard : %s\n", p, n);
|
avrdude_message(MSG_INFO, "%sTopcard : %s\n", p, n);
|
||||||
}
|
}
|
||||||
|
if(strcmp(pgm->type, "Arduino") != 0)
|
||||||
stk500_print_parms1(pgm, p);
|
stk500_print_parms1(pgm, p);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -1294,6 +1333,7 @@ void stk500_initpgm(PROGRAMMER * pgm)
|
|||||||
* mandatory functions
|
* mandatory functions
|
||||||
*/
|
*/
|
||||||
pgm->initialize = stk500_initialize;
|
pgm->initialize = stk500_initialize;
|
||||||
|
pgm->parseextparams = stk500_parseextparms;
|
||||||
pgm->display = stk500_display;
|
pgm->display = stk500_display;
|
||||||
pgm->enable = stk500_enable;
|
pgm->enable = stk500_enable;
|
||||||
pgm->disable = stk500_disable;
|
pgm->disable = stk500_disable;
|
||||||
|
|||||||
@@ -1613,11 +1613,11 @@ static int stk500v2_open(PROGRAMMER * pgm, char * port)
|
|||||||
PDATA(pgm)->pgmtype = PGMTYPE_UNKNOWN;
|
PDATA(pgm)->pgmtype = PGMTYPE_UNKNOWN;
|
||||||
|
|
||||||
if(strcasecmp(port, "avrdoper") == 0){
|
if(strcasecmp(port, "avrdoper") == 0){
|
||||||
#if defined(HAVE_LIBHIDAPI) || (defined(WIN32) && defined(HAVE_LIBHID))
|
#if defined(HAVE_LIBHIDAPI)
|
||||||
serdev = &avrdoper_serdev;
|
serdev = &avrdoper_serdev;
|
||||||
PDATA(pgm)->pgmtype = PGMTYPE_STK500;
|
PDATA(pgm)->pgmtype = PGMTYPE_STK500;
|
||||||
#else
|
#else
|
||||||
avrdude_message(MSG_INFO, "avrdoper requires avrdude with hid support.\n");
|
avrdude_message(MSG_INFO, "avrdoper requires avrdude with libhidapi support.\n");
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -3869,7 +3869,8 @@ static int stk600_xprog_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||||||
* fuses.
|
* fuses.
|
||||||
*/
|
*/
|
||||||
need_erase = 1;
|
need_erase = 1;
|
||||||
} else if (strcmp(mem->desc, "usersig") == 0) {
|
} else if (strcmp(mem->desc, "usersig") == 0 ||
|
||||||
|
strcmp(mem->desc, "userrow") == 0) {
|
||||||
memcode = XPRG_MEM_TYPE_USERSIG;
|
memcode = XPRG_MEM_TYPE_USERSIG;
|
||||||
} else {
|
} else {
|
||||||
avrdude_message(MSG_INFO, "%s: stk600_xprog_write_byte(): unknown memory \"%s\"\n",
|
avrdude_message(MSG_INFO, "%s: stk600_xprog_write_byte(): unknown memory \"%s\"\n",
|
||||||
@@ -3944,7 +3945,8 @@ static int stk600_xprog_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||||||
} else if (strcmp(mem->desc, "calibration") == 0 ||
|
} else if (strcmp(mem->desc, "calibration") == 0 ||
|
||||||
strcmp(mem->desc, "prodsig") == 0) {
|
strcmp(mem->desc, "prodsig") == 0) {
|
||||||
b[1] = XPRG_MEM_TYPE_FACTORY_CALIBRATION;
|
b[1] = XPRG_MEM_TYPE_FACTORY_CALIBRATION;
|
||||||
} else if (strcmp(mem->desc, "usersig") == 0) {
|
} else if (strcmp(mem->desc, "usersig") == 0 ||
|
||||||
|
strcmp(mem->desc, "userrow") == 0) {
|
||||||
b[1] = XPRG_MEM_TYPE_USERSIG;
|
b[1] = XPRG_MEM_TYPE_USERSIG;
|
||||||
} else {
|
} else {
|
||||||
avrdude_message(MSG_INFO, "%s: stk600_xprog_read_byte(): unknown memory \"%s\"\n",
|
avrdude_message(MSG_INFO, "%s: stk600_xprog_read_byte(): unknown memory \"%s\"\n",
|
||||||
@@ -4019,7 +4021,8 @@ static int stk600_xprog_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||||||
} else if (strcmp(mem->desc, "calibration") == 0 ||
|
} else if (strcmp(mem->desc, "calibration") == 0 ||
|
||||||
strcmp(mem->desc, "prodsig") == 0) {
|
strcmp(mem->desc, "prodsig") == 0) {
|
||||||
memtype = XPRG_MEM_TYPE_FACTORY_CALIBRATION;
|
memtype = XPRG_MEM_TYPE_FACTORY_CALIBRATION;
|
||||||
} else if (strcmp(mem->desc, "usersig") == 0) {
|
} else if (strcmp(mem->desc, "usersig") == 0 ||
|
||||||
|
strcmp(mem->desc, "userrow") == 0) {
|
||||||
memtype = XPRG_MEM_TYPE_USERSIG;
|
memtype = XPRG_MEM_TYPE_USERSIG;
|
||||||
} else {
|
} else {
|
||||||
avrdude_message(MSG_INFO, "%s: stk600_xprog_paged_load(): unknown paged memory \"%s\"\n",
|
avrdude_message(MSG_INFO, "%s: stk600_xprog_paged_load(): unknown paged memory \"%s\"\n",
|
||||||
@@ -4132,7 +4135,8 @@ static int stk600_xprog_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||||||
} else if (strcmp(mem->desc, "calibration") == 0) {
|
} else if (strcmp(mem->desc, "calibration") == 0) {
|
||||||
memtype = XPRG_MEM_TYPE_FACTORY_CALIBRATION;
|
memtype = XPRG_MEM_TYPE_FACTORY_CALIBRATION;
|
||||||
writemode = (1 << XPRG_MEM_WRITE_WRITE);
|
writemode = (1 << XPRG_MEM_WRITE_WRITE);
|
||||||
} else if (strcmp(mem->desc, "usersig") == 0) {
|
} else if (strcmp(mem->desc, "usersig") == 0 ||
|
||||||
|
strcmp(mem->desc, "userrow") == 0) {
|
||||||
memtype = XPRG_MEM_TYPE_USERSIG;
|
memtype = XPRG_MEM_TYPE_USERSIG;
|
||||||
writemode = (1 << XPRG_MEM_WRITE_WRITE);
|
writemode = (1 << XPRG_MEM_WRITE_WRITE);
|
||||||
} else {
|
} else {
|
||||||
@@ -4290,7 +4294,8 @@ static int stk600_xprog_page_erase(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||||||
b[1] = XPRG_ERASE_BOOT_PAGE;
|
b[1] = XPRG_ERASE_BOOT_PAGE;
|
||||||
} else if (strcmp(m->desc, "eeprom") == 0) {
|
} else if (strcmp(m->desc, "eeprom") == 0) {
|
||||||
b[1] = XPRG_ERASE_EEPROM_PAGE;
|
b[1] = XPRG_ERASE_EEPROM_PAGE;
|
||||||
} else if (strcmp(m->desc, "usersig") == 0) {
|
} else if (strcmp(m->desc, "usersig") == 0 ||
|
||||||
|
strcmp(m->desc, "userrow") == 0) {
|
||||||
b[1] = XPRG_ERASE_USERSIG;
|
b[1] = XPRG_ERASE_USERSIG;
|
||||||
} else {
|
} else {
|
||||||
avrdude_message(MSG_INFO, "%s: stk600_xprog_page_erase(): unknown paged memory \"%s\"\n",
|
avrdude_message(MSG_INFO, "%s: stk600_xprog_page_erase(): unknown paged memory \"%s\"\n",
|
||||||
|
|||||||
390
src/term.c
390
src/term.c
@@ -23,6 +23,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
@@ -97,8 +98,8 @@ struct command cmd[] = {
|
|||||||
{ "sig", cmd_sig, "display device signature bytes" },
|
{ "sig", cmd_sig, "display device signature bytes" },
|
||||||
{ "part", cmd_part, "display the current part information" },
|
{ "part", cmd_part, "display the current part information" },
|
||||||
{ "send", cmd_send, "send a raw command : %s <b1> <b2> <b3> <b4>" },
|
{ "send", cmd_send, "send a raw command : %s <b1> <b2> <b3> <b4>" },
|
||||||
{ "parms", cmd_parms, "display adjustable parameters (STK500 only)" },
|
{ "parms", cmd_parms, "display adjustable parameters (STK500 and Curiosity Nano only)" },
|
||||||
{ "vtarg", cmd_vtarg, "set <V[target]> (STK500 only)" },
|
{ "vtarg", cmd_vtarg, "set <V[target]> (STK500 and Curiosity Nano only)" },
|
||||||
{ "varef", cmd_varef, "set <V[aref]> (STK500 only)" },
|
{ "varef", cmd_varef, "set <V[aref]> (STK500 only)" },
|
||||||
{ "fosc", cmd_fosc, "set <oscillator frequency> (STK500 only)" },
|
{ "fosc", cmd_fosc, "set <oscillator frequency> (STK500 only)" },
|
||||||
{ "sck", cmd_sck, "set <SCK period> (STK500 only)" },
|
{ "sck", cmd_sck, "set <SCK period> (STK500 only)" },
|
||||||
@@ -125,9 +126,15 @@ static int nexttok(char * buf, char ** tok, char ** next)
|
|||||||
q++;
|
q++;
|
||||||
|
|
||||||
/* isolate first token */
|
/* isolate first token */
|
||||||
n = q+1;
|
n = q;
|
||||||
while (*n && !isspace((int)*n))
|
uint8_t quotes = 0;
|
||||||
|
while (*n && (!isspace((int)*n) || quotes)) {
|
||||||
|
if (*n == '\"')
|
||||||
|
quotes++;
|
||||||
|
else if (isspace((int)*n) && *(n-1) == '\"')
|
||||||
|
break;
|
||||||
n++;
|
n++;
|
||||||
|
}
|
||||||
|
|
||||||
if (*n) {
|
if (*n) {
|
||||||
*n = 0;
|
*n = 0;
|
||||||
@@ -148,12 +155,10 @@ static int nexttok(char * buf, char ** tok, char ** next)
|
|||||||
static int hexdump_line(char * buffer, unsigned char * p, int n, int pad)
|
static int hexdump_line(char * buffer, unsigned char * p, int n, int pad)
|
||||||
{
|
{
|
||||||
char * hexdata = "0123456789abcdef";
|
char * hexdata = "0123456789abcdef";
|
||||||
char * b;
|
char * b = buffer;
|
||||||
int i, j;
|
int32_t i = 0;
|
||||||
|
int32_t j = 0;
|
||||||
|
|
||||||
b = buffer;
|
|
||||||
|
|
||||||
j = 0;
|
|
||||||
for (i=0; i<n; i++) {
|
for (i=0; i<n; i++) {
|
||||||
if (i && ((i % 8) == 0))
|
if (i && ((i % 8) == 0))
|
||||||
b[j++] = ' ';
|
b[j++] = ' ';
|
||||||
@@ -182,7 +187,7 @@ static int chardump_line(char * buffer, unsigned char * p, int n, int pad)
|
|||||||
int i;
|
int i;
|
||||||
char b [ 128 ];
|
char b [ 128 ];
|
||||||
|
|
||||||
for (i=0; i<n; i++) {
|
for (int32_t i = 0; i < n; i++) {
|
||||||
memcpy(b, p, n);
|
memcpy(b, p, n);
|
||||||
buffer[i] = '.';
|
buffer[i] = '.';
|
||||||
if (isalpha((int)(b[i])) || isdigit((int)(b[i])) || ispunct((int)(b[i])))
|
if (isalpha((int)(b[i])) || isdigit((int)(b[i])) || ispunct((int)(b[i])))
|
||||||
@@ -191,7 +196,7 @@ static int chardump_line(char * buffer, unsigned char * p, int n, int pad)
|
|||||||
buffer[i] = ' ';
|
buffer[i] = ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=n; i<pad; i++)
|
for (i = n; i < pad; i++)
|
||||||
buffer[i] = ' ';
|
buffer[i] = ' ';
|
||||||
|
|
||||||
buffer[i] = 0;
|
buffer[i] = 0;
|
||||||
@@ -202,16 +207,13 @@ static int chardump_line(char * buffer, unsigned char * p, int n, int pad)
|
|||||||
|
|
||||||
static int hexdump_buf(FILE * f, int startaddr, unsigned char * buf, int len)
|
static int hexdump_buf(FILE * f, int startaddr, unsigned char * buf, int len)
|
||||||
{
|
{
|
||||||
int addr;
|
|
||||||
int n;
|
|
||||||
unsigned char * p;
|
|
||||||
char dst1[80];
|
char dst1[80];
|
||||||
char dst2[80];
|
char dst2[80];
|
||||||
|
|
||||||
addr = startaddr;
|
int32_t addr = startaddr;
|
||||||
p = (unsigned char *)buf;
|
unsigned char * p = (unsigned char *)buf;
|
||||||
while (len) {
|
while (len) {
|
||||||
n = 16;
|
int32_t n = 16;
|
||||||
if (n > len)
|
if (n > len)
|
||||||
n = len;
|
n = len;
|
||||||
hexdump_line(dst1, p, n, 48);
|
hexdump_line(dst1, p, n, 48);
|
||||||
@@ -229,92 +231,99 @@ static int hexdump_buf(FILE * f, int startaddr, unsigned char * buf, int len)
|
|||||||
static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
|
static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
|
||||||
int argc, char * argv[])
|
int argc, char * argv[])
|
||||||
{
|
{
|
||||||
static char prevmem[128] = {0};
|
if (argc < 2) {
|
||||||
char * e;
|
avrdude_message(MSG_INFO, "Usage: %s <memtype> [<start addr> <len>]\n"
|
||||||
unsigned char * buf;
|
" %s <memtype> [<start addr> <...>]\n"
|
||||||
int maxsize;
|
" %s <memtype> <...>\n"
|
||||||
unsigned long i;
|
" %s <memtype>\n",
|
||||||
static unsigned long addr=0;
|
argv[0], argv[0], argv[0], argv[0]);
|
||||||
static int len=64;
|
|
||||||
AVRMEM * mem;
|
|
||||||
char * memtype = NULL;
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
if (!((argc == 2) || (argc == 4))) {
|
|
||||||
avrdude_message(MSG_INFO, "Usage: dump <memtype> [<addr> <len>]\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memtype = argv[1];
|
enum { read_size = 256 };
|
||||||
|
static char prevmem[128] = {0x00};
|
||||||
if (strncmp(prevmem, memtype, strlen(memtype)) != 0) {
|
char * memtype = argv[1];
|
||||||
addr = 0;
|
AVRMEM * mem = avr_locate_mem(p, memtype);
|
||||||
len = 64;
|
|
||||||
strncpy(prevmem, memtype, sizeof(prevmem)-1);
|
|
||||||
prevmem[sizeof(prevmem)-1] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
mem = avr_locate_mem(p, memtype);
|
|
||||||
if (mem == NULL) {
|
if (mem == NULL) {
|
||||||
avrdude_message(MSG_INFO, "\"%s\" memory type not defined for part \"%s\"\n",
|
avrdude_message(MSG_INFO, "\"%s\" memory type not defined for part \"%s\"\n",
|
||||||
memtype, p->desc);
|
memtype, p->desc);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
uint32_t maxsize = mem->size;
|
||||||
|
|
||||||
|
// Get start address if present
|
||||||
|
char * end_ptr;
|
||||||
|
static uint32_t addr = 0;
|
||||||
if (argc == 4) {
|
if (argc == 4) {
|
||||||
addr = strtoul(argv[2], &e, 0);
|
addr = strtoul(argv[2], &end_ptr, 0);
|
||||||
if (*e || (e == argv[2])) {
|
if (*end_ptr || (end_ptr == argv[2])) {
|
||||||
avrdude_message(MSG_INFO, "%s (dump): can't parse address \"%s\"\n",
|
avrdude_message(MSG_INFO, "%s (%s): can't parse address \"%s\"\n",
|
||||||
progname, argv[2]);
|
progname, argv[0], argv[2]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
} else if (addr >= maxsize) {
|
||||||
|
avrdude_message(MSG_INFO, "%s (%s): address 0x%05lx is out of range for %s memory\n",
|
||||||
len = strtol(argv[3], &e, 0);
|
progname, argv[0], addr, mem->desc);
|
||||||
if (*e || (e == argv[3])) {
|
|
||||||
avrdude_message(MSG_INFO, "%s (dump): can't parse length \"%s\"\n",
|
|
||||||
progname, argv[3]);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
maxsize = mem->size;
|
// Get no. bytes to read if present
|
||||||
|
static int32_t len = read_size;
|
||||||
if (addr >= maxsize) {
|
if (argc >= 3) {
|
||||||
if (argc == 2) {
|
memset(prevmem, 0x00, sizeof(prevmem));
|
||||||
/* wrap around */
|
if (strcmp(argv[argc - 1], "...") == 0) {
|
||||||
|
if (argc == 3)
|
||||||
addr = 0;
|
addr = 0;
|
||||||
}
|
len = maxsize - addr;
|
||||||
else {
|
} else if (argc == 4) {
|
||||||
avrdude_message(MSG_INFO, "%s (dump): address 0x%05lx is out of range for %s memory\n",
|
len = strtol(argv[3], &end_ptr, 0);
|
||||||
progname, addr, mem->desc);
|
if (*end_ptr || (end_ptr == argv[3])) {
|
||||||
|
avrdude_message(MSG_INFO, "%s (%s): can't parse length \"%s\"\n",
|
||||||
|
progname, argv[0], argv[3]);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
len = read_size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// No address or length specified
|
||||||
|
else if (argc == 2) {
|
||||||
|
if (strncmp(prevmem, memtype, strlen(memtype)) != 0) {
|
||||||
|
addr = 0;
|
||||||
|
len = read_size;
|
||||||
|
strncpy(prevmem, memtype, sizeof(prevmem) - 1);
|
||||||
|
prevmem[sizeof(prevmem) - 1] = 0;
|
||||||
|
}
|
||||||
|
if (addr >= maxsize)
|
||||||
|
addr = 0; // Wrap around
|
||||||
}
|
}
|
||||||
|
|
||||||
/* trim len if nessary to not read past the end of memory */
|
// Trim len if nessary to not read past the end of memory
|
||||||
if ((addr + len) > maxsize)
|
if ((addr + len) > maxsize)
|
||||||
len = maxsize - addr;
|
len = maxsize - addr;
|
||||||
|
|
||||||
buf = malloc(len);
|
uint8_t * buf = malloc(len);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
avrdude_message(MSG_INFO, "%s (dump): out of memory\n", progname);
|
avrdude_message(MSG_INFO, "%s (dump): out of memory\n", progname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=0; i<len; i++) {
|
report_progress(0, 1, "Reading");
|
||||||
rc = pgm->read_byte(pgm, p, mem, addr+i, &buf[i]);
|
for (uint32_t i = 0; i < len; i++) {
|
||||||
|
int32_t rc = pgm->read_byte(pgm, p, mem, addr + i, &buf[i]);
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
avrdude_message(MSG_INFO, "error reading %s address 0x%05lx of part %s\n",
|
avrdude_message(MSG_INFO, "error reading %s address 0x%05lx of part %s\n",
|
||||||
mem->desc, addr+i, p->desc);
|
mem->desc, addr + i, p->desc);
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
avrdude_message(MSG_INFO, "read operation not supported on memory type \"%s\"\n",
|
avrdude_message(MSG_INFO, "read operation not supported on memory type \"%s\"\n",
|
||||||
mem->desc);
|
mem->desc);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
report_progress(i, len, NULL);
|
||||||
}
|
}
|
||||||
|
report_progress(1, 1, NULL);
|
||||||
|
|
||||||
hexdump_buf(stdout, addr, buf, len);
|
hexdump_buf(stdout, addr, buf, len);
|
||||||
|
|
||||||
fprintf(stdout, "\n");
|
fprintf(stdout, "\n");
|
||||||
|
|
||||||
free(buf);
|
free(buf);
|
||||||
@@ -328,35 +337,31 @@ static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
|
|||||||
static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
|
static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
|
||||||
int argc, char * argv[])
|
int argc, char * argv[])
|
||||||
{
|
{
|
||||||
char * e;
|
|
||||||
int len, maxsize;
|
|
||||||
char * memtype;
|
|
||||||
unsigned long addr, i;
|
|
||||||
unsigned char * buf;
|
|
||||||
unsigned char b;
|
|
||||||
int rc;
|
|
||||||
int werror;
|
|
||||||
AVRMEM * mem;
|
|
||||||
|
|
||||||
if (argc < 4) {
|
if (argc < 4) {
|
||||||
avrdude_message(MSG_INFO, "Usage: write <memtype> <addr> <byte1> "
|
avrdude_message(MSG_INFO,
|
||||||
"<byte2> ... <byteN>\n");
|
"Usage: write <memtype> <start addr> <data1> <data2> <dataN>\n"
|
||||||
|
" write <memtype> <start addr> <no. bytes> <data1> <dataN> <...>\n\n"
|
||||||
|
" Add a suffix to manually specify the size for each field:\n"
|
||||||
|
" HH/hh: 8-bit, H/h/S/s: 16-bit, L/l: 32-bit, LL/ll: 64-bit, F/f: 32-bit float\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memtype = argv[1];
|
int32_t i;
|
||||||
|
uint8_t write_mode; // Operation mode, "standard" or "fill"
|
||||||
mem = avr_locate_mem(p, memtype);
|
uint8_t start_offset; // Which argc argument
|
||||||
|
int32_t len; // Number of bytes to write to memory
|
||||||
|
char * memtype = argv[1]; // Memory name string
|
||||||
|
AVRMEM * mem = avr_locate_mem(p, memtype);
|
||||||
if (mem == NULL) {
|
if (mem == NULL) {
|
||||||
avrdude_message(MSG_INFO, "\"%s\" memory type not defined for part \"%s\"\n",
|
avrdude_message(MSG_INFO, "\"%s\" memory type not defined for part \"%s\"\n",
|
||||||
memtype, p->desc);
|
memtype, p->desc);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
uint32_t maxsize = mem->size;
|
||||||
|
|
||||||
maxsize = mem->size;
|
char * end_ptr;
|
||||||
|
int32_t addr = strtoul(argv[2], &end_ptr, 0);
|
||||||
addr = strtoul(argv[2], &e, 0);
|
if (*end_ptr || (end_ptr == argv[2])) {
|
||||||
if (*e || (e == argv[2])) {
|
|
||||||
avrdude_message(MSG_INFO, "%s (write): can't parse address \"%s\"\n",
|
avrdude_message(MSG_INFO, "%s (write): can't parse address \"%s\"\n",
|
||||||
progname, argv[2]);
|
progname, argv[2]);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -368,61 +373,228 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* number of bytes to write at the specified address */
|
// Allocate a buffer guaranteed to be large enough
|
||||||
len = argc - 3;
|
uint8_t * buf = calloc(mem->size + 0x10 + strlen(argv[argc - 2]), sizeof(uint8_t));
|
||||||
|
|
||||||
if ((addr + len) > maxsize) {
|
|
||||||
avrdude_message(MSG_INFO, "%s (write): selected address and # bytes exceed "
|
|
||||||
"range for %s memory\n",
|
|
||||||
progname, memtype);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
buf = malloc(len);
|
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
avrdude_message(MSG_INFO, "%s (write): out of memory\n", progname);
|
avrdude_message(MSG_INFO, "%s (write): out of memory\n", progname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i=3; i<argc; i++) {
|
// Find the first argument to write to flash and how many arguments to parse and write
|
||||||
buf[i-3] = strtoul(argv[i], &e, 0);
|
if (strcmp(argv[argc - 1], "...") == 0) {
|
||||||
if (*e || (e == argv[i])) {
|
write_mode = WRITE_MODE_FILL;
|
||||||
avrdude_message(MSG_INFO, "%s (write): can't parse byte \"%s\"\n",
|
start_offset = 4;
|
||||||
progname, argv[i]);
|
len = strtoul(argv[3], &end_ptr, 0);
|
||||||
|
if (*end_ptr || (end_ptr == argv[3])) {
|
||||||
|
avrdude_message(MSG_INFO, "%s (write ...): can't parse address \"%s\"\n",
|
||||||
|
progname, argv[3]);
|
||||||
free(buf);
|
free(buf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
write_mode = WRITE_MODE_STANDARD;
|
||||||
|
start_offset = 3;
|
||||||
|
len = argc - start_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
pgm->err_led(pgm, OFF);
|
// Structure related to data that is being written to memory
|
||||||
for (werror=0, i=0; i<len; i++) {
|
struct Data {
|
||||||
|
// Data info
|
||||||
|
int32_t bytes_grown;
|
||||||
|
uint8_t size;
|
||||||
|
bool is_float;
|
||||||
|
bool is_signed;
|
||||||
|
char * str_ptr;
|
||||||
|
// Data union
|
||||||
|
union {
|
||||||
|
float f;
|
||||||
|
int64_t ll;
|
||||||
|
uint8_t a[8];
|
||||||
|
};
|
||||||
|
} data = {
|
||||||
|
.bytes_grown = 0,
|
||||||
|
.size = 0,
|
||||||
|
.is_float = false,
|
||||||
|
.is_signed = false,
|
||||||
|
.str_ptr = NULL,
|
||||||
|
.ll = 0
|
||||||
|
};
|
||||||
|
|
||||||
rc = avr_write_byte(pgm, p, mem, addr+i, buf[i]);
|
for (i = start_offset; i < len + start_offset; i++) {
|
||||||
|
data.is_float = false;
|
||||||
|
data.size = 0;
|
||||||
|
|
||||||
|
// Handle the next argument
|
||||||
|
if (i < argc - start_offset + 3) {
|
||||||
|
// Free string pointer if already allocated
|
||||||
|
if(data.str_ptr) {
|
||||||
|
free(data.str_ptr);
|
||||||
|
data.str_ptr = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get suffix if present
|
||||||
|
char suffix = argv[i][strlen(argv[i]) - 1];
|
||||||
|
char lsuffix = argv[i][strlen(argv[i]) - 2];
|
||||||
|
if ((suffix == 'L' && lsuffix == 'L') || (suffix == 'l' && lsuffix == 'l')) {
|
||||||
|
argv[i][strlen(argv[i]) - 2] = '\0';
|
||||||
|
data.size = 8;
|
||||||
|
} else if (suffix == 'L' || suffix == 'l') {
|
||||||
|
argv[i][strlen(argv[i]) - 1] = '\0';
|
||||||
|
data.size = 4;
|
||||||
|
} else if ((suffix == 'F' || suffix == 'f') &&
|
||||||
|
strncmp(argv[i], "0x", 2) != 0 && strncmp(argv[i], "-0x", 3) != 0) {
|
||||||
|
argv[i][strlen(argv[i]) - 1] = '\0';
|
||||||
|
data.size = 4;
|
||||||
|
} else if ((suffix == 'H' && lsuffix == 'H') || (suffix == 'h' && lsuffix == 'h')) {
|
||||||
|
argv[i][strlen(argv[i]) - 2] = '\0';
|
||||||
|
data.size = 1;
|
||||||
|
} else if (suffix == 'H' || suffix == 'h' || suffix == 'S' || suffix == 's') {
|
||||||
|
argv[i][strlen(argv[i]) - 1] = '\0';
|
||||||
|
data.size = 2;
|
||||||
|
} else if (suffix == '\'') {
|
||||||
|
data.size = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try integers
|
||||||
|
data.ll = strtoll(argv[i], &end_ptr, 0);
|
||||||
|
if (*end_ptr || (end_ptr == argv[i])) {
|
||||||
|
// Try float
|
||||||
|
data.f = strtof(argv[i], &end_ptr);
|
||||||
|
data.is_float = true;
|
||||||
|
if (*end_ptr || (end_ptr == argv[i])) {
|
||||||
|
data.is_float = false;
|
||||||
|
// Try single character
|
||||||
|
if (argv[i][0] == '\'' && argv[i][2] == '\'') {
|
||||||
|
data.ll = argv[i][1];
|
||||||
|
} else {
|
||||||
|
// Try string that starts and ends with quotes
|
||||||
|
if (argv[i][0] == '\"' && argv[i][strlen(argv[i]) - 1] == '\"') {
|
||||||
|
data.str_ptr = calloc(strlen(argv[i]), sizeof(char));
|
||||||
|
if (data.str_ptr == NULL) {
|
||||||
|
avrdude_message(MSG_INFO, "%s (write str): out of memory\n", progname);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
// Strip start and end quotes
|
||||||
|
strncpy(data.str_ptr, argv[i] + 1, strlen(argv[i]) - 2);
|
||||||
|
} else {
|
||||||
|
avrdude_message(MSG_INFO, "\n%s (write): can't parse data '%s'\n",
|
||||||
|
progname, argv[i]);
|
||||||
|
free(buf);
|
||||||
|
if(data.str_ptr != NULL)
|
||||||
|
free(data.str_ptr);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Print warning if data size might be ambiguous
|
||||||
|
bool is_hex = (strncmp(argv[i], "0x", 2) == 0);
|
||||||
|
bool is_neg_hex = (strncmp(argv[i], "-0x", 3) == 0);
|
||||||
|
bool leading_zero = (strncmp(argv[i], "0x0", 3) == 0);
|
||||||
|
int8_t hex_digits = (strlen(argv[i]) - 2);
|
||||||
|
if(!data.size // No pre-defined size
|
||||||
|
&& (is_neg_hex // Hex with - sign in front
|
||||||
|
|| (is_hex && leading_zero && (hex_digits & (hex_digits - 1))) // Hex with 3, 5, 6 or 7 digits
|
||||||
|
|| (!is_hex && !data.is_float && llabs(data.ll) > 0xFF && strlen(argv[i]) > 2))) // Base10 int greater than 255
|
||||||
|
{
|
||||||
|
avrdude_message(MSG_INFO, "Warning: no size suffix specified for \"%s\". "
|
||||||
|
"Writing %d byte(s)\n",
|
||||||
|
argv[i],
|
||||||
|
llabs(data.ll) > UINT32_MAX ? 8 :
|
||||||
|
llabs(data.ll) > UINT16_MAX || data.is_float ? 4 : \
|
||||||
|
llabs(data.ll) > UINT8_MAX ? 2 : 1);
|
||||||
|
}
|
||||||
|
// Flag if signed integer and adjust size
|
||||||
|
if (data.ll < 0 && !data.is_float) {
|
||||||
|
data.is_signed = true;
|
||||||
|
if (data.ll < INT32_MIN)
|
||||||
|
data.size = 8;
|
||||||
|
else if (data.ll < INT16_MIN)
|
||||||
|
data.size = 4;
|
||||||
|
else if (data.ll < INT8_MIN)
|
||||||
|
data.size = 2;
|
||||||
|
else
|
||||||
|
data.size = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(data.str_ptr) {
|
||||||
|
for(int16_t j = 0; j < strlen(data.str_ptr); j++)
|
||||||
|
buf[i - start_offset + data.bytes_grown++] = (uint8_t)data.str_ptr[j];
|
||||||
|
} else {
|
||||||
|
buf[i - start_offset + data.bytes_grown] = data.a[0];
|
||||||
|
if (llabs(data.ll) > 0x000000FF || data.size >= 2 || data.is_float)
|
||||||
|
buf[i - start_offset + ++data.bytes_grown] = data.a[1];
|
||||||
|
if (llabs(data.ll) > 0x0000FFFF || data.size >= 4 || data.is_float) {
|
||||||
|
buf[i - start_offset + ++data.bytes_grown] = data.a[2];
|
||||||
|
buf[i - start_offset + ++data.bytes_grown] = data.a[3];
|
||||||
|
}
|
||||||
|
if (llabs(data.ll) > 0xFFFFFFFF || data.size == 8) {
|
||||||
|
buf[i - start_offset + ++data.bytes_grown] = data.a[4];
|
||||||
|
buf[i - start_offset + ++data.bytes_grown] = data.a[5];
|
||||||
|
buf[i - start_offset + ++data.bytes_grown] = data.a[6];
|
||||||
|
buf[i - start_offset + ++data.bytes_grown] = data.a[7];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure buf does not overflow
|
||||||
|
if (i - start_offset + data.bytes_grown > maxsize)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// When in "fill" mode, the maximum size is already predefined
|
||||||
|
if (write_mode == WRITE_MODE_FILL)
|
||||||
|
data.bytes_grown = 0;
|
||||||
|
|
||||||
|
if ((addr + len + data.bytes_grown) > maxsize) {
|
||||||
|
avrdude_message(MSG_INFO, "%s (write): selected address and # bytes exceed "
|
||||||
|
"range for %s memory\n",
|
||||||
|
progname, memtype);
|
||||||
|
free(buf);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data.str_ptr)
|
||||||
|
free(data.str_ptr);
|
||||||
|
|
||||||
|
avrdude_message(MSG_NOTICE, "\nInfo: Writing %d bytes starting from address 0x%02x",
|
||||||
|
len + data.bytes_grown, addr);
|
||||||
|
if (write_mode == WRITE_MODE_FILL)
|
||||||
|
avrdude_message(MSG_NOTICE, ". Remaining space filled with %s", argv[argc - 2]);
|
||||||
|
avrdude_message(MSG_NOTICE, "\n");
|
||||||
|
|
||||||
|
pgm->err_led(pgm, OFF);
|
||||||
|
bool werror = false;
|
||||||
|
report_progress(0, 1, "Writing");
|
||||||
|
for (i = 0; i < (len + data.bytes_grown); i++) {
|
||||||
|
int32_t rc = avr_write_byte(pgm, p, mem, addr+i, buf[i]);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
avrdude_message(MSG_INFO, "%s (write): error writing 0x%02x at 0x%05lx, rc=%d\n",
|
avrdude_message(MSG_INFO, "%s (write): error writing 0x%02x at 0x%05lx, rc=%d\n",
|
||||||
progname, buf[i], addr+i, rc);
|
progname, buf[i], addr+i, rc);
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
avrdude_message(MSG_INFO, "write operation not supported on memory type \"%s\"\n",
|
avrdude_message(MSG_INFO, "write operation not supported on memory type \"%s\"\n",
|
||||||
mem->desc);
|
mem->desc);
|
||||||
werror = 1;
|
werror = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t b;
|
||||||
rc = pgm->read_byte(pgm, p, mem, addr+i, &b);
|
rc = pgm->read_byte(pgm, p, mem, addr+i, &b);
|
||||||
if (b != buf[i]) {
|
if (b != buf[i]) {
|
||||||
avrdude_message(MSG_INFO, "%s (write): error writing 0x%02x at 0x%05lx cell=0x%02x\n",
|
avrdude_message(MSG_INFO, "%s (write): error writing 0x%02x at 0x%05lx cell=0x%02x\n",
|
||||||
progname, buf[i], addr+i, b);
|
progname, buf[i], addr+i, b);
|
||||||
werror = 1;
|
werror = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (werror) {
|
if (werror) {
|
||||||
pgm->err_led(pgm, ON);
|
pgm->err_led(pgm, ON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
report_progress(i, (len + data.bytes_grown), NULL);
|
||||||
}
|
}
|
||||||
|
report_progress(1, 1, NULL);
|
||||||
|
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
||||||
fprintf(stdout, "\n");
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -541,6 +713,10 @@ static int cmd_sig(PROGRAMMER * pgm, struct avrpart * p,
|
|||||||
static int cmd_quit(PROGRAMMER * pgm, struct avrpart * p,
|
static int cmd_quit(PROGRAMMER * pgm, struct avrpart * p,
|
||||||
int argc, char * argv[])
|
int argc, char * argv[])
|
||||||
{
|
{
|
||||||
|
/* FUSE bit verify will fail if left in SPI mode */
|
||||||
|
if (spi_mode) {
|
||||||
|
cmd_pgm(pgm, p, 0, NULL);
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,11 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
WRITE_MODE_STANDARD = 0,
|
||||||
|
WRITE_MODE_FILL = 1,
|
||||||
|
} mode;
|
||||||
|
|
||||||
int terminal_mode(PROGRAMMER * pgm, struct avrpart * p);
|
int terminal_mode(PROGRAMMER * pgm, struct avrpart * p);
|
||||||
char * terminal_get_input(const char *prompt);
|
char * terminal_get_input(const char *prompt);
|
||||||
|
|
||||||
|
|||||||
52
src/update.c
52
src/update.c
@@ -25,6 +25,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
|
#include "ac_cfg.h"
|
||||||
#include "avrdude.h"
|
#include "avrdude.h"
|
||||||
#include "libavrdude.h"
|
#include "libavrdude.h"
|
||||||
|
|
||||||
@@ -226,6 +227,13 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AVRMEM_ALIAS * alias_mem = avr_find_memalias(p, mem);
|
||||||
|
char alias_mem_desc[AVR_DESCLEN + 1] = "";
|
||||||
|
if(alias_mem) {
|
||||||
|
strcat(alias_mem_desc, "/");
|
||||||
|
strcat(alias_mem_desc, alias_mem->desc);
|
||||||
|
}
|
||||||
|
|
||||||
if (upd->op == DEVICE_READ) {
|
if (upd->op == DEVICE_READ) {
|
||||||
/*
|
/*
|
||||||
* read out the specified device memory and write it to a file
|
* read out the specified device memory and write it to a file
|
||||||
@@ -237,14 +245,14 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (quell_progress < 2) {
|
if (quell_progress < 2) {
|
||||||
avrdude_message(MSG_INFO, "%s: reading %s memory:\n",
|
avrdude_message(MSG_INFO, "%s: reading %s%s memory:\n",
|
||||||
progname, mem->desc);
|
progname, mem->desc, alias_mem_desc);
|
||||||
}
|
}
|
||||||
report_progress(0,1,"Reading");
|
report_progress(0,1,"Reading");
|
||||||
rc = avr_read(pgm, p, upd->memtype, 0);
|
rc = avr_read(pgm, p, upd->memtype, 0);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
avrdude_message(MSG_INFO, "%s: failed to read all of %s memory, rc=%d\n",
|
avrdude_message(MSG_INFO, "%s: failed to read all of %s%s memory, rc=%d\n",
|
||||||
progname, mem->desc, rc);
|
progname, mem->desc, alias_mem_desc, rc);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
report_progress(1,1,NULL);
|
report_progress(1,1,NULL);
|
||||||
@@ -287,8 +295,8 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
|
|||||||
* write the buffer contents to the selected memory type
|
* write the buffer contents to the selected memory type
|
||||||
*/
|
*/
|
||||||
if (quell_progress < 2) {
|
if (quell_progress < 2) {
|
||||||
avrdude_message(MSG_INFO, "%s: writing %s (%d bytes):\n",
|
avrdude_message(MSG_INFO, "%s: writing %s%s (%d bytes):\n",
|
||||||
progname, mem->desc, size);
|
progname, mem->desc, alias_mem_desc, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(flags & UF_NOWRITE)) {
|
if (!(flags & UF_NOWRITE)) {
|
||||||
@@ -305,16 +313,16 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
avrdude_message(MSG_INFO, "%s: failed to write %s memory, rc=%d\n",
|
avrdude_message(MSG_INFO, "%s: failed to write %s%s memory, rc=%d\n",
|
||||||
progname, mem->desc, rc);
|
progname, mem->desc, alias_mem_desc, rc);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
vsize = rc;
|
vsize = rc;
|
||||||
|
|
||||||
if (quell_progress < 2) {
|
if (quell_progress < 2) {
|
||||||
avrdude_message(MSG_INFO, "%s: %d bytes of %s written\n", progname,
|
avrdude_message(MSG_INFO, "%s: %d bytes of %s%s written\n", progname,
|
||||||
vsize, mem->desc);
|
vsize, mem->desc, alias_mem_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -326,11 +334,11 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
|
|||||||
pgm->vfy_led(pgm, ON);
|
pgm->vfy_led(pgm, ON);
|
||||||
|
|
||||||
if (quell_progress < 2) {
|
if (quell_progress < 2) {
|
||||||
avrdude_message(MSG_INFO, "%s: verifying %s memory against %s:\n",
|
avrdude_message(MSG_INFO, "%s: verifying %s%s memory against %s:\n",
|
||||||
progname, mem->desc, upd->filename);
|
progname, mem->desc, alias_mem_desc, upd->filename);
|
||||||
|
|
||||||
avrdude_message(MSG_INFO, "%s: load data %s data from input file %s:\n",
|
avrdude_message(MSG_NOTICE2, "%s: load data %s%s data from input file %s:\n",
|
||||||
progname, mem->desc, upd->filename);
|
progname, mem->desc, alias_mem_desc, upd->filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = fileio(FIO_READ, upd->filename, upd->format, p, upd->memtype, -1);
|
rc = fileio(FIO_READ, upd->filename, upd->format, p, upd->memtype, -1);
|
||||||
@@ -342,17 +350,17 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
|
|||||||
v = avr_dup_part(p);
|
v = avr_dup_part(p);
|
||||||
size = rc;
|
size = rc;
|
||||||
if (quell_progress < 2) {
|
if (quell_progress < 2) {
|
||||||
avrdude_message(MSG_INFO, "%s: input file %s contains %d bytes\n",
|
avrdude_message(MSG_NOTICE2, "%s: input file %s contains %d bytes\n",
|
||||||
progname, upd->filename, size);
|
progname, upd->filename, size);
|
||||||
avrdude_message(MSG_INFO, "%s: reading on-chip %s data:\n",
|
avrdude_message(MSG_NOTICE2, "%s: reading on-chip %s%s data:\n",
|
||||||
progname, mem->desc);
|
progname, mem->desc, alias_mem_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
report_progress (0,1,"Reading");
|
report_progress (0,1,"Reading");
|
||||||
rc = avr_read(pgm, p, upd->memtype, v);
|
rc = avr_read(pgm, p, upd->memtype, v);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
avrdude_message(MSG_INFO, "%s: failed to read all of %s memory, rc=%d\n",
|
avrdude_message(MSG_INFO, "%s: failed to read all of %s%s memory, rc=%d\n",
|
||||||
progname, mem->desc, rc);
|
progname, mem->desc, alias_mem_desc, rc);
|
||||||
pgm->err_led(pgm, ON);
|
pgm->err_led(pgm, ON);
|
||||||
avr_free_part(v);
|
avr_free_part(v);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -362,7 +370,7 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
|
|||||||
|
|
||||||
|
|
||||||
if (quell_progress < 2) {
|
if (quell_progress < 2) {
|
||||||
avrdude_message(MSG_INFO, "%s: verifying ...\n", progname);
|
avrdude_message(MSG_NOTICE2, "%s: verifying ...\n", progname);
|
||||||
}
|
}
|
||||||
rc = avr_verify(p, v, upd->memtype, size);
|
rc = avr_verify(p, v, upd->memtype, size);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
@@ -374,8 +382,8 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (quell_progress < 2) {
|
if (quell_progress < 2) {
|
||||||
avrdude_message(MSG_INFO, "%s: %d bytes of %s verified\n",
|
avrdude_message(MSG_INFO, "%s: %d bytes of %s%s verified\n",
|
||||||
progname, rc, mem->desc);
|
progname, rc, mem->desc, alias_mem_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
pgm->vfy_led(pgm, OFF);
|
pgm->vfy_led(pgm, OFF);
|
||||||
|
|||||||
@@ -39,14 +39,21 @@
|
|||||||
#include "updi_constants.h"
|
#include "updi_constants.h"
|
||||||
#include "updi_state.h"
|
#include "updi_state.h"
|
||||||
|
|
||||||
static void msleep(int tms)
|
static void updi_set_rtsdtr_mode(PROGRAMMER* pgm)
|
||||||
{
|
{
|
||||||
usleep(tms * 1000);
|
updi_rts_mode rts_mode = updi_get_rts_mode(pgm);
|
||||||
|
|
||||||
|
if (rts_mode == RTS_MODE_DEFAULT) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
serial_set_dtr_rts(&pgm->fd, 0);
|
||||||
|
serial_set_dtr_rts(&pgm->fd, rts_mode == RTS_MODE_LOW ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int updi_physical_open(PROGRAMMER* pgm, int baudrate, unsigned long cflags)
|
static int updi_physical_open(PROGRAMMER* pgm, int baudrate, unsigned long cflags)
|
||||||
{
|
{
|
||||||
serial_recv_timeout = 100;
|
serial_recv_timeout = 1000;
|
||||||
union pinfo pinfo;
|
union pinfo pinfo;
|
||||||
|
|
||||||
pinfo.serialinfo.baud = baudrate;
|
pinfo.serialinfo.baud = baudrate;
|
||||||
@@ -65,11 +72,17 @@ static int updi_physical_open(PROGRAMMER* pgm, int baudrate, unsigned long cflag
|
|||||||
*/
|
*/
|
||||||
serial_drain(&pgm->fd, 0);
|
serial_drain(&pgm->fd, 0);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* set RTS/DTR mode if needed
|
||||||
|
*/
|
||||||
|
updi_set_rtsdtr_mode(pgm);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void updi_physical_close(PROGRAMMER* pgm)
|
static void updi_physical_close(PROGRAMMER* pgm)
|
||||||
{
|
{
|
||||||
|
serial_set_dtr_rts(&pgm->fd, 0);
|
||||||
serial_close(&pgm->fd);
|
serial_close(&pgm->fd);
|
||||||
pgm->fd.ifd = -1;
|
pgm->fd.ifd = -1;
|
||||||
}
|
}
|
||||||
@@ -124,28 +137,38 @@ static int updi_physical_send_double_break(PROGRAMMER * pgm)
|
|||||||
|
|
||||||
avrdude_message(MSG_DEBUG, "%s: Sending double break\n", progname);
|
avrdude_message(MSG_DEBUG, "%s: Sending double break\n", progname);
|
||||||
|
|
||||||
updi_physical_close(pgm);
|
if (serial_setparams(&pgm->fd, 300, SERIAL_8E1) < 0) {
|
||||||
|
|
||||||
if (updi_physical_open(pgm, 300, SERIAL_8E1)==-1) {
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer[0] = UPDI_BREAK;
|
updi_set_rtsdtr_mode(pgm);
|
||||||
|
|
||||||
serial_send(&pgm->fd, buffer, 1);
|
|
||||||
serial_recv(&pgm->fd, buffer, 1);
|
|
||||||
|
|
||||||
msleep(100);
|
|
||||||
|
|
||||||
buffer[0] = UPDI_BREAK;
|
buffer[0] = UPDI_BREAK;
|
||||||
|
|
||||||
serial_send(&pgm->fd, buffer, 1);
|
serial_send(&pgm->fd, buffer, 1);
|
||||||
serial_recv(&pgm->fd, buffer, 1);
|
serial_recv(&pgm->fd, buffer, 1);
|
||||||
|
|
||||||
updi_physical_close(pgm);
|
usleep(100*1000);
|
||||||
|
|
||||||
return updi_physical_open(pgm, pgm->baudrate? pgm->baudrate: 115200, SERIAL_8E2);
|
buffer[0] = UPDI_BREAK;
|
||||||
|
|
||||||
|
serial_send(&pgm->fd, buffer, 1);
|
||||||
|
serial_recv(&pgm->fd, buffer, 1);
|
||||||
|
|
||||||
|
serial_drain(&pgm->fd, 0);
|
||||||
|
|
||||||
|
if (serial_setparams(&pgm->fd, pgm->baudrate? pgm->baudrate: 115200, SERIAL_8E2) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
updi_set_rtsdtr_mode(pgm);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* drain any extraneous input
|
||||||
|
*/
|
||||||
|
serial_drain(&pgm->fd, 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int updi_physical_sib(PROGRAMMER * pgm, unsigned char * buffer, uint8_t size)
|
int updi_physical_sib(PROGRAMMER * pgm, unsigned char * buffer, uint8_t size)
|
||||||
@@ -175,10 +198,14 @@ int updi_physical_sib(PROGRAMMER * pgm, unsigned char * buffer, uint8_t size)
|
|||||||
|
|
||||||
int updi_link_open(PROGRAMMER * pgm)
|
int updi_link_open(PROGRAMMER * pgm)
|
||||||
{
|
{
|
||||||
|
unsigned char init_buffer[1];
|
||||||
|
|
||||||
if (updi_physical_open(pgm, pgm->baudrate? pgm->baudrate: 115200, SERIAL_8E2) < 0) {
|
if (updi_physical_open(pgm, pgm->baudrate? pgm->baudrate: 115200, SERIAL_8E2) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return updi_physical_send_double_break(pgm);
|
|
||||||
|
init_buffer[0]=UPDI_BREAK;
|
||||||
|
return updi_physical_send(pgm, init_buffer, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updi_link_close(PROGRAMMER * pgm)
|
void updi_link_close(PROGRAMMER * pgm)
|
||||||
|
|||||||
@@ -53,3 +53,13 @@ void updi_set_nvm_mode(PROGRAMMER * pgm, updi_nvm_mode mode)
|
|||||||
{
|
{
|
||||||
((updi_state *)(pgm->cookie))->nvm_mode = mode;
|
((updi_state *)(pgm->cookie))->nvm_mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updi_rts_mode updi_get_rts_mode(PROGRAMMER * pgm)
|
||||||
|
{
|
||||||
|
return ((updi_state *)(pgm->cookie))->rts_mode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void updi_set_rts_mode(PROGRAMMER * pgm, updi_rts_mode mode)
|
||||||
|
{
|
||||||
|
((updi_state *)(pgm->cookie))->rts_mode = mode;
|
||||||
|
}
|
||||||
|
|||||||
@@ -61,11 +61,19 @@ typedef struct
|
|||||||
char debug_version;
|
char debug_version;
|
||||||
} updi_sib_info;
|
} updi_sib_info;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
RTS_MODE_DEFAULT,
|
||||||
|
RTS_MODE_LOW,
|
||||||
|
RTS_MODE_HIGH
|
||||||
|
} updi_rts_mode;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
updi_sib_info sib_info;
|
updi_sib_info sib_info;
|
||||||
updi_datalink_mode datalink_mode;
|
updi_datalink_mode datalink_mode;
|
||||||
updi_nvm_mode nvm_mode;
|
updi_nvm_mode nvm_mode;
|
||||||
|
updi_rts_mode rts_mode;
|
||||||
} updi_state;
|
} updi_state;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -77,6 +85,8 @@ updi_datalink_mode updi_get_datalink_mode(PROGRAMMER * pgm);
|
|||||||
void updi_set_datalink_mode(PROGRAMMER * pgm, updi_datalink_mode mode);
|
void updi_set_datalink_mode(PROGRAMMER * pgm, updi_datalink_mode mode);
|
||||||
updi_nvm_mode updi_get_nvm_mode(PROGRAMMER * pgm);
|
updi_nvm_mode updi_get_nvm_mode(PROGRAMMER * pgm);
|
||||||
void updi_set_nvm_mode(PROGRAMMER * pgm, updi_nvm_mode mode);
|
void updi_set_nvm_mode(PROGRAMMER * pgm, updi_nvm_mode mode);
|
||||||
|
updi_rts_mode updi_get_rts_mode(PROGRAMMER * pgm);
|
||||||
|
void updi_set_rts_mode(PROGRAMMER * pgm, updi_rts_mode mode);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ static int usbhid_recv(union filedescriptor *fd, unsigned char *buf, size_t nbyt
|
|||||||
if (udev == NULL)
|
if (udev == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
rv = i = hid_read_timeout(udev, buf, nbytes, 300);
|
rv = i = hid_read_timeout(udev, buf, nbytes, 10000);
|
||||||
if (i != nbytes)
|
if (i != nbytes)
|
||||||
avrdude_message(MSG_INFO,
|
avrdude_message(MSG_INFO,
|
||||||
"%s: Short read, read only %d out of %u bytes\n",
|
"%s: Short read, read only %d out of %u bytes\n",
|
||||||
|
|||||||
63
src/usbasp.c
63
src/usbasp.c
@@ -66,42 +66,63 @@
|
|||||||
|
|
||||||
static libusb_context *ctx = NULL;
|
static libusb_context *ctx = NULL;
|
||||||
|
|
||||||
static int libusb_to_errno(int result)
|
static const char *errstr(int result)
|
||||||
{
|
{
|
||||||
|
static char msg[30];
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case LIBUSB_SUCCESS:
|
case LIBUSB_SUCCESS:
|
||||||
return 0;
|
return "No error";
|
||||||
case LIBUSB_ERROR_IO:
|
case LIBUSB_ERROR_IO:
|
||||||
return EIO;
|
n = EIO;
|
||||||
|
break;
|
||||||
case LIBUSB_ERROR_INVALID_PARAM:
|
case LIBUSB_ERROR_INVALID_PARAM:
|
||||||
return EINVAL;
|
n = EINVAL;
|
||||||
|
break;
|
||||||
case LIBUSB_ERROR_ACCESS:
|
case LIBUSB_ERROR_ACCESS:
|
||||||
return EACCES;
|
n = EACCES;
|
||||||
|
break;
|
||||||
case LIBUSB_ERROR_NO_DEVICE:
|
case LIBUSB_ERROR_NO_DEVICE:
|
||||||
return ENXIO;
|
n = ENXIO;
|
||||||
|
break;
|
||||||
case LIBUSB_ERROR_NOT_FOUND:
|
case LIBUSB_ERROR_NOT_FOUND:
|
||||||
return ENOENT;
|
n = ENOENT;
|
||||||
|
break;
|
||||||
case LIBUSB_ERROR_BUSY:
|
case LIBUSB_ERROR_BUSY:
|
||||||
return EBUSY;
|
n = EBUSY;
|
||||||
#ifdef ETIMEDOUT
|
break;
|
||||||
case LIBUSB_ERROR_TIMEOUT:
|
case LIBUSB_ERROR_TIMEOUT:
|
||||||
return ETIMEDOUT;
|
#ifdef ETIMEDOUT
|
||||||
|
n = ETIMEDOUT;
|
||||||
|
break;
|
||||||
|
#else
|
||||||
|
return "Operation timed out"
|
||||||
#endif
|
#endif
|
||||||
#ifdef EOVERFLOW
|
|
||||||
case LIBUSB_ERROR_OVERFLOW:
|
case LIBUSB_ERROR_OVERFLOW:
|
||||||
return EOVERFLOW;
|
#ifdef EOVERFLOW
|
||||||
|
n = EOVERFLOW;
|
||||||
|
break;
|
||||||
|
#else
|
||||||
|
return "Value too large to be stored in data type"
|
||||||
#endif
|
#endif
|
||||||
case LIBUSB_ERROR_PIPE:
|
case LIBUSB_ERROR_PIPE:
|
||||||
return EPIPE;
|
n = EPIPE;
|
||||||
|
break;
|
||||||
case LIBUSB_ERROR_INTERRUPTED:
|
case LIBUSB_ERROR_INTERRUPTED:
|
||||||
return EINTR;
|
n = EINTR;
|
||||||
|
break;
|
||||||
case LIBUSB_ERROR_NO_MEM:
|
case LIBUSB_ERROR_NO_MEM:
|
||||||
return ENOMEM;
|
n = ENOMEM;
|
||||||
|
break;
|
||||||
case LIBUSB_ERROR_NOT_SUPPORTED:
|
case LIBUSB_ERROR_NOT_SUPPORTED:
|
||||||
return ENOSYS;
|
n = ENOSYS;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return ERANGE;
|
snprintf(msg, sizeof msg, "Unknown libusb error: %d", result);
|
||||||
|
return msg;
|
||||||
}
|
}
|
||||||
|
return strerror(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -279,7 +300,7 @@ static int usbasp_transmit(PROGRAMMER * pgm,
|
|||||||
buffersize & 0xffff,
|
buffersize & 0xffff,
|
||||||
5000);
|
5000);
|
||||||
if(nbytes < 0){
|
if(nbytes < 0){
|
||||||
avrdude_message(MSG_INFO, "%s: error: usbasp_transmit: %s\n", progname, strerror(libusb_to_errno(nbytes)));
|
avrdude_message(MSG_INFO, "%s: error: usbasp_transmit: %s\n", progname, errstr(nbytes));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -343,7 +364,7 @@ static int usbOpenDevice(libusb_device_handle **device, int vendor,
|
|||||||
if (!handle) {
|
if (!handle) {
|
||||||
errorCode = USB_ERROR_ACCESS;
|
errorCode = USB_ERROR_ACCESS;
|
||||||
avrdude_message(MSG_INFO, "%s: Warning: cannot open USB device: %s\n",
|
avrdude_message(MSG_INFO, "%s: Warning: cannot open USB device: %s\n",
|
||||||
progname, strerror(libusb_to_errno(r)));
|
progname, errstr(r));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
errorCode = 0;
|
errorCode = 0;
|
||||||
@@ -354,7 +375,7 @@ static int usbOpenDevice(libusb_device_handle **device, int vendor,
|
|||||||
if ((vendorName != NULL) && (vendorName[0] != 0)) {
|
if ((vendorName != NULL) && (vendorName[0] != 0)) {
|
||||||
errorCode = USB_ERROR_IO;
|
errorCode = USB_ERROR_IO;
|
||||||
avrdude_message(MSG_INFO, "%s: Warning: cannot query manufacturer for device: %s\n",
|
avrdude_message(MSG_INFO, "%s: Warning: cannot query manufacturer for device: %s\n",
|
||||||
progname, strerror(libusb_to_errno(r)));
|
progname, errstr(r));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
avrdude_message(MSG_NOTICE2, "%s: seen device from vendor ->%s<-\n",
|
avrdude_message(MSG_NOTICE2, "%s: seen device from vendor ->%s<-\n",
|
||||||
@@ -368,7 +389,7 @@ static int usbOpenDevice(libusb_device_handle **device, int vendor,
|
|||||||
if ((productName != NULL) && (productName[0] != 0)) {
|
if ((productName != NULL) && (productName[0] != 0)) {
|
||||||
errorCode = USB_ERROR_IO;
|
errorCode = USB_ERROR_IO;
|
||||||
avrdude_message(MSG_INFO, "%s: Warning: cannot query product for device: %s\n",
|
avrdude_message(MSG_INFO, "%s: Warning: cannot query product for device: %s\n",
|
||||||
progname, strerror(libusb_to_errno(r)));
|
progname, errstr(r));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
avrdude_message(MSG_NOTICE2, "%s: seen product ->%s<-\n",
|
avrdude_message(MSG_NOTICE2, "%s: seen product ->%s<-\n",
|
||||||
|
|||||||
@@ -511,6 +511,20 @@ static int usbtiny_initialize (PROGRAMMER *pgm, AVRPART *p )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int usbtiny_setpin(struct programmer_t * pgm, int pinfunc, int value)
|
||||||
|
{
|
||||||
|
/* USBtiny is not a bit bang device, but it can set RESET */
|
||||||
|
if(pinfunc == PIN_AVR_RESET) {
|
||||||
|
if (usb_control(pgm, USBTINY_POWERUP,
|
||||||
|
PDATA(pgm)->sck_period, value ? RESET_HIGH : RESET_LOW) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
usleep(50000);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Tell the USBtiny to release the output pins, etc */
|
/* Tell the USBtiny to release the output pins, etc */
|
||||||
static void usbtiny_powerdown(PROGRAMMER * pgm)
|
static void usbtiny_powerdown(PROGRAMMER * pgm)
|
||||||
{
|
{
|
||||||
@@ -580,6 +594,27 @@ int usbtiny_cmd_tpi(PROGRAMMER * pgm, const unsigned char *cmd,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int usbtiny_spi(struct programmer_t * pgm, const unsigned char *cmd, unsigned char *res, int count)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
// Clear the receive buffer so we don't read old data in case of failure
|
||||||
|
memset(res, 0, count);
|
||||||
|
|
||||||
|
if (count % 4) {
|
||||||
|
avrdude_message(MSG_INFO, "Direct SPI write must be a multiple of 4 bytes for %s\n",
|
||||||
|
pgm->type);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < count; i += 4) {
|
||||||
|
if (usbtiny_cmd(pgm, cmd + i, res + i) < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Send the chip-erase command */
|
/* Send the chip-erase command */
|
||||||
static int usbtiny_chip_erase(PROGRAMMER * pgm, AVRPART * p)
|
static int usbtiny_chip_erase(PROGRAMMER * pgm, AVRPART * p)
|
||||||
{
|
{
|
||||||
@@ -759,6 +794,8 @@ void usbtiny_initpgm ( PROGRAMMER* pgm )
|
|||||||
pgm->set_sck_period = usbtiny_set_sck_period;
|
pgm->set_sck_period = usbtiny_set_sck_period;
|
||||||
pgm->setup = usbtiny_setup;
|
pgm->setup = usbtiny_setup;
|
||||||
pgm->teardown = usbtiny_teardown;
|
pgm->teardown = usbtiny_teardown;
|
||||||
|
pgm->setpin = usbtiny_setpin;
|
||||||
|
pgm->spi = usbtiny_spi;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* !HAVE_LIBUSB */
|
#else /* !HAVE_LIBUSB */
|
||||||
|
|||||||
Reference in New Issue
Block a user