Compare commits

...

129 Commits

Author SHA1 Message Date
Marius Greuel 15fe12b1a9 Add CMakeSettings.json for Visual Studio 2022 2022-05-09 15:42:48 +02:00
Marius Greuel b8420ee52d Update GitHub deploy action 2022-05-09 15:42:48 +02:00
Marius Greuel 6ebbd4e162 Update README.md 2022-05-09 15:42:48 +02:00
Marius Greuel 4b2bf38849 Add support for COM port discovery via USB VID/PID Add support for Leonardo USB bootloader auto-reset 2022-05-09 15:41:06 +02:00
Marius Greuel 9d6420e723 Correct endpoint direction for control messages of USBtinyISP devices 2022-05-09 15:41:06 +02:00
Marius Greuel bc9b67a153 Change Intel HEX line length from 32 to 16 to match line length of avr-objcopy 2022-05-09 15:41:06 +02:00
Marius Greuel 93b2a56c0e Change program URL to github.com 2022-05-09 15:41:06 +02:00
Joerg Wunsch a855692d97 Correctly name the release in CMakeLists.txt as well 2022-05-08 13:58:44 +02:00
Joerg Wunsch ec50337434 Correctly name the release in NEWS 2022-05-07 22:39:47 +02:00
Joerg Wunsch a2e456ca8a v7.0 release preparation 2022-05-07 22:20:31 +02:00
Joerg Wunsch 43ddea9102 Calibration memory of ATtiny43U is only 1 byte
Closes issue #921.
2022-05-05 22:58:45 +02:00
Joerg Wunsch a4c9fcdcd7 More fixes for PR #915 2022-05-02 22:51:22 +02:00
Joerg Wunsch 28ccd82edc PR 930 931 issue 927 are done 2022-05-01 22:32:54 +02:00
Jörg Wunsch ca16fc2ce6
Merge pull request #930 from cederom/cederom-programmer-avrftdi-ktlink
Added KT-LINK FT2232H interface with IO switching and voltage buffers.
2022-05-01 22:29:46 +02:00
Jörg Wunsch d7c59ca2f9
Merge pull request #931 from MCUdude/linuxspi-baud-fix
Fix linuxspi baud to clock period calculation
2022-05-01 22:26:23 +02:00
Joerg Wunsch 4bcd0eaa1d Fix a number of mistakes in avrdude.conf.in
Stefan Rueger found a lot of mistakes in this file.

Closes #915
2022-05-01 21:55:50 +02:00
Joerg Wunsch 08ad5ea445 Fix broken texinfo
@ must be escaped as @@
2022-04-26 23:19:20 +02:00
Joerg Wunsch 5a3ff78844 Fix syntax error in workflow build.yml file 2022-04-26 21:41:03 +02:00
Joerg Wunsch 74a92d7991 Try to exclude the 'onlinedocs' branch from actions
There's no sourcecode within that branch, anyway.
2022-04-26 21:29:46 +02:00
MCUdude 9d025e6a70 Fix linuxspi baud to clock period calculation
#927 related
2022-04-10 23:36:53 +02:00
Tomasz 'CeDeROM' CEDRO b99a145b9f Added KT-LINK FT2232H interface with IO switching and voltage buffers.
Example TPI run: https://github.com/avrdudes/avrdude/issues/928

Signed-off-by: Tomasz 'CeDeROM' CEDRO <tomek@cedro.info>
2022-04-10 22:28:44 +02:00
Joerg Wunsch 60960ba590 Closed 922, 924, 929 2022-04-10 22:20:11 +02:00
Jörg Wunsch 99a75701b1
Merge pull request #924 from MCUdude/terminal-overflow-fix
Fix terminal write buffer overflow issue
2022-04-10 22:19:27 +02:00
Jörg Wunsch abe7180bb8
Merge pull request #929 from per1234/update-docs-link
Update documentation link to new URL
2022-04-10 22:15:23 +02:00
per1234 157b6a63c1
Update documentation link to new URL
The project documentation is now hosted on GitHub pages. Pointing the documentation link to the documentation site home page will offer the reader easy access to the documentation for the latest and previous releases while also avoiding the maintenance burden of updating the readme on every release
2022-04-10 11:28:39 -07:00
MCUdude 1363c7fe76 Fix buffer overflow issue
when in terminal fill mode
2022-04-09 20:08:44 +02:00
Joerg Wunsch 7e26a15375 PRs/Issues 900, 901, 913, 914 done 2022-04-05 20:55:23 +02:00
Jörg Wunsch e84210c6b0
Merge pull request #914 from MCUdude/terminal-write-str
Add terminal write string functionality
2022-04-05 20:54:20 +02:00
MCUdude 08bd5fa938 Add string write to terminal example 2022-04-05 19:37:45 +02:00
MCUdude 17b67da03e Make sure memory can be filled with a string
... and not just the last character
2022-04-04 09:38:02 +02:00
MCUdude 795dd91575 Code cleanup + formatting 2022-04-01 22:23:55 +02:00
MCUdude 8f100f5df3 Initial support for string write 2022-04-01 21:57:53 +02:00
MCUdude f0f9059ade Tweak nexttok for better string handling
Now a string that starts and ends with a quote (") is combined into a single (argc) argument rather than being split where spaces used to be
2022-04-01 16:52:59 +02:00
Nav e069871c8e
Increased timeout passed to hid_read_timeout() - set to 10000 for consistency (#901) 2022-03-31 23:26:53 +02:00
Joerg Wunsch 0aa43968a0 Add PR 908, 909, 910, 912 2022-03-31 23:14:35 +02:00
Hans f22bc62b06
Mask out unused ATmega32U4 efuse bits (#909)
Closes #446
2022-03-31 23:13:57 +02:00
Hans d09a4e93a2
Add ATmega16U4 to avrdude.conf (#910)
Closes #447
2022-03-31 23:12:32 +02:00
Hans aa7ae7bb87
Add MacOS serial/parallel port note (#908)
Closes #510
2022-03-31 22:32:57 +02:00
Hans 1d0cbc2246
Add progressbar for read and write command (#912) 2022-03-31 22:21:49 +02:00
Joerg Wunsch 79c4137289 Mention the new search order for avrdude.conf 2022-03-22 08:49:04 +01:00
Joerg Wunsch 8697f6def7 Remove remnants of the old erase-cycle counter from examples 2022-03-21 06:38:28 +01:00
Joerg Wunsch 981a6f1f20 Restore the -u option as a dummy.
Closes #890
2022-03-20 21:50:45 +01:00
Joerg Wunsch c64db5fb76 Link the project's "Pages" for documentation 2022-03-19 23:26:27 +01:00
Joerg Wunsch 50c373bf71 Mention issues #771, #897, PRs #898, #899, #902, #903 2022-03-19 23:05:19 +01:00
Jörg Wunsch 0c722bf288
Merge pull request #903 from dl8dtl/term-docs
Terminal mode documentation
2022-03-19 23:04:50 +01:00
Jörg Wunsch 28d1442fc8
Merge pull request #902 from MCUdude/terminal-fix
Minor terminal write improvements
2022-03-19 23:02:24 +01:00
Jörg Wunsch 75e4d06463
Merge pull request #899 from MCUdude/avrdude-conf-fix
Fix errors in Avrdude.conf

This also closes #897
2022-03-19 23:01:12 +01:00
Jörg Wunsch 99f191a0ca
Merge pull request #898 from dl8dtl/macos-nonstandard-baudrates
Macos nonstandard baudrates

closes #266
2022-03-19 22:57:37 +01:00
Joerg Wunsch 33bace0cee Provide an example for the second form of the "write" command
In terminal mode, there are two forms of "write", one that
explicitly mentions all data values, and a second one that
instead specifies a total range to write, where the last data
value given is replicated as needed.
2022-03-19 17:30:55 +01:00
Joerg Wunsch 0c912a201f Try making the cindex (concept index) meaningful
Rearrange existing @cindex entries, add a lot of new ones.
2022-03-19 00:03:17 +01:00
Joerg Wunsch 31feb9ff75 Link the concept index 2022-03-19 00:00:54 +01:00
Joerg Wunsch c5a28eedc0 Also tweak smallexample 2022-03-19 00:00:41 +01:00
Joerg Wunsch 29a01c1047 Terminal mode: fix documentation of second version of "write"
Right after start_addr, the next element is the number of bytes
to be written.
2022-03-18 23:42:32 +01:00
MCUdude 426ea1fa78 Add missing free()'s 2022-03-18 21:20:58 +01:00
MCUdude 6a5988ad64 Print write info message when in verbose mode 2022-03-18 21:19:36 +01:00
MCUdude dcf771424b Increase buffer size to prevent potential overflow 2022-03-18 19:17:17 +01:00
Joerg Wunsch 67b56d322b Update texinfo documentation for terminal-mode changes
This documents the recent changes that have been implemented in
terminal mode.
2022-03-17 23:13:52 +01:00
Joerg Wunsch 27d201acb1 Also tweak smallexample 2022-03-17 07:21:33 +01:00
Joerg Wunsch ded30f86bc CSS test 2022-03-16 23:22:14 +01:00
Joerg Wunsch 9bc4a2463d Attempt to tweak CSS of the generated HTML docs a bit 2022-03-16 23:19:45 +01:00
Joerg Wunsch 8ad55e07ac Update generated documentation 2022-03-13 22:55:33 +01:00
Joerg Wunsch d89817ddb9 Merge branch 'main' into pages-test 2022-03-13 22:54:24 +01:00
Joerg Wunsch fc6a71a142 Merge remote-tracking branch 'upstream/main' 2022-03-13 22:53:46 +01:00
Joerg Wunsch da1271642e Remove the pointer to the mailing list
It makes more sense to point people to Github issue trackers now,
even for questions.
2022-03-13 22:52:44 +01:00
Joerg Wunsch 0e441013e9 Update docs 2022-03-13 00:31:27 +01:00
Joerg Wunsch c5f7939fca Merge branch 'main' into pages-test 2022-03-13 00:29:54 +01:00
Joerg Wunsch 297d81818a Merge remote-tracking branch 'upstream/main' 2022-03-13 00:25:50 +01:00
Joerg Wunsch 7391e569b3 Bring the texinfo doc up to date
* remove copyright years; they are not meaningful anyway
* reflect the project move from Savannah to Github
2022-03-13 00:21:35 +01:00
Joerg Wunsch 67ab74cd6a Fix a one-bit error in ATmega165* signature read command. 2022-03-13 00:21:35 +01:00
Joerg Wunsch 631f671fe8 Mention PRs #893, #894, #896, bug #889 2022-03-13 00:21:20 +01:00
MCUdude 248b554e8d Add support for read with ... "operator"
This means that you can use ... to read the "rest" of the memory.
$ read eeprom ...   will dump the entire memory
$ read eeorm 0x80 ...   will dump the memory from address 0x80 to the end address
2022-03-13 00:20:07 +01:00
MCUdude 40e3aa1790 Incread default read size to 256 bytes 2022-03-13 00:20:07 +01:00
MCUdude dca5fc92bf Restructure "write mode" code 2022-03-13 00:20:07 +01:00
MCUdude 4e05a8fa41 Update description 2022-03-13 00:20:07 +01:00
MCUdude 1299d6b8bd Fix terminal write bug
Wouldn't write data properly after an integer >= 2 bytes was written
2022-03-13 00:20:07 +01:00
MCUdude da315d7323 Support both userrow and usersig names 2022-03-13 00:20:07 +01:00
Joerg Wunsch 416c465ec0 Bring the texinfo doc up to date
* remove copyright years; they are not meaningful anyway
* reflect the project move from Savannah to Github
2022-03-13 00:13:29 +01:00
MCUdude 41f524c1ba Use the same device signature on ATmega165 and ATmega165A 2022-03-08 13:17:01 +01:00
MCUdude 5ebb9047be Fix incorrect ATxmega128D4 flash page size 2022-03-08 12:50:17 +01:00
MCUdude fde7881611 Fix incorrect ATmega64M1 flash and eeprom size
#897 related
2022-03-08 12:34:06 +01:00
MCUdude 1c94c95f1c Fix target names not following the standard 2022-03-08 12:32:41 +01:00
Joerg Wunsch e2995857ac Remove verboseness from build.sh
Got accidentally committed.
2022-03-07 23:27:54 +01:00
Joerg Wunsch a4cbd5c6fc Append a newline to the nonstandard baudrate warning 2022-03-07 23:25:36 +01:00
Joerg Wunsch 87b39637ff Implement nonstandard baudrate handling on MacOS
Alas, MacOS doesn't handle nonstandard baud rates like other systems
in regular tcsetattr() calls. Instead, they invented a new ioctl
(IOSSIOSPEED). So, if we notice we are going to configure a
nonstandard rate on MacOS, issue that ioctl after configuring
everything else using tcsetattr().
2022-03-07 23:20:50 +01:00
Joerg Wunsch 34168759b0 Fix a one-bit error in ATmega165* signature read command. 2022-03-07 22:52:14 +01:00
Joerg Wunsch c746c9bc9e Fix a one-bit error in ATmega165* signature read command. 2022-03-07 22:49:46 +01:00
Joerg Wunsch 65618ed655 Fix a one-bit error in the signature read command for ATmega165* 2022-03-07 21:38:17 +01:00
Joerg Wunsch 00ea962abe Add link to docs 2022-03-07 00:22:59 +01:00
Joerg Wunsch d62f309a00 Add symlink for index.html 2022-03-07 00:18:04 +01:00
Joerg Wunsch 92a5ae20a6 Test for Github pages 2022-03-07 00:09:47 +01:00
Joerg Wunsch 5cbc9c37fc Mention PRs #893, #894, #896, bug #889 2022-03-03 23:15:20 +01:00
Jörg Wunsch 0f4b5b223b
Merge pull request #894 from MCUdude/terminal
Improve terminal read functionality
2022-03-03 23:14:37 +01:00
Jörg Wunsch 0b82b5c573
Merge pull request #896 from MCUdude/terminal-write
Fix ugly terminal write bug
2022-03-03 23:12:47 +01:00
Jörg Wunsch 9355d67e0f
Merge pull request #893 from MCUdude/userrow-fix
Support both userrow and usersig names
2022-03-03 23:09:20 +01:00
MCUdude d9c52249a9 Restructure "write mode" code 2022-03-03 19:37:42 +01:00
MCUdude c7174d7678 Update description 2022-03-02 20:24:51 +01:00
MCUdude df6e2eea12 Fix terminal write bug
Wouldn't write data properly after an integer >= 2 bytes was written
2022-03-02 20:09:59 +01:00
Joerg Wunsch 0d58adb10a Close #892 #895 2022-03-01 23:30:11 +01:00
Jörg Wunsch ebb1849724
Merge pull request #895 from janegilruud/bugfix/fix-cnano-updi-flash-read
For UPDI devices do not add offset when accessing flash.
2022-03-01 23:26:11 +01:00
Jan Egil Ruud 0c8b42524e For UPDI devices do not add offset when accessing flash. 2022-03-01 14:24:33 +01:00
MCUdude b688b1f601 Add support for read with ... "operator"
This means that you can use ... to read the "rest" of the memory.
$ read eeprom ...   will dump the entire memory
$ read eeorm 0x80 ...   will dump the memory from address 0x80 to the end address
2022-02-28 23:59:30 +01:00
MCUdude d89f695c31 Incread default read size to 256 bytes 2022-02-28 23:59:30 +01:00
MCUdude 1f2b570216 Support both userrow and usersig names 2022-02-28 19:46:47 +01:00
Joerg Wunsch 64cc54ac35 PR #888 done 2022-02-21 23:28:50 +01:00
Jörg Wunsch e2e5e44bab
Merge pull request #888 from MCUdude/userrow-alias
Add userrow and usersig aliases
2022-02-21 23:28:05 +01:00
MCUdude 07ea8f5e09 Add userrow and usersig aliases 2022-02-21 22:36:06 +01:00
Joerg Wunsch 0269817217 Add a missing @end table
Has been slipped when adding some -x documentation before.
2022-02-21 22:01:05 +01:00
Joerg Wunsch fe6290072a PR #880 done 2022-02-21 21:54:47 +01:00
Jörg Wunsch 008f95f6ff
Merge pull request #880 from MCUdude/terminal-write
Avrdude terminal write improvements
2022-02-21 21:53:38 +01:00
MCUdude a73567893b Properly handle negative number sizes 2022-02-21 13:43:38 +01:00
MCUdude fa706f0d01 Handle data size warning better
Now it only outputs a warning when the size of the data the user input is actually ambiguous
2022-02-20 23:03:31 +01:00
MCUdude 3532c567ac Add suffix for 8-bit data
use [val]HH or [val]hh to force 8-bit writes to memory
2022-02-20 22:23:15 +01:00
Joerg Wunsch 14f646822c PR #886 done 2022-02-20 20:59:28 +01:00
Jörg Wunsch bb73ade70b
Merge pull request #886 from dbuchwald/ser_posix_cleanup
Cleanup of POSIX serial init code
2022-02-20 20:58:22 +01:00
MCUdude bb99a36a14 Formatting
Use enums for write mode, and change datatypes from int/long/char to int32_t/uint8_t where possible
2022-02-20 19:08:30 +01:00
Joerg Wunsch 0d7d034d24 Issue #884 closed 2022-02-20 16:58:39 +01:00
MCUdude a9b756e5c7 Add struct initialization list 2022-02-20 12:46:53 +01:00
Dawid Buchwald cf67a76c23 Merge branch 'main' into ser_posix_cleanup 2022-02-20 12:37:19 +01:00
MCUdude 0e29b43bd0 Add support for 64-bit integers
Also, move everything data related into a struct, to keep tings a little more organized
2022-02-19 23:34:50 +01:00
MCUdude 4b9219edee Add support for suffixes for manually specifying data size
H/h/S/s: 16-bit, L/l: 32-bit, F/f: 32-bit float
2022-02-19 22:48:58 +01:00
MCUdude 62f3b84eee Use union for simpler data representation
It is a bit hacky, but for this purpose it fits surprisingly well
2022-02-19 20:15:52 +01:00
Dawid Buchwald 066f54fbfa Cleanup of POSIX serial init code 2022-02-19 18:00:58 +01:00
Hans c345985928
Merge branch 'avrdudes:main' into terminal-write 2022-02-18 22:09:42 +01:00
MCUdude 6e7f38e81f Properly handle negative numbers
Now -3.141592 and -32768 are valid numbers that's stored correctly in memory
2022-02-18 09:58:16 +01:00
MCUdude 10e05eed21 Require single quotes when writing characters 2022-02-18 09:58:16 +01:00
MCUdude 551046052e Add support for writing floats 2022-02-18 09:58:16 +01:00
MCUdude 2a92b8cce4 Add support for memory "fill" with arbitrary data too
If you run the following command: $ write eeprom 0x00 0x10 A B C ...

It will write the following data to EEPROM:
|ABCCCCCCCCCCCCCC|
starting from address 0x00
2022-02-18 09:58:16 +01:00
MCUdude c007dc7d24 Add support for writing single characters
Now this is possible: write eeprom 0x00 a b c d e f 0x80 0x90 ! H E L L O
2022-02-18 09:58:16 +01:00
MCUdude 2589b17640 Add support for memory "fill" mode
Syntax: write <memtype> <start addr> <no. byte to write> <byte to write> ...
2022-02-18 09:58:13 +01:00
28 changed files with 2691 additions and 274 deletions

View File

@ -20,7 +20,11 @@ name: Build
on:
push:
branches-ignore:
- 'onlinedocs'
pull_request:
branches-ignore:
- 'onlinedocs'
workflow_call:
env:

View File

@ -25,7 +25,7 @@ on:
jobs:
build:
uses: avrdudes/avrdude/.github/workflows/build.yml@main
uses: mariusgreuel/avrdude/.github/workflows/build.yml@windows
release:
needs: build

View File

@ -21,7 +21,7 @@
# cmake --build build
cmake_minimum_required(VERSION 3.12)
project(avrdude VERSION 6.99)
project(avrdude VERSION 7.0)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED True)

126
CMakeSettings.json Normal file
View File

@ -0,0 +1,126 @@
{
"configurations": [
{
"name": "x86-Debug",
"generator": "Visual Studio 17 2022",
"configurationType": "Debug",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x86" ],
"variables": [
{
"name": "DEBUG_CMAKE",
"value": "True",
"type": "BOOL"
},
{
"name": "USE_EXTERNAL",
"value": "True",
"type": "BOOL"
}
]
},
{
"name": "x86-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x86" ],
"variables": [
{
"name": "DEBUG_CMAKE",
"value": "True",
"type": "BOOL"
},
{
"name": "USE_EXTERNAL",
"value": "True",
"type": "BOOL"
},
{
"name": "CMAKE_C_FLAGS_RELWITHDEBINFO",
"value": "/MT /GL /Zi /O2 /Ob1 /DNDEBUG",
"type": "STRING"
},
{
"name": "CMAKE_CXX_FLAGS_RELWITHDEBINFO",
"value": "/MT /GL /Zi /O2 /Ob1 /DNDEBUG",
"type": "STRING"
},
{
"name": "CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO",
"value": "/debug /INCREMENTAL:NO /LTCG /OPT:REF /OPT:ICF",
"type": "STRING"
}
]
},
{
"name": "x64-Debug",
"generator": "Visual Studio 17 2022 Win64",
"configurationType": "Debug",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": [
{
"name": "DEBUG_CMAKE",
"value": "True",
"type": "BOOL"
},
{
"name": "USE_EXTERNAL",
"value": "True",
"type": "BOOL"
}
]
},
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": [
{
"name": "DEBUG_CMAKE",
"value": "True",
"type": "BOOL"
},
{
"name": "USE_EXTERNAL",
"value": "True",
"type": "BOOL"
},
{
"name": "CMAKE_C_FLAGS_RELWITHDEBINFO",
"value": "/MT /GL /Zi /O2 /Ob1 /DNDEBUG",
"type": "STRING"
},
{
"name": "CMAKE_CXX_FLAGS_RELWITHDEBINFO",
"value": "/MT /GL /Zi /O2 /Ob1 /DNDEBUG",
"type": "STRING"
},
{
"name": "CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO",
"value": "/debug /INCREMENTAL:NO /LTCG /OPT:REF /OPT:ICF",
"type": "STRING"
}
]
}
]
}

46
NEWS
View File

@ -5,7 +5,7 @@ Approximate change log for AVRDUDE by version.
(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:
@ -18,6 +18,12 @@ Changes since version 6.4:
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:
@ -35,6 +41,7 @@ Changes since version 6.4:
- 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:
@ -45,6 +52,8 @@ Changes since version 6.4:
- 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:
@ -70,6 +79,20 @@ Changes since version 6.4:
- 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:
@ -138,6 +161,27 @@ Changes since version 6.4:
- 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:

64
README-old.md Normal file
View File

@ -0,0 +1,64 @@
# AVRDUDE
[![Build Status](https://github.com/avrdudes/avrdude/actions/workflows/build.yml/badge.svg)](https://github.com/avrdudes/avrdude/actions/workflows/build.yml)
AVRDUDE - AVR Downloader Uploader - is a program for downloading and uploading
the on-chip memories of Microchips [AVR microcontrollers](https://en.wikipedia.org/wiki/AVR_microcontrollers).
It can program the Flash and EEPROM, and where supported by the programming
protocol, it can program fuse and lock bits.
AVRDUDE also supplies a direct instruction mode allowing one to issue any
programming instruction to the AVR chip regardless of whether AVRDUDE
implements that specific feature of a particular chip.
AVRDUDE was originally written in 2003 by Brian S. Dean. Since 2006, AVRDUDE has been maintained by Jörg Wunsch,
with the help of [various contributors](./AUTHORS).
The latest version of AVRDUDE is always available here:\
<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
To get AVRDUDE for Windows, install the latest version from the [Releases](http://download.savannah.gnu.org/releases/avrdude/) page.
Alternatively, you may [build AVRDUDE](https://github.com/avrdudes/avrdude/wiki) yourself from source.
## Getting AVRDUDE for Linux
To install AVRDUDE for Linux, install the package `avrdude` by running the following commands:
```console
sudo apt-get install avrdude
```
Alternatively, you may [build AVRDUDE](https://github.com/avrdudes/avrdude/wiki) yourself from source.
## Getting AVRDUDE for MacOS
On MacOS, AVRDUDE can be installed through Mac Ports.
Alternatively, you may [build AVRDUDE](https://github.com/avrdudes/avrdude/wiki) yourself from source.
## Using AVRDUDE
AVRDUDE is a command-line application. Run the command `avrdude` without any arguments for a list of options.
A typical command to program your HEX file into your AVR microcontroller looks like this:
```console
avrdude -c <programmer> -p <part> -U flash:w:<file>:i
```
For instance, to program an **Arduino Uno** connected to the serial port **COM1** with a HEX file called `blink.hex`,
you would run the following command:
```console
avrdude -c arduino -P COM1 -b 115200 -p atmega328p -D -U flash:w:objs/blink.hex:i
```
There are many different programmers and options that may be required for the programming to succeed.
For more information, refer to the [AVRDUDE documentation](https://avrdudes.github.io/avrdude/).

230
README.md
View File

@ -1,60 +1,224 @@
# AVRDUDE
# AVRDUDE for Windows
[![Build Status](https://github.com/avrdudes/avrdude/actions/workflows/build.yml/badge.svg)](https://github.com/avrdudes/avrdude/actions/workflows/build.yml)
[![Build Status](https://github.com/mariusgreuel/avrdude/actions/workflows/build.yml/badge.svg?branch=windows)](https://github.com/mariusgreuel/avrdude/actions/workflows/build.yml)
AVRDUDE - AVR Downloader Uploader - is a program for downloading and uploading
the on-chip memories of Microchips [AVR microcontrollers](https://en.wikipedia.org/wiki/AVR_microcontrollers).
It can program the Flash and EEPROM, and where supported by the programming
protocol, it can program fuse and lock bits.
AVRDUDE also supplies a direct instruction mode allowing one to issue any
programming instruction to the AVR chip regardless of whether AVRDUDE
implements that specific feature of a particular chip.
This is a fork of AVRDUDE 7.0 from <https://github.com/avrdudes/avrdude>.
AVRDUDE was originally written in 2003 by Brian S. Dean. Since 2006, AVRDUDE has been maintained by Jörg Wunsch,
with the help of [various contributors](./AUTHORS).
The purpose of this fork is to add better support for Windows to bring it on par with the Linux version of AVRDUDE.
The latest version of AVRDUDE is always available here:\
<https://github.com/avrdudes/avrdude>
Noteable changes include:
## Getting AVRDUDE for Windows
- [Support Atmel AVR programmers out of the box](#support-atmel-avr-programmers-out-of-the-box)
- [Support Micronucleus bootloader](#support-micronucleus-bootloader)
- [Support Teensy HalfKay bootloader](#support-teensy-halfkay-bootloader)
- [Support COM port discovery via USB VID/PID](#support-com-port-discovery-via-usb-vidpid)
- [Support Arduino Leonardo bootloader auto-reset](#support-arduino-leonardo-bootloader-auto-reset)
- [Support WinUSB devices via custom libusb](#support-winusb-devices-via-custom-libusb)
- [Support FTDI devices via custom libftdi](#support-ftdi-devices-via-custom-libftdi)
- [Support HID devices via libhidapi](#support-hid-devices-via-libhidapi)
- [Support Visual Studio](#support-visual-studio)
- [Miscellaneous bug-fixes and patches](#miscellaneous-bug-fixes-and-patches)
To get AVRDUDE for Windows, install the latest version from the [Releases](http://download.savannah.gnu.org/releases/avrdude/) page.
The original AVRDUDE project homepage can be found here <https://github.com/avrdudes/avrdude>.
Alternatively, you may [build AVRDUDE](https://github.com/avrdudes/avrdude/wiki) yourself from source.
## Documentation
## Getting AVRDUDE for Linux
Documentation for current and previous releases is [on Github Pages](https://avrdudes.github.io/avrdude/).
To install AVRDUDE for Linux, install the package `avrdude` by running the following commands:
## Download
To get the latest version of **AVRDUDE for Windows**, go to the [releases folder](https://github.com/mariusgreuel/avrdude/releases):
<https://github.com/mariusgreuel/avrdude/releases>
## Feature Details
### Support Atmel AVR programmers out of the box
This build contains support for Atmel AVR programmers, such as
- [Atmel-ICE](https://www.microchip.com/DevelopmentTools/ProductDetails/ATATMEL-ICE) (Part Number: ATATMEL-ICE)
- [Atmel AVRISP mkII](https://www.microchip.com/DevelopmentTools/ProductDetails/PartNO/ATAVRISP2) (Part Number: ATAVRISP2)
This build does not rely on **libusb** drivers. Instead the default Atmel drivers can be used, allowing you to use AVRDUDE and Atmel Studio 7 side-by-side, without switching drivers.
If you previously changed the driver of your programmer to libusb, you should use **Windows Device Manager** to uninstall the device, and then reinstall using the default Windows drivers.
### Support Micronucleus bootloader
This build adds support for the [Micronucleus bootloader](https://github.com/micronucleus/micronucleus), so you do no longer need a separate command-line utility when working with devices that use the Micronucleus bootloader.
The Micronucleus bootloader is typically used on small ATtiny boards, such as **Digispark** (ATtiny85), **Digispark Pro** (ATtiny167), and the respective clones.
By default, it uses the USB VID/PID **16D0:0753** (MCS Digistump).
Since this bootloader is optimized for size, it implements writing to flash memory only.
As it does not support reading, you need to use the **-V** option to prevent AVRDUDE from verifing the flash memory. To have AVRDUDE wait for the device to be connected, use the extended option '-x wait'.
#### Example: Flashing a Micronucleus bootloader device
```console
sudo apt-get install avrdude
avrdude -c micronucleus -p t85 -x wait -V -U flash:w:main.hex:i
```
Alternatively, you may [build AVRDUDE](https://github.com/avrdudes/avrdude/wiki) yourself from source.
### Support Teensy HalfKay bootloader
## Getting AVRDUDE for MacOS
This build adds support for the [Teensy HalfKay bootloader](https://www.pjrc.com/teensy/halfkay_protocol.html), so you do no longer need a the Teensy Loader tool when working with Teensy devices.
On MacOS, AVRDUDE can be installed through Mac Ports.
Since this bootloader is optimized for size, it implements writing to flash memory only.
As it does not support reading, you need to use the **-V** option to prevent AVRDUDE from verifing the flash memory. To have AVRDUDE wait for the device to be connected, use the extended option '-x wait'.
Alternatively, you may [build AVRDUDE](https://github.com/avrdudes/avrdude/wiki) yourself from source.
Supported devices are:
## Using AVRDUDE
- Teensy 1.0 (AT90USB162)
- Teensy 2.0 (ATmega32U4)
- Teensy++ 1.0 (AT90USB646)
- Teensy++ 2.0 (AT90USB1286)
AVRDUDE is a command-line application. Run the command `avrdude` without any arguments for a list of options.
A typical command to program your HEX file into your AVR microcontroller looks like this:
#### Example: Flashing a Teensy 2.0 device
```console
avrdude -c <programmer> -p <part> -U flash:w:<file>:i
avrdude -c teensy -p m32u4 -x wait -V -U flash:w:main.hex:i
```
For instance, to program an **Arduino Uno** connected to the serial port **COM1** with a HEX file called `blink.hex`,
you would run the following command:
### Support COM port discovery via USB VID/PID
Most Arduino boards use a USB-based virtual COM port, which is connected to some sort of bootloader. Since COM port numbers (COM1, COM2, ...) are determined by Windows, you first need to use Windows device manager to figure out the COM port before you can use AVRDUDE to flash the board. Alternatively, you may use Windows device manager to assign a COM port of your choice to the USB device. Additionally, the COM port of your Arduino board may change over time, for instance if you plug the device in a different USB port.
To simplify the discovery of your Arduino board, I provided the possibility to specify the USB vendor and product ID instead of the COM port.
For instance, to connect to an Arduino Leonardo, use the following command:
```console
avrdude -c arduino -P COM1 -b 115200 -p atmega328p -D -U flash:w:objs/blink.hex:i
avrdude -c avr109 -P usb:2341:0036 -p m32u4
```
There are many different programmers and options that may be required for the programming to succeed.
Since the USB vendor and device ID **2341:0036** is the identical for all Leonardo boards, the command above will work regardless of which COM port was actually assigned to your board.
Note that can cannot use this method if you have more than one device of the same type (i.e. that share the same USB VID/PID) plugged into your computer. Also, some devices ship various versions of firmwares using different VID/PID.
To figure out the USB VID and PID, you may use **Windows devices manager** (see the **Hardware IDs** of the **Details tab** of the USB device), or look it up in the official list of Arduino devices:
<https://github.com/arduino/ArduinoCore-avr/blob/master/boards.txt>
USB VID/PID pairs for some popular boards and the respective commands are:
- Arduino Uno Rev 3: **2A03:0043** -> `avrdude -c arduino -P usb:2A03:0043 -p m328p`
- Arduino Micro: **2341:0037** -> `avrdude -c avr109 -P usb:2341:0037 -p m32u4`
- Arduino Leonardo: **2341:0036** -> `avrdude -c avr109 -P usb:2341:0036 -p m32u4`
- Sparkfun Pro Micro (5V): **1B4F:9205** -> `avrdude -c avr109 -P usb:1B4F:9205 -p m32u4`
- Sparkfun Pro Micro (3.3V): **1B4F:9203** -> `avrdude -c avr109 -P usb:1B4F:9203 -p m32u4`
- Adafruit Circuit Playground: **239A:0011** -> `avrdude -c avr109 -P usb:239A:0011 -p m32u4`
### Support Arduino Leonardo bootloader auto-reset
Before any Arduino board may be flashed via the bootloader, you need to kick it into bootloader mode first. This can done manually by pressing the reset button, or automatically via an special auto-reset mechanism: For boards with a USB to serial converter chip (such as Arduino Uno or Nano), the tool needs to pull the DTR signal to low, which will briefly pull the RESET pin of the microcontroller to low. For boards with a direct USB connection (such as Arduino Leonardo or Micro), the sketch typically implements a serial port via a USB composite device with a virtual COM port. To perform the auto-reset, the sketch implements a hack that resets the device into bootloader mode when the COM port is opened with a baudrate of 1200bps. To make matters even more complicated, the bootloader COM port has a different USB VID:PID pair than the sketch COM port, which causes the COM port to change while performing the reset.
To simplify the process of auto-resetting the board, this version will auto-reset the device when AVRDUDE detects that the device is running in sketch mode. Note that the sketch is required to implement a USB composite device with a virtual COM port with a matching USB VID:PID, which is implemented in the Arduino core software.
### Support WinUSB devices via custom libusb
Since AVRDUDE originated from Unix, the USB support in AVRDUDE is built upon the Unix-based USB library [libusb](https://sourceforge.net/projects/libusb/). In order to support Windows, libusb has been ported to Windows [libusb-win32](https://sourceforge.net/projects/libusb-win32/).
The downside of using libusb-win32 is that it requires the user to manually install a kernel-mode driver (libusb0.sys or libusbk.sys) instead of the manufacturer supplied Windows driver. There are several hacks to accomplish this, such as the [Zadig driver installation utility](https://zadig.akeo.ie/), which installs a self-signed root certificate in the Windows driver store due to the lack of proper driver installation packages.
This build contains a custom library called **libwinusb**, which implements a sub-set of the libusb-win32 API. The libwinusb implementation supports both the **winusb.sys** driver, and the **libusb0.sys** driver as well. This patch has a number of advantages, such as
- Many USB devices that ship with WinUSB drivers, such as Atmel programmer, will run out of the box.
- Works with both WinUSB and libusb: You can use either Windows built-in WinUSB driver to access your USB devices, or keep using the libusb drivers if you have them installed already.
- No static dependency to libusb0.dll: You cannot run the original version AVRDUDE, unless you previously installed libusb. On systems where libusb is not installed, this build eliminates the error "The code execution cannot proceed because libusb0.dll was not found. Reinstalling the program may fix this problem".
#### Microsoft OS descriptors and firmware examples
Windows provides a mechanism to automatically load the built-in WinUSB driver without providing a driver installation package (INF file). The automatic WinUSB driver installation is triggered via a special [Microsoft OS descriptor](https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors) that must be present in the firmware of the USB device.
To demonstrate how this works, I added Microsoft OS descriptors to the following projects:
- **USBasp** - USB programmer for Atmel AVR controllers: <https://github.com/mariusgreuel/USBasp>
- **FabISP** a.k.a **USBtinyISP** - A fab-able in-system programmer: <https://github.com/mariusgreuel/FabISP>
- **Micronucleus** - ATtiny USB bootloader with a strong emphasis on bootloader compactness: <https://github.com/mariusgreuel/micronucleus>
### Support FTDI devices via custom libftdi
In order to support FTDI devices, AVRDUDE uses the Unix-based library [libftdi1](https://www.intra2net.com/en/developer/libftdi/). Similar to libusb, the libftdi1 library does not play nice on Windows: On Windows, FTDI devices load the manufacturer supplied driver via plug-and-play. The FTDI drivers implement an API via the FTDI D2XX DLLs. However, libftdi1 cannot use the D2XX interface, so it will not work with the plug-and-play drivers.
This build contains a patches library of **libftdi**. The patches load the D2XX DLLs to support FTDI devices, so FTDI devices will just work.
### Support HID devices via libhidapi
This build include the WIN32 version of libhidapi, and some patches, to allow HID devices to work out of the box.
### Support Visual Studio
This build adds support for **Microsoft Visual Studio**. Building AVRDUDE with Microsoft Visual C/C++ will give you the best user and debugging experience while working on Windows.
### Miscellaneous bug-fixes and patches
- This build fixes [bug #54159: Buffer overflow in usbtiny.c](http://savannah.nongnu.org/bugs/?54159), which causes AVRDUDE to crash when using the USBtiny programmer.
- Support new microcontroller: ATtiny167
## Releases
You can find the latest releases of **AVRDUDE for Windows** here:
<https://github.com/mariusgreuel/avrdude/releases>
## Users manual
You can find the original users manual (does not contain AVRDUDE for Windows extras) of AVRDUDE here:
<https://www.nongnu.org/avrdude/user-manual/avrdude.html>
## Build
The build instructions have been moved here:\
<https://github.com/avrdudes/avrdude/wiki>
### Building AVRDUDE for Windows using MSVC
#### Windows Prerequisites
In order to build AVRDUDE on Windows, you need:
- Flex and Bison installed, for instance via [Chocolatey](https://chocolatey.org/)
- Microsoft Visual Studio 2019 with **Desktop development with C++** and **CMake** enabled
#### Windows Build Instructions
To build AVRDUDE on Windows, do the following:
- `git clone --branch windows https://github.com/mariusgreuel/avrdude`
- Open the folder **avrdude** using the menu item **File->Open->Folder**
- Build the project using the menu item **Build->Build All**
### Linux udev rules
If you intent to use either the Micronucleus or Teensy bootloader, you should edit the udev rules so that you can run AVRDUDE without root.
For instance, if you are on Ubuntu and you installed the avrdude package, you would edit `/lib/udev/rules.d/60-avrdude.rules` and add the following rules:
```console
# Micronucleus Bootloader
SUBSYSTEM=="usb", ATTR{idVendor}=="16d0", ATTR{idProduct}=="0753", TAG+="uaccess"
# Teensy Bootloader
SUBSYSTEM=="usb", ATTR{idVendor}=="16c0", ATTR{idProduct}=="0478", TAG+="uaccess"
```
## Troubleshooting Tips & Tricks
### Atmel DFU Device driver broken
The current version of the Atmel DFU drivers that are distributed via the Windows Update are goofed up (@Atmel: It might have something to do with the fact that you commented out the CopyFiles sections!).
Symptoms are:
- You cannot use AVRDUDE to connect to an Atmel DFU device, and you get the error message "No matching USB device found".
- When installing the drivers via Windows Update, you get the error message "Windows encountered a problem installing the drivers for your device" and "A service installation section in this INF is invalid."
- In Windows Device Manager, the Atmel DFU device shows up as an unknown device.
You should use an older driver package that does not contain this bug.
### Outdated libusb0 driver
The most current version of libusb0.sys is 1.2.6.0, signed on 12/17/2012 by Travis Lee Robinson. If you are using an older version (check with Windows Device Manager), you may not be able to connect to your USB devices using the libusb0 driver.
For more information, refer to the [AVRDUDE documentation](http://download.savannah.gnu.org/releases/avrdude/avrdude-doc-6.4.pdf).

View File

@ -75,6 +75,7 @@ if(MSVC)
"msvc/getopt.c"
"msvc/gettimeofday.c"
"msvc/usleep.cpp"
"msvc/usb_com_helper.cpp"
)
set(EXTRA_WINDOWS_INCLUDES ${EXTRA_WINDOWS_INCLUDES}
"msvc"

View File

@ -593,6 +593,38 @@ programmer
reset = 3; # TMS 7
;
# Kristech KT-LINK FT2232H interface with IO switching and voltage buffers.
# Created on 20220410 by CeDeROM Tomasz CEDRO (www.cederom.io).
# Interface DataSheet: https://kristech.pl/files/KT-LINK-UM-ENG.pdf
# AVRDUDE FT2232H PIN NUMBER DECODE:
# | 0 | 1 | .. | 7 | 8 | 9 | .. | 15 |
# | ADBUS0 | ADBUS1 | .. | ADBUS7 | ACBUS0 | ACBUS1 | .. | ACBUS7 |
# KT-LINK JTAG CONN:
# 1=Vsense(->EXT13), 19=5V(EXT1->EXT3), 20=GND, 3=TPIRST, 9=TPICLK, 7=TPIDATA.
# INTERNALS CONFIGURATION ("~" MEANS ACTIVE LOW):
# ~TRST_EN=10(ACBUS2), ~CLK_EN=14(ACBUS6), ~MOSI_EN=13(ACBUS5),
# TMS_SEL=5(ADBUS5), ~TMS_EN=12(ACBUS4), LED=~15(ACBUS7).
# CONNECTION NOTES:
# * Connect EXT connector pin 1 with 3 to get 5V on JTAG connector pin 19.
# * Connect JTAG connector pin 1 to 5V (i.e. EXT pin 13 or JTAG pin 19).
# * For TPI connection use resistors: TDO --[470R]-- TPIDATA --[470R]-- TDI.
# * Powering target from JTAG pin 19 allows KT-LINK current measurement.
programmer
id = "ktlink";
desc = "KT-LINK FT2232H interface with IO switching and voltage buffers.";
type = "avrftdi";
connection_type = usb;
usbvid= 0x0403;
usbpid= 0xBBE2;
usbdev= "A";
reset = 8;
sck = 0;
mosi = 1;
miso = 2;
buff = ~10,~14,~13,5;
rdyled = ~15;
;
programmer
id = "serialupdi";
desc = "SerialUPDI";
@ -4741,16 +4773,79 @@ part parent "m324p"
signature = 0x1e 0x94 0x0a;
memory "eeprom"
paged = no; /* leave this "no" */
size = 512;
page_size = 4;
;
min_write_delay = 9000;
max_write_delay = 9000;
readback_p1 = 0xff;
readback_p2 = 0xff;
read = " 1 0 1 0 0 0 0 0",
" 0 0 x x x a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" o o o o o o o o";
write = " 1 1 0 0 0 0 0 0",
" 0 0 x x x a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" i i i i i i i i";
loadpage_lo = " 1 1 0 0 0 0 0 1",
" 0 0 0 0 0 0 0 0",
" 0 0 0 0 0 0 a1 a0",
" i i i i i i i i";
writepage = " 1 1 0 0 0 0 1 0",
" 0 0 x x x a10 a9 a8",
" a7 a6 a5 a4 a3 a2 0 0",
" x x x x x x x x";
mode = 0x41;
delay = 10;
blocksize = 128;
readsize = 256;
;
memory "flash"
paged = yes;
size = 16384;
page_size = 128;
num_pages = 128;
min_write_delay = 4500;
max_write_delay = 4500;
readback_p1 = 0xff;
readback_p2 = 0xff;
read_lo = " 0 0 1 0 0 0 0 0",
" 0 a14 a13 a12 a11 a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" o o o o o o o o";
read_hi = " 0 0 1 0 1 0 0 0",
" 0 a14 a13 a12 a11 a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" o o o o o o o o";
loadpage_lo = " 0 1 0 0 0 0 0 0",
" 0 0 x x x x x x",
" x x a5 a4 a3 a2 a1 a0",
" i i i i i i i i";
loadpage_hi = " 0 1 0 0 1 0 0 0",
" 0 0 x x x x x x",
" x x a5 a4 a3 a2 a1 a0",
" i i i i i i i i";
writepage = " 0 1 0 0 1 1 0 0",
" 0 a14 a13 a12 a11 a10 a9 a8",
" a7 a6 x x x x x x",
" x x x x x x x x";
mode = 0x21;
delay = 6;
blocksize = 256;
readsize = 256;
;
;
#------------------------------------------------------------
@ -5907,7 +6002,7 @@ part
" i i i i i i i i";
writepage = " 0 1 0 0 1 1 0 0",
" x x x a12 a11 a10 a9 a8",
" x a14 a13 a12 a11 a10 a9 a8",
" a7 a6 x x x x x x",
" x x x x x x x x";
@ -5980,7 +6075,7 @@ part
part parent "m329"
id = "m329a";
desc = "ATmega329a";
desc = "ATmega329A";
;
#------------------------------------------------------------
@ -6161,7 +6256,7 @@ part
" i i i i i i i i";
writepage = " 0 1 0 0 1 1 0 0",
" x x x a12 a11 a10 a9 a8",
"a15 a14 a13 a12 a11 a10 a9 a8",
" a7 x x x x x x x",
" x x x x x x x x";
@ -8846,7 +8941,7 @@ part
"a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o";
write = "1 1 0 0 0 0 0 0 0 0 x x x x x a8",
"a8 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i";
"a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i";
loadpage_lo = " 1 1 0 0 0 0 0 1",
" 0 0 0 0 0 0 0 0",
@ -8854,8 +8949,8 @@ part
" i i i i i i i i";
writepage = " 1 1 0 0 0 0 1 0",
" 0 0 x x x x x x",
" 0 0 a5 a4 a3 a2 0 0",
" 0 0 x x x x x a8",
" a7 a6 a5 a4 a3 a2 0 0",
" x x x x x x x x";
mode = 0x41;
@ -9033,7 +9128,7 @@ part
"a7 a6 a5 a4 a3 a2 a1 a0 o o o o o o o o";
write = "1 1 0 0 0 0 0 0 0 0 x x x x x a8",
"a8 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i";
"a7 a6 a5 a4 a3 a2 a1 a0 i i i i i i i i";
loadpage_lo = " 1 1 0 0 0 0 0 1",
" 0 0 0 0 0 0 0 0",
@ -9041,8 +9136,8 @@ part
" i i i i i i i i";
writepage = " 1 1 0 0 0 0 1 0",
" 0 0 x x x x x x",
" 0 0 a5 a4 a3 a2 0 0",
" 0 0 x x x x x a8",
" a7 a6 a5 a4 a3 a2 0 0",
" x x x x x x x x";
mode = 0x41;
@ -9776,6 +9871,81 @@ part parent "m328"
signature = 0x1e 0x96 0x84;
bs2 = 0xe2;
memory "eeprom"
paged = no;
size = 2048;
page_size = 8;
min_write_delay = 3600;
max_write_delay = 3600;
readback_p1 = 0xff;
readback_p2 = 0xff;
read = " 1 0 1 0 0 0 0 0",
" 0 0 0 x x a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" o o o o o o o o";
write = " 1 1 0 0 0 0 0 0",
" 0 0 0 x x a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" i i i i i i i i";
loadpage_lo = " 1 1 0 0 0 0 0 1",
" 0 0 0 0 0 0 0 0",
" 0 0 0 0 0 a2 a1 a0",
" i i i i i i i i";
writepage = " 1 1 0 0 0 0 1 0",
" 0 0 x x x a10 a9 a8",
" a7 a6 a5 a4 a3 0 0 0",
" x x x x x x x x";
mode = 0x41;
delay = 20;
blocksize = 4;
readsize = 256;
;
memory "flash"
paged = yes;
size = 65536;
page_size = 256;
num_pages = 256;
min_write_delay = 4500;
max_write_delay = 4500;
readback_p1 = 0xff;
readback_p2 = 0xff;
read_lo = " 0 0 1 0 0 0 0 0",
" a15 a14 a13 a12 a11 a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" o o o o o o o o";
read_hi = " 0 0 1 0 1 0 0 0",
" a15 a14 a13 a12 a11 a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" o o o o o o o o";
loadpage_lo = " 0 1 0 0 0 0 0 0",
" 0 0 0 x x x x x",
" x a6 a5 a4 a3 a2 a1 a0",
" i i i i i i i i";
loadpage_hi = " 0 1 0 0 1 0 0 0",
" 0 0 0 x x x x x",
" x a6 a5 a4 a3 a2 a1 a0",
" i i i i i i i i";
writepage = " 0 1 0 0 1 1 0 0",
" a15 a14 a13 a12 a11 a10 a9 a8",
" a7 x x x x x x x",
" x x x x x x x x";
mode = 0x41;
delay = 6;
blocksize = 128;
readsize = 256;
;
memory "efuse"
size = 1;
min_write_delay = 4500;
@ -10247,7 +10417,7 @@ part
" i i i i i i i i";
writepage = " 1 1 0 0 0 0 1 0",
" 0 0 x x x x x x",
" 0 0 x x x x x a8",
" a7 a6 a5 a4 a3 a2 0 0",
" x x x x x x x x";
@ -12115,7 +12285,7 @@ part
writepage = " 1 1 0 0 0 0 1 0",
" 0 0 x x x x x x",
" x a6 a5 a4 a3 a2 0 0",
" a7 a6 a5 a4 a3 a2 0 0",
" x x x x x x x x";
mode = 0x41;
@ -12307,8 +12477,8 @@ part
" i i i i i i i i";
writepage = " 1 1 0 0 0 0 1 0",
" 0 0 x x x x x x",
" x a6 a5 a4 a3 a2 0 0",
" 0 0 x x x x x a8",
" a7 a6 a5 a4 a3 a2 0 0",
" x x x x x x x x";
mode = 0x41;
@ -12549,7 +12719,7 @@ part parent "t84"
part
id = "t43u";
desc = "ATtiny43u";
desc = "ATtiny43U";
has_debugwire = yes;
flash_instr = 0xB4, 0x07, 0x17;
eeprom_instr = 0xBB, 0xFF, 0xBB, 0xEE, 0xBB, 0xCC, 0xB2, 0x0D,
@ -12609,7 +12779,7 @@ part
readback_p1 = 0xff;
readback_p2 = 0xff;
read = "1 0 1 0 0 0 0 0 0 0 0 x x x x x",
"0 0 a4 a3 a2 a1 a0 o o o o o o o o";
"0 0 a5 a4 a3 a2 a1 a0 o o o o o o o o";
write = "1 1 0 0 0 0 0 0 0 0 0 x x x x x",
"0 0 a5 a4 a3 a2 a1 a0 i i i i i i i i";
@ -12678,6 +12848,8 @@ part
size = 1;
write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
"x x x x x x x x 1 1 i i i i i i";
read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
"x x x x x x x x o o o o o o o o";
min_write_delay = 4500;
max_write_delay = 4500;
;
@ -12716,12 +12888,203 @@ part
;
memory "calibration"
size = 2;
size = 1;
read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
"0 0 0 0 0 0 0 a0 o o o o o o o o";
;
;
#------------------------------------------------------------
# ATmega16u4
#------------------------------------------------------------
part
id = "m16u4";
desc = "ATmega16U4";
signature = 0x1e 0x94 0x88;
usbpid = 0x2ff4;
has_jtag = yes;
# stk500_devcode = 0xB2;
# avr910_devcode = 0x43;
chip_erase_delay = 9000;
pagel = 0xD7;
bs2 = 0xA0;
reset = dedicated;
pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
"x x x x x x x x x x x x x x x x";
chip_erase = "1 0 1 0 1 1 0 0 1 0 0 0 0 0 0 0",
"x x x x x x x x x x x x x x x x";
timeout = 200;
stabdelay = 100;
cmdexedelay = 25;
synchloops = 32;
bytedelay = 0;
pollindex = 3;
pollvalue = 0x53;
predelay = 1;
postdelay = 1;
pollmethod = 1;
pp_controlstack =
0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
hventerstabdelay = 100;
progmodedelay = 0;
latchcycles = 5;
togglevtg = 1;
poweroffdelay = 15;
resetdelayms = 1;
resetdelayus = 0;
hvleavestabdelay = 15;
chiperasepulsewidth = 0;
chiperasepolltimeout = 10;
programfusepulsewidth = 0;
programfusepolltimeout = 5;
programlockpulsewidth = 0;
programlockpolltimeout = 5;
idr = 0x31;
spmcr = 0x57;
rampz = 0x3b;
allowfullpagebitstream = no;
ocdrev = 3;
memory "eeprom"
paged = no; /* leave this "no" */
page_size = 4; /* for parallel programming */
size = 512;
min_write_delay = 9000;
max_write_delay = 9000;
readback_p1 = 0x00;
readback_p2 = 0x00;
read = " 1 0 1 0 0 0 0 0",
" x x x x x x x a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" o o o o o o o o";
write = " 1 1 0 0 0 0 0 0",
" x x x x x x x a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" i i i i i i i i";
loadpage_lo = " 1 1 0 0 0 0 0 1",
" 0 0 0 0 0 0 0 0",
" 0 0 0 0 0 0 a1 a0",
" i i i i i i i i";
writepage = " 1 1 0 0 0 0 1 0",
" 0 0 x x x x x a8",
" a7 a6 a5 a4 a3 a2 0 0",
" x x x x x x x x";
mode = 0x41;
delay = 20;
blocksize = 4;
readsize = 256;
;
memory "flash"
paged = yes;
size = 16384;
page_size = 128;
num_pages = 128;
min_write_delay = 4500;
max_write_delay = 4500;
readback_p1 = 0x00;
readback_p2 = 0x00;
read_lo = " 0 0 1 0 0 0 0 0",
" 0 a14 a13 a12 a11 a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" o o o o o o o o";
read_hi = " 0 0 1 0 1 0 0 0",
" 0 a14 a13 a12 a11 a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" o o o o o o o o";
loadpage_lo = " 0 1 0 0 0 0 0 0",
" x x x x x x x x",
" x x a5 a4 a3 a2 a1 a0",
" i i i i i i i i";
loadpage_hi = " 0 1 0 0 1 0 0 0",
" x x x x x x x x",
" x x a5 a4 a3 a2 a1 a0",
" i i i i i i i i";
writepage = " 0 1 0 0 1 1 0 0",
" a15 a14 a13 a12 a11 a10 a9 a8",
" a7 a6 x x x x x x",
" x x x x x x x x";
mode = 0x41;
delay = 6;
blocksize = 128;
readsize = 256;
;
memory "lfuse"
size = 1;
write = "1 0 1 0 1 1 0 0 1 0 1 0 0 0 0 0",
"x x x x x x x x i i i i i i i i";
read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
"x x x x x x x x o o o o o o o o";
min_write_delay = 9000;
max_write_delay = 9000;
;
memory "hfuse"
size = 1;
write = "1 0 1 0 1 1 0 0 1 0 1 0 1 0 0 0",
"x x x x x x x x i i i i i i i i";
read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
"x x x x x x x x o o o o o o o o";
min_write_delay = 9000;
max_write_delay = 9000;
;
memory "efuse"
size = 1;
write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
"x x x x x x x x 1 1 1 1 i i i i";
read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
"x x x x x x x x o o o o o o o o";
min_write_delay = 9000;
max_write_delay = 9000;
;
memory "lock"
size = 1;
read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
"x x x x x x x x 0 0 o o o o o o";
write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
"x x x x x x x x 1 1 i i i i i i";
min_write_delay = 9000;
max_write_delay = 9000;
;
memory "calibration"
size = 1;
read = "0 0 1 1 1 0 0 0 x x x x x x x x",
"0 0 0 0 0 0 0 0 o o o o o o o o";
;
memory "signature"
size = 3;
read = "0 0 1 1 0 0 0 0 x x x x x x x x",
"x x x x x x a1 a0 o o o o o o o o";
;
;
#------------------------------------------------------------
# ATmega32u4
#------------------------------------------------------------
@ -12802,12 +13165,12 @@ part
loadpage_lo = " 1 1 0 0 0 0 0 1",
" 0 0 0 0 0 0 0 0",
" 0 0 0 0 0 a2 a1 a0",
" 0 0 0 0 0 0 a1 a0",
" i i i i i i i i";
writepage = " 1 1 0 0 0 0 1 0",
" 0 0 x x x a10 a9 a8",
" a7 a6 a5 a4 a3 0 0 0",
" a7 a6 a5 a4 a3 a2 0 0",
" x x x x x x x x";
mode = 0x41;
@ -12881,7 +13244,7 @@ part
memory "efuse"
size = 1;
write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
"x x x x x x x x x x x x i i i i";
"x x x x x x x x 1 1 1 1 i i i i";
read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
"x x x x x x x x o o o o o o o o";
@ -13201,7 +13564,7 @@ part
" i i i i i i i i";
writepage = " 1 1 0 0 0 0 1 0",
" 0 0 x x x a10 a9 a8",
" 0 0 x x a11 a10 a9 a8",
" a7 a6 a5 a4 a3 0 0 0",
" x x x x x x x x";
@ -14263,7 +14626,7 @@ part
part
id = "m165";
desc = "ATmega165";
signature = 0x1e 0x94 0x07;
signature = 0x1e 0x94 0x10;
has_jtag = yes;
# stk500_devcode = 0x??;
# avr910_devcode = 0x??;
@ -14437,7 +14800,7 @@ part
memory "signature"
size = 3;
read = "0 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0",
read = "0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0",
"x x x x x x a1 a0 o o o o o o o o";
;
@ -15445,6 +15808,13 @@ part parent "x128c3"
id = "x128d4";
desc = "ATxmega128D4";
signature = 0x1e 0x97 0x47;
memory "flash"
size = 0x22000;
offset = 0x800000;
page_size = 0x100;
readsize = 0x100;
;
;
#------------------------------------------------------------
@ -16253,28 +16623,28 @@ part
readback_p1 = 0xff;
readback_p2 = 0xff;
read_lo = " 0 0 1 0 0 0 0 0",
" 0 0 0 a12 a11 a10 a9 a8",
" 0 0 a13 a12 a11 a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" o o o o o o o o";
read_hi = " 0 0 1 0 1 0 0 0",
" 0 0 0 a12 a11 a10 a9 a8",
" 0 0 a13 a12 a11 a10 a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" o o o o o o o o";
loadpage_lo = " 0 1 0 0 0 0 0 0",
" 0 0 0 x x x x x",
" x x a5 a4 a3 a2 a1 a0",
" x x x x a3 a2 a1 a0",
" i i i i i i i i";
loadpage_hi = " 0 1 0 0 1 0 0 0",
" 0 0 0 x x x x x",
" x x a5 a4 a3 a2 a1 a0",
" x x x x a3 a2 a1 a0",
" i i i i i i i i";
writepage = " 0 1 0 0 1 1 0 0",
" 0 0 0 a12 a11 a10 a9 a8",
" a7 a6 x x x x x x",
" 0 0 a13 a12 a11 a10 a9 a8",
" a7 a6 a5 a4 x x x x",
" x x x x x x x x";
mode = 0x41;
@ -16513,7 +16883,7 @@ part parent ".reduced_core_tiny"
part
id = "m406";
desc = "ATMEGA406";
desc = "ATmega406";
has_jtag = yes;
signature = 0x1e 0x95 0x07;
@ -16748,12 +17118,16 @@ part parent ".avr8x"
desc = "AVR8X tiny family common values";
family_id = "tinyAVR";
memory "usersig"
memory "userrow"
size = 0x20;
offset = 0x1300;
page_size = 0x20;
readsize = 0x100;
;
memory "usersig"
alias "userrow";
;
;
#------------------------------------------------------------
@ -16765,12 +17139,16 @@ part parent ".avr8x"
desc = "AVR8X mega family common values";
family_id = "megaAVR";
memory "usersig"
memory "userrow"
size = 0x40;
offset = 0x1300;
page_size = 0x40;
readsize = 0x100;
;
memory "usersig"
alias "userrow";
;
;
#------------------------------------------------------------
@ -18001,6 +18379,10 @@ part
readsize = 0x20;
;
memory "usersig"
alias "userrow";
;
memory "data"
# SRAM, only used to supply the offset
offset = 0x1000000;
@ -18837,6 +19219,10 @@ part parent ".avrdx"
page_size = 0x40;
readsize = 0x40;
;
memory "usersig"
alias "userrow";
;
;
#------------------------------------------------------------

View File

@ -23,7 +23,7 @@
# Process this file with autoconf to produce a configure script.
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_HOST

View File

@ -40,7 +40,7 @@ all-local: info html ps pdf
html: avrdude-html/avrdude.html
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 \
mkdir -p avrdude-html ; \
mv -f *.html avrdude-html ; \

20
src/doc/avrdude.css Normal file
View 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;
}

View File

@ -28,9 +28,7 @@ This file documents the avrdude program.
For avrdude version @value{VERSION}, @value{UPDATED}.
Copyright @copyright{} 2003, 2005 Brian Dean
Copyright @copyright{} 2006 - 2021 J@"org Wunsch
Copyright @copyright{} Brian Dean, J@"org Wunsch
Permission is granted to make and distribute verbatim copies of
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
@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{} 2006 - 2013 J@"org Wunsch
Copyright @copyright{} Brian S. Dean, J@"org Wunsch
@sp 2
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}.
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{} 2003,2005 Brian S. Dean
Copyright @copyright{} 2006 J@"org Wunsch
Copyright @copyright{} Brian S. Dean, J@"org Wunsch
@end ifinfo
@menu
@ -119,6 +110,7 @@ Copyright @copyright{} 2006 J@"org Wunsch
* Programmer Specific Information::
* Platform Dependent Information::
* Troubleshooting::
* Index::
@end menu
@c
@ -127,7 +119,7 @@ Copyright @copyright{} 2006 J@"org Wunsch
@node Introduction, Command Line Options, Top, Top
@comment node-name, next, previous, up
@chapter Introduction
@cindex introduction
@cindex Introduction
AVRDUDE - AVR Downloader Uploader - is a program for downloading and
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,
programming fuse/lock bits, etc.
@cindex Programmers supported
AVRDUDE supports the following basic programmer types: Atmel's STK500,
Atmel's AVRISP and AVRISP mkII devices,
Atmel's STK600,
@ -345,6 +339,7 @@ below for Teensy specific options.
@c Node
@c
@node History, , Introduction, Introduction
@cindex History
@section History and Credits
AVRDUDE was written by Brian S. Dean under the name of AVRPROG to run on
@ -353,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
Windows programming software.
The AVRDUDE source now resides in the public CVS repository on
savannah.gnu.org (@url{http://savannah.gnu.org/projects/avrdude/}),
where it continues to be enhanced and ported to other systems. In
For many years, the AVRDUDE source resided in public repositories on
savannah.nongnu.org,
where it continued to be enhanced and ported to other systems. In
addition to FreeBSD, AVRDUDE now runs on Linux and Windows. The
developers behind the porting effort primarily were Ted Roth, Eric
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
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
@ -374,7 +371,6 @@ Roth.
@c
@node Command Line Options, Terminal Mode Operation, Introduction, Top
@chapter Command Line Options
@cindex options
@menu
* Option Descriptions::
@ -386,6 +382,7 @@ Roth.
@c Node
@c
@node Option Descriptions, Programmers accepting extended parameters, Command Line Options, Command Line Options
@cindex Options (command-line)
@section Option Descriptions
@noindent
@ -410,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.
Currently, the following MCU types are understood:
@cindex Device support
@multitable @columnfractions .15 .3
@include parts.texi
@end multitable
@ -461,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.
Currently, the following programmer ids are understood and supported:
@cindex Programmer support
@multitable @columnfractions .2 .6
@include programmers.texi
@end multitable
@ -838,7 +839,7 @@ accepting extended parameters.
@c
@node Programmers accepting extended parameters, Example Command Line Invocations, Option Descriptions, Command Line Options
@section Programmers accepting extended parameters
@cindex @code{-x} AVR Dragon
@table @code
@item JTAG ICE mkII/3
@ -855,6 +856,7 @@ Each AVR unit within the chain shifts by 4 bits.
Other JTAG units might require a different bit shift count.
@end table
@cindex @code{-x} AVR910
@item AVR910
The AVR910 programmer type accepts the following extended parameter:
@ -875,13 +877,16 @@ Use
programmer creates errors during initial sequence.
@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
The BusPirate programmer type accepts the following extended parameters:
@ -971,6 +976,7 @@ The default value is 100ms. Using 10ms might work in most cases.
@end table
@cindex @code{-x} Micronucleus bootloader
@item Micronucleus bootloader
When using the Micronucleus programmer type, the
@ -983,6 +989,7 @@ If no time-out is specified, AVRDUDE will wait indefinitely until the
device is plugged in.
@end table
@cindex @code{-x} Teensy bootloader
@item Teensy bootloader
When using the Teensy programmer type, the
@ -995,6 +1002,7 @@ If no time-out is specified, AVRDUDE will wait indefinitely until the
device is plugged in.
@end table
@cindex @code{-x} Wiring
@item Wiring
When using the Wiring programmer type, the
@ -1006,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.
@end table
@cindex @code{-x} PICkit2
@item PICkit2
Connection to the PICkit2 programmer:
@multitable @columnfractions .05 .3
@ -1026,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).
@end table
@cindex @code{-x} USBasp
@item USBasp
Extended parameters:
@table @code
@ -1036,6 +1046,7 @@ rather than entire chip.
Only applicable to TPI devices (ATtiny 4/5/9/10/20/40).
@end table
@cindex @code{-x} xbee
@item xbee
Extended parameters:
@table @code
@ -1052,6 +1063,7 @@ The remaining two necessary XBee-to-MCU connections are not selectable
the MCU's TXD line.
@end table
@cindex @code{-x} serialupdi
@item serialupdi
Extended parameters:
@table @code
@ -1254,6 +1266,7 @@ commands can be recalled and edited.
@end menu
@node Terminal Mode Commands, Terminal Mode Examples, Terminal Mode Operation, Terminal Mode Operation
@cindex Terminal Mode
@section Terminal Mode Commands
@noindent
@ -1261,20 +1274,83 @@ The following commands are implemented:
@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
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
previous dump command left off.
@item write @var{memtype} @var{addr} @var{byte1} @dots{} @var{byteN}
Manually program the respective memory cells, starting at address addr,
using the values @var{byte1} through @var{byteN}. This feature is not
@item write @var{memtype} @var{start_addr} @var{data1} @var{data2} @dots{} @var{dataN}
Manually program the respective memory cells, starting at address @var{start_addr},
using the values @var{data1} through @var{dataN}. This feature is not
implemented for bank-addressed memories such as the flash memory of
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
Perform a chip erase.
@ -1367,6 +1443,7 @@ Display the current target supply voltage and JTAG bit clock rate/period.
@c Node
@c
@node Terminal Mode Examples, , Terminal Mode Commands, Terminal Mode Operation
@cindex Terminal Mode
@section Terminal Mode Examples
@noindent
@ -1378,7 +1455,6 @@ Display part parameters, modify eeprom cells, perform a chip erase:
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e9702
avrdude: current erase-rewrite cycle count is 52 (if being tracked)
avrdude> part
>>> part
@ -1440,7 +1516,6 @@ display the factory defaults, then reprogram:
avrdude: AVR device initialized and ready to accept instructions
avrdude: Device signature = 0x1e9702
avrdude: current erase-rewrite cycle count is 52 (if being tracked)
avrdude> d efuse
>>> d efuse
0000 fd |. |
@ -1466,11 +1541,56 @@ avrdude>
@end cartouche
@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 Node
@c
@node Configuration File, Programmer Specific Information, Terminal Mode Operation, Top
@cindex Configuration File
@cindex @code{avrdude.conf}
@chapter Configuration File
@noindent
@ -1833,6 +1953,7 @@ Reading fuse and lock bits is fully supported.
@c Node
@c
@node Atmel STK600, Atmel DFU bootloader using FLIP version 1, Programmer Specific Information, Programmer Specific Information
@cindex STK600
@section Atmel STK600
@c
@ -1929,6 +2050,7 @@ least 4.5 V in order to work. This can be done using
@c Node
@c
@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
Bootloaders using the FLIP protocol version 1 experience some very
@ -1957,6 +2079,7 @@ versions of the bootloader.
@c Node
@c
@node SerialUPDI programmer, , Atmel DFU bootloader using FLIP version 1, Programmer Specific Information
@cindex SerialUPDI
@section SerialUPDI programmer
SerialUPDI programmer can be used for programming UPDI-only devices
@ -2207,6 +2330,8 @@ configuration file will be always be @code{/etc/avrdude.conf}.
@noindent
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.
@multitable @columnfractions .30 .30 .30
@ -2439,13 +2564,13 @@ such as @option{--prefix} and @option{--datadir}.
@c
@c Node
@c
@node Troubleshooting, ,Platform Dependent Information ,Top
@node Troubleshooting,Index ,Platform Dependent Information ,Top
@appendix Troubleshooting
@noindent
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
@ -2750,7 +2875,11 @@ erase cycle.
@end itemize
@node Index, , Troubleshooting, Top
@unnumbered Concept Index
@printindex cp
@bye

View File

@ -1159,7 +1159,7 @@ static int fileio_ihex(struct fioparms * fio,
switch (fio->op) {
case FIO_WRITE:
rc = b2ihex(mem->buf, size, 32, fio->fileoffset, filename, f);
rc = b2ihex(mem->buf, size, 16, fio->fileoffset, filename, f);
if (rc < 0) {
return -1;
}

View File

@ -1174,7 +1174,8 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
u32_to_b4(xd.nvm_fuse_offset, m->offset & ~7);
} else if (matches(m->desc, "lock")) {
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);
} else if (strcmp(m->desc, "prodsig") == 0) {
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_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_base, m->offset);
@ -1265,7 +1267,7 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
"xd->flash_page_size=%x\n\t"
"xd->eeprom_page_size=%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.prog_base_msb,
xd.prog_base[0], xd.prog_base[1],
@ -1686,9 +1688,10 @@ static int jtag3_page_erase(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
cmd[3] = XMEGA_ERASE_BOOT_PAGE;
} else if (strcmp(m->desc, "eeprom") == 0) {
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;
} else if ( ( strcmp(m->desc, "boot") == 0 ) ) {
} else if (strcmp(m->desc, "boot") == 0) {
cmd[3] = XMEGA_ERASE_BOOT_PAGE;
} else {
cmd[3] = XMEGA_ERASE_APP_PAGE;
@ -1760,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;
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;
} else if ( ( strcmp(m->desc, "boot") == 0 ) ) {
} else if (strcmp(m->desc, "boot") == 0) {
cmd[3] = MTYPE_BOOT_FLASH;
} else if ( p->flags & AVRPART_HAS_PDI || p->flags & AVRPART_HAS_UPDI ) {
cmd[3] = MTYPE_FLASH;
@ -1849,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;
if (pgm->flag & PGM_FL_IS_DW)
return -1;
} else if ( ( strcmp(m->desc, "prodsig") == 0 ) ) {
} else if (strcmp(m->desc, "prodsig") == 0) {
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;
} else if ( ( strcmp(m->desc, "boot") == 0 ) ) {
} else if (strcmp(m->desc, "boot") == 0) {
cmd[3] = MTYPE_BOOT_FLASH;
} else if ( p->flags & AVRPART_HAS_PDI ) {
cmd[3] = MTYPE_FLASH;
@ -1965,7 +1970,8 @@ static int jtag3_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
cmd[3] = MTYPE_FUSE_BITS;
if (!(p->flags & AVRPART_HAS_UPDI))
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;
} else if (strcmp(mem->desc, "prodsig") == 0) {
cmd[3] = MTYPE_PRODSIG;
@ -2126,7 +2132,8 @@ static int jtag3_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
cmd[3] = MTYPE_FUSE_BITS;
if (!(p->flags & AVRPART_HAS_UPDI))
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;
} else if (strcmp(mem->desc, "prodsig") == 0) {
cmd[3] = MTYPE_PRODSIG;
@ -2465,7 +2472,10 @@ static unsigned int jtag3_memaddr(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, uns
* Non-Xmega device.
*/
if (p->flags & AVRPART_HAS_UPDI) {
if (m->size == 1) {
if (strcmp(m->desc, "flash") == 0) {
return addr;
}
else if (m->size == 1) {
addr = m->offset;
}
else if (m->size > 1) {

View File

@ -1056,7 +1056,8 @@ static void jtagmkII_set_xmega_params(PROGRAMMER * pgm, AVRPART * p)
u32_to_b4(sendbuf.dd.nvm_fuse_offset, m->offset & ~7);
} else if (strncmp(m->desc, "lock", 4) == 0) {
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);
} else if (strcmp(m->desc, "prodsig") == 0) {
u32_to_b4(sendbuf.dd.nvm_prod_sig_offset, m->offset);
@ -1933,9 +1934,10 @@ static int jtagmkII_page_erase(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
cmd[1] = XMEGA_ERASE_BOOT_PAGE;
} else if (strcmp(m->desc, "eeprom") == 0) {
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;
} else if ( ( strcmp(m->desc, "boot") == 0 ) ) {
} else if (strcmp(m->desc, "boot") == 0) {
cmd[1] = XMEGA_ERASE_BOOT_PAGE;
} else {
cmd[1] = XMEGA_ERASE_APP_PAGE;
@ -2044,13 +2046,14 @@ static int jtagmkII_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
free(cmd);
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;
} else if ( ( strcmp(m->desc, "usersig") == 0 ) ) {
} else if (strcmp(m->desc, "usersig") == 0 ||
strcmp(m->desc, "userrow") == 0) {
cmd[1] = MTYPE_USERSIG;
} else if ( ( strcmp(m->desc, "boot") == 0 ) ) {
} else if (strcmp(m->desc, "boot") == 0) {
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;
} else {
cmd[1] = MTYPE_SPM;
@ -2156,16 +2159,17 @@ static int jtagmkII_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
/* dynamically decide between flash/boot memtype */
dynamic_memtype = 1;
} 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)
return -1;
} else if ( ( strcmp(m->desc, "prodsig") == 0 ) ) {
} else if (strcmp(m->desc, "prodsig") == 0) {
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;
} else if ( ( strcmp(m->desc, "boot") == 0 ) ) {
} else if (strcmp(m->desc, "boot") == 0) {
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;
} else {
cmd[1] = MTYPE_SPM;
@ -2291,7 +2295,8 @@ static int jtagmkII_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
unsupp = 1;
} else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) {
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;
} else if (strcmp(mem->desc, "prodsig") == 0) {
cmd[1] = MTYPE_PRODSIG;
@ -2460,7 +2465,8 @@ static int jtagmkII_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
unsupp = 1;
} else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) {
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;
} else if (strcmp(mem->desc, "prodsig") == 0) {
cmd[1] = MTYPE_PRODSIG;

View File

@ -223,7 +223,7 @@ static int linuxspi_open(PROGRAMMER *pgm, char *port)
avrdude_message(MSG_INFO,
"%s: obsolete use of -b <clock> option for bit clock; use -B <clock>\n",
progname);
pgm->bitclock = 1E6 / pgm->baudrate;
pgm->bitclock = 1.0 / pgm->baudrate;
}
if (pgm->bitclock == 0) {
avrdude_message(MSG_NOTICE,

View File

@ -129,7 +129,7 @@ static void usage(void)
" -q Quell progress output. -q -q for less.\n"
" -l logfile Use logfile rather than stderr for diagnostics.\n"
" -? Display this usage.\n"
"\navrdude version %s, URL: <https://github.com/avrdudes/avrdude>\n"
"\navrdude version %s, URL: <https://github.com/mariusgreuel/avrdude>\n"
,progname, version);
}
@ -571,6 +571,11 @@ int main(int argc, char * argv [])
terminal = 1;
break;
case 'u':
avrdude_message(MSG_INFO, "%s: \"safemode\" feature no longer supported\n",
progname);
break;
case 'U':
upd = parse_op(optarg);
if (upd == NULL) {

View File

@ -0,0 +1,82 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2019 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/>.
*/
extern "C"
{
#include "avrdude.h"
}
#include "usb_com_helper.h"
#include "usb_com_locator.h"
class AvrdudeConsole : public UsbComLocator::IConsole
{
public:
void WriteLine(UsbComLocator::MessageLevel level, const std::string& message) override
{
switch (level)
{
case UsbComLocator::MessageLevel::Verbose:
avrdude_message(MSG_NOTICE, "%s: %s\n", progname, message.c_str());
break;
case UsbComLocator::MessageLevel::Debug:
avrdude_message(MSG_DEBUG, "%s: %s\n", progname, message.c_str());
break;
default:
avrdude_message(MSG_INFO, "%s: %s\n", progname, message.c_str());
break;
}
}
};
int win32_find_usb_com_port(const char* deviceId, char** port, bool wait_for_device, bool find_related_devices, bool auto_reset)
{
try
{
UsbComLocator::Locator::Options options;
options.WaitForDevice = wait_for_device;
options.FindRelatedDevices = find_related_devices;
options.AutoReset = auto_reset;
AvrdudeConsole console;
UsbComLocator::Locator locator(&console);
std::string filename = locator.FindPortForDevice(deviceId, &options);
if (filename.empty())
{
*port = nullptr;
return -1;
}
filename = "\\\\.\\" + filename;
size_t bufferSize = filename.size() + 1;
*port = static_cast<char*>(malloc(bufferSize));
if (*port == nullptr)
{
return -1;
}
strncpy(*port, filename.c_str(), bufferSize);
return 0;
}
catch (const std::exception&)
{
*port = nullptr;
return -1;
}
}

35
src/msvc/usb_com_helper.h Normal file
View File

@ -0,0 +1,35 @@
/*
* avrdude - A Downloader/Uploader for AVR device programmers
* Copyright (C) 2019 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/>.
*/
#ifndef USB_COM_HELPER_H
#define USB_COM_HELPER_H
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
int win32_find_usb_com_port(const char* deviceId, char** port, bool wait_for_device, bool find_related_devices, bool auto_reset);
#ifdef __cplusplus
}
#endif
#endif // USB_COM_HELPER_H

1074
src/msvc/usb_com_locator.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -28,6 +28,7 @@
#include "ac_cfg.h"
#include <ctype.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -42,6 +43,10 @@
#include <termios.h>
#include <unistd.h>
#ifdef __APPLE__
# include <IOKit/serial/ioss.h>
#endif
#include "avrdude.h"
#include "libavrdude.h"
@ -78,10 +83,12 @@ static struct baud_mapping baud_lookup_table [] = {
static struct termios 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;
*nonstandard = false;
while (map->baud) {
if (map->baud == baud)
return map->speed;
@ -92,30 +99,20 @@ static speed_t serial_baud_lookup(long baud)
* If a non-standard BAUD rate is used, issue
* 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);
return baud;
}
*nonstandard = true;
static tcflag_t translate_flags(unsigned long cflags)
{
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) ;
return baud;
}
static int ser_setparams(union filedescriptor *fd, long baud, unsigned long cflags)
{
int rc;
struct termios termios;
speed_t speed = serial_baud_lookup (baud);
bool nonstandard;
speed_t speed = serial_baud_lookup (baud, &nonstandard);
if (!isatty(fd->ifd))
return -ENOTTY;
@ -137,15 +134,86 @@ static int ser_setparams(union filedescriptor *fd, long baud, unsigned long cfla
original_termios = termios;
}
termios.c_iflag = IGNBRK;
termios.c_oflag = 0;
termios.c_lflag = 0;
termios.c_cflag = translate_flags(cflags);
termios.c_cc[VMIN] = 1;
termios.c_cc[VTIME] = 0;
if (cflags & SERIAL_CREAD) {
termios.c_cflag |= CREAD;
}
if (cflags & SERIAL_CLOCAL) {
termios.c_cflag |= CLOCAL;
}
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);
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 */
cfsetospeed(&termios, speed);
cfsetispeed(&termios, speed);
rc = tcsetattr(fd->ifd, TCSANOW, &termios);
if (rc < 0) {
@ -154,14 +222,19 @@ static int ser_setparams(union filedescriptor *fd, long baud, unsigned long cfla
return -errno;
}
/*
* Everything is now set up for a local line without modem control
* or flow control, so clear O_NONBLOCK again.
*/
rc = fcntl(fd->ifd, F_GETFL, 0);
if (rc != -1)
fcntl(fd->ifd, F_SETFL, rc & ~O_NONBLOCK);
#ifdef __APPLE__
// handle nonstandard speed values the MacOS way
if (nonstandard) {
if (ioctl(fd->ifd, IOSSIOSPEED, &speed) < 0) {
avrdude_message(MSG_INFO, "%s: ser_setparams(): ioctrl(IOSSIOSPEED) failed\n",
progname);
return -errno;
}
}
#endif // __APPLE__
tcflush(fd->ifd, TCIFLUSH);
return 0;
}
@ -520,3 +593,4 @@ struct serial_device serial_serdev =
struct serial_device *serdev = &serial_serdev;
#endif /* WIN32 */

View File

@ -36,6 +36,10 @@
#include "avrdude.h"
#include "libavrdude.h"
#ifdef _MSC_VER
#include "msvc/usb_com_helper.h"
#endif
long serial_recv_timeout = 5000; /* ms */
#define W32SERBUFSIZE 1024
@ -257,6 +261,13 @@ static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp)
return net_open(port + strlen("net:"), fdp);
}
#ifdef _MSC_VER
if (win32_find_usb_com_port(port, &newname, true, true, true) >= 0)
{
port = newname;
}
#endif
if (strncasecmp(port, "com", strlen("com")) == 0) {
// prepend "\\\\.\\" to name, required for port # >= 10

View File

@ -3869,7 +3869,8 @@ static int stk600_xprog_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
* fuses.
*/
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;
} else {
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 ||
strcmp(mem->desc, "prodsig") == 0) {
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;
} else {
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 ||
strcmp(mem->desc, "prodsig") == 0) {
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;
} else {
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) {
memtype = XPRG_MEM_TYPE_FACTORY_CALIBRATION;
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;
writemode = (1 << XPRG_MEM_WRITE_WRITE);
} else {
@ -4290,7 +4294,8 @@ static int stk600_xprog_page_erase(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
b[1] = XPRG_ERASE_BOOT_PAGE;
} else if (strcmp(m->desc, "eeprom") == 0) {
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;
} else {
avrdude_message(MSG_INFO, "%s: stk600_xprog_page_erase(): unknown paged memory \"%s\"\n",

View File

@ -23,6 +23,7 @@
#include <ctype.h>
#include <string.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
@ -125,9 +126,15 @@ static int nexttok(char * buf, char ** tok, char ** next)
q++;
/* isolate first token */
n = q+1;
while (*n && !isspace((int)*n))
n = q;
uint8_t quotes = 0;
while (*n && (!isspace((int)*n) || quotes)) {
if (*n == '\"')
quotes++;
else if (isspace((int)*n) && *(n-1) == '\"')
break;
n++;
}
if (*n) {
*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)
{
char * hexdata = "0123456789abcdef";
char * b;
int i, j;
char * b = buffer;
int32_t i = 0;
int32_t j = 0;
b = buffer;
j = 0;
for (i=0; i<n; i++) {
if (i && ((i % 8) == 0))
b[j++] = ' ';
@ -182,7 +187,7 @@ static int chardump_line(char * buffer, unsigned char * p, int n, int pad)
int i;
char b [ 128 ];
for (i=0; i<n; i++) {
for (int32_t i = 0; i < n; i++) {
memcpy(b, p, n);
buffer[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] = ' ';
}
for (i=n; i<pad; i++)
for (i = n; i < pad; i++)
buffer[i] = ' ';
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)
{
int addr;
int n;
unsigned char * p;
char dst1[80];
char dst2[80];
addr = startaddr;
p = (unsigned char *)buf;
int32_t addr = startaddr;
unsigned char * p = (unsigned char *)buf;
while (len) {
n = 16;
int32_t n = 16;
if (n > len)
n = len;
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,
int argc, char * argv[])
{
static char prevmem[128] = {0};
char * e;
unsigned char * buf;
int maxsize;
unsigned long i;
static unsigned long addr=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;
if (argc < 2) {
avrdude_message(MSG_INFO, "Usage: %s <memtype> [<start addr> <len>]\n"
" %s <memtype> [<start addr> <...>]\n"
" %s <memtype> <...>\n"
" %s <memtype>\n",
argv[0], argv[0], argv[0], argv[0]);
return -1;
}
memtype = argv[1];
if (strncmp(prevmem, memtype, strlen(memtype)) != 0) {
addr = 0;
len = 64;
strncpy(prevmem, memtype, sizeof(prevmem)-1);
prevmem[sizeof(prevmem)-1] = 0;
}
mem = avr_locate_mem(p, memtype);
enum { read_size = 256 };
static char prevmem[128] = {0x00};
char * memtype = argv[1];
AVRMEM * mem = avr_locate_mem(p, memtype);
if (mem == NULL) {
avrdude_message(MSG_INFO, "\"%s\" memory type not defined for part \"%s\"\n",
memtype, p->desc);
return -1;
}
uint32_t maxsize = mem->size;
// Get start address if present
char * end_ptr;
static uint32_t addr = 0;
if (argc == 4) {
addr = strtoul(argv[2], &e, 0);
if (*e || (e == argv[2])) {
avrdude_message(MSG_INFO, "%s (dump): can't parse address \"%s\"\n",
progname, argv[2]);
addr = strtoul(argv[2], &end_ptr, 0);
if (*end_ptr || (end_ptr == argv[2])) {
avrdude_message(MSG_INFO, "%s (%s): can't parse address \"%s\"\n",
progname, argv[0], argv[2]);
return -1;
}
len = strtol(argv[3], &e, 0);
if (*e || (e == argv[3])) {
avrdude_message(MSG_INFO, "%s (dump): can't parse length \"%s\"\n",
progname, argv[3]);
} else if (addr >= maxsize) {
avrdude_message(MSG_INFO, "%s (%s): address 0x%05lx is out of range for %s memory\n",
progname, argv[0], addr, mem->desc);
return -1;
}
}
maxsize = mem->size;
if (addr >= maxsize) {
if (argc == 2) {
/* wrap around */
// Get no. bytes to read if present
static int32_t len = read_size;
if (argc >= 3) {
memset(prevmem, 0x00, sizeof(prevmem));
if (strcmp(argv[argc - 1], "...") == 0) {
if (argc == 3)
addr = 0;
len = maxsize - addr;
} else if (argc == 4) {
len = strtol(argv[3], &end_ptr, 0);
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;
}
} 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;
}
else {
avrdude_message(MSG_INFO, "%s (dump): address 0x%05lx is out of range for %s memory\n",
progname, addr, mem->desc);
return -1;
}
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)
len = maxsize - addr;
buf = malloc(len);
uint8_t * buf = malloc(len);
if (buf == NULL) {
avrdude_message(MSG_INFO, "%s (dump): out of memory\n", progname);
return -1;
}
for (i=0; i<len; i++) {
rc = pgm->read_byte(pgm, p, mem, addr+i, &buf[i]);
report_progress(0, 1, "Reading");
for (uint32_t i = 0; i < len; i++) {
int32_t rc = pgm->read_byte(pgm, p, mem, addr + i, &buf[i]);
if (rc != 0) {
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)
avrdude_message(MSG_INFO, "read operation not supported on memory type \"%s\"\n",
mem->desc);
return -1;
}
report_progress(i, len, NULL);
}
report_progress(1, 1, NULL);
hexdump_buf(stdout, addr, buf, len);
fprintf(stdout, "\n");
free(buf);
@ -328,35 +337,31 @@ static int cmd_dump(PROGRAMMER * pgm, struct avrpart * p,
static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
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) {
avrdude_message(MSG_INFO, "Usage: write <memtype> <addr> <byte1> "
"<byte2> ... <byteN>\n");
avrdude_message(MSG_INFO,
"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;
}
memtype = argv[1];
mem = avr_locate_mem(p, memtype);
int32_t i;
uint8_t write_mode; // Operation mode, "standard" or "fill"
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) {
avrdude_message(MSG_INFO, "\"%s\" memory type not defined for part \"%s\"\n",
memtype, p->desc);
return -1;
}
uint32_t maxsize = mem->size;
maxsize = mem->size;
addr = strtoul(argv[2], &e, 0);
if (*e || (e == argv[2])) {
char * end_ptr;
int32_t addr = strtoul(argv[2], &end_ptr, 0);
if (*end_ptr || (end_ptr == argv[2])) {
avrdude_message(MSG_INFO, "%s (write): can't parse address \"%s\"\n",
progname, argv[2]);
return -1;
@ -368,61 +373,228 @@ static int cmd_write(PROGRAMMER * pgm, struct avrpart * p,
return -1;
}
/* number of bytes to write at the specified address */
len = argc - 3;
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);
// Allocate a buffer guaranteed to be large enough
uint8_t * buf = calloc(mem->size + 0x10 + strlen(argv[argc - 2]), sizeof(uint8_t));
if (buf == NULL) {
avrdude_message(MSG_INFO, "%s (write): out of memory\n", progname);
return -1;
}
for (i=3; i<argc; i++) {
buf[i-3] = strtoul(argv[i], &e, 0);
if (*e || (e == argv[i])) {
avrdude_message(MSG_INFO, "%s (write): can't parse byte \"%s\"\n",
progname, argv[i]);
// Find the first argument to write to flash and how many arguments to parse and write
if (strcmp(argv[argc - 1], "...") == 0) {
write_mode = WRITE_MODE_FILL;
start_offset = 4;
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);
return -1;
}
} else {
write_mode = WRITE_MODE_STANDARD;
start_offset = 3;
len = argc - start_offset;
}
pgm->err_led(pgm, OFF);
for (werror=0, i=0; i<len; i++) {
// Structure related to data that is being written to memory
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) {
avrdude_message(MSG_INFO, "%s (write): error writing 0x%02x at 0x%05lx, rc=%d\n",
progname, buf[i], addr+i, rc);
if (rc == -1)
avrdude_message(MSG_INFO, "write operation not supported on memory type \"%s\"\n",
mem->desc);
werror = 1;
werror = true;
}
uint8_t b;
rc = pgm->read_byte(pgm, p, mem, addr+i, &b);
if (b != buf[i]) {
avrdude_message(MSG_INFO, "%s (write): error writing 0x%02x at 0x%05lx cell=0x%02x\n",
progname, buf[i], addr+i, b);
werror = 1;
werror = true;
}
if (werror) {
pgm->err_led(pgm, ON);
}
report_progress(i, (len + data.bytes_grown), NULL);
}
report_progress(1, 1, NULL);
free(buf);
fprintf(stdout, "\n");
return 0;
}

View File

@ -27,6 +27,11 @@
extern "C" {
#endif
typedef enum {
WRITE_MODE_STANDARD = 0,
WRITE_MODE_FILL = 1,
} mode;
int terminal_mode(PROGRAMMER * pgm, struct avrpart * p);
char * terminal_get_input(const char *prompt);

View File

@ -291,7 +291,7 @@ static int usbhid_recv(union filedescriptor *fd, unsigned char *buf, size_t nbyt
if (udev == NULL)
return -1;
rv = i = hid_read_timeout(udev, buf, nbytes, 300);
rv = i = hid_read_timeout(udev, buf, nbytes, 10000);
if (i != nbytes)
avrdude_message(MSG_INFO,
"%s: Short read, read only %d out of %u bytes\n",

View File

@ -100,7 +100,7 @@ static int usb_control (PROGRAMMER * pgm,
{
int nbytes;
nbytes = usb_control_msg( PDATA(pgm)->usb_handle,
USB_ENDPOINT_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
USB_ENDPOINT_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
requestid,
val, index, // 2 bytes each of data
NULL, 0, // no data buffer in control message