mirror of
https://github.com/radiomanV/TL866.git
synced 2025-06-18 14:25:38 -04:00
Initial commit
This commit is contained in:
commit
cf85433f29
22
.gitattributes
vendored
Normal file
22
.gitattributes
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
|
||||
# Custom for Visual Studio
|
||||
*.cs diff=csharp
|
||||
*.sln merge=union
|
||||
*.csproj merge=union
|
||||
*.vbproj merge=union
|
||||
*.fsproj merge=union
|
||||
*.dbproj merge=union
|
||||
|
||||
# Standard to msysgit
|
||||
*.doc diff=astextplain
|
||||
*.DOC diff=astextplain
|
||||
*.docx diff=astextplain
|
||||
*.DOCX diff=astextplain
|
||||
*.dot diff=astextplain
|
||||
*.DOT diff=astextplain
|
||||
*.pdf diff=astextplain
|
||||
*.PDF diff=astextplain
|
||||
*.rtf diff=astextplain
|
||||
*.RTF diff=astextplain
|
215
.gitignore
vendored
Normal file
215
.gitignore
vendored
Normal file
@ -0,0 +1,215 @@
|
||||
#################
|
||||
## Eclipse
|
||||
#################
|
||||
|
||||
*.pydevproject
|
||||
.project
|
||||
.metadata
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.classpath
|
||||
.settings/
|
||||
.loadpath
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
|
||||
# CDT-specific
|
||||
.cproject
|
||||
|
||||
# PDT-specific
|
||||
.buildpath
|
||||
|
||||
|
||||
#################
|
||||
## Visual Studio
|
||||
#################
|
||||
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.sln.docstates
|
||||
|
||||
# Build results
|
||||
|
||||
[Dd]ebug/
|
||||
[Rr]elease/
|
||||
x64/
|
||||
build/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.log
|
||||
*.scc
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# NCrunch
|
||||
*.ncrunch*
|
||||
.*crunch*.local.xml
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.Publish.xml
|
||||
*.pubxml
|
||||
|
||||
# NuGet Packages Directory
|
||||
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
|
||||
#packages/
|
||||
|
||||
# Windows Azure Build Output
|
||||
csx
|
||||
*.build.csdef
|
||||
|
||||
# Windows Store app package directory
|
||||
AppPackages/
|
||||
|
||||
# Others
|
||||
sql/
|
||||
*.Cache
|
||||
ClientBin/
|
||||
[Ss]tyle[Cc]op.*
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.[Pp]ublish.xml
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file to a newer
|
||||
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
App_Data/*.mdf
|
||||
App_Data/*.ldf
|
||||
|
||||
#############
|
||||
## Windows detritus
|
||||
#############
|
||||
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Mac crap
|
||||
.DS_Store
|
||||
|
||||
|
||||
#############
|
||||
## Python
|
||||
#############
|
||||
|
||||
*.py[co]
|
||||
|
||||
# Packages
|
||||
*.egg
|
||||
*.egg-info
|
||||
dist/
|
||||
build/
|
||||
eggs/
|
||||
parts/
|
||||
var/
|
||||
sdist/
|
||||
develop-eggs/
|
||||
.installed.cfg
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
.coverage
|
||||
.tox
|
||||
|
||||
#Translations
|
||||
*.mo
|
||||
|
||||
#Mr Developer
|
||||
.mr.developer.cfg
|
339
LICENSE.md
Normal file
339
LICENSE.md
Normal file
@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser 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.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser General
|
||||
Public License instead of this License.
|
39
TL866_Updater.X/18f87j50.lkr
Normal file
39
TL866_Updater.X/18f87j50.lkr
Normal file
@ -0,0 +1,39 @@
|
||||
// File: 18f87j50.lkr
|
||||
// Modified linker script for the PIC18F87J50 processor
|
||||
|
||||
LIBPATH .
|
||||
|
||||
FILES c018i.o
|
||||
FILES clib.lib
|
||||
FILES p18f87j50.lib
|
||||
|
||||
CODEPAGE NAME=bootloader START=0x0 END=0x017FF PROTECTED
|
||||
CODEPAGE NAME=vectors START=0x01800 END=0x01829 PROTECTED
|
||||
CODEPAGE NAME=page START=0x0182A END=0x1FBFF
|
||||
CODEPAGE NAME=config START=0x1FFF8 END=0x1FFFD PROTECTED
|
||||
CODEPAGE NAME=devid START=0x3FFFFE END=0x3FFFFF PROTECTED
|
||||
|
||||
ACCESSBANK NAME=accessram START=0x0 END=0x5F
|
||||
DATABANK NAME=gpr0 START=0x60 END=0xFF
|
||||
DATABANK NAME=gpr1 START=0x100 END=0x1FF
|
||||
DATABANK NAME=gpr2 START=0x200 END=0x2FF
|
||||
DATABANK NAME=gpr3 START=0x300 END=0x3FF
|
||||
DATABANK NAME=gpr4 START=0x400 END=0x4FF
|
||||
DATABANK NAME=gpr5 START=0x500 END=0x5FF
|
||||
DATABANK NAME=gpr6 START=0x600 END=0x6FF
|
||||
DATABANK NAME=gpr7 START=0x700 END=0x7FF
|
||||
DATABANK NAME=big START=0x800 END=0xBFF PROTECTED
|
||||
//DATABANK NAME=gpr9 START=0x900 END=0x9FF
|
||||
//DATABANK NAME=gpr10 START=0xA00 END=0xAFF
|
||||
//DATABANK NAME=gpr11 START=0xB00 END=0xBFF
|
||||
DATABANK NAME=gpr12 START=0xC00 END=0xCFF
|
||||
DATABANK NAME=gpr13 START=0xD00 END=0xDFF
|
||||
DATABANK NAME=gpr14 START=0xE00 END=0xEFF
|
||||
DATABANK NAME=gpr15 START=0xF00 END=0xF3F
|
||||
DATABANK NAME=sfr15 START=0xF40 END=0xF5F PROTECTED
|
||||
ACCESSBANK NAME=accesssfr START=0xF60 END=0xFFF PROTECTED
|
||||
|
||||
SECTION NAME=big_buffer RAM=big
|
||||
SECTION NAME=CONFIG ROM=config
|
||||
|
||||
STACK SIZE=0x100 RAM=gpr14
|
59
TL866_Updater.X/HardwareProfile.h
Normal file
59
TL866_Updater.X/HardwareProfile.h
Normal file
@ -0,0 +1,59 @@
|
||||
/************************************************************************
|
||||
HardwareProfile.h
|
||||
|
||||
WFF USB Generic HID Demonstration 3
|
||||
usbGenericHidCommunication reference firmware 3_0_0_0
|
||||
Copyright (C) 2011 Simon Inns
|
||||
|
||||
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 3 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/>.
|
||||
|
||||
Email: simon.inns@gmail.com
|
||||
|
||||
************************************************************************/
|
||||
|
||||
#ifndef HARDWAREPROFILE_H
|
||||
#define HARDWAREPROFILE_H
|
||||
|
||||
// USB stack hardware selection options ----------------------------------------------------------------
|
||||
|
||||
// (This section is the set of definitions required by the MCHPFSUSB framework.)
|
||||
|
||||
// Uncomment the following define if you wish to use the self-power sense feature
|
||||
// and define the port, pin and tris for the power sense pin below:
|
||||
// #define USE_SELF_POWER_SENSE_IO
|
||||
#define tris_self_power TRISAbits.TRISA2
|
||||
#if defined(USE_SELF_POWER_SENSE_IO)
|
||||
#define self_power PORTAbits.RA2
|
||||
#else
|
||||
#define self_power 1
|
||||
#endif
|
||||
|
||||
// Uncomment the following define if you wish to use the bus-power sense feature
|
||||
// and define the port, pin and tris for the power sense pin below:
|
||||
//#define USE_USB_BUS_SENSE_IO
|
||||
#define tris_usb_bus_sense TRISAbits.TRISA1
|
||||
#if defined(USE_USB_BUS_SENSE_IO)
|
||||
#define USB_BUS_SENSE PORTAbits.RA1
|
||||
#else
|
||||
#define USB_BUS_SENSE 1
|
||||
#endif
|
||||
|
||||
// Application specific hardware definitions ------------------------------------------------------------
|
||||
|
||||
// Oscillator frequency (48Mhz with a 20Mhz external oscillator)
|
||||
#define CLOCK_FREQ 48000000
|
||||
#define GetSystemClock() CLOCK_FREQ
|
||||
#define GetInstructionClock() CLOCK_FREQ
|
||||
|
||||
#endif
|
108
TL866_Updater.X/Makefile
Normal file
108
TL866_Updater.X/Makefile
Normal file
@ -0,0 +1,108 @@
|
||||
#
|
||||
# There exist several targets which are by default empty and which can be
|
||||
# used for execution of your targets. These targets are usually executed
|
||||
# before and after some main targets. They are:
|
||||
#
|
||||
# .build-pre: called before 'build' target
|
||||
# .build-post: called after 'build' target
|
||||
# .clean-pre: called before 'clean' target
|
||||
# .clean-post: called after 'clean' target
|
||||
# .clobber-pre: called before 'clobber' target
|
||||
# .clobber-post: called after 'clobber' target
|
||||
# .all-pre: called before 'all' target
|
||||
# .all-post: called after 'all' target
|
||||
# .help-pre: called before 'help' target
|
||||
# .help-post: called after 'help' target
|
||||
#
|
||||
# Targets beginning with '.' are not intended to be called on their own.
|
||||
#
|
||||
# Main targets can be executed directly, and they are:
|
||||
#
|
||||
# build build a specific configuration
|
||||
# clean remove built files from a configuration
|
||||
# clobber remove all built files
|
||||
# all build all configurations
|
||||
# help print help mesage
|
||||
#
|
||||
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
|
||||
# .help-impl are implemented in nbproject/makefile-impl.mk.
|
||||
#
|
||||
# Available make variables:
|
||||
#
|
||||
# CND_BASEDIR base directory for relative paths
|
||||
# CND_DISTDIR default top distribution directory (build artifacts)
|
||||
# CND_BUILDDIR default top build directory (object files, ...)
|
||||
# CONF name of current configuration
|
||||
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
|
||||
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
|
||||
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
|
||||
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
|
||||
# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
|
||||
# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
|
||||
#
|
||||
# NOCDDL
|
||||
|
||||
|
||||
# Environment
|
||||
MKDIR=mkdir
|
||||
CP=cp
|
||||
CCADMIN=CCadmin
|
||||
RANLIB=ranlib
|
||||
|
||||
|
||||
# build
|
||||
build: .build-post
|
||||
|
||||
.build-pre:
|
||||
# Add your pre 'build' code here...
|
||||
|
||||
.build-post: .build-impl
|
||||
# Add your post 'build' code here...
|
||||
|
||||
|
||||
# clean
|
||||
clean: .clean-post
|
||||
|
||||
.clean-pre:
|
||||
# Add your pre 'clean' code here...
|
||||
|
||||
.clean-post: .clean-impl
|
||||
# Add your post 'clean' code here...
|
||||
|
||||
|
||||
# clobber
|
||||
clobber: .clobber-post
|
||||
|
||||
.clobber-pre:
|
||||
# Add your pre 'clobber' code here...
|
||||
|
||||
.clobber-post: .clobber-impl
|
||||
# Add your post 'clobber' code here...
|
||||
|
||||
|
||||
# all
|
||||
all: .all-post
|
||||
|
||||
.all-pre:
|
||||
# Add your pre 'all' code here...
|
||||
|
||||
.all-post: .all-impl
|
||||
# Add your post 'all' code here...
|
||||
|
||||
|
||||
# help
|
||||
help: .help-post
|
||||
|
||||
.help-pre:
|
||||
# Add your pre 'help' code here...
|
||||
|
||||
.help-post: .help-impl
|
||||
# Add your post 'help' code here...
|
||||
|
||||
|
||||
|
||||
# include project implementation makefile
|
||||
include nbproject/Makefile-impl.mk
|
||||
|
||||
# include project make variables
|
||||
include nbproject/Makefile-variables.mk
|
44
TL866_Updater.X/config_bits.h
Normal file
44
TL866_Updater.X/config_bits.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* File: config_bits.h
|
||||
* Author: Radioman
|
||||
*
|
||||
* Created on 09 aprilie 2013, 07:13
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_BITS_H
|
||||
#define CONFIG_BITS_H
|
||||
|
||||
// PIC18F87J50 Configuration Bit Settings
|
||||
// CONFIG1L
|
||||
#pragma config WDTEN = OFF // Watchdog Timer Enable bit (WDT disabled (control is placed on SWDTEN bit))
|
||||
#pragma config PLLDIV = 4 // PLL Prescaler Selection bits (Divide by 4 (16 MHz oscillator input))
|
||||
#pragma config STVREN = ON // Stack Overflow/Underflow Reset Enable bit (Reset on stack overflow/underflow enabled)
|
||||
#pragma config XINST = OFF // Extended Instruction Set Enable bit (Instruction set extension and Indexed Addressing mode disabled (Legacy mode))
|
||||
#pragma config DEBUG = OFF // Debugging off
|
||||
|
||||
// CONFIG1H
|
||||
#pragma config CPUDIV = OSC1 // CPU System Clock Postscaler (No CPU system clock divide); 48Mhz CPU Clock
|
||||
#pragma config CP0 = OFF // Code Protection bit (Program memory is not code-protected)
|
||||
|
||||
// CONFIG2L
|
||||
#pragma config FOSC = HSPLL // Oscillator Selection bits (HS oscillator, PLL enabled, HSPLL used by USB)
|
||||
#pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor enabled)
|
||||
#pragma config IESO = ON // Two-Speed Start-up (Internal/External Oscillator Switchover) Control bit (Two-Speed Start-up enabled)
|
||||
|
||||
// CONFIG2H
|
||||
#pragma config WDTPS = 32768 // Watchdog Timer Postscaler Select bits (1:32768)
|
||||
|
||||
// CONFIG3L
|
||||
#pragma config EASHFT = ON // External Address Bus Shift Enable bit (Address shifting enabled, address on external bus is offset to start at 000000h)
|
||||
#pragma config MODE = MM // External Memory Bus Configuration bits (Microcontroller mode - External bus disabled)
|
||||
#pragma config BW = 16 // Data Bus Width Select bit (16-bit external bus mode)
|
||||
#pragma config WAIT = OFF // External Bus Wait Enable bit (Wait states on the external bus are disabled)
|
||||
|
||||
// CONFIG3H
|
||||
#pragma config CCP2MX = DEFAULT // ECCP2 MUX bit (ECCP2/P2A is multiplexed with RC1)
|
||||
#pragma config ECCPMX = DEFAULT // ECCPx MUX bit (ECCP1 outputs (P1B/P1C) are multiplexed with RE6 and RE5; ECCP3 outputs (P3B/P3C) are multiplexed with RE4 and RE3)
|
||||
#pragma config PMPMX = DEFAULT // PMP Pin Multiplex bit (PMP pins placed on EMB)
|
||||
#pragma config MSSPMSK = MSK7 // MSSP Address Masking Mode Select bit (7-Bit Address Masking mode enable)
|
||||
|
||||
#endif /* CONFIG_BITS_H */
|
||||
|
938
TL866_Updater.X/main.c
Normal file
938
TL866_Updater.X/main.c
Normal file
@ -0,0 +1,938 @@
|
||||
/*
|
||||
* File: main.c
|
||||
* Author: Radioman
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <USB/usb.h>
|
||||
#include <USB/usb_function_generic.h>
|
||||
|
||||
#include "HardwareProfile.h"
|
||||
#include "main.h"
|
||||
#include "config_bits.h"
|
||||
#include <delays.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/**********************************************REMAPPED VECTORS********************************************************/
|
||||
#define REMAPPED_RESET_VECTOR_ADDRESS 0x1800
|
||||
#define REMAPPED_HIGH_INTERRUPT_VECTOR_ADDRESS 0x1808
|
||||
#define REMAPPED_LOW_INTERRUPT_VECTOR_ADDRESS 0x1818
|
||||
|
||||
extern void _startup(void);
|
||||
void high_ISR(void);
|
||||
void low_ISR(void);
|
||||
|
||||
|
||||
#pragma code REMAPPED_RESET_VECTOR = REMAPPED_RESET_VECTOR_ADDRESS
|
||||
|
||||
void _reset(void)
|
||||
{
|
||||
_asm goto _startup _endasm
|
||||
}
|
||||
|
||||
#pragma code REMAPPED_HIGH_INTERRUPT_VECTOR = REMAPPED_HIGH_INTERRUPT_VECTOR_ADDRESS
|
||||
|
||||
void Remapped_High_ISR(void)
|
||||
{
|
||||
_asm goto high_ISR _endasm
|
||||
}
|
||||
#pragma code REMAPPED_LOW_INTERRUPT_VECTOR = REMAPPED_LOW_INTERRUPT_VECTOR_ADDRESS
|
||||
|
||||
void Remapped_Low_ISR(void)
|
||||
{
|
||||
_asm goto low_ISR _endasm
|
||||
}
|
||||
|
||||
#pragma code HIGH_INTERRUPT_VECTOR = 0x08
|
||||
|
||||
void High_ISR(void)
|
||||
{
|
||||
_asm goto REMAPPED_HIGH_INTERRUPT_VECTOR_ADDRESS _endasm
|
||||
}
|
||||
#pragma code LOW_INTERRUPT_VECTOR = 0x18
|
||||
|
||||
void Low_ISR(void)
|
||||
{
|
||||
_asm goto REMAPPED_LOW_INTERRUPT_VECTOR_ADDRESS _endasm
|
||||
}
|
||||
#pragma code
|
||||
/*************************************END REMAPPED VECTORS********************************************************/
|
||||
|
||||
|
||||
#define DEVICE_TYPE_LOCATION 0x11B4 //This ROM location will tell us the device type
|
||||
#define DEVICE_COPY_PROTECT 0x1FFF9 //Copy protect config byte location
|
||||
|
||||
//ROM constants
|
||||
#pragma romdata _signature = 0x1FBFC
|
||||
const rom unsigned char sigbytes[] = {0x55, 0xAA, 0xA5, 0x5A};
|
||||
#pragma romdata
|
||||
|
||||
far rom unsigned char devcode[] = {'C', 'o', 'd', 'e', 'd', 'u', 'm', 'p'};
|
||||
far rom unsigned char serial[] = {
|
||||
'0', '0', '0', '0', '0', '0', '0', '0',
|
||||
'0', '0', '0', '0', '0', '0', '0', '0',
|
||||
'0', '0', '0', '0', '0', '0', '0', '0'
|
||||
};
|
||||
|
||||
far rom unsigned char A_Table[] = {
|
||||
0xA4, 0x1E, 0x42, 0x8C, 0x3C, 0x76, 0x14, 0xC7, 0xB8, 0xB5, 0x81, 0x4A, 0x13, 0x37, 0x7C, 0x0A,
|
||||
0xFE, 0x3B, 0x63, 0xC1, 0xD5, 0xFD, 0x8C, 0x39, 0xD1, 0x1F, 0x22, 0xC7, 0x7F, 0x4D, 0x2F, 0x15,
|
||||
0x71, 0x21, 0xF9, 0x25, 0x33, 0x44, 0x92, 0x93, 0x80, 0xD7, 0xAB, 0x1B, 0xB6, 0x11, 0xA9, 0x5A,
|
||||
0x88, 0x29, 0xFB, 0xD9, 0xF3, 0x76, 0xAA, 0x47, 0x73, 0xD5, 0x31, 0x06, 0x76, 0x4B, 0x90, 0xEA,
|
||||
0x11, 0xEB, 0x9C, 0x3D, 0xF2, 0xFA, 0x99, 0x06, 0x96, 0x52, 0x0A, 0x8A, 0xBC, 0x04, 0xC8, 0x14,
|
||||
0x19, 0x41, 0x52, 0xF2, 0x4D, 0x7B, 0x64, 0xC0, 0x16, 0xC7, 0xCB, 0xE9, 0xC3, 0x86, 0x77, 0x6A,
|
||||
0xEC, 0x44, 0xD2, 0xD9, 0x61, 0xE0, 0x50, 0xA6, 0x60, 0xED, 0x47, 0xA2, 0x0B, 0x59, 0x02, 0xBD,
|
||||
0x18, 0x4C, 0x11, 0x14, 0xCB, 0x53, 0xE2, 0x2B, 0x21, 0xBE, 0x96, 0x76, 0x4F, 0x47, 0x0D, 0x1F,
|
||||
0x6A, 0xF4, 0x43, 0x03, 0x68, 0x3E, 0xE0, 0xFE, 0x47, 0x72, 0x0A, 0x68, 0x8C, 0x58, 0x7E, 0xDF,
|
||||
0xEF, 0x13, 0xDF, 0x47, 0x55, 0x48, 0x4D, 0x10, 0xFE, 0x82, 0x3A, 0xB7, 0x00, 0xD5, 0x79, 0x90,
|
||||
0xF4, 0xC2, 0x98, 0xC2, 0xEF, 0x5B, 0x70, 0x93, 0xB4, 0xA7, 0xFA, 0xE6, 0x27, 0x48, 0x65, 0x01,
|
||||
0x05, 0x5B, 0x65, 0x94, 0xD3, 0xA0, 0xCD, 0xF7, 0x14, 0xDB, 0x60, 0xB4, 0xBF, 0x7A, 0xE4, 0x45,
|
||||
0xF0, 0x77, 0x79, 0x1F, 0xDE, 0x80, 0x29, 0xEF, 0x0D, 0x56, 0xC0, 0x23, 0xC5, 0x73, 0xDE, 0xAC,
|
||||
0xC2, 0xEF, 0x4A, 0x02, 0x2D, 0xA4, 0x89, 0x69, 0xCB, 0x91, 0xB0, 0x74, 0x75, 0x7C, 0x76, 0xC7,
|
||||
0xC8, 0xDB, 0x8D, 0x20, 0x1D, 0xF5, 0x33, 0x99, 0xBB, 0x45, 0x04, 0x27, 0x4C, 0x1F, 0x12, 0x67,
|
||||
0x8E, 0x96, 0x37, 0x9A, 0x4B, 0x9C, 0xAA, 0xED, 0x8B, 0x6B, 0xD1, 0xFF, 0x08, 0x24, 0x56, 0x9D
|
||||
};
|
||||
|
||||
far rom unsigned char CS_Table[] = {
|
||||
0x0B, 0x08, 0x07, 0x18, 0xEC, 0xC7, 0xDF, 0x8C, 0xD6, 0x76, 0xCE, 0x10, 0x9F, 0x61, 0x7C, 0xF5,
|
||||
0x61, 0x09, 0xFB, 0x59, 0xD0, 0x24, 0xB4, 0x4F, 0xCA, 0xE4, 0xA1, 0x3A, 0x30, 0x7C, 0xBD, 0x7A,
|
||||
0xF5, 0xE1, 0xB9, 0x4B, 0x74, 0xCD, 0xF1, 0xE9, 0x07, 0x0A, 0x9E, 0xF9, 0xD5, 0xED, 0x4D, 0x24,
|
||||
0xEB, 0x21, 0x90, 0x05, 0x8F, 0xA5, 0xF3, 0x45, 0xD0, 0x18, 0x31, 0x04, 0x62, 0x35, 0xA8, 0x7B,
|
||||
0xA9, 0x9A, 0x0B, 0xE0, 0x14, 0xCD, 0x57, 0x8A, 0xAC, 0x80, 0x08, 0x56, 0xED, 0x14, 0x8C, 0x49,
|
||||
0xD4, 0x5D, 0xF8, 0x77, 0x39, 0xA5, 0xFA, 0x23, 0x5F, 0xF3, 0x0E, 0x27, 0xCA, 0x8D, 0xF5, 0x97,
|
||||
0x50, 0xBB, 0x64, 0xA1, 0x73, 0xCE, 0xF9, 0xB7, 0xEE, 0x61, 0x72, 0xF1, 0x8E, 0xDF, 0x21, 0xAC,
|
||||
0x43, 0x45, 0x9B, 0x78, 0x77, 0x29, 0xB1, 0x31, 0x9E, 0xFC, 0xA1, 0x6B, 0x0F, 0x8C, 0x8D, 0x13,
|
||||
0x12, 0xCC, 0x2B, 0x54, 0x3A, 0xD8, 0xBF, 0xB8, 0xF5, 0x34, 0x46, 0x90, 0x61, 0x54, 0xF4, 0x95,
|
||||
0x61, 0x62, 0xE1, 0xCF, 0xF1, 0x3B, 0x00, 0xB6, 0xB6, 0xBB, 0x50, 0x98, 0xD9, 0x3A, 0x56, 0x3A,
|
||||
0x16, 0x56, 0xCA, 0xC2, 0x10, 0xF3, 0x91, 0xD4, 0xE8, 0x81, 0xEB, 0xFC, 0x0D, 0x7E, 0xEE, 0x4C,
|
||||
0x56, 0x3B, 0x33, 0x46, 0x4E, 0xE2, 0xCF, 0xFC, 0xCF, 0xB8, 0x84, 0x75, 0xD2, 0xA0, 0x39, 0x53,
|
||||
0x85, 0xE1, 0xA8, 0xB3, 0x9E, 0x28, 0x57, 0x55, 0xEF, 0xD1, 0xC9, 0xFD, 0x3B, 0x62, 0xF5, 0x18,
|
||||
0x49, 0x58, 0xF7, 0xA3, 0x36, 0x27, 0x06, 0x49, 0x0F, 0x7C, 0xA6, 0xCB, 0xA0, 0xC5, 0x1E, 0xA5,
|
||||
0x86, 0xF3, 0x2D, 0xEF, 0x8C, 0x7E, 0xF9, 0x81, 0x34, 0xAA, 0x48, 0x5A, 0x93, 0x0A, 0xF2, 0x43,
|
||||
0x62, 0x42, 0x97, 0xAF, 0x53, 0x10, 0x8D, 0xE6, 0xA1, 0x8E, 0x1C, 0x62, 0xEB, 0xB1, 0xEE, 0x79
|
||||
};
|
||||
|
||||
far rom unsigned char config_bytes[] = {
|
||||
0xA8, 0xF3, 0x05, 0xFF, 0xF8, 0xF6, 0xFF, 0xFF
|
||||
};
|
||||
|
||||
|
||||
//RAM buffers
|
||||
#pragma udata big_buffer
|
||||
unsigned char buffer[0x400]; //1Kbyte data buffer
|
||||
#pragma udata USB_VARIABLES=0x500
|
||||
DATA_PACKET rxdatapacket;//USB receive buffer
|
||||
unsigned char txdatapacket[USBGEN_EP_SIZE];//USB transmit buffer
|
||||
#pragma udata CONTEXT_SWITCH=0x700
|
||||
unsigned long int reset_switch;//Here is the RAM context switch location
|
||||
#pragma udata
|
||||
|
||||
|
||||
//Used function prototypes
|
||||
unsigned short crc16(unsigned char *data, unsigned short len);
|
||||
void make_crc(void);
|
||||
void decrypt(unsigned char version);
|
||||
void encrypt(unsigned char version);
|
||||
void FlashErase(unsigned long address);
|
||||
void WriteBlock(unsigned long address, unsigned char* buffer);
|
||||
void WriteBuffer(unsigned long address);
|
||||
void WriteBootloader(unsigned char version);
|
||||
void WriteConfig(unsigned char version);
|
||||
void WriteInfo(unsigned char *info_ptr);
|
||||
void load_shiftregister(unsigned char value);
|
||||
void config_io();
|
||||
void ReadProgMem(void);
|
||||
void ProcessIo(void);
|
||||
|
||||
//Global variables
|
||||
const far rom unsigned short* crc16Table = (const far rom void*) 0x1FD50;//Pointer to crc16 table in ROM
|
||||
const far rom unsigned short* infoTable = (const far rom void*) 0x1FD00;//Pointer to encrypted info area (80bytes) in ROM
|
||||
USB_HANDLE USBOutHandle;
|
||||
USB_HANDLE USBInHandle;
|
||||
volatile WORD led_cnt;
|
||||
unsigned char info[80];
|
||||
|
||||
#pragma interruptlow high_ISR
|
||||
|
||||
void high_ISR(void)
|
||||
{
|
||||
#if defined(USB_INTERRUPT)
|
||||
// Perform USB device tasks
|
||||
USBDeviceTasks();
|
||||
#endif
|
||||
}
|
||||
|
||||
#pragma interruptlow low_ISR
|
||||
|
||||
void low_ISR(void)
|
||||
{
|
||||
}
|
||||
|
||||
void DeviceReset(void)
|
||||
{
|
||||
UCONbits.USBEN = 0;
|
||||
Delay10KTCYx(255);
|
||||
Delay10KTCYx(255);
|
||||
Reset();
|
||||
}
|
||||
|
||||
// crc16 CCITT
|
||||
|
||||
unsigned short crc16(unsigned char *data, unsigned short len)
|
||||
{
|
||||
unsigned short crc = 0;
|
||||
while (len--)
|
||||
crc = ((crc >> 8) ^ crc16Table[(crc ^ *data++) & 0xFF]);
|
||||
return crc;
|
||||
}
|
||||
|
||||
|
||||
//Fill the info array[32-77] with random values until the crc16 match the criteria crc<0x2000
|
||||
|
||||
void make_crc(void)
|
||||
{
|
||||
int i;
|
||||
unsigned short crc;
|
||||
while (crc16(info, sizeof(info) - 2) > 0x1FFF) {
|
||||
for (i = 0; i < 46; i++) {
|
||||
info[i + 32] = (unsigned char) rand() % 0x100;
|
||||
}
|
||||
}
|
||||
crc = crc16(info, sizeof(info) - 2);
|
||||
info[sizeof(info) - 1] = crc >> 8 & 0x1F; //yes, 0x1F
|
||||
info[sizeof(info) - 2] = crc & 0xFF;
|
||||
}
|
||||
|
||||
|
||||
//decrypt info array
|
||||
|
||||
void decrypt(unsigned char version)
|
||||
{
|
||||
int i, index = 0x0A;
|
||||
int s = sizeof(info);
|
||||
unsigned char o1, o2;
|
||||
const far rom unsigned char* xorTableptr = (version == VERSION_A ? &A_Table[0] : &CS_Table[0]);
|
||||
//first step, xoring each element from table with a random value from xortable. Starting index is 0x0A. Index is incremented modulo 256
|
||||
for (i = 0; i < s; i++) {
|
||||
info[i] ^= xorTableptr[index++];
|
||||
index &= 0xFF;
|
||||
}
|
||||
/*next step, right shift whole array by 3 bits. Because anding with 0x1F, the last byte from info table must be always <0x20 in the encryption step, greater values will be trimmed at decryption step;
|
||||
this is why the crc16 must be 0x1FFF max., the last byte from info table is MSB of crc16.
|
||||
*/
|
||||
for (i = 0; i < s - 1; i++) {
|
||||
o1 = (info[s - i - 1] >> 3) & 0x1F;
|
||||
o2 = info[s - i - 2] << 5;
|
||||
info[s - i - 1] = o1 | o2;
|
||||
}
|
||||
info[0] >>= 3;
|
||||
info[0] &= 0x1F;
|
||||
//Last step, descrambling data; we put each element in the right position. At the end we have the decrypted serial and devcode ;)
|
||||
for (i = 0; i < s / 2; i += 4) {
|
||||
o1 = info[i];
|
||||
info[i] = info[s - i - 1];
|
||||
info[s - i - 1] = o1;
|
||||
}
|
||||
}
|
||||
|
||||
//encrypt the info array, ready to be inserted in TL866 firmware.
|
||||
|
||||
void encrypt(unsigned char version)
|
||||
{
|
||||
int i, index = 0x0A;
|
||||
int s = sizeof(info);
|
||||
unsigned char o1, o2;
|
||||
const far rom unsigned char* xorTableptr = (version == VERSION_A ? A_Table : CS_Table);
|
||||
make_crc(); //compute the right crc16. The last two bytes in the info table is the crc16 in little-endian and must be max. 0x1FFF otherwise decryption will be wrong.
|
||||
|
||||
/*Data scrambling. We swap the first byte with the last, the fourth from the beginning with the fourth from the end and so on.
|
||||
So we have the following 10 swaps:(0-79),(4-75),(8-71),(12-67),(16-63),(20-59),(24-55),(28-51),(32-47),(36-43).
|
||||
*/
|
||||
for (i = 0; i < s / 2; i += 4) {
|
||||
o1 = info[i];
|
||||
info[i] = info[s - i - 1];
|
||||
info[s - i - 1] = o1;
|
||||
//printf("(%d-%d),",i,s-i-1);
|
||||
}
|
||||
//Next step, left shift whole array by 3 bits .
|
||||
for (i = 0; i < s - 1; i++) {
|
||||
o1 = (info[i] << 3) & 0xF8;
|
||||
o2 = info[i + 1] >> 5;
|
||||
info[i] = o2 | o1;
|
||||
}
|
||||
info[s - 1] <<= 3;
|
||||
info[s - 1] &= 0xF8;
|
||||
|
||||
//Last step, xoring each info table value with a random number from xortable. The start index in this table is 0x0A. Index is incremented modulo 256
|
||||
for (i = 0; i < s; i++) {
|
||||
info[i] ^= xorTableptr[index++];
|
||||
index &= 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
//Erase flash page
|
||||
|
||||
void FlashErase(unsigned long address)
|
||||
{
|
||||
TBLPTR = address;
|
||||
EECON1 = 0b00010100;
|
||||
INTCONbits.GIE = 0;
|
||||
EECON2 = 0x55;
|
||||
EECON2 = 0xAA;
|
||||
EECON1bits.WR = 1;
|
||||
EECON1bits.WREN = 0;
|
||||
INTCONbits.GIE = 1;
|
||||
}
|
||||
|
||||
//Write a 64 byte block of data
|
||||
|
||||
void WriteBlock(unsigned long address, unsigned char* buffer)
|
||||
{
|
||||
unsigned char i;
|
||||
TBLPTR = address;
|
||||
EECON1 = 0b00000100;
|
||||
for (i = 0; i < 64; i++) {
|
||||
TABLAT = buffer[i];
|
||||
_asm tblwtpostinc _endasm
|
||||
}
|
||||
TBLPTR = address;
|
||||
INTCONbits.GIE = 0;
|
||||
EECON2 = 0x55;
|
||||
EECON2 = 0xAA;
|
||||
EECON1bits.WR = 1;
|
||||
EECON1bits.WREN = 0;
|
||||
INTCONbits.GIE = 1;
|
||||
}
|
||||
|
||||
|
||||
//Write 1Kbyte buffer to flash
|
||||
void WriteBuffer(unsigned long address)
|
||||
{
|
||||
|
||||
unsigned char i;
|
||||
unsigned char *buffer_ptr = &buffer[0];
|
||||
for (i = 0; i < 16; i++) {
|
||||
WriteBlock(address, buffer_ptr);
|
||||
buffer_ptr += 64;
|
||||
address += 64;
|
||||
}
|
||||
}
|
||||
|
||||
//Rewrite bootloader
|
||||
void WriteBootloader(unsigned char version)
|
||||
{
|
||||
unsigned char i;
|
||||
unsigned long addr = 0;
|
||||
WriteConfig(version);
|
||||
for (i = 0; i < 6; i++) {
|
||||
memcpypgm2ram(buffer, (const far rom void*) addr, 0x400); //copy 1024bytes from flash to buffer
|
||||
if (i == 4) {
|
||||
buffer[0x1B4] = version;
|
||||
}
|
||||
FlashErase(addr); //erase data block
|
||||
WriteBuffer(addr); //write data block
|
||||
addr += 0x400; //next data block
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Rewrite config area
|
||||
void WriteConfig(unsigned char version)
|
||||
{
|
||||
unsigned char t;
|
||||
unsigned long addr = 0x1FC00;
|
||||
const far rom unsigned char* xorTableptr = (version == VERSION_A ? &A_Table[0] : &CS_Table[0]);
|
||||
memcpypgm2ram(buffer, (const far rom void*) addr, 0x400); //copy 1024bytes from flash to buffer
|
||||
memcpypgm2ram(&t, (const far rom void*) DEVICE_TYPE_LOCATION, 1);
|
||||
memcpypgm2ram(&info[0], infoTable, 80);
|
||||
decrypt(t);
|
||||
encrypt(version);
|
||||
memcpy(buffer + 0x100, (void*) &info[0], 80); //copy the info array to buffer
|
||||
memcpypgm2ram(buffer, xorTableptr, 0x100); //copy xortable to buffer
|
||||
FlashErase(addr); //erase data block
|
||||
WriteBuffer(addr); //write data block
|
||||
}
|
||||
|
||||
//Rewrite Info
|
||||
void WriteInfo(unsigned char *info_ptr)
|
||||
{
|
||||
unsigned char t;
|
||||
unsigned long addr = 0x1FC00;
|
||||
memcpypgm2ram(&t, (const far rom void*) DEVICE_TYPE_LOCATION, 1);
|
||||
memcpypgm2ram(buffer, (const far rom void*) addr, 0x400); //copy 1024bytes from flash to buffer
|
||||
memcpy(&info[0], (void*) info_ptr, 32); //copy device and serial code received over the usb to info array
|
||||
encrypt(t); //encrypt the info array with (t) version of the key
|
||||
memcpy(buffer + 0x100, (void*) &info[0], 80); //copy the info array to buffer
|
||||
FlashErase(addr); //erase data block
|
||||
WriteBuffer(addr); //write data block
|
||||
}
|
||||
|
||||
/* Test routine */
|
||||
void load_shiftregister(unsigned char value)
|
||||
{
|
||||
unsigned char i;
|
||||
for (i = 0; i <= 7; i++) {
|
||||
SR_DAT = (value & 0x80) ? 1 : 0;
|
||||
value <<= 1;
|
||||
SR_CLK = 1;
|
||||
Delay10TCYx(2);
|
||||
SR_CLK = 0;
|
||||
Delay10TCYx(2);
|
||||
}
|
||||
}
|
||||
|
||||
void config_io()
|
||||
{
|
||||
OSCTUNEbits.PLLEN = 1; //Enable the PLL and wait 2+ms until the PLL locks before enabling USB module
|
||||
Delay10KTCYx(20);
|
||||
WDTCONbits.ADSHR = 1; // Select alternate SFR location to access ANCONx registers
|
||||
ANCON0 = 0xFF; // Default all pins to digital
|
||||
ANCON1 = 0xFF; // Default all pins to digital
|
||||
WDTCONbits.ADSHR = 0; // Select normal SFR locations
|
||||
USBOutHandle = 0;
|
||||
USBInHandle = 0;
|
||||
USBDeviceInit();
|
||||
LATA = INIT_LATA;
|
||||
LATB = INIT_LATB;
|
||||
LATC = INIT_LATC;
|
||||
LATD = INIT_LATD;
|
||||
LATE = INIT_LATE;
|
||||
LATF = INIT_LATF;
|
||||
LATG = INIT_LATG;
|
||||
LATH = INIT_LATH;
|
||||
LATJ = INIT_LATJ;
|
||||
|
||||
TRISA = INIT_TRISA;
|
||||
TRISB = INIT_TRISB;
|
||||
TRISC = INIT_TRISC;
|
||||
TRISD = INIT_TRISD;
|
||||
TRISE = INIT_TRISE;
|
||||
TRISF = INIT_TRISF;
|
||||
TRISG = INIT_TRISG;
|
||||
TRISH = INIT_TRISH;
|
||||
TRISJ = INIT_TRISJ;
|
||||
|
||||
//Init IO expander
|
||||
load_shiftregister(0);
|
||||
LE0 = 1; //vpp0
|
||||
LE1 = 1; //vpp1
|
||||
LE5 = 1; //gnd0
|
||||
LE6 = 1; //gnd1
|
||||
LE7 = 1; //gnd2
|
||||
Delay10TCYx(2);
|
||||
LE0 = 0; //vpp0
|
||||
LE1 = 0; //vpp1
|
||||
LE5 = 0; //gnd0
|
||||
LE6 = 0; //gnd1
|
||||
LE7 = 0; //gnd2
|
||||
Delay10TCYx(2);
|
||||
load_shiftregister(0xFF);
|
||||
LE2 = 1; //vcc0
|
||||
LE3 = 1; //vcc1
|
||||
LE4 = 1; //vcc2
|
||||
Delay10TCYx(2);
|
||||
LE2 = 0; //vcc0
|
||||
LE3 = 0; //vcc1
|
||||
LE4 = 0; //vcc2
|
||||
Delay10TCYx(2);
|
||||
OE_VPP = 1;
|
||||
OE_VCC = 1;
|
||||
LED_PIN = 0;
|
||||
}
|
||||
|
||||
void ReadProgMem(void)
|
||||
{
|
||||
memcpypgm2ram(&txdatapacket[0], (const far rom void*) rxdatapacket.ADR.pAdr, rxdatapacket.len);
|
||||
}
|
||||
|
||||
|
||||
// Process USB commands
|
||||
|
||||
void ProcessIo(void)
|
||||
{
|
||||
|
||||
static unsigned char count = 0;
|
||||
if (USBSuspendControl == 1) {
|
||||
return;
|
||||
}
|
||||
if (USBDeviceState < CONFIGURED_STATE) {
|
||||
if (--led_cnt == 0) {
|
||||
LED_PIN ^= 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (led_cnt != 0) {
|
||||
LED_PIN = 1;
|
||||
led_cnt--;
|
||||
} else
|
||||
LED_PIN = 0;
|
||||
|
||||
if (count) {
|
||||
if (!USBHandleBusy(USBInHandle)) {
|
||||
USBInHandle = USBGenWrite(USBGEN_EP_NUM, (BYTE*) & txdatapacket, count);
|
||||
count = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!USBHandleBusy(USBOutHandle)) {
|
||||
led_cnt = 5000U;
|
||||
count = 0;
|
||||
switch (rxdatapacket.CMD) {
|
||||
|
||||
case RESET: // reset device
|
||||
reset_switch = 0x55AA55AA;
|
||||
DeviceReset();
|
||||
break;
|
||||
|
||||
case READ_VERSION://get device state
|
||||
txdatapacket[0] = 0; //echo
|
||||
txdatapacket[1] = 1; //normal mode
|
||||
txdatapacket[2] = 33; //Length of devcode+serial+firmware version (LSB)
|
||||
txdatapacket[3] = 0; //Length of devcode+serial+firmware version (MSB)
|
||||
txdatapacket[4] = 0; //minor version
|
||||
txdatapacket[5] = 0; //major version
|
||||
txdatapacket[39] = 1; //Hardware version
|
||||
memcpypgm2ram(&txdatapacket[6], (const far rom void*) DEVICE_TYPE_LOCATION, 1);
|
||||
memcpypgm2ram(&txdatapacket[7], (const far rom void*) devcode, 8);
|
||||
memcpypgm2ram(&txdatapacket[15], (const far rom void*) serial, 24);
|
||||
count = 40;
|
||||
break;
|
||||
case READ_FLASH:
|
||||
ReadProgMem();
|
||||
count = rxdatapacket.len;
|
||||
break;
|
||||
|
||||
case WRITE_BOOTLOADER:
|
||||
WriteBootloader(rxdatapacket._byte[1]);
|
||||
txdatapacket[0] = WRITE_BOOTLOADER;
|
||||
count = 1;
|
||||
break;
|
||||
|
||||
case WRITE_CONFIG:
|
||||
memcpypgm2ram(buffer, (const far rom void*) 0x1FC00, 0x400); //copy 1024bytes from flash in buffer
|
||||
memcpypgm2ram(&buffer[0x3F8], (const far rom void*) config_bytes, 8); //Overwrite config bytes with default one
|
||||
if (!rxdatapacket._byte[1])//check for copy protect bit
|
||||
{
|
||||
buffer[0x3F9] |= 0x4; //Clear copy protect bit
|
||||
}
|
||||
FlashErase(0x1FC00); //erase data block
|
||||
WriteBuffer(0x1FC00); //write data block
|
||||
txdatapacket[0] = WRITE_CONFIG;
|
||||
count = 1;
|
||||
break;
|
||||
|
||||
case WRITE_INFO:
|
||||
WriteInfo(&rxdatapacket._byte[1]);
|
||||
//DeviceReset();
|
||||
txdatapacket[0] = WRITE_INFO;
|
||||
count = 1;
|
||||
break;
|
||||
|
||||
case GET_INFO:
|
||||
memcpypgm2ram(&txdatapacket[32], (const far rom void*) DEVICE_TYPE_LOCATION, 1); //get the bootloader version
|
||||
memcpypgm2ram(&txdatapacket[33], (const far rom void*) DEVICE_COPY_PROTECT, 1); //get the copy protect byte
|
||||
memcpypgm2ram(&info[0], infoTable, 80); //copy the encrypted info array
|
||||
decrypt(txdatapacket[32]); //decrypt the info array
|
||||
memcpy(txdatapacket, (void*) info, 32);
|
||||
txdatapacket[33] &= 0x4;
|
||||
count = 34;
|
||||
break;
|
||||
|
||||
case GET_PORT_INP: // Get Port INP
|
||||
count = 1;
|
||||
switch (rxdatapacket._byte[1]) {
|
||||
case 0:
|
||||
txdatapacket[0] = PORTA;
|
||||
break;
|
||||
case 1:
|
||||
txdatapacket[0] = PORTB;
|
||||
break;
|
||||
case 2:
|
||||
txdatapacket[0] = PORTC;
|
||||
break;
|
||||
case 3:
|
||||
txdatapacket[0] = PORTD;
|
||||
break;
|
||||
case 4:
|
||||
txdatapacket[0] = PORTE;
|
||||
break;
|
||||
case 5:
|
||||
txdatapacket[0] = PORTF;
|
||||
break;
|
||||
case 6:
|
||||
txdatapacket[0] = PORTG;
|
||||
break;
|
||||
case 7:
|
||||
txdatapacket[0] = PORTH;
|
||||
break;
|
||||
case 8:
|
||||
txdatapacket[0] = PORTJ;
|
||||
break;
|
||||
default:
|
||||
count = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case GET_PORT_LAT: // Get Port LAT
|
||||
count = 1;
|
||||
switch (rxdatapacket._byte[1]) {
|
||||
case 0:
|
||||
txdatapacket[0] = LATA;
|
||||
break;
|
||||
case 1:
|
||||
txdatapacket[0] = LATB;
|
||||
break;
|
||||
case 2:
|
||||
txdatapacket[0] = LATC;
|
||||
break;
|
||||
case 3:
|
||||
txdatapacket[0] = LATD;
|
||||
break;
|
||||
case 4:
|
||||
txdatapacket[0] = LATE;
|
||||
break;
|
||||
case 5:
|
||||
txdatapacket[0] = LATF;
|
||||
break;
|
||||
case 6:
|
||||
txdatapacket[0] = LATG;
|
||||
break;
|
||||
case 7:
|
||||
txdatapacket[0] = LATH;
|
||||
break;
|
||||
case 8:
|
||||
txdatapacket[0] = LATJ;
|
||||
break;
|
||||
default:
|
||||
count = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case GET_PORT_TRIS: // Get Port TRIS
|
||||
count = 1;
|
||||
switch (rxdatapacket._byte[1]) {
|
||||
case 0:
|
||||
txdatapacket[0] = TRISA;
|
||||
break;
|
||||
case 1:
|
||||
txdatapacket[0] = TRISB;
|
||||
break;
|
||||
case 2:
|
||||
txdatapacket[0] = TRISC;
|
||||
break;
|
||||
case 3:
|
||||
txdatapacket[0] = TRISD;
|
||||
break;
|
||||
case 4:
|
||||
txdatapacket[0] = TRISE;
|
||||
break;
|
||||
case 5:
|
||||
txdatapacket[0] = TRISF;
|
||||
break;
|
||||
case 6:
|
||||
txdatapacket[0] = TRISG;
|
||||
break;
|
||||
case 7:
|
||||
txdatapacket[0] = TRISH;
|
||||
break;
|
||||
case 8:
|
||||
txdatapacket[0] = TRISJ;
|
||||
break;
|
||||
default:
|
||||
count = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SET_PORT_TRIS://Set ports Tris value
|
||||
switch (rxdatapacket._byte[1]) {
|
||||
case 0:
|
||||
if (rxdatapacket._byte[3])
|
||||
TRISA |= (1U << rxdatapacket._byte[2]);
|
||||
else
|
||||
TRISA &= ~(1U << rxdatapacket._byte[2]);
|
||||
break;
|
||||
case 1:
|
||||
if (rxdatapacket._byte[3])
|
||||
TRISB |= (1U << rxdatapacket._byte[2]);
|
||||
else
|
||||
TRISB &= ~(1U << rxdatapacket._byte[2]);
|
||||
break;
|
||||
case 2:
|
||||
if (rxdatapacket._byte[3])
|
||||
TRISC |= (1U << rxdatapacket._byte[2]);
|
||||
else
|
||||
TRISC &= ~(1U << rxdatapacket._byte[2]);
|
||||
break;
|
||||
case 3:
|
||||
if (rxdatapacket._byte[3])
|
||||
TRISD |= (1U << rxdatapacket._byte[2]);
|
||||
else
|
||||
TRISD &= ~(1U << rxdatapacket._byte[2]);
|
||||
break;
|
||||
case 4:
|
||||
if (rxdatapacket._byte[3])
|
||||
TRISE |= (1U << rxdatapacket._byte[2]);
|
||||
else
|
||||
TRISE &= ~(1U << rxdatapacket._byte[2]);
|
||||
break;
|
||||
case 5:
|
||||
if (rxdatapacket._byte[3])
|
||||
TRISF |= (1U << rxdatapacket._byte[2]);
|
||||
else
|
||||
TRISF &= ~(1U << rxdatapacket._byte[2]);
|
||||
break;
|
||||
case 6:
|
||||
if (rxdatapacket._byte[3])
|
||||
TRISG |= (1U << rxdatapacket._byte[2]);
|
||||
else
|
||||
TRISG &= ~(1U << rxdatapacket._byte[2]);
|
||||
break;
|
||||
case 7:
|
||||
if (rxdatapacket._byte[3])
|
||||
TRISH |= (1U << rxdatapacket._byte[2]);
|
||||
else
|
||||
TRISH &= ~(1U << rxdatapacket._byte[2]);
|
||||
break;
|
||||
case 8:
|
||||
if (rxdatapacket._byte[3])
|
||||
TRISJ |= (1U << rxdatapacket._byte[2]);
|
||||
else
|
||||
TRISJ &= ~(1U << rxdatapacket._byte[2]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case SET_PORT_LAT://Set ports Lat value
|
||||
switch (rxdatapacket._byte[1]) {
|
||||
case 0:
|
||||
if (rxdatapacket._byte[3])
|
||||
LATA |= (1U << rxdatapacket._byte[2]);
|
||||
else
|
||||
LATA &= ~(1U << rxdatapacket._byte[2]);
|
||||
break;
|
||||
case 1:
|
||||
if (rxdatapacket._byte[3])
|
||||
LATB |= (1U << rxdatapacket._byte[2]);
|
||||
else
|
||||
LATB &= ~(1U << rxdatapacket._byte[2]);
|
||||
break;
|
||||
case 2:
|
||||
if (rxdatapacket._byte[3])
|
||||
LATC |= (1U << rxdatapacket._byte[2]);
|
||||
else
|
||||
LATC &= ~(1U << rxdatapacket._byte[2]);
|
||||
break;
|
||||
case 3:
|
||||
if (rxdatapacket._byte[3])
|
||||
LATD |= (1U << rxdatapacket._byte[2]);
|
||||
else
|
||||
LATD &= ~(1U << rxdatapacket._byte[2]);
|
||||
break;
|
||||
case 4:
|
||||
if (rxdatapacket._byte[3])
|
||||
LATE |= (1U << rxdatapacket._byte[2]);
|
||||
else
|
||||
LATE &= ~(1U << rxdatapacket._byte[2]);
|
||||
break;
|
||||
case 5:
|
||||
if (rxdatapacket._byte[3])
|
||||
LATF |= (1U << rxdatapacket._byte[2]);
|
||||
else
|
||||
LATF &= ~(1U << rxdatapacket._byte[2]);
|
||||
break;
|
||||
case 6:
|
||||
if (rxdatapacket._byte[3])
|
||||
LATG |= (1U << rxdatapacket._byte[2]);
|
||||
else
|
||||
LATG &= ~(1U << rxdatapacket._byte[2]);
|
||||
break;
|
||||
case 7:
|
||||
if (rxdatapacket._byte[3])
|
||||
LATH |= (1U << rxdatapacket._byte[2]);
|
||||
else
|
||||
LATH &= ~(1U << rxdatapacket._byte[2]);
|
||||
break;
|
||||
case 8:
|
||||
if (rxdatapacket._byte[3])
|
||||
LATJ |= (1U << rxdatapacket._byte[2]);
|
||||
else
|
||||
LATJ &= ~(1U << rxdatapacket._byte[2]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SET_SHIFTREG:
|
||||
load_shiftregister(rxdatapacket._byte[1]);
|
||||
break;
|
||||
|
||||
default: // Unknown command received
|
||||
break;
|
||||
}
|
||||
|
||||
//rearm Out Endpoint
|
||||
USBOutHandle = USBGenRead(USBGEN_EP_NUM, (BYTE*) & rxdatapacket, USBGEN_EP_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// USB Callback handling routines -----------------------------------------------------------
|
||||
|
||||
// Call back that is invoked when a USB suspend is detected
|
||||
|
||||
void USBCBSuspend(void)
|
||||
{
|
||||
}
|
||||
|
||||
// This call back is invoked when a wakeup from USB suspend is detected.
|
||||
|
||||
void USBCBWakeFromSuspend(void)
|
||||
{
|
||||
}
|
||||
|
||||
// The USB host sends out a SOF packet to full-speed devices every 1 ms.
|
||||
|
||||
void USBCB_SOF_Handler(void)
|
||||
{
|
||||
// No need to clear UIRbits.SOFIF to 0 here. Callback caller is already doing that.
|
||||
}
|
||||
|
||||
// The purpose of this callback is mainly for debugging during development.
|
||||
// Check UEIR to see which error causes the interrupt.
|
||||
|
||||
void USBCBErrorHandler(void)
|
||||
{
|
||||
// No need to clear UEIR to 0 here.
|
||||
// Callback caller is already doing that.
|
||||
}
|
||||
|
||||
// Check other requests callback
|
||||
|
||||
void USBCBCheckOtherReq(void)
|
||||
{
|
||||
}
|
||||
|
||||
// Callback function is called when a SETUP, bRequest: SET_DESCRIPTOR request arrives.
|
||||
|
||||
void USBCBStdSetDscHandler(void)
|
||||
{
|
||||
// You must claim session ownership if supporting this request
|
||||
}
|
||||
|
||||
//This function is called when the device becomes initialized
|
||||
|
||||
void USBCBInitEP(void)
|
||||
{
|
||||
//Enable the application endpoints
|
||||
USBEnableEndpoint(USBGEN_EP_NUM, USB_OUT_ENABLED | USB_IN_ENABLED | USB_HANDSHAKE_ENABLED | USB_DISALLOW_SETUP);
|
||||
USBOutHandle = USBGenRead(USBGEN_EP_NUM, (BYTE*) & rxdatapacket, USBGEN_EP_SIZE);
|
||||
}
|
||||
|
||||
// Send resume call-back
|
||||
|
||||
void USBCBSendResume(void)
|
||||
{
|
||||
static WORD delay_count;
|
||||
// Verify that the host has armed us to perform remote wakeup.
|
||||
if (USBGetRemoteWakeupStatus() == TRUE) {
|
||||
// Verify that the USB bus is suspended (before we send remote wakeup signalling).
|
||||
if (USBIsBusSuspended() == TRUE) {
|
||||
USBMaskInterrupts();
|
||||
|
||||
// Bring the clock speed up to normal running state
|
||||
USBCBWakeFromSuspend();
|
||||
USBSuspendControl = 0;
|
||||
USBBusIsSuspended = FALSE;
|
||||
|
||||
// Section 7.1.7.7 of the USB 2.0 specifications indicates a USB
|
||||
// device must continuously see 5ms+ of idle on the bus, before it sends
|
||||
// remote wakeup signalling. One way to be certain that this parameter
|
||||
// gets met, is to add a 2ms+ blocking delay here (2ms plus at
|
||||
// least 3ms from bus idle to USBIsBusSuspended() == FLAG_TRUE, yeilds
|
||||
// 5ms+ total delay since start of idle).
|
||||
//5ms+ total delay since start of idle).
|
||||
delay_count = 3600U;
|
||||
do {
|
||||
delay_count--;
|
||||
} while (delay_count);
|
||||
|
||||
//Now drive the resume K-state signalling onto the USB bus.
|
||||
USBResumeControl = 1; // Start RESUME signaling
|
||||
delay_count = 1800U; // Set RESUME line for 1-13 ms
|
||||
do {
|
||||
delay_count--;
|
||||
} while (delay_count);
|
||||
USBResumeControl = 0; //Finished driving resume signalling
|
||||
|
||||
USBUnmaskInterrupts();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// USB callback function handler
|
||||
|
||||
BOOL USER_USB_CALLBACK_EVENT_HANDLER(int event, void *pdata, WORD size)
|
||||
{
|
||||
switch (event) {
|
||||
case EVENT_TRANSFER:
|
||||
break;
|
||||
case EVENT_SOF:
|
||||
USBCB_SOF_Handler();
|
||||
break;
|
||||
case EVENT_SUSPEND:
|
||||
USBCBSuspend();
|
||||
break;
|
||||
case EVENT_RESUME:
|
||||
USBCBWakeFromSuspend();
|
||||
break;
|
||||
case EVENT_CONFIGURED:
|
||||
USBCBInitEP();
|
||||
break;
|
||||
case EVENT_SET_DESCRIPTOR:
|
||||
USBCBStdSetDscHandler();
|
||||
break;
|
||||
case EVENT_EP0_REQUEST:
|
||||
USBCBCheckOtherReq();
|
||||
break;
|
||||
case EVENT_BUS_ERROR:
|
||||
USBCBErrorHandler();
|
||||
break;
|
||||
case EVENT_TRANSFER_TERMINATED:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
USBOutHandle = 0;
|
||||
USBInHandle = 0;
|
||||
led_cnt = 1;
|
||||
config_io();
|
||||
srand(0); //initialize the random number generator
|
||||
#if defined (USB_INTERRUPT)
|
||||
USBDeviceAttach();
|
||||
#endif
|
||||
while (1) {
|
||||
#if defined(USB_POLLING)
|
||||
USBDeviceTasks();
|
||||
#endif
|
||||
ProcessIo();
|
||||
|
||||
}
|
||||
}
|
101
TL866_Updater.X/main.h
Normal file
101
TL866_Updater.X/main.h
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* File: main.h
|
||||
* Author: Radioman
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MAIN_H
|
||||
#define MAIN_H
|
||||
|
||||
|
||||
|
||||
|
||||
#define _XTAL_FREQ 48000000
|
||||
|
||||
//TL866 Ports settings
|
||||
#define INIT_LATA (0b00010000)
|
||||
#define INIT_LATB (0b00000010)
|
||||
#define INIT_LATC (0b00000000)
|
||||
#define INIT_LATD (0b00000000)
|
||||
#define INIT_LATE (0b00000000)
|
||||
#define INIT_LATF (0b00000000)
|
||||
#define INIT_LATG (0b00010000)
|
||||
#define INIT_LATH (0b00000000)
|
||||
#define INIT_LATJ (0b00000000)
|
||||
|
||||
#define INIT_TRISA (0b00000000)
|
||||
#define INIT_TRISB (0b00000001)
|
||||
#define INIT_TRISC (0b00000000)
|
||||
#define INIT_TRISD (0b00000000)
|
||||
#define INIT_TRISE (0b00000000)
|
||||
#define INIT_TRISF (0b00000000)
|
||||
#define INIT_TRISG (0b00000000)
|
||||
#define INIT_TRISH (0b00000000)
|
||||
#define INIT_TRISJ (0b00000000)
|
||||
|
||||
#define LE0 (LATHbits.LATH0)//vpp0
|
||||
#define LE1 (LATHbits.LATH1)//vpp1
|
||||
#define LE2 (LATAbits.LATA2)//vcc0
|
||||
#define LE3 (LATAbits.LATA0)//vcc1
|
||||
#define LE4 (LATAbits.LATA5)//vcc2
|
||||
#define LE5 (LATAbits.LATA3)//gnd0
|
||||
#define LE6 (LATHbits.LATH4)//gnd2
|
||||
#define LE7 (LATAbits.LATA1)//gnd3
|
||||
#define OE_VPP (LATGbits.LATG4)//OE_VPP
|
||||
#define OE_VCC (LATAbits.LATA4)//OE_VCC
|
||||
#define SR_DAT (LATHbits.LATH2)// shift register data line
|
||||
#define SR_CLK (LATHbits.LATH3)// shift register clock line (register shift on 1)
|
||||
|
||||
#define LED_PIN (LATCbits.LATC0)
|
||||
#define LED_ON 1
|
||||
#define LED_OFF 0
|
||||
|
||||
#define INPUT_PIN 1
|
||||
#define OUTPUT_PIN 0
|
||||
#define FLAG_FALSE 0
|
||||
#define FLAG_TRUE 1
|
||||
|
||||
#define VERSION_A 1
|
||||
#define VERSION_CS 2
|
||||
|
||||
#define OVER_HEAD 5 //Overhead: <CMD_CODE><LEN><ADDR:3>
|
||||
#define DATA_SIZE (USBGEN_EP_SIZE - OVER_HEAD)
|
||||
|
||||
#define READ_VERSION 0x00
|
||||
#define READ_FLASH 0x01
|
||||
#define WRITE_BOOTLOADER 0x02
|
||||
#define WRITE_CONFIG 0x03
|
||||
#define WRITE_INFO 0x04
|
||||
#define GET_INFO 0x05
|
||||
//#define DEBUG_PACKET 0x7F
|
||||
#define GET_PORT_INP 0x80
|
||||
#define GET_PORT_LAT 0x81
|
||||
#define GET_PORT_TRIS 0x82
|
||||
#define SET_PORT_TRIS 0x83
|
||||
#define SET_PORT_LAT 0x84
|
||||
#define SET_SHIFTREG 0x85
|
||||
#define RESET 0xFF
|
||||
|
||||
typedef union {
|
||||
unsigned char _byte[USBGEN_EP_SIZE]; //For Byte Access
|
||||
|
||||
struct {
|
||||
unsigned char CMD;
|
||||
unsigned char len;
|
||||
|
||||
union {
|
||||
rom far char *pAdr; //Address Pointer
|
||||
|
||||
struct {
|
||||
unsigned char low; //Little-endian order
|
||||
unsigned char high;
|
||||
unsigned char upper;
|
||||
};
|
||||
} ADR;
|
||||
unsigned char data[DATA_SIZE];
|
||||
};
|
||||
} DATA_PACKET;
|
||||
|
||||
#endif /* MAIN_H */
|
||||
|
173
TL866_Updater.X/nbproject/Makefile-default.mk
Normal file
173
TL866_Updater.X/nbproject/Makefile-default.mk
Normal file
@ -0,0 +1,173 @@
|
||||
#
|
||||
# Generated Makefile - do not edit!
|
||||
#
|
||||
# Edit the Makefile in the project folder instead (../Makefile). Each target
|
||||
# has a -pre and a -post target defined where you can add customized code.
|
||||
#
|
||||
# This makefile implements configuration specific macros and targets.
|
||||
|
||||
|
||||
# Include project Makefile
|
||||
ifeq "${IGNORE_LOCAL}" "TRUE"
|
||||
# do not include local makefile. User is passing all local related variables already
|
||||
else
|
||||
include Makefile
|
||||
# Include makefile containing local settings
|
||||
ifeq "$(wildcard nbproject/Makefile-local-default.mk)" "nbproject/Makefile-local-default.mk"
|
||||
include nbproject/Makefile-local-default.mk
|
||||
endif
|
||||
endif
|
||||
|
||||
# Environment
|
||||
MKDIR=gnumkdir -p
|
||||
RM=rm -f
|
||||
MV=mv
|
||||
CP=cp
|
||||
|
||||
# Macros
|
||||
CND_CONF=default
|
||||
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
|
||||
IMAGE_TYPE=debug
|
||||
OUTPUT_SUFFIX=cof
|
||||
DEBUGGABLE_SUFFIX=cof
|
||||
FINAL_IMAGE=dist/${CND_CONF}/${IMAGE_TYPE}/TL866_Updater.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
|
||||
else
|
||||
IMAGE_TYPE=production
|
||||
OUTPUT_SUFFIX=hex
|
||||
DEBUGGABLE_SUFFIX=cof
|
||||
FINAL_IMAGE=dist/${CND_CONF}/${IMAGE_TYPE}/TL866_Updater.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
|
||||
endif
|
||||
|
||||
# Object Directory
|
||||
OBJECTDIR=build/${CND_CONF}/${IMAGE_TYPE}
|
||||
|
||||
# Distribution Directory
|
||||
DISTDIR=dist/${CND_CONF}/${IMAGE_TYPE}
|
||||
|
||||
# Object Files Quoted if spaced
|
||||
OBJECTFILES_QUOTED_IF_SPACED=${OBJECTDIR}/main.o ${OBJECTDIR}/usb_descriptors.o ${OBJECTDIR}/_ext/1389087059/usb_function_generic.o ${OBJECTDIR}/_ext/882318247/usb_device.o
|
||||
POSSIBLE_DEPFILES=${OBJECTDIR}/main.o.d ${OBJECTDIR}/usb_descriptors.o.d ${OBJECTDIR}/_ext/1389087059/usb_function_generic.o.d ${OBJECTDIR}/_ext/882318247/usb_device.o.d
|
||||
|
||||
# Object Files
|
||||
OBJECTFILES=${OBJECTDIR}/main.o ${OBJECTDIR}/usb_descriptors.o ${OBJECTDIR}/_ext/1389087059/usb_function_generic.o ${OBJECTDIR}/_ext/882318247/usb_device.o
|
||||
|
||||
|
||||
CFLAGS=
|
||||
ASFLAGS=
|
||||
LDLIBSOPTIONS=
|
||||
|
||||
############# Tool locations ##########################################
|
||||
# If you copy a project from one host to another, the path where the #
|
||||
# compiler is installed may be different. #
|
||||
# If you open this project with MPLAB X in the new host, this #
|
||||
# makefile will be regenerated and the paths will be corrected. #
|
||||
#######################################################################
|
||||
# fixDeps replaces a bunch of sed/cat/printf statements that slow down the build
|
||||
FIXDEPS=fixDeps
|
||||
|
||||
.build-conf: ${BUILD_SUBPROJECTS}
|
||||
${MAKE} ${MAKE_OPTIONS} -f nbproject/Makefile-default.mk dist/${CND_CONF}/${IMAGE_TYPE}/TL866_Updater.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
|
||||
|
||||
MP_PROCESSOR_OPTION=18F87J50
|
||||
MP_PROCESSOR_OPTION_LD=18f87j50
|
||||
MP_LINKER_DEBUG_OPTION=
|
||||
# ------------------------------------------------------------------------------------
|
||||
# Rules for buildStep: assemble
|
||||
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
|
||||
else
|
||||
endif
|
||||
|
||||
# ------------------------------------------------------------------------------------
|
||||
# Rules for buildStep: compile
|
||||
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
|
||||
${OBJECTDIR}/main.o: main.c nbproject/Makefile-${CND_CONF}.mk
|
||||
@${MKDIR} ${OBJECTDIR}
|
||||
@${RM} ${OBJECTDIR}/main.o.d
|
||||
${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -p$(MP_PROCESSOR_OPTION) -I"F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/Include" -I"./" -ms -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/main.o main.c
|
||||
@${DEP_GEN} -d ${OBJECTDIR}/main.o
|
||||
@${FIXDEPS} "${OBJECTDIR}/main.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18
|
||||
|
||||
${OBJECTDIR}/usb_descriptors.o: usb_descriptors.c nbproject/Makefile-${CND_CONF}.mk
|
||||
@${MKDIR} ${OBJECTDIR}
|
||||
@${RM} ${OBJECTDIR}/usb_descriptors.o.d
|
||||
${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -p$(MP_PROCESSOR_OPTION) -I"F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/Include" -I"./" -ms -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/usb_descriptors.o usb_descriptors.c
|
||||
@${DEP_GEN} -d ${OBJECTDIR}/usb_descriptors.o
|
||||
@${FIXDEPS} "${OBJECTDIR}/usb_descriptors.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18
|
||||
|
||||
${OBJECTDIR}/_ext/1389087059/usb_function_generic.o: F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/USB/Generic\ Device\ Driver/usb_function_generic.c nbproject/Makefile-${CND_CONF}.mk
|
||||
@${MKDIR} ${OBJECTDIR}/_ext/1389087059
|
||||
@${RM} ${OBJECTDIR}/_ext/1389087059/usb_function_generic.o.d
|
||||
${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -p$(MP_PROCESSOR_OPTION) -I"F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/Include" -I"./" -ms -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1389087059/usb_function_generic.o "F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/USB/Generic Device Driver/usb_function_generic.c"
|
||||
@${DEP_GEN} -d ${OBJECTDIR}/_ext/1389087059/usb_function_generic.o
|
||||
@${FIXDEPS} "${OBJECTDIR}/_ext/1389087059/usb_function_generic.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18
|
||||
|
||||
${OBJECTDIR}/_ext/882318247/usb_device.o: F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/USB/usb_device.c nbproject/Makefile-${CND_CONF}.mk
|
||||
@${MKDIR} ${OBJECTDIR}/_ext/882318247
|
||||
@${RM} ${OBJECTDIR}/_ext/882318247/usb_device.o.d
|
||||
${MP_CC} $(MP_EXTRA_CC_PRE) -D__DEBUG -p$(MP_PROCESSOR_OPTION) -I"F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/Include" -I"./" -ms -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/882318247/usb_device.o F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/USB/usb_device.c
|
||||
@${DEP_GEN} -d ${OBJECTDIR}/_ext/882318247/usb_device.o
|
||||
@${FIXDEPS} "${OBJECTDIR}/_ext/882318247/usb_device.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18
|
||||
|
||||
else
|
||||
${OBJECTDIR}/main.o: main.c nbproject/Makefile-${CND_CONF}.mk
|
||||
@${MKDIR} ${OBJECTDIR}
|
||||
@${RM} ${OBJECTDIR}/main.o.d
|
||||
${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -I"F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/Include" -I"./" -ms -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/main.o main.c
|
||||
@${DEP_GEN} -d ${OBJECTDIR}/main.o
|
||||
@${FIXDEPS} "${OBJECTDIR}/main.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18
|
||||
|
||||
${OBJECTDIR}/usb_descriptors.o: usb_descriptors.c nbproject/Makefile-${CND_CONF}.mk
|
||||
@${MKDIR} ${OBJECTDIR}
|
||||
@${RM} ${OBJECTDIR}/usb_descriptors.o.d
|
||||
${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -I"F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/Include" -I"./" -ms -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/usb_descriptors.o usb_descriptors.c
|
||||
@${DEP_GEN} -d ${OBJECTDIR}/usb_descriptors.o
|
||||
@${FIXDEPS} "${OBJECTDIR}/usb_descriptors.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18
|
||||
|
||||
${OBJECTDIR}/_ext/1389087059/usb_function_generic.o: F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/USB/Generic\ Device\ Driver/usb_function_generic.c nbproject/Makefile-${CND_CONF}.mk
|
||||
@${MKDIR} ${OBJECTDIR}/_ext/1389087059
|
||||
@${RM} ${OBJECTDIR}/_ext/1389087059/usb_function_generic.o.d
|
||||
${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -I"F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/Include" -I"./" -ms -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/1389087059/usb_function_generic.o "F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/USB/Generic Device Driver/usb_function_generic.c"
|
||||
@${DEP_GEN} -d ${OBJECTDIR}/_ext/1389087059/usb_function_generic.o
|
||||
@${FIXDEPS} "${OBJECTDIR}/_ext/1389087059/usb_function_generic.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18
|
||||
|
||||
${OBJECTDIR}/_ext/882318247/usb_device.o: F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/USB/usb_device.c nbproject/Makefile-${CND_CONF}.mk
|
||||
@${MKDIR} ${OBJECTDIR}/_ext/882318247
|
||||
@${RM} ${OBJECTDIR}/_ext/882318247/usb_device.o.d
|
||||
${MP_CC} $(MP_EXTRA_CC_PRE) -p$(MP_PROCESSOR_OPTION) -I"F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/Include" -I"./" -ms -oa- -I ${MP_CC_DIR}\\..\\h -fo ${OBJECTDIR}/_ext/882318247/usb_device.o F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/USB/usb_device.c
|
||||
@${DEP_GEN} -d ${OBJECTDIR}/_ext/882318247/usb_device.o
|
||||
@${FIXDEPS} "${OBJECTDIR}/_ext/882318247/usb_device.o.d" $(SILENT) -rsi ${MP_CC_DIR}../ -c18
|
||||
|
||||
endif
|
||||
|
||||
# ------------------------------------------------------------------------------------
|
||||
# Rules for buildStep: link
|
||||
ifeq ($(TYPE_IMAGE), DEBUG_RUN)
|
||||
dist/${CND_CONF}/${IMAGE_TYPE}/TL866_Updater.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk 18f87j50.lkr
|
||||
@${MKDIR} dist/${CND_CONF}/${IMAGE_TYPE}
|
||||
${MP_LD} $(MP_EXTRA_LD_PRE) "18f87j50.lkr" -p$(MP_PROCESSOR_OPTION_LD) -w -x -u_DEBUG -z__MPLAB_BUILD=1 -u_CRUNTIME -z__MPLAB_DEBUG=1 $(MP_LINKER_DEBUG_OPTION) -l ${MP_CC_DIR}\\..\\lib -o dist/${CND_CONF}/${IMAGE_TYPE}/TL866_Updater.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED}
|
||||
else
|
||||
dist/${CND_CONF}/${IMAGE_TYPE}/TL866_Updater.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}: ${OBJECTFILES} nbproject/Makefile-${CND_CONF}.mk 18f87j50.lkr
|
||||
@${MKDIR} dist/${CND_CONF}/${IMAGE_TYPE}
|
||||
${MP_LD} $(MP_EXTRA_LD_PRE) "18f87j50.lkr" -p$(MP_PROCESSOR_OPTION_LD) -w -z__MPLAB_BUILD=1 -u_CRUNTIME -l ${MP_CC_DIR}\\..\\lib -o dist/${CND_CONF}/${IMAGE_TYPE}/TL866_Updater.X.${IMAGE_TYPE}.${DEBUGGABLE_SUFFIX} ${OBJECTFILES_QUOTED_IF_SPACED}
|
||||
endif
|
||||
|
||||
|
||||
# Subprojects
|
||||
.build-subprojects:
|
||||
|
||||
|
||||
# Subprojects
|
||||
.clean-subprojects:
|
||||
|
||||
# Clean Targets
|
||||
.clean-conf: ${CLEAN_SUBPROJECTS}
|
||||
${RM} -r build/default
|
||||
${RM} -r dist/default
|
||||
|
||||
# Enable dependency checking
|
||||
.dep.inc: .depcheck-impl
|
||||
|
||||
DEPFILES=$(shell mplabwildcard ${POSSIBLE_DEPFILES})
|
||||
ifneq (${DEPFILES},)
|
||||
include ${DEPFILES}
|
||||
endif
|
8
TL866_Updater.X/nbproject/Makefile-genesis.properties
Normal file
8
TL866_Updater.X/nbproject/Makefile-genesis.properties
Normal file
@ -0,0 +1,8 @@
|
||||
#
|
||||
#Sun Mar 16 00:40:34 EET 2014
|
||||
default.com-microchip-mplab-nbide-toolchainC18-C18LanguageToolchain.md5=335cf5619a83d7964709638747493acc
|
||||
default.languagetoolchain.dir=F\:\\SDK\\Microchip\\C18\\bin
|
||||
com-microchip-mplab-nbide-embedded-makeproject-MakeProject.md5=415494acd195d89b2f6d7a36797a5ab4
|
||||
default.languagetoolchain.version=3.45
|
||||
host.platform=windows
|
||||
conf.ids=default
|
69
TL866_Updater.X/nbproject/Makefile-impl.mk
Normal file
69
TL866_Updater.X/nbproject/Makefile-impl.mk
Normal file
@ -0,0 +1,69 @@
|
||||
#
|
||||
# Generated Makefile - do not edit!
|
||||
#
|
||||
# Edit the Makefile in the project folder instead (../Makefile). Each target
|
||||
# has a pre- and a post- target defined where you can add customization code.
|
||||
#
|
||||
# This makefile implements macros and targets common to all configurations.
|
||||
#
|
||||
# NOCDDL
|
||||
|
||||
|
||||
# Building and Cleaning subprojects are done by default, but can be controlled with the SUB
|
||||
# macro. If SUB=no, subprojects will not be built or cleaned. The following macro
|
||||
# statements set BUILD_SUB-CONF and CLEAN_SUB-CONF to .build-reqprojects-conf
|
||||
# and .clean-reqprojects-conf unless SUB has the value 'no'
|
||||
SUB_no=NO
|
||||
SUBPROJECTS=${SUB_${SUB}}
|
||||
BUILD_SUBPROJECTS_=.build-subprojects
|
||||
BUILD_SUBPROJECTS_NO=
|
||||
BUILD_SUBPROJECTS=${BUILD_SUBPROJECTS_${SUBPROJECTS}}
|
||||
CLEAN_SUBPROJECTS_=.clean-subprojects
|
||||
CLEAN_SUBPROJECTS_NO=
|
||||
CLEAN_SUBPROJECTS=${CLEAN_SUBPROJECTS_${SUBPROJECTS}}
|
||||
|
||||
|
||||
# Project Name
|
||||
PROJECTNAME=TL866_Updater.X
|
||||
|
||||
# Active Configuration
|
||||
DEFAULTCONF=default
|
||||
CONF=${DEFAULTCONF}
|
||||
|
||||
# All Configurations
|
||||
ALLCONFS=default
|
||||
|
||||
|
||||
# build
|
||||
.build-impl: .build-pre
|
||||
${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .build-conf
|
||||
|
||||
|
||||
# clean
|
||||
.clean-impl: .clean-pre
|
||||
${MAKE} -f nbproject/Makefile-${CONF}.mk SUBPROJECTS=${SUBPROJECTS} .clean-conf
|
||||
|
||||
# clobber
|
||||
.clobber-impl: .clobber-pre .depcheck-impl
|
||||
${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default clean
|
||||
|
||||
|
||||
|
||||
# all
|
||||
.all-impl: .all-pre .depcheck-impl
|
||||
${MAKE} SUBPROJECTS=${SUBPROJECTS} CONF=default build
|
||||
|
||||
|
||||
|
||||
# dependency checking support
|
||||
.depcheck-impl:
|
||||
# @echo "# This code depends on make tool being used" >.dep.inc
|
||||
# @if [ -n "${MAKE_VERSION}" ]; then \
|
||||
# echo "DEPFILES=\$$(wildcard \$$(addsuffix .d, \$${OBJECTFILES}))" >>.dep.inc; \
|
||||
# echo "ifneq (\$${DEPFILES},)" >>.dep.inc; \
|
||||
# echo "include \$${DEPFILES}" >>.dep.inc; \
|
||||
# echo "endif" >>.dep.inc; \
|
||||
# else \
|
||||
# echo ".KEEP_STATE:" >>.dep.inc; \
|
||||
# echo ".KEEP_STATE_FILE:.make.state.\$${CONF}" >>.dep.inc; \
|
||||
# fi
|
37
TL866_Updater.X/nbproject/Makefile-local-default.mk
Normal file
37
TL866_Updater.X/nbproject/Makefile-local-default.mk
Normal file
@ -0,0 +1,37 @@
|
||||
#
|
||||
# Generated Makefile - do not edit!
|
||||
#
|
||||
#
|
||||
# This file contains information about the location of compilers and other tools.
|
||||
# If you commmit this file into your revision control server, you will be able to
|
||||
# to checkout the project and build it from the command line with make. However,
|
||||
# if more than one person works on the same project, then this file might show
|
||||
# conflicts since different users are bound to have compilers in different places.
|
||||
# In that case you might choose to not commit this file and let MPLAB X recreate this file
|
||||
# for each user. The disadvantage of not commiting this file is that you must run MPLAB X at
|
||||
# least once so the file gets created and the project can be built. Finally, you can also
|
||||
# avoid using this file at all if you are only building from the command line with make.
|
||||
# You can invoke make with the values of the macros:
|
||||
# $ makeMP_CC="/opt/microchip/mplabc30/v3.30c/bin/pic30-gcc" ...
|
||||
#
|
||||
SHELL=cmd.exe
|
||||
PATH_TO_IDE_BIN=C:/Program Files/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/
|
||||
# Adding MPLAB X bin directory to path.
|
||||
PATH:=C:/Program Files/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/:$(PATH)
|
||||
# Path to java used to run MPLAB X when this makefile was created
|
||||
MP_JAVA_PATH="C:\Program Files\Microchip\MPLABX\sys\java\jre1.6.0_32-windows\java-windows/bin/"
|
||||
OS_CURRENT="$(shell uname -s)"
|
||||
MP_CC="F:\SDK\Microchip\C18\bin\mcc18.exe"
|
||||
# MP_CPPC is not defined
|
||||
# MP_BC is not defined
|
||||
MP_AS="F:\SDK\Microchip\C18\bin\..\mpasm\MPASMWIN.exe"
|
||||
MP_LD="F:\SDK\Microchip\C18\bin\mplink.exe"
|
||||
MP_AR="F:\SDK\Microchip\C18\bin\mplib.exe"
|
||||
DEP_GEN=${MP_JAVA_PATH}java -jar "C:/Program Files/Microchip/MPLABX/mplab_ide/mplab_ide/modules/../../bin/extractobjectdependencies.jar"
|
||||
MP_CC_DIR="F:\SDK\Microchip\C18\bin"
|
||||
# MP_CPPC_DIR is not defined
|
||||
# MP_BC_DIR is not defined
|
||||
MP_AS_DIR="F:\SDK\Microchip\C18\bin\..\mpasm"
|
||||
MP_LD_DIR="F:\SDK\Microchip\C18\bin"
|
||||
MP_AR_DIR="F:\SDK\Microchip\C18\bin"
|
||||
# MP_BC_DIR is not defined
|
13
TL866_Updater.X/nbproject/Makefile-variables.mk
Normal file
13
TL866_Updater.X/nbproject/Makefile-variables.mk
Normal file
@ -0,0 +1,13 @@
|
||||
#
|
||||
# Generated - do not edit!
|
||||
#
|
||||
# NOCDDL
|
||||
#
|
||||
CND_BASEDIR=`pwd`
|
||||
# default configuration
|
||||
CND_ARTIFACT_DIR_default=dist/default/production
|
||||
CND_ARTIFACT_NAME_default=TL866_Updater.X.production.hex
|
||||
CND_ARTIFACT_PATH_default=dist/default/production/TL866_Updater.X.production.hex
|
||||
CND_PACKAGE_DIR_default=${CND_DISTDIR}/default/package
|
||||
CND_PACKAGE_NAME_default=tl866updater.x.tar
|
||||
CND_PACKAGE_PATH_default=${CND_DISTDIR}/default/package/tl866updater.x.tar
|
73
TL866_Updater.X/nbproject/Package-default.bash
Normal file
73
TL866_Updater.X/nbproject/Package-default.bash
Normal file
@ -0,0 +1,73 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
#
|
||||
# Generated - do not edit!
|
||||
#
|
||||
|
||||
# Macros
|
||||
TOP=`pwd`
|
||||
CND_CONF=default
|
||||
CND_DISTDIR=dist
|
||||
TMPDIR=build/${CND_CONF}/${IMAGE_TYPE}/tmp-packaging
|
||||
TMPDIRNAME=tmp-packaging
|
||||
OUTPUT_PATH=dist/${CND_CONF}/${IMAGE_TYPE}/TL866_Updater.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
|
||||
OUTPUT_BASENAME=TL866_Updater.X.${IMAGE_TYPE}.${OUTPUT_SUFFIX}
|
||||
PACKAGE_TOP_DIR=tl866updater.x/
|
||||
|
||||
# Functions
|
||||
function checkReturnCode
|
||||
{
|
||||
rc=$?
|
||||
if [ $rc != 0 ]
|
||||
then
|
||||
exit $rc
|
||||
fi
|
||||
}
|
||||
function makeDirectory
|
||||
# $1 directory path
|
||||
# $2 permission (optional)
|
||||
{
|
||||
mkdir -p "$1"
|
||||
checkReturnCode
|
||||
if [ "$2" != "" ]
|
||||
then
|
||||
chmod $2 "$1"
|
||||
checkReturnCode
|
||||
fi
|
||||
}
|
||||
function copyFileToTmpDir
|
||||
# $1 from-file path
|
||||
# $2 to-file path
|
||||
# $3 permission
|
||||
{
|
||||
cp "$1" "$2"
|
||||
checkReturnCode
|
||||
if [ "$3" != "" ]
|
||||
then
|
||||
chmod $3 "$2"
|
||||
checkReturnCode
|
||||
fi
|
||||
}
|
||||
|
||||
# Setup
|
||||
cd "${TOP}"
|
||||
mkdir -p ${CND_DISTDIR}/${CND_CONF}/package
|
||||
rm -rf ${TMPDIR}
|
||||
mkdir -p ${TMPDIR}
|
||||
|
||||
# Copy files and create directories and links
|
||||
cd "${TOP}"
|
||||
makeDirectory ${TMPDIR}/tl866updater.x/bin
|
||||
copyFileToTmpDir "${OUTPUT_PATH}" "${TMPDIR}/${PACKAGE_TOP_DIR}bin/${OUTPUT_BASENAME}" 0755
|
||||
|
||||
|
||||
# Generate tar file
|
||||
cd "${TOP}"
|
||||
rm -f ${CND_DISTDIR}/${CND_CONF}/package/tl866updater.x.tar
|
||||
cd ${TMPDIR}
|
||||
tar -vcf ../../../../${CND_DISTDIR}/${CND_CONF}/package/tl866updater.x.tar *
|
||||
checkReturnCode
|
||||
|
||||
# Cleanup
|
||||
cd "${TOP}"
|
||||
rm -rf ${TMPDIR}
|
148
TL866_Updater.X/nbproject/configurations.xml
Normal file
148
TL866_Updater.X/nbproject/configurations.xml
Normal file
@ -0,0 +1,148 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configurationDescriptor version="62">
|
||||
<logicalFolder name="root" displayName="root" projectFiles="true">
|
||||
<logicalFolder name="HeaderFiles"
|
||||
displayName="Header Files"
|
||||
projectFiles="true">
|
||||
<itemPath>config_bits.h</itemPath>
|
||||
<itemPath>main.h</itemPath>
|
||||
<itemPath>usb_config.h</itemPath>
|
||||
<itemPath>HardwareProfile.h</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="LinkerScript"
|
||||
displayName="Linker Files"
|
||||
projectFiles="true">
|
||||
<itemPath>18f87j50.lkr</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="SourceFiles"
|
||||
displayName="Source Files"
|
||||
projectFiles="true">
|
||||
<itemPath>main.c</itemPath>
|
||||
<itemPath>usb_descriptors.c</itemPath>
|
||||
<itemPath>F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/USB/Generic Device Driver/usb_function_generic.c</itemPath>
|
||||
<itemPath>F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/USB/usb_device.c</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="ExternalFiles"
|
||||
displayName="Important Files"
|
||||
projectFiles="false">
|
||||
<itemPath>Makefile</itemPath>
|
||||
</logicalFolder>
|
||||
</logicalFolder>
|
||||
<projectmakefile>Makefile</projectmakefile>
|
||||
<confs>
|
||||
<conf name="default" type="2">
|
||||
<toolsSet>
|
||||
<developmentServer>localhost</developmentServer>
|
||||
<targetDevice>PIC18F87J50</targetDevice>
|
||||
<targetHeader></targetHeader>
|
||||
<targetPluginBoard></targetPluginBoard>
|
||||
<platformTool>Simulator</platformTool>
|
||||
<languageToolchain>C18</languageToolchain>
|
||||
<languageToolchainVersion>3.45</languageToolchainVersion>
|
||||
<platform>3</platform>
|
||||
</toolsSet>
|
||||
<compileType>
|
||||
<linkerTool>
|
||||
<linkerLibItems>
|
||||
</linkerLibItems>
|
||||
</linkerTool>
|
||||
<loading>
|
||||
<useAlternateLoadableFile>false</useAlternateLoadableFile>
|
||||
<alternateLoadableFile></alternateLoadableFile>
|
||||
</loading>
|
||||
</compileType>
|
||||
<makeCustomizationType>
|
||||
<makeCustomizationPreStepEnabled>false</makeCustomizationPreStepEnabled>
|
||||
<makeCustomizationPreStep></makeCustomizationPreStep>
|
||||
<makeCustomizationPostStepEnabled>false</makeCustomizationPostStepEnabled>
|
||||
<makeCustomizationPostStep></makeCustomizationPostStep>
|
||||
<makeCustomizationPutChecksumInUserID>false</makeCustomizationPutChecksumInUserID>
|
||||
<makeCustomizationEnableLongLines>false</makeCustomizationEnableLongLines>
|
||||
<makeCustomizationNormalizeHexFile>false</makeCustomizationNormalizeHexFile>
|
||||
</makeCustomizationType>
|
||||
<C18>
|
||||
<property key="code-model" value="ms"/>
|
||||
<property key="data-model" value="oa-"/>
|
||||
<property key="default-char-unsigned" value="false"/>
|
||||
<property key="enable-all-optimizations" value="true"/>
|
||||
<property key="enable-int-promotion" value="false"/>
|
||||
<property key="enable-multi-bank-stack-model" value="false"/>
|
||||
<property key="enable-ob" value="true"/>
|
||||
<property key="enable-od" value="true"/>
|
||||
<property key="enable-om" value="true"/>
|
||||
<property key="enable-on" value="true"/>
|
||||
<property key="enable-op" value="true"/>
|
||||
<property key="enable-opa" value="true"/>
|
||||
<property key="enable-or" value="true"/>
|
||||
<property key="enable-os" value="true"/>
|
||||
<property key="enable-ot" value="true"/>
|
||||
<property key="enable-ou" value="true"/>
|
||||
<property key="enable-ow" value="true"/>
|
||||
<property key="extra-include-directories"
|
||||
value="F:/SDK/Microchip/microchip_solutions_v2013-06-15/Microchip/Include;./"/>
|
||||
<property key="optimization-master" value="Enable all"/>
|
||||
<property key="preprocessor-macros" value=""/>
|
||||
<property key="procedural-abstraction-passes" value="0"/>
|
||||
<property key="storage-class" value="sca"/>
|
||||
<property key="verbose" value="false"/>
|
||||
<property key="warning-level" value="2"/>
|
||||
</C18>
|
||||
<C18-AS>
|
||||
<property key="cross.reference.file" value=""/>
|
||||
<property key="default.radix" value="HEX"/>
|
||||
<property key="enable.case.sensitivity" value="true"/>
|
||||
<property key="hex.output.format" value="INHX32"/>
|
||||
<property key="preprocessor.macros" value=""/>
|
||||
<property key="warning.level" value="0"/>
|
||||
</C18-AS>
|
||||
<C18-LD>
|
||||
<property key="cod-file" value="false"/>
|
||||
<property key="extra-lib-directories" value=""/>
|
||||
<property key="hex-output-format" value="INHX32"/>
|
||||
<property key="map-file" value=""/>
|
||||
</C18-LD>
|
||||
<C18LanguageToolchain>
|
||||
<property key="extended-mode" value="false"/>
|
||||
<property key="extended-mode-mcc18" value="false"/>
|
||||
<property key="extended-mode-mpasm" value="false"/>
|
||||
<property key="extended-mode-mplink" value="false"/>
|
||||
<property key="stack-analysis" value="false"/>
|
||||
<property key="stack-analysis-mcc18" value="false"/>
|
||||
<property key="stack-analysis-mplink" value="false"/>
|
||||
</C18LanguageToolchain>
|
||||
<Simulator>
|
||||
<property key="animationupdates.realtimewatchupdates" value="false"/>
|
||||
<property key="animationupdates.steptime" value=""/>
|
||||
<property key="animationupdates.updatetime" value=""/>
|
||||
<property key="breakoptions.coreerrors" value="Ignore"/>
|
||||
<property key="breakoptions.corewarnings" value="Ignore"/>
|
||||
<property key="breakoptions.peripheralerrors" value="Ignore"/>
|
||||
<property key="breakoptions.peripheralwarnings" value="Ignore"/>
|
||||
<property key="breakoptions.stimulusmessages.notes" value="Ignore"/>
|
||||
<property key="breakoptions.stimulusmessags.errors" value="Ignore"/>
|
||||
<property key="breakoptions.stimulusmessags.warnings" value="Ignore"/>
|
||||
<property key="breakoptions.wdtwarnings" value="Ignore"/>
|
||||
<property key="codecoverage.enabled" value="Disable"/>
|
||||
<property key="codecoverage.enableoutputtofile" value="false"/>
|
||||
<property key="codecoverage.outputfile" value=""/>
|
||||
<property key="oscillator.auxfrequency" value="120"/>
|
||||
<property key="oscillator.auxfrequencyunit" value="Mega"/>
|
||||
<property key="oscillator.frequency" value="1"/>
|
||||
<property key="oscillator.frequencyunit" value="Mega"/>
|
||||
<property key="oscillator.rcfrequency" value="250"/>
|
||||
<property key="oscillator.rcfrequencyunit" value="Kilo"/>
|
||||
<property key="performancedata.show" value="false"/>
|
||||
<property key="periphADC1.altscl" value="false"/>
|
||||
<property key="periphADC2.altscl" value="false"/>
|
||||
<property key="tracecontrol.select" value="0"/>
|
||||
<property key="tracecontrol.timestamp" value="2"/>
|
||||
<property key="tracecontrol.tracebufmax" value="54600"/>
|
||||
<property key="tracecontrol.tracefile" value="C:\Users\radioman\mpdeftrace.log"/>
|
||||
<property key="tracecontrol.traceresetonrun" value="false"/>
|
||||
<property key="uart1io.output" value="window"/>
|
||||
<property key="uart1io.outputfile" value=""/>
|
||||
<property key="uart1io.uartioenabled" value="false"/>
|
||||
</Simulator>
|
||||
</conf>
|
||||
</confs>
|
||||
</configurationDescriptor>
|
25
TL866_Updater.X/nbproject/private/configurations.xml
Normal file
25
TL866_Updater.X/nbproject/private/configurations.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configurationDescriptor version="62">
|
||||
<projectmakefile>Makefile</projectmakefile>
|
||||
<defaultConf>0</defaultConf>
|
||||
<confs>
|
||||
<conf name="default" type="2">
|
||||
<platformToolSN></platformToolSN>
|
||||
<languageToolchainDir>F:\SDK\Microchip\C18\bin</languageToolchainDir>
|
||||
<mdbdebugger version="1">
|
||||
<placeholder1>place holder 1</placeholder1>
|
||||
<placeholder2>place holder 2</placeholder2>
|
||||
</mdbdebugger>
|
||||
<runprofile version="6">
|
||||
<args></args>
|
||||
<rundir></rundir>
|
||||
<buildfirst>true</buildfirst>
|
||||
<console-type>0</console-type>
|
||||
<terminal-type>0</terminal-type>
|
||||
<remove-instrumentation>0</remove-instrumentation>
|
||||
<environment>
|
||||
</environment>
|
||||
</runprofile>
|
||||
</conf>
|
||||
</confs>
|
||||
</configurationDescriptor>
|
4
TL866_Updater.X/nbproject/private/private.xml
Normal file
4
TL866_Updater.X/nbproject/private/private.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
|
||||
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
|
||||
</project-private>
|
0
TL866_Updater.X/nbproject/project.properties
Normal file
0
TL866_Updater.X/nbproject/project.properties
Normal file
16
TL866_Updater.X/nbproject/project.xml
Normal file
16
TL866_Updater.X/nbproject/project.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>com.microchip.mplab.nbide.embedded.makeproject</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/make-project/1">
|
||||
<name>TL866_Updater</name>
|
||||
<creation-uuid>c6c863ce-cc00-448b-983f-c3179648c58d</creation-uuid>
|
||||
<make-project-type>0</make-project-type>
|
||||
<c-extensions>c</c-extensions>
|
||||
<cpp-extensions/>
|
||||
<header-extensions>h</header-extensions>
|
||||
<sourceEncoding>ISO-8859-1</sourceEncoding>
|
||||
<make-dep-projects/>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
168
TL866_Updater.X/usb_config.h
Normal file
168
TL866_Updater.X/usb_config.h
Normal file
@ -0,0 +1,168 @@
|
||||
/********************************************************************
|
||||
FileName: usb_config.h
|
||||
Dependencies: Always: GenericTypeDefs.h, usb_device.h
|
||||
Situational: usb_function_hid.h, usb_function_cdc.h, usb_function_msd.h, etc.
|
||||
Processor: PIC18 or PIC24 USB Microcontrollers
|
||||
Hardware: The code is natively intended to be used on the following
|
||||
hardware platforms: PICDEM<EFBFBD> FS USB Demo Board,
|
||||
PIC18F87J50 FS USB Plug-In Module, or
|
||||
Explorer 16 + PIC24 USB PIM. The firmware may be
|
||||
modified for use on other USB platforms by editing the
|
||||
HardwareProfile.h file.
|
||||
Complier: Microchip C18 (for PIC18) or C30 (for PIC24)
|
||||
Company: Microchip Technology, Inc.
|
||||
|
||||
Software License Agreement:
|
||||
|
||||
The software supplied herewith by Microchip Technology Incorporated
|
||||
(the <EFBFBD>Company<EFBFBD>) for its PIC<EFBFBD> Microcontroller is intended and
|
||||
supplied to you, the Company<EFBFBD>s customer, for use solely and
|
||||
exclusively on Microchip PIC Microcontroller products. The
|
||||
software is owned by the Company and/or its supplier, and is
|
||||
protected under applicable copyright laws. All rights are reserved.
|
||||
Any use in violation of the foregoing restrictions may subject the
|
||||
user to criminal sanctions under applicable laws, as well as to
|
||||
civil liability for the breach of the terms and conditions of this
|
||||
license.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED IN AN <EFBFBD>AS IS<EFBFBD> CONDITION. NO WARRANTIES,
|
||||
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
|
||||
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
|
||||
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
|
||||
********************************************************************
|
||||
File Description:
|
||||
|
||||
Change History:
|
||||
Rev Date Description
|
||||
1.0 11/19/2004 Initial release
|
||||
2.1 02/26/2007 Updated for simplicity and to use common
|
||||
coding style
|
||||
*******************************************************************/
|
||||
|
||||
/*********************************************************************
|
||||
* Descriptor specific type definitions are defined in: usbd.h
|
||||
********************************************************************/
|
||||
|
||||
#ifndef USBCFG_H
|
||||
#define USBCFG_H
|
||||
|
||||
/** DEFINITIONS ****************************************************/
|
||||
#define USB_EP0_BUFF_SIZE 8 // Valid Options: 8, 16, 32, or 64 bytes.
|
||||
// Using larger options take more SRAM, but
|
||||
// does not provide much advantage in most types
|
||||
// of applications. Exceptions to this, are applications
|
||||
// that use EP0 IN or OUT for sending large amounts of
|
||||
// application related data.
|
||||
|
||||
#define USB_MAX_NUM_INT 1 // For tracking Alternate Setting
|
||||
#define USB_MAX_EP_NUMBER 1
|
||||
|
||||
//Device descriptor - if these two definitions are not defined then
|
||||
// a ROM USB_DEVICE_DESCRIPTOR variable by the exact name of device_dsc
|
||||
// must exist.
|
||||
#define USB_USER_DEVICE_DESCRIPTOR &device_dsc
|
||||
#define USB_USER_DEVICE_DESCRIPTOR_INCLUDE extern ROM USB_DEVICE_DESCRIPTOR device_dsc
|
||||
|
||||
//Configuration descriptors - if these two definitions do not exist then
|
||||
// a ROM BYTE *ROM variable named exactly USB_CD_Ptr[] must exist.
|
||||
#define USB_USER_CONFIG_DESCRIPTOR USB_CD_Ptr
|
||||
#define USB_USER_CONFIG_DESCRIPTOR_INCLUDE extern ROM BYTE *ROM USB_CD_Ptr[]
|
||||
|
||||
//Make sure only one of the below "#define USB_PING_PONG_MODE"
|
||||
//is uncommented.
|
||||
//#define USB_PING_PONG_MODE USB_PING_PONG__NO_PING_PONG
|
||||
#define USB_PING_PONG_MODE USB_PING_PONG__FULL_PING_PONG
|
||||
//#define USB_PING_PONG_MODE USB_PING_PONG__EP0_OUT_ONLY
|
||||
//#define USB_PING_PONG_MODE USB_PING_PONG__ALL_BUT_EP0 //NOTE: This mode is not supported in PIC18F4550 family rev A3 devices
|
||||
|
||||
|
||||
//#define USB_POLLING
|
||||
#define USB_INTERRUPT
|
||||
|
||||
/* Parameter definitions are defined in usb_device.h */
|
||||
#define USB_PULLUP_OPTION USB_PULLUP_ENABLE
|
||||
//#define USB_PULLUP_OPTION USB_PULLUP_DISABLED
|
||||
|
||||
#define USB_TRANSCEIVER_OPTION USB_INTERNAL_TRANSCEIVER
|
||||
//External Transceiver support is not available on all product families. Please
|
||||
// refer to the product family datasheet for more information if this feature
|
||||
// is available on the target processor.
|
||||
//#define USB_TRANSCEIVER_OPTION USB_EXTERNAL_TRANSCEIVER
|
||||
|
||||
#define USB_SPEED_OPTION USB_FULL_SPEED
|
||||
//#define USB_SPEED_OPTION USB_LOW_SPEED //(not valid option for PIC24F devices)
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
//Option to enable auto-arming of the status stage of control transfers, if no
|
||||
//"progress" has been made for the USB_STATUS_STAGE_TIMEOUT value.
|
||||
//If progress is made (any successful transactions completing on EP0 IN or OUT)
|
||||
//the timeout counter gets reset to the USB_STATUS_STAGE_TIMEOUT value.
|
||||
//
|
||||
//During normal control transfer processing, the USB stack or the application
|
||||
//firmware will call USBCtrlEPAllowStatusStage() as soon as the firmware is finished
|
||||
//processing the control transfer. Therefore, the status stage completes as
|
||||
//quickly as is physically possible. The USB_ENABLE_STATUS_STAGE_TIMEOUTS
|
||||
//feature, and the USB_STATUS_STAGE_TIMEOUT value are only relevant, when:
|
||||
//1. The application uses the USBDeferStatusStage() API function, but never calls
|
||||
// USBCtrlEPAllowStatusStage(). Or:
|
||||
//2. The application uses host to device (OUT) control transfers with data stage,
|
||||
// and some abnormal error occurs, where the host might try to abort the control
|
||||
// transfer, before it has sent all of the data it claimed it was going to send.
|
||||
//
|
||||
//If the application firmware never uses the USBDeferStatusStage() API function,
|
||||
//and it never uses host to device control transfers with data stage, then
|
||||
//it is not required to enable the USB_ENABLE_STATUS_STAGE_TIMEOUTS feature.
|
||||
|
||||
#define USB_ENABLE_STATUS_STAGE_TIMEOUTS //Comment this out to disable this feature.
|
||||
|
||||
//Section 9.2.6 of the USB 2.0 specifications indicate that:
|
||||
//1. Control transfers with no data stage: Status stage must complete within
|
||||
// 50ms of the start of the control transfer.
|
||||
//2. Control transfers with (IN) data stage: Status stage must complete within
|
||||
// 50ms of sending the last IN data packet in fullfilment of the data stage.
|
||||
//3. Control transfers with (OUT) data stage: No specific status stage timing
|
||||
// requirement. However, the total time of the entire control transfer (ex:
|
||||
// including the OUT data stage and IN status stage) must not exceed 5 seconds.
|
||||
//
|
||||
//Therefore, if the USB_ENABLE_STATUS_STAGE_TIMEOUTS feature is used, it is suggested
|
||||
//to set the USB_STATUS_STAGE_TIMEOUT value to timeout in less than 50ms. If the
|
||||
//USB_ENABLE_STATUS_STAGE_TIMEOUTS feature is not enabled, then the USB_STATUS_STAGE_TIMEOUT
|
||||
//parameter is not relevant.
|
||||
|
||||
#define USB_STATUS_STAGE_TIMEOUT (BYTE)45 //Approximate timeout in milliseconds, except when
|
||||
//USB_POLLING mode is used, and USBDeviceTasks() is called at < 1kHz
|
||||
//In this special case, the timeout becomes approximately:
|
||||
//Timeout(in milliseconds) = ((1000 * (USB_STATUS_STAGE_TIMEOUT - 1)) / (USBDeviceTasks() polling frequency in Hz))
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#define USB_SUPPORT_DEVICE
|
||||
|
||||
#define USB_NUM_STRING_DESCRIPTORS 3
|
||||
|
||||
//#define USB_INTERRUPT_LEGACY_CALLBACKS
|
||||
#define USB_ENABLE_ALL_HANDLERS
|
||||
//#define USB_ENABLE_SUSPEND_HANDLER
|
||||
//#define USB_ENABLE_WAKEUP_FROM_SUSPEND_HANDLER
|
||||
//#define USB_ENABLE_SOF_HANDLER
|
||||
//#define USB_ENABLE_ERROR_HANDLER
|
||||
//#define USB_ENABLE_OTHER_REQUEST_HANDLER
|
||||
//#define USB_ENABLE_SET_DESCRIPTOR_HANDLER
|
||||
//#define USB_ENABLE_INIT_EP_HANDLER
|
||||
//#define USB_ENABLE_EP0_DATA_HANDLER
|
||||
//#define USB_ENABLE_TRANSFER_COMPLETE_HANDLER
|
||||
|
||||
/** DEVICE CLASS USAGE *********************************************/
|
||||
#define USB_USE_GEN
|
||||
|
||||
/** ENDPOINTS ALLOCATION *******************************************/
|
||||
|
||||
/* Generic */
|
||||
#define USBGEN_EP_SIZE 64
|
||||
#define USBGEN_EP_NUM 1
|
||||
|
||||
/** DEFINITIONS ****************************************************/
|
||||
|
||||
#endif //USBCFG_H
|
274
TL866_Updater.X/usb_descriptors.c
Normal file
274
TL866_Updater.X/usb_descriptors.c
Normal file
@ -0,0 +1,274 @@
|
||||
/********************************************************************
|
||||
FileName: usb_descriptors.c
|
||||
Dependencies: See INCLUDES section
|
||||
Processor: PIC18 or PIC24 USB Microcontrollers
|
||||
Hardware: The code is natively intended to be used on the following
|
||||
hardware platforms: PICDEM™ FS USB Demo Board,
|
||||
PIC18F87J50 FS USB Plug-In Module, or
|
||||
Explorer 16 + PIC24 USB PIM. The firmware may be
|
||||
modified for use on other USB platforms by editing the
|
||||
HardwareProfile.h file.
|
||||
Complier: Microchip C18 (for PIC18) or C30 (for PIC24)
|
||||
Company: Microchip Technology, Inc.
|
||||
|
||||
Software License Agreement:
|
||||
|
||||
The software supplied herewith by Microchip Technology Incorporated
|
||||
(the “Company”) for its PIC® Microcontroller is intended and
|
||||
supplied to you, the Company’s customer, for use solely and
|
||||
exclusively on Microchip PIC Microcontroller products. The
|
||||
software is owned by the Company and/or its supplier, and is
|
||||
protected under applicable copyright laws. All rights are reserved.
|
||||
Any use in violation of the foregoing restrictions may subject the
|
||||
user to criminal sanctions under applicable laws, as well as to
|
||||
civil liability for the breach of the terms and conditions of this
|
||||
license.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
|
||||
WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
|
||||
TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
|
||||
IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
||||
|
||||
*********************************************************************
|
||||
-usb_descriptors.c-
|
||||
-------------------------------------------------------------------
|
||||
Filling in the descriptor values in the usb_descriptors.c file:
|
||||
-------------------------------------------------------------------
|
||||
|
||||
[Device Descriptors]
|
||||
The device descriptor is defined as a USB_DEVICE_DESCRIPTOR type.
|
||||
This type is defined in usb_ch9.h Each entry into this structure
|
||||
needs to be the correct length for the data type of the entry.
|
||||
|
||||
[Configuration Descriptors]
|
||||
The configuration descriptor was changed in v2.x from a structure
|
||||
to a BYTE array. Given that the configuration is now a byte array
|
||||
each byte of multi-byte fields must be listed individually. This
|
||||
means that for fields like the total size of the configuration where
|
||||
the field is a 16-bit value "64,0," is the correct entry for a
|
||||
configuration that is only 64 bytes long and not "64," which is one
|
||||
too few bytes.
|
||||
|
||||
The configuration attribute must always have the _DEFAULT
|
||||
definition at the minimum. Additional options can be ORed
|
||||
to the _DEFAULT attribute. Available options are _SELF and _RWU.
|
||||
These definitions are defined in the usb_device.h file. The
|
||||
_SELF tells the USB host that this device is self-powered. The
|
||||
_RWU tells the USB host that this device supports Remote Wakeup.
|
||||
|
||||
[Endpoint Descriptors]
|
||||
Like the configuration descriptor, the endpoint descriptors were
|
||||
changed in v2.x of the stack from a structure to a BYTE array. As
|
||||
endpoint descriptors also has a field that are multi-byte entities,
|
||||
please be sure to specify both bytes of the field. For example, for
|
||||
the endpoint size an endpoint that is 64 bytes needs to have the size
|
||||
defined as "64,0," instead of "64,"
|
||||
|
||||
Take the following example:
|
||||
// Endpoint Descriptor //
|
||||
0x07, //the size of this descriptor //
|
||||
USB_DESCRIPTOR_ENDPOINT, //Endpoint Descriptor
|
||||
_EP02_IN, //EndpointAddress
|
||||
_INT, //Attributes
|
||||
0x08,0x00, //size (note: 2 bytes)
|
||||
0x02, //Interval
|
||||
|
||||
The first two parameters are self-explanatory. They specify the
|
||||
length of this endpoint descriptor (7) and the descriptor type.
|
||||
The next parameter identifies the endpoint, the definitions are
|
||||
defined in usb_device.h and has the following naming
|
||||
convention:
|
||||
_EP<##>_<dir>
|
||||
where ## is the endpoint number and dir is the direction of
|
||||
transfer. The dir has the value of either 'OUT' or 'IN'.
|
||||
The next parameter identifies the type of the endpoint. Available
|
||||
options are _BULK, _INT, _ISO, and _CTRL. The _CTRL is not
|
||||
typically used because the default control transfer endpoint is
|
||||
not defined in the USB descriptors. When _ISO option is used,
|
||||
addition options can be ORed to _ISO. Example:
|
||||
_ISO|_AD|_FE
|
||||
This describes the endpoint as an isochronous pipe with adaptive
|
||||
and feedback attributes. See usb_device.h and the USB
|
||||
specification for details. The next parameter defines the size of
|
||||
the endpoint. The last parameter in the polling interval.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Adding a USB String
|
||||
-------------------------------------------------------------------
|
||||
A string descriptor array should have the following format:
|
||||
|
||||
rom struct{byte bLength;byte bDscType;word string[size];}sdxxx={
|
||||
sizeof(sdxxx),DSC_STR,<text>};
|
||||
|
||||
The above structure provides a means for the C compiler to
|
||||
calculate the length of string descriptor sdxxx, where xxx is the
|
||||
index number. The first two bytes of the descriptor are descriptor
|
||||
length and type. The rest <text> are string texts which must be
|
||||
in the unicode format. The unicode format is achieved by declaring
|
||||
each character as a word type. The whole text string is declared
|
||||
as a word array with the number of characters equals to <size>.
|
||||
<size> has to be manually counted and entered into the array
|
||||
declaration. Let's study this through an example:
|
||||
if the string is "USB" , then the string descriptor should be:
|
||||
(Using index 02)
|
||||
rom struct{byte bLength;byte bDscType;word string[3];}sd002={
|
||||
sizeof(sd002),DSC_STR,'U','S','B'};
|
||||
|
||||
A USB project may have multiple strings and the firmware supports
|
||||
the management of multiple strings through a look-up table.
|
||||
The look-up table is defined as:
|
||||
rom const unsigned char *rom USB_SD_Ptr[]={&sd000,&sd001,&sd002};
|
||||
|
||||
The above declaration has 3 strings, sd000, sd001, and sd002.
|
||||
Strings can be removed or added. sd000 is a specialized string
|
||||
descriptor. It defines the language code, usually this is
|
||||
US English (0x0409). The index of the string must match the index
|
||||
position of the USB_SD_Ptr array, &sd000 must be in position
|
||||
USB_SD_Ptr[0], &sd001 must be in position USB_SD_Ptr[1] and so on.
|
||||
The look-up table USB_SD_Ptr is used by the get string handler
|
||||
function.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
||||
The look-up table scheme also applies to the configuration
|
||||
descriptor. A USB device may have multiple configuration
|
||||
descriptors, i.e. CFG01, CFG02, etc. To add a configuration
|
||||
descriptor, user must implement a structure similar to CFG01.
|
||||
The next step is to add the configuration descriptor name, i.e.
|
||||
cfg01, cfg02,.., to the look-up table USB_CD_Ptr. USB_CD_Ptr[0]
|
||||
is a dummy place holder since configuration 0 is the un-configured
|
||||
state according to the definition in the USB specification.
|
||||
|
||||
********************************************************************/
|
||||
|
||||
/*********************************************************************
|
||||
* Descriptor specific type definitions are defined in:
|
||||
* usb_device.h
|
||||
*
|
||||
* Configuration options are defined in:
|
||||
* usb_config.h
|
||||
********************************************************************/
|
||||
#ifndef __USB_DESCRIPTORS_C
|
||||
#define __USB_DESCRIPTORS_C
|
||||
|
||||
/** INCLUDES *******************************************************/
|
||||
#include "./USB/usb.h"
|
||||
|
||||
/** CONSTANTS ******************************************************/
|
||||
#if defined(__18CXX)
|
||||
#pragma romdata
|
||||
#endif
|
||||
|
||||
/* Device Descriptor */
|
||||
ROM USB_DEVICE_DESCRIPTOR device_dsc ={
|
||||
0x12, // Size of this descriptor in bytes
|
||||
USB_DESCRIPTOR_DEVICE, // DEVICE descriptor type
|
||||
0x0200, // USB Spec Release Number in BCD format
|
||||
0x00, // Class Code
|
||||
0x00, // Subclass code
|
||||
0x00, // Protocol code
|
||||
USB_EP0_BUFF_SIZE, // Max packet size for EP0, see usb_config.h
|
||||
0x04D8, // Vendor ID: 0x04D8 is Microchip's Vendor ID
|
||||
0xE11C, // Product ID: 0xE11C
|
||||
0x0000, // Device release number in BCD format
|
||||
0x01, // Manufacturer string index
|
||||
0x02, // Product string index
|
||||
0x00, // Device serial number string index
|
||||
0x01 // Number of possible configurations
|
||||
};
|
||||
|
||||
/* Configuration 1 Descriptor */
|
||||
ROM BYTE configDescriptor1[] = {
|
||||
/* Configuration Descriptor */
|
||||
0x09, //sizeof(USB_CFG_DSC), // Size of this descriptor in bytes
|
||||
USB_DESCRIPTOR_CONFIGURATION, // CONFIGURATION descriptor type
|
||||
0x20, 0x00, // Total length of data for this cfg
|
||||
1, // Number of interfaces in this cfg
|
||||
1, // Index value of this configuration
|
||||
0, // Configuration string index
|
||||
_DEFAULT | _SELF, // Attributes, see usb_device.h
|
||||
50, // Max power consumption (2X mA)
|
||||
|
||||
/* Interface Descriptor */
|
||||
0x09, //sizeof(USB_INTF_DSC), // Size of this descriptor in bytes
|
||||
USB_DESCRIPTOR_INTERFACE, // INTERFACE descriptor type
|
||||
0, // Interface Number
|
||||
0, // Alternate Setting Number
|
||||
2, // Number of endpoints in this intf
|
||||
0x00, // Class code
|
||||
0x00, // Subclass code
|
||||
0x00, // Protocol code
|
||||
0, // Interface string index
|
||||
|
||||
/* Endpoint Descriptor */
|
||||
0x07, /*sizeof(USB_EP_DSC)*/
|
||||
USB_DESCRIPTOR_ENDPOINT, //Endpoint Descriptor
|
||||
_EP01_OUT, //EndpointAddress
|
||||
_BULK, //Attributes
|
||||
USBGEN_EP_SIZE, 0x00, //size
|
||||
1, //Interval
|
||||
|
||||
0x07, /*sizeof(USB_EP_DSC)*/
|
||||
USB_DESCRIPTOR_ENDPOINT, //Endpoint Descriptor
|
||||
_EP01_IN, //EndpointAddress
|
||||
_BULK, //Attributes
|
||||
USBGEN_EP_SIZE, 0x00, //size
|
||||
1 //Interval
|
||||
};
|
||||
|
||||
|
||||
//Language code string descriptor
|
||||
|
||||
ROM struct {
|
||||
BYTE bLength;
|
||||
BYTE bDscType;
|
||||
WORD string[1];
|
||||
}
|
||||
sd000 = {
|
||||
sizeof(sd000), USB_DESCRIPTOR_STRING,
|
||||
{
|
||||
0x0409}
|
||||
};
|
||||
|
||||
//Manufacturer string descriptor
|
||||
|
||||
ROM struct {
|
||||
BYTE bLength;
|
||||
BYTE bDscType;
|
||||
WORD string[9];
|
||||
}
|
||||
sd001 = {
|
||||
sizeof(sd001), USB_DESCRIPTOR_STRING,
|
||||
{
|
||||
'R', 'a', 'd', 'i', 'o', 's', 'o', 'f', 't'}
|
||||
};
|
||||
|
||||
//Product string descriptor
|
||||
|
||||
ROM struct {
|
||||
BYTE bLength;
|
||||
BYTE bDscType;
|
||||
WORD string[10];
|
||||
}
|
||||
sd002 = {
|
||||
sizeof(sd002), USB_DESCRIPTOR_STRING,
|
||||
{
|
||||
'T', 'L', '8', '6', '6', ' ', 'T', 'e', 's', 't'}
|
||||
};
|
||||
|
||||
//Array of configuration descriptors
|
||||
ROM BYTE *ROM USB_CD_Ptr[] ={
|
||||
(ROM BYTE * ROM) & configDescriptor1
|
||||
};
|
||||
//Array of string descriptors
|
||||
ROM BYTE *ROM USB_SD_Ptr[] ={
|
||||
(ROM BYTE * ROM) & sd000,
|
||||
(ROM BYTE * ROM) & sd001,
|
||||
(ROM BYTE * ROM) & sd002
|
||||
};
|
||||
|
||||
/** EOF usb_descriptors.c ***************************************************/
|
||||
|
||||
#endif
|
56
TL866_Updater/TL866_Updater.pro
Normal file
56
TL866_Updater/TL866_Updater.pro
Normal file
@ -0,0 +1,56 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2014-01-28T20:16:00
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = TL866_Updater
|
||||
TEMPLATE = app
|
||||
|
||||
|
||||
SOURCES += main.cpp\
|
||||
mainwindow.cpp \
|
||||
advdialog.cpp \
|
||||
firmware.cpp \
|
||||
crc16.cpp \
|
||||
editdialog.cpp \
|
||||
hexwriter.cpp \
|
||||
notifier.cpp
|
||||
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
advdialog.h \
|
||||
firmware.h \
|
||||
crc16.h \
|
||||
editdialog.h \
|
||||
hexwriter.h \
|
||||
notifier.h \
|
||||
tl866_global.h
|
||||
|
||||
FORMS += mainwindow.ui \
|
||||
editdialog.ui \
|
||||
advdialog.ui
|
||||
|
||||
RESOURCES += \
|
||||
resources.qrc
|
||||
|
||||
unix:!macx{
|
||||
HEADERS += usb_linux.h
|
||||
SOURCES += usb_linux.cpp
|
||||
QMAKE_CXXFLAGS += -Wno-aggressive-loop-optimizations
|
||||
LIBS += -ludev \
|
||||
-lusb-1.0
|
||||
}
|
||||
|
||||
win32:{
|
||||
HEADERS += usb_win.h
|
||||
SOURCES += usb_win.cpp
|
||||
LIBS += user32.lib \
|
||||
Setupapi.lib
|
||||
RC_FILE = win_resources.rc
|
||||
}
|
||||
|
109
TL866_Updater/advdialog.cpp
Normal file
109
TL866_Updater/advdialog.cpp
Normal file
@ -0,0 +1,109 @@
|
||||
/* Advanced Dialog window class
|
||||
*
|
||||
* This file is part of the TL866 updater project.
|
||||
*
|
||||
* Copyright (C) radioman 2013
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "advdialog.h"
|
||||
#include "ui_advdialog.h"
|
||||
#include "editdialog.h"
|
||||
#include "mainwindow.h"
|
||||
#include "tl866_global.h"
|
||||
|
||||
|
||||
AdvDialog::AdvDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::AdvDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setFixedSize(size());
|
||||
}
|
||||
|
||||
AdvDialog::~AdvDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void AdvDialog::SetSerial(QString devcode, QString serial)
|
||||
{
|
||||
ui->txtDevcode->clear();
|
||||
ui->txtSerial->clear();
|
||||
ui->txtDevcode->setText(devcode);
|
||||
ui->txtSerial->setText(serial);
|
||||
device_code = devcode;
|
||||
serial_number = serial;
|
||||
}
|
||||
|
||||
void AdvDialog::SetInfo(QString info)
|
||||
{
|
||||
ui->txtInfo->clear();
|
||||
ui->txtInfo->setText(info);
|
||||
}
|
||||
|
||||
void AdvDialog::SetUi(bool cp, int type)
|
||||
{
|
||||
if(type == VERSION_TL866A)
|
||||
ui->radioA->setChecked(true);
|
||||
if(type == VERSION_TL866CS)
|
||||
ui->radioCS->setChecked(true);
|
||||
ui->optionCP->setChecked(cp);
|
||||
}
|
||||
|
||||
void AdvDialog::on_btnEdit_clicked()
|
||||
{
|
||||
EditDialog* dlg=new EditDialog(this);
|
||||
QString devcode =ui->txtDevcode->text();
|
||||
QString serial =ui->txtSerial->text();
|
||||
dlg->SetText(devcode,serial);
|
||||
if(dlg->exec()==QDialog::Accepted)
|
||||
{
|
||||
dlg->GetResult(&devcode, &serial);
|
||||
ui->txtDevcode->setText(devcode);
|
||||
ui->txtSerial->setText(serial);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AdvDialog::on_btnDefault_clicked()
|
||||
{
|
||||
((MainWindow*)this->parent())->set_default(ui->txtDevcode, ui->txtSerial);
|
||||
}
|
||||
|
||||
void AdvDialog::on_btnClone_clicked()
|
||||
{
|
||||
((MainWindow*)this->parent())->Refresh();
|
||||
ui->txtDevcode->setText(device_code);
|
||||
ui->txtSerial->setText(serial_number);
|
||||
}
|
||||
|
||||
void AdvDialog::on_btnWriteBootloader_clicked()
|
||||
{
|
||||
((MainWindow*)this->parent())->WriteBootloader(ui->radioA->isChecked() ? A_BOOTLOADER : CS_BOOTLOADER);
|
||||
}
|
||||
|
||||
void AdvDialog::on_btnWriteConfig_clicked()
|
||||
{
|
||||
((MainWindow*)this->parent())->WriteConfig(ui->optionCP->isChecked());
|
||||
}
|
||||
|
||||
void AdvDialog::on_btnWriteInfo_clicked()
|
||||
{
|
||||
((MainWindow*)this->parent())->WriteInfo(ui->txtDevcode->text(), ui->txtSerial->text());
|
||||
}
|
36
TL866_Updater/advdialog.h
Normal file
36
TL866_Updater/advdialog.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef ADVDIALOG_H
|
||||
#define ADVDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class AdvDialog;
|
||||
}
|
||||
|
||||
class AdvDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AdvDialog(QWidget *parent = 0);
|
||||
~AdvDialog();
|
||||
void SetSerial(QString devcode, QString serial);
|
||||
void SetInfo(QString info);
|
||||
void SetUi(bool cp, int type);
|
||||
|
||||
private slots:
|
||||
void on_btnEdit_clicked();
|
||||
void on_btnDefault_clicked();
|
||||
void on_btnClone_clicked();
|
||||
void on_btnWriteBootloader_clicked();
|
||||
void on_btnWriteConfig_clicked();
|
||||
void on_btnWriteInfo_clicked();
|
||||
|
||||
private:
|
||||
Ui::AdvDialog *ui;
|
||||
QString device_code;
|
||||
QString serial_number;
|
||||
|
||||
};
|
||||
|
||||
#endif // DIALOG2_H
|
444
TL866_Updater/advdialog.ui
Normal file
444
TL866_Updater/advdialog.ui
Normal file
@ -0,0 +1,444 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AdvDialog</class>
|
||||
<widget class="QDialog" name="AdvDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>610</width>
|
||||
<height>322</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Advanced</string>
|
||||
</property>
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="btnOK">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>518</x>
|
||||
<y>288</y>
|
||||
<width>75</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="txtInfo">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>12</x>
|
||||
<y>12</y>
|
||||
<width>581</width>
|
||||
<height>79</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Courier New</family>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QTextEdit{color: black; background-color: rgb(255, 255, 225)};</string>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>12</x>
|
||||
<y>97</y>
|
||||
<width>331</width>
|
||||
<height>67</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>11</pointsize>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Bootloader</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="btnWriteBootloader">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>31</y>
|
||||
<width>75</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Write</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioA">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>91</x>
|
||||
<y>34</y>
|
||||
<width>101</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>A Bootloader</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioCS">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>202</x>
|
||||
<y>34</y>
|
||||
<width>120</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>CS Bootloader</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>352</x>
|
||||
<y>97</y>
|
||||
<width>241</width>
|
||||
<height>67</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Copy protection</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="btnWriteConfig">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>16</x>
|
||||
<y>31</y>
|
||||
<width>75</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Write</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="optionCP">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>98</x>
|
||||
<y>34</y>
|
||||
<width>138</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Code protection bit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>12</x>
|
||||
<y>170</y>
|
||||
<width>591</width>
|
||||
<height>108</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>11</pointsize>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Device Serial number</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>16</x>
|
||||
<y>27</y>
|
||||
<width>85</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Device code</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>131</x>
|
||||
<y>27</y>
|
||||
<width>91</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Serial number</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>316</x>
|
||||
<y>42</y>
|
||||
<width>269</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnEdit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnClone">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clone</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnDefault">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Default</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnWriteInfo">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>75</y>
|
||||
<width>75</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Write</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="txtSerial">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>97</x>
|
||||
<y>46</y>
|
||||
<width>202</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Courier New</family>
|
||||
<pointsize>10</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit{color: black; background-color: rgb(255, 255, 225)};</string>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>24</number>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="txtDevcode">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>46</y>
|
||||
<width>81</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Courier New</family>
|
||||
<pointsize>10</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit{color: black; background-color: rgb(255, 255, 225)};</string>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>25</x>
|
||||
<y>293</y>
|
||||
<width>381</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Courier New</family>
|
||||
<pointsize>10</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel{color: rgb(255, 0, 0)};</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Warning! You can brick your device here.</string>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>btnOK</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>AdvDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
56
TL866_Updater/crc16.cpp
Normal file
56
TL866_Updater/crc16.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
/* Class CRC16
|
||||
*
|
||||
* This file is part of the TL866 updater project.
|
||||
*
|
||||
* Copyright (C) radioman 2013
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "crc16.h"
|
||||
|
||||
//Precomputed crc16 table
|
||||
static const unsigned short crc16table[256] = {
|
||||
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
|
||||
0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
|
||||
0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40, 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
|
||||
0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641, 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
|
||||
0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240, 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
|
||||
0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41, 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
|
||||
0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41, 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
|
||||
0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640, 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
|
||||
0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240, 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
|
||||
0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41, 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
|
||||
0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41, 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
|
||||
0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640, 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
|
||||
0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241, 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
|
||||
0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40, 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
|
||||
0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40, 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
|
||||
0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641, 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
|
||||
};
|
||||
|
||||
|
||||
unsigned short CRC16::crc16(const unsigned char *data, unsigned int length)
|
||||
{
|
||||
unsigned short crc=0;
|
||||
while(length--)
|
||||
{
|
||||
crc=((crc>>8)^crc16table[(crc^*data++)&0xFF]);
|
||||
}
|
||||
return crc;
|
||||
}
|
12
TL866_Updater/crc16.h
Normal file
12
TL866_Updater/crc16.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef CRC16_H
|
||||
#define CRC16_H
|
||||
|
||||
class CRC16
|
||||
{
|
||||
public:
|
||||
static unsigned short crc16(const unsigned char *data, unsigned int length);
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // CRC16_H
|
BIN
TL866_Updater/dumper.bin
Normal file
BIN
TL866_Updater/dumper.bin
Normal file
Binary file not shown.
84
TL866_Updater/editdialog.cpp
Normal file
84
TL866_Updater/editdialog.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
/* Edit Dialog window class
|
||||
*
|
||||
* This file is part of the TL866 updater project.
|
||||
*
|
||||
* Copyright (C) radioman 2013
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "editdialog.h"
|
||||
#include "ui_editdialog.h"
|
||||
#include <QMessageBox>
|
||||
|
||||
EditDialog::EditDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::EditDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->buttonBox,SIGNAL(accepted()),this,SLOT(okButton_clicked()));
|
||||
setFixedSize(size());
|
||||
}
|
||||
|
||||
EditDialog::~EditDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void EditDialog::GetResult(QString* devcode, QString* serial)
|
||||
{
|
||||
*devcode = ui->txtDevcode->text();
|
||||
*serial = ui->txtSerial->text();
|
||||
}
|
||||
|
||||
void EditDialog::SetText(QString devcode, QString serial)
|
||||
{
|
||||
ui->txtDevcode->setText(devcode);
|
||||
ui->txtSerial->setText(serial);
|
||||
}
|
||||
|
||||
void EditDialog::on_btnRndDev_clicked()
|
||||
{
|
||||
int i;
|
||||
QString s;
|
||||
for(i=0;i<8;i++)
|
||||
{
|
||||
s.append(QString::number( qrand() % 10));
|
||||
}
|
||||
ui->txtDevcode->setText(s);
|
||||
}
|
||||
|
||||
void EditDialog::on_btnRndSer_clicked()
|
||||
{
|
||||
int i;
|
||||
QString s;
|
||||
for(i=0;i<24;i++)
|
||||
{
|
||||
s.append(QString::number(qrand()%16,16).toUpper());
|
||||
}
|
||||
ui->txtSerial->setText(s);
|
||||
}
|
||||
|
||||
void EditDialog::okButton_clicked()
|
||||
{
|
||||
if(ui->txtDevcode->text()=="codedump" && ui->txtSerial->text()=="000000000000000000000000")
|
||||
{
|
||||
QMessageBox::warning(this, "TL866", "Please enter another device and serial code!\nThese two are reserved.");
|
||||
return;
|
||||
}
|
||||
accept();
|
||||
}
|
31
TL866_Updater/editdialog.h
Normal file
31
TL866_Updater/editdialog.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef EDITDIALOG_H
|
||||
#define EDITDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class EditDialog;
|
||||
}
|
||||
|
||||
class EditDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EditDialog(QWidget *parent = 0);
|
||||
~EditDialog();
|
||||
void GetResult(QString* devcode, QString* serial);
|
||||
void SetText(QString devcode, QString serial);
|
||||
|
||||
public slots:
|
||||
|
||||
private slots:
|
||||
void on_btnRndDev_clicked();
|
||||
void on_btnRndSer_clicked();
|
||||
void okButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::EditDialog *ui;
|
||||
};
|
||||
|
||||
#endif // EDITDIALOG_H
|
185
TL866_Updater/editdialog.ui
Normal file
185
TL866_Updater/editdialog.ui
Normal file
@ -0,0 +1,185 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>EditDialog</class>
|
||||
<widget class="QDialog" name="EditDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>471</width>
|
||||
<height>153</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>307</x>
|
||||
<y>117</y>
|
||||
<width>161</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>10</pointsize>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnRndDev">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>35</x>
|
||||
<y>63</y>
|
||||
<width>75</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Random</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnRndSer">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>238</x>
|
||||
<y>63</y>
|
||||
<width>75</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Random</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>41</x>
|
||||
<y>9</y>
|
||||
<width>85</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Device code</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>237</x>
|
||||
<y>9</y>
|
||||
<width>91</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Serial number</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="txtDevcode">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>12</x>
|
||||
<y>28</y>
|
||||
<width>117</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Courier New</family>
|
||||
<pointsize>16</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit{color: black; background-color: rgb(255, 255, 225)};</string>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>8</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="txtSerial">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>135</x>
|
||||
<y>28</y>
|
||||
<width>324</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Courier New</family>
|
||||
<pointsize>16</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit{color: black; background-color: rgb(255, 255, 225)};</string>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>24</number>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>EditDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
330
TL866_Updater/firmware.cpp
Normal file
330
TL866_Updater/firmware.cpp
Normal file
@ -0,0 +1,330 @@
|
||||
/* Class Firmware
|
||||
*
|
||||
* This file is part of the TL866 updater project.
|
||||
*
|
||||
* Copyright (C) radioman 2013
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "firmware.h"
|
||||
#include "crc16.h"
|
||||
#include <QFile>
|
||||
#include<QTime>
|
||||
|
||||
|
||||
Firmware::Firmware()
|
||||
{
|
||||
m_isValid=false;
|
||||
m_eraseA=0;
|
||||
m_eraseCS=0;
|
||||
const unsigned int poly=0xEDB88320;
|
||||
unsigned int tmp,i,j;
|
||||
for(i=0;i<sizeof(crc32Table);i++)
|
||||
{
|
||||
tmp=i;
|
||||
for(j=0;j<8;j++)
|
||||
{
|
||||
tmp=(tmp&1 ? (tmp>>1)^poly:tmp>>1);
|
||||
}
|
||||
crc32Table[i]=tmp;
|
||||
}
|
||||
qsrand(QDateTime::currentDateTime().toTime_t());
|
||||
|
||||
}
|
||||
|
||||
//Open update.dat file and decrypt it.
|
||||
int Firmware::open(const QString &filename)
|
||||
{
|
||||
m_isValid=false;
|
||||
QFile file(filename);
|
||||
if (!file.open(QFile::ReadOnly))
|
||||
return OpenError;
|
||||
|
||||
if (file.size()!=UPDATE_DAT_SIZE)
|
||||
{
|
||||
file.close();
|
||||
return FilesizeError;
|
||||
}
|
||||
|
||||
UpdateDat upd;
|
||||
if(file.read((char*)&upd,sizeof(upd))!=UPDATE_DAT_SIZE)
|
||||
{
|
||||
file.close();
|
||||
return OpenError;
|
||||
}
|
||||
file.close();
|
||||
m_eraseA = upd.A_erase;
|
||||
m_eraseCS = upd.CS_erase;
|
||||
m_version = upd.header[0];
|
||||
|
||||
unsigned int i;
|
||||
//Decrypt firmwares (first step).
|
||||
for(i=0;i<sizeof(m_firmwareA);i++)
|
||||
{
|
||||
//Try to understand these ;)
|
||||
m_firmwareA[i] = upd.A_Firmware[i] ^ upd.A_Xortable2[(i+upd.A_Index)&0x3FF] ^ upd.A_Xortable1[(i/80)&0xFF];
|
||||
m_firmwareCS[i] = upd.CS_Firmware[i] ^ upd.CS_Xortable2[(i+upd.CS_Index)&0x3FF] ^ upd.CS_Xortable1[(i/80)&0xFF];
|
||||
}
|
||||
|
||||
//Check if decryption is ok
|
||||
if((upd.A_CRC32!=crc32(m_firmwareA,sizeof(m_firmwareA)))||(upd.CS_CRC32=!crc32(m_firmwareCS,sizeof(m_firmwareCS))))
|
||||
return CRCError;
|
||||
|
||||
m_isValid=true;
|
||||
return NoError;
|
||||
}
|
||||
|
||||
//Compute CRC32
|
||||
unsigned int Firmware::crc32(unsigned char *buffer,unsigned int length)
|
||||
{
|
||||
unsigned int crc=0xFFFFFFFF;
|
||||
while(length--)
|
||||
{
|
||||
crc=((crc>>8)^crc32Table[(crc&0xFF)^*buffer++]);
|
||||
}
|
||||
return ~crc;
|
||||
}
|
||||
|
||||
//Get a magic number used in erase command
|
||||
unsigned char Firmware::GetEraseParammeter(int type)
|
||||
{
|
||||
return (type == VERSION_TL866A ? m_eraseA : m_eraseCS);
|
||||
}
|
||||
|
||||
unsigned char Firmware::GetFirmwareVersion()
|
||||
{
|
||||
return m_version;
|
||||
}
|
||||
|
||||
//Get the status of the firmware
|
||||
bool Firmware::isValid()
|
||||
{
|
||||
return m_isValid;
|
||||
}
|
||||
|
||||
|
||||
//Get encrypted firmware
|
||||
void Firmware::get_firmware(unsigned char *data_out, int type, int key)
|
||||
{
|
||||
if(type == key)
|
||||
{
|
||||
memcpy(data_out, type == VERSION_TL866A ? m_firmwareA : m_firmwareCS, ENCRYPTED_FIRMWARE_SIZE);
|
||||
return;
|
||||
}
|
||||
unsigned char data[UNENCRYPTED_FIRMWARE_SIZE];
|
||||
decrypt_firmware(data,key);
|
||||
encrypt_firmware(data,data_out,type);
|
||||
}
|
||||
|
||||
|
||||
//Encrypt firmware
|
||||
void Firmware::encrypt_firmware(const unsigned char *data_in, unsigned char *data_out, int key)
|
||||
{
|
||||
unsigned char xortable[256], data[80];
|
||||
int i,j,index=0x15;
|
||||
unsigned char* pEnc = key == A_KEY ? m_firmwareA : m_firmwareCS;
|
||||
|
||||
//extracting the xortable right from the encrypted firmware ;)
|
||||
for(i=0;i<16;i++)
|
||||
{
|
||||
for(j=0;j<16;j++)
|
||||
{
|
||||
xortable[16 * i + j] = ~(pEnc[320 * i + j + XOR_TABLE_START]);//try to understand this ;)
|
||||
}
|
||||
}
|
||||
//encrypt firmware
|
||||
|
||||
for(i=0;i<UNENCRYPTED_FIRMWARE_SIZE;i+=BLOCK_SIZE-16)
|
||||
{
|
||||
memcpy(data,data_in+i,BLOCK_SIZE-16);
|
||||
encrypt_block(data,xortable,index);
|
||||
memcpy(data_out,data,BLOCK_SIZE);
|
||||
data_out+=BLOCK_SIZE;
|
||||
index+=4;
|
||||
index&=0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
//decrypt firmware
|
||||
void Firmware::decrypt_firmware(unsigned char *data_out, int type)
|
||||
{
|
||||
unsigned char xortable[XOR_TABLE_SIZE], data[BLOCK_SIZE];
|
||||
int i,j,index=0x15;
|
||||
unsigned char* pEnc = type == VERSION_TL866A ? m_firmwareA : m_firmwareCS;
|
||||
|
||||
//extracting xortable right from the encrypted firmware ;)
|
||||
for(i=0;i<16;i++)
|
||||
{
|
||||
for(j=0;j<16;j++)
|
||||
{
|
||||
xortable[16 * i + j] = ~(pEnc[320 * i + j + XOR_TABLE_START]);
|
||||
}
|
||||
}
|
||||
//decrypt firmware
|
||||
|
||||
for(i=0;i<ENCRYPTED_FIRMWARE_SIZE;i+=BLOCK_SIZE)
|
||||
{
|
||||
memcpy(data,pEnc+i,BLOCK_SIZE);
|
||||
decrypt_block(data,xortable,index);
|
||||
memcpy(data_out,data,BLOCK_SIZE-16);
|
||||
data_out+=BLOCK_SIZE-16;
|
||||
index+=4;
|
||||
index&=0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
//encrypt a block of 80 bytes
|
||||
void Firmware::encrypt_block(unsigned char *data, unsigned char *xortable, int index)
|
||||
{
|
||||
int i;
|
||||
unsigned char o1,o2;
|
||||
//First step, fill the last 16 bytes of data buffer with random generated values.
|
||||
for(i=0;i<16;i++){
|
||||
data[i+64]=(unsigned char) qrand() % 0x100;
|
||||
}
|
||||
|
||||
/* Second step, data scrambling. We swap the first byte with the last, the fourth from the beginning with the fourth from the end and so on.
|
||||
So, we have the following 10 swaps:(0-79),(4-75),(8-71),(12-67),(16-63),(20-59),(24-55),(28-51),(32-47),(36-43).
|
||||
*/
|
||||
for(i=0;i<BLOCK_SIZE/2;i+=4){
|
||||
o1=data[i];
|
||||
data[i]=data[BLOCK_SIZE-i-1];
|
||||
data[BLOCK_SIZE-i-1]=o1;
|
||||
}
|
||||
//Next step, left shifting whole array by 3 bits.
|
||||
for(i=0;i<BLOCK_SIZE-1;i++){
|
||||
o1=(data[i]<<3) & 0xF8;
|
||||
o2=data[i+1]>>5;
|
||||
data[i]=o2 | o1;
|
||||
}
|
||||
data[BLOCK_SIZE-1]<<=3;
|
||||
data[BLOCK_SIZE-1]&=0xF8;
|
||||
|
||||
//Last step, xoring each data value with a random number from xortable. Index is incremented modulo 256
|
||||
for(i=0;i<BLOCK_SIZE;i++){
|
||||
data[i]^=xortable[index++];
|
||||
index&=0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
//decrypt a block of 80 bytes
|
||||
void Firmware::decrypt_block(unsigned char *data, unsigned char *xortable, int index)
|
||||
{
|
||||
int i;
|
||||
unsigned char o1,o2;
|
||||
//first step, xoring each element with a random value from xortable. Index is incremented modulo 256
|
||||
for(i=0;i<BLOCK_SIZE;i++){
|
||||
data[i]^=xortable[index++];
|
||||
index&=0xFF;
|
||||
}
|
||||
|
||||
//next step, right shifting whole array by 3 bits.
|
||||
for(i=0;i<BLOCK_SIZE-1;i++){
|
||||
o1=(data[BLOCK_SIZE-i-1]>>3) & 0x1F;
|
||||
o2=data[BLOCK_SIZE-i-2]<<5;
|
||||
data[BLOCK_SIZE-i-1]=o1 | o2;
|
||||
}
|
||||
data[0]>>=3;
|
||||
data[0]&=0x1F;
|
||||
|
||||
//Last step, descrambling data; put each element in the right position. At the end we have the decrypted data block ;)
|
||||
for(i=0;i<BLOCK_SIZE/2;i+=4){
|
||||
o1=data[i];
|
||||
data[i]=data[BLOCK_SIZE-i-1];
|
||||
data[BLOCK_SIZE-i-1]=o1;
|
||||
}
|
||||
}
|
||||
|
||||
//Encrypt 80 bytes data block containing dev code and serial
|
||||
void Firmware::encrypt_serial(unsigned char *key, const unsigned char *firmware)
|
||||
{
|
||||
int i,index=0x0A;
|
||||
unsigned char o1,o2;
|
||||
|
||||
|
||||
//compute the right crc16. The last two bytes in the info table is the crc16 in little-endian order and must be max. 0x1FFF, otherwise the decryption will be wrong.
|
||||
while(CRC16::crc16(key,BLOCK_SIZE-2) >0x1FFF)//a little brute-force method to match the required CRC;
|
||||
{
|
||||
for(i=32;i<BLOCK_SIZE-2;i++)
|
||||
{
|
||||
key[i] = (unsigned char) (qrand() % 0x100);
|
||||
}
|
||||
}
|
||||
ushort crc = CRC16::crc16(key,BLOCK_SIZE-2);
|
||||
key[BLOCK_SIZE-2]=(crc & 0xff);
|
||||
key[BLOCK_SIZE-1]=(crc >> 8);
|
||||
|
||||
|
||||
/*Data scrambling. We swap the first byte with the last, the fourth from the beginning with the fourth from the end and so on.
|
||||
So we have the following 10 swaps:(0-79),(4-75),(8-71),(12-67),(16-63),(20-59),(24-55),(28-51),(32-47),(36-43).
|
||||
*/
|
||||
for(i=0;i<BLOCK_SIZE/2;i+=4){
|
||||
o1=key[i];
|
||||
key[i]=key[BLOCK_SIZE-i-1];
|
||||
key[BLOCK_SIZE-i-1]=o1;
|
||||
}
|
||||
//Next step, left shift whole array by 3 bits .
|
||||
for(i=0;i<BLOCK_SIZE-1;i++){
|
||||
o1=(key[i]<<3) & 0xF8;
|
||||
o2=key[i+1]>>5;
|
||||
key[i]=o2 | o1;
|
||||
}
|
||||
key[BLOCK_SIZE-1]<<=3;
|
||||
key[BLOCK_SIZE-1]&=0xF8;
|
||||
|
||||
//Last step, xoring each info table value with a random number from xortable. The start index in this table is 0x0A. Index is incremented modulo 256
|
||||
for(i=0;i<BLOCK_SIZE;i++){
|
||||
key[i]^=firmware[XOR_TABLE_OFFSET+index];
|
||||
index++;
|
||||
index&=0xFF;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Decrypt 80 bytes data block containing dev code and serial
|
||||
void Firmware::decrypt_serial(unsigned char *key, const unsigned char *firmware)
|
||||
{
|
||||
int i,index=0x0A;
|
||||
unsigned char o1,o2;
|
||||
|
||||
//first step, xoring each element from table with a random value from xortable. Starting index is 0x0A. Index is incremented modulo 256
|
||||
for(i=0;i<BLOCK_SIZE;i++){
|
||||
key[i]^=firmware[XOR_TABLE_OFFSET+index];
|
||||
index++;
|
||||
index&=0xFF;
|
||||
}
|
||||
|
||||
/*next step, right shift whole array by 3 bits. Because anding with 0x1F, the last byte from info table must be always <0x20 in the encryption step, greater values will be trimmed at decryption step;
|
||||
this is why the crc16 must be 0x1FFF max., the last byte from info table is MSB of crc16.
|
||||
*/
|
||||
for(i=0;i<BLOCK_SIZE-1;i++){
|
||||
o1=(key[BLOCK_SIZE-i-1]>>3) & 0x1F;
|
||||
o2=key[BLOCK_SIZE-i-2]<<5;
|
||||
key[BLOCK_SIZE-i-1]=o1 | o2;
|
||||
}
|
||||
key[0]>>=3;
|
||||
key[0]&=0x1F;
|
||||
|
||||
//Last step, descrambling data; we put each element in the right position. At the end we have the decrypted serial and devcode ;)
|
||||
for(i=0;i<BLOCK_SIZE/2;i+=4){
|
||||
o1=key[i];
|
||||
key[i]=key[BLOCK_SIZE-i-1];
|
||||
key[BLOCK_SIZE-i-1]=o1;
|
||||
}
|
||||
}
|
84
TL866_Updater/firmware.h
Normal file
84
TL866_Updater/firmware.h
Normal file
@ -0,0 +1,84 @@
|
||||
#ifndef FIRMWARE_H
|
||||
#define FIRMWARE_H
|
||||
|
||||
#include <QString>
|
||||
#include "tl866_global.h"
|
||||
|
||||
#define UPDATE_DAT_SIZE 312348
|
||||
#define BLOCK_SIZE 80
|
||||
#define XOR_TABLE_SIZE 0x100
|
||||
#define XOR_TABLE_START 0x1EEDF
|
||||
#define XOR_TABLE_OFFSET 0x1FC00
|
||||
|
||||
|
||||
class Firmware
|
||||
{
|
||||
public:
|
||||
|
||||
Firmware();
|
||||
int open(const QString &filename);
|
||||
bool isValid();
|
||||
unsigned char GetEraseParammeter(int type);
|
||||
unsigned char GetFirmwareVersion();
|
||||
void decrypt_firmware(unsigned char *data_out, int type);
|
||||
void encrypt_firmware(const unsigned char *data_in, unsigned char *data_out, int key);
|
||||
void get_firmware(unsigned char *data_out, int type, int key);
|
||||
void encrypt_serial(unsigned char *key, const unsigned char *firmware);
|
||||
void decrypt_serial(unsigned char *key, const unsigned char *firmware);
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
NoError,
|
||||
OpenError,
|
||||
FilesizeError,
|
||||
CRCError,
|
||||
DecryptionError
|
||||
};
|
||||
|
||||
|
||||
enum ENCRYPTION_KEY
|
||||
{
|
||||
A_KEY = VERSION_TL866A,
|
||||
CS_KEY = VERSION_TL866CS
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
typedef struct {
|
||||
unsigned char header[4];//file header
|
||||
unsigned int A_CRC32;//4 bytes
|
||||
unsigned char pad1;
|
||||
unsigned char A_erase;
|
||||
unsigned char pad2;
|
||||
unsigned char pad3;
|
||||
unsigned int CS_CRC32;//4 bytes
|
||||
unsigned char pad4;
|
||||
unsigned char CS_erase;
|
||||
unsigned char pad5;
|
||||
unsigned char pad6;
|
||||
unsigned int A_Index;//index used in A firmware decryption
|
||||
unsigned char A_Xortable1[256];//First xortable used in A firmware decryption
|
||||
unsigned char A_Xortable2[1024];//Second xortable used in A firmware decryption
|
||||
unsigned int CS_Index;//index used in CS firmware decryption
|
||||
unsigned char CS_Xortable1[256];//First xortable used in CS firmware decryption
|
||||
unsigned char CS_Xortable2[1024];//Second xortable used in CS firmware decryption
|
||||
unsigned char A_Firmware[ENCRYPTED_FIRMWARE_SIZE];//Encrypted A firmware
|
||||
unsigned char CS_Firmware[ENCRYPTED_FIRMWARE_SIZE];//Encrypted CS firmware
|
||||
}UpdateDat;
|
||||
|
||||
unsigned int crc32(unsigned char *buffer, unsigned int length);
|
||||
void encrypt_block(unsigned char *data, unsigned char *xortable, int index);
|
||||
void decrypt_block(unsigned char *data, unsigned char *xortable, int index);
|
||||
|
||||
|
||||
unsigned int crc32Table[256];
|
||||
unsigned char m_firmwareA[ENCRYPTED_FIRMWARE_SIZE ];
|
||||
unsigned char m_firmwareCS[ENCRYPTED_FIRMWARE_SIZE ];
|
||||
unsigned char m_eraseA;
|
||||
unsigned char m_eraseCS;
|
||||
unsigned char m_version;
|
||||
bool m_isValid;
|
||||
};
|
||||
|
||||
#endif // FIRMWARE_H
|
BIN
TL866_Updater/firmwareA.bin
Normal file
BIN
TL866_Updater/firmwareA.bin
Normal file
Binary file not shown.
BIN
TL866_Updater/firmwareCS.bin
Normal file
BIN
TL866_Updater/firmwareCS.bin
Normal file
Binary file not shown.
74
TL866_Updater/hexwriter.cpp
Normal file
74
TL866_Updater/hexwriter.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
/* Class HexWriter
|
||||
*
|
||||
* This file is part of the TL866 updater project.
|
||||
*
|
||||
* Copyright (C) radioman 2013
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*/
|
||||
|
||||
#include "hexwriter.h"
|
||||
|
||||
|
||||
void HexWriter::WriteHex(QTextStream &outStream, const uchar *data, uint size)
|
||||
{
|
||||
uchar temp[2];
|
||||
ushort segment=0;
|
||||
ushort address=0;
|
||||
|
||||
while(size>16)
|
||||
{
|
||||
if(!address)//address is zero, insert extended linear address record
|
||||
{
|
||||
temp[0]=(segment>>8);
|
||||
temp[1]=(segment&0xff);
|
||||
segment++;
|
||||
outStream << GetHexLine(temp,2,0,SEGMENT_RECORD) << endl;
|
||||
}
|
||||
outStream << GetHexLine(&data[(segment-1)*0x10000+address],16,address,DATA_RECORD) << endl;
|
||||
address+=16;
|
||||
size-=16;
|
||||
}
|
||||
outStream << GetHexLine(&data[(segment-1)*0x10000+address],size/2,address,DATA_RECORD) << endl;
|
||||
size/=2;
|
||||
address+=size;
|
||||
outStream << GetHexLine(&data[(segment-1)*0x10000+address],size,address,DATA_RECORD) << endl;
|
||||
outStream << GetHexLine(NULL,0,0,EOF_RECORD) << endl;
|
||||
}
|
||||
|
||||
|
||||
QString HexWriter::GetHexLine(const uchar *data, ushort size, ushort address ,uchar recordtype)
|
||||
{
|
||||
QString s=(QString(":%1%2%3").arg(size & 0xff, 2, 16, QChar('0')).arg(address, 4, 16, QChar('0')).arg(recordtype, 2, 16, QChar('0')).toUpper()).toLocal8Bit();
|
||||
ushort checksum=size;
|
||||
checksum += recordtype;
|
||||
checksum += (address >> 8);
|
||||
checksum += (address & 0xff);
|
||||
if(data!=NULL)
|
||||
{
|
||||
for(int i=0;i<size;i++)
|
||||
{
|
||||
s.append(QString("%1").arg(data[i], 2, 16, QChar('0')).toUpper());
|
||||
checksum += data[i];
|
||||
}
|
||||
}
|
||||
checksum &=0xff;
|
||||
checksum ^=0xff;
|
||||
checksum ++;
|
||||
checksum &=0xff;
|
||||
s.append(QString("%1").arg(checksum, 2, 16, QChar('0')).toUpper());
|
||||
return s;
|
||||
}
|
21
TL866_Updater/hexwriter.h
Normal file
21
TL866_Updater/hexwriter.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef HEXWRITER_H
|
||||
#define HEXWRITER_H
|
||||
#include <QTextStream>
|
||||
|
||||
class HexWriter
|
||||
{
|
||||
public:
|
||||
void WriteHex(QTextStream &outStream, const uchar *data, uint size);
|
||||
|
||||
private:
|
||||
QString GetHexLine(const uchar *data, ushort size, ushort address ,uchar recordtype);
|
||||
|
||||
enum RECORD_TYPE
|
||||
{
|
||||
DATA_RECORD = 0,
|
||||
SEGMENT_RECORD = 4,// Extended Linear Address Record
|
||||
EOF_RECORD = 1
|
||||
};
|
||||
};
|
||||
|
||||
#endif // HEXWRITER_H
|
37
TL866_Updater/main.cpp
Normal file
37
TL866_Updater/main.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
/* Main.cpp
|
||||
*
|
||||
* This file is part of the TL866 updater project.
|
||||
*
|
||||
* Copyright (C) radioman 2013
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*/
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
//#include <QStyleFactory>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
//qDebug()<<QStyleFactory::keys();
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
829
TL866_Updater/mainwindow.cpp
Normal file
829
TL866_Updater/mainwindow.cpp
Normal file
@ -0,0 +1,829 @@
|
||||
/* Class MainWindow
|
||||
*
|
||||
* This file is part of the TL866 updater project.
|
||||
*
|
||||
* Copyright (C) radioman 2014
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*/
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "editdialog.h"
|
||||
#include "hexwriter.h"
|
||||
#include "crc16.h"
|
||||
#include <QWidget>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QResource>
|
||||
#include <QFuture>
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
//setup UI
|
||||
ui->setupUi(this);
|
||||
setFixedSize(size());
|
||||
|
||||
//initialise object pointers
|
||||
advdlg = new AdvDialog(this);
|
||||
usbNotifier = new Notifier();
|
||||
usb_device = new USB();
|
||||
|
||||
//initialise used signals
|
||||
connect(usbNotifier,SIGNAL(deviceChange(bool)),this,SLOT(DeviceChanged(bool)));
|
||||
connect(this, SIGNAL(update_gui(QString, bool, bool)),this,SLOT(gui_updated(QString, bool, bool)));
|
||||
connect(this, SIGNAL(reflash_status(bool)), this, SLOT(reflash_finished(bool)));
|
||||
connect(this, SIGNAL(dump_status(QString)), this, SLOT(dump_finished(QString)));
|
||||
connect(this, SIGNAL(update_progress(int)),ui->progressBar,SLOT(setValue(int)));
|
||||
|
||||
//set used properties
|
||||
this->setProperty("device_code", "");
|
||||
this->setProperty("serial_number", "");
|
||||
this->setProperty("device_type", 0);
|
||||
|
||||
//initialise main ui
|
||||
ui->btnAdvanced->setEnabled(false);
|
||||
ui->btnDump->setEnabled(false);
|
||||
leds_off();
|
||||
reset_flag=false;
|
||||
DeviceChanged(true);
|
||||
}
|
||||
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
if(watcher.isRunning())
|
||||
{
|
||||
watcher.cancel();
|
||||
watcher.waitForFinished();
|
||||
}
|
||||
delete usb_device;
|
||||
delete usbNotifier;
|
||||
delete advdlg;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
//Turn off all leds
|
||||
void MainWindow::leds_off()
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background, QColor::fromRgb(0,64,0));
|
||||
ui->LedNorm->setPalette(pal);
|
||||
ui->LedBoot->setPalette(pal);
|
||||
pal.setColor(QPalette::Background, QColor::fromRgb(64,64,0));
|
||||
ui->LedErase->setPalette(pal);
|
||||
pal.setColor(QPalette::Background, QColor::fromRgb(64,0,0));
|
||||
ui->LedWrite->setPalette(pal);
|
||||
}
|
||||
|
||||
/* LEDs on/off toggle routines */
|
||||
void MainWindow::setNled(bool state)
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background,state ? QColor::fromRgb(0,255,0) : QColor::fromRgb(0,64,0));
|
||||
ui->LedNorm->setPalette(pal);
|
||||
}
|
||||
|
||||
void MainWindow::setBled(bool state)
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background,state ? QColor::fromRgb(0,255,0) : QColor::fromRgb(0,64,0));
|
||||
ui->LedBoot->setPalette(pal);
|
||||
}
|
||||
|
||||
void MainWindow::setEled(bool state)
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background,state ? QColor::fromRgb(255,255,0) : QColor::fromRgb(64,64,0));
|
||||
ui->LedErase->setPalette(pal);
|
||||
}
|
||||
|
||||
void MainWindow::setWled(bool state)
|
||||
{
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Background,state ? QColor::fromRgb(255,0,0) : QColor::fromRgb(64,0,0));
|
||||
ui->LedWrite->setPalette(pal);
|
||||
}
|
||||
|
||||
|
||||
//simple wait routine
|
||||
void MainWindow::wait_ms(unsigned long time)
|
||||
{
|
||||
QWaitCondition wc;
|
||||
QMutex mutex;
|
||||
QMutexLocker locker(&mutex);
|
||||
wc.wait(&mutex, time);
|
||||
}
|
||||
|
||||
|
||||
//browse for update.dat file
|
||||
void MainWindow::on_btnInput_clicked()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, "Update.dat" ,NULL, "dat files (*.dat);;All files (*.*)");
|
||||
if(fileName.isEmpty())
|
||||
return;
|
||||
|
||||
int ret=firmware.open(fileName);
|
||||
if(ret == Firmware::NoError)
|
||||
{
|
||||
ui->txtInput->setText(fileName);
|
||||
ui->lblVersion->setText(QString("[V:%1]").arg(firmware.GetFirmwareVersion()));
|
||||
return;
|
||||
}
|
||||
|
||||
switch(ret)
|
||||
{
|
||||
case Firmware::OpenError:
|
||||
QMessageBox::warning(this,"TL866",QString("Cannot read file %1").arg(fileName));
|
||||
break;
|
||||
case Firmware::FilesizeError:
|
||||
QMessageBox::warning(this,"TL866",QString("%1\n\nFilesize error!").arg(fileName));
|
||||
break;
|
||||
case Firmware::CRCError:
|
||||
QMessageBox::warning(this,"TL866",QString("%1\n\nData CRC error!").arg(fileName));
|
||||
break;
|
||||
case Firmware::DecryptionError:
|
||||
QMessageBox::warning(this,"TL866","Firmware decryption error!");
|
||||
break;
|
||||
}
|
||||
ui->lblVersion->clear();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//show advanced dialog
|
||||
void MainWindow::on_btnAdvanced_clicked()
|
||||
{
|
||||
advdlg->show();
|
||||
}
|
||||
|
||||
|
||||
//show edit device code and serial number dialog
|
||||
void MainWindow::on_btnEdit_clicked()
|
||||
{
|
||||
EditDialog* dlg=new EditDialog(this);
|
||||
QString devcode =ui->txtDevcode->text();
|
||||
QString serial =ui->txtSerial->text();
|
||||
dlg->SetText(devcode,serial);
|
||||
if(dlg->exec()==QDialog::Accepted)
|
||||
{
|
||||
dlg->GetResult(&devcode, &serial);
|
||||
ui->txtDevcode->setText(devcode);
|
||||
ui->txtSerial->setText(serial);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//set default device code and serial number
|
||||
void MainWindow::on_btnDefault_clicked()
|
||||
{
|
||||
set_default(ui->txtDevcode, ui->txtSerial);
|
||||
}
|
||||
|
||||
//public helper function to set default serial and device code
|
||||
void MainWindow::set_default(QLineEdit *devcode, QLineEdit *serial)
|
||||
{
|
||||
unsigned char key[BLOCK_SIZE];
|
||||
QByteArray res = get_resource(ui->radiofA->isChecked() ? A_FIRMWARE_RESOURCE : CS_FIRMWARE_RESOURCE, FLASH_SIZE);
|
||||
memcpy(key,res.data()+SERIAL_OFFSET,BLOCK_SIZE);
|
||||
firmware.decrypt_serial(key, (uchar*)res.data());
|
||||
devcode->setText(QString::fromAscii((const char*)&key[0],8));
|
||||
serial->setText(QString::fromAscii((const char*)&key[8],24));
|
||||
}
|
||||
|
||||
|
||||
//Read device info
|
||||
void MainWindow::Refresh()
|
||||
{
|
||||
reset_flag=false;
|
||||
DeviceChanged(true);
|
||||
}
|
||||
|
||||
|
||||
//clone serial and device code from connected device
|
||||
void MainWindow::on_btnClone_clicked()
|
||||
{
|
||||
Refresh();
|
||||
ui->txtDevcode->setText(this->property("device_code").toString());
|
||||
ui->txtSerial->setText(this->property("serial_number").toString());
|
||||
}
|
||||
|
||||
|
||||
//reset device button
|
||||
void MainWindow::on_btnReset_clicked()
|
||||
{
|
||||
|
||||
if(watcher.isRunning())
|
||||
return;
|
||||
if(!CheckDevices(this))
|
||||
return;
|
||||
|
||||
if(usb_device->open_device(0))
|
||||
{
|
||||
reset();
|
||||
usb_device->close_device();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//reflash device button
|
||||
void MainWindow::on_btnReflash_clicked()
|
||||
{
|
||||
if(watcher.isRunning())
|
||||
return;
|
||||
|
||||
if(!CheckDevices(this))
|
||||
return;
|
||||
|
||||
if(!firmware.isValid())
|
||||
{
|
||||
QMessageBox::warning(this, "TL866", "No firmware file loaded!\nPlease load the update.dat file.");
|
||||
return;
|
||||
}
|
||||
|
||||
if(QMessageBox::warning(this, "TL866", "Warning! this operation will reflash the device.\nDo you want to continue?",
|
||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)
|
||||
return;
|
||||
|
||||
int index=-1;
|
||||
if(ui->radioA->isChecked())
|
||||
index=0;
|
||||
if(ui->radioCS->isChecked())
|
||||
index=1;
|
||||
if(ui->radioDump->isChecked())
|
||||
index=2;
|
||||
if(index == -1)
|
||||
return;
|
||||
job_list.clear();
|
||||
job_list.append(REFLASH);
|
||||
watcher.setProperty("firmware_version", index);
|
||||
ui->progressBar->setMaximum(ENCRYPTED_FIRMWARE_SIZE/BLOCK_SIZE-1);
|
||||
watcher.setFuture(QtConcurrent::map(job_list, WorkerWrapper(this)));
|
||||
}
|
||||
|
||||
|
||||
//dump device button
|
||||
void MainWindow::on_btnDump_clicked()
|
||||
{
|
||||
if(!watcher.isRunning())
|
||||
{
|
||||
if(!firmware.isValid())
|
||||
{
|
||||
QMessageBox::warning(this, "TL866", "No firmware file loaded!\nPlease load the update.dat file.");
|
||||
return;
|
||||
}
|
||||
|
||||
QString fileName=QFileDialog::getSaveFileName(this,"Save firmware hex file",NULL,"hex files (*.hex);;All files (*.*)");
|
||||
if(!fileName.isEmpty())
|
||||
{
|
||||
job_list.clear();
|
||||
job_list.append(DUMP);
|
||||
watcher.setProperty("hex_path", fileName);
|
||||
ui->progressBar->setMaximum(FLASH_SIZE - 1);
|
||||
watcher.setFuture(QtConcurrent::map(job_list, WorkerWrapper(this)));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//save hex button
|
||||
void MainWindow::on_btnSave_clicked()
|
||||
{
|
||||
QString fileName=QFileDialog::getSaveFileName(this,"Save firmware hex file",NULL,"hex files (*.hex);;All files (*.*)");
|
||||
if(!fileName.isEmpty())
|
||||
{
|
||||
if(!fileName.endsWith(".hex", Qt::CaseInsensitive))
|
||||
fileName += ".hex";
|
||||
QFile file(fileName);
|
||||
if(!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
{
|
||||
QMessageBox::critical(this,"TL866",QString("Error creating file %1\n%2.").arg(fileName).arg(file.errorString()));
|
||||
return;
|
||||
}
|
||||
QTextStream fileStream(&file);
|
||||
|
||||
QByteArray b =get_resource(ui->radiofA->isChecked() ? A_FIRMWARE_RESOURCE : CS_FIRMWARE_RESOURCE, FLASH_SIZE);
|
||||
|
||||
uchar *temp = new uchar[FLASH_SIZE];//128K byte array
|
||||
memcpy(temp,b.data(),FLASH_SIZE);//copy entire firmware to array
|
||||
|
||||
if(ui->optionBoot->isChecked())
|
||||
memset(temp+BOOTLOADER_SIZE, 0xFF, UNENCRYPTED_FIRMWARE_SIZE);//if the option bootloader only is selected then clear the main firmware area(0x1800-0x1FBFF)
|
||||
|
||||
uchar *key = new uchar[BLOCK_SIZE];//for holding serial and dev code
|
||||
firmware.decrypt_serial(key, temp);//decrypt the serial key from temp array to key array
|
||||
memset(key,' ',32);//add trailing spaces
|
||||
|
||||
memcpy(key, ui->txtDevcode->text().toAscii().data(), ui->txtDevcode->text().size());//copy devcode to key array
|
||||
memcpy(key+8, ui->txtSerial->text().toAscii().data(), ui->txtSerial->text().size());//copy serial to key array
|
||||
|
||||
firmware.encrypt_serial(key, temp);//encrypt the devcode and serial
|
||||
memcpy(temp + SERIAL_OFFSET ,key,BLOCK_SIZE);//copy the new devcode and serial to temp array
|
||||
|
||||
HexWriter *hexwriter = new HexWriter;
|
||||
hexwriter->WriteHex(fileStream,temp,FLASH_SIZE);//write temp array to fileStream in Intel hex format
|
||||
delete hexwriter;
|
||||
delete key;
|
||||
delete temp;
|
||||
file.close();//done!
|
||||
}
|
||||
}
|
||||
|
||||
//Helper function to get a binary resource
|
||||
QByteArray MainWindow::get_resource(QString resource_path, int size)
|
||||
{
|
||||
QResource res(resource_path);
|
||||
QByteArray ba;
|
||||
ba = (res.isCompressed() ? qUncompress(res.data(), size) : QByteArray((const char*)res.data(), size));
|
||||
return ba;
|
||||
}
|
||||
|
||||
|
||||
//Background worker dispatch routine. Notice that this function is executed in a separate thread.
|
||||
void MainWindow::DoWork(WorkerJob job)
|
||||
{
|
||||
switch(job)
|
||||
{
|
||||
case REFLASH:
|
||||
if(usb_device->open_device(0))
|
||||
{
|
||||
bool success =reflash();
|
||||
usb_device->close_device();
|
||||
emit reflash_status(success);
|
||||
}
|
||||
break;
|
||||
|
||||
case DUMP:
|
||||
if(usb_device->open_device(0))
|
||||
{
|
||||
QString result = dump();
|
||||
usb_device->close_device();
|
||||
emit dump_status(result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Send the Reset command to the TL866.
|
||||
void MainWindow::reset()
|
||||
{
|
||||
|
||||
uchar data[4] = {RESET_COMMAND, 0, 0, 0};
|
||||
reset_flag=true;
|
||||
usb_device->usb_write(data, 4);
|
||||
}
|
||||
|
||||
//Reflash function. This routine is executed in a separate thread.
|
||||
bool MainWindow::reflash()
|
||||
{
|
||||
uchar buffer[BLOCK_SIZE+7];
|
||||
uchar data[ENCRYPTED_FIRMWARE_SIZE];
|
||||
|
||||
TL866_REPORT report;
|
||||
|
||||
//read the device to determine his satus
|
||||
memset((uchar*)&report,0, sizeof(TL866_REPORT));
|
||||
report.echo = REPORT_COMMAND;//0 anyway
|
||||
usb_device->usb_write((uchar *)&report, 5);
|
||||
usb_device->usb_read((uchar*)&report, sizeof(TL866_REPORT));
|
||||
if(report.device_status == NORMAL_MODE)//if the device is not in bootloader mode reset it.
|
||||
{
|
||||
reset();
|
||||
wait_ms(2500);
|
||||
}
|
||||
|
||||
//read the device again to see the true device version as reported by the bootloader
|
||||
memset((uchar*)&report,0, sizeof(TL866_REPORT));
|
||||
report.echo = REPORT_COMMAND;//0 anyway
|
||||
usb_device->usb_write((uchar *)&report, 5);
|
||||
usb_device->usb_read((uchar*)&report, sizeof(TL866_REPORT));
|
||||
int device_version = report.device_version;
|
||||
|
||||
|
||||
//Erase device first
|
||||
memset(buffer,0,20);
|
||||
buffer[0]=ERASE_COMMAND;
|
||||
buffer[7]=firmware.GetEraseParammeter(device_version);
|
||||
emit update_gui(QString("<erasing...>"), true, false);
|
||||
usb_device->usb_write(buffer, 20);
|
||||
|
||||
usb_device->usb_read(data, 32);
|
||||
if(data[0] != ERASE_COMMAND)
|
||||
return false;//erase failed
|
||||
|
||||
//Write device.
|
||||
emit update_gui(QString("<erasing...>"), false, false);
|
||||
wait_ms(1000);
|
||||
emit update_gui(QString("<writing...>"), false, true);
|
||||
|
||||
|
||||
//Get the encrypted firmware.
|
||||
switch(watcher.property("firmware_version").toInt())
|
||||
{
|
||||
case FIRMWARE_A:
|
||||
default:
|
||||
firmware.get_firmware(data, device_version, Firmware::A_KEY);
|
||||
break;
|
||||
case FIRMWARE_CS:
|
||||
firmware.get_firmware(data, device_version, Firmware::CS_KEY);
|
||||
break;
|
||||
case FIRMWARE_CUSTOM:
|
||||
QByteArray b = get_resource(DUMPER_RESOURCE, UNENCRYPTED_FIRMWARE_SIZE);
|
||||
firmware.encrypt_firmware((const uchar*)b.data(), data, device_version);
|
||||
}
|
||||
|
||||
|
||||
/* prepare data by adding 7 bytes header on each 80 bytes data block and send it over the usb.
|
||||
*
|
||||
* 7 bytes header+80 bytes data like this: | Command | lenght | address | data |
|
||||
* 2bytes 2bytes 3bytes 80bytes
|
||||
*
|
||||
*/
|
||||
|
||||
quint32 address = BOOTLOADER_SIZE;
|
||||
for (int i = 0; i<ENCRYPTED_FIRMWARE_SIZE; i += BLOCK_SIZE)
|
||||
{
|
||||
buffer[0] = WRITE_COMMAND;//command LSB
|
||||
buffer[1] = 0x00;//command MSB
|
||||
buffer[2] = BLOCK_SIZE;//Block size without header(LSB)
|
||||
buffer[3] = 0x00;//Block size MSB
|
||||
buffer[4] = address & 0xff;//24 bit address which will be written (3 bytes in little endian order)
|
||||
buffer[5] = (address & 0xff00)>>8;
|
||||
buffer[6] = (address & 0xff0000)>>16;
|
||||
memcpy(&buffer[7], &data[i], BLOCK_SIZE);
|
||||
|
||||
if (usb_device->usb_write(buffer, sizeof(buffer)) != sizeof(buffer))
|
||||
return false;//write failed
|
||||
address+=64;//next data block
|
||||
emit update_progress(i/BLOCK_SIZE);
|
||||
}
|
||||
|
||||
//Reset the device back in normal working mode
|
||||
emit update_gui(QString("<writing...>"), false, false);
|
||||
wait_ms(500);
|
||||
emit update_gui(QString("<resetting...>"), false, false);
|
||||
reset();
|
||||
wait_ms(1500);
|
||||
return true;//reflash ok
|
||||
|
||||
}
|
||||
|
||||
//Dump function. This function is executed in separate thread.
|
||||
QString MainWindow::dump()
|
||||
{
|
||||
uchar temp[FLASH_SIZE];//128Kbyte buffer
|
||||
uchar w[5];
|
||||
QFile file(watcher.property("hex_path").toString());
|
||||
|
||||
if(!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
return file.errorString();
|
||||
|
||||
QTextStream fileStream(&file);
|
||||
|
||||
for(int i = 0; i < FLASH_SIZE; i += 64)
|
||||
{
|
||||
w[0] = DUMPER_READ_FLASH;
|
||||
w[1] = 64;//packet size
|
||||
w[2] = i & 0xff;//24bit address in little endian order
|
||||
w[3] = (i & 0xff00)>>8;
|
||||
w[4] = (i & 0xff0000)>>16;
|
||||
|
||||
usb_device->usb_write(w, sizeof(w));
|
||||
if(usb_device->usb_read(&temp[i],64) != 64)
|
||||
return QString("USB read error.");
|
||||
emit update_progress(i);
|
||||
}
|
||||
|
||||
firmware.decrypt_firmware(&temp[BOOTLOADER_SIZE], this->property("device_type").toInt());
|
||||
|
||||
HexWriter *hexwriter = new HexWriter;
|
||||
hexwriter->WriteHex(fileStream,temp,sizeof(temp));//write temp array to fileStream in Intel hex format.
|
||||
delete hexwriter;
|
||||
file.close();
|
||||
return QString("");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Reflash finished SLOT
|
||||
void MainWindow::reflash_finished(bool success)
|
||||
{
|
||||
if(success)
|
||||
QMessageBox::information(this, "TL866", "Reflash OK!");
|
||||
else
|
||||
QMessageBox::critical(this, "TL866", "Reflash Failed!");
|
||||
emit update_progress(0);
|
||||
}
|
||||
|
||||
|
||||
//Dump finished SLOT
|
||||
void MainWindow::dump_finished(QString result)
|
||||
{
|
||||
if(result.isEmpty())
|
||||
QMessageBox::information(this, "TL866", "Firmware dump complete!");
|
||||
else
|
||||
QMessageBox::critical(this, "TL866", QString("Error creating dump.hex file\n%1.").arg(result));
|
||||
emit update_progress(0);
|
||||
}
|
||||
|
||||
|
||||
//Gui update SLOT
|
||||
void MainWindow::gui_updated(QString message, bool eraseLed, bool writeLed)
|
||||
{
|
||||
setEled(eraseLed);
|
||||
setWled(writeLed);
|
||||
QStringList list(ui->txtInfo->toPlainText().split("\n"));
|
||||
list.removeAt(1);
|
||||
list.insert(1,"Device status: Bootloader mode " + message);
|
||||
ui->txtInfo->clear();
|
||||
ui->txtInfo->append(list.join("\n"));
|
||||
}
|
||||
|
||||
|
||||
//This procedure is called automatically by the usb device change. Call this function to refresh the info.
|
||||
void MainWindow::DeviceChanged(bool arrived)
|
||||
{
|
||||
if(!arrived && reset_flag)//ignore unplug event if the device was resetted by us.
|
||||
return;
|
||||
|
||||
reset_flag=false;
|
||||
ui->txtInfo->clear();
|
||||
int devtype = 0;
|
||||
int count=usb_device->get_devices_count();
|
||||
this->setWindowTitle(QString("TL866 firmware updater (%1 %2 connected)").arg(count).arg(count == 1 ? "device" : "devices"));
|
||||
|
||||
if(count)
|
||||
{
|
||||
TL866_REPORT report;
|
||||
if(usb_device->open_device(0))
|
||||
{
|
||||
memset((uchar*)&report,0, sizeof(TL866_REPORT));
|
||||
report.echo = REPORT_COMMAND;//0 anyway
|
||||
usb_device->usb_write((uchar *)&report, 5);
|
||||
usb_device->usb_read((uchar*)&report, sizeof(TL866_REPORT));
|
||||
|
||||
switch(report.device_version)
|
||||
{
|
||||
case VERSION_TL866A:
|
||||
ui->txtInfo->append("Device version: TL866A");
|
||||
devtype = VERSION_TL866A;
|
||||
break;
|
||||
case VERSION_TL866CS:
|
||||
ui->txtInfo->append("Device version: TL866CS");
|
||||
devtype = VERSION_TL866CS;
|
||||
break;
|
||||
default:
|
||||
ui->txtInfo->append("Device version: Unknown");
|
||||
devtype = 0;
|
||||
}
|
||||
|
||||
|
||||
switch(report.device_status)
|
||||
{
|
||||
case NORMAL_MODE:
|
||||
setNled(true);
|
||||
setBled(false);
|
||||
ui->txtInfo->append("Device status: Normal working mode.");
|
||||
break;
|
||||
case BOOTLOADER_MODE:
|
||||
setNled(false);
|
||||
setBled(true);
|
||||
ui->txtInfo->append("Device status: Bootloader mode <waiting for update.>");
|
||||
break;
|
||||
default:
|
||||
setNled(false);
|
||||
setBled(false);
|
||||
ui->txtInfo->append("Device status: Unknown.");
|
||||
}
|
||||
QString s_devcode = (QString::fromAscii((const char*)&report.device_code,8));
|
||||
QString s_serial = (QString::fromAscii((const char*)&report.serial_number,24));
|
||||
bool isDumperActive = (s_devcode.toLower() == "codedump" && s_serial == "000000000000000000000000");
|
||||
|
||||
if(isDumperActive)
|
||||
{
|
||||
|
||||
DUMPER_REPORT dumper_report;
|
||||
uchar b[] = {DUMPER_INFO};
|
||||
usb_device->usb_write(b, 1);
|
||||
usb_device->usb_read((uchar*)&dumper_report, sizeof(DUMPER_REPORT));
|
||||
devtype = dumper_report.bootloader_version;
|
||||
|
||||
s_devcode = (QString::fromAscii((const char*)&dumper_report.device_code,8));
|
||||
s_serial = (QString::fromAscii((const char*)&dumper_report.serial_number,24));
|
||||
|
||||
advdlg->SetSerial(s_devcode, s_serial);
|
||||
|
||||
QString info;
|
||||
info.append(QString("Device code: %1\n").arg(s_devcode));
|
||||
info.append(QString("Serial number: %1\n").arg(s_serial));
|
||||
info.append(QString("Bootloader version: %1\n").arg((devtype == VERSION_TL866A) ? "A" : "CS"));
|
||||
info.append(QString("Code Protection bit: %1\n").arg(dumper_report.cp_bit ? "No" : "Yes"));
|
||||
|
||||
advdlg->SetInfo(info);
|
||||
advdlg->SetUi(dumper_report.cp_bit == 0, devtype);
|
||||
|
||||
ui->btnAdvanced->setEnabled(true);
|
||||
ui->btnDump->setEnabled(true);
|
||||
}
|
||||
else//dumper is not active
|
||||
{
|
||||
ui->btnAdvanced->setEnabled(false);
|
||||
ui->btnDump->setEnabled(false);
|
||||
advdlg->SetSerial("", "");
|
||||
advdlg->SetInfo("");
|
||||
advdlg->hide();
|
||||
}
|
||||
|
||||
ui->txtInfo->append("Device code: " + s_devcode);
|
||||
ui->txtInfo->append("Serial number: " + s_serial);
|
||||
this->setProperty("device_code", s_devcode);
|
||||
this->setProperty("serial_number", s_serial);
|
||||
ui->txtInfo->append(isDumperActive ? "Firmware version: Firmware dumper" :
|
||||
report.device_status == NORMAL_MODE ? QString("Firmware version: %1.%2.%3")
|
||||
.arg(report.hardware_version)
|
||||
.arg(report.firmware_version_major)
|
||||
.arg(report.firmware_version_minor):
|
||||
"Firmware version: Bootloader");
|
||||
|
||||
if(!watcher.isRunning())
|
||||
usb_device->close_device();//do not close device if an upgrade is in progress.
|
||||
}
|
||||
else//error oppening device
|
||||
SetBlank();
|
||||
|
||||
}
|
||||
else//no device connected
|
||||
SetBlank();
|
||||
|
||||
this->setProperty("device_type", devtype);//save global property for later usage.
|
||||
}
|
||||
|
||||
|
||||
//Helper function
|
||||
void MainWindow::SetBlank()
|
||||
{
|
||||
leds_off();
|
||||
ui->btnAdvanced->setEnabled(false);
|
||||
ui->btnDump->setEnabled(false);
|
||||
//ui->txtDevcode->setText("");
|
||||
//ui->txtSerial->setText("");
|
||||
this->setProperty("device_code", "");
|
||||
this->setProperty("serial_number", "");
|
||||
advdlg->SetSerial("", "");
|
||||
advdlg->SetInfo("");
|
||||
advdlg->hide();
|
||||
}
|
||||
|
||||
//Helper function
|
||||
bool MainWindow::CheckDevices(QWidget *parent)
|
||||
{
|
||||
if (usb_device->get_devices_count() == 0)
|
||||
{
|
||||
QMessageBox::warning(parent, "TL866", "No device detected!\nPlease connect one and try again.");
|
||||
return false;
|
||||
}
|
||||
if (usb_device->get_devices_count() > 1)
|
||||
{
|
||||
QMessageBox::warning(parent, "TL866", "Multiple devices detected!\nPlease connect only one device.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*Advanced functions*/
|
||||
|
||||
|
||||
//Write bootloader
|
||||
void MainWindow::WriteBootloader(BootloaderType type)
|
||||
{
|
||||
if(!CheckDevices(advdlg))
|
||||
return;
|
||||
if(!AdvQuestion())
|
||||
return;
|
||||
if(usb_device->open_device(0))
|
||||
{
|
||||
ushort crc = BootloaderCRC();
|
||||
if(!((crc == A_BOOTLOADER_CRC) || (crc == CS_BOOTLOADER_CRC)))
|
||||
{
|
||||
usb_device->close_device();
|
||||
QMessageBox::warning(advdlg, "TL866",
|
||||
"The bootloader CRC of your device version doesn't match!\nAs a safety measure, nothing will be written.");
|
||||
return;
|
||||
}
|
||||
uchar b[2]={DUMPER_WRITE_BOOTLOADER, type == A_BOOTLOADER ? VERSION_TL866A : VERSION_TL866CS};
|
||||
usb_device->usb_write(b, 2);
|
||||
b[0] = 0;
|
||||
usb_device->usb_read(b, 1);
|
||||
usb_device->close_device();
|
||||
Refresh();
|
||||
if(b[0] == DUMPER_WRITE_BOOTLOADER)
|
||||
QMessageBox::information(advdlg, "TL866", "Bootloader was successfully written.");
|
||||
else
|
||||
QMessageBox::critical(advdlg, "TL866", "Bootloader writing failed.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//write copy protect bit
|
||||
void MainWindow::WriteConfig(bool copy_protect)
|
||||
{
|
||||
if(!CheckDevices(advdlg))
|
||||
return;
|
||||
if(!AdvQuestion())
|
||||
return;
|
||||
if(usb_device->open_device(0))
|
||||
{
|
||||
uchar b[2]={DUMPER_WRITE_CONFIG, (uchar)(copy_protect ? 1 : 0)};
|
||||
usb_device->usb_write(b, 2);
|
||||
b[0] = 0;
|
||||
usb_device->usb_read(b, 1);
|
||||
usb_device->close_device();
|
||||
Refresh();
|
||||
if(b[0] == DUMPER_WRITE_CONFIG)
|
||||
QMessageBox::information(advdlg, "TL866", "Code protection bit was successfully written.");
|
||||
else
|
||||
QMessageBox::critical(advdlg, "TL866", "Writing code protect bit failed.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//write serial number and device code
|
||||
void MainWindow::WriteInfo(QString device_code, QString serial_number)
|
||||
{
|
||||
if(!CheckDevices(advdlg))
|
||||
return;
|
||||
if(!AdvQuestion())
|
||||
return;
|
||||
if(usb_device->open_device(0))
|
||||
{
|
||||
uchar b[34];
|
||||
memset(b,' ',34);//add trailing spaces
|
||||
b[0] = DUMPER_WRITE_INFO;
|
||||
memcpy(b+1, device_code.toAscii().data(), device_code.size());//copy devcode to b array
|
||||
memcpy(b+9, serial_number.toAscii().data(), serial_number.size());//copy serial to key array
|
||||
usb_device->usb_write(b, 34);
|
||||
b[0] = 0;
|
||||
usb_device->usb_read(b, 1);
|
||||
usb_device->close_device();
|
||||
Refresh();
|
||||
if(b[0] == DUMPER_WRITE_INFO)
|
||||
QMessageBox::information(advdlg, "TL866", "Device info was successfully written.");
|
||||
else
|
||||
QMessageBox::critical(advdlg, "TL866", "Writing device info failed.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//read bootloader and compute crc16
|
||||
ushort MainWindow::BootloaderCRC()
|
||||
{
|
||||
uchar buffer[BOOTLOADER_SIZE];//6Kbyte
|
||||
uchar w[5];
|
||||
|
||||
for(int i=0;i<BOOTLOADER_SIZE;i+=64)
|
||||
{
|
||||
w[0]=DUMPER_READ_FLASH;
|
||||
w[1]=64;//packet size
|
||||
w[2]=i & 0xff;//24bit address in little endian order
|
||||
w[3]=(i & 0xff00)>>8;
|
||||
w[4]=(i & 0xff0000)>>16;
|
||||
usb_device->usb_write(w, sizeof(w));
|
||||
if(usb_device->usb_read(&buffer[i],64) != 64)
|
||||
{
|
||||
QMessageBox::warning(advdlg, "TL866", "USB read error!");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return CRC16::crc16(buffer, sizeof(buffer));
|
||||
}
|
||||
|
||||
|
||||
//helper function
|
||||
bool MainWindow::AdvQuestion()
|
||||
{
|
||||
return(QMessageBox::warning(advdlg, "TL866", "Warning! this operation may brick your device.\nDo you want to continue?",
|
||||
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes);
|
||||
}
|
108
TL866_Updater/mainwindow.h
Normal file
108
TL866_Updater/mainwindow.h
Normal file
@ -0,0 +1,108 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include "advdialog.h"
|
||||
#include <QtConcurrentMap>
|
||||
#include <QFutureWatcher>
|
||||
#include <QDebug>
|
||||
#include <QLineEdit>
|
||||
#include <firmware.h>
|
||||
#include <notifier.h>
|
||||
#include "tl866_global.h"
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
#include "usb_win.h"
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#include "usb_linux.h"
|
||||
#endif
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
USB *usb_device;
|
||||
|
||||
void set_default(QLineEdit *devcode, QLineEdit *serial);
|
||||
void Refresh();
|
||||
void WriteBootloader(BootloaderType type);
|
||||
void WriteConfig(bool copy_protect);
|
||||
void WriteInfo(QString device_code, QString serial_number);
|
||||
|
||||
|
||||
|
||||
private slots:
|
||||
void on_btnInput_clicked();
|
||||
void on_btnAdvanced_clicked();
|
||||
void on_btnEdit_clicked();
|
||||
void on_btnDefault_clicked();
|
||||
void on_btnClone_clicked();
|
||||
void on_btnReflash_clicked();
|
||||
void on_btnReset_clicked();
|
||||
void on_btnSave_clicked();
|
||||
void on_btnDump_clicked();
|
||||
void reflash_finished(bool success);
|
||||
void dump_finished(QString succes);
|
||||
void DeviceChanged(bool arrived);
|
||||
void gui_updated(QString message, bool eraseLed, bool writeLed);
|
||||
|
||||
|
||||
signals:
|
||||
void reflash_status(bool success);
|
||||
void dump_status(QString result);
|
||||
void update_gui(QString message, bool eraseLed, bool writeLed);
|
||||
void update_progress(int value);
|
||||
|
||||
|
||||
private:
|
||||
enum WorkerJob{REFLASH, DUMP};
|
||||
Ui::MainWindow *ui;
|
||||
AdvDialog* advdlg;
|
||||
Firmware firmware;
|
||||
Notifier *usbNotifier;
|
||||
QList<WorkerJob> job_list;
|
||||
QFutureWatcher<void> watcher;
|
||||
QByteArray get_resource(QString resource_path, int size);
|
||||
bool reset_flag;
|
||||
|
||||
void leds_off();
|
||||
void setNled(bool state);
|
||||
void setBled(bool state);
|
||||
void setEled(bool state);
|
||||
void setWled(bool state);
|
||||
void wait_ms(unsigned long time);
|
||||
void SetBlank();
|
||||
bool CheckDevices(QWidget *parent);
|
||||
bool AdvQuestion();
|
||||
ushort BootloaderCRC();
|
||||
bool reflash();
|
||||
QString dump();
|
||||
void reset();
|
||||
void DoWork(WorkerJob job);
|
||||
|
||||
#define A_FIRMWARE_RESOURCE ":/firmware/firmwareA.bin"
|
||||
#define CS_FIRMWARE_RESOURCE ":/firmware/firmwareCS.bin"
|
||||
#define DUMPER_RESOURCE ":/firmware/dumper.bin"
|
||||
|
||||
struct WorkerWrapper
|
||||
{
|
||||
MainWindow *instance;
|
||||
WorkerWrapper(MainWindow *w): instance(w) {}
|
||||
void operator()(WorkerJob job) {
|
||||
instance->DoWork(job);
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
820
TL866_Updater/mainwindow.ui
Normal file
820
TL866_Updater/mainwindow.ui
Normal file
@ -0,0 +1,820 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>750</width>
|
||||
<height>361</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset>
|
||||
<normaloff>penDrive4.ico</normaloff>penDrive4.ico</iconset>
|
||||
</property>
|
||||
<property name="locale">
|
||||
<locale language="English" country="UnitedStates"/>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>750</width>
|
||||
<height>370</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>10</pointsize>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_1">
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>Hardware</string>
|
||||
</attribute>
|
||||
<widget class="QProgressBar" name="progressBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>157</x>
|
||||
<y>305</y>
|
||||
<width>568</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="textVisible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="invertedAppearance">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>8</x>
|
||||
<y>58</y>
|
||||
<width>715</width>
|
||||
<height>110</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>11</pointsize>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Firmware to write</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>255</x>
|
||||
<y>40</y>
|
||||
<width>375</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetDefaultConstraint</enum>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnReflash">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reflash</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnReset">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnDump">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Dump</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnAdvanced">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Advanced</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget1">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>15</x>
|
||||
<y>23</y>
|
||||
<width>201</width>
|
||||
<height>77</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioA">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TL866A firmware</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioCS">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TL866CS firmware</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radioDump">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Firmware dumper</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>9</y>
|
||||
<width>95</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>10</pointsize>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Update.dat file</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="txtInfo">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>8</x>
|
||||
<y>174</y>
|
||||
<width>717</width>
|
||||
<height>115</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Courier New</family>
|
||||
<pointsize>11</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QTextEdit{color: black; background-color: rgb(255, 255, 225)};</string>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnInput">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>697</x>
|
||||
<y>30</y>
|
||||
<width>26</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="LedNorm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>14</x>
|
||||
<y>305</y>
|
||||
<width>29</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="LedBoot">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>49</x>
|
||||
<y>305</y>
|
||||
<width>29</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="LedErase">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>84</x>
|
||||
<y>305</y>
|
||||
<width>29</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="LedWrite">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>119</x>
|
||||
<y>305</y>
|
||||
<width>29</width>
|
||||
<height>12</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>15</x>
|
||||
<y>292</y>
|
||||
<width>32</width>
|
||||
<height>13</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Norm</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>51</x>
|
||||
<y>292</y>
|
||||
<width>30</width>
|
||||
<height>13</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Boot</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>85</x>
|
||||
<y>292</y>
|
||||
<width>32</width>
|
||||
<height>13</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Erase</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>121</x>
|
||||
<y>292</y>
|
||||
<width>32</width>
|
||||
<height>13</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Write</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="txtInput">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>9</x>
|
||||
<y>30</y>
|
||||
<width>680</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit{color: black; background-color: rgb(255, 255, 225)};</string>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="cursorMoveStyle">
|
||||
<enum>Qt::VisualMoveStyle</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="lblVersion">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>119</x>
|
||||
<y>9</y>
|
||||
<width>111</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>10</pointsize>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLabel{color: green};</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><br/></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Firmware</string>
|
||||
</attribute>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>8</x>
|
||||
<y>16</y>
|
||||
<width>731</width>
|
||||
<height>101</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>11</pointsize>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Device Serial number</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>24</x>
|
||||
<y>30</y>
|
||||
<width>85</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Device code</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>220</x>
|
||||
<y>30</y>
|
||||
<width>91</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Serial number</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="txtSerial">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>135</x>
|
||||
<y>49</y>
|
||||
<width>324</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Courier New</family>
|
||||
<pointsize>16</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit{color: black; background-color: rgb(255, 255, 225)};</string>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>24</number>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="txtDevcode">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>9</x>
|
||||
<y>49</y>
|
||||
<width>117</width>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Courier New</family>
|
||||
<pointsize>16</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit{color: black; background-color: rgb(255, 255, 225)};</string>
|
||||
</property>
|
||||
<property name="maxLength">
|
||||
<number>8</number>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnClone">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>559</x>
|
||||
<y>50</y>
|
||||
<width>82</width>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clone</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>470</x>
|
||||
<y>50</y>
|
||||
<width>83</width>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Edit</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btnDefault">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>647</x>
|
||||
<y>50</y>
|
||||
<width>82</width>
|
||||
<height>27</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Default</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>8</x>
|
||||
<y>152</y>
|
||||
<width>720</width>
|
||||
<height>132</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>11</pointsize>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Hex file generator</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="btnSave">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>27</x>
|
||||
<y>97</y>
|
||||
<width>75</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>15</x>
|
||||
<y>26</y>
|
||||
<width>141</width>
|
||||
<height>54</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="optionFull">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Arial</family>
|
||||
<pointsize>10</pointsize>
|
||||
<weight>50</weight>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Full firmware</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="optionBoot">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Bootloader only</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>272</x>
|
||||
<y>28</y>
|
||||
<width>231</width>
|
||||
<height>54</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radiofA">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Generate TL866A firmware</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="radiofCS">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Generate TL866CS firmware</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
186
TL866_Updater/notifier.cpp
Normal file
186
TL866_Updater/notifier.cpp
Normal file
@ -0,0 +1,186 @@
|
||||
/* Class Notifier
|
||||
*
|
||||
* This file is part of the TL866 updater project.
|
||||
*
|
||||
* Copyright (C) radioman 2013
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "notifier.h"
|
||||
#include "tl866_global.h"
|
||||
#include <QDebug>
|
||||
|
||||
Notifier::Notifier(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
this->hide();
|
||||
socket_notifier=NULL;
|
||||
RegisterUsbNotifications();
|
||||
}
|
||||
|
||||
Notifier::~Notifier()
|
||||
{
|
||||
if(socket_notifier !=NULL)
|
||||
delete socket_notifier;
|
||||
}
|
||||
|
||||
|
||||
/* Platform specific implementation of usb device change notification.
|
||||
* We use a hidden widget class because we need the winId (hwnd) for Windows implementation.
|
||||
*/
|
||||
|
||||
//Usb Device change Windows implementation
|
||||
#ifdef Q_OS_WIN32
|
||||
#include <Windows.h>
|
||||
#include <Dbt.h>
|
||||
|
||||
const GUID MINIPRO_GUID={0x85980D83,0x32B9,0x4BA1,{0x8F,0xDF,0x12,0xA7,0x11,0xB9,0x9C,0xA2}};
|
||||
|
||||
void Notifier::RegisterUsbNotifications()
|
||||
{
|
||||
DEV_BROADCAST_DEVICEINTERFACE deviceInterface;
|
||||
ZeroMemory(&deviceInterface, sizeof(deviceInterface));
|
||||
deviceInterface.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE);
|
||||
deviceInterface.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
|
||||
deviceInterface.dbcc_classguid = MINIPRO_GUID;
|
||||
HDEVNOTIFY m_notify_handle = RegisterDeviceNotification((HANDLE)this->winId(),&deviceInterface, DEVICE_NOTIFY_WINDOW_HANDLE);
|
||||
if(m_notify_handle==NULL)
|
||||
{
|
||||
qDebug() << "Failed to register device notification!";
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "Register device notification O.K.";
|
||||
}
|
||||
|
||||
bool Notifier::winEvent(MSG *message, long *result)
|
||||
{
|
||||
Q_UNUSED(result);
|
||||
if (message->message==WM_DEVICECHANGE)
|
||||
{
|
||||
if (message->wParam==DBT_DEVICEARRIVAL)
|
||||
emit deviceChange(true);
|
||||
if (message->wParam==DBT_DEVICEREMOVECOMPLETE)
|
||||
emit deviceChange(false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Notifier::udev_event()
|
||||
{
|
||||
//stub function
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//Usb Device change Linux implementation
|
||||
#ifdef Q_OS_LINUX
|
||||
|
||||
#include <libudev.h>
|
||||
|
||||
udev_monitor *mon;//Global variable
|
||||
QStringList nodes;
|
||||
|
||||
|
||||
void Notifier::udev_event()
|
||||
{
|
||||
udev_device *dev = udev_monitor_receive_device(mon);
|
||||
if(dev)
|
||||
{
|
||||
QString devnode(udev_device_get_devnode(dev));
|
||||
QString vid(udev_device_get_sysattr_value(dev,"idVendor"));
|
||||
QString pid(udev_device_get_sysattr_value(dev,"idProduct"));
|
||||
QString action(udev_device_get_action(dev));
|
||||
if(action.toLower() == "add" && vid.toUShort(0,16) == TL866_VID && pid.toUShort(0,16) == TL866_PID)
|
||||
{
|
||||
if(!nodes.contains(devnode,Qt::CaseInsensitive))
|
||||
{
|
||||
nodes.append(devnode);
|
||||
//qDebug() << devnode <<" added";
|
||||
}
|
||||
emit deviceChange(true);
|
||||
}
|
||||
if(action.toLower() == "remove")
|
||||
{
|
||||
if(nodes.contains(devnode,Qt::CaseInsensitive))
|
||||
{
|
||||
|
||||
//qDebug() << devnode << " removed";
|
||||
nodes.removeOne(devnode);
|
||||
emit deviceChange(false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
udev_device_unref(dev);
|
||||
}
|
||||
|
||||
|
||||
void Notifier::RegisterUsbNotifications()
|
||||
{
|
||||
udev *udev = udev_new();
|
||||
if (!udev)
|
||||
{
|
||||
qDebug() << "udev error!" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
udev_enumerate *enumerate;
|
||||
udev_list_entry *devices, *dev_list_entry;
|
||||
udev_device *dev;
|
||||
|
||||
enumerate = udev_enumerate_new(udev);
|
||||
udev_enumerate_add_match_subsystem(enumerate, "usb");
|
||||
udev_enumerate_scan_devices(enumerate);
|
||||
devices = udev_enumerate_get_list_entry(enumerate);
|
||||
nodes.clear();
|
||||
const char *path;
|
||||
udev_list_entry_foreach(dev_list_entry, devices)
|
||||
{
|
||||
|
||||
path = udev_list_entry_get_name(dev_list_entry);
|
||||
dev = udev_device_new_from_syspath(udev, path);
|
||||
QString devnode(udev_device_get_devnode(dev));
|
||||
QString vid(udev_device_get_sysattr_value(dev,"idVendor"));
|
||||
QString pid(udev_device_get_sysattr_value(dev,"idProduct"));
|
||||
//QString product(udev_device_get_sysattr_value(dev,"product"));
|
||||
if((vid.toUShort(0,16) == TL866_VID) && (pid.toUShort(0,16) == TL866_PID))
|
||||
{
|
||||
nodes.append(devnode);
|
||||
//qDebug()<< "Found" << devnode << vid << pid << product;
|
||||
}
|
||||
udev_device_unref(dev);
|
||||
}
|
||||
udev_enumerate_unref(enumerate);
|
||||
|
||||
mon = udev_monitor_new_from_netlink(udev, "udev");
|
||||
if(!mon)
|
||||
{
|
||||
qDebug() << "Netlink not available!" << endl;
|
||||
return;
|
||||
}
|
||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "usb", "usb_device");
|
||||
udev_monitor_enable_receiving(mon);
|
||||
int fd = udev_monitor_get_fd(mon);
|
||||
socket_notifier=new QSocketNotifier(fd,QSocketNotifier::Read);
|
||||
connect(socket_notifier,SIGNAL(activated(int)),this,SLOT(udev_event()));
|
||||
qDebug() << "Register device notification O.K.";
|
||||
}
|
||||
#endif
|
||||
|
33
TL866_Updater/notifier.h
Normal file
33
TL866_Updater/notifier.h
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef NOTIFIER_H
|
||||
#define NOTIFIER_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QSocketNotifier>
|
||||
|
||||
class Notifier : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Notifier(QWidget *parent = 0);
|
||||
|
||||
~Notifier();
|
||||
signals:
|
||||
void deviceChange(bool arrived);
|
||||
|
||||
public slots:
|
||||
|
||||
private slots:
|
||||
void udev_event();
|
||||
|
||||
private:
|
||||
QSocketNotifier *socket_notifier;
|
||||
void RegisterUsbNotifications();
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
private:
|
||||
bool winEvent(MSG *message, long *result);
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
#endif // NOTIFIER_H
|
BIN
TL866_Updater/penDrive4.ico
Normal file
BIN
TL866_Updater/penDrive4.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
7
TL866_Updater/resources.qrc
Normal file
7
TL866_Updater/resources.qrc
Normal file
@ -0,0 +1,7 @@
|
||||
<RCC>
|
||||
<qresource prefix="/firmware">
|
||||
<file>firmwareA.bin</file>
|
||||
<file>firmwareCS.bin</file>
|
||||
<file>dumper.bin</file>
|
||||
</qresource>
|
||||
</RCC>
|
54
TL866_Updater/tl866_global.h
Normal file
54
TL866_Updater/tl866_global.h
Normal file
@ -0,0 +1,54 @@
|
||||
#ifndef TL866_GLOBAL_H
|
||||
#define TL866_GLOBAL_H
|
||||
|
||||
|
||||
#define SERIAL_OFFSET 0x1FD00
|
||||
#define FLASH_SIZE 0x20000
|
||||
#define BOOTLOADER_SIZE 0x1800
|
||||
#define ENCRYPTED_FIRMWARE_SIZE 0x25D00
|
||||
#define UNENCRYPTED_FIRMWARE_SIZE 0x1E400
|
||||
|
||||
#define WRITE_COMMAND 0xAA
|
||||
#define ERASE_COMMAND 0xCC
|
||||
#define RESET_COMMAND 0xFF
|
||||
#define REPORT_COMMAND 0x00
|
||||
|
||||
#define DUMPER_READ_FLASH 0x01
|
||||
#define DUMPER_WRITE_BOOTLOADER 0x02
|
||||
#define DUMPER_WRITE_CONFIG 0x03
|
||||
#define DUMPER_WRITE_INFO 0x04
|
||||
#define DUMPER_INFO 0x05
|
||||
|
||||
#define A_BOOTLOADER_CRC 0x95AB
|
||||
#define CS_BOOTLOADER_CRC 0x20D2
|
||||
|
||||
#define TL866_VID 0x04d8
|
||||
#define TL866_PID 0xe11c
|
||||
|
||||
enum BootloaderType{A_BOOTLOADER, CS_BOOTLOADER};
|
||||
enum FirmwareType{FIRMWARE_A, FIRMWARE_CS, FIRMWARE_CUSTOM};
|
||||
enum DEVICE_VERSION{VERSION_TL866A = 1, VERSION_TL866CS = 2};
|
||||
enum DEVICE_STATUS{NORMAL_MODE = 1, BOOTLOADER_MODE = 2};
|
||||
|
||||
typedef struct {
|
||||
uchar echo;
|
||||
uchar device_status;
|
||||
ushort report_size;
|
||||
uchar firmware_version_minor;
|
||||
uchar firmware_version_major;
|
||||
uchar device_version;
|
||||
uchar device_code[8];
|
||||
uchar serial_number[24];
|
||||
uchar hardware_version;
|
||||
}TL866_REPORT;
|
||||
|
||||
|
||||
typedef struct{
|
||||
uchar device_code[8];
|
||||
uchar serial_number[24];
|
||||
uchar bootloader_version;
|
||||
uchar cp_bit;
|
||||
}DUMPER_REPORT;
|
||||
|
||||
|
||||
#endif // TL866_GLOBAL_H
|
110
TL866_Updater/usb_linux.cpp
Normal file
110
TL866_Updater/usb_linux.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
/* Class USB, Linux version
|
||||
*
|
||||
* This file is part of the TL866 updater project.
|
||||
*
|
||||
* Copyright (C) radioman 2013
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*/
|
||||
|
||||
#include "usb_linux.h"
|
||||
#include "tl866_global.h"
|
||||
#include <QDebug>
|
||||
|
||||
USB::USB()
|
||||
{
|
||||
device_handle = NULL;
|
||||
libusb_init(&ctx);//initialize a new session
|
||||
libusb_set_debug(ctx, 3);//set verbosity level
|
||||
}
|
||||
|
||||
USB::~USB()
|
||||
{
|
||||
if(isOpen())
|
||||
close_device();
|
||||
libusb_exit(ctx); //close session
|
||||
}
|
||||
|
||||
|
||||
int USB::get_devices_count()
|
||||
{
|
||||
libusb_device **devs;
|
||||
devices.clear();
|
||||
|
||||
int count = libusb_get_device_list(ctx, &devs);
|
||||
if(count < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
for(int i = 0; i < count; i++) {
|
||||
libusb_device_descriptor desc;
|
||||
int ret = libusb_get_device_descriptor(devs[i], &desc);
|
||||
if (ret < 0) {
|
||||
return 0;
|
||||
}
|
||||
if(desc.idProduct == TL866_PID && desc.idVendor == TL866_VID)
|
||||
{
|
||||
devices.append(devs[i]);
|
||||
}
|
||||
|
||||
}
|
||||
libusb_free_device_list(devs, 1);
|
||||
return devices.size();
|
||||
}
|
||||
|
||||
bool USB::open_device(int index)
|
||||
{
|
||||
if(isOpen())
|
||||
close_device();
|
||||
|
||||
return (libusb_open(devices[index], &device_handle) == 0);
|
||||
|
||||
}
|
||||
|
||||
bool USB::isOpen()
|
||||
{
|
||||
return (device_handle !=NULL);
|
||||
}
|
||||
|
||||
void USB::close_device()
|
||||
{
|
||||
libusb_close(device_handle);
|
||||
device_handle = NULL;
|
||||
}
|
||||
|
||||
size_t USB::usb_read(unsigned char *data, size_t size)
|
||||
{
|
||||
int bytes_read;
|
||||
if(libusb_claim_interface(device_handle, 0) < 0)
|
||||
return 0;
|
||||
int ret = libusb_bulk_transfer(device_handle, LIBUSB_ENDPOINT_IN | 1, data, size, &bytes_read, 0);
|
||||
libusb_release_interface(device_handle, 0);
|
||||
if(ret !=0)
|
||||
return 0;
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
size_t USB::usb_write(unsigned char *data, size_t size)
|
||||
{
|
||||
int bytes_writen;
|
||||
if(libusb_claim_interface(device_handle, 0) < 0)
|
||||
return 0;
|
||||
int ret = libusb_bulk_transfer(device_handle, LIBUSB_ENDPOINT_OUT | 1, data, size, &bytes_writen, 0);
|
||||
libusb_release_interface(device_handle, 0);
|
||||
if(ret !=0)
|
||||
return 0;
|
||||
return bytes_writen;
|
||||
}
|
28
TL866_Updater/usb_linux.h
Normal file
28
TL866_Updater/usb_linux.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef USB_LINUX_H
|
||||
#define USB_LINUX_H
|
||||
|
||||
#include <glob.h>
|
||||
#include <QList>
|
||||
#include <libusb-1.0/libusb.h>
|
||||
|
||||
class USB
|
||||
{
|
||||
public:
|
||||
USB();
|
||||
~USB();
|
||||
|
||||
int get_devices_count();
|
||||
bool open_device(int index);
|
||||
bool isOpen();
|
||||
void close_device();
|
||||
size_t usb_read(unsigned char *data, size_t size);
|
||||
size_t usb_write(unsigned char *data, size_t size);
|
||||
|
||||
|
||||
private:
|
||||
libusb_context *ctx;
|
||||
libusb_device_handle *device_handle;
|
||||
QList<libusb_device*> devices;
|
||||
};
|
||||
|
||||
#endif // USB_LINUX_H
|
129
TL866_Updater/usb_win.cpp
Normal file
129
TL866_Updater/usb_win.cpp
Normal file
@ -0,0 +1,129 @@
|
||||
/* Class USB, windows version
|
||||
*
|
||||
* This file is part of the TL866 updater project.
|
||||
*
|
||||
* Copyright (C) radioman 2013
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
* USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "usb_win.h"
|
||||
#include "tl866_global.h"
|
||||
#include <QDebug>
|
||||
#include <Windows.h>
|
||||
#include <SetupAPI.h>
|
||||
|
||||
#define TL866_IOCTL_READ 0x222004
|
||||
#define TL866_IOCTL_WRITE 0x222000
|
||||
|
||||
USB::USB()
|
||||
{
|
||||
hDriver=INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
USB::~USB()
|
||||
{
|
||||
if(hDriver !=INVALID_HANDLE_VALUE)
|
||||
close_device();
|
||||
}
|
||||
const GUID MINIPRO_GUID={0x85980D83,0x32B9,0x4BA1,{0x8F,0xDF,0x12,0xA7,0x11,0xB9,0x9C,0xA2}};
|
||||
|
||||
int USB::get_devices_count()
|
||||
{
|
||||
DWORD idx = 0;
|
||||
devices.clear();
|
||||
HDEVINFO handle = SetupDiGetClassDevs(&MINIPRO_GUID, 0, 0, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
|
||||
|
||||
if (INVALID_HANDLE_VALUE == handle)
|
||||
{
|
||||
qDebug() << "SetupDi failed";
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (1)
|
||||
{
|
||||
SP_DEVINFO_DATA deviceinfodata;
|
||||
deviceinfodata.cbSize = sizeof(SP_DEVINFO_DATA);
|
||||
|
||||
if (SetupDiEnumDeviceInfo(handle, idx, &deviceinfodata))
|
||||
{
|
||||
SP_DEVICE_INTERFACE_DATA deviceinterfacedata;
|
||||
deviceinterfacedata.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
||||
|
||||
if (SetupDiEnumDeviceInterfaces(handle, 0, &MINIPRO_GUID, idx, &deviceinterfacedata))
|
||||
{
|
||||
idx++;
|
||||
DWORD size = 0;
|
||||
|
||||
SetupDiGetDeviceInterfaceDetail(handle, &deviceinterfacedata, NULL, 0, &size, NULL);
|
||||
PSP_DEVICE_INTERFACE_DETAIL_DATA deviceinterfacedetaildata = (PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(size * sizeof(TCHAR));
|
||||
deviceinterfacedetaildata->cbSize = sizeof(SP_INTERFACE_DEVICE_DETAIL_DATA);
|
||||
DWORD datasize = size;
|
||||
|
||||
if (SetupDiGetDeviceInterfaceDetail(handle, &deviceinterfacedata, deviceinterfacedetaildata, datasize , &size, NULL))
|
||||
#ifdef UNICODE
|
||||
devices.append(QString::fromWCharArray(deviceinterfacedetaildata->DevicePath));
|
||||
#else
|
||||
devices.append(deviceinterfacedetaildata->DevicePath);
|
||||
#endif free(deviceinterfacedetaildata);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return devices.count();
|
||||
}
|
||||
|
||||
bool USB::open_device(int index)
|
||||
{
|
||||
hDriver = CreateFileA(devices.at(index).toAscii().data(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
|
||||
return (hDriver != INVALID_HANDLE_VALUE);
|
||||
}
|
||||
|
||||
void USB::close_device()
|
||||
{
|
||||
CloseHandle(hDriver);
|
||||
hDriver=NULL;
|
||||
}
|
||||
|
||||
|
||||
bool USB::isOpen()
|
||||
{
|
||||
return (hDriver != INVALID_HANDLE_VALUE);
|
||||
}
|
||||
|
||||
size_t USB::usb_read(unsigned char *data, size_t size)
|
||||
{
|
||||
DWORD bytes_read;
|
||||
uchar buffer[4];
|
||||
if (hDriver == INVALID_HANDLE_VALUE)
|
||||
return 0;
|
||||
bool ret = DeviceIoControl(hDriver, TL866_IOCTL_READ, buffer, sizeof(buffer), data, size, &bytes_read, NULL);
|
||||
return (ret ? bytes_read : 0);
|
||||
}
|
||||
|
||||
size_t USB::usb_write(unsigned char *data, size_t size)
|
||||
{
|
||||
DWORD bytes_written;
|
||||
uchar buffer[4096];
|
||||
if (hDriver == INVALID_HANDLE_VALUE)
|
||||
return 0;
|
||||
bool ret = DeviceIoControl(hDriver, TL866_IOCTL_WRITE, data, size, buffer, sizeof(buffer), &bytes_written, NULL);
|
||||
return (ret ? bytes_written : 0);
|
||||
}
|
24
TL866_Updater/usb_win.h
Normal file
24
TL866_Updater/usb_win.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef USB_WIN_H
|
||||
#define USB_WIN_H
|
||||
#include <QStringList>
|
||||
#include <Windows.h>
|
||||
|
||||
class USB
|
||||
{
|
||||
public:
|
||||
USB();
|
||||
~USB();
|
||||
|
||||
int get_devices_count();
|
||||
bool open_device(int index);
|
||||
bool isOpen();
|
||||
void close_device();
|
||||
size_t usb_read(unsigned char *data, size_t size);
|
||||
size_t usb_write(unsigned char *data, size_t size);
|
||||
|
||||
private:
|
||||
QStringList devices;
|
||||
HANDLE hDriver;
|
||||
};
|
||||
|
||||
#endif // USB_WIN_H
|
1
TL866_Updater/win_resources.rc
Normal file
1
TL866_Updater/win_resources.rc
Normal file
@ -0,0 +1 @@
|
||||
IDI_ICON1 ICON DISCARDABLE "penDrive4.ico"
|
3
TSOP_Encryption/fuses.txt
Normal file
3
TSOP_Encryption/fuses.txt
Normal file
@ -0,0 +1,3 @@
|
||||
Low:0x75
|
||||
High:0xFe
|
||||
Lock:0xFF
|
20
TSOP_Encryption/tsop.atsln
Normal file
20
TSOP_Encryption/tsop.atsln
Normal file
@ -0,0 +1,20 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Atmel Studio Solution File, Format Version 11.00
|
||||
Project("{54F91283-7BC4-4236-8FF9-10F437C3AD48}") = "tsop", "tsop.cproj", "{6E70B2DD-551C-45A6-9C65-066D4AC11795}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|AVR = Debug|AVR
|
||||
Release|AVR = Release|AVR
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{6E70B2DD-551C-45A6-9C65-066D4AC11795}.Debug|AVR.ActiveCfg = Debug|AVR
|
||||
{6E70B2DD-551C-45A6-9C65-066D4AC11795}.Debug|AVR.Build.0 = Debug|AVR
|
||||
{6E70B2DD-551C-45A6-9C65-066D4AC11795}.Release|AVR.ActiveCfg = Release|AVR
|
||||
{6E70B2DD-551C-45A6-9C65-066D4AC11795}.Release|AVR.Build.0 = Release|AVR
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
208
TSOP_Encryption/tsop.c
Normal file
208
TSOP_Encryption/tsop.c
Normal file
@ -0,0 +1,208 @@
|
||||
/*
|
||||
* tsop.c
|
||||
*
|
||||
* Created: 22.02.2014 07:22:55
|
||||
* Author: radioman
|
||||
*/
|
||||
|
||||
#define F_CPU 4800000UL //Internal 4.8Mhz clock
|
||||
|
||||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <util/delay.h>
|
||||
#include <avr/pgmspace.h>
|
||||
|
||||
//Extracted xor table from TL866 firmware at 0x0196AA
|
||||
const unsigned char xortable[] PROGMEM =
|
||||
{
|
||||
0x48, 0x0D, 0x11, 0xB6, 0xA4, 0x76, 0xA0, 0xF6, 0x66, 0xE9, 0x55, 0xE5, 0xAC, 0x20, 0xDB, 0x16,
|
||||
0x0C, 0x65, 0x1F, 0x53, 0x7A, 0xEC, 0x55, 0x8F, 0x6C, 0x65, 0x3D, 0x1C, 0x3C, 0xD2, 0xA4, 0x1F,
|
||||
0xCD, 0x96, 0x2D, 0x40, 0x71, 0xCF, 0x51, 0xA6, 0x0A, 0xE6, 0xA5, 0x22, 0x70, 0x65, 0x5B, 0xAA,
|
||||
0x13, 0x08, 0x0C, 0x0A, 0xE2, 0x16, 0xB5, 0xD6, 0x6B, 0xF1, 0xFF, 0xA3, 0x43, 0xEC, 0xC3, 0x76,
|
||||
0xA8, 0x5E, 0xCD, 0x7D, 0x65, 0xF5, 0xE0, 0xFD, 0xF6, 0x4C, 0xFB, 0x8C, 0xED, 0xBF, 0xDB, 0x80,
|
||||
0x94, 0x7E, 0xC1, 0xA7, 0xD4, 0xE0, 0x75, 0x39, 0x55, 0xFA, 0x8B, 0x0A, 0xE7, 0x71, 0xE5, 0x04,
|
||||
0x21, 0x8C, 0x79, 0xD5, 0x47, 0x8D, 0x54, 0xE5, 0x71, 0x42, 0xDF, 0x8B, 0xEA, 0xD7, 0x62, 0x80,
|
||||
0xD7, 0xEE, 0xC6, 0x94, 0x19, 0xF1, 0x9F, 0x9F, 0x74, 0xA7, 0x6A, 0xBB, 0xF0, 0x06, 0x12, 0xB0,
|
||||
0x7F, 0x49, 0xBA, 0xB0, 0xE1, 0x42, 0xB6, 0x45, 0xC5, 0xF0, 0xDA, 0x87, 0x31, 0x54, 0xF8, 0x92,
|
||||
0x23, 0x81, 0xA4, 0x37, 0x79, 0xF3, 0x3A, 0xF2, 0x0E, 0x21, 0x23, 0x1C, 0x26, 0x55, 0x53, 0x62,
|
||||
0x0C, 0xBC, 0x16, 0x76, 0xF9, 0xB9, 0x0D, 0x04, 0x38, 0x7F, 0x73, 0xE8, 0x88, 0xDF, 0xA5, 0x9E,
|
||||
0xC2, 0x5E, 0xE2, 0xFA, 0xBB, 0x8B, 0x4F, 0x19, 0x6C, 0x90, 0x3E, 0x97, 0x50, 0x06, 0xAF, 0x02,
|
||||
0x0E, 0x0E, 0x17, 0x8F, 0x58, 0x9D, 0x61, 0x0C, 0x13, 0x17, 0x33, 0x16, 0xB8, 0x20, 0x72, 0x8C,
|
||||
0xFA, 0xAF, 0x08, 0x44, 0xA9, 0x63, 0xE5, 0xFC, 0xD6, 0x1B, 0x43, 0x93, 0x38, 0xC1, 0x2F, 0x79,
|
||||
0xCE, 0x66, 0x45, 0x64, 0xC6, 0x94, 0xBB, 0x44, 0x9E, 0xDF, 0xA1, 0x7A, 0x89, 0xBE, 0x66, 0x44,
|
||||
0x14, 0x99, 0x9F, 0x7C, 0x09, 0x23, 0x04, 0x83, 0x93, 0xEA, 0xBB, 0x78, 0xA4, 0x2D, 0xDA, 0xAD
|
||||
};
|
||||
|
||||
/*Constant response packet. This packet structure is simple:
|
||||
1.Xor bytes from offset 4 to 35(0x74 to 0xBA) with byte at offset 0 (0x57)
|
||||
2.Compute a checksum of first 35 bytes; the result must match the last byte (0x7D). If this checksum doesn't match then the TL866 report "V0 is illegal"
|
||||
|
||||
Actually the TL866 firmware will check if the first 8 bytes are: 51 33 51 00 c8 9d d4 3e ; if yes then return FAKE!
|
||||
Now what happen if we put 37 bytes of '0'? well xor zero by zero equal zero and checksum of an infinite number of zeros is zero! and this will pass the genuine check. Very weak algorithm.
|
||||
But we keep this as original chip does. Thanks Gerard for your captures.
|
||||
*/
|
||||
const unsigned char response[] PROGMEM =
|
||||
{
|
||||
0x57, 0x33, 0x57, 0x00, 0x74, 0x87, 0x75, 0xC5, 0xE9, 0xE6, 0xF5, 0xEE, 0x95, 0x12, 0x5B, 0x66,
|
||||
0x1F, 0x0A, 0x68, 0xFC, 0x8A, 0x80, 0x3B, 0xFD, 0x72, 0x01, 0x7E, 0x38, 0x2B, 0x4D, 0xC3, 0x43,
|
||||
0xC7, 0xA5, 0x9A, 0xBA, 0x7D
|
||||
};
|
||||
|
||||
|
||||
//Data line port defines
|
||||
#define DATA_LINE_DDR DDRB
|
||||
#define DATA_LINE_OUT_PORT PORTB
|
||||
#define DATA_LINE_IN_PORT PINB
|
||||
#define DATA_LINE_PIN 4
|
||||
|
||||
|
||||
//clock line port defines
|
||||
#define CLOCK_LINE_DDR DDRB
|
||||
#define CLOCK_LINE_PORT PINB
|
||||
#define CLOCK_LINE_PIN 3
|
||||
|
||||
//helper macros
|
||||
#define data_line (DATA_LINE_IN_PORT &(1<<DATA_LINE_PIN))
|
||||
#define clock_line (CLOCK_LINE_PORT &(1<<CLOCK_LINE_PIN))
|
||||
#define data_line_high (DATA_LINE_OUT_PORT |= (1<<DATA_LINE_PIN))
|
||||
#define data_line_low (DATA_LINE_OUT_PORT &= ~(1<<DATA_LINE_PIN))
|
||||
#define set_data_line_out (DATA_LINE_DDR |=(1<<DATA_LINE_PIN))
|
||||
#define set_data_line_in (DATA_LINE_DDR &= ~(1<<DATA_LINE_PIN))
|
||||
|
||||
//machine state
|
||||
#define STATE_RECEIVE 0
|
||||
#define STATE_TRANSMIT 1
|
||||
|
||||
|
||||
unsigned char buffer[47];//Receive/Send buffer
|
||||
volatile unsigned char state_machine;//keep the machine state
|
||||
unsigned char bit;
|
||||
unsigned char byte;
|
||||
|
||||
static inline unsigned int crc16_ccitt(unsigned char* data, unsigned int len);
|
||||
static inline void spi_receive();
|
||||
static inline void spi_send();
|
||||
static inline void check();
|
||||
|
||||
//Main routine
|
||||
int main(void)
|
||||
{
|
||||
DATA_LINE_OUT_PORT |=(1<<DATA_LINE_PIN);//pull-up on data line
|
||||
CLOCK_LINE_PORT |=(1<<CLOCK_LINE_PIN);//pull-up on clock line
|
||||
PCMSK |=(1<<CLOCK_LINE_PIN);//set PCMSK clock line external interrupt mask
|
||||
GIMSK|=(1<<PCIE);//activate external sense interrupts
|
||||
bit=0;
|
||||
byte=0;
|
||||
state_machine=STATE_RECEIVE;//we start in receive mode
|
||||
_delay_ms(5);//wait for lines to settle.
|
||||
sei();//enable interrupts
|
||||
while(1)//just nothing here. From now all tasks are interrupt driven.
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//CRC16_CCITT routine
|
||||
unsigned int crc16_ccitt(unsigned char* data, unsigned int len)
|
||||
{
|
||||
unsigned int crc=0;
|
||||
while(len--)
|
||||
{
|
||||
crc = (unsigned char)(crc >> 8) | (crc << 8);
|
||||
crc ^= *data++;
|
||||
crc ^= (unsigned char)(crc & 0xFF) >> 4;
|
||||
crc ^= (crc << 8) << 4;
|
||||
crc ^= ((crc & 0xFF) << 4) << 1;
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
|
||||
//Simple interrupt routine handler
|
||||
ISR(PCINT0_vect)
|
||||
{
|
||||
if(clock_line)//If clock line was changed from 0 to 1 then we call receive/send routines
|
||||
{
|
||||
if(!state_machine)
|
||||
spi_receive();
|
||||
else
|
||||
spi_send();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Receive 10 bytes routine. Driven by clock line
|
||||
static inline void spi_receive()
|
||||
{
|
||||
buffer[byte]<<=1;
|
||||
if(data_line)
|
||||
buffer[byte]|=1;
|
||||
bit++;
|
||||
bit &=7;
|
||||
if(!bit)
|
||||
{
|
||||
byte++;
|
||||
if(byte==10)
|
||||
{
|
||||
byte=0;
|
||||
set_data_line_out;//switch the data line in output mode
|
||||
check();//check and prepare transmit buffer
|
||||
if (buffer[byte] & 0x80)//put the first bit to data line
|
||||
data_line_high;
|
||||
else
|
||||
data_line_low;
|
||||
buffer[byte]<<=1;
|
||||
bit++;
|
||||
state_machine=STATE_TRANSMIT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Send 47 bytes routine. Driven by clock line.
|
||||
static inline void spi_send()
|
||||
{
|
||||
if (buffer[byte] & 0x80)
|
||||
data_line_high;
|
||||
else
|
||||
data_line_low;
|
||||
buffer[byte]<<=1;
|
||||
bit++;
|
||||
bit &=7;
|
||||
if(!bit)
|
||||
{
|
||||
byte++;
|
||||
if(byte==47)
|
||||
{
|
||||
byte=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check the received data
|
||||
static inline void check()
|
||||
{
|
||||
unsigned char i,index;
|
||||
//swap byte 2 by 8 and 4 by 9
|
||||
i=buffer[8];
|
||||
buffer[8]=buffer[2];
|
||||
buffer[2]=i;
|
||||
i=buffer[9];
|
||||
buffer[9]=buffer[4];
|
||||
buffer[4]=i;
|
||||
//calculate crc16_ccitt of the first 10 bytes. If they match then we change the state machine in transmit mode.
|
||||
if(crc16_ccitt(buffer,8)==((buffer[9] << 8) | buffer[8]))
|
||||
{
|
||||
index=(buffer[0] & buffer[7]);//The starting index for byte xoring is byte 0 AND 7
|
||||
for(i=0;i<10;i++)
|
||||
{
|
||||
buffer[i] ^=pgm_read_byte(&xortable[index++]);//xor first 10 bytes against a xortable
|
||||
index &=0xFF;//index is incremented modulo 256
|
||||
}
|
||||
for(i=0;i<37;i++)
|
||||
{
|
||||
buffer[i+10]=pgm_read_byte(&response[i]);//copy the next predefined 37 bytes from flash to the SRAM buffer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
103
TSOP_Encryption/tsop.cproj
Normal file
103
TSOP_Encryption/tsop.cproj
Normal file
@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectVersion>6.1</ProjectVersion>
|
||||
<ToolchainName>com.Atmel.AVRGCC8.C</ToolchainName>
|
||||
<ProjectGuid>{6e70b2dd-551c-45a6-9c65-066d4ac11795}</ProjectGuid>
|
||||
<avrdevice>ATtiny13A</avrdevice>
|
||||
<avrdeviceseries>none</avrdeviceseries>
|
||||
<OutputType>Executable</OutputType>
|
||||
<Language>C</Language>
|
||||
<OutputFileName>$(MSBuildProjectName)</OutputFileName>
|
||||
<OutputFileExtension>.elf</OutputFileExtension>
|
||||
<OutputDirectory>$(MSBuildProjectDirectory)\$(Configuration)</OutputDirectory>
|
||||
<AssemblyName>tsop</AssemblyName>
|
||||
<Name>tsop</Name>
|
||||
<RootNamespace>tsop</RootNamespace>
|
||||
<ToolchainFlavour>Native</ToolchainFlavour>
|
||||
<KeepTimersRunning>true</KeepTimersRunning>
|
||||
<OverrideVtor>false</OverrideVtor>
|
||||
<CacheFlash>true</CacheFlash>
|
||||
<ProgFlashFromRam>true</ProgFlashFromRam>
|
||||
<RamSnippetAddress />
|
||||
<UncachedRange />
|
||||
<OverrideVtorValue />
|
||||
<BootSegment>2</BootSegment>
|
||||
<eraseonlaunchrule>1</eraseonlaunchrule>
|
||||
<AsfFrameworkConfig>
|
||||
<framework-data xmlns="">
|
||||
<options />
|
||||
<configurations />
|
||||
<files />
|
||||
<documentation help="" />
|
||||
<offline-documentation help="" />
|
||||
<dependencies>
|
||||
<content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.11.0" />
|
||||
</dependencies>
|
||||
</framework-data>
|
||||
</AsfFrameworkConfig>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<ToolchainSettings>
|
||||
<AvrGcc>
|
||||
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
|
||||
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
|
||||
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
|
||||
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
|
||||
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
|
||||
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
|
||||
<avrgcc.compiler.symbols.DefSymbols>
|
||||
<ListValues>
|
||||
<Value>NDEBUG</Value>
|
||||
</ListValues>
|
||||
</avrgcc.compiler.symbols.DefSymbols>
|
||||
<avrgcc.compiler.optimization.level>Optimize for size (-Os)</avrgcc.compiler.optimization.level>
|
||||
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
|
||||
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
|
||||
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
|
||||
<avrgcc.compiler.miscellaneous.Verbose>True</avrgcc.compiler.miscellaneous.Verbose>
|
||||
<avrgcc.linker.general.GenerateMAPFile>False</avrgcc.linker.general.GenerateMAPFile>
|
||||
<avrgcc.linker.libraries.Libraries>
|
||||
<ListValues>
|
||||
<Value>libm</Value>
|
||||
</ListValues>
|
||||
</avrgcc.linker.libraries.Libraries>
|
||||
</AvrGcc>
|
||||
</ToolchainSettings>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<ToolchainSettings>
|
||||
<AvrGcc>
|
||||
<avrgcc.common.outputfiles.hex>True</avrgcc.common.outputfiles.hex>
|
||||
<avrgcc.common.outputfiles.lss>True</avrgcc.common.outputfiles.lss>
|
||||
<avrgcc.common.outputfiles.eep>True</avrgcc.common.outputfiles.eep>
|
||||
<avrgcc.common.outputfiles.srec>True</avrgcc.common.outputfiles.srec>
|
||||
<avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</avrgcc.compiler.general.ChangeDefaultCharTypeUnsigned>
|
||||
<avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>True</avrgcc.compiler.general.ChangeDefaultBitFieldUnsigned>
|
||||
<avrgcc.compiler.symbols.DefSymbols>
|
||||
<ListValues>
|
||||
<Value>DEBUG</Value>
|
||||
</ListValues>
|
||||
</avrgcc.compiler.symbols.DefSymbols>
|
||||
<avrgcc.compiler.optimization.level>Optimize (-O1)</avrgcc.compiler.optimization.level>
|
||||
<avrgcc.compiler.optimization.PackStructureMembers>True</avrgcc.compiler.optimization.PackStructureMembers>
|
||||
<avrgcc.compiler.optimization.AllocateBytesNeededForEnum>True</avrgcc.compiler.optimization.AllocateBytesNeededForEnum>
|
||||
<avrgcc.compiler.optimization.DebugLevel>Default (-g2)</avrgcc.compiler.optimization.DebugLevel>
|
||||
<avrgcc.compiler.warnings.AllWarnings>True</avrgcc.compiler.warnings.AllWarnings>
|
||||
<avrgcc.linker.libraries.Libraries>
|
||||
<ListValues>
|
||||
<Value>libm</Value>
|
||||
</ListValues>
|
||||
</avrgcc.linker.libraries.Libraries>
|
||||
<avrgcc.assembler.debugging.DebugLevel>Default (-Wa,-g)</avrgcc.assembler.debugging.DebugLevel>
|
||||
</AvrGcc>
|
||||
</ToolchainSettings>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="tsop.c">
|
||||
<SubType>compile</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />
|
||||
</Project>
|
52
TSOP_Encryption/tsop.hex
Normal file
52
TSOP_Encryption/tsop.hex
Normal file
@ -0,0 +1,52 @@
|
||||
:100000009CC0A9C0BDC0A7C0A6C0A5C0A4C0A3C0B5
|
||||
:10001000A2C0A1C057335700748775C5E9E6F5EE55
|
||||
:1000200095125B661F0A68FC8A803BFD72017E3870
|
||||
:100030002B4DC343C7A59ABA7D480D11B6A476A02F
|
||||
:10004000F666E955E5AC20DB160C651F537AEC55D6
|
||||
:100050008F6C653D1C3CD2A41FCD962D4071CF51B5
|
||||
:10006000A60AE6A52270655BAA13080C0AE216B57B
|
||||
:10007000D66BF1FFA343ECC376A85ECD7D65F5E0BA
|
||||
:10008000FDF64CFB8CEDBFDB80947EC1A7D4E07500
|
||||
:100090003955FA8B0AE771E504218C79D5478D54DF
|
||||
:1000A000E57142DF8BEAD76280D7EEC69419F19FE3
|
||||
:1000B0009F74A76ABBF00612B07F49BAB0E142B69E
|
||||
:1000C00045C5F0DA873154F8922381A43779F33AA1
|
||||
:1000D000F20E21231C265553620CBC1676F9B90D7D
|
||||
:1000E00004387F73E888DFA59EC25EE2FABB8B4FBF
|
||||
:1000F000196C903E975006AF020E0E178F589D61F7
|
||||
:100100000C13173316B820728CFAAF0844A963E5B4
|
||||
:10011000FCD61B439338C12F79CE664564C694BB89
|
||||
:10012000449EDFA17A89BE664414999F7C0923040A
|
||||
:100130008393EABB78A42DDAAD0011241FBECFE96A
|
||||
:10014000CDBF20E0A0E6B0E001C01D92A239B20709
|
||||
:10015000E1F702D0EBC054CFC49AB39AAB9A8BB7F5
|
||||
:1001600080628BBF1092600010929100109261002B
|
||||
:100170008FE697E10197F1F700C000007894FFCF78
|
||||
:100180001F920F920FB60F9211242F933F934F930C
|
||||
:100190005F938F939F93AF93BF93EF93FF93B39B23
|
||||
:1001A000B6C08091610090919100E92FF0E0EE5986
|
||||
:1001B000FF4F81118DC08081880F8083B49B02C066
|
||||
:1001C00081608083809160008F5F87708093600082
|
||||
:1001D00081119DC09F5F909391009A3009F097C064
|
||||
:1001E00010929100BC9A80916A0040916400409303
|
||||
:1001F0006A008093640080916B0050916600509378
|
||||
:100200006B0080936600E2E6F0E080E090E09827E3
|
||||
:100210008927982721918227282F22952F708227BE
|
||||
:100220009C01322F22273295307F28273927C90198
|
||||
:100230009927B5E0880F991FBA95E1F78227932790
|
||||
:1002400020E0EA36F20719F7352F20E0242B821739
|
||||
:10025000930751F0E0919100AE2FB0E0AE59BF4F3F
|
||||
:100260008C9187FF25C022C0909169008091620027
|
||||
:100270009823A2E6B0E080E0E82FE90FF0E0E75C29
|
||||
:10028000FF4FE4912C912E272D938F5F8A30A1F799
|
||||
:10029000ACE6B0E080E090E0FC01EC5EFF4FE49162
|
||||
:1002A000ED93019685329105B9F7D4CFC49A01C078
|
||||
:1002B000C498F0E0EE59FF4F8081880F80838091D1
|
||||
:1002C00060008F5F8093600081E0809361001FC0B9
|
||||
:1002D000808187FF02C0C49A01C0C49890919100A8
|
||||
:1002E000E92FF0E0EE59FF4F8081880F80838091E5
|
||||
:1002F00060008F5F877080936000811108C0892F34
|
||||
:100300008F5F809391008F3211F410929100FF91D2
|
||||
:10031000EF91BF91AF919F918F915F914F913F91DD
|
||||
:100320002F910F900FBE0F901F901895F894FFCF4C
|
||||
:00000001FF
|
BIN
docs/TL866.pdf
Normal file
BIN
docs/TL866.pdf
Normal file
Binary file not shown.
BIN
docs/TL866_prog.pdf
Normal file
BIN
docs/TL866_prog.pdf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user