boot: Add bootloader
This commit is contained in:
parent
3ffd686b57
commit
6e47b25a90
3
bootloader/.gitignore
vendored
Normal file
3
bootloader/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
*.o
|
||||
*.bin
|
||||
*.hex
|
361
bootloader/License.txt
Normal file
361
bootloader/License.txt
Normal file
@ -0,0 +1,361 @@
|
||||
OBJECTIVE DEVELOPMENT GmbH's V-USB driver software is distributed under the
|
||||
terms and conditions of the GNU GPL version 2 or the GNU GPL version 3. It is
|
||||
your choice whether you apply the terms of version 2 or version 3. The full
|
||||
text of GPLv2 is included below. In addition to the requirements in the GPL,
|
||||
we STRONGLY ENCOURAGE you to do the following:
|
||||
|
||||
(1) Publish your entire project on a web site and drop us a note with the URL.
|
||||
Use the form at http://www.obdev.at/vusb/feedback.html for your submission.
|
||||
|
||||
(2) Adhere to minimum publication standards. Please include AT LEAST:
|
||||
- a circuit diagram in PDF, PNG or GIF format
|
||||
- full source code for the host software
|
||||
- a Readme.txt file in ASCII format which describes the purpose of the
|
||||
project and what can be found in which directories and which files
|
||||
- a reference to http://www.obdev.at/vusb/
|
||||
|
||||
(3) If you improve the driver firmware itself, please give us a free license
|
||||
to your modifications for our commercial license offerings.
|
||||
|
||||
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
181
bootloader/Makefile
Normal file
181
bootloader/Makefile
Normal file
@ -0,0 +1,181 @@
|
||||
# Name: Makefile
|
||||
# Project: USBaspLoader
|
||||
# Author: Christian Starkjohann
|
||||
# Creation Date: 2007-12-10
|
||||
# Tabsize: 4
|
||||
# Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||
# License: GNU GPL v2 (see License.txt)
|
||||
# This Revision: $Id$
|
||||
|
||||
###############################################################################
|
||||
# Configure the following variables according to your AVR.
|
||||
# Program the device with
|
||||
# make fuse # to set the clock generator, boot section size etc.
|
||||
# make flash # to load the boot loader into flash
|
||||
# make lock # to protect the boot loader from overwriting
|
||||
|
||||
F_CPU = 16000000
|
||||
DEVICE = atmega8
|
||||
# BOOTLOADER_ADDRESS is 1800 for 8k devices, 3800 for 16k and 7800 for 32k.
|
||||
BOOTLOADER_ADDRESS = 1800
|
||||
FUSEOPT = $(FUSEOPT_8)
|
||||
LOCKOPT = -U lock:w:0x2f:m
|
||||
|
||||
PROGRAMMER = -c usbasp
|
||||
# PROGRAMMER contains AVRDUDE options to address your programmer
|
||||
|
||||
FUSEOPT_8 = -U lfuse:w:0xbf:m -U hfuse:w:0xc0:m
|
||||
FUSEOPT_88 = -U hfuse:w:0xd6:m -U lfuse:w:0xdf:m -U efuse:w:0x00:m
|
||||
FUSEOPT_168 = -U hfuse:w:0xd6:m -U lfuse:w:0xdf:m -U efuse:w:0x00:m
|
||||
FUSEOPT_328 = -U lfuse:w:0xf7:m -U hfuse:w:0xda:m -U efuse:w:0x03:m
|
||||
# You may have to change the order of these -U commands.
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# ATMega8
|
||||
#---------------------------------------------------------------------
|
||||
# Fuse high byte:
|
||||
# 0xc0 = 1 1 0 0 0 0 0 0 <-- BOOTRST (boot reset vector at 0x1800)
|
||||
# ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0
|
||||
# | | | | | +-------- BOOTSZ1
|
||||
# | | | | + --------- EESAVE (preserve EEPROM over chip erase)
|
||||
# | | | +-------------- CKOPT (full output swing)
|
||||
# | | +---------------- SPIEN (allow serial programming)
|
||||
# | +------------------ WDTON (WDT not always on)
|
||||
# +-------------------- RSTDISBL (reset pin is enabled)
|
||||
# Fuse low byte:
|
||||
# 0x9f = 1 0 0 1 1 1 1 1
|
||||
# ^ ^ \ / \--+--/
|
||||
# | | | +------- CKSEL 3..0 (external >8M crystal)
|
||||
# | | +--------------- SUT 1..0 (crystal osc, BOD enabled)
|
||||
# | +------------------ BODEN (BrownOut Detector enabled)
|
||||
# +-------------------- BODLEVEL (2.7V)
|
||||
#---------------------------------------------------------------------
|
||||
# ATMega88, ATMega168
|
||||
#---------------------------------------------------------------------
|
||||
# Fuse extended byte:
|
||||
# 0x00 = 0 0 0 0 0 0 0 0 <-- BOOTRST (boot reset vector at 0x1800)
|
||||
# \+/
|
||||
# +------- BOOTSZ (00 = 2k bytes)
|
||||
# Fuse high byte:
|
||||
# 0xd6 = 1 1 0 1 0 1 1 0
|
||||
# ^ ^ ^ ^ ^ \-+-/
|
||||
# | | | | | +------ BODLEVEL 0..2 (110 = 1.8 V)
|
||||
# | | | | + --------- EESAVE (preserve EEPROM over chip erase)
|
||||
# | | | +-------------- WDTON (if 0: watchdog always on)
|
||||
# | | +---------------- SPIEN (allow serial programming)
|
||||
# | +------------------ DWEN (debug wire enable)
|
||||
# +-------------------- RSTDISBL (reset pin is enabled)
|
||||
# Fuse low byte:
|
||||
# 0xdf = 1 1 0 1 1 1 1 1
|
||||
# ^ ^ \ / \--+--/
|
||||
# | | | +------- CKSEL 3..0 (external >8M crystal)
|
||||
# | | +--------------- SUT 1..0 (crystal osc, BOD enabled)
|
||||
# | +------------------ CKOUT (if 0: Clock output enabled)
|
||||
# +-------------------- CKDIV8 (if 0: divide by 8)
|
||||
#---------------------------------------------------------------------
|
||||
# ATMega328P
|
||||
#---------------------------------------------------------------------
|
||||
# Fuse extended byte:
|
||||
# 0x03 = - - - - - 0 1 1
|
||||
# \-+-/
|
||||
# +------ BODLEVEL 0..2 (011 = 4.3V)
|
||||
# Fuse high byte:
|
||||
# 0xda = 1 1 0 1 1 0 1 0 <-- BOOTRST (0 = jump to bootloader at start)
|
||||
# ^ ^ ^ ^ ^ \+/
|
||||
# | | | | | +------- BOOTSZ 0..1 (01 = 2KB starting at 0x7800)
|
||||
# | | | | + --------- EESAVE (don't preserve EEPROM over chip erase)
|
||||
# | | | +-------------- WDTON (1 = watchdog disabled at start)
|
||||
# | | +---------------- SPIEN (0 = allow serial programming)
|
||||
# | +------------------ DWEN (1 = debug wire disable)
|
||||
# +-------------------- RSTDISBL (1 = reset pin is enabled)
|
||||
# Fuse low byte:
|
||||
# 0xf7 = 1 1 1 1 0 1 1 1
|
||||
# ^ ^ \ / \--+--/
|
||||
# | | | +------- CKSEL 3..0 (0111 = external full-swing crystal)
|
||||
# | | +--------------- SUT 1..0 (11 = startup time 16K CK/14K + 65ms)
|
||||
# | +------------------ CKOUT (1 = clock output disabled)
|
||||
# +-------------------- CKDIV8 (1 = do not divide clock by 8)
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
||||
# Tools:
|
||||
AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE)
|
||||
CC = avr-gcc
|
||||
|
||||
# Options:
|
||||
DEFINES = #-DDEBUG_LEVEL=2
|
||||
# Remove the -fno-* options when you use gcc 3, it does not understand them
|
||||
CFLAGS = -Wall -Os -fno-move-loop-invariants -fno-tree-scev-cprop -fno-inline-small-functions -I. -mmcu=$(DEVICE) -DF_CPU=$(F_CPU) $(DEFINES)
|
||||
LDFLAGS = -Wl,--relax,--gc-sections -Wl,--section-start=.text=$(BOOTLOADER_ADDRESS)
|
||||
|
||||
OBJECTS = usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o
|
||||
|
||||
# symbolic targets:
|
||||
all: main.hex
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
.S.o:
|
||||
$(CC) $(CFLAGS) -x assembler-with-cpp -c $< -o $@
|
||||
# "-x assembler-with-cpp" should not be necessary since this is the default
|
||||
# file type for the .S (with capital S) extension. However, upper case
|
||||
# characters are not always preserved on Windows. To ensure WinAVR
|
||||
# compatibility define the file type manually.
|
||||
|
||||
.c.s:
|
||||
$(CC) $(CFLAGS) -S $< -o $@
|
||||
|
||||
flash: all
|
||||
$(AVRDUDE) -U flash:w:main.hex:i
|
||||
|
||||
readflash:
|
||||
$(AVRDUDE) -U flash:r:read.hex:i
|
||||
|
||||
fuse:
|
||||
$(AVRDUDE) $(FUSEOPT)
|
||||
|
||||
lock:
|
||||
$(AVRDUDE) $(LOCKOPT)
|
||||
|
||||
read_fuses:
|
||||
$(UISP) --rd_fuses
|
||||
|
||||
clean:
|
||||
rm -f main.hex main.bin *.o usbdrv/*.o main.s usbdrv/oddebug.s usbdrv/usbdrv.s
|
||||
|
||||
# file targets:
|
||||
main.bin: $(OBJECTS)
|
||||
$(CC) $(CFLAGS) -o main.bin $(OBJECTS) $(LDFLAGS)
|
||||
|
||||
main.hex: main.bin
|
||||
rm -f main.hex main.eep.hex
|
||||
avr-objcopy -j .text -j .data -O ihex main.bin main.hex
|
||||
avr-size main.hex
|
||||
|
||||
disasm: main.bin
|
||||
avr-objdump -d main.bin
|
||||
|
||||
cpp:
|
||||
$(CC) $(CFLAGS) -E main.c
|
||||
|
||||
# Special rules for generating hex files for various devices and clock speeds
|
||||
ALLHEXFILES = hexfiles/mega8_12mhz.hex hexfiles/mega8_15mhz.hex hexfiles/mega8_16mhz.hex \
|
||||
hexfiles/mega88_12mhz.hex hexfiles/mega88_15mhz.hex hexfiles/mega88_16mhz.hex hexfiles/mega88_20mhz.hex\
|
||||
hexfiles/mega168_12mhz.hex hexfiles/mega168_15mhz.hex hexfiles/mega168_16mhz.hex hexfiles/mega168_20mhz.hex\
|
||||
hexfiles/mega328p_12mhz.hex hexfiles/mega328p_15mhz.hex hexfiles/mega328p_16mhz.hex hexfiles/mega328p_20mhz.hex
|
||||
|
||||
allhexfiles: $(ALLHEXFILES)
|
||||
$(MAKE) clean
|
||||
avr-size hexfiles/*.hex
|
||||
|
||||
$(ALLHEXFILES):
|
||||
@[ -d hexfiles ] || mkdir hexfiles
|
||||
@device=`echo $@ | sed -e 's|.*/mega||g' -e 's|_.*||g'`; \
|
||||
clock=`echo $@ | sed -e 's|.*_||g' -e 's|mhz.*||g'`; \
|
||||
addr=`echo $$device | sed -e 's/\([0-9]\)8/\1/g' | awk '{printf("%x", ($$1 - 2) * 1024)}'`; \
|
||||
echo "### Make with F_CPU=$${clock}000000 DEVICE=atmega$$device BOOTLOADER_ADDRESS=$$addr"; \
|
||||
$(MAKE) clean; \
|
||||
$(MAKE) main.hex F_CPU=$${clock}000000 DEVICE=atmega$$device BOOTLOADER_ADDRESS=$$addr DEFINES=-DUSE_AUTOCONFIG=1
|
||||
mv main.hex $@
|
160
bootloader/bootloaderconfig.h
Normal file
160
bootloader/bootloaderconfig.h
Normal file
@ -0,0 +1,160 @@
|
||||
/* Name: bootloaderconfig.h
|
||||
* Project: USBaspLoader
|
||||
* Author: Christian Starkjohann
|
||||
* Creation Date: 2007-12-08
|
||||
* Tabsize: 4
|
||||
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||
* License: GNU GPL v2 (see License.txt)
|
||||
* This Revision: $Id$
|
||||
*/
|
||||
|
||||
#ifndef __bootloaderconfig_h_included__
|
||||
#define __bootloaderconfig_h_included__
|
||||
|
||||
/*
|
||||
General Description:
|
||||
This file (together with some settings in Makefile) configures the boot loader
|
||||
according to the hardware.
|
||||
|
||||
This file contains (besides the hardware configuration normally found in
|
||||
usbconfig.h) two functions or macros: bootLoaderInit() and
|
||||
bootLoaderCondition(). Whether you implement them as macros or as static
|
||||
inline functions is up to you, decide based on code size and convenience.
|
||||
|
||||
bootLoaderInit() is called as one of the first actions after reset. It should
|
||||
be a minimum initialization of the hardware so that the boot loader condition
|
||||
can be read. This will usually consist of activating a pull-up resistor for an
|
||||
external jumper which selects boot loader mode.
|
||||
|
||||
bootLoaderCondition() is called immediately after initialization and in each
|
||||
main loop iteration. If it returns TRUE, the boot loader will be active. If it
|
||||
returns FALSE, the boot loader jumps to address 0 (the loaded application)
|
||||
immediately.
|
||||
|
||||
For compatibility with Thomas Fischl's avrusbboot, we also support the macro
|
||||
names BOOTLOADER_INIT and BOOTLOADER_CONDITION for this functionality. If
|
||||
these macros are defined, the boot loader usees them.
|
||||
*/
|
||||
|
||||
/* ---------------------------- Hardware Config ---------------------------- */
|
||||
|
||||
#define USB_CFG_IOPORTNAME D
|
||||
/* This is the port where the USB bus is connected. When you configure it to
|
||||
* "B", the registers PORTB, PINB and DDRB will be used.
|
||||
*/
|
||||
#define USB_CFG_DMINUS_BIT 4
|
||||
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
|
||||
* This may be any bit in the port.
|
||||
*/
|
||||
#define USB_CFG_DPLUS_BIT 2
|
||||
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
|
||||
* This may be any bit in the port. Please note that D+ must also be connected
|
||||
* to interrupt pin INT0!
|
||||
*/
|
||||
#define USB_CFG_CLOCK_KHZ (F_CPU/1000)
|
||||
/* Clock rate of the AVR in MHz. Legal values are 12000, 16000 or 16500.
|
||||
* The 16.5 MHz version of the code requires no crystal, it tolerates +/- 1%
|
||||
* deviation from the nominal frequency. All other rates require a precision
|
||||
* of 2000 ppm and thus a crystal!
|
||||
* Default if not specified: 12 MHz
|
||||
*/
|
||||
|
||||
/* ----------------------- Optional Hardware Config ------------------------ */
|
||||
|
||||
/* #define USB_CFG_PULLUP_IOPORTNAME D */
|
||||
/* If you connect the 1.5k pullup resistor from D- to a port pin instead of
|
||||
* V+, you can connect and disconnect the device from firmware by calling
|
||||
* the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h).
|
||||
* This constant defines the port on which the pullup resistor is connected.
|
||||
*/
|
||||
/* #define USB_CFG_PULLUP_BIT 4 */
|
||||
/* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined
|
||||
* above) where the 1.5k pullup resistor is connected. See description
|
||||
* above for details.
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* ---------------------- feature / code size options ---------------------- */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#define HAVE_EEPROM_PAGED_ACCESS 1
|
||||
/* If HAVE_EEPROM_PAGED_ACCESS is defined to 1, page mode access to EEPROM is
|
||||
* compiled in. Whether page mode or byte mode access is used by AVRDUDE
|
||||
* depends on the target device. Page mode is only used if the device supports
|
||||
* it, e.g. for the ATMega88, 168 etc. You can save quite a bit of memory by
|
||||
* disabling page mode EEPROM access. Costs ~ 138 bytes.
|
||||
*/
|
||||
#define HAVE_EEPROM_BYTE_ACCESS 1
|
||||
/* If HAVE_EEPROM_BYTE_ACCESS is defined to 1, byte mode access to EEPROM is
|
||||
* compiled in. Byte mode is only used if the device (as identified by its
|
||||
* signature) does not support page mode for EEPROM. It is required for
|
||||
* accessing the EEPROM on the ATMega8. Costs ~54 bytes.
|
||||
*/
|
||||
#define BOOTLOADER_CAN_EXIT 1
|
||||
/* If this macro is defined to 1, the boot loader will exit shortly after the
|
||||
* programmer closes the connection to the device. Costs ~36 bytes.
|
||||
*/
|
||||
#define HAVE_CHIP_ERASE 0
|
||||
/* If this macro is defined to 1, the boot loader implements the Chip Erase
|
||||
* ISP command. Otherwise pages are erased on demand before they are written.
|
||||
*/
|
||||
//#define SIGNATURE_BYTES 0x1e, 0x93, 0x07, 0 /* ATMega8 */
|
||||
/* This macro defines the signature bytes returned by the emulated USBasp to
|
||||
* the programmer software. They should match the actual device at least in
|
||||
* memory size and features. If you don't define this, values for ATMega8,
|
||||
* ATMega88, ATMega168 and ATMega328 are guessed correctly.
|
||||
*/
|
||||
|
||||
/* The following block guesses feature options so that the resulting code
|
||||
* should fit into 2k bytes boot block with the given device and clock rate.
|
||||
* Activate by passing "-DUSE_AUTOCONFIG=1" to the compiler.
|
||||
* This requires gcc 3.4.6 for small enough code size!
|
||||
*/
|
||||
#if USE_AUTOCONFIG
|
||||
# undef HAVE_EEPROM_PAGED_ACCESS
|
||||
# define HAVE_EEPROM_PAGED_ACCESS (USB_CFG_CLOCK_KHZ != 15000)
|
||||
# undef HAVE_EEPROM_BYTE_ACCESS
|
||||
# define HAVE_EEPROM_BYTE_ACCESS 1
|
||||
# undef BOOTLOADER_CAN_EXIT
|
||||
# define BOOTLOADER_CAN_EXIT 1
|
||||
# undef SIGNATURE_BYTES
|
||||
#endif /* USE_AUTOCONFIG */
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Example configuration: Port D bit 3 is connected to a jumper which ties
|
||||
* this pin to GND if the boot loader is requested. Initialization allows
|
||||
* several clock cycles for the input voltage to stabilize before
|
||||
* bootLoaderCondition() samples the value.
|
||||
* We use a function for bootLoaderInit() for convenience and a macro for
|
||||
* bootLoaderCondition() for efficiency.
|
||||
*/
|
||||
|
||||
#ifndef __ASSEMBLER__ /* assembler cannot parse function definitions */
|
||||
|
||||
#define JUMPER_BIT 3 /* jumper is connected to this bit in port D, active low */
|
||||
|
||||
#ifndef MCUCSR /* compatibility between ATMega8 and ATMega88 */
|
||||
# define MCUCSR MCUSR
|
||||
#endif
|
||||
|
||||
static inline void bootLoaderInit(void)
|
||||
{
|
||||
PORTD |= (1 << JUMPER_BIT); /* activate pull-up */
|
||||
//if(!(MCUCSR & (1 << EXTRF))) // If this was not an external reset, ignore
|
||||
// leaveBootloader();
|
||||
MCUCSR = 0; /* clear all reset flags for next time */
|
||||
}
|
||||
|
||||
static inline void bootLoaderExit(void)
|
||||
{
|
||||
PORTD = 0; /* undo bootLoaderInit() changes */
|
||||
}
|
||||
|
||||
#define bootLoaderCondition() ((PIND & (1 << JUMPER_BIT)) == 0)
|
||||
|
||||
#endif /* __ASSEMBLER__ */
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#endif /* __bootloader_h_included__ */
|
326
bootloader/main.c
Normal file
326
bootloader/main.c
Normal file
@ -0,0 +1,326 @@
|
||||
/* Name: main.c
|
||||
* Project: USBaspLoader
|
||||
* Author: Christian Starkjohann
|
||||
* Creation Date: 2007-12-08
|
||||
* Tabsize: 4
|
||||
* Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||
* License: GNU GPL v2 (see License.txt)
|
||||
* This Revision: $Id$
|
||||
*/
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <avr/pgmspace.h>
|
||||
#include <avr/wdt.h>
|
||||
#include <avr/boot.h>
|
||||
#include <avr/eeprom.h>
|
||||
#include <util/delay.h>
|
||||
#include <string.h>
|
||||
|
||||
static void leaveBootloader() __attribute__((__noreturn__));
|
||||
|
||||
#include "bootloaderconfig.h"
|
||||
#include "usbdrv/usbdrv.c"
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
/* Request constants used by USBasp */
|
||||
#define USBASP_FUNC_CONNECT 1
|
||||
#define USBASP_FUNC_DISCONNECT 2
|
||||
#define USBASP_FUNC_TRANSMIT 3
|
||||
#define USBASP_FUNC_READFLASH 4
|
||||
#define USBASP_FUNC_ENABLEPROG 5
|
||||
#define USBASP_FUNC_WRITEFLASH 6
|
||||
#define USBASP_FUNC_READEEPROM 7
|
||||
#define USBASP_FUNC_WRITEEEPROM 8
|
||||
#define USBASP_FUNC_SETLONGADDRESS 9
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
#ifndef ulong
|
||||
# define ulong unsigned long
|
||||
#endif
|
||||
#ifndef uint
|
||||
# define uint unsigned int
|
||||
#endif
|
||||
|
||||
/* defaults if not in config file: */
|
||||
#ifndef HAVE_EEPROM_PAGED_ACCESS
|
||||
# define HAVE_EEPROM_PAGED_ACCESS 0
|
||||
#endif
|
||||
#ifndef HAVE_EEPROM_BYTE_ACCESS
|
||||
# define HAVE_EEPROM_BYTE_ACCESS 0
|
||||
#endif
|
||||
#ifndef BOOTLOADER_CAN_EXIT
|
||||
# define BOOTLOADER_CAN_EXIT 0
|
||||
#endif
|
||||
|
||||
/* allow compatibility with avrusbboot's bootloaderconfig.h: */
|
||||
#ifdef BOOTLOADER_INIT
|
||||
# define bootLoaderInit() BOOTLOADER_INIT
|
||||
# define bootLoaderExit()
|
||||
#endif
|
||||
#ifdef BOOTLOADER_CONDITION
|
||||
# define bootLoaderCondition() BOOTLOADER_CONDITION
|
||||
#endif
|
||||
|
||||
/* device compatibility: */
|
||||
#ifndef GICR /* ATMega*8 don't have GICR, use MCUCR instead */
|
||||
# define GICR MCUCR
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
#if (FLASHEND) > 0xffff /* we need long addressing */
|
||||
# define CURRENT_ADDRESS currentAddress.l
|
||||
# define addr_t ulong
|
||||
#else
|
||||
# define CURRENT_ADDRESS currentAddress.w[0]
|
||||
# define addr_t uint
|
||||
#endif
|
||||
|
||||
typedef union longConverter{
|
||||
addr_t l;
|
||||
uint w[sizeof(addr_t)/2];
|
||||
uchar b[sizeof(addr_t)];
|
||||
}longConverter_t;
|
||||
|
||||
static uchar requestBootLoaderExit;
|
||||
static longConverter_t currentAddress; /* in bytes */
|
||||
static uchar bytesRemaining;
|
||||
static uchar isLastPage;
|
||||
#if HAVE_EEPROM_PAGED_ACCESS
|
||||
static uchar currentRequest;
|
||||
#else
|
||||
static const uchar currentRequest = 0;
|
||||
#endif
|
||||
|
||||
static const uchar signatureBytes[4] = {
|
||||
#ifdef SIGNATURE_BYTES
|
||||
SIGNATURE_BYTES
|
||||
#elif defined (__AVR_ATmega8__) || defined (__AVR_ATmega8HVA__)
|
||||
0x1e, 0x93, 0x07, 0
|
||||
#elif defined (__AVR_ATmega48__) || defined (__AVR_ATmega48P__)
|
||||
0x1e, 0x92, 0x05, 0
|
||||
#elif defined (__AVR_ATmega88__) || defined (__AVR_ATmega88P__)
|
||||
0x1e, 0x93, 0x0a, 0
|
||||
#elif defined (__AVR_ATmega168__) || defined (__AVR_ATmega168P__)
|
||||
0x1e, 0x94, 0x06, 0
|
||||
#elif defined (__AVR_ATmega328P__)
|
||||
0x1e, 0x95, 0x0f, 0
|
||||
#else
|
||||
# error "Device signature is not known, please edit main.c!"
|
||||
#endif
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
static void (*nullVector)(void) __attribute__((__noreturn__));
|
||||
|
||||
static void leaveBootloader()
|
||||
{
|
||||
DBG1(0x01, 0, 0);
|
||||
bootLoaderExit();
|
||||
cli();
|
||||
USB_INTR_ENABLE = 0;
|
||||
USB_INTR_CFG = 0; /* also reset config bits */
|
||||
GICR = (1 << IVCE); /* enable change of interrupt vectors */
|
||||
GICR = (0 << IVSEL); /* move interrupts to application flash section */
|
||||
/* We must go through a global function pointer variable instead of writing
|
||||
* ((void (*)(void))0)();
|
||||
* because the compiler optimizes a constant 0 to "rcall 0" which is not
|
||||
* handled correctly by the assembler.
|
||||
*/
|
||||
nullVector();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
uchar usbFunctionSetup(uchar data[8])
|
||||
{
|
||||
usbRequest_t *rq = (void *)data;
|
||||
uchar len = 0;
|
||||
static uchar replyBuffer[4];
|
||||
|
||||
usbMsgPtr = (usbMsgPtr_t)replyBuffer;
|
||||
if(rq->bRequest == USBASP_FUNC_TRANSMIT){ /* emulate parts of ISP protocol */
|
||||
uchar rval = 0;
|
||||
usbWord_t address;
|
||||
address.bytes[1] = rq->wValue.bytes[1];
|
||||
address.bytes[0] = rq->wIndex.bytes[0];
|
||||
if(rq->wValue.bytes[0] == 0x30){ /* read signature */
|
||||
rval = rq->wIndex.bytes[0] & 3;
|
||||
rval = signatureBytes[rval];
|
||||
#if HAVE_EEPROM_BYTE_ACCESS
|
||||
}else if(rq->wValue.bytes[0] == 0xa0){ /* read EEPROM byte */
|
||||
rval = eeprom_read_byte((void *)address.word);
|
||||
}else if(rq->wValue.bytes[0] == 0xc0){ /* write EEPROM byte */
|
||||
eeprom_write_byte((void *)address.word, rq->wIndex.bytes[1]);
|
||||
#endif
|
||||
#if HAVE_CHIP_ERASE
|
||||
}else if(rq->wValue.bytes[0] == 0xac && rq->wValue.bytes[1] == 0x80){ /* chip erase */
|
||||
addr_t addr;
|
||||
for(addr = 0; addr < FLASHEND + 1 - 2048; addr += SPM_PAGESIZE) {
|
||||
/* wait and erase page */
|
||||
DBG1(0x33, 0, 0);
|
||||
# ifndef NO_FLASH_WRITE
|
||||
boot_spm_busy_wait();
|
||||
cli();
|
||||
boot_page_erase(addr);
|
||||
sei();
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
}else{
|
||||
/* ignore all others, return default value == 0 */
|
||||
}
|
||||
replyBuffer[3] = rval;
|
||||
len = 4;
|
||||
}else if(rq->bRequest == USBASP_FUNC_ENABLEPROG){
|
||||
/* replyBuffer[0] = 0; is never touched and thus always 0 which means success */
|
||||
len = 1;
|
||||
}else if(rq->bRequest >= USBASP_FUNC_READFLASH && rq->bRequest <= USBASP_FUNC_SETLONGADDRESS){
|
||||
currentAddress.w[0] = rq->wValue.word;
|
||||
if(rq->bRequest == USBASP_FUNC_SETLONGADDRESS){
|
||||
#if (FLASHEND) > 0xffff
|
||||
currentAddress.w[1] = rq->wIndex.word;
|
||||
#endif
|
||||
}else{
|
||||
bytesRemaining = rq->wLength.bytes[0];
|
||||
/* if(rq->bRequest == USBASP_FUNC_WRITEFLASH) only evaluated during writeFlash anyway */
|
||||
isLastPage = rq->wIndex.bytes[1] & 0x02;
|
||||
#if HAVE_EEPROM_PAGED_ACCESS
|
||||
currentRequest = rq->bRequest;
|
||||
#endif
|
||||
len = 0xff; /* hand over to usbFunctionRead() / usbFunctionWrite() */
|
||||
}
|
||||
#if BOOTLOADER_CAN_EXIT
|
||||
}else if(rq->bRequest == USBASP_FUNC_DISCONNECT){
|
||||
requestBootLoaderExit = 1; /* allow proper shutdown/close of connection */
|
||||
#endif
|
||||
}else{
|
||||
/* ignore: USBASP_FUNC_CONNECT */
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
uchar usbFunctionWrite(uchar *data, uchar len)
|
||||
{
|
||||
uchar isLast;
|
||||
|
||||
DBG1(0x31, (void *)¤tAddress.l, 4);
|
||||
if(len > bytesRemaining)
|
||||
len = bytesRemaining;
|
||||
bytesRemaining -= len;
|
||||
isLast = bytesRemaining == 0;
|
||||
if(currentRequest >= USBASP_FUNC_READEEPROM){
|
||||
uchar i;
|
||||
for(i = 0; i < len; i++){
|
||||
eeprom_write_byte((void *)(currentAddress.w[0]++), *data++);
|
||||
}
|
||||
}else{
|
||||
uchar i;
|
||||
for(i = 0; i < len;){
|
||||
#if !HAVE_CHIP_ERASE
|
||||
if((currentAddress.w[0] & (SPM_PAGESIZE - 1)) == 0){ /* if page start: erase */
|
||||
DBG1(0x33, 0, 0);
|
||||
# ifndef NO_FLASH_WRITE
|
||||
cli();
|
||||
boot_page_erase(CURRENT_ADDRESS); /* erase page */
|
||||
sei();
|
||||
boot_spm_busy_wait(); /* wait until page is erased */
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
i += 2;
|
||||
DBG1(0x32, 0, 0);
|
||||
cli();
|
||||
boot_page_fill(CURRENT_ADDRESS, *(short *)data);
|
||||
sei();
|
||||
CURRENT_ADDRESS += 2;
|
||||
data += 2;
|
||||
/* write page when we cross page boundary or we have the last partial page */
|
||||
if((currentAddress.w[0] & (SPM_PAGESIZE - 1)) == 0 || (isLast && i >= len && isLastPage)){
|
||||
DBG1(0x34, 0, 0);
|
||||
#ifndef NO_FLASH_WRITE
|
||||
cli();
|
||||
boot_page_write(CURRENT_ADDRESS - 2);
|
||||
sei();
|
||||
boot_spm_busy_wait();
|
||||
cli();
|
||||
boot_rww_enable();
|
||||
sei();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
DBG1(0x35, (void *)¤tAddress.l, 4);
|
||||
}
|
||||
return isLast;
|
||||
}
|
||||
|
||||
uchar usbFunctionRead(uchar *data, uchar len)
|
||||
{
|
||||
uchar i;
|
||||
|
||||
if(len > bytesRemaining)
|
||||
len = bytesRemaining;
|
||||
bytesRemaining -= len;
|
||||
for(i = 0; i < len; i++){
|
||||
if(currentRequest >= USBASP_FUNC_READEEPROM){
|
||||
*data = eeprom_read_byte((void *)currentAddress.w[0]);
|
||||
}else{
|
||||
*data = pgm_read_byte((void *)CURRENT_ADDRESS);
|
||||
}
|
||||
data++;
|
||||
CURRENT_ADDRESS++;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
static void initForUsbConnectivity(void)
|
||||
{
|
||||
uchar i = 0;
|
||||
|
||||
usbInit();
|
||||
/* enforce USB re-enumerate: */
|
||||
usbDeviceDisconnect(); /* do this while interrupts are disabled */
|
||||
while(--i){ /* fake USB disconnect for > 250 ms */
|
||||
wdt_reset();
|
||||
_delay_ms(1);
|
||||
}
|
||||
usbDeviceConnect();
|
||||
sei();
|
||||
}
|
||||
|
||||
int __attribute__((noreturn)) main(void)
|
||||
{
|
||||
/* initialize */
|
||||
wdt_disable(); /* main app may have enabled watchdog */
|
||||
bootLoaderInit();
|
||||
odDebugInit();
|
||||
DBG1(0x00, 0, 0);
|
||||
#ifndef NO_FLASH_WRITE
|
||||
GICR = (1 << IVCE); /* enable change of interrupt vectors */
|
||||
GICR = (1 << IVSEL); /* move interrupts to boot flash section */
|
||||
#endif
|
||||
if(bootLoaderCondition()){
|
||||
uchar i = 0, j = 0;
|
||||
initForUsbConnectivity();
|
||||
do{
|
||||
usbPoll();
|
||||
#if BOOTLOADER_CAN_EXIT
|
||||
if(requestBootLoaderExit){
|
||||
if(--i == 0){
|
||||
if(--j == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}while(bootLoaderCondition()); /* main event loop */
|
||||
}
|
||||
leaveBootloader();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
323
bootloader/usbconfig.h
Normal file
323
bootloader/usbconfig.h
Normal file
@ -0,0 +1,323 @@
|
||||
/* Name: usbconfig.h
|
||||
* Project: V-USB, virtual USB port for Atmel's(r) AVR(r) microcontrollers
|
||||
* Author: Christian Starkjohann
|
||||
* Creation Date: 2005-04-01
|
||||
* Tabsize: 4
|
||||
* Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH
|
||||
* License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
|
||||
* This Revision: $Id$
|
||||
*/
|
||||
|
||||
#ifndef __usbconfig_h_included__
|
||||
#define __usbconfig_h_included__
|
||||
|
||||
/* YOU SHOULD NOT NEED TO MODIFY THIS FILE! All configurations are supposed
|
||||
* to go into bootloaderconfig.h!
|
||||
*/
|
||||
|
||||
/* ---------------------------- Hardware Config ---------------------------- */
|
||||
|
||||
/* All the port and pin assignments, as well as the clock speed and CRC
|
||||
setting are now in bootloaderconfig.h: */
|
||||
|
||||
#include "bootloaderconfig.h"
|
||||
|
||||
/* --------------------------- Functional Range ---------------------------- */
|
||||
|
||||
#define USB_CFG_HAVE_INTRIN_ENDPOINT 0
|
||||
/* Define this to 1 if you want to compile a version with two endpoints: The
|
||||
* default control endpoint 0 and an interrupt-in endpoint (any other endpoint
|
||||
* number).
|
||||
*/
|
||||
#define USB_CFG_HAVE_INTRIN_ENDPOINT3 0
|
||||
/* Define this to 1 if you want to compile a version with three endpoints: The
|
||||
* default control endpoint 0, an interrupt-in endpoint 3 (or the number
|
||||
* configured below) and a catch-all default interrupt-in endpoint as above.
|
||||
* You must also define USB_CFG_HAVE_INTRIN_ENDPOINT to 1 for this feature.
|
||||
*/
|
||||
#define USB_CFG_EP3_NUMBER 3
|
||||
/* If the so-called endpoint 3 is used, it can now be configured to any other
|
||||
* endpoint number (except 0) with this macro. Default if undefined is 3.
|
||||
*/
|
||||
/* #define USB_INITIAL_DATATOKEN USBPID_DATA1 */
|
||||
/* The above macro defines the startup condition for data toggling on the
|
||||
* interrupt/bulk endpoints 1 and 3. Defaults to USBPID_DATA1.
|
||||
* Since the token is toggled BEFORE sending any data, the first packet is
|
||||
* sent with the oposite value of this configuration!
|
||||
*/
|
||||
#define USB_CFG_IMPLEMENT_HALT 0
|
||||
/* Define this to 1 if you also want to implement the ENDPOINT_HALT feature
|
||||
* for endpoint 1 (interrupt endpoint). Although you may not need this feature,
|
||||
* it is required by the standard. We have made it a config option because it
|
||||
* bloats the code considerably.
|
||||
*/
|
||||
#define USB_CFG_SUPPRESS_INTR_CODE 0
|
||||
/* Define this to 1 if you want to declare interrupt-in endpoints, but don't
|
||||
* want to send any data over them. If this macro is defined to 1, functions
|
||||
* usbSetInterrupt() and usbSetInterrupt3() are omitted. This is useful if
|
||||
* you need the interrupt-in endpoints in order to comply to an interface
|
||||
* (e.g. HID), but never want to send any data. This option saves a couple
|
||||
* of bytes in flash memory and the transmit buffers in RAM.
|
||||
*/
|
||||
#define USB_CFG_INTR_POLL_INTERVAL 10
|
||||
/* If you compile a version with endpoint 1 (interrupt-in), this is the poll
|
||||
* interval. The value is in milliseconds and must not be less than 10 ms for
|
||||
* low speed devices.
|
||||
*/
|
||||
#ifndef USB_CFG_IS_SELF_POWERED // allow bootloaderconfig.h to override
|
||||
#define USB_CFG_IS_SELF_POWERED 0
|
||||
#endif
|
||||
/* Define this to 1 if the device has its own power supply. Set it to 0 if the
|
||||
* device is powered from the USB bus.
|
||||
*/
|
||||
#ifndef USB_CFG_MAX_BUS_POWER // allow bootloaderconfig.h to override
|
||||
#define USB_CFG_MAX_BUS_POWER 100
|
||||
#endif
|
||||
/* Set this variable to the maximum USB bus power consumption of your device.
|
||||
* The value is in milliamperes. [It will be divided by two since USB
|
||||
* communicates power requirements in units of 2 mA.]
|
||||
*/
|
||||
#define USB_CFG_IMPLEMENT_FN_WRITE 1
|
||||
/* Set this to 1 if you want usbFunctionWrite() to be called for control-out
|
||||
* transfers. Set it to 0 if you don't need it and want to save a couple of
|
||||
* bytes.
|
||||
*/
|
||||
#define USB_CFG_IMPLEMENT_FN_READ 1
|
||||
/* Set this to 1 if you need to send control replies which are generated
|
||||
* "on the fly" when usbFunctionRead() is called. If you only want to send
|
||||
* data from a static buffer, set it to 0 and return the data from
|
||||
* usbFunctionSetup(). This saves a couple of bytes.
|
||||
*/
|
||||
#define USB_CFG_IMPLEMENT_FN_WRITEOUT 0
|
||||
/* Define this to 1 if you want to use interrupt-out (or bulk out) endpoints.
|
||||
* You must implement the function usbFunctionWriteOut() which receives all
|
||||
* interrupt/bulk data sent to any endpoint other than 0. The endpoint number
|
||||
* can be found in 'usbRxToken'.
|
||||
*/
|
||||
#define USB_CFG_HAVE_FLOWCONTROL 0
|
||||
/* Define this to 1 if you want flowcontrol over USB data. See the definition
|
||||
* of the macros usbDisableAllRequests() and usbEnableAllRequests() in
|
||||
* usbdrv.h.
|
||||
*/
|
||||
#define USB_CFG_DRIVER_FLASH_PAGE 0
|
||||
/* If the device has more than 64 kBytes of flash, define this to the 64 k page
|
||||
* where the driver's constants (descriptors) are located. Or in other words:
|
||||
* Define this to 1 for boot loaders on the ATMega128.
|
||||
*/
|
||||
#define USB_CFG_LONG_TRANSFERS 0
|
||||
/* Define this to 1 if you want to send/receive blocks of more than 254 bytes
|
||||
* in a single control-in or control-out transfer. Note that the capability
|
||||
* for long transfers increases the driver size.
|
||||
*/
|
||||
/* #define USB_RX_USER_HOOK(data, len) if(usbRxToken == (uchar)USBPID_SETUP) blinkLED(); */
|
||||
/* This macro is a hook if you want to do unconventional things. If it is
|
||||
* defined, it's inserted at the beginning of received message processing.
|
||||
* If you eat the received message and don't want default processing to
|
||||
* proceed, do a return after doing your things. One possible application
|
||||
* (besides debugging) is to flash a status LED on each packet.
|
||||
*/
|
||||
/* #define USB_RESET_HOOK(resetStarts) if(!resetStarts){hadUsbReset();} */
|
||||
/* This macro is a hook if you need to know when an USB RESET occurs. It has
|
||||
* one parameter which distinguishes between the start of RESET state and its
|
||||
* end.
|
||||
*/
|
||||
/* #define USB_SET_ADDRESS_HOOK() hadAddressAssigned(); */
|
||||
/* This macro (if defined) is executed when a USB SET_ADDRESS request was
|
||||
* received.
|
||||
*/
|
||||
#define USB_COUNT_SOF 0
|
||||
/* define this macro to 1 if you need the global variable "usbSofCount" which
|
||||
* counts SOF packets. This feature requires that the hardware interrupt is
|
||||
* connected to D- instead of D+.
|
||||
*/
|
||||
/* #ifdef __ASSEMBLER__
|
||||
* macro myAssemblerMacro
|
||||
* in YL, TCNT0
|
||||
* sts timer0Snapshot, YL
|
||||
* endm
|
||||
* #endif
|
||||
* #define USB_SOF_HOOK myAssemblerMacro
|
||||
* This macro (if defined) is executed in the assembler module when a
|
||||
* Start Of Frame condition is detected. It is recommended to define it to
|
||||
* the name of an assembler macro which is defined here as well so that more
|
||||
* than one assembler instruction can be used. The macro may use the register
|
||||
* YL and modify SREG. If it lasts longer than a couple of cycles, USB messages
|
||||
* immediately after an SOF pulse may be lost and must be retried by the host.
|
||||
* What can you do with this hook? Since the SOF signal occurs exactly every
|
||||
* 1 ms (unless the host is in sleep mode), you can use it to tune OSCCAL in
|
||||
* designs running on the internal RC oscillator.
|
||||
* Please note that Start Of Frame detection works only if D- is wired to the
|
||||
* interrupt, not D+. THIS IS DIFFERENT THAN MOST EXAMPLES!
|
||||
*/
|
||||
#define USB_CFG_CHECK_DATA_TOGGLING 0
|
||||
/* define this macro to 1 if you want to filter out duplicate data packets
|
||||
* sent by the host. Duplicates occur only as a consequence of communication
|
||||
* errors, when the host does not receive an ACK. Please note that you need to
|
||||
* implement the filtering yourself in usbFunctionWriteOut() and
|
||||
* usbFunctionWrite(). Use the global usbCurrentDataToken and a static variable
|
||||
* for each control- and out-endpoint to check for duplicate packets.
|
||||
*/
|
||||
#define USB_CFG_HAVE_MEASURE_FRAME_LENGTH 0
|
||||
/* define this macro to 1 if you want the function usbMeasureFrameLength()
|
||||
* compiled in. This function can be used to calibrate the AVR's RC oscillator.
|
||||
*/
|
||||
#define USB_USE_FAST_CRC 0
|
||||
/* The assembler module has two implementations for the CRC algorithm. One is
|
||||
* faster, the other is smaller. This CRC routine is only used for transmitted
|
||||
* messages where timing is not critical. The faster routine needs 31 cycles
|
||||
* per byte while the smaller one needs 61 to 69 cycles. The faster routine
|
||||
* may be worth the 32 bytes bigger code size if you transmit lots of data and
|
||||
* run the AVR close to its limit.
|
||||
*/
|
||||
|
||||
/* -------------------------- Device Description --------------------------- */
|
||||
|
||||
#define USB_CFG_VENDOR_ID 0xc0, 0x16 /* = 0x16c0 = 5824 = voti.nl */
|
||||
/* USB vendor ID for the device, low byte first. If you have registered your
|
||||
* own Vendor ID, define it here. Otherwise you may use one of obdev's free
|
||||
* shared VID/PID pairs. Be sure to read USB-IDs-for-free.txt for rules!
|
||||
*/
|
||||
#define USB_CFG_DEVICE_ID 0xdc, 0x05 /* = 0x05dc = 1500 */
|
||||
/* This is the ID of the product, low byte first. It is interpreted in the
|
||||
* scope of the vendor ID. If you have registered your own VID with usb.org
|
||||
* or if you have licensed a PID from somebody else, define it here. Otherwise
|
||||
* you may use one of obdev's free shared VID/PID pairs. See the file
|
||||
* USB-IDs-for-free.txt for details!
|
||||
*/
|
||||
#define USB_CFG_DEVICE_VERSION 0x02, 0x01
|
||||
/* Version number of the device: Minor number first, then major number.
|
||||
*/
|
||||
#define USB_CFG_VENDOR_NAME 'w','w','w','.','f','i','s','c','h','l','.','d','e'
|
||||
#define USB_CFG_VENDOR_NAME_LEN 13
|
||||
/* These two values define the vendor name returned by the USB device. The name
|
||||
* must be given as a list of characters under single quotes. The characters
|
||||
* are interpreted as Unicode (UTF-16) entities.
|
||||
* If you don't want a vendor name string, undefine these macros.
|
||||
* ALWAYS define a vendor name containing your Internet domain name if you use
|
||||
* obdev's free shared VID/PID pair. See the file USB-IDs-for-free.txt for
|
||||
* details.
|
||||
*/
|
||||
#define USB_CFG_DEVICE_NAME 'U', 'S', 'B', 'a', 's', 'p'
|
||||
#define USB_CFG_DEVICE_NAME_LEN 6
|
||||
/* Same as above for the device name. If you don't want a device name, undefine
|
||||
* the macros. See the file USB-IDs-for-free.txt before you assign a name if
|
||||
* you use a shared VID/PID.
|
||||
*/
|
||||
/*#define USB_CFG_SERIAL_NUMBER 'N', 'o', 'n', 'e' */
|
||||
/*#define USB_CFG_SERIAL_NUMBER_LEN 0 */
|
||||
/* Same as above for the serial number. If you don't want a serial number,
|
||||
* undefine the macros.
|
||||
* It may be useful to provide the serial number through other means than at
|
||||
* compile time. See the section about descriptor properties below for how
|
||||
* to fine tune control over USB descriptors such as the string descriptor
|
||||
* for the serial number.
|
||||
*/
|
||||
#define USB_CFG_DEVICE_CLASS 0xff /* set to 0 if deferred to interface */
|
||||
#define USB_CFG_DEVICE_SUBCLASS 0
|
||||
/* See USB specification if you want to conform to an existing device class.
|
||||
* Class 0xff is "vendor specific".
|
||||
*/
|
||||
#define USB_CFG_INTERFACE_CLASS 0 /* define class here if not at device level */
|
||||
#define USB_CFG_INTERFACE_SUBCLASS 0
|
||||
#define USB_CFG_INTERFACE_PROTOCOL 0
|
||||
/* See USB specification if you want to conform to an existing device class or
|
||||
* protocol. The following classes must be set at interface level:
|
||||
* HID class is 3, no subclass and protocol required (but may be useful!)
|
||||
* CDC class is 2, use subclass 2 and protocol 1 for ACM
|
||||
*/
|
||||
/* #define USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH 42 */
|
||||
/* Define this to the length of the HID report descriptor, if you implement
|
||||
* an HID device. Otherwise don't define it or define it to 0.
|
||||
* If you use this define, you must add a PROGMEM character array named
|
||||
* "usbHidReportDescriptor" to your code which contains the report descriptor.
|
||||
* Don't forget to keep the array and this define in sync!
|
||||
*/
|
||||
|
||||
#define USB_PUBLIC static
|
||||
/* Use the define above if you #include usbdrv.c instead of linking against it.
|
||||
* This technique saves a couple of bytes in flash memory.
|
||||
*/
|
||||
|
||||
/* ------------------- Fine Control over USB Descriptors ------------------- */
|
||||
/* If you don't want to use the driver's default USB descriptors, you can
|
||||
* provide our own. These can be provided as (1) fixed length static data in
|
||||
* flash memory, (2) fixed length static data in RAM or (3) dynamically at
|
||||
* runtime in the function usbFunctionDescriptor(). See usbdrv.h for more
|
||||
* information about this function.
|
||||
* Descriptor handling is configured through the descriptor's properties. If
|
||||
* no properties are defined or if they are 0, the default descriptor is used.
|
||||
* Possible properties are:
|
||||
* + USB_PROP_IS_DYNAMIC: The data for the descriptor should be fetched
|
||||
* at runtime via usbFunctionDescriptor(). If the usbMsgPtr mechanism is
|
||||
* used, the data is in FLASH by default. Add property USB_PROP_IS_RAM if
|
||||
* you want RAM pointers.
|
||||
* + USB_PROP_IS_RAM: The data returned by usbFunctionDescriptor() or found
|
||||
* in static memory is in RAM, not in flash memory.
|
||||
* + USB_PROP_LENGTH(len): If the data is in static memory (RAM or flash),
|
||||
* the driver must know the descriptor's length. The descriptor itself is
|
||||
* found at the address of a well known identifier (see below).
|
||||
* List of static descriptor names (must be declared PROGMEM if in flash):
|
||||
* char usbDescriptorDevice[];
|
||||
* char usbDescriptorConfiguration[];
|
||||
* char usbDescriptorHidReport[];
|
||||
* char usbDescriptorString0[];
|
||||
* int usbDescriptorStringVendor[];
|
||||
* int usbDescriptorStringDevice[];
|
||||
* int usbDescriptorStringSerialNumber[];
|
||||
* Other descriptors can't be provided statically, they must be provided
|
||||
* dynamically at runtime.
|
||||
*
|
||||
* Descriptor properties are or-ed or added together, e.g.:
|
||||
* #define USB_CFG_DESCR_PROPS_DEVICE (USB_PROP_IS_RAM | USB_PROP_LENGTH(18))
|
||||
*
|
||||
* The following descriptors are defined:
|
||||
* USB_CFG_DESCR_PROPS_DEVICE
|
||||
* USB_CFG_DESCR_PROPS_CONFIGURATION
|
||||
* USB_CFG_DESCR_PROPS_STRINGS
|
||||
* USB_CFG_DESCR_PROPS_STRING_0
|
||||
* USB_CFG_DESCR_PROPS_STRING_VENDOR
|
||||
* USB_CFG_DESCR_PROPS_STRING_PRODUCT
|
||||
* USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER
|
||||
* USB_CFG_DESCR_PROPS_HID
|
||||
* USB_CFG_DESCR_PROPS_HID_REPORT
|
||||
* USB_CFG_DESCR_PROPS_UNKNOWN (for all descriptors not handled by the driver)
|
||||
*
|
||||
* Note about string descriptors: String descriptors are not just strings, they
|
||||
* are Unicode strings prefixed with a 2 byte header. Example:
|
||||
* int serialNumberDescriptor[] = {
|
||||
* USB_STRING_DESCRIPTOR_HEADER(6),
|
||||
* 'S', 'e', 'r', 'i', 'a', 'l'
|
||||
* };
|
||||
*/
|
||||
|
||||
#define USB_CFG_DESCR_PROPS_DEVICE 0
|
||||
#define USB_CFG_DESCR_PROPS_CONFIGURATION 0
|
||||
#define USB_CFG_DESCR_PROPS_STRINGS 0
|
||||
#define USB_CFG_DESCR_PROPS_STRING_0 0
|
||||
#define USB_CFG_DESCR_PROPS_STRING_VENDOR 0
|
||||
#define USB_CFG_DESCR_PROPS_STRING_PRODUCT 0
|
||||
#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0
|
||||
#define USB_CFG_DESCR_PROPS_HID 0
|
||||
#define USB_CFG_DESCR_PROPS_HID_REPORT 0
|
||||
#define USB_CFG_DESCR_PROPS_UNKNOWN 0
|
||||
|
||||
#define usbMsgPtr_t unsigned short // scalar type yields shortest code
|
||||
|
||||
/* ----------------------- Optional MCU Description ------------------------ */
|
||||
|
||||
/* The following configurations have working defaults in usbdrv.h. You
|
||||
* usually don't need to set them explicitly. Only if you want to run
|
||||
* the driver on a device which is not yet supported or with a compiler
|
||||
* which is not fully supported (such as IAR C) or if you use a differnt
|
||||
* interrupt than INT0, you may have to define some of these.
|
||||
*/
|
||||
/* #define USB_INTR_CFG MCUCR */
|
||||
/* #define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) */
|
||||
/* #define USB_INTR_CFG_CLR 0 */
|
||||
/* #define USB_INTR_ENABLE GIMSK */
|
||||
/* #define USB_INTR_ENABLE_BIT INT0 */
|
||||
/* #define USB_INTR_PENDING GIFR */
|
||||
/* #define USB_INTR_PENDING_BIT INTF0 */
|
||||
/* #define USB_INTR_VECTOR INT0_vect */
|
||||
|
||||
#endif /* __usbconfig_h_included__ */
|
329
bootloader/usbdrv/Changelog.txt
Normal file
329
bootloader/usbdrv/Changelog.txt
Normal file
@ -0,0 +1,329 @@
|
||||
This file documents changes in the firmware-only USB driver for atmel's AVR
|
||||
microcontrollers. New entries are always appended to the end of the file.
|
||||
Scroll down to the bottom to see the most recent changes.
|
||||
|
||||
2005-04-01:
|
||||
- Implemented endpoint 1 as interrupt-in endpoint.
|
||||
- Moved all configuration options to usbconfig.h which is not part of the
|
||||
driver.
|
||||
- Changed interface for usbVendorSetup().
|
||||
- Fixed compatibility with ATMega8 device.
|
||||
- Various minor optimizations.
|
||||
|
||||
2005-04-11:
|
||||
- Changed interface to application: Use usbFunctionSetup(), usbFunctionRead()
|
||||
and usbFunctionWrite() now. Added configuration options to choose which
|
||||
of these functions to compile in.
|
||||
- Assembler module delivers receive data non-inverted now.
|
||||
- Made register and bit names compatible with more AVR devices.
|
||||
|
||||
2005-05-03:
|
||||
- Allow address of usbRxBuf on any memory page as long as the buffer does
|
||||
not cross 256 byte page boundaries.
|
||||
- Better device compatibility: works with Mega88 now.
|
||||
- Code optimization in debugging module.
|
||||
- Documentation updates.
|
||||
|
||||
2006-01-02:
|
||||
- Added (free) default Vendor- and Product-IDs bought from voti.nl.
|
||||
- Added USBID-License.txt file which defines the rules for using the free
|
||||
shared VID/PID pair.
|
||||
- Added Readme.txt to the usbdrv directory which clarifies administrative
|
||||
issues.
|
||||
|
||||
2006-01-25:
|
||||
- Added "configured state" to become more standards compliant.
|
||||
- Added "HALT" state for interrupt endpoint.
|
||||
- Driver passes the "USB Command Verifier" test from usb.org now.
|
||||
- Made "serial number" a configuration option.
|
||||
- Minor optimizations, we now recommend compiler option "-Os" for best
|
||||
results.
|
||||
- Added a version number to usbdrv.h
|
||||
|
||||
2006-02-03:
|
||||
- New configuration variable USB_BUFFER_SECTION for the memory section where
|
||||
the USB rx buffer will go. This defaults to ".bss" if not defined. Since
|
||||
this buffer MUST NOT cross 256 byte pages (not even touch a page at the
|
||||
end), the user may want to pass a linker option similar to
|
||||
"-Wl,--section-start=.mybuffer=0x800060".
|
||||
- Provide structure for usbRequest_t.
|
||||
- New defines for USB constants.
|
||||
- Prepared for HID implementations.
|
||||
- Increased data size limit for interrupt transfers to 8 bytes.
|
||||
- New macro usbInterruptIsReady() to query interrupt buffer state.
|
||||
|
||||
2006-02-18:
|
||||
- Ensure that the data token which is sent as an ack to an OUT transfer is
|
||||
always zero sized. This fixes a bug where the host reports an error after
|
||||
sending an out transfer to the device, although all data arrived at the
|
||||
device.
|
||||
- Updated docs in usbdrv.h to reflect changed API in usbFunctionWrite().
|
||||
|
||||
* Release 2006-02-20
|
||||
|
||||
- Give a compiler warning when compiling with debugging turned on.
|
||||
- Added Oleg Semyonov's changes for IAR-cc compatibility.
|
||||
- Added new (optional) functions usbDeviceConnect() and usbDeviceDisconnect()
|
||||
(also thanks to Oleg!).
|
||||
- Rearranged tests in usbPoll() to save a couple of instructions in the most
|
||||
likely case that no actions are pending.
|
||||
- We need a delay between the SET ADDRESS request until the new address
|
||||
becomes active. This delay was handled in usbPoll() until now. Since the
|
||||
spec says that the delay must not exceed 2ms, previous versions required
|
||||
aggressive polling during the enumeration phase. We have now moved the
|
||||
handling of the delay into the interrupt routine.
|
||||
- We must not reply with NAK to a SETUP transaction. We can only achieve this
|
||||
by making sure that the rx buffer is empty when SETUP tokens are expected.
|
||||
We therefore don't pass zero sized data packets from the status phase of
|
||||
a transfer to usbPoll(). This change MAY cause troubles if you rely on
|
||||
receiving a less than 8 bytes long packet in usbFunctionWrite() to
|
||||
identify the end of a transfer. usbFunctionWrite() will NEVER be called
|
||||
with a zero length.
|
||||
|
||||
* Release 2006-03-14
|
||||
|
||||
- Improved IAR C support: tiny memory model, more devices
|
||||
- Added template usbconfig.h file under the name usbconfig-prototype.h
|
||||
|
||||
* Release 2006-03-26
|
||||
|
||||
- Added provision for one more interrupt-in endpoint (endpoint 3).
|
||||
- Added provision for one interrupt-out endpoint (endpoint 1).
|
||||
- Added flowcontrol macros for USB.
|
||||
- Added provision for custom configuration descriptor.
|
||||
- Allow ANY two port bits for D+ and D-.
|
||||
- Merged (optional) receive endpoint number into global usbRxToken variable.
|
||||
- Use USB_CFG_IOPORTNAME instead of USB_CFG_IOPORT. We now construct the
|
||||
variable name from the single port letter instead of computing the address
|
||||
of related ports from the output-port address.
|
||||
|
||||
* Release 2006-06-26
|
||||
|
||||
- Updated documentation in usbdrv.h and usbconfig-prototype.h to reflect the
|
||||
new features.
|
||||
- Removed "#warning" directives because IAR does not understand them. Use
|
||||
unused static variables instead to generate a warning.
|
||||
- Do not include <avr/io.h> when compiling with IAR.
|
||||
- Introduced USB_CFG_DESCR_PROPS_* in usbconfig.h to configure how each
|
||||
USB descriptor should be handled. It is now possible to provide descriptor
|
||||
data in Flash, RAM or dynamically at runtime.
|
||||
- STALL is now a status in usbTxLen* instead of a message. We can now conform
|
||||
to the spec and leave the stall status pending until it is cleared.
|
||||
- Made usbTxPacketCnt1 and usbTxPacketCnt3 public. This allows the
|
||||
application code to reset data toggling on interrupt pipes.
|
||||
|
||||
* Release 2006-07-18
|
||||
|
||||
- Added an #if !defined __ASSEMBLER__ to the warning in usbdrv.h. This fixes
|
||||
an assembler error.
|
||||
- usbDeviceDisconnect() takes pull-up resistor to high impedance now.
|
||||
|
||||
* Release 2007-02-01
|
||||
|
||||
- Merged in some code size improvements from usbtiny (thanks to Dick
|
||||
Streefland for these optimizations!)
|
||||
- Special alignment requirement for usbRxBuf not required any more. Thanks
|
||||
again to Dick Streefland for this hint!
|
||||
- Reverted to "#warning" instead of unused static variables -- new versions
|
||||
of IAR CC should handle this directive.
|
||||
- Changed Open Source license to GNU GPL v2 in order to make linking against
|
||||
other free libraries easier. We no longer require publication of the
|
||||
circuit diagrams, but we STRONGLY encourage it. If you improve the driver
|
||||
itself, PLEASE grant us a royalty free license to your changes for our
|
||||
commercial license.
|
||||
|
||||
* Release 2007-03-29
|
||||
|
||||
- New configuration option "USB_PUBLIC" in usbconfig.h.
|
||||
- Set USB version number to 1.10 instead of 1.01.
|
||||
- Code used USB_CFG_DESCR_PROPS_STRING_DEVICE and
|
||||
USB_CFG_DESCR_PROPS_STRING_PRODUCT inconsistently. Changed all occurrences
|
||||
to USB_CFG_DESCR_PROPS_STRING_PRODUCT.
|
||||
- New assembler module for 16.5 MHz RC oscillator clock with PLL in receiver
|
||||
code.
|
||||
- New assembler module for 16 MHz crystal.
|
||||
- usbdrvasm.S contains common code only, clock-specific parts have been moved
|
||||
to usbdrvasm12.S, usbdrvasm16.S and usbdrvasm165.S respectively.
|
||||
|
||||
* Release 2007-06-25
|
||||
|
||||
- 16 MHz module: Do SE0 check in stuffed bits as well.
|
||||
|
||||
* Release 2007-07-07
|
||||
|
||||
- Define hi8(x) for IAR compiler to limit result to 8 bits. This is necessary
|
||||
for negative values.
|
||||
- Added 15 MHz module contributed by V. Bosch.
|
||||
- Interrupt vector name can now be configured. This is useful if somebody
|
||||
wants to use a different hardware interrupt than INT0.
|
||||
|
||||
* Release 2007-08-07
|
||||
|
||||
- Moved handleIn3 routine in usbdrvasm16.S so that relative jump range is
|
||||
not exceeded.
|
||||
- More config options: USB_RX_USER_HOOK(), USB_INITIAL_DATATOKEN,
|
||||
USB_COUNT_SOF
|
||||
- USB_INTR_PENDING can now be a memory address, not just I/O
|
||||
|
||||
* Release 2007-09-19
|
||||
|
||||
- Split out common parts of assembler modules into separate include file
|
||||
- Made endpoint numbers configurable so that given interface definitions
|
||||
can be matched. See USB_CFG_EP3_NUMBER in usbconfig-prototype.h.
|
||||
- Store endpoint number for interrupt/bulk-out so that usbFunctionWriteOut()
|
||||
can handle any number of endpoints.
|
||||
- Define usbDeviceConnect() and usbDeviceDisconnect() even if no
|
||||
USB_CFG_PULLUP_IOPORTNAME is defined. Directly set D+ and D- to 0 in this
|
||||
case.
|
||||
|
||||
* Release 2007-12-01
|
||||
|
||||
- Optimize usbDeviceConnect() and usbDeviceDisconnect() for less code size
|
||||
when USB_CFG_PULLUP_IOPORTNAME is not defined.
|
||||
|
||||
* Release 2007-12-13
|
||||
|
||||
- Renamed all include-only assembler modules from *.S to *.inc so that
|
||||
people don't add them to their project sources.
|
||||
- Distribute leap bits in tx loop more evenly for 16 MHz module.
|
||||
- Use "macro" and "endm" instead of ".macro" and ".endm" for IAR
|
||||
- Avoid compiler warnings for constant expr range by casting some values in
|
||||
USB descriptors.
|
||||
|
||||
* Release 2008-01-21
|
||||
|
||||
- Fixed bug in 15 and 16 MHz module where the new address set with
|
||||
SET_ADDRESS was already accepted at the next NAK or ACK we send, not at
|
||||
the next data packet we send. This caused problems when the host polled
|
||||
too fast. Thanks to Alexander Neumann for his help and patience debugging
|
||||
this issue!
|
||||
|
||||
* Release 2008-02-05
|
||||
|
||||
- Fixed bug in 16.5 MHz module where a register was used in the interrupt
|
||||
handler before it was pushed. This bug was introduced with version
|
||||
2007-09-19 when common parts were moved to a separate file.
|
||||
- Optimized CRC routine (thanks to Reimar Doeffinger).
|
||||
|
||||
* Release 2008-02-16
|
||||
|
||||
- Removed outdated IAR compatibility stuff (code sections).
|
||||
- Added hook macros for USB_RESET_HOOK() and USB_SET_ADDRESS_HOOK().
|
||||
- Added optional routine usbMeasureFrameLength() for calibration of the
|
||||
internal RC oscillator.
|
||||
|
||||
* Release 2008-02-28
|
||||
|
||||
- USB_INITIAL_DATATOKEN defaults to USBPID_DATA1 now, which means that we
|
||||
start with sending USBPID_DATA0.
|
||||
- Changed defaults in usbconfig-prototype.h
|
||||
- Added free USB VID/PID pair for MIDI class devices
|
||||
- Restructured AVR-USB as separate package, not part of PowerSwitch any more.
|
||||
|
||||
* Release 2008-04-18
|
||||
|
||||
- Restructured usbdrv.c so that it is easier to read and understand.
|
||||
- Better code optimization with gcc 4.
|
||||
- If a second interrupt in endpoint is enabled, also add it to config
|
||||
descriptor.
|
||||
- Added config option for long transfers (above 254 bytes), see
|
||||
USB_CFG_LONG_TRANSFERS in usbconfig.h.
|
||||
- Added 20 MHz module contributed by Jeroen Benschop.
|
||||
|
||||
* Release 2008-05-13
|
||||
|
||||