avrdudes / avrdude

AVRDUDE is a utility to program AVR microcontrollers
GNU General Public License v2.0
759 stars 139 forks source link

Add more usage examples to Avrdude documentation #1362

Closed MCUdude closed 1 year ago

MCUdude commented 1 year ago

Avrdude supports some nice CLI features like read/write to stdin/stdout (-U) and piping into terminal mode, but none of these features are documented in the avrdude.texi file.

We should perhaps mention that this is possible and provide a few examples under 2.3 Example Command Line Invocations

I can submit a PR for this, but are there other neat tricks we should add to the texi docs?

MCUdude commented 1 year ago

Here are the development branch I'm working on. https://github.com/MCUdude/avrdude/tree/cli-examples

I've currently added the following examples:

Write stdin to EEPROM

% echo "The quick brown fox" | avrdude -cusbasp -pattiny13 -Ueeprom:w:-:r
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9007 (probably t13)
avrdude: reading input file <stdin> for eeprom
         with 20 bytes in 1 section within [0, 0x13]
         using 5 pages and 0 pad bytes
avrdude: writing 20 bytes eeprom ...
Writing | ################################################## | 100% 0.21 s
avrdude: 20 bytes of eeprom written
avrdude: verifying eeprom memory against <stdin>
Reading | ################################################## | 100% 0.01 s
avrdude: 20 bytes of eeprom verified

avrdude done.  Thank you.

Read EEPROM and write to stdout

% avrdude -cusbasp -pattiny13 -Ueeprom:r:-:I
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9007 (probably t13)
avrdude: reading eeprom memory ...
Reading | ################################################## | 100% 0.02 s
avrdude: writing output file <stdout>
:2000000054686520717569636B2062726F776E20666F780AFFFFFFFFFFFFFFFFFFFFFFFFCF // 00000> The_quick_brown_fox.............
:20002000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0 // 00020> ................................
:00000001FF

avrdude done.  Thank you.

Pipe commands into Avrdude terminal mode

% echo "dump eeprom 0 0x40" | avrdude -cusbasp -patmega328p -t
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)
Reading | ################################################## | 100% 0.02 s
0000  48 65 6c 6c 6f 20 57 6f  72 6c 64 21 00 ff ff ff  |Hello World!....|
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0020  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

avrdude done.  Thank you.
mcuee commented 1 year ago

I think this is a good idea. Please raise the PR.

mcuee commented 1 year ago

Some other tips and tricks I collected here. Please check if anything is of interests to the PR as well. https://github.com/mcuee/avrdude/wiki

stefanrueger commented 1 year ago
stefanrueger commented 1 year ago

Pipe commands into Avrdude terminal mode

Note that (since yesterday) AVRDUDE can also use semicolon-space separated commands in one terminal line:

$ echo 'dump eeprom 0 0x40; write eeprom 0 "Bonjour le mode"' | avrdude -cusbasp -patmega328p -t

Also, perhaps show examples of use with binary 0b... and file input for terminal write

MCUdude commented 1 year ago

@mcuee and @stefanrueger thanks for the input! There are some very neat and clever commands that deserve to be in the official user manual. I'll continue adding examples, and submit a PR when I'm ready.