41 Commits

Author SHA1 Message Date
Marius Greuel
488da2642a build.sh: For compatibility with old CMake versions, use old syntax to generate build system 2023-02-04 17:54:18 +01:00
Stefan Rueger
5ec72e240b Update News 2023-01-14 14:46:17 +00:00
Stefan Rueger
347ecadae9 Merge pull request #1282 from stefanrueger/grammar
Reduce complexity of grammar
2023-01-14 14:36:20 +00:00
Stefan Rueger
7e5bfdeff0 Merge pull request #1277 from stefanrueger/silence
Silence gcc compiler warnings
2023-01-14 14:35:11 +00:00
Stefan Rueger
b89b79d332 Merge pull request #1276 from mcuee/document_fix
Fix documentation for avrftdi pin numbers to start with 0
2023-01-14 14:34:03 +00:00
Stefan Rueger
65686c7fed Merge pull request #1273 from stefanrueger/stk500_value_polling
Only send write flash cmd to STK500v2 programmers if page not empty
2023-01-14 14:29:59 +00:00
Stefan Rueger
a3b7072b7d Merge pull request #1272 from stefanrueger/mode_memdelay
Correct memory mode, delay and readback for classic parts
2023-01-14 14:29:19 +00:00
Stefan Rueger
1fa34c58a7 Print warnings for deprecated grammar use 2023-01-13 23:34:28 +00:00
Stefan Rueger
09c4b670c7 Shift simple part/memory components from grammar to config.c table 2023-01-13 23:34:18 +00:00
mcuee
9cf4f55b87 Merge pull request #1280 from mcuee/configure_ac_readline
Update configure.ac to reflect HAVE_READLINE statue
2023-01-13 13:29:31 +08:00
mcuee
b3a29917b0 Merge pull request #1279 from mcuee/configure_ac_update
Update configure.ac for MinGW build
2023-01-13 13:29:14 +08:00
mcuee
6595f53425 Update configure.ac to reflect HAVE_READLINE statue 2023-01-13 11:05:16 +08:00
Stefan Rueger
0ae6c6543b Shift simple programmer components from grammar to config.c table 2023-01-12 23:59:45 +00:00
Stefan Rueger
f9c5c0cfbc Silence sign-cpmpare warnings in pickit2.c 2023-01-12 14:09:38 +00:00
mcuee
a22d379c03 Update configure.ac for MinGW build
Fix avrdudes#957.
Even though we are only supporting CMake build now, the fix is simple enough and not affecting CMake.
2023-01-12 21:06:36 +08:00
Stefan Rueger
22f9bc5260 Enable -Wextra -Wno-unused-parameter by default for gcc 2023-01-12 00:01:46 +00:00
Stefan Rueger
6088c9b98f Silence sign-compare warning in avr910.c 2023-01-11 23:55:07 +00:00
Stefan Rueger
e349cd1f6b Silence sign-compare warning in buterfly.c 2023-01-11 23:52:59 +00:00
Stefan Rueger
7ad5289d66 Silence sign-compare warnings in dfu.c 2023-01-11 23:50:26 +00:00
Stefan Rueger
b75e26bf6d Silence sign-compare warnings in flip1.c 2023-01-11 23:48:04 +00:00
Stefan Rueger
81f01939c2 Silence missing-field-initializers warning in flip1.c 2023-01-11 23:45:07 +00:00
Stefan Rueger
2a79faae86 Silence sign-compare warnings in flip2.c 2023-01-11 23:38:43 +00:00
Stefan Rueger
3c51fb6aae Silence sign-compare warnings in ft245r.c 2023-01-11 23:34:14 +00:00
Stefan Rueger
3b7f0d2c55 Use portable %lu and cast for size_t 2023-01-11 23:25:13 +00:00
Stefan Rueger
507031badf Silence compiler warnings in jtagm.c 2023-01-11 23:18:08 +00:00
Stefan Rueger
6d15d24a4d Fix fall through error in jtagmkI.c 2023-01-11 23:12:44 +00:00
Stefan Rueger
cec9715ba2 Silence sign-compare warnings in lists.c 2023-01-11 23:09:56 +00:00
Stefan Rueger
7f0fe41b6c Silence sign-compare warnings in micronucleus.c 2023-01-11 22:56:41 +00:00
Stefan Rueger
aa258ace36 Silence sign-compare warnings in pgm_type.c and clean up 2023-01-11 19:32:16 +00:00
Stefan Rueger
e089d7ecc5 Silence sign-compare warnings in pindefs.c 2023-01-11 19:07:02 +00:00
Stefan Rueger
3521c9d9fb Silence sign-compare warnings in ser_avrdoper.c 2023-01-11 19:01:00 +00:00
Stefan Rueger
c6b2f12c04 Silence sign-compare warnings in serialupdi.c 2023-01-11 18:48:14 +00:00
Stefan Rueger
3611c89ee0 Silence sign-compare warnings in usbasp.c 2023-01-11 18:32:51 +00:00
Stefan Rueger
246d2d502d Silence sign-compare warning in usb_hidapi.c 2023-01-11 18:25:00 +00:00
Stefan Rueger
79dd434d20 Silence sign-compare warnings in usbtiny.c 2023-01-11 17:42:05 +00:00
Stefan Rueger
319ee2db9c Silence fall through warning in update.c 2023-01-11 17:34:51 +00:00
mcuee
368bad5ca0 Document fix for avrftdi bit number should start with 0
This resolves https://github.com/avrdudes/avrdude/issues/369
2023-01-11 14:50:24 +08:00
Marius Greuel
6b95f9d181 Update README.md to point to GitHub Releases 2023-01-09 20:00:07 +01:00
Stefan Rueger
8150930958 Only send write flash cmd to STK500v2 programmers if page not empty
... except if it's for a bootloader: they might need to know about
0xff pages if they use an SPM page erase command and therefore
memory does not look like NOR-memory.

This is a slight optimisation for all parts (as writing 0xff pages
on NOR-memory flash is a NOP), but more importantly, prevents a
firmware error to surface for those parts that need to carry out
value polling to determine when writing the page has finished on
the device.
2023-01-09 14:14:40 +00:00
Stefan Rueger
beeb14ee3d Correct memory mode, delay and readback parameters
Injected automatically from the corresponding ATDF files
2023-01-08 17:03:23 +00:00
Stefan Rueger
dcb8165a1c Show memory mode as hex number in avrdude.conf
It is a bitfield instructing STK500 how to program the memory
2023-01-08 16:57:09 +00:00
41 changed files with 539 additions and 2417 deletions

View File

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

12
NEWS
View File

@@ -9,14 +9,24 @@ Changes since version 7.1:
* Major changes compared to the previous version:
* New devices supported: none
* New devices supported:
* New programmers supported:
* Issues fixed:
- STK500V2 ISP problem with ATmega8/8515/8535, ATmega16 and
ATmega32 #425
* Pull requests:
- Correct memory mode, delay and readback (classic parts) #1272
- Only send write flash cmd to STK500v2 ISP programmers if page
is not empty #1273
- Fix docu that avrftdi bit numbers start with 0 #1276
- Silence gcc compiler warnings #1277
- Reduce complexity of grammar #1282
* Internals:

View File

@@ -1,64 +0,0 @@
# 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/).

226
README.md
View File

@@ -1,224 +1,64 @@
# AVRDUDE for Windows
# AVRDUDE
[![Build Status](https://github.com/mariusgreuel/avrdude/actions/workflows/build.yml/badge.svg?branch=windows)](https://github.com/mariusgreuel/avrdude/actions/workflows/build.yml)
[![Build Status](https://github.com/avrdudes/avrdude/actions/workflows/build.yml/badge.svg)](https://github.com/avrdudes/avrdude/actions/workflows/build.yml)
This is a fork of AVRDUDE 7.0 from <https://github.com/avrdudes/avrdude>.
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.
The purpose of this fork is to add better support for Windows to bring it on par with the Linux version of 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).
Noteable changes include:
- [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)
The original AVRDUDE project homepage can be found here <https://github.com/avrdudes/avrdude>.
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/).
## Download
## Getting AVRDUDE for Windows
To get the latest version of **AVRDUDE for Windows**, go to the [releases folder](https://github.com/mariusgreuel/avrdude/releases):
To get AVRDUDE for Windows, install the latest version from the [Releases](https://github.com/avrdudes/avrdude/releases) page.
<https://github.com/mariusgreuel/avrdude/releases>
Alternatively, you may [build AVRDUDE](https://github.com/avrdudes/avrdude/wiki) yourself from source.
## Feature Details
## Getting AVRDUDE for Linux
### 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
To install AVRDUDE for Linux, install the package `avrdude` by running the following commands:
```console
avrdude -c micronucleus -p t85 -x wait -V -U flash:w:main.hex:i
sudo apt-get install avrdude
```
### Support Teensy HalfKay bootloader
Alternatively, you may [build AVRDUDE](https://github.com/avrdudes/avrdude/wiki) yourself from source.
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.
## Getting AVRDUDE for MacOS
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'.
On MacOS, AVRDUDE can be installed through Mac Ports.
Supported devices are:
Alternatively, you may [build AVRDUDE](https://github.com/avrdudes/avrdude/wiki) yourself from source.
- Teensy 1.0 (AT90USB162)
- Teensy 2.0 (ATmega32U4)
- Teensy++ 1.0 (AT90USB646)
- Teensy++ 2.0 (AT90USB1286)
## Using AVRDUDE
#### Example: Flashing a Teensy 2.0 device
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 teensy -p m32u4 -x wait -V -U flash:w:main.hex:i
avrdude -c <programmer> -p <part> -U flash:w:<file>:i
```
### 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:
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 avr109 -P usb:2341:0036 -p m32u4
avrdude -c arduino -P COM1 -b 115200 -p atmega328p -D -U flash:w:objs/blink.hex:i
```
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.
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/).

View File

@@ -74,9 +74,11 @@ case "${ostype}" in
;;
esac
cmake ${build_flags} ${extra_enable} -D CMAKE_BUILD_TYPE=${build_type} -B build_${ostype} ||\
mkdir -p build_${ostype}
cd build_${ostype}
cmake ${build_flags} ${extra_enable} -D CMAKE_BUILD_TYPE=${build_type} .. ||\
{ echo "CMake failed."; exit 1; }
cmake --build build_${ostype} ||\
cmake --build . ||\
{ echo "Build failed."; exit 1; }
cat <<EOF

View File

@@ -71,14 +71,13 @@ if(MSVC)
"msvc/gettimeofday.c"
"msvc/usleep.cpp"
"msvc/readline.cpp"
"msvc/usb_com_helper.cpp"
)
set(EXTRA_WINDOWS_INCLUDES ${EXTRA_WINDOWS_INCLUDES}
"msvc"
)
else()
set(LIB_MATH m)
add_compile_options(-Wall) # -Wextra
add_compile_options(-Wall -Wextra -Wno-unused-parameter)
endif()
# =====================================

View File

@@ -653,9 +653,9 @@ static int avr910_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVRM
avr910_set_addr(pgm, addr / rd_size);
while (addr < max_addr) {
if ((max_addr - addr) < blocksize) {
if (max_addr - addr < (unsigned int) blocksize)
blocksize = max_addr - addr;
}
cmd[1] = (blocksize >> 8) & 0xff;
cmd[2] = blocksize & 0xff;

File diff suppressed because it is too large Load Diff

View File

@@ -662,7 +662,7 @@ static int butterfly_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const A
butterfly_set_addr(pgm, addr / rd_size);
}
while (addr < max_addr) {
if ((max_addr - addr) < blocksize) {
if ((max_addr - addr) < (unsigned int) blocksize) {
blocksize = max_addr - addr;
};
cmd[1] = (blocksize >> 8) & 0xff;

View File

@@ -63,24 +63,88 @@ extern char * yytext;
// Component description for config_gram.y, will be sorted appropriately on first use
Component_t avr_comp[] = {
// PROGRAMMER
pgm_comp_desc(desc, COMP_STRING),
pgm_comp_desc(prog_modes, COMP_INT),
pgm_comp_desc(baudrate, COMP_INT),
pgm_comp_desc(usbvid, COMP_INT),
pgm_comp_desc(usbdev, COMP_STRING),
pgm_comp_desc(usbsn, COMP_STRING),
pgm_comp_desc(usbvendor, COMP_STRING),
pgm_comp_desc(usbproduct, COMP_STRING),
// AVRPART
part_comp_desc(desc, COMP_STRING),
part_comp_desc(family_id, COMP_STRING),
part_comp_desc(prog_modes, COMP_INT),
part_comp_desc(mcuid, COMP_INT),
part_comp_desc(n_interrupts, COMP_INT),
part_comp_desc(n_page_erase, COMP_INT),
part_comp_desc(n_boot_sections, COMP_INT),
part_comp_desc(boot_section_size, COMP_INT),
part_comp_desc(autobaud_sync, COMP_CHAR),
part_comp_desc(hvupdi_variant, COMP_INT),
part_comp_desc(stk500_devcode, COMP_INT),
part_comp_desc(avr910_devcode, COMP_INT),
part_comp_desc(chip_erase_delay, COMP_INT),
part_comp_desc(pagel, COMP_CHAR),
part_comp_desc(bs2, COMP_CHAR),
part_comp_desc(timeout, COMP_INT),
part_comp_desc(stabdelay, COMP_INT),
part_comp_desc(cmdexedelay, COMP_INT),
part_comp_desc(synchloops, COMP_INT),
part_comp_desc(bytedelay, COMP_INT),
part_comp_desc(pollindex, COMP_INT),
part_comp_desc(pollvalue, COMP_CHAR),
part_comp_desc(predelay, COMP_INT),
part_comp_desc(postdelay, COMP_INT),
part_comp_desc(pollmethod, COMP_INT),
part_comp_desc(hventerstabdelay, COMP_INT), // STK500 v2 hv mode parameters
part_comp_desc(progmodedelay, COMP_INT),
part_comp_desc(latchcycles, COMP_INT),
part_comp_desc(togglevtg, COMP_INT),
part_comp_desc(poweroffdelay, COMP_INT),
part_comp_desc(resetdelayms, COMP_INT),
part_comp_desc(resetdelayus, COMP_INT),
part_comp_desc(hvleavestabdelay, COMP_INT),
part_comp_desc(resetdelay, COMP_INT),
part_comp_desc(chiperasepulsewidth, COMP_INT),
part_comp_desc(chiperasepolltimeout, COMP_INT),
part_comp_desc(chiperasetime, COMP_INT),
part_comp_desc(programfusepulsewidth, COMP_INT),
part_comp_desc(programfusepolltimeout, COMP_INT),
part_comp_desc(programlockpulsewidth, COMP_INT),
part_comp_desc(programlockpolltimeout, COMP_INT),
part_comp_desc(synchcycles, COMP_INT),
part_comp_desc(hvspcmdexedelay, COMP_INT),
part_comp_desc(idr, COMP_CHAR),
part_comp_desc(rampz, COMP_CHAR),
part_comp_desc(spmcr, COMP_CHAR),
part_comp_desc(eecr, COMP_CHAR),
part_comp_desc(eind, COMP_CHAR),
part_comp_desc(mcu_base, COMP_INT),
part_comp_desc(nvm_base, COMP_INT),
part_comp_desc(ocd_base, COMP_INT),
part_comp_desc(ocdrev, COMP_INT),
part_comp_desc(autobaud_sync, COMP_CHAR),
// AVRMEM
mem_comp_desc(paged, COMP_BOOL),
mem_comp_desc(size, COMP_INT),
mem_comp_desc(num_pages, COMP_INT),
mem_comp_desc(n_word_writes, COMP_INT),
mem_comp_desc(offset, COMP_INT),
mem_comp_desc(min_write_delay, COMP_INT),
mem_comp_desc(max_write_delay, COMP_INT),
mem_comp_desc(pwroff_after_write, COMP_INT),
{"readback_p1", COMP_AVRMEM, offsetof(AVRMEM, readback)+0, 1, COMP_CHAR },
{"readback_p2", COMP_AVRMEM, offsetof(AVRMEM, readback)+1, 1, COMP_CHAR },
mem_comp_desc(mode, COMP_INT),
mem_comp_desc(delay, COMP_INT),
mem_comp_desc(pollindex, COMP_INT),
mem_comp_desc(blocksize, COMP_INT),
mem_comp_desc(readsize, COMP_INT),
};
#define DEBUG 0
@@ -282,6 +346,9 @@ TOKEN *new_constant(const char *con) {
!strcmp("PM_XMEGAJTAG", con)? PM_XMEGAJTAG:
!strcmp("PM_AVR32JTAG", con)? PM_AVR32JTAG:
!strcmp("PM_aWire", con)? PM_aWire:
!strcmp("pseudo", con)? 2:
!strcmp("yes", con) || !strcmp("true", con)? 1:
!strcmp("no", con) || !strcmp("false", con)? 0:
(assigned = 0);
if(!assigned) {
@@ -802,6 +869,7 @@ const char *cfg_comp_type(int type) {
case COMP_INT: return "number";
case COMP_SHORT: return "short";
case COMP_CHAR: return "char";
case COMP_BOOL: return "bool";
case COMP_STRING: return "string";
case COMP_CHAR_ARRAY: return "byte array";
case COMP_INT_LISTID: return "number list";
@@ -820,6 +888,7 @@ void cfg_assign(char *sp, int strct, Component_t *cp, VALUE *v) {
int num;
switch(cp->type) {
case COMP_BOOL:
case COMP_CHAR:
case COMP_SHORT:
case COMP_INT:

View File

@@ -48,6 +48,7 @@ enum { // Component types in structure
COMP_INT,
COMP_SHORT,
COMP_CHAR,
COMP_BOOL,
COMP_STRING,
COMP_CHAR_ARRAY, // This and below are not yet implemented
COMP_INT_LISTID,

View File

@@ -71,13 +71,9 @@ static int pin_name;
%token K_MEMORY
%token K_PAGE_SIZE
%token K_PAGED
%token K_ALIAS
%token K_BAUDRATE
%token K_BS2
%token K_BUFF
%token K_CHIP_ERASE_DELAY
%token K_CONNTYPE
%token K_DEDICATED
%token K_DEFAULT_BITCLOCK
@@ -85,41 +81,23 @@ static int pin_name;
%token K_DEFAULT_PROGRAMMER
%token K_DEFAULT_SERIAL
%token K_DEFAULT_SPI
%token K_DESC
%token K_FAMILY_ID
%token K_HVUPDI_SUPPORT
%token K_HVUPDI_VARIANT
%token K_DEVICECODE
%token K_STK500_DEVCODE
%token K_AVR910_DEVCODE
%token K_EEPROM
%token K_ERRLED
%token K_FLASH
%token K_ID
%token K_IO
%token K_LOADPAGE
%token K_MAX_WRITE_DELAY
%token K_MCU_BASE
%token K_MIN_WRITE_DELAY
%token K_SDI
%token K_SDO
%token K_NUM_PAGES
%token K_NVM_BASE
%token K_OCD_BASE
%token K_OCDREV
%token K_OFFSET
%token K_PAGEL
%token K_PARALLEL
%token K_PARENT
%token K_PART
%token K_PGMLED
%token K_PROGRAMMER
%token K_PSEUDO
%token K_PWROFF_AFTER_WRITE
%token K_RDYLED
%token K_READBACK
%token K_READBACK_P1
%token K_READBACK_P2
%token K_READMEM
%token K_RESET
%token K_RETRY_PULSE
@@ -129,56 +107,13 @@ static int pin_name;
%token K_SIGNATURE
%token K_SIZE
%token K_USB
%token K_USBDEV
%token K_USBSN
%token K_USBPID
%token K_USBPRODUCT
%token K_USBVENDOR
%token K_USBVID
%token K_TYPE
%token K_VCC
%token K_VFYLED
%token K_NO
%token K_YES
/* stk500 v2 xml file parameters */
/* ISP */
%token K_TIMEOUT
%token K_STABDELAY
%token K_CMDEXEDELAY
%token K_HVSPCMDEXEDELAY
%token K_SYNCHLOOPS
%token K_BYTEDELAY
%token K_POLLVALUE
%token K_POLLINDEX
%token K_PREDELAY
%token K_POSTDELAY
%token K_POLLMETHOD
%token K_MODE
%token K_DELAY
%token K_BLOCKSIZE
%token K_READSIZE
/* HV mode */
%token K_HVENTERSTABDELAY
%token K_PROGMODEDELAY
%token K_LATCHCYCLES
%token K_TOGGLEVTG
%token K_POWEROFFDELAY
%token K_RESETDELAYMS
%token K_RESETDELAYUS
%token K_HVLEAVESTABDELAY
%token K_RESETDELAY
%token K_SYNCHCYCLES
%token K_HVCMDEXEDELAY
%token K_CHIPERASEPULSEWIDTH
%token K_CHIPERASEPOLLTIMEOUT
%token K_CHIPERASETIME
%token K_PROGRAMFUSEPULSEWIDTH
%token K_PROGRAMFUSEPOLLTIMEOUT
%token K_PROGRAMLOCKPULSEWIDTH
%token K_PROGRAMLOCKPOLLTIMEOUT
%token K_PP_CONTROLSTACK
%token K_HVSP_CONTROLSTACK
@@ -481,20 +416,10 @@ prog_parm :
|
prog_parm_pins
|
prog_parm_usb
K_USBPID TKN_EQUAL usb_pid_list
|
prog_parm_conntype
|
K_DESC TKN_EQUAL TKN_STRING {
current_prog->desc = cache_string($3->value.string);
free_token($3);
} |
K_BAUDRATE TKN_EQUAL numexpr {
{
current_prog->baudrate = $3->value.number;
free_token($3);
}
} |
prog_parm_updi
;
@@ -531,40 +456,6 @@ prog_parm_conntype_id:
K_SPI { current_prog->conntype = CONNTYPE_SPI; }
;
prog_parm_usb:
K_USBDEV TKN_EQUAL TKN_STRING {
{
current_prog->usbdev = cache_string($3->value.string);
free_token($3);
}
} |
K_USBVID TKN_EQUAL numexpr {
{
current_prog->usbvid = $3->value.number;
free_token($3);
}
} |
K_USBPID TKN_EQUAL usb_pid_list |
K_USBSN TKN_EQUAL TKN_STRING {
{
current_prog->usbsn = cache_string($3->value.string);
free_token($3);
}
} |
K_USBVENDOR TKN_EQUAL TKN_STRING {
{
current_prog->usbvendor = cache_string($3->value.string);
free_token($3);
}
} |
K_USBPRODUCT TKN_EQUAL TKN_STRING {
{
current_prog->usbproduct = cache_string($3->value.string);
free_token($3);
}
}
;
usb_pid_list:
numexpr {
{
@@ -689,10 +580,6 @@ reset_disposition :
K_DEDICATED | K_IO
;
parallel_modes :
yesno | K_PSEUDO
;
retry_lines :
K_RESET | K_SCK
;
@@ -708,46 +595,13 @@ part_parm :
free_token($3);
} |
K_DESC TKN_EQUAL TKN_STRING
{
current_part->desc = cache_string($3->value.string);
free_token($3);
} |
K_FAMILY_ID TKN_EQUAL TKN_STRING
{
current_part->family_id = cache_string($3->value.string);
free_token($3);
} |
K_HVUPDI_VARIANT TKN_EQUAL numexpr
{
current_part->hvupdi_variant = $3->value.number;
free_token($3);
} |
K_DEVICECODE TKN_EQUAL numexpr {
{
yyerror("devicecode is deprecated, use "
"stk500_devcode instead");
yyerror("devicecode is deprecated, will be removed in v8.0, use stk500_devcode instead");
YYABORT;
}
} |
K_STK500_DEVCODE TKN_EQUAL numexpr {
{
current_part->stk500_devcode = $3->value.number;
free_token($3);
}
} |
K_AVR910_DEVCODE TKN_EQUAL numexpr {
{
current_part->avr910_devcode = $3->value.number;
free_token($3);
}
} |
K_SIGNATURE TKN_EQUAL TKN_NUMBER TKN_NUMBER TKN_NUMBER {
{
current_part->signature[0] = $3->value.number;
@@ -914,24 +768,6 @@ part_parm :
}
} |
K_CHIP_ERASE_DELAY TKN_EQUAL numexpr
{
current_part->chip_erase_delay = $3->value.number;
free_token($3);
} |
K_PAGEL TKN_EQUAL numexpr
{
current_part->pagel = $3->value.number;
free_token($3);
} |
K_BS2 TKN_EQUAL numexpr
{
current_part->bs2 = $3->value.number;
free_token($3);
} |
K_RESET TKN_EQUAL reset_disposition
{
if ($3->primary == K_DEDICATED)
@@ -942,306 +778,145 @@ part_parm :
free_tokens(2, $1, $3);
} |
K_TIMEOUT TKN_EQUAL numexpr
K_HAS_JTAG TKN_EQUAL numexpr
{
current_part->timeout = $3->value.number;
free_token($3);
} |
K_STABDELAY TKN_EQUAL numexpr
{
current_part->stabdelay = $3->value.number;
free_token($3);
} |
K_CMDEXEDELAY TKN_EQUAL numexpr
{
current_part->cmdexedelay = $3->value.number;
free_token($3);
} |
K_HVSPCMDEXEDELAY TKN_EQUAL numexpr
{
current_part->hvspcmdexedelay = $3->value.number;
free_token($3);
} |
K_SYNCHLOOPS TKN_EQUAL numexpr
{
current_part->synchloops = $3->value.number;
free_token($3);
} |
K_BYTEDELAY TKN_EQUAL numexpr
{
current_part->bytedelay = $3->value.number;
free_token($3);
} |
K_POLLVALUE TKN_EQUAL numexpr
{
current_part->pollvalue = $3->value.number;
free_token($3);
} |
K_POLLINDEX TKN_EQUAL numexpr
{
current_part->pollindex = $3->value.number;
free_token($3);
} |
K_PREDELAY TKN_EQUAL numexpr
{
current_part->predelay = $3->value.number;
free_token($3);
} |
K_POSTDELAY TKN_EQUAL numexpr
{
current_part->postdelay = $3->value.number;
free_token($3);
} |
K_POLLMETHOD TKN_EQUAL numexpr
{
current_part->pollmethod = $3->value.number;
free_token($3);
} |
K_HVENTERSTABDELAY TKN_EQUAL numexpr
{
current_part->hventerstabdelay = $3->value.number;
free_token($3);
} |
K_PROGMODEDELAY TKN_EQUAL numexpr
{
current_part->progmodedelay = $3->value.number;
free_token($3);
} |
K_LATCHCYCLES TKN_EQUAL numexpr
{
current_part->latchcycles = $3->value.number;
free_token($3);
} |
K_TOGGLEVTG TKN_EQUAL numexpr
{
current_part->togglevtg = $3->value.number;
free_token($3);
} |
K_POWEROFFDELAY TKN_EQUAL numexpr
{
current_part->poweroffdelay = $3->value.number;
free_token($3);
} |
K_RESETDELAYMS TKN_EQUAL numexpr
{
current_part->resetdelayms = $3->value.number;
free_token($3);
} |
K_RESETDELAYUS TKN_EQUAL numexpr
{
current_part->resetdelayus = $3->value.number;
free_token($3);
} |
K_HVLEAVESTABDELAY TKN_EQUAL numexpr
{
current_part->hvleavestabdelay = $3->value.number;
free_token($3);
} |
K_RESETDELAY TKN_EQUAL numexpr
{
current_part->resetdelay = $3->value.number;
free_token($3);
} |
K_CHIPERASEPULSEWIDTH TKN_EQUAL numexpr
{
current_part->chiperasepulsewidth = $3->value.number;
free_token($3);
} |
K_CHIPERASEPOLLTIMEOUT TKN_EQUAL numexpr
{
current_part->chiperasepolltimeout = $3->value.number;
free_token($3);
} |
K_CHIPERASETIME TKN_EQUAL numexpr
{
current_part->chiperasetime = $3->value.number;
free_token($3);
} |
K_PROGRAMFUSEPULSEWIDTH TKN_EQUAL numexpr
{
current_part->programfusepulsewidth = $3->value.number;
free_token($3);
} |
K_PROGRAMFUSEPOLLTIMEOUT TKN_EQUAL numexpr
{
current_part->programfusepolltimeout = $3->value.number;
free_token($3);
} |
K_PROGRAMLOCKPULSEWIDTH TKN_EQUAL numexpr
{
current_part->programlockpulsewidth = $3->value.number;
free_token($3);
} |
K_PROGRAMLOCKPOLLTIMEOUT TKN_EQUAL numexpr
{
current_part->programlockpolltimeout = $3->value.number;
free_token($3);
} |
K_SYNCHCYCLES TKN_EQUAL numexpr
{
current_part->synchcycles = $3->value.number;
free_token($3);
} |
K_HAS_JTAG TKN_EQUAL yesno
{
if ($3->primary == K_YES)
yywarning("has_jtag is deprecated, will be removed in v8.0, use prog_modes");
if ($3->value.number == 1)
current_part->prog_modes |= PM_JTAG;
else if ($3->primary == K_NO)
else if ($3->value.number == 0)
current_part->prog_modes &= ~(PM_JTAG | PM_JTAGmkI | PM_XMEGAJTAG | PM_AVR32JTAG);
free_token($3);
} |
K_HAS_DW TKN_EQUAL yesno
K_HAS_DW TKN_EQUAL numexpr
{
if ($3->primary == K_YES)
yywarning("has_debugwire is deprecated, will be removed in v8.0, use prog_modes");
if ($3->value.number == 1)
current_part->prog_modes |= PM_debugWIRE;
else if ($3->primary == K_NO)
else if ($3->value.number == 0)
current_part->prog_modes &= ~PM_debugWIRE;
free_token($3);
} |
K_HAS_PDI TKN_EQUAL yesno
K_HAS_PDI TKN_EQUAL numexpr
{
if ($3->primary == K_YES)
yywarning("has_pdi is deprecated, will be removed in v8.0, use prog_modes");
if ($3->value.number == 1)
current_part->prog_modes |= PM_PDI;
else if ($3->primary == K_NO)
else if ($3->value.number == 0)
current_part->prog_modes &= ~PM_PDI;
free_token($3);
} |
K_HAS_UPDI TKN_EQUAL yesno
K_HAS_UPDI TKN_EQUAL numexpr
{
if ($3->primary == K_YES)
yywarning("has_updi is deprecated, will be removed in v8.0, use prog_modes");
if ($3->value.number == 1)
current_part->prog_modes |= PM_UPDI;
else if ($3->primary == K_NO)
else if ($3->value.number == 0)
current_part->prog_modes &= ~PM_UPDI;
free_token($3);
} |
K_HAS_TPI TKN_EQUAL yesno
K_HAS_TPI TKN_EQUAL numexpr
{
if ($3->primary == K_YES)
yywarning("has_tpi is deprecated, will be removed in v8.0, use prog_modes");
if ($3->value.number == 1)
current_part->prog_modes |= PM_TPI;
else if ($3->primary == K_NO)
else if ($3->value.number == 0)
current_part->prog_modes &= ~PM_TPI;
free_token($3);
} |
K_IS_AT90S1200 TKN_EQUAL yesno
K_IS_AT90S1200 TKN_EQUAL numexpr
{
if ($3->primary == K_YES)
if ($3->value.number == 1)
current_part->flags |= AVRPART_IS_AT90S1200;
else if ($3->primary == K_NO)
else if ($3->value.number == 0)
current_part->flags &= ~AVRPART_IS_AT90S1200;
else {
yyerror("is_at90s1200 not a Boolean value");
free_token($3);
YYABORT;
}
free_token($3);
} |
K_IS_AVR32 TKN_EQUAL yesno
K_IS_AVR32 TKN_EQUAL numexpr
{
if ($3->primary == K_YES)
yywarning("is_avr32 is deprecated, will be removed in v8.0, use prog_modes");
if ($3->value.number == 1)
current_part->prog_modes |= PM_aWire;
else if ($3->primary == K_NO)
else if ($3->value.number == 0)
current_part->prog_modes &= ~PM_aWire;
free_token($3);
} |
K_ALLOWFULLPAGEBITSTREAM TKN_EQUAL yesno
K_ALLOWFULLPAGEBITSTREAM TKN_EQUAL numexpr
{
if ($3->primary == K_YES)
if ($3->value.number == 1)
current_part->flags |= AVRPART_ALLOWFULLPAGEBITSTREAM;
else if ($3->primary == K_NO)
else if ($3->value.number == 0)
current_part->flags &= ~AVRPART_ALLOWFULLPAGEBITSTREAM;
else {
yyerror("allowfullpagebitstream not a Boolean value");
free_token($3);
YYABORT;
}
free_token($3);
} |
K_ENABLEPAGEPROGRAMMING TKN_EQUAL yesno
K_ENABLEPAGEPROGRAMMING TKN_EQUAL numexpr
{
if ($3->primary == K_YES)
if ($3->value.number == 1)
current_part->flags |= AVRPART_ENABLEPAGEPROGRAMMING;
else if ($3->primary == K_NO)
else if ($3->value.number == 0)
current_part->flags &= ~AVRPART_ENABLEPAGEPROGRAMMING;
else {
yyerror("enablepageprogramming not a Boolean value");
free_token($3);
YYABORT;
}
free_token($3);
} |
K_MCU_BASE TKN_EQUAL numexpr
K_SERIAL TKN_EQUAL numexpr
{
current_part->mcu_base = $3->value.number;
free_token($3);
} |
K_NVM_BASE TKN_EQUAL numexpr
{
current_part->nvm_base = $3->value.number;
free_token($3);
} |
K_OCD_BASE TKN_EQUAL numexpr
{
current_part->ocd_base = $3->value.number;
free_token($3);
} |
K_OCDREV TKN_EQUAL numexpr
{
current_part->ocdrev = $3->value.number;
free_token($3);
} |
K_SERIAL TKN_EQUAL yesno
{
if ($3->primary == K_YES)
if ($3->value.number == 1)
current_part->flags |= AVRPART_SERIALOK;
else if ($3->primary == K_NO)
else if ($3->value.number == 0)
current_part->flags &= ~AVRPART_SERIALOK;
else {
yyerror("serial not a Boolean value");
free_token($3);
YYABORT;
}
free_token($3);
} |
K_PARALLEL TKN_EQUAL parallel_modes
K_PARALLEL TKN_EQUAL numexpr
{
if ($3->primary == K_YES) {
if ($3->value.number == 1) {
current_part->flags |= AVRPART_PARALLELOK;
current_part->flags &= ~AVRPART_PSEUDOPARALLEL;
}
else if ($3->primary == K_NO) {
else if ($3->value.number == 0) {
current_part->flags &= ~AVRPART_PARALLELOK;
current_part->flags &= ~AVRPART_PSEUDOPARALLEL;
}
else if ($3->primary == K_PSEUDO) {
else if ($3->value.number == 2) {
current_part->flags |= AVRPART_PARALLELOK;
current_part->flags |= AVRPART_PSEUDOPARALLEL;
}
else {
yyerror("parallel outside [0, 2] (yes/no/pseudo)");
free_token($3);
YYABORT;
}
free_token($3);
@@ -1343,11 +1018,6 @@ part_parm :
;
yesno :
K_YES | K_NO
;
mem_specs :
mem_spec TKN_SEMI |
mem_alias TKN_SEMI |
@@ -1361,19 +1031,6 @@ mem_spec :
free_token($1);
} |
K_PAGED TKN_EQUAL yesno
{
current_mem->paged = $3->primary == K_YES ? 1 : 0;
free_token($3);
} |
K_SIZE TKN_EQUAL numexpr
{
current_mem->size = $3->value.number;
free_token($3);
} |
K_PAGE_SIZE TKN_EQUAL numexpr
{
int ps = $3->value.number;
@@ -1384,36 +1041,6 @@ mem_spec :
free_token($3);
} |
K_NUM_PAGES TKN_EQUAL numexpr
{
current_mem->num_pages = $3->value.number;
free_token($3);
} |
K_OFFSET TKN_EQUAL numexpr
{
current_mem->offset = $3->value.number;
free_token($3);
} |
K_MIN_WRITE_DELAY TKN_EQUAL numexpr
{
current_mem->min_write_delay = $3->value.number;
free_token($3);
} |
K_MAX_WRITE_DELAY TKN_EQUAL numexpr
{
current_mem->max_write_delay = $3->value.number;
free_token($3);
} |
K_PWROFF_AFTER_WRITE TKN_EQUAL yesno
{
current_mem->pwroff_after_write = $3->primary == K_YES ? 1 : 0;
free_token($3);
} |
K_READBACK TKN_EQUAL TKN_NUMBER TKN_NUMBER
{
current_mem->readback[0] = $3->value.number;
@@ -1422,50 +1049,6 @@ mem_spec :
free_token($4);
} |
K_READBACK_P1 TKN_EQUAL numexpr
{
current_mem->readback[0] = $3->value.number;
free_token($3);
} |
K_READBACK_P2 TKN_EQUAL numexpr
{
current_mem->readback[1] = $3->value.number;
free_token($3);
} |
K_MODE TKN_EQUAL numexpr
{
current_mem->mode = $3->value.number;
free_token($3);
} |
K_DELAY TKN_EQUAL numexpr
{
current_mem->delay = $3->value.number;
free_token($3);
} |
K_BLOCKSIZE TKN_EQUAL numexpr
{
current_mem->blocksize = $3->value.number;
free_token($3);
} |
K_READSIZE TKN_EQUAL numexpr
{
current_mem->readsize = $3->value.number;
free_token($3);
} |
K_POLLINDEX TKN_EQUAL numexpr
{
current_mem->pollindex = $3->value.number;
free_token($3);
} |
opcode TKN_EQUAL string_list {
{
int opnum;

View File

@@ -78,9 +78,12 @@ dnl Makefile.am:77: compiling `config_gram.c' with per-target flags requires `AM
AM_PROG_CC_C_O
# Checks for libraries.
# For MinGW.
AC_CHECK_LIB([ws2_32], [WSAStartup])
AC_CHECK_LIB([termcap], [tputs])
AC_CHECK_LIB([ncurses], [tputs])
AC_CHECK_LIB([readline], [readline])
AC_CHECK_LIB([readline], [readline], [have_readline=yes])
AH_TEMPLATE([HAVE_LIBELF],
[Define if ELF support is enabled via libelf])
AC_CHECK_LIB([elf], [elf_getshdrstrndx], [have_libelf=yes])
@@ -429,7 +432,7 @@ fi
# If we are compiling with gcc, enable all warnings and make warnings errors.
if test "$GCC" = yes; then
ENABLE_WARNINGS="-Wall"
ENABLE_WARNINGS="-Wall -Wextra -Wno-unused-parameter"
# does this compiler support -Wno-pointer-sign ?
AC_MSG_CHECKING([if gcc accepts -Wno-pointer-sign ])

View File

@@ -763,7 +763,7 @@ static void dev_part_strct(const AVRPART *p, bool tsv, const AVRPART *base, bool
_if_memout(intcmp, "%d", max_write_delay);
_if_memout_yn(pwroff_after_write);
_if_n_memout_str(memcmp, 2, dev_sprintf("0x%02x 0x%02x", m->readback[0], m->readback[1]), readback);
_if_memout(intcmp, "%d", mode);
_if_memout(intcmp, "0x%02x", mode);
_if_memout(intcmp, "%d", delay);
_if_memout(intcmp, "%d", blocksize);
_if_memout(intcmp, "%d", readsize);

View File

@@ -62,6 +62,11 @@ static int dev_message(int msglvl, const char *fmt, ...);
dev_part_strct_entry(tsv, ".prog", id, NULL, #component, dev_sprintf(fmt, pgm->component), pgm->comments); \
} while(0)
#define _if_pgmout_bool(component) do { \
if(!base || !!base->component != !!pgm->component) \
dev_part_strct_entry(tsv, ".prog", id, NULL, #component, dev_sprintf("%s", pgm->component? "true": "false"), pgm->comments); \
} while(0)
// Result must be a malloc'd string
#define _if_pgmout_str(cmp, result, component) do { \
if(!base || cmp(base->component, pgm->component)) \
@@ -77,6 +82,11 @@ static int dev_message(int msglvl, const char *fmt, ...);
dev_part_strct_entry(tsv, ".pt", p->desc, NULL, #component, dev_sprintf(fmt, p->component), p->comments); \
} while(0)
#define _if_partout_bool(component) do { \
if(!base || !!base->component != !!p->component) \
dev_part_strct_entry(tsv, ".pt", p->desc, NULL, #component, dev_sprintf("%s", p->component? "true": "false"), p->comments); \
} while(0)
#define _if_n_partout(cmp, n, fmt, component) do { \
if(!base || cmp(base->component, p->component, n)) \
dev_part_strct_entry(tsv, ".pt", p->desc, NULL, #component, dev_sprintf(fmt, p->component), p->comments); \
@@ -120,6 +130,11 @@ static int dev_message(int msglvl, const char *fmt, ...);
#define _memout_yn(component) \
dev_part_strct_entry(tsv, ".ptmm", p->desc, m->desc, #component, cfg_strdup("_memout_yn()", m->component? "yes": "no"), m->comments)
#define _if_memout_bool(component) do { \
if(!bm || !!bm->component != !!m->component) \
dev_part_strct_entry(tsv, ".ptmm", p->desc, m->desc, #component, dev_sprintf("%s", m->component? "true": "false"), m->comments); \
} while(0)
#define _if_memout_yn(component) do { \
if(!bm || bm->component != m->component) \
dev_part_strct_entry(tsv, ".ptmm", p->desc, m->desc, #component, cfg_strdup("_if_memout_yn()", m->component? "yes": "no"), m->comments); \

View File

@@ -275,12 +275,12 @@ int dfu_getstatus(struct dfu_dev *dfu, struct dfu_status *status)
return -1;
}
if (result < sizeof(struct dfu_status)) {
if (result < (int) sizeof(struct dfu_status)) {
pmsg_error("unable to get DFU status: %s\n", "short read");
return -1;
}
if (result > sizeof(struct dfu_status)) {
if (result > (int) sizeof(struct dfu_status)) {
pmsg_error("oversize read (should not happen); exiting\n");
exit(1);
}

View File

@@ -223,8 +223,8 @@ The STK600, JTAG ICE mkII/3, AVRISP mkII, USBasp, avrftdi (and derivatives), and
programmers communicate through the USB, using @code{libusb} as a
platform abstraction layer.
The avrftdi adds support for the FT2232C/D, FT2232H, and FT4232H devices. These all use
the MPSSE mode, which has a specific pin mapping. Bit 1 (the lsb of the byte in the config
file) is SCK. Bit 2 is SDO, and Bit 3 is SDI. Bit 4 usually reset. The 2232C/D parts
the MPSSE mode, which has a specific pin mapping. Bit 0 (the lsb of the byte in the config
file) is SCK. Bit 1 is SDO, and Bit 2 is SDI. Bit 3 usually reset. The 2232C/D parts
are only supported on interface A, but the H parts can be either A or B (specified by the
usbdev config parameter).
The STK500, STK600, JTAG ICE, and avr910 contain on-board logic to control the programming of the target

View File

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

View File

@@ -374,7 +374,7 @@ int flip1_read_byte(const PROGRAMMER *pgm, const AVRPART *part, const AVRMEM *me
if (strcmp(mem->desc, "signature") == 0) {
if (flip1_read_sig_bytes(pgm, part, mem) < 0)
return -1;
if (addr >= mem->size) {
if (addr >= (unsigned long) mem->size) {
pmsg_error("signature address %lu out of range [0, %d]\n", addr, mem->size-1);
return -1;
}
@@ -461,7 +461,7 @@ int flip1_paged_write(const PROGRAMMER *pgm, const AVRPART *part, const AVRMEM *
result = flip1_write_memory(FLIP1(pgm)->dfu, mem_unit, addr,
mem->buf + addr, n_bytes);
return (result == 0) ? n_bytes : -1;
return result == 0? (int) n_bytes: -1;
}
int flip1_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *part, const AVRMEM *mem) {
@@ -470,7 +470,7 @@ int flip1_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *part, const AVRME
if (FLIP1(pgm)->dfu == NULL)
return -1;
if (mem->size < sizeof(FLIP1(pgm)->part_sig)) {
if (mem->size < (int) sizeof(FLIP1(pgm)->part_sig)) {
pmsg_error("signature read must be at least %u bytes\n", (unsigned int) sizeof(FLIP1(pgm)->part_sig));
return -1;
}
@@ -652,7 +652,7 @@ int flip1_write_memory(struct dfu_dev *dfu,
int cmd_result = 0;
int aux_result;
struct flip1_cmd_header cmd_header = {
FLIP1_CMD_PROG_START, mem_unit
FLIP1_CMD_PROG_START, mem_unit, {0}, {0}, {0},
};
struct flip1_prog_footer cmd_footer = {
{ 0, 0, 0, 0 }, /* CRC */

View File

@@ -459,7 +459,7 @@ int flip2_paged_load(const PROGRAMMER *pgm, const AVRPART *part, const AVRMEM *m
result = flip2_read_memory(FLIP2(pgm)->dfu, mem_unit, addr,
mem->buf + addr, n_bytes);
return (result == 0) ? n_bytes : -1;
return result == 0? (int) n_bytes: -1;
}
int flip2_paged_write(const PROGRAMMER *pgm, const AVRPART *part, const AVRMEM *mem,
@@ -490,7 +490,7 @@ int flip2_paged_write(const PROGRAMMER *pgm, const AVRPART *part, const AVRMEM *
result = flip2_write_memory(FLIP2(pgm)->dfu, mem_unit, addr,
mem->buf + addr, n_bytes);
return (result == 0) ? n_bytes : -1;
return result == 0? (int) n_bytes: -1;
}
// Parse the -E option flag
@@ -520,7 +520,7 @@ int flip2_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *part, const AVRME
if (FLIP2(pgm)->dfu == NULL)
return -1;
if (mem->size < sizeof(FLIP2(pgm)->part_sig)) {
if (mem->size < (int) sizeof(FLIP2(pgm)->part_sig)) {
pmsg_error("signature read must be at least %u bytes\n", (unsigned int) sizeof(FLIP2(pgm)->part_sig));
return -1;
}

View File

@@ -166,14 +166,14 @@ static void ft245r_rx_buf_purge(const PROGRAMMER *pgm) {
static void ft245r_rx_buf_put(const PROGRAMMER *pgm, uint8_t byte) {
rx.len++;
rx.buf[rx.wr++] = byte;
if (rx.wr >= sizeof(rx.buf))
if (rx.wr >= (int) sizeof(rx.buf))
rx.wr = 0;
}
static uint8_t ft245r_rx_buf_get(const PROGRAMMER *pgm) {
rx.len--;
uint8_t byte = rx.buf[rx.rd++];
if (rx.rd >= sizeof(rx.buf))
if (rx.rd >= (int) sizeof(rx.buf))
rx.rd = 0;
return byte;
}
@@ -246,10 +246,8 @@ static int ft245r_flush(const PROGRAMMER *pgm) {
static int ft245r_send2(const PROGRAMMER *pgm, unsigned char *buf, size_t len,
bool discard_rx_data) {
int i, j;
for (i = 0; i < len; ++i) {
for (j = 0; j < baud_multiplier; ++j) {
for (size_t i = 0; i < len; ++i) {
for (int j = 0; j < baud_multiplier; ++j) {
if (discard_rx_data)
++rx.discard;
tx.buf[tx.len++] = buf[i];
@@ -270,13 +268,11 @@ static int ft245r_send_and_discard(const PROGRAMMER *pgm, unsigned char *buf,
}
static int ft245r_recv(const PROGRAMMER *pgm, unsigned char *buf, size_t len) {
int i, j;
ft245r_flush(pgm);
ft245r_fill(pgm);
#if FT245R_DEBUG
msg_info("%s: discarding %d, consuming %zu bytes\n", __func__, rx.discard, len);
msg_info("%s: discarding %d, consuming %lu bytes\n", __func__, rx.discard, (unsigned long) len);
#endif
while (rx.discard > 0) {
int result = ft245r_rx_buf_fill_and_get(pgm);
@@ -288,7 +284,7 @@ static int ft245r_recv(const PROGRAMMER *pgm, unsigned char *buf, size_t len) {
--rx.discard;
}
for (i = 0; i < len; ++i)
for (size_t i = 0; i < len; ++i)
{
int result = ft245r_rx_buf_fill_and_get(pgm);
if (result < 0)
@@ -297,7 +293,7 @@ static int ft245r_recv(const PROGRAMMER *pgm, unsigned char *buf, size_t len) {
}
buf[i] = (uint8_t)result;
for (j = 1; j < baud_multiplier; ++j)
for (int j = 1; j < baud_multiplier; ++j)
{
result = ft245r_rx_buf_fill_and_get(pgm);
if (result < 0)
@@ -1054,7 +1050,7 @@ static int ft245r_paged_write_flash(const PROGRAMMER *pgm, const AVRPART *p, con
avr_set_bits(m->op[spi], cmd);
avr_set_addr(m->op[spi], cmd, addr/2);
avr_set_input(m->op[spi], cmd, m->buf[addr]);
for(int k=0; k<sizeof cmd; k++)
for(size_t k=0; k<sizeof cmd; k++)
buf_pos += set_data(pgm, buf+buf_pos, cmd[k]);
i++; j++; addr++;
@@ -1064,7 +1060,7 @@ static int ft245r_paged_write_flash(const PROGRAMMER *pgm, const AVRPART *p, con
// page boundary, finished or buffer exhausted? queue up requests
if(do_page_write || i >= (int) n_bytes || j >= FT245R_FRAGMENT_SIZE/FT245R_CMD_SIZE) {
if(i >= n_bytes) {
if(i >= (int) n_bytes) {
ft245r_out = SET_BITS_0(ft245r_out, pgm, PIN_AVR_SCK, 0); // SCK down
buf[buf_pos++] = ft245r_out;
} else {
@@ -1150,7 +1146,7 @@ static int ft245r_paged_load_flash(const PROGRAMMER *pgm, const AVRPART *p, cons
avr_set_addr(m->op[AVR_OP_LOAD_EXT_ADDR], cmd, addr/2);
buf_pos = 0;
for(int k=0; k<sizeof cmd; k++)
for(size_t k=0; k<sizeof cmd; k++)
buf_pos += set_data(pgm, buf+buf_pos, cmd[k]);
ft245r_send_and_discard(pgm, buf, buf_pos);
}
@@ -1164,7 +1160,7 @@ static int ft245r_paged_load_flash(const PROGRAMMER *pgm, const AVRPART *p, cons
memset(cmd, 0, sizeof cmd);
avr_set_bits(m->op[spi], cmd);
avr_set_addr(m->op[spi], cmd, addr/2);
for(int k=0; k<sizeof cmd; k++)
for(size_t k=0; k<sizeof cmd; k++)
buf_pos += set_data(pgm, buf+buf_pos, cmd[k]);
i++; j++; addr++;

View File

@@ -2586,7 +2586,7 @@ static int jtag3_send_tpi(const PROGRAMMER *pgm, unsigned char *data, size_t len
cmdbuf[0] = SCOPE_AVR_TPI;
if (len > INT_MAX) {
pmsg_error("invalid jtag3_send_tpi() packet length %zu\n", len);
pmsg_error("invalid jtag3_send_tpi() packet length %lu\n", (unsigned long) len);
free(cmdbuf);
return -1;
}

View File

@@ -83,7 +83,7 @@ struct pdata
* to try connecting at startup, we keep these two entries on top to
* speedup the program start.
*/
const static struct {
static const struct {
long baud;
unsigned char val;
} baudtab[] = {
@@ -139,11 +139,10 @@ u16_to_b2(unsigned char *b, unsigned short l)
}
static void jtagmkI_prmsg(const PROGRAMMER *pgm, unsigned char *data, size_t len) {
int i;
if (verbose >= 4) {
msg_trace("Raw message:\n");
size_t i;
for (i = 0; i < len; i++) {
msg_trace("0x%02x ", data[i]);
if (i % 16 == 15)
@@ -182,6 +181,7 @@ static void jtagmkI_prmsg(const PROGRAMMER *pgm, unsigned char *data, size_t len
case RESP_POWER:
msg_info("target power lost\n");
break;
default:
msg_info("unknown message 0x%02x\n", data[0]);
@@ -471,9 +471,7 @@ static int jtagmkI_program_disable(const PROGRAMMER *pgm) {
static unsigned char jtagmkI_get_baud(long baud)
{
int i;
for (i = 0; i < sizeof baudtab / sizeof baudtab[0]; i++)
for (size_t i = 0; i < sizeof baudtab / sizeof baudtab[0]; i++)
if (baud == baudtab[i].baud)
return baudtab[i].val;

View File

@@ -121,9 +121,17 @@ SIGN [+-]
}
(?x: prog_modes | mcuid | n_interrupts | n_page_erase | n_word_writes | n_boot_sections |
boot_section_size | autobaud_sync | idr | rampz | spmcr | eecr | eind ) { /* struct components */
(?x: desc | prog_modes | baudrate | usbvid | usbdev | usbsn | usbvendor | usbproduct |
family_id | mcuid | n_interrupts | n_page_erase | n_boot_sections | boot_section_size |
hvupdi_variant | stk500_devcode | avr910_devcode | chip_erase_delay | pagel | bs2 |
timeout | stabdelay | cmdexedelay | synchloops | bytedelay | pollindex | pollvalue | predelay | postdelay | pollmethod |
hventerstabdelay | progmodedelay | latchcycles | togglevtg | poweroffdelay | resetdelayms | resetdelayus | resetdelay | hvleavestabdelay |
chiperasetime | (chiperase|program(fuse|lock))(polltimeout|pulsewidth) | synchcycles | hvspcmdexedelay |
mcu_base | nvm_base | ocd_base | ocdrev |
autobaud_sync | idr | rampz | spmcr | eecr | eind |
paged | size | num_pages | n_word_writes | offset | min_write_delay | max_write_delay | pwroff_after_write |
readback_p1 | readback_p2 | mode | delay | blocksize | readsize ) {
/* struct components for PROGRAMMER, AVRPART and AVRMEM */
Component_t *cp = cfg_comp_search(yytext, current_strct);
if(!cp) {
yyerror("unknown component %s in %s", yytext, cfg_strct_name(current_strct));
@@ -135,27 +143,17 @@ SIGN [+-]
return TKN_COMPONENT;
}
PM_(SPM|TPI|ISP|PDI|UPDI|HVSP|HVPP|debugWIRE|JTAG|JTAGmkI|XMEGAJTAG|AVR32JTAG|aWire) { /* Constants */
(?x: PM_(SPM|TPI|ISP|PDI|UPDI|HVSP|HVPP|debugWIRE|JTAG|JTAGmkI|XMEGAJTAG|AVR32JTAG|aWire) |
yes|no|pseudo | true|false ) { /* Constants */
yylval = new_constant(yytext);
return TKN_NUMBER;
}
alias { yylval=NULL; return K_ALIAS; }
allowfullpagebitstream { yylval=NULL; ccap(); return K_ALLOWFULLPAGEBITSTREAM; }
avr910_devcode { yylval=NULL; ccap(); return K_AVR910_DEVCODE; }
bank_size { yylval=NULL; return K_PAGE_SIZE; }
banked { yylval=NULL; return K_PAGED; }
baudrate { yylval=NULL; ccap(); return K_BAUDRATE; }
blocksize { yylval=NULL; ccap(); return K_BLOCKSIZE; }
bs2 { yylval=NULL; ccap(); return K_BS2; }
buff { yylval=NULL; ccap(); return K_BUFF; }
bytedelay { yylval=NULL; ccap(); return K_BYTEDELAY; }
chip_erase { yylval=new_token(K_CHIP_ERASE); ccap(); return K_CHIP_ERASE; }
chip_erase_delay { yylval=NULL; ccap(); return K_CHIP_ERASE_DELAY; }
chiperasepolltimeout { yylval=NULL; ccap(); return K_CHIPERASEPOLLTIMEOUT; }
chiperasepulsewidth { yylval=NULL; ccap(); return K_CHIPERASEPULSEWIDTH; }
chiperasetime { yylval=NULL; ccap(); return K_CHIPERASETIME; }
cmdexedelay { yylval=NULL; ccap(); return K_CMDEXEDELAY; }
connection_type { yylval=NULL; ccap(); return K_CONNTYPE; }
dedicated { yylval=new_token(K_DEDICATED); return K_DEDICATED; }
default_bitclock { yylval=NULL; return K_DEFAULT_BITCLOCK; }
@@ -163,14 +161,11 @@ default_parallel { yylval=NULL; return K_DEFAULT_PARALLEL; }
default_programmer { yylval=NULL; return K_DEFAULT_PROGRAMMER; }
default_serial { yylval=NULL; return K_DEFAULT_SERIAL; }
default_spi { yylval=NULL; return K_DEFAULT_SPI; }
delay { yylval=NULL; ccap(); return K_DELAY; }
desc { yylval=NULL; ccap(); return K_DESC; }
devicecode { yylval=NULL; ccap(); return K_DEVICECODE; }
eeprom { yylval=NULL; return K_EEPROM; }
eeprom_instr { yylval=NULL; ccap(); return K_EEPROM_INSTR; }
enablepageprogramming { yylval=NULL; ccap(); return K_ENABLEPAGEPROGRAMMING; }
errled { yylval=NULL; ccap(); return K_ERRLED; }
family_id { yylval=NULL; ccap(); return K_FAMILY_ID; }
flash { yylval=NULL; return K_FLASH; }
flash_instr { yylval=NULL; ccap(); return K_FLASH_INSTR; }
has_debugwire { yylval=NULL; ccap(); return K_HAS_DW; }
@@ -178,99 +173,49 @@ has_jtag { yylval=NULL; ccap(); return K_HAS_JTAG; }
has_pdi { yylval=NULL; ccap(); return K_HAS_PDI; }
has_tpi { yylval=NULL; ccap(); return K_HAS_TPI; }
has_updi { yylval=NULL; ccap(); return K_HAS_UPDI; }
hventerstabdelay { yylval=NULL; ccap(); return K_HVENTERSTABDELAY; }
hvleavestabdelay { yylval=NULL; ccap(); return K_HVLEAVESTABDELAY; }
hvsp_controlstack { yylval=NULL; ccap(); return K_HVSP_CONTROLSTACK; }
hvspcmdexedelay { yylval=NULL; ccap(); return K_HVSPCMDEXEDELAY; }
hvupdi_support { yylval=NULL; ccap(); return K_HVUPDI_SUPPORT; }
hvupdi_variant { yylval=NULL; ccap(); return K_HVUPDI_VARIANT; }
id { yylval=NULL; ccap(); return K_ID; }
io { yylval=new_token(K_IO); return K_IO; }
is_at90s1200 { yylval=NULL; ccap(); return K_IS_AT90S1200; }
is_avr32 { yylval=NULL; ccap(); return K_IS_AVR32; }
latchcycles { yylval=NULL; ccap(); return K_LATCHCYCLES; }
load_ext_addr { yylval=new_token(K_LOAD_EXT_ADDR); ccap(); return K_LOAD_EXT_ADDR; }
loadpage_hi { yylval=new_token(K_LOADPAGE_HI); ccap(); return K_LOADPAGE_HI; }
loadpage_lo { yylval=new_token(K_LOADPAGE_LO); ccap(); return K_LOADPAGE_LO; }
max_write_delay { yylval=NULL; ccap(); return K_MAX_WRITE_DELAY; }
mcu_base { yylval=NULL; ccap(); return K_MCU_BASE; }
memory { yylval=NULL; ccap(); current_strct = COMP_AVRMEM; return K_MEMORY; }
min_write_delay { yylval=NULL; ccap(); return K_MIN_WRITE_DELAY; }
miso { yylval=NULL; ccap(); return K_SDI; } // Deprecated
mode { yylval=NULL; ccap(); return K_MODE; }
mosi { yylval=NULL; ccap(); return K_SDO; } // Deprecated
no { yylval=new_token(K_NO); return K_NO; }
miso { yylval=NULL; ccap(); yywarning("miso is deprecated, will be removed in v8.0, use sdi"); return K_SDI; }
mosi { yylval=NULL; ccap(); yywarning("mosi is deprecated, will be removed in v8.0, use sdo"); return K_SDO; }
NULL { yylval=NULL; return K_NULL; }
num_banks { yylval=NULL; return K_NUM_PAGES; }
num_pages { yylval=NULL; ccap(); return K_NUM_PAGES; }
nvm_base { yylval=NULL; ccap(); return K_NVM_BASE; }
ocd_base { yylval=NULL; ccap(); return K_OCD_BASE; }
ocdrev { yylval=NULL; ccap(); return K_OCDREV; }
offset { yylval=NULL; ccap(); return K_OFFSET; }
paged { yylval=NULL; ccap(); return K_PAGED; }
pagel { yylval=NULL; ccap(); return K_PAGEL; }
page_size { yylval=NULL; ccap(); return K_PAGE_SIZE; }
parallel { yylval=NULL; ccap(); return K_PARALLEL; }
parent { yylval=NULL; return K_PARENT; }
part { yylval=NULL; ccap(); current_strct = COMP_AVRPART; return K_PART; }
pgm_enable { yylval=new_token(K_PGM_ENABLE); ccap(); return K_PGM_ENABLE; }
pgmled { yylval=NULL; ccap(); return K_PGMLED; }
pollindex { yylval=NULL; ccap(); return K_POLLINDEX; }
pollmethod { yylval=NULL; ccap(); return K_POLLMETHOD; }
pollvalue { yylval=NULL; ccap(); return K_POLLVALUE; }
postdelay { yylval=NULL; ccap(); return K_POSTDELAY; }
poweroffdelay { yylval=NULL; ccap(); return K_POWEROFFDELAY; }
pp_controlstack { yylval=NULL; ccap(); return K_PP_CONTROLSTACK; }
predelay { yylval=NULL; ccap(); return K_PREDELAY; }
progmodedelay { yylval=NULL; ccap(); return K_PROGMODEDELAY; }
programfusepolltimeout { yylval=NULL; ccap(); return K_PROGRAMFUSEPOLLTIMEOUT; }
programfusepulsewidth { yylval=NULL; ccap(); return K_PROGRAMFUSEPULSEWIDTH; }
programlockpolltimeout { yylval=NULL; ccap(); return K_PROGRAMLOCKPOLLTIMEOUT; }
programlockpulsewidth { yylval=NULL; ccap(); return K_PROGRAMLOCKPULSEWIDTH; }
programmer { yylval=NULL; ccap(); current_strct = COMP_PROGRAMMER; return K_PROGRAMMER; }
pseudo { yylval=new_token(K_PSEUDO); return K_PSEUDO; }
pwroff_after_write { yylval=NULL; ccap(); return K_PWROFF_AFTER_WRITE; }
rdyled { yylval=NULL; ccap(); return K_RDYLED; }
read { yylval=new_token(K_READ); ccap(); return K_READ; }
read_hi { yylval=new_token(K_READ_HI); ccap(); return K_READ_HI; }
read_lo { yylval=new_token(K_READ_LO); ccap(); return K_READ_LO; }
readback { yylval=NULL; ccap(); return K_READBACK; }
readback_p1 { yylval=NULL; ccap(); return K_READBACK_P1; }
readback_p2 { yylval=NULL; ccap(); return K_READBACK_P2; }
readsize { yylval=NULL; ccap(); return K_READSIZE; }
reset { yylval=new_token(K_RESET); ccap(); return K_RESET; }
resetdelay { yylval=NULL; ccap(); return K_RESETDELAY; }
resetdelayms { yylval=NULL; ccap(); return K_RESETDELAYMS; }
resetdelayus { yylval=NULL; ccap(); return K_RESETDELAYUS; }
retry_pulse { yylval=NULL; ccap(); return K_RETRY_PULSE; }
sck { yylval=new_token(K_SCK); ccap(); return K_SCK; }
sdi { yylval=NULL; ccap(); return K_SDI; }
sdo { yylval=NULL; ccap(); return K_SDO; }
serial { yylval=NULL; ccap(); return K_SERIAL; }
signature { yylval=NULL; ccap(); return K_SIGNATURE; }
size { yylval=NULL; ccap(); return K_SIZE; }
spi { yylval=NULL; return K_SPI; }
stabdelay { yylval=NULL; ccap(); return K_STABDELAY; }
stk500_devcode { yylval=NULL; ccap(); return K_STK500_DEVCODE; }
synchcycles { yylval=NULL; ccap(); return K_SYNCHCYCLES; }
synchloops { yylval=NULL; ccap(); return K_SYNCHLOOPS; }
timeout { yylval=NULL; ccap(); return K_TIMEOUT; }
togglevtg { yylval=NULL; ccap(); return K_TOGGLEVTG; }
type { yylval=NULL; ccap(); return K_TYPE; }
usb { yylval=NULL; return K_USB; }
usbdev { yylval=NULL; ccap(); return K_USBDEV; }
usbpid { yylval=NULL; ccap(); return K_USBPID; }
usbproduct { yylval=NULL; ccap(); return K_USBPRODUCT; }
usbsn { yylval=NULL; ccap(); return K_USBSN; }
usbvendor { yylval=NULL; ccap(); return K_USBVENDOR; }
usbvid { yylval=NULL; ccap(); return K_USBVID; }
vcc { yylval=NULL; ccap(); return K_VCC; }
vfyled { yylval=NULL; ccap(); return K_VFYLED; }
write { yylval=new_token(K_WRITE); ccap(); return K_WRITE; }
write_hi { yylval=new_token(K_WRITE_HI); ccap(); return K_WRITE_HI; }
write_lo { yylval=new_token(K_WRITE_LO); ccap(); return K_WRITE_LO; }
writepage { yylval=new_token(K_WRITEPAGE); ccap(); return K_WRITEPAGE; }
yes { yylval=new_token(K_YES); return K_YES; }
"," { yylval = NULL; pyytext(); return TKN_COMMA; }
"=" { yylval = NULL; pyytext(); return TKN_EQUAL; }

View File

@@ -795,7 +795,7 @@ lget ( LISTID lid )
void *
lget_n ( LISTID lid, unsigned int n )
{
int i;
unsigned int i;
LIST * l;
LISTNODE * ln;
@@ -803,7 +803,7 @@ lget_n ( LISTID lid, unsigned int n )
CKLMAGIC(l);
if ((n<1)||(n>lsize(l))) {
if (n < 1 || n > (unsigned int) lsize(l)) {
return NULL;
}
@@ -836,7 +836,7 @@ lget_n ( LISTID lid, unsigned int n )
LNODEID
lget_ln ( LISTID lid, unsigned int n )
{
int i;
unsigned int i;
LIST * l;
LISTNODE * ln;
@@ -844,7 +844,7 @@ lget_ln ( LISTID lid, unsigned int n )
CKLMAGIC(l);
if ((n<1)||(n>lsize(l))) {
if (n < 1 || n > (unsigned int) lsize(l)) {
return NULL;
}
@@ -944,7 +944,7 @@ insert_ln ( LIST * l, LISTNODE * ln, void * data_ptr )
int
lins_n ( LISTID lid, void * data_ptr, unsigned int n )
{
int i;
unsigned int i;
LIST * l;
LISTNODE * ln;
@@ -952,7 +952,7 @@ lins_n ( LISTID lid, void * data_ptr, unsigned int n )
CKLMAGIC(l);
if ((n<1)||(n>(l->num+1))) {
if (n < 1 || n > (unsigned int) (l->num+1)) {
return -1;
}
@@ -1185,7 +1185,7 @@ lrmv_ln ( LISTID lid, LNODEID lnid )
void *
lrmv_n ( LISTID lid, unsigned int n )
{
int i;
unsigned int i;
LIST * l;
LISTNODE * ln;
@@ -1193,7 +1193,7 @@ lrmv_n ( LISTID lid, unsigned int n )
CKLMAGIC(l);
if ((n<1)||(n>l->num)) {
if (n < 1 || n > (unsigned int) l->num) {
return NULL;
}

View File

@@ -192,7 +192,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/mariusgreuel/avrdude>\n",
"\navrdude version %s, URL: <https://github.com/avrdudes/avrdude>\n",
progname, version);
}

View File

@@ -191,7 +191,7 @@ static int micronucleus_get_bootloader_info_v1(pdata_t* pdata)
pmsg_warning("unable to get bootloader info block: %s\n", usb_strerror());
return result;
}
else if (result < sizeof(buffer))
else if ((size_t) result < sizeof(buffer))
{
pmsg_warning("received invalid bootloader info block size: %d\n", result);
return -1;
@@ -258,7 +258,7 @@ static int micronucleus_get_bootloader_info_v2(pdata_t* pdata)
pmsg_warning("unable to get bootloader info block: %s\n", usb_strerror());
return result;
}
else if (result < sizeof(buffer))
else if ((size_t) result < sizeof(buffer))
{
pmsg_warning("received invalid bootloader info block size: %d\n", result);
return -1;
@@ -449,7 +449,7 @@ static int micronucleus_write_page_v2(pdata_t* pdata, uint32_t address, uint8_t*
return result;
}
for (int i = 0; i < size; i += 4)
for (uint32_t i = 0; i < size; i += 4)
{
int w1 = (buffer[i + 1] << 8) | (buffer[i + 0] << 0);
int w2 = (buffer[i + 3] << 8) | (buffer[i + 2] << 0);
@@ -491,7 +491,7 @@ static int micronucleus_write_page(pdata_t* pdata, uint32_t address, uint8_t* bu
// Require software start.
pdata->start_program = true;
}
else if (address >= pdata->bootloader_start - pdata->page_size)
else if (address >= (uint32_t) (pdata->bootloader_start - pdata->page_size))
{
if (pdata->major_version >= 2)
{

View File

@@ -1,82 +0,0 @@
/*
* 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;
}
}

View File

@@ -1,35 +0,0 @@
/*
* 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

File diff suppressed because it is too large Load Diff

View File

@@ -111,29 +111,17 @@ const PROGRAMMER_TYPE programmers_types[] = { // Name(s) the programmers call th
{"xbee", xbee_initpgm, xbee_desc}, // "XBee"
};
const PROGRAMMER_TYPE * locate_programmer_type(const char * id)
{
const PROGRAMMER_TYPE * p = NULL;
int i;
int found;
found = 0;
for (i = 0; i < sizeof(programmers_types)/sizeof(programmers_types[0]) && !found; i++) {
p = &(programmers_types[i]);
if (strcasecmp(id, p->id) == 0)
found = 1;
}
if (found)
return p;
const PROGRAMMER_TYPE *locate_programmer_type(const char *id) {
for(size_t i = 0; i < sizeof programmers_types/sizeof*programmers_types; i++)
if(strcasecmp(id, programmers_types[i].id) == 0)
return programmers_types + i;
return NULL;
}
// Return type id given the init function or "" if not found
const char *locate_programmer_type_id(void (*initpgm)(PROGRAMMER *pgm)) {
for (int i=0; i < sizeof programmers_types/sizeof*programmers_types; i++)
for(size_t i=0; i < sizeof programmers_types/sizeof*programmers_types; i++)
if(programmers_types[i].initpgm == initpgm)
return programmers_types[i].id;
@@ -142,35 +130,15 @@ const char *locate_programmer_type_id(void (*initpgm)(PROGRAMMER *pgm)) {
/*
* Iterate over the list of programmers given as "programmers", and
* call the callback function cb for each entry found. cb is being
* Iterate over the list of programmer types given in the table above and
* call the callback function cb for each entry found. cb is being
* passed the following arguments:
* . the name of the programmer (for -c)
* . the descriptive text given in the config file
* . the name of the config file this programmer has been defined in
* . the line number of the config file this programmer has been defined at
* . the "cookie" passed into walk_programmers() (opaque client data)
* - Name of the programmer
* - Descriptive text
* - "Cookie" passed into walk_programmer_types() for opaque client data
*/
/*
void walk_programmer_types(LISTID programmer_types, walk_programmer_types_cb cb, void *cookie)
{
LNODEID ln1;
PROGRAMMER * p;
for (ln1 = lfirst(programmers); ln1; ln1 = lnext(ln1)) {
p = ldata(ln1);
cb(p->id, p->desc, cookie);
}
}
}*/
void walk_programmer_types(walk_programmer_types_cb cb, void *cookie)
{
const PROGRAMMER_TYPE * p;
int i;
for (i = 0; i < sizeof(programmers_types)/sizeof(programmers_types[0]); i++) {
p = &(programmers_types[i]);
cb(p->id, p->desc, cookie);
}
void walk_programmer_types(walk_programmer_types_cb cb, void *cookie) {
for (size_t i = 0; i < sizeof(programmers_types)/sizeof(programmers_types[0]); i++)
cb(programmers_types[i].id, programmers_types[i].desc, cookie);
}

View File

@@ -199,7 +199,7 @@ static int pickit2_open(PROGRAMMER *pgm, const char *port) {
strcpy(cbuf, pgm->desc);
// Convert from wide chars and overlay over initial part of desc
for (int i = 0; i < sizeof wbuf/sizeof*wbuf && wbuf[i]; i++)
for(size_t i = 0; i < sizeof wbuf/sizeof*wbuf && wbuf[i]; i++)
cbuf[i] = (char) wbuf[i]; // TODO what about little/big endian???
pgm->desc = cache_string(cbuf);
}
@@ -1058,7 +1058,7 @@ static int usb_read_interrupt(const PROGRAMMER *pgm, void *buff, int size, int t
GetOverlappedResult(PDATA(pgm)->usb_handle, &ovr, &bytesRead, 0);
return bytesRead > 0 ? bytesRead : -1;
return bytesRead > 0? (int) bytesRead: -1;
}
// simple write with timeout
@@ -1083,7 +1083,7 @@ static int usb_write_interrupt(const PROGRAMMER *pgm, const void *buff, int size
GetOverlappedResult(PDATA(pgm)->usb_handle, &ovr, &bytesWritten, 0);
return bytesWritten > 0 ? bytesWritten : -1;
return bytesWritten > 0? (int) bytesWritten: -1;
}
static int pickit2_write_report(const PROGRAMMER *pgm, const unsigned char report[65]) {

View File

@@ -84,9 +84,7 @@ static int pin_fill_old_pinno(const struct pindef_t * const pindef, unsigned int
* @param[out] pinno old pin definition integer
*/
static int pin_fill_old_pinlist(const struct pindef_t * const pindef, unsigned int * const pinno) {
int i;
for(i = 0; i < PIN_FIELD_SIZE; i++) {
for(size_t i = 0; i < PIN_FIELD_SIZE; i++) {
if(i == 0) {
if((pindef->mask[i] & ~PIN_MASK) != 0) {
pmsg_error("pins of higher index than max field size for old pinno found\n");
@@ -229,7 +227,6 @@ int pins_check(const PROGRAMMER *const pgm, const struct pin_checklist_t *const
bool invalid = false;
bool inverse = false;
int index;
int segment;
bool mandatory_used = false;
pinmask_t invalid_used[PIN_FIELD_SIZE] = {0};
pinmask_t inverse_used[PIN_FIELD_SIZE] = {0};
@@ -246,7 +243,7 @@ int pins_check(const PROGRAMMER *const pgm, const struct pin_checklist_t *const
}
}
for(segment = 0; segment < PIN_FIELD_SIZE; segment++) {
for(size_t segment = 0; segment < PIN_FIELD_SIZE; segment++) {
// check if for mandatory any pin is defined
invalid_used[segment] = pgm->pin[pinname].mask[segment] & ~valid_pins->mask[segment];
if(is_mandatory && (0 != (pgm->pin[pinname].mask[segment] & valid_pins->mask[segment]))) {

View File

@@ -55,7 +55,7 @@
#define USB_VENDOR_ID 0x16c0
#define USB_PRODUCT_ID 0x05df
static int reportDataSizes[4] = {13, 29, 61, 125};
static const int reportDataSizes[4] = {13, 29, 61, 125};
static unsigned char avrdoperRxBuffer[280]; /* buffer for receive data */
static int avrdoperRxLength = 0; /* amount of valid bytes in rx buffer */
@@ -232,7 +232,7 @@ static void avrdoper_close(union filedescriptor *fdp)
static int chooseDataSize(int len)
{
int i;
size_t i;
for(i = 0; i < sizeof(reportDataSizes)/sizeof(reportDataSizes[0]); i++){
if(reportDataSizes[i] >= len)
@@ -243,13 +243,17 @@ static int chooseDataSize(int len)
static int avrdoper_send(const union filedescriptor *fdp, const unsigned char *buf, size_t buflen)
{
if(buflen > INT_MAX) {
pmsg_error("%s() called with too large buflen = %lu\n", __func__, (unsigned long) buflen);
return -1;
}
if(verbose > 3)
dumpBlock("Send", buf, buflen);
while(buflen > 0){
unsigned char buffer[256];
int rval, lenIndex = chooseDataSize(buflen);
int thisLen = buflen > reportDataSizes[lenIndex] ?
reportDataSizes[lenIndex] : buflen;
int thisLen = (int) buflen > reportDataSizes[lenIndex]?
reportDataSizes[lenIndex]: (int) buflen;
buffer[0] = lenIndex + 1; /* report ID */
buffer[1] = thisLen;
memcpy(buffer + 2, buf, thisLen);
@@ -290,7 +294,7 @@ static int avrdoperFillBuffer(const union filedescriptor *fdp) {
bytesPending = buffer[1] - len; /* amount still buffered */
if(len > buffer[1]) /* cut away padding */
len = buffer[1];
if(avrdoperRxLength + len > sizeof(avrdoperRxBuffer)){
if(avrdoperRxLength + len > (int) sizeof(avrdoperRxBuffer)){
pmsg_error("buffer overflow\n");
return -1;
}

View File

@@ -36,10 +36,6 @@
#include "avrdude.h"
#include "libavrdude.h"
#ifdef _MSC_VER
#include "msvc/usb_com_helper.h"
#endif
long serial_recv_timeout = 5000; /* ms */
long serial_drain_timeout = 250; /* ms */
@@ -257,13 +253,6 @@ static int ser_open(const char *port, union pinfo pinfo, union filedescriptor *f
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

@@ -705,11 +705,17 @@ static int serialupdi_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const
unsigned int page_size,
unsigned int addr, unsigned int n_bytes)
{
if (n_bytes > m->readsize) {
if(n_bytes > 65535) {
pmsg_error("%s() called with implausibly high n_bytes = %u\n", __func__, n_bytes);
return -1;
}
if ((int) n_bytes > m->readsize) {
unsigned int read_offset = addr;
unsigned int remaining_bytes = n_bytes;
int remaining_bytes = n_bytes;
int read_bytes = 0;
int rc;
while (remaining_bytes > 0) {
rc = updi_read_data(pgm, m->offset + read_offset, m->buf + read_offset,
remaining_bytes > m->readsize ? m->readsize : remaining_bytes);
@@ -733,10 +739,16 @@ static int serialupdi_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const
unsigned int addr, unsigned int n_bytes)
{
int rc;
if (n_bytes > m->page_size) {
if(n_bytes > 65535) {
pmsg_error("%s() called with implausibly high n_bytes = %u\n", __func__, n_bytes);
return -1;
}
if ((int) n_bytes > m->page_size) {
unsigned int write_offset = addr;
unsigned int remaining_bytes = n_bytes;
int remaining_bytes = n_bytes;
int write_bytes = 0;
while (remaining_bytes > 0) {
if (strcmp(m->desc, "eeprom")==0) {

View File

@@ -2279,7 +2279,11 @@ static int stk500v2_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const A
memcpy(buf+10,m->buf+addr, block_size);
result = stk500v2_command(pgm,buf,block_size+10, sizeof(buf));
// Do not send request to write empty flash pages except for bootloaders (fixes Issue #425)
unsigned char *p = m->buf+addr;
result = (pgm->prog_modes & PM_SPM) || !addrshift || *p != 0xff || memcmp(p, p+1, block_size-1)?
stk500v2_command(pgm, buf, block_size+10, sizeof buf): 0;
if (result < 0) {
pmsg_error("write command failed\n");
return -1;

View File

@@ -560,8 +560,9 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, UPDATE *upd, enum updateflags
pmsg_info("%d byte%s of %s%s written\n", fs.nbytes,
update_plural(fs.nbytes), mem->desc, alias_mem_desc);
if (!(flags & UF_VERIFY)) // Fall through for auto verify unless -V was specified
if (!(flags & UF_VERIFY)) // Fall through for auto verify unless
break;
// Fall through
case DEVICE_VERIFY:
// Verify that the in memory file is the same as what is on the chip

View File

@@ -272,7 +272,9 @@ static int usbhid_recv(const union filedescriptor *fd, unsigned char *buf, size_
return -1;
rv = i = hid_read_timeout(udev, buf, nbytes, 10000);
if (i != nbytes)
if (i < 0)
pmsg_error("hid_read_timeout(usb, %lu, 10000) failed\n", (unsigned long) nbytes);
else if ((size_t) i != nbytes)
pmsg_error("short read, read only %d out of %lu bytes\n", i, (unsigned long) nbytes);
if (verbose > 4) {
@@ -291,6 +293,7 @@ static int usbhid_recv(const union filedescriptor *fd, unsigned char *buf, size_
}
msg_trace2("\n");
}
return rv;
}

View File

@@ -932,7 +932,7 @@ static int usbasp_spi_set_sck_period(const PROGRAMMER *pgm, double sckperiod) {
pmsg_notice2("try to set SCK period to %g s (= %i Hz)\n", sckperiod, sckfreq);
/* Check if programmer is capable of 3 MHz SCK, if not then ommit 3 MHz setting */
int i;
size_t i;
if (PDATA(pgm)->sck_3mhz) {
pmsg_notice2("connected USBasp is capable of 3 MHz SCK\n");
i = 0;
@@ -1122,7 +1122,7 @@ static int usbasp_tpi_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const
pr = addr + m->offset;
readed = 0;
while(readed < n_bytes)
while(readed < (int) n_bytes)
{
clen = n_bytes - readed;
if(clen > 32)
@@ -1187,7 +1187,7 @@ static int usbasp_tpi_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const
usbasp_tpi_send_byte(pgm, TPI_OP_SSTPR(1));
usbasp_tpi_send_byte(pgm, (pr >> 8) );
while(writed < n_bytes)
while(writed < (int) n_bytes)
{
clen = n_bytes - writed;
if(clen > 32)

View File

@@ -96,7 +96,7 @@ static int usb_control (const PROGRAMMER *pgm,
{
int nbytes;
nbytes = usb_control_msg( PDATA(pgm)->usb_handle,
USB_ENDPOINT_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
USB_ENDPOINT_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
requestid,
val, index, // 2 bytes each of data
NULL, 0, // no data buffer in control message
@@ -735,7 +735,7 @@ static int usbtiny_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AV
}
// we can only write a page at a time anyways
if (m->paged && chunk > page_size)
if (m->paged && chunk > (int) page_size)
chunk = page_size;
if (usb_out(pgm,
@@ -752,8 +752,7 @@ static int usbtiny_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AV
}
next = addr + chunk; // Calculate what address we're at now
if (m->paged
&& ((next % page_size) == 0 || next == maxaddr) ) {
if (m->paged && (next % page_size == 0 || next == (int) maxaddr) ) {
// If we're at a page boundary, send the SPI command to flush it.
avr_write_page(pgm, p, m, (unsigned long) addr);
}