mirror of
https://github.com/HEYAHONG/cc-tool.git
synced 2025-05-08 19:51:05 +08:00
Initial import. Need to clean this stuff up
This commit is contained in:
commit
8ab3b96b05
340
COPYING
Normal file
340
COPYING
Normal file
@ -0,0 +1,340 @@
|
||||
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 Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 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 Library General
|
||||
Public License instead of this License.
|
18
ChangeLog
Normal file
18
ChangeLog
Normal file
@ -0,0 +1,18 @@
|
||||
11/08/2011 version 0.11
|
||||
* first public release, alpha version
|
||||
|
||||
11/10/2011 version 0.12
|
||||
* fixed merge data sections bug
|
||||
* add operation log
|
||||
|
||||
11/12/2011 version 0.13
|
||||
* lots of fixes, status changed to beta
|
||||
|
||||
01/11/2012 version 0.15
|
||||
* fix compile time error on x64 machines
|
||||
* minor changes
|
||||
|
||||
03/12/2012 version 0.16
|
||||
* fixed CC debugger device USB PID value
|
||||
|
||||
|
365
INSTALL
Normal file
365
INSTALL
Normal file
@ -0,0 +1,365 @@
|
||||
Installation Instructions
|
||||
*************************
|
||||
|
||||
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
|
||||
2006, 2007, 2008, 2009 Free Software Foundation, Inc.
|
||||
|
||||
Copying and distribution of this file, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
notice and this notice are preserved. This file is offered as-is,
|
||||
without warranty of any kind.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
Briefly, the shell commands `./configure; make; make install' should
|
||||
configure, build, and install this package. The following
|
||||
more-detailed instructions are generic; see the `README' file for
|
||||
instructions specific to this package. Some packages provide this
|
||||
`INSTALL' file but do not implement all of the features documented
|
||||
below. The lack of an optional feature in a given package is not
|
||||
necessarily a bug. More recommendations for GNU packages can be found
|
||||
in *note Makefile Conventions: (standards)Makefile Conventions.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file `config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
It can also use an optional file (typically called `config.cache'
|
||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||
the results of its tests to speed up reconfiguring. Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point `config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You need `configure.ac' if
|
||||
you want to change it or regenerate `configure' using a newer version
|
||||
of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system.
|
||||
|
||||
Running `configure' might take a while. While running, it prints
|
||||
some messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package, generally using the just-built uninstalled binaries.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation. When installing into a prefix owned by root, it is
|
||||
recommended that the package be configured and built as a regular
|
||||
user, and only the `make install' phase executed with root
|
||||
privileges.
|
||||
|
||||
5. Optionally, type `make installcheck' to repeat any self-tests, but
|
||||
this time using the binaries in their final installed location.
|
||||
This target does not install anything. Running this target as a
|
||||
regular user, particularly if the prior `make install' required
|
||||
root privileges, verifies that the installation completed
|
||||
correctly.
|
||||
|
||||
6. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
7. Often, you can also type `make uninstall' to remove the installed
|
||||
files again. In practice, not all packages have tested that
|
||||
uninstallation works correctly, even though it is required by the
|
||||
GNU Coding Standards.
|
||||
|
||||
8. Some packages, particularly those that use Automake, provide `make
|
||||
distcheck', which can by used by developers to test that all other
|
||||
targets like `make install' and `make uninstall' work correctly.
|
||||
This target is generally not run by end users.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. Run `./configure --help'
|
||||
for details on some of the pertinent environment variables.
|
||||
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
./configure CC=c99 CFLAGS=-g LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you can use GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'. This
|
||||
is known as a "VPATH" build.
|
||||
|
||||
With a non-GNU `make', it is safer to compile the package for one
|
||||
architecture at a time in the source code directory. After you have
|
||||
installed the package for one architecture, use `make distclean' before
|
||||
reconfiguring for another architecture.
|
||||
|
||||
On MacOS X 10.5 and later systems, you can create libraries and
|
||||
executables that work on multiple system types--known as "fat" or
|
||||
"universal" binaries--by specifying multiple `-arch' options to the
|
||||
compiler but only a single `-arch' option to the preprocessor. Like
|
||||
this:
|
||||
|
||||
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
|
||||
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
|
||||
CPP="gcc -E" CXXCPP="g++ -E"
|
||||
|
||||
This is not guaranteed to produce working output in all cases, you
|
||||
may have to build one architecture at a time and combine the results
|
||||
using the `lipo' tool if you have problems.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' installs the package's commands under
|
||||
`/usr/local/bin', include files under `/usr/local/include', etc. You
|
||||
can specify an installation prefix other than `/usr/local' by giving
|
||||
`configure' the option `--prefix=PREFIX', where PREFIX must be an
|
||||
absolute file name.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
|
||||
PREFIX as the prefix for installing programs and libraries.
|
||||
Documentation and other data files still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=DIR' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them. In general, the
|
||||
default for these options is expressed in terms of `${prefix}', so that
|
||||
specifying just `--prefix' will affect all of the other directory
|
||||
specifications that were not explicitly provided.
|
||||
|
||||
The most portable way to affect installation locations is to pass the
|
||||
correct locations to `configure'; however, many packages provide one or
|
||||
both of the following shortcuts of passing variable assignments to the
|
||||
`make install' command line to change installation locations without
|
||||
having to reconfigure or recompile.
|
||||
|
||||
The first method involves providing an override variable for each
|
||||
affected directory. For example, `make install
|
||||
prefix=/alternate/directory' will choose an alternate location for all
|
||||
directory configuration variables that were expressed in terms of
|
||||
`${prefix}'. Any directories that were specified during `configure',
|
||||
but not in terms of `${prefix}', must each be overridden at install
|
||||
time for the entire installation to be relocated. The approach of
|
||||
makefile variable overrides for each directory variable is required by
|
||||
the GNU Coding Standards, and ideally causes no recompilation.
|
||||
However, some platforms have known limitations with the semantics of
|
||||
shared libraries that end up requiring recompilation when using this
|
||||
method, particularly noticeable in packages that use GNU Libtool.
|
||||
|
||||
The second method involves providing the `DESTDIR' variable. For
|
||||
example, `make install DESTDIR=/alternate/directory' will prepend
|
||||
`/alternate/directory' before all installation names. The approach of
|
||||
`DESTDIR' overrides is not required by the GNU Coding Standards, and
|
||||
does not work on platforms that have drive letters. On the other hand,
|
||||
it does better at avoiding recompilation issues, and works well even
|
||||
when some directory options were not specified in terms of `${prefix}'
|
||||
at `configure' time.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Some packages offer the ability to configure how verbose the
|
||||
execution of `make' will be. For these packages, running `./configure
|
||||
--enable-silent-rules' sets the default to minimal output, which can be
|
||||
overridden with `make V=1'; while running `./configure
|
||||
--disable-silent-rules' sets the default to verbose, which can be
|
||||
overridden with `make V=0'.
|
||||
|
||||
Particular systems
|
||||
==================
|
||||
|
||||
On HP-UX, the default C compiler is not ANSI C compatible. If GNU
|
||||
CC is not installed, it is recommended to use the following options in
|
||||
order to use an ANSI C compiler:
|
||||
|
||||
./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
|
||||
|
||||
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
|
||||
|
||||
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
|
||||
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
|
||||
a workaround. If GNU CC is not installed, it is therefore recommended
|
||||
to try
|
||||
|
||||
./configure CC="cc"
|
||||
|
||||
and if that doesn't work, try
|
||||
|
||||
./configure CC="cc -nodtk"
|
||||
|
||||
On Solaris, don't put `/usr/ucb' early in your `PATH'. This
|
||||
directory contains several dysfunctional programs; working variants of
|
||||
these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
|
||||
in your `PATH', put it _after_ `/usr/bin'.
|
||||
|
||||
On Haiku, software installed for all users goes in `/boot/common',
|
||||
not `/usr/local'. It is recommended to use the following options:
|
||||
|
||||
./configure --prefix=/boot/common
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' cannot figure out
|
||||
automatically, but needs to determine by the type of machine the package
|
||||
will run on. Usually, assuming the package is built to be run on the
|
||||
_same_ architectures, `configure' can figure that out, but if it prints
|
||||
a message saying it cannot guess the machine type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
OS
|
||||
KERNEL-OS
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the option `--target=TYPE' to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with `--host=TYPE'.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
you can create a site shell script called `config.site' that gives
|
||||
default values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the `configure' command line, using `VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
causes the specified `gcc' to be used as the C compiler (unless it is
|
||||
overridden in the site shell script).
|
||||
|
||||
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
|
||||
an Autoconf bug. Until the bug is fixed you can use this workaround:
|
||||
|
||||
CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
|
||||
|
||||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of all of the options to `configure', and exit.
|
||||
|
||||
`--help=short'
|
||||
`--help=recursive'
|
||||
Print a summary of the options unique to this package's
|
||||
`configure', and exit. The `short' variant lists options used
|
||||
only in the top level, while the `recursive' variant lists options
|
||||
also present in any nested packages.
|
||||
|
||||
`--version'
|
||||
`-V'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||
disable caching.
|
||||
|
||||
`--config-cache'
|
||||
`-C'
|
||||
Alias for `--cache-file=config.cache'.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`--prefix=DIR'
|
||||
Use DIR as the installation prefix. *note Installation Names::
|
||||
for more details, including other options available for fine-tuning
|
||||
the installation locations.
|
||||
|
||||
`--no-create'
|
||||
`-n'
|
||||
Run the configure checks, but stop before creating any output
|
||||
files.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
||||
|
2
Makefile.am
Normal file
2
Makefile.am
Normal file
@ -0,0 +1,2 @@
|
||||
SUBDIRS=src
|
||||
ACLOCAL_AMFLAGS = -I m4
|
726
Makefile.in
Normal file
726
Makefile.in
Normal file
@ -0,0 +1,726 @@
|
||||
# Makefile.in generated by automake 1.11.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
|
||||
# Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = .
|
||||
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
|
||||
$(srcdir)/Makefile.in $(top_srcdir)/configure AUTHORS COPYING \
|
||||
ChangeLog INSTALL NEWS config.guess config.sub depcomp \
|
||||
install-sh ltmain.sh missing
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \
|
||||
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
|
||||
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
|
||||
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
|
||||
configure.lineno config.status.lineno
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
SOURCES =
|
||||
DIST_SOURCES =
|
||||
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
|
||||
html-recursive info-recursive install-data-recursive \
|
||||
install-dvi-recursive install-exec-recursive \
|
||||
install-html-recursive install-info-recursive \
|
||||
install-pdf-recursive install-ps-recursive install-recursive \
|
||||
installcheck-recursive installdirs-recursive pdf-recursive \
|
||||
ps-recursive uninstall-recursive
|
||||
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
|
||||
distclean-recursive maintainer-clean-recursive
|
||||
AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
|
||||
$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
|
||||
distdir dist dist-all distcheck
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DIST_SUBDIRS = $(SUBDIRS)
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
distdir = $(PACKAGE)-$(VERSION)
|
||||
top_distdir = $(distdir)
|
||||
am__remove_distdir = \
|
||||
{ test ! -d "$(distdir)" \
|
||||
|| { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
|
||||
&& rm -fr "$(distdir)"; }; }
|
||||
am__relativize = \
|
||||
dir0=`pwd`; \
|
||||
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
|
||||
sed_rest='s,^[^/]*/*,,'; \
|
||||
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
|
||||
sed_butlast='s,/*[^/]*$$,,'; \
|
||||
while test -n "$$dir1"; do \
|
||||
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
|
||||
if test "$$first" != "."; then \
|
||||
if test "$$first" = ".."; then \
|
||||
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
|
||||
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
|
||||
else \
|
||||
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
|
||||
if test "$$first2" = "$$first"; then \
|
||||
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
|
||||
else \
|
||||
dir2="../$$dir2"; \
|
||||
fi; \
|
||||
dir0="$$dir0"/"$$first"; \
|
||||
fi; \
|
||||
fi; \
|
||||
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
|
||||
done; \
|
||||
reldir="$$dir2"
|
||||
DIST_ARCHIVES = $(distdir).tar.gz
|
||||
GZIP_ENV = --best
|
||||
distuninstallcheck_listfiles = find . -type f -print
|
||||
distcleancheck_listfiles = find . -type f -print
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
|
||||
BOOST_FILESYSTEM_LDFLAGS = @BOOST_FILESYSTEM_LDFLAGS@
|
||||
BOOST_FILESYSTEM_LDPATH = @BOOST_FILESYSTEM_LDPATH@
|
||||
BOOST_FILESYSTEM_LIBS = @BOOST_FILESYSTEM_LIBS@
|
||||
BOOST_LDPATH = @BOOST_LDPATH@
|
||||
BOOST_PROGRAM_OPTIONS_LDFLAGS = @BOOST_PROGRAM_OPTIONS_LDFLAGS@
|
||||
BOOST_PROGRAM_OPTIONS_LDPATH = @BOOST_PROGRAM_OPTIONS_LDPATH@
|
||||
BOOST_PROGRAM_OPTIONS_LIBS = @BOOST_PROGRAM_OPTIONS_LIBS@
|
||||
BOOST_REGEX_LDFLAGS = @BOOST_REGEX_LDFLAGS@
|
||||
BOOST_REGEX_LDPATH = @BOOST_REGEX_LDPATH@
|
||||
BOOST_REGEX_LIBS = @BOOST_REGEX_LIBS@
|
||||
BOOST_ROOT = @BOOST_ROOT@
|
||||
BOOST_SYSTEM_LDFLAGS = @BOOST_SYSTEM_LDFLAGS@
|
||||
BOOST_SYSTEM_LDPATH = @BOOST_SYSTEM_LDPATH@
|
||||
BOOST_SYSTEM_LIBS = @BOOST_SYSTEM_LIBS@
|
||||
BOOST_THREAD_LDFLAGS = @BOOST_THREAD_LDFLAGS@
|
||||
BOOST_THREAD_LDPATH = @BOOST_THREAD_LDPATH@
|
||||
BOOST_THREAD_LIBS = @BOOST_THREAD_LIBS@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DEPS_CFLAGS = @DEPS_CFLAGS@
|
||||
DEPS_LIBS = @DEPS_LIBS@
|
||||
DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
PKG_CONFIG = @PKG_CONFIG@
|
||||
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
|
||||
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
SUBDIRS = src
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
all: all-recursive
|
||||
|
||||
.SUFFIXES:
|
||||
am--refresh:
|
||||
@:
|
||||
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \
|
||||
$(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \
|
||||
&& exit 0; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --gnu Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
echo ' $(SHELL) ./config.status'; \
|
||||
$(SHELL) ./config.status;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
$(SHELL) ./config.status --recheck
|
||||
|
||||
$(top_srcdir)/configure: $(am__configure_deps)
|
||||
$(am__cd) $(srcdir) && $(AUTOCONF)
|
||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
||||
$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
|
||||
$(am__aclocal_m4_deps):
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
distclean-libtool:
|
||||
-rm -f libtool config.lt
|
||||
|
||||
# This directory's subdirectories are mostly independent; you can cd
|
||||
# into them and run `make' without going through this Makefile.
|
||||
# To change the values of `make' variables: instead of editing Makefiles,
|
||||
# (1) if the variable is set in `config.status', edit `config.status'
|
||||
# (which will cause the Makefiles to be regenerated when you run `make');
|
||||
# (2) otherwise, pass the desired values on the `make' command line.
|
||||
$(RECURSIVE_TARGETS):
|
||||
@fail= failcom='exit 1'; \
|
||||
for f in x $$MAKEFLAGS; do \
|
||||
case $$f in \
|
||||
*=* | --[!k]*);; \
|
||||
*k*) failcom='fail=yes';; \
|
||||
esac; \
|
||||
done; \
|
||||
dot_seen=no; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
dot_seen=yes; \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| eval $$failcom; \
|
||||
done; \
|
||||
if test "$$dot_seen" = "no"; then \
|
||||
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
|
||||
fi; test -z "$$fail"
|
||||
|
||||
$(RECURSIVE_CLEAN_TARGETS):
|
||||
@fail= failcom='exit 1'; \
|
||||
for f in x $$MAKEFLAGS; do \
|
||||
case $$f in \
|
||||
*=* | --[!k]*);; \
|
||||
*k*) failcom='fail=yes';; \
|
||||
esac; \
|
||||
done; \
|
||||
dot_seen=no; \
|
||||
case "$@" in \
|
||||
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
|
||||
*) list='$(SUBDIRS)' ;; \
|
||||
esac; \
|
||||
rev=''; for subdir in $$list; do \
|
||||
if test "$$subdir" = "."; then :; else \
|
||||
rev="$$subdir $$rev"; \
|
||||
fi; \
|
||||
done; \
|
||||
rev="$$rev ."; \
|
||||
target=`echo $@ | sed s/-recursive//`; \
|
||||
for subdir in $$rev; do \
|
||||
echo "Making $$target in $$subdir"; \
|
||||
if test "$$subdir" = "."; then \
|
||||
local_target="$$target-am"; \
|
||||
else \
|
||||
local_target="$$target"; \
|
||||
fi; \
|
||||
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|
||||
|| eval $$failcom; \
|
||||
done && test -z "$$fail"
|
||||
tags-recursive:
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
|
||||
done
|
||||
ctags-recursive:
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
|
||||
done
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
|
||||
include_option=--etags-include; \
|
||||
empty_fix=.; \
|
||||
else \
|
||||
include_option=--include; \
|
||||
empty_fix=; \
|
||||
fi; \
|
||||
list='$(SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test ! -f $$subdir/TAGS || \
|
||||
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
|
||||
fi; \
|
||||
done; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
$(am__remove_distdir)
|
||||
test -d "$(distdir)" || mkdir "$(distdir)"
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
test -d "$(distdir)/$$subdir" \
|
||||
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
|
||||
if test "$$subdir" = .; then :; else \
|
||||
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
|
||||
$(am__relativize); \
|
||||
new_distdir=$$reldir; \
|
||||
dir1=$$subdir; dir2="$(top_distdir)"; \
|
||||
$(am__relativize); \
|
||||
new_top_distdir=$$reldir; \
|
||||
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
|
||||
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
|
||||
($(am__cd) $$subdir && \
|
||||
$(MAKE) $(AM_MAKEFLAGS) \
|
||||
top_distdir="$$new_top_distdir" \
|
||||
distdir="$$new_distdir" \
|
||||
am__remove_distdir=: \
|
||||
am__skip_length_check=: \
|
||||
am__skip_mode_fix=: \
|
||||
distdir) \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
-test -n "$(am__skip_mode_fix)" \
|
||||
|| find "$(distdir)" -type d ! -perm -755 \
|
||||
-exec chmod u+rwx,go+rx {} \; -o \
|
||||
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
|
||||
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
|
||||
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|
||||
|| chmod -R a+r "$(distdir)"
|
||||
dist-gzip: distdir
|
||||
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-bzip2: distdir
|
||||
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-lzma: distdir
|
||||
tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-xz: distdir
|
||||
tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-tarZ: distdir
|
||||
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-shar: distdir
|
||||
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist-zip: distdir
|
||||
-rm -f $(distdir).zip
|
||||
zip -rq $(distdir).zip $(distdir)
|
||||
$(am__remove_distdir)
|
||||
|
||||
dist dist-all: distdir
|
||||
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
|
||||
$(am__remove_distdir)
|
||||
|
||||
# This target untars the dist file and tries a VPATH configuration. Then
|
||||
# it guarantees that the distribution is self-contained by making another
|
||||
# tarfile.
|
||||
distcheck: dist
|
||||
case '$(DIST_ARCHIVES)' in \
|
||||
*.tar.gz*) \
|
||||
GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
|
||||
*.tar.bz2*) \
|
||||
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
|
||||
*.tar.lzma*) \
|
||||
lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\
|
||||
*.tar.xz*) \
|
||||
xz -dc $(distdir).tar.xz | $(am__untar) ;;\
|
||||
*.tar.Z*) \
|
||||
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
|
||||
*.shar.gz*) \
|
||||
GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
|
||||
*.zip*) \
|
||||
unzip $(distdir).zip ;;\
|
||||
esac
|
||||
chmod -R a-w $(distdir); chmod a+w $(distdir)
|
||||
mkdir $(distdir)/_build
|
||||
mkdir $(distdir)/_inst
|
||||
chmod a-w $(distdir)
|
||||
test -d $(distdir)/_build || exit 0; \
|
||||
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
|
||||
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
|
||||
&& am__cwd=`pwd` \
|
||||
&& $(am__cd) $(distdir)/_build \
|
||||
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
|
||||
$(DISTCHECK_CONFIGURE_FLAGS) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) check \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) install \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
|
||||
distuninstallcheck \
|
||||
&& chmod -R a-w "$$dc_install_base" \
|
||||
&& ({ \
|
||||
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
|
||||
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
|
||||
} || { rm -rf "$$dc_destdir"; exit 1; }) \
|
||||
&& rm -rf "$$dc_destdir" \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) dist \
|
||||
&& rm -rf $(DIST_ARCHIVES) \
|
||||
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
|
||||
&& cd "$$am__cwd" \
|
||||
|| exit 1
|
||||
$(am__remove_distdir)
|
||||
@(echo "$(distdir) archives ready for distribution: "; \
|
||||
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
|
||||
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
|
||||
distuninstallcheck:
|
||||
@$(am__cd) '$(distuninstallcheck_dir)' \
|
||||
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
|
||||
|| { echo "ERROR: files left after uninstall:" ; \
|
||||
if test -n "$(DESTDIR)"; then \
|
||||
echo " (check DESTDIR support)"; \
|
||||
fi ; \
|
||||
$(distuninstallcheck_listfiles) ; \
|
||||
exit 1; } >&2
|
||||
distcleancheck: distclean
|
||||
@if test '$(srcdir)' = . ; then \
|
||||
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
|
||||
exit 1 ; \
|
||||
fi
|
||||
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|
||||
|| { echo "ERROR: files left in build directory after distclean:" ; \
|
||||
$(distcleancheck_listfiles) ; \
|
||||
exit 1; } >&2
|
||||
check-am: all-am
|
||||
check: check-recursive
|
||||
all-am: Makefile
|
||||
installdirs: installdirs-recursive
|
||||
installdirs-am:
|
||||
install: install-recursive
|
||||
install-exec: install-exec-recursive
|
||||
install-data: install-data-recursive
|
||||
uninstall: uninstall-recursive
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-recursive
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
`test -z '$(STRIP)' || \
|
||||
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-recursive
|
||||
|
||||
clean-am: clean-generic clean-libtool mostlyclean-am
|
||||
|
||||
distclean: distclean-recursive
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-generic distclean-libtool \
|
||||
distclean-tags
|
||||
|
||||
dvi: dvi-recursive
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-recursive
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-recursive
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-dvi: install-dvi-recursive
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am:
|
||||
|
||||
install-html: install-html-recursive
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-recursive
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-recursive
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-recursive
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-recursive
|
||||
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
|
||||
-rm -rf $(top_srcdir)/autom4te.cache
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-recursive
|
||||
|
||||
mostlyclean-am: mostlyclean-generic mostlyclean-libtool
|
||||
|
||||
pdf: pdf-recursive
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-recursive
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am:
|
||||
|
||||
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
|
||||
install-am install-strip tags-recursive
|
||||
|
||||
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
|
||||
all all-am am--refresh check check-am clean clean-generic \
|
||||
clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
|
||||
dist-gzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \
|
||||
distcheck distclean distclean-generic distclean-libtool \
|
||||
distclean-tags distcleancheck distdir distuninstallcheck dvi \
|
||||
dvi-am html html-am info info-am install install-am \
|
||||
install-data install-data-am install-dvi install-dvi-am \
|
||||
install-exec install-exec-am install-html install-html-am \
|
||||
install-info install-info-am install-man install-pdf \
|
||||
install-pdf-am install-ps install-ps-am install-strip \
|
||||
installcheck installcheck-am installdirs installdirs-am \
|
||||
maintainer-clean maintainer-clean-generic mostlyclean \
|
||||
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
|
||||
tags tags-recursive uninstall uninstall-am
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
88
README
Normal file
88
README
Normal file
@ -0,0 +1,88 @@
|
||||
cc-tool provides support of Texas Instruments CC Debugger and
|
||||
some evolution boards to program TI 8051-based System-On-Chip devices
|
||||
|
||||
The software has been tested on SmartRF05 Evaluation Board only
|
||||
(firmware version: 0005, revision 0009 and 0019)
|
||||
Reported corrected working with CC debugegr firmware revision 0025
|
||||
|
||||
In order to work with the board using non-privileged account add this line
|
||||
to udev rules:
|
||||
|
||||
# SmartRF05 Evaluation Board
|
||||
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="16a0", MODE="0666"
|
||||
|
||||
# SmartRF04 Evaluation Board
|
||||
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="11a0", ATTRS{idProduct}=="db20", MODE="0666"
|
||||
|
||||
# CC Debugger
|
||||
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="0451", ATTRS{idProduct}=="16a2", MODE="0666"
|
||||
|
||||
Building from sources was tested on Fedora 13-16, Ubuntu 11.10
|
||||
Packages for building: Ubuntu: libusb-1.0, libboost-all-dev, Fedora: boost-devel, libusb1-devel
|
||||
|
||||
Currently next chips are supported:
|
||||
Supported chips (* - tested):
|
||||
CC2540 CC2530* CC2531* CC2533 CC2430 CC2431 CC2510 CC2511* CC1110 CC1111
|
||||
|
||||
|
||||
Command line options:
|
||||
|
||||
-h, --help
|
||||
produce help message
|
||||
|
||||
-d, --device 'bus_number:device_number'
|
||||
set programmer device usb address. The option is useful if more than one
|
||||
debugger connected to the system simultaneously.
|
||||
|
||||
-f, --fast
|
||||
set fast debug interface speed (by default: slow)
|
||||
|
||||
-i, --read-info-page [file_name]
|
||||
read target info page. If no file-name provided data will be printed to
|
||||
console
|
||||
|
||||
-a, --read-mac-address
|
||||
read target's mac address(es)
|
||||
|
||||
-r, --read file_name
|
||||
read flash memory to the specified file
|
||||
|
||||
-e, --erase
|
||||
erase flash memory completely and reset lock bits
|
||||
|
||||
-w, --write file_name
|
||||
write flash memory. Option can be specified several times to build composite
|
||||
flash image or apply patches
|
||||
|
||||
-v, --verify
|
||||
verify flash after writing
|
||||
|
||||
--reset
|
||||
perform target reset
|
||||
|
||||
-t, --test
|
||||
only search for programmer and target and print various information
|
||||
|
||||
-n, --name target_name
|
||||
specify target name e.g. CC2530 etc. If specified target does not match
|
||||
detected one no operation is performed. Option is not required
|
||||
|
||||
-l, --lock lock_data
|
||||
specify lock data in hex numbers. Lock data size must be exactly
|
||||
1 byte (2 hex digits) or 16 bytes (32 hex digits) depend on target.
|
||||
For several targets lock data can be placed into flash image file
|
||||
|
||||
'file_name' format: [path\]file_name[,[format][,offset]]
|
||||
format can be 'hex' (Intel hex) or 'binary'. Format field can be omitted if file
|
||||
extension is hex or bin. Offset value (in decimal) is an absolute target flash
|
||||
address and is supported only for binary files and only for write operation.
|
||||
|
||||
Examples:
|
||||
|
||||
cc_tool --name cc2530 --write image.hex --write patch.bin,,80
|
||||
cc_tool --read image.bin
|
||||
|
||||
Verification is implemented by calculating crc-16 of 1 Kb flash blocks by means
|
||||
of target itself. After writing is completed target is configured to calculate
|
||||
CRC-16 over own flash and send out results to the cc-tool where it is compared
|
||||
to the input flash image. This method is much faster against read out all flash data.
|
1115
aclocal.m4
vendored
Normal file
1115
aclocal.m4
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1501
config.guess
vendored
Executable file
1501
config.guess
vendored
Executable file
File diff suppressed because it is too large
Load Diff
1705
config.sub
vendored
Executable file
1705
config.sub
vendored
Executable file
File diff suppressed because it is too large
Load Diff
36
configure.ac
Normal file
36
configure.ac
Normal file
@ -0,0 +1,36 @@
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ(2.59)
|
||||
AC_INIT(cc-tool, 0.16, george-u@yandex.com)
|
||||
|
||||
# AC_CANONICAL_SYSTEM
|
||||
AM_INIT_AUTOMAKE(cc-tool, 0.16)
|
||||
|
||||
AC_PROG_LIBTOOL
|
||||
AC_PROG_CXX
|
||||
|
||||
BOOST_REQUIRE([1.34])
|
||||
|
||||
BOOST_FILESYSTEM([mt])
|
||||
BOOST_PROGRAM_OPTIONS([mt])
|
||||
BOOST_SYSTEM([mt])
|
||||
BOOST_REGEX([mt])
|
||||
BOOST_THREADS([mt])
|
||||
|
||||
PKG_CHECK_MODULES([DEPS], [libusb-1.0 >= 1.0.0])
|
||||
|
||||
AC_LANG_PUSH([C++])
|
||||
AC_CHECK_HEADERS( \
|
||||
boost/regex.hpp \
|
||||
boost/foreach.hpp \
|
||||
boost/filesystem.hpp \
|
||||
boost/shared_ptr.hpp \
|
||||
boost/signals2.hpp \
|
||||
boost/crc.hpp \
|
||||
boost/algorithm/string.hpp,
|
||||
[],[AC_MSG_ERROR(You need the Boost libraries.)])
|
||||
AC_LANG_POP([C++])
|
||||
|
||||
AC_CONFIG_FILES(Makefile src/Makefile)
|
||||
AC_OUTPUT
|
||||
|
630
depcomp
Executable file
630
depcomp
Executable file
@ -0,0 +1,630 @@
|
||||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2009-04-28.21; # UTC
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free
|
||||
# Software Foundation, Inc.
|
||||
|
||||
# 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, 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/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Run PROGRAMS ARGS to compile a file, generating dependencies
|
||||
as side-effects.
|
||||
|
||||
Environment variables:
|
||||
depmode Dependency tracking mode.
|
||||
source Source file read by `PROGRAMS ARGS'.
|
||||
object Object file output by `PROGRAMS ARGS'.
|
||||
DEPDIR directory where to store dependencies.
|
||||
depfile Dependency file to output.
|
||||
tmpdepfile Temporary file to use when outputing dependencies.
|
||||
libtool Whether libtool is used (yes/no).
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "depcomp $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
||||
echo "depcomp: Variables source, object and depmode must be set" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
|
||||
depfile=${depfile-`echo "$object" |
|
||||
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
|
||||
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||
|
||||
rm -f "$tmpdepfile"
|
||||
|
||||
# Some modes work just like other modes, but use different flags. We
|
||||
# parameterize here, but still list the modes in the big case below,
|
||||
# to make depend.m4 easier to write. Note that we *cannot* use a case
|
||||
# here, because this file can only contain one case statement.
|
||||
if test "$depmode" = hp; then
|
||||
# HP compiler uses -M and no extra arg.
|
||||
gccflag=-M
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
if test "$depmode" = dashXmstdout; then
|
||||
# This is just like dashmstdout with a different argument.
|
||||
dashmflag=-xM
|
||||
depmode=dashmstdout
|
||||
fi
|
||||
|
||||
cygpath_u="cygpath -u -f -"
|
||||
if test "$depmode" = msvcmsys; then
|
||||
# This is just like msvisualcpp but w/o cygpath translation.
|
||||
# Just convert the backslash-escaped backslashes to single forward
|
||||
# slashes to satisfy depend.m4
|
||||
cygpath_u="sed s,\\\\\\\\,/,g"
|
||||
depmode=msvisualcpp
|
||||
fi
|
||||
|
||||
case "$depmode" in
|
||||
gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
|
||||
## the command line argument order; so add the flags where they
|
||||
## appear in depend2.am. Note that the slowdown incurred here
|
||||
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
|
||||
*) set fnord "$@" "$arg" ;;
|
||||
esac
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
done
|
||||
"$@"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
mv "$tmpdepfile" "$depfile"
|
||||
;;
|
||||
|
||||
gcc)
|
||||
## There are various ways to get dependency output from gcc. Here's
|
||||
## why we pick this rather obscure method:
|
||||
## - Don't want to use -MD because we'd like the dependencies to end
|
||||
## up in a subdir. Having to rename by hand is ugly.
|
||||
## (We might end up doing this anyway to support other compilers.)
|
||||
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
|
||||
## -MM, not -M (despite what the docs say).
|
||||
## - Using -M directly means running the compiler twice (even worse
|
||||
## than renaming).
|
||||
if test -z "$gccflag"; then
|
||||
gccflag=-MD,
|
||||
fi
|
||||
"$@" -Wp,"$gccflag$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
||||
## The second -e expression handles DOS-style file names with drive letters.
|
||||
sed -e 's/^[^:]*: / /' \
|
||||
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
|
||||
## This next piece of magic avoids the `deleted header file' problem.
|
||||
## The problem is that when a header file which appears in a .P file
|
||||
## is deleted, the dependency causes make to die (because there is
|
||||
## typically no way to rebuild the header). We avoid this by adding
|
||||
## dummy dependencies for each header file. Too bad gcc doesn't do
|
||||
## this for us directly.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" |
|
||||
## Some versions of gcc put a space before the `:'. On the theory
|
||||
## that the space means something, we add a space to the output as
|
||||
## well.
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
sgi)
|
||||
if test "$libtool" = yes; then
|
||||
"$@" "-Wp,-MDupdate,$tmpdepfile"
|
||||
else
|
||||
"$@" -MDupdate "$tmpdepfile"
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
|
||||
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
|
||||
echo "$object : \\" > "$depfile"
|
||||
|
||||
# Clip off the initial element (the dependent). Don't try to be
|
||||
# clever and replace this with sed code, as IRIX sed won't handle
|
||||
# lines with more than a fixed number of characters (4096 in
|
||||
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
|
||||
# the IRIX cc adds comments like `#:fec' to the end of the
|
||||
# dependency line.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
|
||||
tr '
|
||||
' ' ' >> "$depfile"
|
||||
echo >> "$depfile"
|
||||
|
||||
# The second pass generates a dummy entry for each header file.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
aix)
|
||||
# The C for AIX Compiler uses -M and outputs the dependencies
|
||||
# in a .u file. In older versions, this file always lives in the
|
||||
# current directory. Also, the AIX compiler puts `$object:' at the
|
||||
# start of each line; $object doesn't have directory information.
|
||||
# Version 6 uses the directory in both cases.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$base.u
|
||||
tmpdepfile3=$dir.libs/$base.u
|
||||
"$@" -Wc,-M
|
||||
else
|
||||
tmpdepfile1=$dir$base.u
|
||||
tmpdepfile2=$dir$base.u
|
||||
tmpdepfile3=$dir$base.u
|
||||
"$@" -M
|
||||
fi
|
||||
stat=$?
|
||||
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
# Each line is of the form `foo.o: dependent.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||
# That's a tab and a space in the [].
|
||||
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
icc)
|
||||
# Intel's C compiler understands `-MD -MF file'. However on
|
||||
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
|
||||
# ICC 7.0 will fill foo.d with something like
|
||||
# foo.o: sub/foo.c
|
||||
# foo.o: sub/foo.h
|
||||
# which is wrong. We want:
|
||||
# sub/foo.o: sub/foo.c
|
||||
# sub/foo.o: sub/foo.h
|
||||
# sub/foo.c:
|
||||
# sub/foo.h:
|
||||
# ICC 7.1 will output
|
||||
# foo.o: sub/foo.c sub/foo.h
|
||||
# and will wrap long lines using \ :
|
||||
# foo.o: sub/foo.c ... \
|
||||
# sub/foo.h ... \
|
||||
# ...
|
||||
|
||||
"$@" -MD -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each line is of the form `foo.o: dependent.h',
|
||||
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
|
||||
sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp2)
|
||||
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
|
||||
# compilers, which have integrated preprocessors. The correct option
|
||||
# to use with these is +Maked; it writes dependencies to a file named
|
||||
# 'foo.d', which lands next to the object file, wherever that
|
||||
# happens to be.
|
||||
# Much of this is similar to the tru64 case; see comments there.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
if test "$libtool" = yes; then
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir.libs/$base.d
|
||||
"$@" -Wc,+Maked
|
||||
else
|
||||
tmpdepfile1=$dir$base.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
"$@" +Maked
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
|
||||
# Add `dependent.h:' lines.
|
||||
sed -ne '2,${
|
||||
s/^ *//
|
||||
s/ \\*$//
|
||||
s/$/:/
|
||||
p
|
||||
}' "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile" "$tmpdepfile2"
|
||||
;;
|
||||
|
||||
tru64)
|
||||
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
|
||||
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||
# dependencies in `foo.d' instead, so we check for that too.
|
||||
# Subdirectories are respected.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
|
||||
if test "$libtool" = yes; then
|
||||
# With Tru64 cc, shared objects can also be used to make a
|
||||
# static library. This mechanism is used in libtool 1.4 series to
|
||||
# handle both shared and static libraries in a single compilation.
|
||||
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
|
||||
#
|
||||
# With libtool 1.5 this exception was removed, and libtool now
|
||||
# generates 2 separate objects for the 2 libraries. These two
|
||||
# compilations output dependencies in $dir.libs/$base.o.d and
|
||||
# in $dir$base.o.d. We have to check for both files, because
|
||||
# one of the two compilations can be disabled. We should prefer
|
||||
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
|
||||
# automatically cleaned when .libs/ is deleted, while ignoring
|
||||
# the former would cause a distcleancheck panic.
|
||||
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
|
||||
tmpdepfile2=$dir$base.o.d # libtool 1.5
|
||||
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
|
||||
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1=$dir$base.o.d
|
||||
tmpdepfile2=$dir$base.d
|
||||
tmpdepfile3=$dir$base.d
|
||||
tmpdepfile4=$dir$base.d
|
||||
"$@" -MD
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
|
||||
do
|
||||
test -f "$tmpdepfile" && break
|
||||
done
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||
# That's a tab and a space in the [].
|
||||
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
#nosideeffect)
|
||||
# This comment above is used by automake to tell side-effect
|
||||
# dependency tracking mechanisms from slower ones.
|
||||
|
||||
dashmstdout)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
# Require at least two characters before searching for `:'
|
||||
# in the target name. This is to cope with DOS-style filenames:
|
||||
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
|
||||
"$@" $dashmflag |
|
||||
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
dashXmstdout)
|
||||
# This case only exists to satisfy depend.m4. It is never actually
|
||||
# run, as this mode is specially recognized in the preamble.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
makedepend)
|
||||
"$@" || exit $?
|
||||
# Remove any Libtool call
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
# X makedepend
|
||||
shift
|
||||
cleared=no eat=no
|
||||
for arg
|
||||
do
|
||||
case $cleared in
|
||||
no)
|
||||
set ""; shift
|
||||
cleared=yes ;;
|
||||
esac
|
||||
if test $eat = yes; then
|
||||
eat=no
|
||||
continue
|
||||
fi
|
||||
case "$arg" in
|
||||
-D*|-I*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
# Strip any option that makedepend may not understand. Remove
|
||||
# the object too, otherwise makedepend will parse it as a source file.
|
||||
-arch)
|
||||
eat=yes ;;
|
||||
-*|$object)
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
esac
|
||||
done
|
||||
obj_suffix=`echo "$object" | sed 's/^.*\././'`
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
sed '1,2d' "$tmpdepfile" | tr ' ' '
|
||||
' | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile" "$tmpdepfile".bak
|
||||
;;
|
||||
|
||||
cpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
"$@" -E |
|
||||
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
|
||||
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
|
||||
sed '$ s: \\$::' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
cat < "$tmpdepfile" >> "$depfile"
|
||||
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvisualcpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test "X$1" != 'X--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
set fnord "$@"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
"$@" -E 2>/dev/null |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
|
||||
echo " " >> "$depfile"
|
||||
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvcmsys)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
none)
|
||||
exec "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown depmode $depmode" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
BIN
docs/chip table.odt
Normal file
BIN
docs/chip table.odt
Normal file
Binary file not shown.
520
install-sh
Executable file
520
install-sh
Executable file
@ -0,0 +1,520 @@
|
||||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2009-04-28.21; # UTC
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
# following copyright and license.
|
||||
#
|
||||
# Copyright (C) 1994 X Consortium
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the X Consortium shall not
|
||||
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||
# ings in this Software without prior written authorization from the X Consor-
|
||||
# tium.
|
||||
#
|
||||
#
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
|
||||
nl='
|
||||
'
|
||||
IFS=" "" $nl"
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit=${DOITPROG-}
|
||||
if test -z "$doit"; then
|
||||
doit_exec=exec
|
||||
else
|
||||
doit_exec=$doit
|
||||
fi
|
||||
|
||||
# Put in absolute file names if you don't have them in your path;
|
||||
# or use environment vars.
|
||||
|
||||
chgrpprog=${CHGRPPROG-chgrp}
|
||||
chmodprog=${CHMODPROG-chmod}
|
||||
chownprog=${CHOWNPROG-chown}
|
||||
cmpprog=${CMPPROG-cmp}
|
||||
cpprog=${CPPROG-cp}
|
||||
mkdirprog=${MKDIRPROG-mkdir}
|
||||
mvprog=${MVPROG-mv}
|
||||
rmprog=${RMPROG-rm}
|
||||
stripprog=${STRIPPROG-strip}
|
||||
|
||||
posix_glob='?'
|
||||
initialize_posix_glob='
|
||||
test "$posix_glob" != "?" || {
|
||||
if (set -f) 2>/dev/null; then
|
||||
posix_glob=
|
||||
else
|
||||
posix_glob=:
|
||||
fi
|
||||
}
|
||||
'
|
||||
|
||||
posix_mkdir=
|
||||
|
||||
# Desired mode of installed file.
|
||||
mode=0755
|
||||
|
||||
chgrpcmd=
|
||||
chmodcmd=$chmodprog
|
||||
chowncmd=
|
||||
mvcmd=$mvprog
|
||||
rmcmd="$rmprog -f"
|
||||
stripcmd=
|
||||
|
||||
src=
|
||||
dst=
|
||||
dir_arg=
|
||||
dst_arg=
|
||||
|
||||
copy_on_change=false
|
||||
no_target_directory=
|
||||
|
||||
usage="\
|
||||
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||
or: $0 [OPTION]... -d DIRECTORIES...
|
||||
|
||||
In the 1st form, copy SRCFILE to DSTFILE.
|
||||
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||
In the 4th, create DIRECTORIES.
|
||||
|
||||
Options:
|
||||
--help display this help and exit.
|
||||
--version display version info and exit.
|
||||
|
||||
-c (ignored)
|
||||
-C install only if different (preserve the last data modification time)
|
||||
-d create directories instead of installing files.
|
||||
-g GROUP $chgrpprog installed files to GROUP.
|
||||
-m MODE $chmodprog installed files to MODE.
|
||||
-o USER $chownprog installed files to USER.
|
||||
-s $stripprog installed files.
|
||||
-t DIRECTORY install into DIRECTORY.
|
||||
-T report an error if DSTFILE is a directory.
|
||||
|
||||
Environment variables override the default commands:
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
|
||||
RMPROG STRIPPROG
|
||||
"
|
||||
|
||||
while test $# -ne 0; do
|
||||
case $1 in
|
||||
-c) ;;
|
||||
|
||||
-C) copy_on_change=true;;
|
||||
|
||||
-d) dir_arg=true;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift;;
|
||||
|
||||
--help) echo "$usage"; exit $?;;
|
||||
|
||||
-m) mode=$2
|
||||
case $mode in
|
||||
*' '* | *' '* | *'
|
||||
'* | *'*'* | *'?'* | *'['*)
|
||||
echo "$0: invalid mode: $mode" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift;;
|
||||
|
||||
-s) stripcmd=$stripprog;;
|
||||
|
||||
-t) dst_arg=$2
|
||||
shift;;
|
||||
|
||||
-T) no_target_directory=true;;
|
||||
|
||||
--version) echo "$0 $scriptversion"; exit $?;;
|
||||
|
||||
--) shift
|
||||
break;;
|
||||
|
||||
-*) echo "$0: invalid option: $1" >&2
|
||||
exit 1;;
|
||||
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
||||
# When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dst_arg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dst_arg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dst_arg=$arg
|
||||
done
|
||||
fi
|
||||
|
||||
if test $# -eq 0; then
|
||||
if test -z "$dir_arg"; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
# It's OK to call `install-sh -d' without argument.
|
||||
# This can happen when creating conditional directories.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
trap '(exit $?); exit' 1 2 13 15
|
||||
|
||||
# Set umask so as not to create temps with too-generous modes.
|
||||
# However, 'strip' requires both read and write access to temps.
|
||||
case $mode in
|
||||
# Optimize common cases.
|
||||
*644) cp_umask=133;;
|
||||
*755) cp_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw='% 200'
|
||||
fi
|
||||
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
|
||||
*)
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw=,u+rw
|
||||
fi
|
||||
cp_umask=$mode$u_plus_rw;;
|
||||
esac
|
||||
fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names starting with `-'.
|
||||
case $src in
|
||||
-*) src=./$src;;
|
||||
esac
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
dst=$src
|
||||
dstdir=$dst
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
if test ! -f "$src" && test ! -d "$src"; then
|
||||
echo "$0: $src does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$dst_arg"; then
|
||||
echo "$0: no destination specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dst=$dst_arg
|
||||
# Protect names starting with `-'.
|
||||
case $dst in
|
||||
-*) dst=./$dst;;
|
||||
esac
|
||||
|
||||
# If destination is a directory, append the input filename; won't work
|
||||
# if double slashes aren't ignored.
|
||||
if test -d "$dst"; then
|
||||
if test -n "$no_target_directory"; then
|
||||
echo "$0: $dst_arg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dstdir=$dst
|
||||
dst=$dstdir/`basename "$src"`
|
||||
dstdir_status=0
|
||||
else
|
||||
# Prefer dirname, but fall back on a substitute if dirname fails.
|
||||
dstdir=`
|
||||
(dirname "$dst") 2>/dev/null ||
|
||||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
|
||||
X"$dst" : 'X\(//\)[^/]' \| \
|
||||
X"$dst" : 'X\(//\)$' \| \
|
||||
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
|
||||
echo X"$dst" |
|
||||
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)[^/].*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\).*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
s/.*/./; q'
|
||||
`
|
||||
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
obsolete_mkdir_used=false
|
||||
|
||||
if test $dstdir_status != 0; then
|
||||
case $posix_mkdir in
|
||||
'')
|
||||
# Create intermediate dirs using mode 755 as modified by the umask.
|
||||
# This is like FreeBSD 'install' as of 1997-10-28.
|
||||
umask=`umask`
|
||||
case $stripcmd.$umask in
|
||||
# Optimize common cases.
|
||||
*[2367][2367]) mkdir_umask=$umask;;
|
||||
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
mkdir_umask=`expr $umask + 22 \
|
||||
- $umask % 100 % 40 + $umask % 20 \
|
||||
- $umask % 10 % 4 + $umask % 2
|
||||
`;;
|
||||
*) mkdir_umask=$umask,go-w;;
|
||||
esac
|
||||
|
||||
# With -d, create the new directory with the user-specified mode.
|
||||
# Otherwise, rely on $mkdir_umask.
|
||||
if test -n "$dir_arg"; then
|
||||
mkdir_mode=-m$mode
|
||||
else
|
||||
mkdir_mode=
|
||||
fi
|
||||
|
||||
posix_mkdir=false
|
||||
case $umask in
|
||||
*[123567][0-7][0-7])
|
||||
# POSIX mkdir -p sets u+wx bits regardless of umask, which
|
||||
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
|
||||
;;
|
||||
*)
|
||||
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
||||
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
|
||||
|
||||
if (umask $mkdir_umask &&
|
||||
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
|
||||
then
|
||||
if test -z "$dir_arg" || {
|
||||
# Check for POSIX incompatibilities with -m.
|
||||
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
||||
# other-writeable bit of parent directory when it shouldn't.
|
||||
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
||||
ls_ld_tmpdir=`ls -ld "$tmpdir"`
|
||||
case $ls_ld_tmpdir in
|
||||
d????-?r-*) different_mode=700;;
|
||||
d????-?--*) different_mode=755;;
|
||||
*) false;;
|
||||
esac &&
|
||||
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
|
||||
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
|
||||
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
||||
}
|
||||
}
|
||||
then posix_mkdir=:
|
||||
fi
|
||||
rmdir "$tmpdir/d" "$tmpdir"
|
||||
else
|
||||
# Remove any dirs left behind by ancient mkdir implementations.
|
||||
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
|
||||
fi
|
||||
trap '' 0;;
|
||||
esac;;
|
||||
esac
|
||||
|
||||
if
|
||||
$posix_mkdir && (
|
||||
umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
|
||||
)
|
||||
then :
|
||||
else
|
||||
|
||||
# The umask is ridiculous, or mkdir does not conform to POSIX,
|
||||
# or it failed possibly due to a race condition. Create the
|
||||
# directory the slow way, step by step, checking for races as we go.
|
||||
|
||||
case $dstdir in
|
||||
/*) prefix='/';;
|
||||
-*) prefix='./';;
|
||||
*) prefix='';;
|
||||
esac
|
||||
|
||||
eval "$initialize_posix_glob"
|
||||
|
||||
oIFS=$IFS
|
||||
IFS=/
|
||||
$posix_glob set -f
|
||||
set fnord $dstdir
|
||||
shift
|
||||
$posix_glob set +f
|
||||
IFS=$oIFS
|
||||
|
||||
prefixes=
|
||||
|
||||
for d
|
||||
do
|
||||
test -z "$d" && continue
|
||||
|
||||
prefix=$prefix$d
|
||||
if test -d "$prefix"; then
|
||||
prefixes=
|
||||
else
|
||||
if $posix_mkdir; then
|
||||
(umask=$mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
|
||||
# Don't fail if two instances are running concurrently.
|
||||
test -d "$prefix" || exit 1
|
||||
else
|
||||
case $prefix in
|
||||
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
|
||||
*) qprefix=$prefix;;
|
||||
esac
|
||||
prefixes="$prefixes '$qprefix'"
|
||||
fi
|
||||
fi
|
||||
prefix=$prefix/
|
||||
done
|
||||
|
||||
if test -n "$prefixes"; then
|
||||
# Don't fail if two instances are running concurrently.
|
||||
(umask $mkdir_umask &&
|
||||
eval "\$doit_exec \$mkdirprog $prefixes") ||
|
||||
test -d "$dstdir" || exit 1
|
||||
obsolete_mkdir_used=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
|
||||
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
|
||||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
|
||||
else
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=$dstdir/_inst.$$_
|
||||
rmtmp=$dstdir/_rm.$$_
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
|
||||
# Copy the file name to the temp name.
|
||||
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits.
|
||||
#
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
||||
#
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
|
||||
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
|
||||
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
|
||||
|
||||
# If -C, don't bother to copy if it wouldn't change the file.
|
||||
if $copy_on_change &&
|
||||
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
|
||||
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
|
||||
|
||||
eval "$initialize_posix_glob" &&
|
||||
$posix_glob set -f &&
|
||||
set X $old && old=:$2:$4:$5:$6 &&
|
||||
set X $new && new=:$2:$4:$5:$6 &&
|
||||
$posix_glob set +f &&
|
||||
|
||||
test "$old" = "$new" &&
|
||||
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
|
||||
then
|
||||
rm -f "$dsttmp"
|
||||
else
|
||||
# Rename the file to the real destination.
|
||||
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
|
||||
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
# support -f.
|
||||
{
|
||||
# Now remove or move aside any old file at destination location.
|
||||
# We try this two ways since rm can't unlink itself on some
|
||||
# systems and the destination file might be busy for other
|
||||
# reasons. In this case, the final cleanup might fail but the new
|
||||
# file should still install successfully.
|
||||
{
|
||||
test ! -f "$dst" ||
|
||||
$doit $rmcmd -f "$dst" 2>/dev/null ||
|
||||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
|
||||
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
|
||||
} ||
|
||||
{ echo "$0: cannot unlink or rename $dst" >&2
|
||||
(exit 1); exit 1
|
||||
}
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dst"
|
||||
}
|
||||
fi || exit 1
|
||||
|
||||
trap '' 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
1096
m4/boost.m4
Normal file
1096
m4/boost.m4
Normal file
File diff suppressed because it is too large
Load Diff
7441
m4/libtool.m4
vendored
Normal file
7441
m4/libtool.m4
vendored
Normal file
File diff suppressed because it is too large
Load Diff
369
m4/ltoptions.m4
vendored
Normal file
369
m4/ltoptions.m4
vendored
Normal file
@ -0,0 +1,369 @@
|
||||
# Helper functions for option handling. -*- Autoconf -*-
|
||||
#
|
||||
# Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
|
||||
# Inc.
|
||||
# Written by Gary V. Vaughan, 2004
|
||||
#
|
||||
# This file is free software; the Free Software Foundation gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 7 ltoptions.m4
|
||||
|
||||
# This is to help aclocal find these macros, as it can't see m4_define.
|
||||
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
|
||||
|
||||
|
||||
# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
|
||||
# ------------------------------------------
|
||||
m4_define([_LT_MANGLE_OPTION],
|
||||
[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
|
||||
|
||||
|
||||
# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
|
||||
# ---------------------------------------
|
||||
# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
|
||||
# matching handler defined, dispatch to it. Other OPTION-NAMEs are
|
||||
# saved as a flag.
|
||||
m4_define([_LT_SET_OPTION],
|
||||
[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
|
||||
m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
|
||||
_LT_MANGLE_DEFUN([$1], [$2]),
|
||||
[m4_warning([Unknown $1 option `$2'])])[]dnl
|
||||
])
|
||||
|
||||
|
||||
# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
|
||||
# ------------------------------------------------------------
|
||||
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
|
||||
m4_define([_LT_IF_OPTION],
|
||||
[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
|
||||
|
||||
|
||||
# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
|
||||
# -------------------------------------------------------
|
||||
# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
|
||||
# are set.
|
||||
m4_define([_LT_UNLESS_OPTIONS],
|
||||
[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
|
||||
[m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
|
||||
[m4_define([$0_found])])])[]dnl
|
||||
m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
|
||||
])[]dnl
|
||||
])
|
||||
|
||||
|
||||
# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
|
||||
# ----------------------------------------
|
||||
# OPTION-LIST is a space-separated list of Libtool options associated
|
||||
# with MACRO-NAME. If any OPTION has a matching handler declared with
|
||||
# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
|
||||
# the unknown option and exit.
|
||||
m4_defun([_LT_SET_OPTIONS],
|
||||
[# Set options
|
||||
m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
|
||||
[_LT_SET_OPTION([$1], _LT_Option)])
|
||||
|
||||
m4_if([$1],[LT_INIT],[
|
||||
dnl
|
||||
dnl Simply set some default values (i.e off) if boolean options were not
|
||||
dnl specified:
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
|
||||
])
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
|
||||
])
|
||||
dnl
|
||||
dnl If no reference was made to various pairs of opposing options, then
|
||||
dnl we run the default mode handler for the pair. For example, if neither
|
||||
dnl `shared' nor `disable-shared' was passed, we enable building of shared
|
||||
dnl archives by default:
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
|
||||
_LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
|
||||
[_LT_ENABLE_FAST_INSTALL])
|
||||
])
|
||||
])# _LT_SET_OPTIONS
|
||||
|
||||
|
||||
## --------------------------------- ##
|
||||
## Macros to handle LT_INIT options. ##
|
||||
## --------------------------------- ##
|
||||
|
||||
# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
|
||||
# -----------------------------------------
|
||||
m4_define([_LT_MANGLE_DEFUN],
|
||||
[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
|
||||
|
||||
|
||||
# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
|
||||
# -----------------------------------------------
|
||||
m4_define([LT_OPTION_DEFINE],
|
||||
[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
|
||||
])# LT_OPTION_DEFINE
|
||||
|
||||
|
||||
# dlopen
|
||||
# ------
|
||||
LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
|
||||
])
|
||||
|
||||
AU_DEFUN([AC_LIBTOOL_DLOPEN],
|
||||
[_LT_SET_OPTION([LT_INIT], [dlopen])
|
||||
AC_DIAGNOSE([obsolete],
|
||||
[$0: Remove this warning and the call to _LT_SET_OPTION when you
|
||||
put the `dlopen' option into LT_INIT's first parameter.])
|
||||
])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
|
||||
|
||||
|
||||
# win32-dll
|
||||
# ---------
|
||||
# Declare package support for building win32 dll's.
|
||||
LT_OPTION_DEFINE([LT_INIT], [win32-dll],
|
||||
[enable_win32_dll=yes
|
||||
|
||||
case $host in
|
||||
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
|
||||
AC_CHECK_TOOL(AS, as, false)
|
||||
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
|
||||
AC_CHECK_TOOL(OBJDUMP, objdump, false)
|
||||
;;
|
||||
esac
|
||||
|
||||
test -z "$AS" && AS=as
|
||||
_LT_DECL([], [AS], [1], [Assembler program])dnl
|
||||
|
||||
test -z "$DLLTOOL" && DLLTOOL=dlltool
|
||||
_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
|
||||
|
||||
test -z "$OBJDUMP" && OBJDUMP=objdump
|
||||
_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
|
||||
])# win32-dll
|
||||
|
||||
AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
|
||||
[AC_REQUIRE([AC_CANONICAL_HOST])dnl
|
||||
_LT_SET_OPTION([LT_INIT], [win32-dll])
|
||||
AC_DIAGNOSE([obsolete],
|
||||
[$0: Remove this warning and the call to _LT_SET_OPTION when you
|
||||
put the `win32-dll' option into LT_INIT's first parameter.])
|
||||
])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
|
||||
|
||||
|
||||
# _LT_ENABLE_SHARED([DEFAULT])
|
||||
# ----------------------------
|
||||
# implement the --enable-shared flag, and supports the `shared' and
|
||||
# `disable-shared' LT_INIT options.
|
||||
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
|
||||
m4_define([_LT_ENABLE_SHARED],
|
||||
[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
|
||||
AC_ARG_ENABLE([shared],
|
||||
[AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
|
||||
[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
|
||||
[p=${PACKAGE-default}
|
||||
case $enableval in
|
||||
yes) enable_shared=yes ;;
|
||||
no) enable_shared=no ;;
|
||||
*)
|
||||
enable_shared=no
|
||||
# Look at the argument we got. We use all the common list separators.
|
||||
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
|
||||
for pkg in $enableval; do
|
||||
IFS="$lt_save_ifs"
|
||||
if test "X$pkg" = "X$p"; then
|
||||
enable_shared=yes
|
||||
fi
|
||||
done
|
||||
IFS="$lt_save_ifs"
|
||||
;;
|
||||
esac],
|
||||
[enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
|
||||
|
||||
_LT_DECL([build_libtool_libs], [enable_shared], [0],
|
||||
[Whether or not to build shared libraries])
|
||||
])# _LT_ENABLE_SHARED
|
||||
|
||||
LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
|
||||
LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
|
||||
|
||||
# Old names:
|
||||
AC_DEFUN([AC_ENABLE_SHARED],
|
||||
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
|
||||
])
|
||||
|
||||
AC_DEFUN([AC_DISABLE_SHARED],
|
||||
[_LT_SET_OPTION([LT_INIT], [disable-shared])
|
||||
])
|
||||
|
||||
AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
|
||||
AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
dnl AC_DEFUN([AM_ENABLE_SHARED], [])
|
||||
dnl AC_DEFUN([AM_DISABLE_SHARED], [])
|
||||
|
||||
|
||||
|
||||
# _LT_ENABLE_STATIC([DEFAULT])
|
||||
# ----------------------------
|
||||
# implement the --enable-static flag, and support the `static' and
|
||||
# `disable-static' LT_INIT options.
|
||||
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
|
||||
m4_define([_LT_ENABLE_STATIC],
|
||||
[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
|
||||
AC_ARG_ENABLE([static],
|
||||
[AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
|
||||
[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
|
||||
[p=${PACKAGE-default}
|
||||
case $enableval in
|
||||
yes) enable_static=yes ;;
|
||||
no) enable_static=no ;;
|
||||
*)
|
||||
enable_static=no
|
||||
# Look at the argument we got. We use all the common list separators.
|
||||
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
|
||||
for pkg in $enableval; do
|
||||
IFS="$lt_save_ifs"
|
||||
if test "X$pkg" = "X$p"; then
|
||||
enable_static=yes
|
||||
fi
|
||||
done
|
||||
IFS="$lt_save_ifs"
|
||||
;;
|
||||
esac],
|
||||
[enable_static=]_LT_ENABLE_STATIC_DEFAULT)
|
||||
|
||||
_LT_DECL([build_old_libs], [enable_static], [0],
|
||||
[Whether or not to build static libraries])
|
||||
])# _LT_ENABLE_STATIC
|
||||
|
||||
LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
|
||||
LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
|
||||
|
||||
# Old names:
|
||||
AC_DEFUN([AC_ENABLE_STATIC],
|
||||
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
|
||||
])
|
||||
|
||||
AC_DEFUN([AC_DISABLE_STATIC],
|
||||
[_LT_SET_OPTION([LT_INIT], [disable-static])
|
||||
])
|
||||
|
||||
AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
|
||||
AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
dnl AC_DEFUN([AM_ENABLE_STATIC], [])
|
||||
dnl AC_DEFUN([AM_DISABLE_STATIC], [])
|
||||
|
||||
|
||||
|
||||
# _LT_ENABLE_FAST_INSTALL([DEFAULT])
|
||||
# ----------------------------------
|
||||
# implement the --enable-fast-install flag, and support the `fast-install'
|
||||
# and `disable-fast-install' LT_INIT options.
|
||||
# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
|
||||
m4_define([_LT_ENABLE_FAST_INSTALL],
|
||||
[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
|
||||
AC_ARG_ENABLE([fast-install],
|
||||
[AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
|
||||
[optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
|
||||
[p=${PACKAGE-default}
|
||||
case $enableval in
|
||||
yes) enable_fast_install=yes ;;
|
||||
no) enable_fast_install=no ;;
|
||||
*)
|
||||
enable_fast_install=no
|
||||
# Look at the argument we got. We use all the common list separators.
|
||||
lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
|
||||
for pkg in $enableval; do
|
||||
IFS="$lt_save_ifs"
|
||||
if test "X$pkg" = "X$p"; then
|
||||
enable_fast_install=yes
|
||||
fi
|
||||
done
|
||||
IFS="$lt_save_ifs"
|
||||
;;
|
||||
esac],
|
||||
[enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
|
||||
|
||||
_LT_DECL([fast_install], [enable_fast_install], [0],
|
||||
[Whether or not to optimize for fast installation])dnl
|
||||
])# _LT_ENABLE_FAST_INSTALL
|
||||
|
||||
LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
|
||||
LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
|
||||
|
||||
# Old names:
|
||||
AU_DEFUN([AC_ENABLE_FAST_INSTALL],
|
||||
[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
|
||||
AC_DIAGNOSE([obsolete],
|
||||
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
|
||||
the `fast-install' option into LT_INIT's first parameter.])
|
||||
])
|
||||
|
||||
AU_DEFUN([AC_DISABLE_FAST_INSTALL],
|
||||
[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
|
||||
AC_DIAGNOSE([obsolete],
|
||||
[$0: Remove this warning and the call to _LT_SET_OPTION when you put
|
||||
the `disable-fast-install' option into LT_INIT's first parameter.])
|
||||
])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
|
||||
dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
|
||||
|
||||
|
||||
# _LT_WITH_PIC([MODE])
|
||||
# --------------------
|
||||
# implement the --with-pic flag, and support the `pic-only' and `no-pic'
|
||||
# LT_INIT options.
|
||||
# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
|
||||
m4_define([_LT_WITH_PIC],
|
||||
[AC_ARG_WITH([pic],
|
||||
[AS_HELP_STRING([--with-pic],
|
||||
[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
|
||||
[pic_mode="$withval"],
|
||||
[pic_mode=default])
|
||||
|
||||
test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
|
||||
|
||||
_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
|
||||
])# _LT_WITH_PIC
|
||||
|
||||
LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
|
||||
LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
|
||||
|
||||
# Old name:
|
||||
AU_DEFUN([AC_LIBTOOL_PICMODE],
|
||||
[_LT_SET_OPTION([LT_INIT], [pic-only])
|
||||
AC_DIAGNOSE([obsolete],
|
||||
[$0: Remove this warning and the call to _LT_SET_OPTION when you
|
||||
put the `pic-only' option into LT_INIT's first parameter.])
|
||||
])
|
||||
|
||||
dnl aclocal-1.4 backwards compatibility:
|
||||
dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
|
||||
|
||||
## ----------------- ##
|
||||
## LTDL_INIT Options ##
|
||||
## ----------------- ##
|
||||
|
||||
m4_define([_LTDL_MODE], [])
|
||||
LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
|
||||
[m4_define([_LTDL_MODE], [nonrecursive])])
|
||||
LT_OPTION_DEFINE([LTDL_INIT], [recursive],
|
||||
[m4_define([_LTDL_MODE], [recursive])])
|
||||
LT_OPTION_DEFINE([LTDL_INIT], [subproject],
|
||||
[m4_define([_LTDL_MODE], [subproject])])
|
||||
|
||||
m4_define([_LTDL_TYPE], [])
|
||||
LT_OPTION_DEFINE([LTDL_INIT], [installable],
|
||||
[m4_define([_LTDL_TYPE], [installable])])
|
||||
LT_OPTION_DEFINE([LTDL_INIT], [convenience],
|
||||
[m4_define([_LTDL_TYPE], [convenience])])
|
123
m4/ltsugar.m4
vendored
Normal file
123
m4/ltsugar.m4
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
|
||||
#
|
||||
# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
|
||||
# Written by Gary V. Vaughan, 2004
|
||||
#
|
||||
# This file is free software; the Free Software Foundation gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 6 ltsugar.m4
|
||||
|
||||
# This is to help aclocal find these macros, as it can't see m4_define.
|
||||
AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
|
||||
|
||||
|
||||
# lt_join(SEP, ARG1, [ARG2...])
|
||||
# -----------------------------
|
||||
# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
|
||||
# associated separator.
|
||||
# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
|
||||
# versions in m4sugar had bugs.
|
||||
m4_define([lt_join],
|
||||
[m4_if([$#], [1], [],
|
||||
[$#], [2], [[$2]],
|
||||
[m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
|
||||
m4_define([_lt_join],
|
||||
[m4_if([$#$2], [2], [],
|
||||
[m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
|
||||
|
||||
|
||||
# lt_car(LIST)
|
||||
# lt_cdr(LIST)
|
||||
# ------------
|
||||
# Manipulate m4 lists.
|
||||
# These macros are necessary as long as will still need to support
|
||||
# Autoconf-2.59 which quotes differently.
|
||||
m4_define([lt_car], [[$1]])
|
||||
m4_define([lt_cdr],
|
||||
[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
|
||||
[$#], 1, [],
|
||||
[m4_dquote(m4_shift($@))])])
|
||||
m4_define([lt_unquote], $1)
|
||||
|
||||
|
||||
# lt_append(MACRO-NAME, STRING, [SEPARATOR])
|
||||
# ------------------------------------------
|
||||
# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
|
||||
# Note that neither SEPARATOR nor STRING are expanded; they are appended
|
||||
# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
|
||||
# No SEPARATOR is output if MACRO-NAME was previously undefined (different
|
||||
# than defined and empty).
|
||||
#
|
||||
# This macro is needed until we can rely on Autoconf 2.62, since earlier
|
||||
# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
|
||||
m4_define([lt_append],
|
||||
[m4_define([$1],
|
||||
m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
|
||||
|
||||
|
||||
|
||||
# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
|
||||
# ----------------------------------------------------------
|
||||
# Produce a SEP delimited list of all paired combinations of elements of
|
||||
# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
|
||||
# has the form PREFIXmINFIXSUFFIXn.
|
||||
# Needed until we can rely on m4_combine added in Autoconf 2.62.
|
||||
m4_define([lt_combine],
|
||||
[m4_if(m4_eval([$# > 3]), [1],
|
||||
[m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
|
||||
[[m4_foreach([_Lt_prefix], [$2],
|
||||
[m4_foreach([_Lt_suffix],
|
||||
]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
|
||||
[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
|
||||
|
||||
|
||||
# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
|
||||
# -----------------------------------------------------------------------
|
||||
# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
|
||||
# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
|
||||
m4_define([lt_if_append_uniq],
|
||||
[m4_ifdef([$1],
|
||||
[m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
|
||||
[lt_append([$1], [$2], [$3])$4],
|
||||
[$5])],
|
||||
[lt_append([$1], [$2], [$3])$4])])
|
||||
|
||||
|
||||
# lt_dict_add(DICT, KEY, VALUE)
|
||||
# -----------------------------
|
||||
m4_define([lt_dict_add],
|
||||
[m4_define([$1($2)], [$3])])
|
||||
|
||||
|
||||
# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
|
||||
# --------------------------------------------
|
||||
m4_define([lt_dict_add_subkey],
|
||||
[m4_define([$1($2:$3)], [$4])])
|
||||
|
||||
|
||||
# lt_dict_fetch(DICT, KEY, [SUBKEY])
|
||||
# ----------------------------------
|
||||
m4_define([lt_dict_fetch],
|
||||
[m4_ifval([$3],
|
||||
m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
|
||||
m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
|
||||
|
||||
|
||||
# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
|
||||
# -----------------------------------------------------------------
|
||||
m4_define([lt_if_dict_fetch],
|
||||
[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
|
||||
[$5],
|
||||
[$6])])
|
||||
|
||||
|
||||
# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
|
||||
# --------------------------------------------------------------
|
||||
m4_define([lt_dict_filter],
|
||||
[m4_if([$5], [], [],
|
||||
[lt_join(m4_quote(m4_default([$4], [[, ]])),
|
||||
lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
|
||||
[lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
|
||||
])
|
23
m4/ltversion.m4
vendored
Normal file
23
m4/ltversion.m4
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
# ltversion.m4 -- version numbers -*- Autoconf -*-
|
||||
#
|
||||
# Copyright (C) 2004 Free Software Foundation, Inc.
|
||||
# Written by Scott James Remnant, 2004
|
||||
#
|
||||
# This file is free software; the Free Software Foundation gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
|
||||
# Generated from ltversion.in.
|
||||
|
||||
# serial 3175 ltversion.m4
|
||||
# This file is part of GNU Libtool
|
||||
|
||||
m4_define([LT_PACKAGE_VERSION], [2.2.10])
|
||||
m4_define([LT_PACKAGE_REVISION], [1.3175])
|
||||
|
||||
AC_DEFUN([LTVERSION_VERSION],
|
||||
[macro_version='2.2.10'
|
||||
macro_revision='1.3175'
|
||||
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
|
||||
_LT_DECL(, macro_revision, 0)
|
||||
])
|
98
m4/lt~obsolete.m4
vendored
Normal file
98
m4/lt~obsolete.m4
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
|
||||
#
|
||||
# Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
|
||||
# Written by Scott James Remnant, 2004.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 5 lt~obsolete.m4
|
||||
|
||||
# These exist entirely to fool aclocal when bootstrapping libtool.
|
||||
#
|
||||
# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
|
||||
# which have later been changed to m4_define as they aren't part of the
|
||||
# exported API, or moved to Autoconf or Automake where they belong.
|
||||
#
|
||||
# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
|
||||
# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
|
||||
# using a macro with the same name in our local m4/libtool.m4 it'll
|
||||
# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
|
||||
# and doesn't know about Autoconf macros at all.)
|
||||
#
|
||||
# So we provide this file, which has a silly filename so it's always
|
||||
# included after everything else. This provides aclocal with the
|
||||
# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
|
||||
# because those macros already exist, or will be overwritten later.
|
||||
# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
|
||||
#
|
||||
# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
|
||||
# Yes, that means every name once taken will need to remain here until
|
||||
# we give up compatibility with versions before 1.7, at which point
|
||||
# we need to keep only those names which we still refer to.
|
||||
|
||||
# This is to help aclocal find these macros, as it can't see m4_define.
|
||||
AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
|
||||
|
||||
m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
|
||||
m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
|
||||
m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
|
||||
m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
|
||||
m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
|
||||
m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
|
||||
m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
|
||||
m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
|
||||
m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
|
||||
m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
|
||||
m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
|
||||
m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
|
||||
m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
|
||||
m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
|
||||
m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
|
||||
m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
|
||||
m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
|
||||
m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
|
||||
m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
|
||||
m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
|
||||
m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
|
||||
m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
|
||||
m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
|
||||
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
|
||||
m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
|
||||
m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
|
||||
m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
|
||||
m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
|
||||
m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
|
||||
m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
|
||||
m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
|
||||
m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
|
||||
m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
|
||||
m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
|
||||
m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
|
||||
m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
|
||||
m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
|
||||
m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
|
||||
m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
|
||||
m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
|
||||
m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
|
||||
m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
|
||||
m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
|
||||
m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
|
||||
m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
|
||||
m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
|
||||
m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
|
||||
m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
|
||||
m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
|
||||
m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
|
||||
m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
|
||||
m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
|
||||
m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
|
||||
m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
|
||||
m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
|
||||
m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])])
|
||||
m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
|
||||
m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
|
||||
m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])])
|
||||
m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])])
|
||||
m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])])
|
376
missing
Executable file
376
missing
Executable file
@ -0,0 +1,376 @@
|
||||
#! /bin/sh
|
||||
# Common stub for a few missing GNU programs while installing.
|
||||
|
||||
scriptversion=2009-04-28.21; # UTC
|
||||
|
||||
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
|
||||
# 2008, 2009 Free Software Foundation, Inc.
|
||||
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||
|
||||
# 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, 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/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run=:
|
||||
sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
|
||||
sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
|
||||
|
||||
# In the cases where this matters, `missing' is being run in the
|
||||
# srcdir already.
|
||||
if test -f configure.ac; then
|
||||
configure_ac=configure.ac
|
||||
else
|
||||
configure_ac=configure.in
|
||||
fi
|
||||
|
||||
msg="missing on your system"
|
||||
|
||||
case $1 in
|
||||
--run)
|
||||
# Try to run requested program, and just exit if it succeeds.
|
||||
run=
|
||||
shift
|
||||
"$@" && exit 0
|
||||
# Exit code 63 means version mismatch. This often happens
|
||||
# when the user try to use an ancient version of a tool on
|
||||
# a file that requires a minimum version. In this case we
|
||||
# we should proceed has if the program had been absent, or
|
||||
# if --run hadn't been passed.
|
||||
if test $? = 63; then
|
||||
run=:
|
||||
msg="probably too old"
|
||||
fi
|
||||
;;
|
||||
|
||||
-h|--h|--he|--hel|--help)
|
||||
echo "\
|
||||
$0 [OPTION]... PROGRAM [ARGUMENT]...
|
||||
|
||||
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
|
||||
error status if there is no known handling for PROGRAM.
|
||||
|
||||
Options:
|
||||
-h, --help display this help and exit
|
||||
-v, --version output version information and exit
|
||||
--run try to run the given command, and emulate it if it fails
|
||||
|
||||
Supported PROGRAM values:
|
||||
aclocal touch file \`aclocal.m4'
|
||||
autoconf touch file \`configure'
|
||||
autoheader touch file \`config.h.in'
|
||||
autom4te touch the output file, or create a stub one
|
||||
automake touch all \`Makefile.in' files
|
||||
bison create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||
flex create \`lex.yy.c', if possible, from existing .c
|
||||
help2man touch the output file
|
||||
lex create \`lex.yy.c', if possible, from existing .c
|
||||
makeinfo touch the output file
|
||||
tar try tar, gnutar, gtar, then tar without non-portable flags
|
||||
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||
|
||||
Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
|
||||
\`g' are ignored when checking the name.
|
||||
|
||||
Send bug reports to <bug-automake@gnu.org>."
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
|
||||
echo "missing $scriptversion (GNU Automake)"
|
||||
exit $?
|
||||
;;
|
||||
|
||||
-*)
|
||||
echo 1>&2 "$0: Unknown \`$1' option"
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
# normalize program name to check for.
|
||||
program=`echo "$1" | sed '
|
||||
s/^gnu-//; t
|
||||
s/^gnu//; t
|
||||
s/^g//; t'`
|
||||
|
||||
# Now exit if we have it, but it failed. Also exit now if we
|
||||
# don't have it and --version was passed (most likely to detect
|
||||
# the program). This is about non-GNU programs, so use $1 not
|
||||
# $program.
|
||||
case $1 in
|
||||
lex*|yacc*)
|
||||
# Not GNU programs, they don't have --version.
|
||||
;;
|
||||
|
||||
tar*)
|
||||
if test -n "$run"; then
|
||||
echo 1>&2 "ERROR: \`tar' requires --run"
|
||||
exit 1
|
||||
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||
# We have it, but it failed.
|
||||
exit 1
|
||||
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
|
||||
# Could not run --version or --help. This is probably someone
|
||||
# running `$TOOL --version' or `$TOOL --help' to check whether
|
||||
# $TOOL exists and not knowing $TOOL uses missing.
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# If it does not exist, or fails to run (possibly an outdated version),
|
||||
# try to emulate it.
|
||||
case $program in
|
||||
aclocal*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
|
||||
to install the \`Automake' and \`Perl' packages. Grab them from
|
||||
any GNU archive site."
|
||||
touch aclocal.m4
|
||||
;;
|
||||
|
||||
autoconf*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`${configure_ac}'. You might want to install the
|
||||
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
|
||||
archive site."
|
||||
touch configure
|
||||
;;
|
||||
|
||||
autoheader*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`acconfig.h' or \`${configure_ac}'. You might want
|
||||
to install the \`Autoconf' and \`GNU m4' packages. Grab them
|
||||
from any GNU archive site."
|
||||
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
|
||||
test -z "$files" && files="config.h"
|
||||
touch_files=
|
||||
for f in $files; do
|
||||
case $f in
|
||||
*:*) touch_files="$touch_files "`echo "$f" |
|
||||
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
|
||||
*) touch_files="$touch_files $f.in";;
|
||||
esac
|
||||
done
|
||||
touch $touch_files
|
||||
;;
|
||||
|
||||
automake*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
|
||||
You might want to install the \`Automake' and \`Perl' packages.
|
||||
Grab them from any GNU archive site."
|
||||
find . -type f -name Makefile.am -print |
|
||||
sed 's/\.am$/.in/' |
|
||||
while read f; do touch "$f"; done
|
||||
;;
|
||||
|
||||
autom4te*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, but is $msg.
|
||||
You might have modified some files without having the
|
||||
proper tools for further handling them.
|
||||
You can get \`$1' as part of \`Autoconf' from any GNU
|
||||
archive site."
|
||||
|
||||
file=`echo "$*" | sed -n "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
if test -f "$file"; then
|
||||
touch $file
|
||||
else
|
||||
test -z "$file" || exec >$file
|
||||
echo "#! /bin/sh"
|
||||
echo "# Created by GNU Automake missing as a replacement of"
|
||||
echo "# $ $@"
|
||||
echo "exit 0"
|
||||
chmod +x $file
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
bison*|yacc*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' $msg. You should only need it if
|
||||
you modified a \`.y' file. You may need the \`Bison' package
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Bison' from any GNU archive site."
|
||||
rm -f y.tab.c y.tab.h
|
||||
if test $# -ne 1; then
|
||||
eval LASTARG="\${$#}"
|
||||
case $LASTARG in
|
||||
*.y)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" y.tab.c
|
||||
fi
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" y.tab.h
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if test ! -f y.tab.h; then
|
||||
echo >y.tab.h
|
||||
fi
|
||||
if test ! -f y.tab.c; then
|
||||
echo 'main() { return 0; }' >y.tab.c
|
||||
fi
|
||||
;;
|
||||
|
||||
lex*|flex*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a \`.l' file. You may need the \`Flex' package
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Flex' from any GNU archive site."
|
||||
rm -f lex.yy.c
|
||||
if test $# -ne 1; then
|
||||
eval LASTARG="\${$#}"
|
||||
case $LASTARG in
|
||||
*.l)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
|
||||
if test -f "$SRCFILE"; then
|
||||
cp "$SRCFILE" lex.yy.c
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if test ! -f lex.yy.c; then
|
||||
echo 'main() { return 0; }' >lex.yy.c
|
||||
fi
|
||||
;;
|
||||
|
||||
help2man*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a dependency of a manual page. You may need the
|
||||
\`Help2man' package in order for those modifications to take
|
||||
effect. You can get \`Help2man' from any GNU archive site."
|
||||
|
||||
file=`echo "$*" | sed -n "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
if test -f "$file"; then
|
||||
touch $file
|
||||
else
|
||||
test -z "$file" || exec >$file
|
||||
echo ".ab help2man is required to generate this page"
|
||||
exit $?
|
||||
fi
|
||||
;;
|
||||
|
||||
makeinfo*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a \`.texi' or \`.texinfo' file, or any other file
|
||||
indirectly affecting the aspect of the manual. The spurious
|
||||
call might also be the consequence of using a buggy \`make' (AIX,
|
||||
DU, IRIX). You might want to install the \`Texinfo' package or
|
||||
the \`GNU make' package. Grab either from any GNU archive site."
|
||||
# The file to touch is that specified with -o ...
|
||||
file=`echo "$*" | sed -n "$sed_output"`
|
||||
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
|
||||
if test -z "$file"; then
|
||||
# ... or it is the one specified with @setfilename ...
|
||||
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
|
||||
file=`sed -n '
|
||||
/^@setfilename/{
|
||||
s/.* \([^ ]*\) *$/\1/
|
||||
p
|
||||
q
|
||||
}' $infile`
|
||||
# ... or it is derived from the source name (dir/f.texi becomes f.info)
|
||||
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
|
||||
fi
|
||||
# If the file does not exist, the user really needs makeinfo;
|
||||
# let's fail without touching anything.
|
||||
test -f $file || exit 1
|
||||
touch $file
|
||||
;;
|
||||
|
||||
tar*)
|
||||
shift
|
||||
|
||||
# We have already tried tar in the generic part.
|
||||
# Look for gnutar/gtar before invocation to avoid ugly error
|
||||
# messages.
|
||||
if (gnutar --version > /dev/null 2>&1); then
|
||||
gnutar "$@" && exit 0
|
||||
fi
|
||||
if (gtar --version > /dev/null 2>&1); then
|
||||
gtar "$@" && exit 0
|
||||
fi
|
||||
firstarg="$1"
|
||||
if shift; then
|
||||
case $firstarg in
|
||||
*o*)
|
||||
firstarg=`echo "$firstarg" | sed s/o//`
|
||||
tar "$firstarg" "$@" && exit 0
|
||||
;;
|
||||
esac
|
||||
case $firstarg in
|
||||
*h*)
|
||||
firstarg=`echo "$firstarg" | sed s/h//`
|
||||
tar "$firstarg" "$@" && exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: I can't seem to be able to run \`tar' with the given arguments.
|
||||
You may want to install GNU tar or Free paxutils, or check the
|
||||
command line arguments."
|
||||
exit 1
|
||||
;;
|
||||
|
||||
*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, and is $msg.
|
||||
You might have modified some files without having the
|
||||
proper tools for further handling them. Check the \`README' file,
|
||||
it often tells you about the needed prerequisites for installing
|
||||
this package. You may also peek at any GNU archive site, in case
|
||||
some other package would contain this missing \`$1' program."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
31
src/Makefile.am
Normal file
31
src/Makefile.am
Normal file
@ -0,0 +1,31 @@
|
||||
AUTOMAKE_OPTIONS = subdir-objects
|
||||
AM_CPPFLAGS = $(DEPS_CFLAGS) -O3 -Iprogrammer -Icommon -Iusb -Idata -Iapplication
|
||||
AM_LDFLAGS = \
|
||||
$(BOOST_FILESYSTEM_LDFLAGS) \
|
||||
$(BOOST_REGEX_LDFLAGS) \
|
||||
$(BOOST_SYSTEM_LDFLAGS) \
|
||||
$(BOOST_PROGRAM_OPTIONS_LDFLAGS)
|
||||
|
||||
# $(BOOST_THREADS_LDFLAGS)
|
||||
|
||||
LDADD = $(DEPS_LIBS)
|
||||
|
||||
LIBS = -s \
|
||||
$(BOOST_FILESYSTEM_LIBS) \
|
||||
$(BOOST_REGEX_LIBS) \
|
||||
$(BOOST_SYSTEM_LIBS) \
|
||||
$(BOOST_PROGRAM_OPTIONS_LIBS)
|
||||
|
||||
# $(BOOST_THREADS_LIBS)
|
||||
|
||||
bin_PROGRAMS=cc-tool
|
||||
cc_tool_SOURCES=main.cpp application/cc_flasher.cpp application/cc_base.cpp \
|
||||
common/log.cpp common/common.cpp common/timer.cpp \
|
||||
usb/usb_device.cpp \
|
||||
data/binary_file.cpp data/data_section.cpp data/data_section_store.cpp \
|
||||
data/file.cpp data/hex_file.cpp data/read_target.cpp \
|
||||
data/progress_watcher.cpp \
|
||||
programmer/cc_253x_2540.cpp programmer/cc_251x_111x.cpp \
|
||||
programmer/cc_243x.cpp programmer/cc_programmer.cpp \
|
||||
programmer/cc_unit_driver.cpp programmer/cc_unit_info.cpp
|
||||
|
690
src/Makefile.in
Normal file
690
src/Makefile.in
Normal file
@ -0,0 +1,690 @@
|
||||
# Makefile.in generated by automake 1.11.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
|
||||
# Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkglibexecdir = $(libexecdir)/@PACKAGE@
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
bin_PROGRAMS = cc-tool$(EXEEXT)
|
||||
subdir = src
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/boost.m4 \
|
||||
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
|
||||
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
|
||||
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_CLEAN_FILES =
|
||||
CONFIG_CLEAN_VPATH_FILES =
|
||||
am__installdirs = "$(DESTDIR)$(bindir)"
|
||||
PROGRAMS = $(bin_PROGRAMS)
|
||||
am__dirstamp = $(am__leading_dot)dirstamp
|
||||
am_cc_tool_OBJECTS = main.$(OBJEXT) application/cc_flasher.$(OBJEXT) \
|
||||
application/cc_base.$(OBJEXT) common/log.$(OBJEXT) \
|
||||
common/common.$(OBJEXT) common/timer.$(OBJEXT) \
|
||||
usb/usb_device.$(OBJEXT) data/binary_file.$(OBJEXT) \
|
||||
data/data_section.$(OBJEXT) data/data_section_store.$(OBJEXT) \
|
||||
data/file.$(OBJEXT) data/hex_file.$(OBJEXT) \
|
||||
data/read_target.$(OBJEXT) data/progress_watcher.$(OBJEXT) \
|
||||
programmer/cc_253x_2540.$(OBJEXT) \
|
||||
programmer/cc_251x_111x.$(OBJEXT) programmer/cc_243x.$(OBJEXT) \
|
||||
programmer/cc_programmer.$(OBJEXT) \
|
||||
programmer/cc_unit_driver.$(OBJEXT) \
|
||||
programmer/cc_unit_info.$(OBJEXT)
|
||||
cc_tool_OBJECTS = $(am_cc_tool_OBJECTS)
|
||||
cc_tool_LDADD = $(LDADD)
|
||||
am__DEPENDENCIES_1 =
|
||||
cc_tool_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@
|
||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
am__mv = mv -f
|
||||
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
|
||||
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
|
||||
CXXLD = $(CXX)
|
||||
CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
--mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
|
||||
$(LDFLAGS) -o $@
|
||||
SOURCES = $(cc_tool_SOURCES)
|
||||
DIST_SOURCES = $(cc_tool_SOURCES)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
BOOST_CPPFLAGS = @BOOST_CPPFLAGS@
|
||||
BOOST_FILESYSTEM_LDFLAGS = @BOOST_FILESYSTEM_LDFLAGS@
|
||||
BOOST_FILESYSTEM_LDPATH = @BOOST_FILESYSTEM_LDPATH@
|
||||
BOOST_FILESYSTEM_LIBS = @BOOST_FILESYSTEM_LIBS@
|
||||
BOOST_LDPATH = @BOOST_LDPATH@
|
||||
BOOST_PROGRAM_OPTIONS_LDFLAGS = @BOOST_PROGRAM_OPTIONS_LDFLAGS@
|
||||
BOOST_PROGRAM_OPTIONS_LDPATH = @BOOST_PROGRAM_OPTIONS_LDPATH@
|
||||
BOOST_PROGRAM_OPTIONS_LIBS = @BOOST_PROGRAM_OPTIONS_LIBS@
|
||||
BOOST_REGEX_LDFLAGS = @BOOST_REGEX_LDFLAGS@
|
||||
BOOST_REGEX_LDPATH = @BOOST_REGEX_LDPATH@
|
||||
BOOST_REGEX_LIBS = @BOOST_REGEX_LIBS@
|
||||
BOOST_ROOT = @BOOST_ROOT@
|
||||
BOOST_SYSTEM_LDFLAGS = @BOOST_SYSTEM_LDFLAGS@
|
||||
BOOST_SYSTEM_LDPATH = @BOOST_SYSTEM_LDPATH@
|
||||
BOOST_SYSTEM_LIBS = @BOOST_SYSTEM_LIBS@
|
||||
BOOST_THREAD_LDFLAGS = @BOOST_THREAD_LDFLAGS@
|
||||
BOOST_THREAD_LDPATH = @BOOST_THREAD_LDPATH@
|
||||
BOOST_THREAD_LIBS = @BOOST_THREAD_LIBS@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DEPS_CFLAGS = @DEPS_CFLAGS@
|
||||
DEPS_LIBS = @DEPS_LIBS@
|
||||
DISTCHECK_CONFIGURE_FLAGS = @DISTCHECK_CONFIGURE_FLAGS@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
DUMPBIN = @DUMPBIN@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
FGREP = @FGREP@
|
||||
GREP = @GREP@
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LD = @LD@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = -s \
|
||||
$(BOOST_FILESYSTEM_LIBS) \
|
||||
$(BOOST_REGEX_LIBS) \
|
||||
$(BOOST_SYSTEM_LIBS) \
|
||||
$(BOOST_PROGRAM_OPTIONS_LIBS)
|
||||
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LIPO = @LIPO@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NM = @NM@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
OBJEXT = @OBJEXT@
|
||||
OTOOL = @OTOOL@
|
||||
OTOOL64 = @OTOOL64@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_URL = @PACKAGE_URL@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
PKG_CONFIG = @PKG_CONFIG@
|
||||
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
|
||||
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
|
||||
RANLIB = @RANLIB@
|
||||
SED = @SED@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
abs_builddir = @abs_builddir@
|
||||
abs_srcdir = @abs_srcdir@
|
||||
abs_top_builddir = @abs_top_builddir@
|
||||
abs_top_srcdir = @abs_top_srcdir@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
builddir = @builddir@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
srcdir = @srcdir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
AUTOMAKE_OPTIONS = subdir-objects
|
||||
AM_CPPFLAGS = $(DEPS_CFLAGS) -O3 -Iprogrammer -Icommon -Iusb -Idata -Iapplication
|
||||
AM_LDFLAGS = \
|
||||
$(BOOST_FILESYSTEM_LDFLAGS) \
|
||||
$(BOOST_REGEX_LDFLAGS) \
|
||||
$(BOOST_SYSTEM_LDFLAGS) \
|
||||
$(BOOST_PROGRAM_OPTIONS_LDFLAGS)
|
||||
|
||||
|
||||
# $(BOOST_THREADS_LDFLAGS)
|
||||
LDADD = $(DEPS_LIBS)
|
||||
cc_tool_SOURCES = main.cpp application/cc_flasher.cpp application/cc_base.cpp \
|
||||
common/log.cpp common/common.cpp common/timer.cpp \
|
||||
usb/usb_device.cpp \
|
||||
data/binary_file.cpp data/data_section.cpp data/data_section_store.cpp \
|
||||
data/file.cpp data/hex_file.cpp data/read_target.cpp \
|
||||
data/progress_watcher.cpp \
|
||||
programmer/cc_253x_2540.cpp programmer/cc_251x_111x.cpp \
|
||||
programmer/cc_243x.cpp programmer/cc_programmer.cpp \
|
||||
programmer/cc_unit_driver.cpp programmer/cc_unit_info.cpp
|
||||
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .cpp .lo .o .obj
|
||||
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
|
||||
&& { if test -f $@; then exit 0; else break; fi; }; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
|
||||
$(am__cd) $(top_srcdir) && \
|
||||
$(AUTOMAKE) --gnu src/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(am__aclocal_m4_deps):
|
||||
install-binPROGRAMS: $(bin_PROGRAMS)
|
||||
@$(NORMAL_INSTALL)
|
||||
test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
|
||||
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
|
||||
for p in $$list; do echo "$$p $$p"; done | \
|
||||
sed 's/$(EXEEXT)$$//' | \
|
||||
while read p p1; do if test -f $$p || test -f $$p1; \
|
||||
then echo "$$p"; echo "$$p"; else :; fi; \
|
||||
done | \
|
||||
sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
|
||||
-e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
|
||||
sed 'N;N;N;s,\n, ,g' | \
|
||||
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
|
||||
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
|
||||
if ($$2 == $$4) files[d] = files[d] " " $$1; \
|
||||
else { print "f", $$3 "/" $$4, $$1; } } \
|
||||
END { for (d in files) print "f", d, files[d] }' | \
|
||||
while read type dir files; do \
|
||||
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
|
||||
test -z "$$files" || { \
|
||||
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
|
||||
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
|
||||
} \
|
||||
; done
|
||||
|
||||
uninstall-binPROGRAMS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
|
||||
files=`for p in $$list; do echo "$$p"; done | \
|
||||
sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
|
||||
-e 's/$$/$(EXEEXT)/' `; \
|
||||
test -n "$$list" || exit 0; \
|
||||
echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
|
||||
cd "$(DESTDIR)$(bindir)" && rm -f $$files
|
||||
|
||||
clean-binPROGRAMS:
|
||||
@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
|
||||
echo " rm -f" $$list; \
|
||||
rm -f $$list || exit $$?; \
|
||||
test -n "$(EXEEXT)" || exit 0; \
|
||||
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
|
||||
echo " rm -f" $$list; \
|
||||
rm -f $$list
|
||||
application/$(am__dirstamp):
|
||||
@$(MKDIR_P) application
|
||||
@: > application/$(am__dirstamp)
|
||||
application/$(DEPDIR)/$(am__dirstamp):
|
||||
@$(MKDIR_P) application/$(DEPDIR)
|
||||
@: > application/$(DEPDIR)/$(am__dirstamp)
|
||||
application/cc_flasher.$(OBJEXT): application/$(am__dirstamp) \
|
||||
application/$(DEPDIR)/$(am__dirstamp)
|
||||
application/cc_base.$(OBJEXT): application/$(am__dirstamp) \
|
||||
application/$(DEPDIR)/$(am__dirstamp)
|
||||
common/$(am__dirstamp):
|
||||
@$(MKDIR_P) common
|
||||
@: > common/$(am__dirstamp)
|
||||
common/$(DEPDIR)/$(am__dirstamp):
|
||||
@$(MKDIR_P) common/$(DEPDIR)
|
||||
@: > common/$(DEPDIR)/$(am__dirstamp)
|
||||
common/log.$(OBJEXT): common/$(am__dirstamp) \
|
||||
common/$(DEPDIR)/$(am__dirstamp)
|
||||
common/common.$(OBJEXT): common/$(am__dirstamp) \
|
||||
common/$(DEPDIR)/$(am__dirstamp)
|
||||
common/timer.$(OBJEXT): common/$(am__dirstamp) \
|
||||
common/$(DEPDIR)/$(am__dirstamp)
|
||||
usb/$(am__dirstamp):
|
||||
@$(MKDIR_P) usb
|
||||
@: > usb/$(am__dirstamp)
|
||||
usb/$(DEPDIR)/$(am__dirstamp):
|
||||
@$(MKDIR_P) usb/$(DEPDIR)
|
||||
@: > usb/$(DEPDIR)/$(am__dirstamp)
|
||||
usb/usb_device.$(OBJEXT): usb/$(am__dirstamp) \
|
||||
usb/$(DEPDIR)/$(am__dirstamp)
|
||||
data/$(am__dirstamp):
|
||||
@$(MKDIR_P) data
|
||||
@: > data/$(am__dirstamp)
|
||||
data/$(DEPDIR)/$(am__dirstamp):
|
||||
@$(MKDIR_P) data/$(DEPDIR)
|
||||
@: > data/$(DEPDIR)/$(am__dirstamp)
|
||||
data/binary_file.$(OBJEXT): data/$(am__dirstamp) \
|
||||
data/$(DEPDIR)/$(am__dirstamp)
|
||||
data/data_section.$(OBJEXT): data/$(am__dirstamp) \
|
||||
data/$(DEPDIR)/$(am__dirstamp)
|
||||
data/data_section_store.$(OBJEXT): data/$(am__dirstamp) \
|
||||
data/$(DEPDIR)/$(am__dirstamp)
|
||||
data/file.$(OBJEXT): data/$(am__dirstamp) \
|
||||
data/$(DEPDIR)/$(am__dirstamp)
|
||||
data/hex_file.$(OBJEXT): data/$(am__dirstamp) \
|
||||
data/$(DEPDIR)/$(am__dirstamp)
|
||||
data/read_target.$(OBJEXT): data/$(am__dirstamp) \
|
||||
data/$(DEPDIR)/$(am__dirstamp)
|
||||
data/progress_watcher.$(OBJEXT): data/$(am__dirstamp) \
|
||||
data/$(DEPDIR)/$(am__dirstamp)
|
||||
programmer/$(am__dirstamp):
|
||||
@$(MKDIR_P) programmer
|
||||
@: > programmer/$(am__dirstamp)
|
||||
programmer/$(DEPDIR)/$(am__dirstamp):
|
||||
@$(MKDIR_P) programmer/$(DEPDIR)
|
||||
@: > programmer/$(DEPDIR)/$(am__dirstamp)
|
||||
programmer/cc_253x_2540.$(OBJEXT): programmer/$(am__dirstamp) \
|
||||
programmer/$(DEPDIR)/$(am__dirstamp)
|
||||
programmer/cc_251x_111x.$(OBJEXT): programmer/$(am__dirstamp) \
|
||||
programmer/$(DEPDIR)/$(am__dirstamp)
|
||||
programmer/cc_243x.$(OBJEXT): programmer/$(am__dirstamp) \
|
||||
programmer/$(DEPDIR)/$(am__dirstamp)
|
||||
programmer/cc_programmer.$(OBJEXT): programmer/$(am__dirstamp) \
|
||||
programmer/$(DEPDIR)/$(am__dirstamp)
|
||||
programmer/cc_unit_driver.$(OBJEXT): programmer/$(am__dirstamp) \
|
||||
programmer/$(DEPDIR)/$(am__dirstamp)
|
||||
programmer/cc_unit_info.$(OBJEXT): programmer/$(am__dirstamp) \
|
||||
programmer/$(DEPDIR)/$(am__dirstamp)
|
||||
cc-tool$(EXEEXT): $(cc_tool_OBJECTS) $(cc_tool_DEPENDENCIES)
|
||||
@rm -f cc-tool$(EXEEXT)
|
||||
$(CXXLINK) $(cc_tool_OBJECTS) $(cc_tool_LDADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
-rm -f application/cc_base.$(OBJEXT)
|
||||
-rm -f application/cc_flasher.$(OBJEXT)
|
||||
-rm -f common/common.$(OBJEXT)
|
||||
-rm -f common/log.$(OBJEXT)
|
||||
-rm -f common/timer.$(OBJEXT)
|
||||
-rm -f data/binary_file.$(OBJEXT)
|
||||
-rm -f data/data_section.$(OBJEXT)
|
||||
-rm -f data/data_section_store.$(OBJEXT)
|
||||
-rm -f data/file.$(OBJEXT)
|
||||
-rm -f data/hex_file.$(OBJEXT)
|
||||
-rm -f data/progress_watcher.$(OBJEXT)
|
||||
-rm -f data/read_target.$(OBJEXT)
|
||||
-rm -f programmer/cc_243x.$(OBJEXT)
|
||||
-rm -f programmer/cc_251x_111x.$(OBJEXT)
|
||||
-rm -f programmer/cc_253x_2540.$(OBJEXT)
|
||||
-rm -f programmer/cc_programmer.$(OBJEXT)
|
||||
-rm -f programmer/cc_unit_driver.$(OBJEXT)
|
||||
-rm -f programmer/cc_unit_info.$(OBJEXT)
|
||||
-rm -f usb/usb_device.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@application/$(DEPDIR)/cc_base.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@application/$(DEPDIR)/cc_flasher.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/common.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/log.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@common/$(DEPDIR)/timer.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@data/$(DEPDIR)/binary_file.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@data/$(DEPDIR)/data_section.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@data/$(DEPDIR)/data_section_store.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@data/$(DEPDIR)/file.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@data/$(DEPDIR)/hex_file.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@data/$(DEPDIR)/progress_watcher.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@data/$(DEPDIR)/read_target.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@programmer/$(DEPDIR)/cc_243x.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@programmer/$(DEPDIR)/cc_251x_111x.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@programmer/$(DEPDIR)/cc_253x_2540.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@programmer/$(DEPDIR)/cc_programmer.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@programmer/$(DEPDIR)/cc_unit_driver.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@programmer/$(DEPDIR)/cc_unit_info.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@usb/$(DEPDIR)/usb_device.Po@am__quote@
|
||||
|
||||
.cpp.o:
|
||||
@am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
|
||||
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
|
||||
@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
|
||||
|
||||
.cpp.obj:
|
||||
@am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
|
||||
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
|
||||
@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
|
||||
|
||||
.cpp.lo:
|
||||
@am__fastdepCXX_TRUE@ depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
|
||||
@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
|
||||
@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
set x; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
shift; \
|
||||
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
if test $$# -gt 0; then \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
"$$@" $$unique; \
|
||||
else \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$unique; \
|
||||
fi; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) '{ files[$$0] = 1; nonempty = 1; } \
|
||||
END { if (nonempty) { for (i in files) print i; }; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& $(am__cd) $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) "$$here"
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
|
||||
list='$(DISTFILES)'; \
|
||||
dist_files=`for file in $$list; do echo $$file; done | \
|
||||
sed -e "s|^$$srcdirstrip/||;t" \
|
||||
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
|
||||
case $$dist_files in \
|
||||
*/*) $(MKDIR_P) `echo "$$dist_files" | \
|
||||
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
|
||||
sort -u` ;; \
|
||||
esac; \
|
||||
for file in $$dist_files; do \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test -d "$(distdir)/$$file"; then \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
|
||||
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
|
||||
fi; \
|
||||
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
|
||||
else \
|
||||
test -f "$(distdir)/$$file" \
|
||||
|| cp -p $$d/$$file "$(distdir)/$$file" \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
all-am: Makefile $(PROGRAMS)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(bindir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
done
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
`test -z '$(STRIP)' || \
|
||||
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
|
||||
-rm -f application/$(DEPDIR)/$(am__dirstamp)
|
||||
-rm -f application/$(am__dirstamp)
|
||||
-rm -f common/$(DEPDIR)/$(am__dirstamp)
|
||||
-rm -f common/$(am__dirstamp)
|
||||
-rm -f data/$(DEPDIR)/$(am__dirstamp)
|
||||
-rm -f data/$(am__dirstamp)
|
||||
-rm -f programmer/$(DEPDIR)/$(am__dirstamp)
|
||||
-rm -f programmer/$(am__dirstamp)
|
||||
-rm -f usb/$(DEPDIR)/$(am__dirstamp)
|
||||
-rm -f usb/$(am__dirstamp)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -rf ./$(DEPDIR) application/$(DEPDIR) common/$(DEPDIR) data/$(DEPDIR) programmer/$(DEPDIR) usb/$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
html-am:
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am:
|
||||
|
||||
install-dvi: install-dvi-am
|
||||
|
||||
install-dvi-am:
|
||||
|
||||
install-exec-am: install-binPROGRAMS
|
||||
|
||||
install-html: install-html-am
|
||||
|
||||
install-html-am:
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-info-am:
|
||||
|
||||
install-man:
|
||||
|
||||
install-pdf: install-pdf-am
|
||||
|
||||
install-pdf-am:
|
||||
|
||||
install-ps: install-ps-am
|
||||
|
||||
install-ps-am:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -rf ./$(DEPDIR) application/$(DEPDIR) common/$(DEPDIR) data/$(DEPDIR) programmer/$(DEPDIR) usb/$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
|
||||
mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-binPROGRAMS
|
||||
|
||||
.MAKE: install-am install-strip
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
|
||||
clean-generic clean-libtool ctags distclean distclean-compile \
|
||||
distclean-generic distclean-libtool distclean-tags distdir dvi \
|
||||
dvi-am html html-am info info-am install install-am \
|
||||
install-binPROGRAMS install-data install-data-am install-dvi \
|
||||
install-dvi-am install-exec install-exec-am install-html \
|
||||
install-html-am install-info install-info-am install-man \
|
||||
install-pdf install-pdf-am install-ps install-ps-am \
|
||||
install-strip installcheck installcheck-am installdirs \
|
||||
maintainer-clean maintainer-clean-generic mostlyclean \
|
||||
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
|
||||
pdf pdf-am ps ps-am tags uninstall uninstall-am \
|
||||
uninstall-binPROGRAMS
|
||||
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
255
src/application/cc_base.cpp
Normal file
255
src/application/cc_base.cpp
Normal file
@ -0,0 +1,255 @@
|
||||
/*
|
||||
* cc_base.cpp
|
||||
*
|
||||
* Created on: Nov 30, 2011
|
||||
* Author: st
|
||||
*/
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include "common.h"
|
||||
#include "version.h"
|
||||
#include "log.h"
|
||||
#include "timer.h"
|
||||
#include "programmer/cc_programmer.h"
|
||||
#include "cc_base.h"
|
||||
|
||||
//==============================================================================
|
||||
static bool extract_usb_address(const String &str, uint_t &bus, uint_t &device)
|
||||
{
|
||||
boost::cmatch what;
|
||||
boost::regex regex("([\\d]{1,3}):([\\d]{1,3})");
|
||||
|
||||
if (!boost::regex_match(str.c_str(), what, regex))
|
||||
return false;
|
||||
|
||||
string_to_number(what[1].str(), bus);
|
||||
string_to_number(what[2].str(), device);
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static std::ostream& operator <<(std::ostream &os, const USB_DeviceID &o)
|
||||
{
|
||||
os << std::hex << std::setfill('0') << std::nouppercase;
|
||||
|
||||
os << " VID: 0x" << std::setw(4) << o.vendor_id;
|
||||
os << " PID: 0x" << std::setw(4) << o.product_id;
|
||||
os << " Description: " << o.description;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static void init_log(int argc, char *argv[], String &log_file)
|
||||
{
|
||||
if (log_file.empty())
|
||||
log_file = String(MODULE_NAME) + ".log";
|
||||
|
||||
log_get().set_log_file(log_file);
|
||||
log_info("main, %s %u.%u", MODULE_NAME, VERSION_MAJOR, VERSION_MINOR);
|
||||
|
||||
String command_line;
|
||||
while (argc--)
|
||||
command_line += String(*argv++) + " ";
|
||||
log_info("main, command line: %s", command_line.c_str());
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static void print_usage(const po::options_description &desc)
|
||||
{
|
||||
std::cout << MODULE_DESCRIPTION << "\n";
|
||||
std::cout << " Version: " << VERSION_MAJOR << "." << VERSION_MINOR << "\n";
|
||||
std::cout << "\n Command line options:\n";
|
||||
std::cout << desc;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Base::init_options(po::options_description &desc)
|
||||
{
|
||||
desc.add_options()
|
||||
("load", po::value<std::vector<std::string> >(), "load firmware image ");
|
||||
|
||||
desc.add_options()
|
||||
("help,h", "produce help message");
|
||||
|
||||
desc.add_options()
|
||||
("log", po::value<String>(&option_log_name_)->implicit_value(""),
|
||||
"create in the current directory log of all operations");
|
||||
|
||||
desc.add_options()
|
||||
("device,d", po::value<String>(&option_device_address_),
|
||||
"set programmer deivce usb address 'bus:device'");
|
||||
|
||||
desc.add_options()
|
||||
("fast,f", "set fast debug interface speed (by default: slow)"); //TODO made fast by default
|
||||
|
||||
desc.add_options()
|
||||
("name,n", po::value<String>(&option_unit_name_),
|
||||
"specify target name e.g. CC2530 etc.");
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Base::on_help(const po::options_description &desc)
|
||||
{
|
||||
print_usage(desc);
|
||||
|
||||
std::cout << "\n Supported targets:\n ";
|
||||
StringVector targets = programmer_.supported_unit_names();
|
||||
foreach (const String &item, targets)
|
||||
std::cout << item << " ";
|
||||
|
||||
std::cout << "\n\n Supported programmers:\n";
|
||||
USB_DeviceIDVector devices = programmer_.supported_devices();
|
||||
foreach (const USB_DeviceID &item, devices)
|
||||
std::cout << item << "\n";
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool CC_Base::read_options(const po::options_description &desc, const po::variables_map &vm)
|
||||
{
|
||||
if (vm.count("help"))
|
||||
{
|
||||
on_help(desc);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (vm.count("device"))
|
||||
{
|
||||
uint_t bus = 0, device = 0;
|
||||
if (!extract_usb_address(option_device_address_, bus, device))
|
||||
throw po::error("Bad device address format");
|
||||
}
|
||||
|
||||
option_fast_interface_speed_ = vm.count("fast") > 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool CC_Base::init_unit()
|
||||
{
|
||||
String unit_name;
|
||||
bool supported = false;
|
||||
programmer_.unit_status(unit_name, supported);
|
||||
|
||||
if (unit_name.empty())
|
||||
{
|
||||
std::cout << " No target detected" << "\n";
|
||||
return false;
|
||||
}
|
||||
std::cout << " Target: " << unit_name << "\n";
|
||||
|
||||
if (!supported)
|
||||
{
|
||||
std::cout << " Target not supported" << "\n";
|
||||
log_info("main, target not suported");
|
||||
return false;
|
||||
}
|
||||
|
||||
boost::to_upper(option_unit_name_);
|
||||
if (unit_name != option_unit_name_ && !option_unit_name_.empty())
|
||||
{
|
||||
std::cout << "Specified target " << option_unit_name_ << " not found" << "\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!programmer_.unit_connect(unit_info_))
|
||||
{
|
||||
std::cout << " Unable to communicate with target" << "\n";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool CC_Base::init_programmer()
|
||||
{
|
||||
CC_Programmer::OpenResult open_result = CC_Programmer::OR_OK;
|
||||
|
||||
if (!option_device_address_.empty())
|
||||
{
|
||||
uint_t bus = 0, device = 0;
|
||||
extract_usb_address(option_device_address_, bus, device);
|
||||
open_result = programmer_.open(bus, device);
|
||||
if (open_result == CC_Programmer::OR_NOT_SUPPORTED)
|
||||
std::cout << std::setfill('0') << " Device at "
|
||||
<< std::setw(3) << bus << ":"
|
||||
<< std::setw(3) << device
|
||||
<< " not supported" << "\n";
|
||||
}
|
||||
else
|
||||
open_result = programmer_.open();
|
||||
|
||||
if (open_result != CC_Programmer::OR_OK)
|
||||
{
|
||||
std::cout << " CC Debugger device not found" << "\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
programmer_.set_debug_interface_speed(option_fast_interface_speed_?
|
||||
CC_Programmer::IS_FAST : CC_Programmer::IS_SLOW);
|
||||
|
||||
CC_ProgrammerInfo info;
|
||||
programmer_.programmer_info(info);
|
||||
std::cout << " Programmer: " << info.name << "\n";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool CC_Base::execute(int argc, char *argv[])
|
||||
{
|
||||
po::options_description desc;
|
||||
init_options(desc);
|
||||
|
||||
po::positional_options_description pd;
|
||||
pd.add("input-file", 1);
|
||||
|
||||
try
|
||||
{
|
||||
po::variables_map vm;
|
||||
po::parsed_options parsed = po::command_line_parser(argc, argv).options(desc).allow_unregistered().positional(pd).run();
|
||||
po::store(parsed, vm);
|
||||
po::notify(vm);
|
||||
|
||||
if (vm.count("log"))
|
||||
init_log(argc, argv, option_log_name_);
|
||||
|
||||
if (!read_options(desc, vm))
|
||||
return false;
|
||||
|
||||
if (init_programmer() && init_unit())
|
||||
{
|
||||
log_info("main, start task processing");
|
||||
process_tasks();
|
||||
log_info("main, finish task processing");
|
||||
programmer_.unit_close();
|
||||
}
|
||||
}
|
||||
catch (std::runtime_error& e) // usb, file error
|
||||
{
|
||||
std::cout << " Error occured";
|
||||
if (strlen(e.what()))
|
||||
{
|
||||
std::cout << ": " << e.what();
|
||||
log_info("%s", e.what());
|
||||
}
|
||||
std::cout << "\n";
|
||||
}
|
||||
catch (po::error& e) //command line error
|
||||
{
|
||||
std::cout << " Bad command line options";
|
||||
if (strlen(e.what()))
|
||||
std::cout << " (" << e.what() << ")";
|
||||
std::cout << "\n Try --help for more information\n";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Base::process_tasks()
|
||||
{ }
|
||||
|
||||
//==============================================================================
|
||||
CC_Base::CC_Base() :
|
||||
option_fast_interface_speed_(false)
|
||||
{ }
|
46
src/application/cc_base.h
Normal file
46
src/application/cc_base.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* cc_base.h
|
||||
*
|
||||
* Created on: Nov 30, 2011
|
||||
* Author: st
|
||||
*/
|
||||
|
||||
#ifndef _CC_BASE_H_
|
||||
#define _CC_BASE_H_
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include "data/binary_file.h"
|
||||
#include "data/hex_file.h"
|
||||
#include "data/read_target.h"
|
||||
#include "data/data_section_store.h"
|
||||
#include "programmer/cc_programmer.h"
|
||||
|
||||
namespace po = boost::program_options;
|
||||
|
||||
class CC_Base : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
bool execute(int argc, char *argv[]);
|
||||
|
||||
CC_Base();
|
||||
|
||||
protected:
|
||||
virtual void init_options(po::options_description &);
|
||||
virtual bool read_options(const po::options_description &, const po::variables_map &);
|
||||
virtual void process_tasks();
|
||||
|
||||
UnitInfo unit_info_;
|
||||
CC_Programmer programmer_;
|
||||
|
||||
private:
|
||||
void on_help(const po::options_description &);
|
||||
bool init_programmer();
|
||||
bool init_unit();
|
||||
|
||||
bool option_fast_interface_speed_;
|
||||
String option_unit_name_;
|
||||
String option_device_address_;
|
||||
String option_log_name_;
|
||||
};
|
||||
|
||||
#endif // !_CC_BASE_H_
|
468
src/application/cc_flasher.cpp
Normal file
468
src/application/cc_flasher.cpp
Normal file
@ -0,0 +1,468 @@
|
||||
/*
|
||||
* cc_tool.cpp
|
||||
*
|
||||
* Created on: Aug 3, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#include <boost/regex.hpp>
|
||||
#include "common.h"
|
||||
#include "version.h"
|
||||
#include "log.h"
|
||||
#include "timer.h"
|
||||
#include "programmer/cc_programmer.h"
|
||||
#include "cc_flasher.h"
|
||||
|
||||
enum Task {
|
||||
T_RESET = 0x0001,
|
||||
T_ERASE = 0x0002,
|
||||
T_WRITE_FLASH = 0x0004,
|
||||
T_READ_FLASH = 0x0008,
|
||||
T_VERIFY = 0x0010,
|
||||
T_LOCK = 0x0020,
|
||||
T_READ_MAC = 0x0040,
|
||||
T_READ_INFO_PAGE = 0x0080,
|
||||
T_TEST = 0x0100,
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
bool extract_mac_address(const String &mac, size_t length, ByteVector &data)
|
||||
{
|
||||
String exp;
|
||||
for (size_t i = 0; i < length; i++)
|
||||
exp += "([\\da-fA-F]{2}):";
|
||||
exp.erase(exp.end() - 1);
|
||||
|
||||
boost::cmatch what;
|
||||
boost::regex regex(exp);
|
||||
|
||||
if (!boost::regex_match(mac.c_str(), what, regex))
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < length; i++)
|
||||
data.push_back(std::strtoul(what[i + 1].str().c_str(), NULL, 16));
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static void print_hex_dump(const ByteVector &data)
|
||||
{
|
||||
size_t total_size = data.size();
|
||||
size_t offset = 0;
|
||||
|
||||
while (total_size)
|
||||
{
|
||||
size_t size = std::min(total_size, (size_t)40);
|
||||
std::cout << binary_to_hex(&data[offset], size, "") << "\n";
|
||||
offset += size;
|
||||
total_size -= size;
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static void load_flash_data(const OptionFileInfo &file_info, DataSectionStore §ion_store)
|
||||
{
|
||||
if (file_info.type == "hex")
|
||||
{
|
||||
DataSectionStore sections;
|
||||
hex_file_load(file_info.name, sections);
|
||||
section_store.add_sections(sections, true);
|
||||
|
||||
size_t n = 0;
|
||||
log_info("main, loaded hex file %s", file_info.name.c_str());
|
||||
foreach (const DataSection &item, section_store.sections())
|
||||
log_info(" section %02u, address: %06Xh, size: %06Xh",
|
||||
n++, item.address, item.size());
|
||||
}
|
||||
|
||||
if (file_info.type == "bin")
|
||||
{
|
||||
ByteVector data;
|
||||
binary_file_load(file_info.name, data);
|
||||
|
||||
DataSection section(file_info.offset, data);
|
||||
section_store.add_section(section, true);
|
||||
|
||||
log_info("main, loaded bin file %s, size: %u", file_info.name.c_str(),
|
||||
data.size());
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static std::ostream& operator <<(std::ostream &os, const CC_ProgrammerInfo &o)
|
||||
{
|
||||
os << " Name: " << o.name << "\n";
|
||||
os << " Debugger ID: " << o.debugger_id << "\n";
|
||||
os << std::hex << std::setfill('0') << std::uppercase;
|
||||
os << " Version: 0x" << std::setw(4) << o.fw_version << "\n";
|
||||
os << " Revision: 0x" << std::setw(4) << o.fw_revision << "\n";
|
||||
os << std::dec;
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static std::ostream& operator <<(std::ostream &os, const UnitInfo &o)
|
||||
{
|
||||
os << " Name: " << o.name << "\n";
|
||||
os << std::hex << std::setfill('0') << std::uppercase;
|
||||
os << " Revision: 0x" << std::setw(2) << (uint_t)o.revision << "\n";
|
||||
os << " Internal ID: 0x" << std::setw(2) << (uint_t)o.internal_ID << "\n";
|
||||
os << " ID: 0x" << std::setw(4) << o.ID << "\n";
|
||||
os << std::dec;
|
||||
os << " Flash size: ";
|
||||
if (!o.flash_size)
|
||||
os << "n/a" << "\n";
|
||||
else
|
||||
os << o.flash_size << " KB" << "\n";
|
||||
os << " RAM size: ";
|
||||
if (!o.ram_size)
|
||||
os << "n/a" << "\n";
|
||||
else
|
||||
os << o.ram_size << " KB" << "\n";
|
||||
os << std::dec;
|
||||
os << " Lock data size: " << o.lock_size << " B" << "\n";
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static void on_progress(size_t done_read, size_t total_read)
|
||||
{
|
||||
std::cout << " Progress: " << done_read * 100 / total_read
|
||||
<< "%\r" << std::flush;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Flasher::init_options(po::options_description &desc)
|
||||
{
|
||||
CC_Base::init_options(desc);
|
||||
|
||||
desc.add_options()
|
||||
("read-info-page,i", po::value<String>(&option_info_page_)->implicit_value(""),
|
||||
"read info pages");
|
||||
|
||||
desc.add_options()
|
||||
("read-mac-address,a", "read mac address(es)");
|
||||
|
||||
desc.add_options()
|
||||
("read,r", po::value<String>(), "read flash memory");
|
||||
|
||||
desc.add_options()
|
||||
("erase,e", "erase flash memory");
|
||||
|
||||
desc.add_options()
|
||||
("write,w", po::value<StringVector>(),
|
||||
"write flash memory. Option can be specified several times.");
|
||||
|
||||
desc.add_options()
|
||||
("verify,v", po::value<String>(&option_verify_type_)->implicit_value(""),
|
||||
"verify flash after write, method '(r)ead' or '(c)cr' (used by default)");
|
||||
|
||||
desc.add_options()
|
||||
("reset", "perform target reset");
|
||||
|
||||
desc.add_options()
|
||||
("test,t", "search for programmer and target");
|
||||
|
||||
desc.add_options()
|
||||
("lock,l", po::value<String>(&option_lock_data_),
|
||||
"specify lock data in hex numbers");
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool CC_Flasher::read_options(const po::options_description &desc, const po::variables_map &vm)
|
||||
{
|
||||
if (!CC_Base::read_options(desc, vm))
|
||||
return false;
|
||||
|
||||
if (vm.count("read-mac-address"))
|
||||
task_set_ |= T_READ_MAC;
|
||||
|
||||
if (vm.count("read-info-page"))
|
||||
{
|
||||
task_set_ |= T_READ_INFO_PAGE;
|
||||
info_page_read_target_.set_source(option_info_page_);
|
||||
}
|
||||
if (vm.count("verify"))
|
||||
task_set_ |= T_VERIFY;
|
||||
|
||||
if (!option_verify_type_.empty())
|
||||
{
|
||||
if (option_verify_type_ == "r" || option_verify_type_ == "read")
|
||||
verify_method_ = CC_Programmer::VM_BY_READ;
|
||||
else
|
||||
if ((option_verify_type_ == "c" || option_verify_type_ == "crc"))
|
||||
verify_method_ = CC_Programmer::VM_BY_CRC;
|
||||
else
|
||||
throw po::error("bad verify method - " + option_verify_type_);
|
||||
}
|
||||
|
||||
if (vm.count("reset"))
|
||||
task_set_ |= T_RESET;
|
||||
if (vm.count("erase"))
|
||||
task_set_ |= T_ERASE;
|
||||
if (vm.count("test"))
|
||||
task_set_ |= T_TEST;
|
||||
|
||||
if (vm.count("read"))
|
||||
{
|
||||
task_set_ |= T_READ_FLASH;
|
||||
flash_read_target_.set_source(vm["read"].as<String>());
|
||||
}
|
||||
|
||||
if (vm.count("write"))
|
||||
{
|
||||
task_set_ |= T_WRITE_FLASH;
|
||||
StringVector list = vm["write"].as<StringVector>();
|
||||
foreach (String &item, list)
|
||||
{
|
||||
OptionFileInfo file_info;
|
||||
option_extract_file_info(item, file_info, true);
|
||||
load_flash_data(file_info, flash_write_data_);
|
||||
}
|
||||
}
|
||||
|
||||
if (vm.count("lock"))
|
||||
task_set_ |= T_LOCK;
|
||||
|
||||
if ((task_set_ & T_VERIFY) && !(task_set_ & T_WRITE_FLASH))
|
||||
throw po::error("verify option is used without write");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Flasher::process_tasks()
|
||||
{
|
||||
target_locked_ = programmer_.unit_locked();
|
||||
if (target_locked_)
|
||||
{
|
||||
std::cout << " Target is locked. ";
|
||||
std::cout << "No operations allowed without erase\n";
|
||||
}
|
||||
|
||||
if (!task_set_)
|
||||
{
|
||||
std::cout << " No actions specified" << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
if (task_set_ & T_TEST)
|
||||
task_test();
|
||||
|
||||
if (target_locked_ && !(task_set_ & T_ERASE))
|
||||
return;
|
||||
|
||||
if (target_locked_)
|
||||
{
|
||||
task_erase();
|
||||
task_set_ &= ~T_ERASE;
|
||||
if (target_locked_)
|
||||
{
|
||||
std::cout << "still locked" << "\n";//
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (task_set_ & T_READ_MAC)
|
||||
task_read_mac_address();
|
||||
|
||||
if (task_set_ & T_READ_INFO_PAGE)
|
||||
task_read_info_page();
|
||||
|
||||
if (task_set_ & T_RESET)
|
||||
{
|
||||
programmer_.unit_reset();
|
||||
std::cout << " Target reseted" << "\n";
|
||||
}
|
||||
|
||||
if (task_set_ & T_READ_FLASH)
|
||||
task_read_flash();
|
||||
|
||||
if (task_set_ & T_ERASE)
|
||||
task_erase();
|
||||
|
||||
if (task_set_ & T_WRITE_FLASH)
|
||||
task_write_flash();
|
||||
|
||||
if (task_set_ & T_VERIFY)
|
||||
task_verify_flash();
|
||||
|
||||
if (task_set_ & T_LOCK)
|
||||
task_lock();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Flasher::task_test()
|
||||
{
|
||||
std::cout << "\n" << " Device info: " << "\n";
|
||||
|
||||
CC_ProgrammerInfo info;
|
||||
programmer_.programmer_info(info);
|
||||
std::cout << info;
|
||||
|
||||
if (target_locked_)
|
||||
return;
|
||||
|
||||
std::cout << "\n" << " Target info: " << "\n";
|
||||
std::cout << unit_info_;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Flasher::task_read_mac_address()
|
||||
{
|
||||
if (!(unit_info_.flags & UnitInfo::SUPPORT_MAC_ADDRESS))
|
||||
{
|
||||
std::cout << " Target does not support MAC address" << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
ByteVector mac0;
|
||||
programmer_.unit_mac_address_read(0, mac0);
|
||||
|
||||
if (unit_info_.mac_address_count == 1)
|
||||
{
|
||||
std::cout << " MAC address: " << binary_to_hex(&mac0[0], mac0.size(), ":")
|
||||
<< "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
ByteVector mac1;
|
||||
programmer_.unit_mac_address_read(1, mac1);
|
||||
|
||||
std::cout << " MAC addresses, primary: "
|
||||
<< binary_to_hex(&mac0[0], mac0.size(), ":")
|
||||
<< ", secondary: "
|
||||
<< binary_to_hex(&mac1[0], mac1.size(), ":") << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Flasher::task_read_info_page()
|
||||
{
|
||||
if (!(unit_info_.flags & UnitInfo::SUPPORT_INFO_PAGE))
|
||||
{
|
||||
std::cout << " Target does not reading Info Page" << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << " Reading info page..." << "\n";
|
||||
|
||||
Timer timer;
|
||||
ByteVector info_page;
|
||||
programmer_.unit_read_info_page(info_page);
|
||||
|
||||
std::cout << " Reading completed (" << timer.elapsed_time() << ")" << "\n";
|
||||
|
||||
if (info_page_read_target_.source_type() == ReadTarget::ST_CONSOLE)
|
||||
{
|
||||
std::cout << " Information page (" << info_page.size() << " B):" << "\n";
|
||||
print_hex_dump(info_page);
|
||||
}
|
||||
else
|
||||
info_page_read_target_.on_read(info_page);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Flasher::task_erase()
|
||||
{
|
||||
std::cout << " Erasing flash..." << "\n";
|
||||
|
||||
if (!programmer_.unit_erase())
|
||||
std::cout << "Flash erasing failed, timeout" << "\n";
|
||||
std::cout << " Erasing completed" << "\n";
|
||||
|
||||
programmer_.unit_connect(unit_info_);
|
||||
target_locked_ = programmer_.unit_locked();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Flasher::task_verify_flash()
|
||||
{
|
||||
std::cout << " Verifying flash..." << "\n";
|
||||
|
||||
Timer timer;
|
||||
bool result = programmer_.unit_flash_verify(flash_write_data_, verify_method_);
|
||||
|
||||
if (result)
|
||||
std::cout << " Verification completed (" << timer.elapsed_time() << ")" << "\n";
|
||||
else
|
||||
std::cout << " Verification failed" << "\n";
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Flasher::task_read_flash()
|
||||
{
|
||||
std::cout
|
||||
<< " Reading flash ("
|
||||
<< unit_info_.actual_flash_size() / 1024 << " KB)..." << "\n";
|
||||
|
||||
Timer timer;
|
||||
ByteVector flash_data;
|
||||
programmer_.unit_flash_read(flash_data);
|
||||
flash_read_target_.on_read(flash_data);
|
||||
|
||||
std::cout << " Reading completed (" << timer.elapsed_time() << ")" << "\n";
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Flasher::task_write_flash()
|
||||
{
|
||||
size_t flash_size = unit_info_.flash_size ?
|
||||
unit_info_.flash_size : unit_info_.max_flash_size;
|
||||
flash_size *= 1024;
|
||||
|
||||
if (flash_write_data_.upper_address() > flash_size)
|
||||
{
|
||||
std::cout << " Flash image size exceeding flash physical size, writing canceled..." << "\n";
|
||||
task_set_ &= ~(T_VERIFY | T_LOCK);
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << " Writing flash... ("
|
||||
<< convinient_storage_size(flash_write_data_.actual_size())
|
||||
<< ")..." << "\n";
|
||||
|
||||
Timer timer;
|
||||
programmer_.unit_flash_write(flash_write_data_);
|
||||
std::cout << " Writing completed (" << timer.elapsed_time() << ")" << "\n";
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Flasher::task_lock()
|
||||
{
|
||||
ByteVector data;
|
||||
|
||||
if (!hex_to_binary(option_lock_data_, data, ""))
|
||||
{
|
||||
std::cout << " Incorrect lock data format" << "\n";
|
||||
return;
|
||||
}
|
||||
if (data.size() != unit_info_.lock_size)
|
||||
{
|
||||
std::cout << " Lock data size must be " << unit_info_.lock_size
|
||||
<< "B, provided: " << data.size() << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
std::cout << " Writing lock data... " << "\n";
|
||||
bool result = programmer_.unit_lock_write(data);
|
||||
if (result)
|
||||
std::cout << " Lock completed" << "\n";
|
||||
else
|
||||
std::cout << " Lock failed" << "\n";
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
CC_Flasher::CC_Flasher() :
|
||||
task_set_(0),
|
||||
verify_method_(CC_Programmer::VM_BY_CRC),
|
||||
target_locked_(false)
|
||||
{
|
||||
programmer_.do_on_flash_read_progress(on_progress);
|
||||
programmer_.do_on_flash_write_progress(on_progress);
|
||||
}
|
55
src/application/cc_flasher.h
Normal file
55
src/application/cc_flasher.h
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* cc_tool.cpp
|
||||
*
|
||||
* Created on: Aug 3, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CC_FLASHER_H_
|
||||
#define _CC_FLASHER_H_
|
||||
|
||||
#include <boost/program_options.hpp>
|
||||
#include "data/binary_file.h"
|
||||
#include "data/hex_file.h"
|
||||
#include "data/read_target.h"
|
||||
#include "data/data_section_store.h"
|
||||
#include "programmer/cc_programmer.h"
|
||||
#include "application/cc_base.h"
|
||||
|
||||
class CC_Flasher : public CC_Base
|
||||
{
|
||||
public:
|
||||
CC_Flasher();
|
||||
|
||||
private:
|
||||
void task_lock();
|
||||
void task_test();
|
||||
void task_erase();
|
||||
void task_read_flash();
|
||||
void task_write_flash();
|
||||
void task_verify_flash();
|
||||
void task_read_mac_address();
|
||||
void task_read_info_page();
|
||||
|
||||
virtual void init_options(po::options_description &);
|
||||
virtual bool read_options(const po::options_description &, const po::variables_map &);
|
||||
virtual void process_tasks();
|
||||
|
||||
String option_lock_data_;
|
||||
String option_info_page_;
|
||||
String option_verify_type_;
|
||||
uint_t task_set_;
|
||||
|
||||
CC_Programmer::VerifyMethod verify_method_;
|
||||
DataSectionStore flash_write_data_;
|
||||
|
||||
ReadTarget flash_read_target_;
|
||||
ReadTarget info_page_read_target_;
|
||||
|
||||
bool target_locked_;
|
||||
};
|
||||
|
||||
#endif // !_CC_FLASHER_H_
|
83
src/common/common.cpp
Normal file
83
src/common/common.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* common.cpp
|
||||
*
|
||||
* Created on: Nov 11, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/time.h>
|
||||
#include "common.h"
|
||||
|
||||
//==============================================================================
|
||||
bool hex_to_binary(const String &hex, ByteVector &out, const char delimiter[])
|
||||
{
|
||||
const char *str = hex.c_str();
|
||||
char buffer[3] = { 0, 0, 0 };
|
||||
|
||||
while (*str)
|
||||
{
|
||||
while (*str && strchr(delimiter, *str) != NULL) str++;
|
||||
if (!*str)
|
||||
break;
|
||||
|
||||
buffer[0] = *str++;
|
||||
if (!*str)
|
||||
return false;
|
||||
buffer[1] = *str++;
|
||||
|
||||
char *error = NULL;
|
||||
out.push_back(std::strtoul(buffer, &error, 16));
|
||||
if (*error != '\0')
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
String binary_to_hex(const uint8_t data[], size_t size, const char delimiter[])
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << std::setfill('0') << std::hex << std::uppercase;
|
||||
|
||||
while (size--)
|
||||
{
|
||||
ss << std::setw(2) << (int)*data++;
|
||||
if (size)
|
||||
ss << delimiter;
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
uint_t get_tick_count()
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday(&tv, NULL);
|
||||
return (tv.tv_sec * 1000 + tv.tv_usec / 1000);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
String convinient_storage_size(off_t size)
|
||||
{
|
||||
const String measure[] = { " B", " KB", " MB", " GB" };
|
||||
|
||||
size_t index = 0;
|
||||
while (size > 1024 && index < (ARRAY_SIZE(measure) - 1))
|
||||
{
|
||||
size = size / 1024;
|
||||
index++;
|
||||
}
|
||||
return number_to_string(size) + measure[index];
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
String binary_to_hex(const ByteVector &data, const char delimiter[])
|
||||
{ return binary_to_hex(&data[0], data.size(), delimiter); }
|
||||
|
||||
//==============================================================================
|
||||
void vector_append(ByteVector &vector, const uint8_t data[], size_t size)
|
||||
{ vector.insert(vector.end(), data, data + size); }
|
76
src/common/common.h
Normal file
76
src/common/common.h
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* common.h
|
||||
*
|
||||
* Created on: Aug 3, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _COMMON_H_
|
||||
#define _COMMON_H_
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <stdexcept>
|
||||
#include <stdint.h>
|
||||
#include <assert.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#define foreach BOOST_FOREACH
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
typedef unsigned int uint_t;
|
||||
typedef std::string String;
|
||||
typedef std::vector<String> StringVector;
|
||||
typedef std::vector<uint8_t> ByteVector;
|
||||
|
||||
String convinient_storage_size(off_t size);
|
||||
uint_t get_tick_count();
|
||||
String binary_to_hex(const uint8_t data[], size_t size, const char delimiter[] = "");
|
||||
String binary_to_hex(const ByteVector &data, const char delimiter[] = "");
|
||||
void vector_append(ByteVector &vector, const uint8_t data[], size_t size);
|
||||
bool hex_to_binary(const String &hex, ByteVector &out, const char delimiter[] = "");
|
||||
|
||||
namespace common_impl
|
||||
{
|
||||
template<typename T>
|
||||
struct nt { typedef T type; };
|
||||
template<>
|
||||
struct nt<unsigned char> { typedef uint_t type; };
|
||||
template<>
|
||||
struct nt<char> { typedef int type; };
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
template<typename T>
|
||||
inline String number_to_string(T number)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << static_cast<typename common_impl::nt<T>::type>(number);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
template<typename T>
|
||||
inline bool string_to_number(const String &string, T &number)
|
||||
{
|
||||
char *bad_character = NULL;
|
||||
number = strtoul(string.c_str(), &bad_character, 10);
|
||||
|
||||
return string.empty() || *bad_character == '\0';
|
||||
}
|
||||
|
||||
#endif // !_COMMON_H_
|
69
src/common/log.cpp
Normal file
69
src/common/log.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* log.cpp
|
||||
*
|
||||
* Created on: Nov 9, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#include "log.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
//==============================================================================
|
||||
Log::Log() :
|
||||
file_(NULL)
|
||||
{ }
|
||||
|
||||
//==============================================================================
|
||||
Log::~Log()
|
||||
{
|
||||
if (file_)
|
||||
fclose(file_);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void Log::set_log_file(const String &file_name)
|
||||
{
|
||||
if (file_)
|
||||
fclose(file_);
|
||||
file_ = fopen(file_name.c_str(), "w");
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void Log::add(LogLevel level, const String &message, va_list ap)
|
||||
{
|
||||
time_t sys_time;
|
||||
tm local_time;
|
||||
time(&sys_time);
|
||||
localtime_r(&sys_time, &local_time);
|
||||
|
||||
char time_stamp[64] = { '\0' };
|
||||
strftime(time_stamp, 64, "%d.%m %H:%M:%S:", &local_time);
|
||||
sprintf(time_stamp + strlen(time_stamp), "%05d", get_tick_count() % 100000);
|
||||
|
||||
if (file_)
|
||||
{
|
||||
fprintf(file_, "[%s] ", time_stamp);
|
||||
vfprintf(file_, message.c_str(), ap);
|
||||
fprintf(file_, "\n");
|
||||
fflush(file_);
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void log_info(const String &message, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, message);
|
||||
log_get().add(Log::LL_INFO, message, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
Log &log_get()
|
||||
{
|
||||
static Log log;
|
||||
return log;
|
||||
}
|
35
src/common/log.h
Normal file
35
src/common/log.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* log.h
|
||||
*
|
||||
* Created on: Nov 9, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _LOG_H_
|
||||
#define _LOG_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "common.h"
|
||||
|
||||
class Log
|
||||
{
|
||||
public:
|
||||
enum LogLevel { LL_INFO };
|
||||
|
||||
void add(LogLevel level, const String &message, va_list ap);
|
||||
void set_log_file(const String &file_name);
|
||||
|
||||
Log();
|
||||
~Log();
|
||||
private:
|
||||
FILE *file_;
|
||||
};
|
||||
|
||||
void log_info(const String &message, ...);
|
||||
Log &log_get();
|
||||
|
||||
#endif // !_LOG_H_
|
35
src/common/timer.cpp
Normal file
35
src/common/timer.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* timer.cpp
|
||||
*
|
||||
* Created on: Nov 11, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "timer.h"
|
||||
|
||||
//==============================================================================
|
||||
Timer::Timer()
|
||||
{
|
||||
start();
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
void Timer::start()
|
||||
{
|
||||
start_time_ = get_tick_count(); elapsed_time_ = 0;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
String Timer::elapsed_time()
|
||||
{
|
||||
elapsed_time_ = get_tick_count() - start_time_;
|
||||
|
||||
char buf[16];
|
||||
sprintf(buf, "%.02f s.", (float)elapsed_time_ / 1000);
|
||||
return buf;
|
||||
}
|
29
src/common/timer.h
Normal file
29
src/common/timer.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* timer.h
|
||||
*
|
||||
* Created on: Nov 5, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _TIMER_H_
|
||||
#define _TIMER_H_
|
||||
|
||||
#include "common.h"
|
||||
|
||||
class Timer : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
String elapsed_time();
|
||||
Timer();
|
||||
|
||||
private:
|
||||
void start();
|
||||
|
||||
uint_t start_time_;
|
||||
uint_t elapsed_time_;
|
||||
};
|
||||
|
||||
#endif // !_TIMER_H_
|
62
src/data/binary_file.cpp
Normal file
62
src/data/binary_file.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* binary_file.cpp
|
||||
*
|
||||
* Created on: Jul 30, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "binary_file.h"
|
||||
#include "file.h"
|
||||
|
||||
//==============================================================================
|
||||
void file_io_error(const String &message, const String &file_name)
|
||||
{
|
||||
String error = message + " " + file_name + ": " + strerror(errno);
|
||||
|
||||
throw FileException(error);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void binary_file_load(const String &file_name, ByteVector &vector)
|
||||
{
|
||||
FILE *file = fopen(file_name.c_str(), "r");
|
||||
if (!file)
|
||||
file_io_error("Unable to open file file", file_name);
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
size_t size = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
|
||||
vector.resize(size, 0);
|
||||
if (fread(&vector[0], 1, size, file) != size && ferror(file) != 0)
|
||||
{
|
||||
fclose(file);
|
||||
file_io_error("Unable to read file", file_name);
|
||||
}
|
||||
|
||||
if (fclose(file))
|
||||
file_io_error("Unable to close file", file_name);
|
||||
//return vector;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void binary_file_save(const String &file_name, const ByteVector &vector)
|
||||
{
|
||||
FILE *file = fopen(file_name.c_str(), "w");
|
||||
if (!file)
|
||||
file_io_error("Unable to open file file", file_name);
|
||||
|
||||
if (fwrite(&vector[0], 1, vector.size(), file) != vector.size() &&
|
||||
ferror(file) != 0)
|
||||
{
|
||||
fclose(file);
|
||||
file_io_error("Unable to write file", file_name);
|
||||
}
|
||||
|
||||
if (fclose(file))
|
||||
file_io_error("Unable to close file", file_name);
|
||||
}
|
25
src/data/binary_file.h
Normal file
25
src/data/binary_file.h
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* binary_file.h
|
||||
*
|
||||
* Created on: Jul 30, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*/
|
||||
|
||||
#ifndef _BINARY_FILE_H_
|
||||
#define _BINARY_FILE_H_
|
||||
|
||||
#include "common.h"
|
||||
|
||||
class BinaryFile
|
||||
{
|
||||
public:
|
||||
static ByteVector& load(const String &file_name, ByteVector &vector);
|
||||
static void save(const String &file_name, const ByteVector &vector);
|
||||
};
|
||||
|
||||
void binary_file_load(const String &file_name, ByteVector &vector);
|
||||
void binary_file_save(const String &file_name, const ByteVector &vector);
|
||||
|
||||
#endif // !_BINARY_FILE_H_
|
58
src/data/data_section.cpp
Normal file
58
src/data/data_section.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* data_section.cpp
|
||||
*
|
||||
* Created on: Jul 29, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#include "data_section.h"
|
||||
|
||||
//==============================================================================
|
||||
std::ostream& operator <<(std::ostream &os, const DataSection &o)
|
||||
{
|
||||
os << std::uppercase << std::hex << std::setfill('0');
|
||||
|
||||
os << "start address: " << std::setw(8) << o.address << ", ";
|
||||
os << "end address: " << std::setw(8) << o.next_address() << ", ";
|
||||
os << "size: " << std::setw(8) << o.size();
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool DataSection::empty() const
|
||||
{
|
||||
return data.empty();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
size_t DataSection::size() const
|
||||
{
|
||||
return data.size();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
uint_t DataSection::next_address() const
|
||||
{
|
||||
return address + data.size();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
DataSection::DataSection() :
|
||||
address(0)
|
||||
{ }
|
||||
|
||||
//==============================================================================
|
||||
DataSection::DataSection(uint_t address_, const ByteVector &data_) :
|
||||
address(address_),
|
||||
data(data_)
|
||||
{ }
|
||||
|
||||
//==============================================================================
|
||||
DataSection::DataSection(uint_t address_, const uint8_t data_[], size_t size) :
|
||||
address(address_),
|
||||
data(data_, data_ + size)
|
||||
{ }
|
35
src/data/data_section.h
Normal file
35
src/data/data_section.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* data_section.h
|
||||
*
|
||||
* Created on: Jul 29, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _DATA_SECTION_H_
|
||||
#define _DATA_SECTION_H_
|
||||
|
||||
#include <list>
|
||||
#include "common.h"
|
||||
|
||||
struct DataSection
|
||||
{
|
||||
bool empty() const;
|
||||
size_t size() const;
|
||||
uint_t next_address() const;
|
||||
|
||||
DataSection();
|
||||
DataSection(uint_t address, const ByteVector &data);
|
||||
DataSection(uint_t address, const uint8_t data[], size_t size);
|
||||
|
||||
uint_t address;
|
||||
ByteVector data;
|
||||
};
|
||||
|
||||
typedef std::list<DataSection> DataSectionList;
|
||||
|
||||
std::ostream& operator <<(std::ostream &os, const DataSection &o);
|
||||
|
||||
#endif // !_DATA_SECTION_H_
|
203
src/data/data_section_store.cpp
Normal file
203
src/data/data_section_store.cpp
Normal file
@ -0,0 +1,203 @@
|
||||
/*
|
||||
* data_section_store.cpp
|
||||
*
|
||||
* Created on: Jul 30, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#include "data_section_store.h"
|
||||
|
||||
//==============================================================================
|
||||
static bool sections_overlapped(
|
||||
const DataSection §ion1,
|
||||
const DataSection §ion2)
|
||||
{
|
||||
if (section1.address >= section2.address &&
|
||||
section1.address < section2.next_address())
|
||||
return true;
|
||||
|
||||
if (section2.address >= section1.address &&
|
||||
section2.address < section1.next_address())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static bool check_section_fit(
|
||||
const DataSectionList §ions,
|
||||
const DataSection §ion)
|
||||
{
|
||||
foreach (const DataSection &item, sections)
|
||||
{
|
||||
if (sections_overlapped(item, section))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static void add_insert_section(
|
||||
DataSectionList §ions,
|
||||
const DataSection §ion)
|
||||
{
|
||||
DataSectionList::iterator it = sections.begin();
|
||||
for ( ; it != sections.end(); it++)
|
||||
{
|
||||
if (it->address > section.address)
|
||||
{
|
||||
if (it != sections.begin())
|
||||
--it;
|
||||
break;
|
||||
}
|
||||
}
|
||||
sections.insert(it, section);
|
||||
/// possibly merge
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static void add_replace_section(
|
||||
DataSectionList §ions,
|
||||
const DataSection §ion)
|
||||
{
|
||||
DataSectionList::iterator cur_section = sections.begin();
|
||||
for (; cur_section != sections.end(); cur_section++)
|
||||
{
|
||||
// new section starts at empty space
|
||||
if (section.address < cur_section->address)
|
||||
{
|
||||
cur_section = sections.insert(cur_section, section);
|
||||
// normalze
|
||||
break;
|
||||
}
|
||||
// new section starts in another section
|
||||
if (cur_section->next_address() > section.address)
|
||||
{
|
||||
uint_t section_offset = section.address - cur_section->address;
|
||||
|
||||
// simple case: replace a part of existing section,
|
||||
// no size change, no normalize
|
||||
if (cur_section->next_address() >= section.next_address())
|
||||
{
|
||||
std::copy(section.data.begin(), section.data.end(),
|
||||
cur_section->data.begin() + section_offset);
|
||||
return;
|
||||
}
|
||||
|
||||
// new section doen't fit current section so resize it and then
|
||||
// normalize
|
||||
cur_section->data.resize(section.next_address() - cur_section->address);
|
||||
std::copy(section.data.begin(), section.data.end(),
|
||||
cur_section->data.begin() + section_offset);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (cur_section == sections.end())
|
||||
{
|
||||
sections.push_back(section);
|
||||
/// possibly merge
|
||||
return;
|
||||
}
|
||||
|
||||
/// normalize sections:
|
||||
DataSectionList::iterator it = cur_section;
|
||||
it++;
|
||||
for (; it != sections.end(); ++it)
|
||||
{
|
||||
if (it->address >= cur_section->next_address())
|
||||
break; // need merge
|
||||
|
||||
/// old section completely overlapped by new one, remove it
|
||||
if (it->address >= cur_section->address &&
|
||||
it->next_address() <= cur_section->next_address())
|
||||
{
|
||||
it = sections.erase(it);
|
||||
continue;
|
||||
}
|
||||
/// old section party overlapped by new one, merge them
|
||||
if (it->address >= cur_section->next_address())
|
||||
{
|
||||
cur_section->data.insert(cur_section->data.end(),
|
||||
it->data.begin() + cur_section->next_address() - it->address,
|
||||
it->data.end());
|
||||
it = sections.erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
const DataSectionList &DataSectionStore::sections() const
|
||||
{ return sections_; }
|
||||
|
||||
//==============================================================================
|
||||
size_t DataSectionStore::lower_address() const
|
||||
{ return sections_.empty() ? 0 : sections_.front().address; }
|
||||
|
||||
//==============================================================================
|
||||
size_t DataSectionStore::upper_address() const
|
||||
{ return sections_.empty() ? 0 : sections_.back().next_address(); }
|
||||
|
||||
//==============================================================================
|
||||
void DataSectionStore::remove_sections()
|
||||
{ sections_.clear(); }
|
||||
|
||||
//==============================================================================
|
||||
bool DataSectionStore::add_section(const DataSection §ion, bool overwrite)
|
||||
{
|
||||
if (section.empty())
|
||||
return true;
|
||||
|
||||
if (!overwrite)
|
||||
{
|
||||
if (!check_section_fit(sections_, section))
|
||||
return false;
|
||||
add_insert_section(sections_, section);
|
||||
}
|
||||
else
|
||||
add_replace_section(sections_, section);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool DataSectionStore::add_sections(const DataSectionStore &store, bool overwrite)
|
||||
{
|
||||
if (!overwrite)
|
||||
{
|
||||
foreach (const DataSection &item, store.sections())
|
||||
{
|
||||
if (check_section_fit(sections_, item))
|
||||
return false;
|
||||
}
|
||||
foreach (const DataSection &item, store.sections())
|
||||
add_insert_section(sections_, item);
|
||||
}
|
||||
else
|
||||
foreach (const DataSection &item, store.sections())
|
||||
add_replace_section(sections_, item);
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void DataSectionStore::create_image(uint8_t filler, ByteVector &image) const
|
||||
{
|
||||
image.resize(upper_address(), 0);
|
||||
std::fill(image.begin(), image.end(), filler);
|
||||
|
||||
foreach (const DataSection §ion, sections_)
|
||||
std::copy(section.data.begin(), section.data.end(), &image[section.address]);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
size_t DataSectionStore::actual_size() const
|
||||
{
|
||||
size_t size = 0;
|
||||
|
||||
foreach (const DataSection §ion, sections_)
|
||||
size += section.data.size();
|
||||
return size;
|
||||
}
|
50
src/data/data_section_store.h
Normal file
50
src/data/data_section_store.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* data_section_store.h
|
||||
*
|
||||
* Created on: Jul 29, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _DATA_SECTION_STORE_H_
|
||||
#define _DATA_SECTION_STORE_H_
|
||||
|
||||
#include "common.h"
|
||||
#include "data_section.h"
|
||||
|
||||
/// Class store and manage a list of DataSections object in (accednig not-overlapped order)
|
||||
class DataSectionStore
|
||||
{
|
||||
public:
|
||||
/// Return sum of all sections' sizes
|
||||
size_t actual_size() const;
|
||||
|
||||
/// Return the minor valid address
|
||||
size_t lower_address() const;
|
||||
|
||||
/// Return the address next to the most one
|
||||
size_t upper_address() const;
|
||||
|
||||
/// Add section to the store
|
||||
/// @return false if section overlapped and overwrite is false
|
||||
bool add_section(const DataSection &data, bool overwrite);
|
||||
|
||||
/// Add all of DataSectionStore object's sections to the store
|
||||
/// @return false if section overlapped and overwrite is false
|
||||
bool add_sections(const DataSectionStore §ion_store, bool overwrite);
|
||||
|
||||
/// Remove all sections
|
||||
void remove_sections();
|
||||
|
||||
/// Unite all sections to one continuoys memory block
|
||||
void create_image(uint8_t filler, ByteVector &image) const;
|
||||
|
||||
const DataSectionList §ions() const;
|
||||
|
||||
private:
|
||||
DataSectionList sections_;
|
||||
};
|
||||
|
||||
#endif // !_DATA_SECTION_STORE_H_
|
143
src/data/file.cpp
Normal file
143
src/data/file.cpp
Normal file
@ -0,0 +1,143 @@
|
||||
/*
|
||||
* file.cpp
|
||||
*
|
||||
* Created on: Aug 4, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include "file.h"
|
||||
|
||||
//==============================================================================
|
||||
inline void check_open(const String &context, FILE *file)
|
||||
{
|
||||
if (!file)
|
||||
throw FileException(context + " on not opened file");
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
inline void file_io_error(const String &context, const String &file_name)
|
||||
{
|
||||
String error = context + " failed, file name: " + file_name + ": " + strerror(errno);
|
||||
|
||||
throw FileException(error);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
File::File() :
|
||||
file_(NULL)
|
||||
{ }
|
||||
|
||||
//==============================================================================
|
||||
File::~File()
|
||||
{
|
||||
if (file_ != NULL)
|
||||
fclose(file_);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void File::open(const String &file_name, const char mode[], off_t max_size)
|
||||
{
|
||||
close();
|
||||
|
||||
file_name_ = file_name;
|
||||
|
||||
file_ = fopen(file_name.c_str(), mode);
|
||||
if (file_ == NULL)
|
||||
file_io_error("File::open", file_name_);
|
||||
|
||||
if (max_size && max_size < size())
|
||||
{
|
||||
close();
|
||||
throw FileException("File " + file_name + " is too long");
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void File::close()
|
||||
{
|
||||
if (file_ != NULL)
|
||||
if (fclose(file_) < 0)
|
||||
file_io_error("File::close", file_name_);
|
||||
file_ = NULL;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
off_t File::size()
|
||||
{
|
||||
check_open("File::size", file_);
|
||||
|
||||
struct stat file_stat;
|
||||
if (fstat(fileno(file_), &file_stat) != 0)
|
||||
file_io_error("File::size", file_name_);
|
||||
|
||||
return file_stat.st_size;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
off_t File::seek(off_t offset, uint_t position)
|
||||
{
|
||||
check_open("File::seek", file_);
|
||||
|
||||
off_t result = fseeko(file_, offset, position);
|
||||
|
||||
if (result == (off_t) -1)
|
||||
file_io_error("File::seek", file_name_);
|
||||
return result;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void File::write(const uint8_t data[], size_t size)
|
||||
{
|
||||
check_open("File::write", file_);
|
||||
|
||||
if (fwrite(data, size, 1, file_) != 1 || ferror(file_))
|
||||
file_io_error("File::write", file_name_);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void File::write(const ByteVector &data)
|
||||
{
|
||||
check_open("File::write", file_);
|
||||
|
||||
if (fwrite(&data[0], data.size(), 1, file_) != 1 || ferror(file_))
|
||||
file_io_error("File::write", file_name_);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void File::read(uint8_t data[], size_t size)
|
||||
{
|
||||
check_open("File::read", file_);
|
||||
|
||||
if (fread(data, size, 1, file_) != 1 || ferror(file_))
|
||||
file_io_error("File::read", file_name_);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void File::read(ByteVector &data, size_t size)
|
||||
{
|
||||
check_open("File::read", file_);
|
||||
|
||||
data.resize(size);
|
||||
|
||||
if (fread(&data[0], data.size(), 1, file_) != 1 || ferror(file_))
|
||||
file_io_error("File::read", file_name_);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool File::read_n(uint8_t data[], size_t max_size, size_t &read_size)
|
||||
{
|
||||
check_open("File::read_max", file_);
|
||||
|
||||
ssize_t result = fread(data, 1, max_size, file_);
|
||||
if (ferror(file_))
|
||||
file_io_error("File::read_max", file_name_);
|
||||
|
||||
read_size = result;
|
||||
return feof(file_);
|
||||
}
|
47
src/data/file.h
Normal file
47
src/data/file.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* file.h
|
||||
*
|
||||
* Created on: Aug 1, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _FILE_H_
|
||||
#define _FILE_H_
|
||||
|
||||
#include "common.h"
|
||||
|
||||
class File //: boost::noncopyable
|
||||
{
|
||||
public:
|
||||
void open(const String &file_name, const char mode[], off_t max_size = 0); // throw
|
||||
void close(); // throw
|
||||
|
||||
off_t size(); // throw
|
||||
off_t seek(off_t offset, uint_t position); // throw
|
||||
|
||||
void write(const uint8_t data[], size_t size); // throw
|
||||
void write(const ByteVector &data); // throw
|
||||
|
||||
void read(uint8_t data[], size_t size); // throw
|
||||
void read(ByteVector &data, size_t size); // throw
|
||||
// return false if eof
|
||||
bool read_n(uint8_t data[], size_t max_size, size_t &read_size); // throw
|
||||
|
||||
File();
|
||||
~File();
|
||||
|
||||
private:
|
||||
FILE *file_;
|
||||
String file_name_;
|
||||
};
|
||||
|
||||
class FileException : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
FileException(const String& arg) : std::runtime_error(arg) { }
|
||||
};
|
||||
|
||||
#endif // !_FILE_H_
|
393
src/data/hex_file.cpp
Normal file
393
src/data/hex_file.cpp
Normal file
@ -0,0 +1,393 @@
|
||||
/*
|
||||
* hex_file.cpp
|
||||
*
|
||||
* Created on: Jul 22, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#include <numeric>
|
||||
#include <fstream>
|
||||
#include "file.h"
|
||||
#include "hex_file.h"
|
||||
|
||||
void file_io_error(const String &message, const String &file_name); // throw
|
||||
|
||||
class HexDataReader
|
||||
{
|
||||
public:
|
||||
enum Error
|
||||
{
|
||||
ERROR_OK,
|
||||
ERROR_RECORD_CRC_MISMATCH,
|
||||
ERROR_RECORD_NO_HEADER,
|
||||
ERROR_RECORD_BAD_FORMAT,
|
||||
ERROR_RECORD_UNKNOWN_TYPE,
|
||||
ERROR_RECORD_SIZE_MISMATCH,
|
||||
ERROR_RECORD_BAD_CHARACTER,
|
||||
ERROR_SECTION_OVERLAPPING,
|
||||
};
|
||||
|
||||
Error read_next_record(const String &record_line);
|
||||
Error read_complete();
|
||||
|
||||
HexDataReader(DataSectionStore §ions, bool ignore_crc);
|
||||
|
||||
private:
|
||||
DataSectionStore &store_;
|
||||
uint_t address_prefix_;
|
||||
bool section_started_;
|
||||
//Error error_;
|
||||
DataSection section_;
|
||||
bool ignore_crc_;
|
||||
};
|
||||
|
||||
struct Record
|
||||
{
|
||||
enum Type {
|
||||
RT_DATA = 0,
|
||||
RT_EOF = 1,
|
||||
RT_EX_SEGMENT_ADDRESS = 2,
|
||||
RT_START_SEGMENT_ADDRESS = 3,
|
||||
RT_EX_LINEAR_ADDRESS = 4,
|
||||
RT_START_LINEAR_ADDRESS = 5,
|
||||
|
||||
MAX_TYPE_NUMBER = RT_START_LINEAR_ADDRESS,
|
||||
};
|
||||
|
||||
Type type;
|
||||
uint_t address;
|
||||
ByteVector data;
|
||||
};
|
||||
|
||||
static void hex_file_error(
|
||||
const String &file_name,
|
||||
HexDataReader::Error error,
|
||||
uint_t line_number); // throw
|
||||
|
||||
//==============================================================================
|
||||
std::ostream& operator <<(std::ostream &os, const Record &o)
|
||||
{
|
||||
os << "Type: ";
|
||||
|
||||
if (o.type == Record::RT_DATA)
|
||||
os << "Data";
|
||||
if (o.type == Record::RT_EOF)
|
||||
os << "End Of File";
|
||||
if (o.type == Record::RT_EX_SEGMENT_ADDRESS)
|
||||
os << "Extended Segment Address";
|
||||
if (o.type == Record::RT_START_SEGMENT_ADDRESS)
|
||||
os << "Start Segment Address";
|
||||
if (o.type == Record::RT_EX_LINEAR_ADDRESS)
|
||||
os << "Extended Linear Address";
|
||||
if (o.type == Record::RT_START_LINEAR_ADDRESS)
|
||||
os << "Start Linear Address ";
|
||||
os << ", ";
|
||||
|
||||
os << std::uppercase << std::hex << std::setfill('0');
|
||||
os << "address: " << std::setw(8) << o.address << ", ";
|
||||
os << "size: " << std::dec << o.data.size();
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static bool hex_to_byte(char low_part, char high_part, uint8_t &out_byte)
|
||||
{
|
||||
if (!isxdigit(low_part) || !isxdigit(high_part))
|
||||
return false;
|
||||
|
||||
char buffer[3] = { low_part, high_part, 0 };
|
||||
out_byte = strtoul(buffer, NULL, 16);
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static bool hex_to_binary(const char data[], size_t size, uint8_t out[])
|
||||
{
|
||||
for (size_t i = 0; i < size; i += 2)
|
||||
{
|
||||
if (!hex_to_byte(data[i], data[i + 1], out[i / 2]))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static uint_t make_word(uint8_t low_byte, uint8_t high_byte, bool big_endian = true)
|
||||
{
|
||||
return big_endian ? (low_byte << 8) | high_byte : (high_byte << 8) | low_byte;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static HexDataReader::Error parse_record(const String &line, Record &record, bool ignore_crc)
|
||||
{
|
||||
if (line[0] != ':')
|
||||
return HexDataReader::ERROR_RECORD_NO_HEADER;
|
||||
|
||||
if (!(line.size() % 2) || line.size() > 1024)
|
||||
return HexDataReader::ERROR_RECORD_SIZE_MISMATCH;
|
||||
|
||||
size_t record_size = line.size() / 2;
|
||||
uint8_t data[record_size];
|
||||
|
||||
if (!hex_to_binary(line.c_str() + 1, line.size() - 1, data))
|
||||
return HexDataReader::ERROR_RECORD_BAD_CHARACTER;
|
||||
|
||||
uint8_t crc = 0;
|
||||
if (!ignore_crc && std::accumulate(data, data + record_size, crc) != 0)
|
||||
return HexDataReader::ERROR_RECORD_CRC_MISMATCH;
|
||||
|
||||
uint8_t data_size = data[0];
|
||||
if (data_size != (record_size - 5)) // 5 - header size
|
||||
return HexDataReader::ERROR_RECORD_SIZE_MISMATCH;
|
||||
|
||||
uint8_t record_type = data[3];
|
||||
if (record_type > Record::MAX_TYPE_NUMBER)
|
||||
return HexDataReader::ERROR_RECORD_UNKNOWN_TYPE;
|
||||
|
||||
if (record_type == Record::RT_DATA)
|
||||
record.data.assign(data + 4, data + 4 + data_size);
|
||||
else
|
||||
record.data.clear();
|
||||
|
||||
uint_t address = make_word(data[1], data[2]);
|
||||
|
||||
if (record_type == Record::RT_EX_SEGMENT_ADDRESS)
|
||||
{
|
||||
if (data_size != 2 || address)
|
||||
return HexDataReader::ERROR_RECORD_BAD_FORMAT;
|
||||
|
||||
address = make_word(data[4], data[5]) << 4;
|
||||
}
|
||||
|
||||
if (record_type == Record::RT_EX_LINEAR_ADDRESS)
|
||||
{
|
||||
if (data_size != 2 || address)
|
||||
return HexDataReader::ERROR_RECORD_BAD_FORMAT;
|
||||
|
||||
address = make_word(data[4], data[5]) << 16;
|
||||
}
|
||||
|
||||
record.type = (Record::Type)record_type;
|
||||
record.address = address;
|
||||
|
||||
return HexDataReader::ERROR_OK;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
HexDataReader::HexDataReader(DataSectionStore &store, bool ignore_crc) :
|
||||
store_(store),
|
||||
address_prefix_(0),
|
||||
section_started_(false),
|
||||
ignore_crc_(ignore_crc)
|
||||
{ }
|
||||
|
||||
// Do not pass empty lines here!
|
||||
//==============================================================================
|
||||
HexDataReader::Error HexDataReader::read_next_record(const String &record_line)
|
||||
{
|
||||
Record record;
|
||||
|
||||
HexDataReader::Error error = parse_record(record_line, record, ignore_crc_);
|
||||
if (error != ERROR_OK)
|
||||
return error;
|
||||
|
||||
if (record.type == Record::RT_EOF)
|
||||
return ERROR_OK;
|
||||
|
||||
if (record.type == Record::RT_DATA)
|
||||
{
|
||||
record.address |= address_prefix_;
|
||||
if (section_started_ && section_.next_address() != record.address)
|
||||
{
|
||||
if (!store_.add_section(section_, false))
|
||||
return ERROR_SECTION_OVERLAPPING;
|
||||
|
||||
section_.data.clear();
|
||||
section_started_ = false;
|
||||
}
|
||||
|
||||
if (!section_started_)
|
||||
{
|
||||
section_started_ = true;
|
||||
section_.address = record.address;
|
||||
}
|
||||
section_.data.insert(section_.data.end(), record.data.begin(), record.data.end());
|
||||
}
|
||||
if (record.type == Record::RT_EX_SEGMENT_ADDRESS)
|
||||
address_prefix_ = record.address;
|
||||
|
||||
if (record.type == Record::RT_EX_LINEAR_ADDRESS)
|
||||
address_prefix_ = record.address;
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
HexDataReader::Error HexDataReader::read_complete()
|
||||
{
|
||||
if (section_started_ && !store_.add_section(section_, false))
|
||||
return ERROR_SECTION_OVERLAPPING;
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void hex_file_load(const String &file_name,
|
||||
DataSectionStore §ion_store, bool ignore_crc_mismatch)
|
||||
{
|
||||
std::ifstream in(file_name.c_str());
|
||||
if (!in)
|
||||
throw std::runtime_error("Unable to open file " + file_name);
|
||||
|
||||
HexDataReader::Error error = HexDataReader::ERROR_OK;
|
||||
uint_t line_number = 0;
|
||||
|
||||
HexDataReader reader(section_store, ignore_crc_mismatch);
|
||||
String record_line;
|
||||
while (in)
|
||||
{
|
||||
line_number++;
|
||||
std::getline(in, record_line);
|
||||
|
||||
if (!record_line.empty() && *record_line.rbegin() == '\r')
|
||||
record_line.erase(record_line.end() - 1);
|
||||
|
||||
if (record_line.empty())
|
||||
continue;
|
||||
|
||||
error = reader.read_next_record(record_line);
|
||||
if (error != HexDataReader::ERROR_OK)
|
||||
hex_file_error(file_name, error, line_number);
|
||||
}
|
||||
|
||||
error = reader.read_complete();
|
||||
if (error != HexDataReader::ERROR_OK)
|
||||
hex_file_error(file_name, error, line_number);
|
||||
|
||||
//return section_store;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static void write_eof_record(std::ostream &out)
|
||||
{
|
||||
out << ":00000001FF";
|
||||
out << "\n";
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static void write_data_record(std::ostream &out, uint_t address,
|
||||
const uint8_t data[], size_t size)
|
||||
{
|
||||
const uint8_t buffer[] = { size, address >> 8, address, 0x00 };
|
||||
|
||||
uint8_t crc = 0;
|
||||
crc = std::accumulate(buffer, buffer + ARRAY_SIZE(buffer), crc);
|
||||
crc = std::accumulate(data, data + size, crc);
|
||||
crc = 0x100 - crc;
|
||||
|
||||
out << ":";
|
||||
out << binary_to_hex(buffer, ARRAY_SIZE(buffer));
|
||||
out << binary_to_hex(data, size);
|
||||
out << binary_to_hex(&crc, 1);
|
||||
out << "\r\n";
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static void write_segment_record(std::ostream &out, uint16_t address)
|
||||
{
|
||||
const uint8_t buffer[] = { 0x02, 0x00, 0x00, 0x02, address >> 8, address };
|
||||
|
||||
uint8_t crc = 0;
|
||||
crc = 0x100 - std::accumulate(buffer, buffer + ARRAY_SIZE(buffer), crc);
|
||||
|
||||
out << ":";
|
||||
out << binary_to_hex(buffer, ARRAY_SIZE(buffer));
|
||||
out << binary_to_hex(&crc, 1);
|
||||
out << "\r\n";
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void hex_file_save(const String &file_name, const DataSectionStore §ion_store)
|
||||
{
|
||||
std::ofstream out(file_name.c_str());
|
||||
if (!out)
|
||||
throw FileException("Unable to open file" + file_name);
|
||||
|
||||
uint_t offset = 0;
|
||||
foreach (const DataSection §ion, section_store.sections())
|
||||
{
|
||||
uint_t address = section.address;
|
||||
uint_t size = section.size();
|
||||
|
||||
while (size)
|
||||
{
|
||||
if ((address - offset) > 0xFFFF)
|
||||
{
|
||||
offset = address & ~0x0F;
|
||||
write_segment_record(out, offset >> 4);
|
||||
}
|
||||
|
||||
const uint_t RECORD_MAX_DATA_SIZE = 16;
|
||||
const uint_t record_size = std::min(RECORD_MAX_DATA_SIZE, size);
|
||||
|
||||
write_data_record(out,
|
||||
address - offset,
|
||||
§ion.data[address - section.address],
|
||||
record_size);
|
||||
|
||||
address += record_size;
|
||||
size -= record_size;
|
||||
}
|
||||
}
|
||||
write_eof_record(out);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static void hex_file_error(
|
||||
const String &file_name,
|
||||
HexDataReader::Error error,
|
||||
uint_t line_number)
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
ss << "File '" << file_name << "' load error: ";
|
||||
|
||||
switch (error)
|
||||
{
|
||||
case HexDataReader::ERROR_RECORD_CRC_MISMATCH:
|
||||
ss << "CRC mismatch, line: " << line_number;
|
||||
break;
|
||||
|
||||
case HexDataReader::ERROR_RECORD_NO_HEADER:
|
||||
ss << "Record header not found, line: " << line_number;
|
||||
break;
|
||||
|
||||
case HexDataReader::ERROR_RECORD_BAD_FORMAT:
|
||||
ss << "Record format error, line: " << line_number;
|
||||
break;
|
||||
|
||||
case HexDataReader::ERROR_RECORD_UNKNOWN_TYPE:
|
||||
ss << "Unknown record type, line: " << line_number;
|
||||
break;
|
||||
|
||||
case HexDataReader::ERROR_RECORD_SIZE_MISMATCH:
|
||||
ss << "Record size mismatch, line: " << line_number;
|
||||
break;
|
||||
|
||||
case HexDataReader::ERROR_RECORD_BAD_CHARACTER:
|
||||
ss << "Unexpected character, line: " << line_number;
|
||||
break;
|
||||
|
||||
case HexDataReader::ERROR_SECTION_OVERLAPPING:
|
||||
ss << "Sections overlapped";
|
||||
|
||||
case HexDataReader::ERROR_OK:
|
||||
default:
|
||||
ss << "ok";
|
||||
}
|
||||
|
||||
throw FileException(ss.str());
|
||||
}
|
29
src/data/hex_file.h
Normal file
29
src/data/hex_file.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* hex_file.h
|
||||
*
|
||||
* Created on: Jul 15, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _HEX_FILE_H_
|
||||
#define _HEX_FILE_H_
|
||||
|
||||
#include "common.h"
|
||||
#include "data_section_store.h"
|
||||
|
||||
class HexFile
|
||||
{
|
||||
public:
|
||||
static DataSectionStore& load(const String &file_name,
|
||||
DataSectionStore §ion_store, bool ignore_crc_mismatch = false);
|
||||
|
||||
static void save(const String &file_name, const DataSectionStore §ion_store);
|
||||
};
|
||||
|
||||
void hex_file_load(const String &file_name, DataSectionStore §ion_store, bool ignore_crc_mismatch = false);
|
||||
void hex_file_save(const String &file_name, const DataSectionStore §ion_store);
|
||||
|
||||
#endif // !_HEX_FILE_H_
|
98
src/data/progress_watcher.cpp
Normal file
98
src/data/progress_watcher.cpp
Normal file
@ -0,0 +1,98 @@
|
||||
/*
|
||||
* progress_watcher.cpp
|
||||
*
|
||||
* Created on: Nov 12, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#include "progress_watcher.h"
|
||||
|
||||
//==============================================================================
|
||||
void ProgressWatcher::do_on_read_progress(const OnProgress::slot_type &slot)
|
||||
{ on_read_progress_.connect(slot); }
|
||||
|
||||
//==============================================================================
|
||||
void ProgressWatcher::do_on_write_progress(const OnProgress::slot_type &slot)
|
||||
{ on_write_progress_.connect(slot); }
|
||||
|
||||
//==============================================================================
|
||||
void ProgressWatcher::read_progress(uint_t done_chunk)
|
||||
{
|
||||
if (enabled_ && read_started_ && done_chunk)
|
||||
{
|
||||
done_read_ += done_chunk;
|
||||
on_read_progress_(done_read_, total_read_);
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void ProgressWatcher::write_progress(uint_t done_chunk)
|
||||
{
|
||||
if (enabled_ && write_started_ && done_chunk)
|
||||
{
|
||||
done_write_ += done_chunk;
|
||||
on_write_progress_(done_write_, total_write_);
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void ProgressWatcher::read_start(size_t total_size)
|
||||
{
|
||||
if (!enabled_)
|
||||
return;
|
||||
|
||||
read_started_ = true;
|
||||
total_read_ = total_size;
|
||||
done_read_ = 0;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void ProgressWatcher::read_finish()
|
||||
{
|
||||
if (!enabled_)
|
||||
return;
|
||||
|
||||
read_started_ = false;
|
||||
if (done_read_ != total_read_)
|
||||
on_read_progress_(total_read_, total_read_);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void ProgressWatcher::write_start(size_t total_size)
|
||||
{
|
||||
if (!enabled_)
|
||||
return;
|
||||
|
||||
write_started_ = true;
|
||||
total_write_ = total_size;
|
||||
done_write_ = 0;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void ProgressWatcher::write_finish()
|
||||
{
|
||||
if (!enabled_)
|
||||
return;
|
||||
|
||||
write_started_ = false;
|
||||
if (done_write_ != total_write_)
|
||||
on_write_progress_(done_write_, total_write_);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void ProgressWatcher::enable(bool enable)
|
||||
{ enabled_ = enable; }
|
||||
|
||||
//==============================================================================
|
||||
ProgressWatcher::ProgressWatcher() :
|
||||
total_read_(0),
|
||||
total_write_(0),
|
||||
read_started_(false),
|
||||
write_started_(false),
|
||||
done_read_(0),
|
||||
done_write_(0),
|
||||
enabled_(true)
|
||||
{ }
|
50
src/data/progress_watcher.h
Normal file
50
src/data/progress_watcher.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* progress_watcher.h
|
||||
*
|
||||
* Created on: Nov 12, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _PROGRESS_WATCHER_H_
|
||||
#define _PROGRESS_WATCHER_H_
|
||||
|
||||
#include "common.h"
|
||||
#include <boost/signals2.hpp>
|
||||
|
||||
class ProgressWatcher : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
typedef boost::signals2::signal<void (uint_t done_size, uint_t full_size)> OnProgress;
|
||||
|
||||
void do_on_read_progress(const OnProgress::slot_type &slot);
|
||||
void do_on_write_progress(const OnProgress::slot_type &slot);
|
||||
|
||||
void read_progress(uint_t done_chunk);
|
||||
void write_progress(uint_t done_chunk);
|
||||
|
||||
void read_start(size_t total_size);
|
||||
void read_finish();
|
||||
|
||||
void write_start(size_t total_size);
|
||||
void write_finish();
|
||||
|
||||
void enable(bool enable);
|
||||
|
||||
ProgressWatcher();
|
||||
|
||||
private:
|
||||
uint_t total_read_;
|
||||
uint_t total_write_;
|
||||
bool read_started_;
|
||||
bool write_started_;
|
||||
uint_t done_read_;
|
||||
uint_t done_write_;
|
||||
bool enabled_;
|
||||
OnProgress on_read_progress_;
|
||||
OnProgress on_write_progress_;
|
||||
};
|
||||
|
||||
#endif // !_PROGRESS_WATCHER_H_
|
97
src/data/read_target.cpp
Normal file
97
src/data/read_target.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* read_traget.cpp
|
||||
*
|
||||
* Created on: Oct 31, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include "data/data_section_store.h"
|
||||
#include "data/hex_file.h"
|
||||
#include "data/binary_file.h"
|
||||
#include "read_target.h"
|
||||
#include "common/common.h"
|
||||
|
||||
//==============================================================================
|
||||
ReadTarget::ReadTarget() :
|
||||
source_type_(ST_CONSOLE)
|
||||
{ }
|
||||
|
||||
//==============================================================================
|
||||
ReadTarget::SourceType ReadTarget::source_type() const
|
||||
{ return source_type_; }
|
||||
|
||||
//==============================================================================
|
||||
void ReadTarget::on_read(const ByteVector &data) const
|
||||
{
|
||||
if (file_format_ == "hex")
|
||||
{
|
||||
DataSectionStore store;
|
||||
store.add_section(DataSection(0, data), true);
|
||||
hex_file_save(file_name_, store);
|
||||
}
|
||||
if (file_format_ == "bin")
|
||||
binary_file_save(file_name_, data);
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
void ReadTarget::set_source(const String &input)
|
||||
{
|
||||
if (input.empty())
|
||||
source_type_ = ST_CONSOLE;
|
||||
else
|
||||
{
|
||||
OptionFileInfo file_info;
|
||||
option_extract_file_info(input, file_info, false);
|
||||
|
||||
source_type_ = ST_FILE;
|
||||
file_format_ = file_info.type;
|
||||
file_name_ = file_info.name;
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void option_extract_file_info(const String &input, OptionFileInfo &file_info,
|
||||
bool support_offset)
|
||||
{
|
||||
StringVector strs;
|
||||
boost::split(strs, input, boost::is_any_of(":"));
|
||||
|
||||
if (strs.size() > 3)
|
||||
throw std::runtime_error("bad file name format (" + input + ")");
|
||||
|
||||
file_info.offset = 0;
|
||||
file_info.name = strs[0];
|
||||
if (strs.size() > 1)
|
||||
file_info.type = strs[1];
|
||||
if (file_info.type.empty())
|
||||
{
|
||||
file_info.type = boost::filesystem::extension(file_info.name);
|
||||
if (file_info.type[0] == '.')
|
||||
file_info.type.erase(0, 1);
|
||||
}
|
||||
|
||||
if (strs.size() > 2)
|
||||
{
|
||||
if (!string_to_number(strs[2], file_info.offset))
|
||||
throw std::runtime_error("bad offset value (" + input + ")");
|
||||
|
||||
if (!support_offset)
|
||||
throw std::runtime_error("offset is not allowed here (" + input + ")");
|
||||
}
|
||||
|
||||
String type;
|
||||
|
||||
if (file_info.type.empty() || file_info.type == "bin" || file_info.type == "binary")
|
||||
type = "bin";
|
||||
if (file_info.type == "hex" || file_info.type == "ihex")
|
||||
type = "hex";
|
||||
if (type.empty())
|
||||
throw std::runtime_error("unknown file type (" + input + ")");
|
||||
file_info.type = type;
|
||||
}
|
43
src/data/read_target.h
Normal file
43
src/data/read_target.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* read_traget.h
|
||||
*
|
||||
* Created on: Oct 31, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _READ_TARGET_H_
|
||||
#define _READ_TARGET_H_
|
||||
|
||||
#include "common.h"
|
||||
|
||||
struct OptionFileInfo
|
||||
{
|
||||
String type;
|
||||
String name;
|
||||
size_t offset;
|
||||
};
|
||||
|
||||
void option_extract_file_info(const String &input, OptionFileInfo &file_info,
|
||||
bool support_offset);
|
||||
|
||||
class ReadTarget
|
||||
{
|
||||
public:
|
||||
enum SourceType { ST_CONSOLE, ST_FILE };
|
||||
|
||||
SourceType source_type() const;
|
||||
void set_source(const String &input);
|
||||
void on_read(const ByteVector &data) const;
|
||||
|
||||
ReadTarget();
|
||||
|
||||
private:
|
||||
String file_format_;
|
||||
String file_name_;
|
||||
SourceType source_type_;
|
||||
};
|
||||
|
||||
#endif // !_READ_TARGET_H_
|
20
src/main.cpp
Normal file
20
src/main.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
/*
|
||||
* main.cpp
|
||||
*
|
||||
* Created on: Jul 28, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#include "application/cc_flasher.h"
|
||||
|
||||
//==============================================================================
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CC_Flasher cc_flasher;
|
||||
cc_flasher.execute(argc, argv);
|
||||
|
||||
return 0;
|
||||
}
|
120
src/programmer/cc_243x.cpp
Normal file
120
src/programmer/cc_243x.cpp
Normal file
@ -0,0 +1,120 @@
|
||||
/*
|
||||
* cc_243x.cpp
|
||||
*
|
||||
* Created on: Nov 9, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#include "log.h"
|
||||
#include "cc_debug_interface.h"
|
||||
#include "cc_243x.h"
|
||||
|
||||
const uint16_t XREG_FMAP = 0xDF9F;
|
||||
|
||||
//==============================================================================
|
||||
CC_243x::CC_243x(USB_Device &programmer, ProgressWatcher &pw) :
|
||||
CC_UnitDriver(programmer, pw)
|
||||
{
|
||||
UnitCoreInfo reg_info;
|
||||
|
||||
reg_info.flash_word_size = 4;
|
||||
reg_info.write_block_size = 1024;
|
||||
reg_info.verify_block_size = 1024;
|
||||
reg_info.xbank_offset = 0x8000;
|
||||
reg_info.dma0_cfg_offset = 0x0800;
|
||||
reg_info.dma_data_offset = 0x0000;
|
||||
|
||||
reg_info.memctr = 0xDFC7;
|
||||
reg_info.fmap = XREG_FMAP;
|
||||
reg_info.faddrh = 0xDFAD;
|
||||
reg_info.faddrl = 0xDFAC;
|
||||
reg_info.fctl = 0xDFAE;
|
||||
reg_info.fwdata = 0xDFAF;//
|
||||
reg_info.rndh = 0xDFBD;
|
||||
reg_info.rndl = 0xDFBC;
|
||||
reg_info.dma0_cfgh = 0xDFD5;
|
||||
reg_info.dma0_cfgl = 0xDFD4;
|
||||
reg_info.dma_arm = 0xDFD6;
|
||||
reg_info.dma_req = 0xDFD7;
|
||||
reg_info.dma_irq = 0xDFD1;
|
||||
|
||||
reg_info.fctl_write = 0x02;
|
||||
|
||||
set_reg_info(reg_info);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_243x::supported_units(Unit_ID_List &units)
|
||||
{
|
||||
units.push_back(Unit_ID(0x2430, "CC2430"));
|
||||
units.push_back(Unit_ID(0x2431, "CC2431"));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_243x::find_unit_info(UnitInfo &unit_info)
|
||||
{
|
||||
unit_info.flags = UnitInfo::SUPPORT_MAC_ADDRESS;
|
||||
unit_info.lock_size = 1;
|
||||
unit_info.max_flash_size = 128;
|
||||
unit_info.flash_page_size = 2048;
|
||||
unit_info.mac_address_count = 1;
|
||||
|
||||
ByteVector sfr;
|
||||
|
||||
read_xdata_memory(0xDF60, 2, sfr);
|
||||
unit_info.revision = sfr[0];
|
||||
unit_info.internal_ID = sfr[1];
|
||||
|
||||
// Possible flash sizes: 32, 64, 128
|
||||
log_info("! getting flash size");///
|
||||
|
||||
unit_info.flash_size = 32;
|
||||
for (uint8_t i = 1; i < 3; i++)
|
||||
{
|
||||
write_xdata_memory(XREG_FMAP, i);
|
||||
uint8_t result = read_xdata_memory(XREG_FMAP);
|
||||
if (result != i)
|
||||
{
|
||||
log_info("%02Xh, n: %02Xh", i, result);
|
||||
break;
|
||||
}
|
||||
unit_info.flash_size = 32 << i;
|
||||
}
|
||||
|
||||
unit_info_ = unit_info;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool CC_243x::erase_check_comleted()
|
||||
{
|
||||
uint8_t status = 0;
|
||||
|
||||
read_debug_status(status);
|
||||
return (status & DEBUG_STATUS_CHIP_ERASE_BUSY);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_243x::mac_address_read(size_t index, ByteVector &mac_address)
|
||||
{ read_xdata_memory(0xDF43, 8, mac_address); }
|
||||
|
||||
//==============================================================================
|
||||
void CC_243x::mac_address_write(ByteVector &mac_address)
|
||||
{ }
|
||||
|
||||
//==============================================================================
|
||||
void CC_243x::flash_write(const DataSectionStore §ions)
|
||||
{ write_flash_slow(sections); }
|
||||
|
||||
//==============================================================================
|
||||
void CC_243x::flash_read_block(size_t offset, size_t size, ByteVector &data)
|
||||
{ flash_large_read_block(offset, size, data); }
|
||||
|
||||
//==============================================================================
|
||||
bool CC_243x::lock_write(const ByteVector &data)
|
||||
{
|
||||
write_lock_to_info_page(data[0]);
|
||||
return true;
|
||||
}
|
35
src/programmer/cc_243x.h
Normal file
35
src/programmer/cc_243x.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* cc_243x.h
|
||||
*
|
||||
* Created on: Nov 9, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CC_243X_H_
|
||||
#define _CC_243X_H_
|
||||
|
||||
#include "cc_unit_driver.h"
|
||||
|
||||
class CC_243x : public CC_UnitDriver
|
||||
{
|
||||
public:
|
||||
virtual void supported_units(Unit_ID_List &units);
|
||||
virtual void find_unit_info(UnitInfo &info);
|
||||
|
||||
virtual bool erase_check_comleted();
|
||||
|
||||
virtual void mac_address_read(size_t index, ByteVector &mac_address);
|
||||
virtual void mac_address_write(ByteVector &mac_address);
|
||||
|
||||
virtual void flash_write(const DataSectionStore §ions);
|
||||
virtual void flash_read_block(size_t offset, size_t size, ByteVector &data);
|
||||
|
||||
virtual bool lock_write(const ByteVector &data);
|
||||
|
||||
CC_243x(USB_Device &programmer, ProgressWatcher &pw);
|
||||
};
|
||||
|
||||
#endif // !_CC_243X_H_
|
92
src/programmer/cc_251x_111x.cpp
Normal file
92
src/programmer/cc_251x_111x.cpp
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* cc_251x_111x.cpp
|
||||
*
|
||||
* Created on: Nov 10, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cc_251x_111x.h"
|
||||
#include "cc_debug_interface.h"
|
||||
|
||||
//==============================================================================
|
||||
CC_251x_111x::CC_251x_111x(USB_Device &programmer, ProgressWatcher &pw) :
|
||||
CC_UnitDriver(programmer, pw)
|
||||
{
|
||||
UnitCoreInfo reg_info;
|
||||
|
||||
reg_info.flash_word_size = 2;
|
||||
reg_info.verify_block_size = 512;
|
||||
reg_info.write_block_size = 512;
|
||||
reg_info.xbank_offset = 0;
|
||||
reg_info.dma0_cfg_offset = 0xFF00;
|
||||
reg_info.dma_data_offset = 0xF000;
|
||||
|
||||
reg_info.rndh = 0xDFBD;
|
||||
reg_info.rndl = 0xDFBC;
|
||||
reg_info.dma0_cfgh = 0xDFD5;
|
||||
reg_info.dma0_cfgl = 0xDFD4;
|
||||
reg_info.dma_arm = 0xDFD6;
|
||||
reg_info.dma_req = 0xDFD7;
|
||||
reg_info.dma_irq = 0xDFD1;
|
||||
reg_info.fctl = 0xDFAE;
|
||||
reg_info.fwdata = 0xDFAF;
|
||||
reg_info.faddrl = 0xDFAC;
|
||||
reg_info.faddrh = 0xDFAD;
|
||||
|
||||
reg_info.fctl_write = 0x02;
|
||||
|
||||
set_reg_info(reg_info);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_251x_111x::supported_units(Unit_ID_List &units)
|
||||
{
|
||||
units.push_back(Unit_ID(0x2510, "CC2510"));
|
||||
units.push_back(Unit_ID(0x2511, "CC2511"));
|
||||
units.push_back(Unit_ID(0x1111, "CC1110"));
|
||||
units.push_back(Unit_ID(0x1110, "CC1111"));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_251x_111x::find_unit_info(UnitInfo &unit_info)
|
||||
{
|
||||
unit_info.lock_size = 1;
|
||||
unit_info.max_flash_size = 32;
|
||||
unit_info.flash_page_size = 1024;
|
||||
unit_info.mac_address_count = 1;
|
||||
|
||||
ByteVector sfr;
|
||||
|
||||
read_xdata_memory(0xDF36, 2, sfr);
|
||||
unit_info.revision = sfr[0];
|
||||
unit_info.internal_ID = sfr[1];
|
||||
|
||||
unit_info_ = unit_info;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool CC_251x_111x::erase_check_comleted()
|
||||
{
|
||||
uint8_t status = 0;
|
||||
|
||||
read_debug_status(status);
|
||||
return (status & DEBUG_STATUS_CHIP_ERASE_BUSY);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_251x_111x::flash_read_block(size_t offset, size_t size, ByteVector &data)
|
||||
{ flash_read_32k(offset, size, data); }
|
||||
|
||||
//==============================================================================
|
||||
void CC_251x_111x::flash_write(const DataSectionStore §ions)
|
||||
{ write_flash_slow(sections); }
|
||||
|
||||
//==============================================================================
|
||||
bool CC_251x_111x::lock_write(const ByteVector &data)
|
||||
{
|
||||
write_lock_to_info_page(data[0]);
|
||||
return true;
|
||||
}
|
32
src/programmer/cc_251x_111x.h
Normal file
32
src/programmer/cc_251x_111x.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* cc_251x_111x.h
|
||||
*
|
||||
* Created on: Nov 9, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CC_251X_111X_H_
|
||||
#define _CC_251X_111X_H_
|
||||
|
||||
#include "cc_unit_driver.h"
|
||||
|
||||
class CC_251x_111x : public CC_UnitDriver
|
||||
{
|
||||
public:
|
||||
virtual void supported_units(Unit_ID_List &units);
|
||||
virtual void find_unit_info(UnitInfo &info);
|
||||
|
||||
virtual bool erase_check_comleted();
|
||||
|
||||
virtual void flash_write(const DataSectionStore §ions);
|
||||
virtual void flash_read_block(size_t offset, size_t size, ByteVector &data);
|
||||
|
||||
virtual bool lock_write(const ByteVector &data);
|
||||
|
||||
CC_251x_111x(USB_Device &programmer, ProgressWatcher &pw);
|
||||
};
|
||||
|
||||
#endif // !_CC_251X_111X_H_
|
315
src/programmer/cc_253x_2540.cpp
Normal file
315
src/programmer/cc_253x_2540.cpp
Normal file
@ -0,0 +1,315 @@
|
||||
/*
|
||||
* cc_253x_2540.cpp
|
||||
*
|
||||
* Created on: Aug 4, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#include "log.h"
|
||||
#include "cc_253x_2540.h"
|
||||
|
||||
const size_t LOCK_DATA_SIZE = 16;
|
||||
const size_t INFO_PAGE_OFFSET = 0x7800;
|
||||
const size_t INFO_PAGE_SIZE = 0x800;
|
||||
|
||||
const uint16_t XREG_DBGDATA = 0x6260;
|
||||
const uint16_t XREG_FWDATA = 0x6273;
|
||||
const uint16_t XREG_FCTL = 0x6270;
|
||||
const uint16_t XREG_FADDRL = 0x6271;
|
||||
const uint16_t XREG_FADDRH = 0x6272;
|
||||
const uint16_t XREG_DMA1CFGL = 0x70D2;
|
||||
const uint16_t XREG_DMA1CFGH = 0x70D3;
|
||||
const uint16_t XREG_DMAARM = 0x70D6;
|
||||
const uint16_t XREG_DMAREQ = 0x70D7;
|
||||
const uint16_t XREG_DMAIRQ = 0x70D1;
|
||||
|
||||
const uint16_t XREG_MEMCTR = 0x70C7;
|
||||
const uint16_t XREG_FMAP = 0x709F;
|
||||
|
||||
//==============================================================================
|
||||
CC_253x_2540::CC_253x_2540(USB_Device &usb_device, ProgressWatcher &pw) :
|
||||
CC_UnitDriver(usb_device, pw)
|
||||
{
|
||||
UnitCoreInfo reg_info;
|
||||
|
||||
reg_info.flash_word_size = 4;
|
||||
reg_info.write_block_size = 1024;
|
||||
reg_info.verify_block_size = 1024;
|
||||
reg_info.xbank_offset = 0x8000;
|
||||
reg_info.dma0_cfg_offset = 0x0800;
|
||||
reg_info.dma_data_offset = 0x0000;
|
||||
|
||||
reg_info.memctr = XREG_MEMCTR;
|
||||
reg_info.fmap = XREG_FMAP;
|
||||
reg_info.faddrh = XREG_FADDRH;
|
||||
reg_info.faddrl = XREG_FADDRL;
|
||||
reg_info.fctl = XREG_FCTL;
|
||||
reg_info.fwdata = XREG_FWDATA;
|
||||
reg_info.rndh = 0x70BD;
|
||||
reg_info.rndl = 0x70BC;
|
||||
reg_info.dma0_cfgh = 0x70D5;
|
||||
reg_info.dma0_cfgl = 0x70D4;
|
||||
reg_info.dma_arm = XREG_DMAARM;
|
||||
reg_info.dma_req = XREG_DMAREQ;
|
||||
reg_info.dma_irq = XREG_DMAIRQ;
|
||||
|
||||
reg_info.fctl_write = 0x06;
|
||||
|
||||
set_reg_info(reg_info);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_253x_2540::supported_units(Unit_ID_List &units)
|
||||
{
|
||||
units.push_back(Unit_ID(0x2540, "CC2540"));
|
||||
units.push_back(Unit_ID(0x2530, "CC2530"));
|
||||
units.push_back(Unit_ID(0x2531, "CC2531"));
|
||||
units.push_back(Unit_ID(0x2533, "CC2533"));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_253x_2540::find_unit_info(UnitInfo &unit_info)
|
||||
{
|
||||
ByteVector sfr;
|
||||
read_xdata_memory(0x6276, 2, sfr);
|
||||
|
||||
unit_info.flags = UnitInfo::SUPPORT_MAC_ADDRESS | UnitInfo::SUPPORT_INFO_PAGE;
|
||||
|
||||
if (sfr[0] & 0x08)
|
||||
unit_info.flags |= UnitInfo::SUPPORT_USB;
|
||||
|
||||
unit_info.ram_size = (sfr[1] & 0x07) + 1;
|
||||
|
||||
switch ((sfr[0] >> 4) & 0x07)
|
||||
{
|
||||
case 0x01:
|
||||
unit_info.flash_size = 32;
|
||||
break;
|
||||
case 0x02:
|
||||
unit_info.flash_size = 64;
|
||||
break;
|
||||
case 0x03:
|
||||
unit_info.flash_size = (unit_info.ID == 0x2533) ? 96 : 128;
|
||||
break;
|
||||
case 0x04:
|
||||
unit_info.flash_size = 256;
|
||||
break;
|
||||
}
|
||||
|
||||
///unit_info.flash_size = 64;////
|
||||
|
||||
unit_info.lock_size = 16;
|
||||
unit_info.flash_page_size = (unit_info.ID == 0x2533) ? 1 : 2;
|
||||
unit_info.max_flash_size = (unit_info.ID == 0x2533) ? 96 : 256;
|
||||
unit_info_.mac_address_count = 2;
|
||||
|
||||
read_xdata_memory(0x6249, 1, sfr);
|
||||
unit_info.revision = sfr[0];
|
||||
|
||||
read_xdata_memory(0x624A, 1, sfr);
|
||||
unit_info.internal_ID = sfr[0];
|
||||
|
||||
unit_info_ = unit_info;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_253x_2540::read_info_page(ByteVector &info_page)
|
||||
{
|
||||
log_info("programmer, read info page");
|
||||
|
||||
size_t address = INFO_PAGE_OFFSET;
|
||||
size_t total_size = INFO_PAGE_SIZE;
|
||||
ByteVector data;
|
||||
|
||||
while (total_size)
|
||||
{
|
||||
size_t count = std::min(XDATA_READ_CHUNK_SIZE, total_size);
|
||||
read_xdata_memory(address, count, data);
|
||||
info_page.insert(info_page.end(), data.begin(), data.end());
|
||||
total_size -= count;
|
||||
address += count;
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_253x_2540::mac_address_read(size_t index, ByteVector &mac_address)
|
||||
{
|
||||
log_info("programmer, read mac address %u", index);
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
if (unit_info_.ID != 0x2540)
|
||||
read_xdata_memory(0x780E, 8, mac_address);
|
||||
else
|
||||
read_xdata_memory(0x780C, 6, mac_address);
|
||||
}
|
||||
if (index == 1)
|
||||
{
|
||||
size_t size = unit_info_.ID == 0x2540 ? 6 : 8;
|
||||
size_t offset = unit_info_.flash_page_size * 1024 - LOCK_DATA_SIZE - size;
|
||||
|
||||
flash_read_start();
|
||||
flash_read_block(offset, size, mac_address);
|
||||
flash_read_end();
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_253x_2540::mac_address_write(ByteVector &mac_address)
|
||||
{ }
|
||||
|
||||
//==============================================================================
|
||||
bool CC_253x_2540::erase_check_comleted()
|
||||
{
|
||||
log_info("programmer, check erase is completed");
|
||||
|
||||
uint8_t status = 0;
|
||||
|
||||
read_debug_status(status);
|
||||
return !(status & DEBUG_STATUS_CHIP_ERASE_BUSY);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_253x_2540::flash_select_bank(uint_t bank)
|
||||
{
|
||||
log_info("programmer, set flash bank %u", bank);
|
||||
|
||||
uint8_t command[] = { 0xBE, 0x57, 0x75, 0x9F, bank };
|
||||
|
||||
usb_device_.bulk_write(ENDPOINT_OUT, sizeof(command), &command[0]);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_253x_2540::flash_read_block(size_t offset, size_t size, ByteVector &data)
|
||||
{ flash_large_read_block(offset, size, data); }
|
||||
|
||||
//==============================================================================
|
||||
bool CC_253x_2540::lock_write(const ByteVector &lock_data)
|
||||
{
|
||||
pw_.enable(false);
|
||||
|
||||
DataSection section(unit_info_.flash_size * 1024 - lock_data.size(), lock_data);
|
||||
DataSectionStore store;
|
||||
store.add_section(section, true);
|
||||
write_flash_slow(store);
|
||||
|
||||
ByteVector read_data;
|
||||
flash_read_start();
|
||||
flash_read_block(section.address, section.size(), read_data);
|
||||
bool result = !memcmp(&read_data[0], §ion.data[0], section.size());
|
||||
flash_read_end();
|
||||
return result;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_253x_2540::flash_write(const DataSectionStore §ions)
|
||||
{
|
||||
// write_flash_slow(sections);
|
||||
// return;
|
||||
|
||||
// Buffers
|
||||
const uint16_t ADDR_BUF0 = 0x0000; // 1K
|
||||
const uint16_t ADDR_BUF1 = 0x0400; // 1K
|
||||
const uint16_t ADDR_DMA_DESC = 0x0800; // 32 bytes
|
||||
|
||||
// DMA Channels
|
||||
const uint8_t CH_DBG_TO_BUF0 = 0x02;
|
||||
const uint8_t CH_DBG_TO_BUF1 = 0x04;
|
||||
const uint8_t CH_BUF0_TO_FLASH = 0x08;
|
||||
const uint8_t CH_BUF1_TO_FLASH = 0x10;
|
||||
|
||||
const uint16_t PROG_BLOCK_SIZE = 1024;
|
||||
|
||||
const uint8_t dma_desc[32] = {
|
||||
// Debug Interface -> Buffer 0 (Channel 1)
|
||||
HIBYTE(XREG_DBGDATA), // src[15:8]
|
||||
LOBYTE(XREG_DBGDATA), // src[7:0]
|
||||
HIBYTE(ADDR_BUF0), // dest[15:8]
|
||||
LOBYTE(ADDR_BUF0), // dest[7:0]
|
||||
HIBYTE(PROG_BLOCK_SIZE), LOBYTE(PROG_BLOCK_SIZE), 31, // trigger DBG_BW
|
||||
0x11, // increment destination
|
||||
|
||||
// Debug Interface -> Buffer 1 (Channel 2)
|
||||
HIBYTE(XREG_DBGDATA), // src[15:8]
|
||||
LOBYTE(XREG_DBGDATA), // src[7:0]
|
||||
HIBYTE(ADDR_BUF1), // dest[15:8]
|
||||
LOBYTE(ADDR_BUF1), // dest[7:0]
|
||||
HIBYTE(PROG_BLOCK_SIZE), LOBYTE(PROG_BLOCK_SIZE), 31, // trigger DBG_BW
|
||||
0x11, // increment destination
|
||||
|
||||
// Buffer 0 -> Flash controller (Channel 3)
|
||||
HIBYTE(ADDR_BUF0), // src[15:8]
|
||||
LOBYTE(ADDR_BUF0), // src[7:0]
|
||||
HIBYTE(XREG_FWDATA), // dest[15:8]
|
||||
LOBYTE(XREG_FWDATA), // dest[7:0]
|
||||
HIBYTE(PROG_BLOCK_SIZE), LOBYTE(PROG_BLOCK_SIZE), 18, // trigger FLASH
|
||||
0x42, // increment source
|
||||
|
||||
// Buffer 1 -> Flash controller (Channel 4)
|
||||
HIBYTE(ADDR_BUF1), // src[15:8]
|
||||
LOBYTE(ADDR_BUF1), // src[7:0]
|
||||
HIBYTE(XREG_FWDATA), // dest[15:8]
|
||||
LOBYTE(XREG_FWDATA), // dest[7:0]
|
||||
HIBYTE(PROG_BLOCK_SIZE), LOBYTE(PROG_BLOCK_SIZE), 18, // trigger FLASH
|
||||
0x42 // increment source
|
||||
};
|
||||
|
||||
ByteVector xsfr;
|
||||
|
||||
// Load dma descriptors
|
||||
write_xdata_memory(ADDR_DMA_DESC, dma_desc, sizeof(dma_desc));
|
||||
|
||||
// Set the pointer to the DMA descriptors
|
||||
write_xdata_memory(XREG_DMA1CFGL, LOBYTE(ADDR_DMA_DESC));
|
||||
write_xdata_memory(XREG_DMA1CFGH, HIBYTE(ADDR_DMA_DESC));
|
||||
|
||||
write_xdata_memory(XREG_FADDRL, 0);
|
||||
write_xdata_memory(XREG_FADDRH, 0);
|
||||
|
||||
ByteVector data;
|
||||
sections.create_image(0xFF, data);
|
||||
data.resize((sections.upper_address() + (PROG_BLOCK_SIZE - 1)) &
|
||||
~(PROG_BLOCK_SIZE - 1), 0xFF);
|
||||
|
||||
pw_.write_start(data.size());
|
||||
|
||||
uint8_t dbg_arm, flash_arm;
|
||||
for (size_t i = 0; i < (data .size() / PROG_BLOCK_SIZE); i++)
|
||||
{
|
||||
if ((i & 0x0001) == 0)
|
||||
{
|
||||
dbg_arm = CH_DBG_TO_BUF0;
|
||||
flash_arm = CH_BUF0_TO_FLASH;
|
||||
}
|
||||
else
|
||||
{
|
||||
dbg_arm = CH_DBG_TO_BUF1;
|
||||
flash_arm = CH_BUF1_TO_FLASH;
|
||||
}
|
||||
// transfer next buffer (first buffer when i == 0)
|
||||
write_xdata_memory(XREG_DMAARM, dbg_arm);
|
||||
|
||||
ByteVector command;
|
||||
command.push_back(0xEE);
|
||||
command.push_back(0x84);
|
||||
command.push_back(0x00);
|
||||
command.insert(command.end(), &data[i * PROG_BLOCK_SIZE],
|
||||
&data[i * PROG_BLOCK_SIZE] + PROG_BLOCK_SIZE);
|
||||
|
||||
usb_device_.bulk_write(ENDPOINT_OUT, command.size(), &command[0]);
|
||||
|
||||
// wait for write to finish
|
||||
while (read_xdata_memory(XREG_FCTL) & 0x80);
|
||||
|
||||
write_xdata_memory(XREG_DMAARM, flash_arm);
|
||||
write_xdata_memory(XREG_FCTL, 0x06);
|
||||
|
||||
pw_.write_progress(PROG_BLOCK_SIZE);
|
||||
}
|
||||
while (read_xdata_memory(XREG_FCTL) & 0x80); // wait for the last buffer
|
||||
|
||||
pw_.write_finish();
|
||||
}
|
49
src/programmer/cc_253x_2540.h
Normal file
49
src/programmer/cc_253x_2540.h
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* cc_253x_2540.h
|
||||
*
|
||||
* Created on: Aug 4, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CC_253X_2540_H_
|
||||
#define _CC_253X_2540_H_
|
||||
|
||||
#include "cc_debug_interface.h"
|
||||
#include "cc_unit_driver.h"
|
||||
|
||||
class CC_253x_2540 : public CC_UnitDriver
|
||||
{
|
||||
public:
|
||||
virtual void supported_units(Unit_ID_List &units);
|
||||
virtual void find_unit_info(UnitInfo &info);
|
||||
virtual void read_info_page(ByteVector &info_page);
|
||||
virtual bool erase_check_comleted();
|
||||
virtual void mac_address_read(size_t index, ByteVector &mac_address);
|
||||
virtual void mac_address_write(ByteVector &mac_address);
|
||||
virtual void flash_write(const DataSectionStore §ions);
|
||||
virtual bool lock_write(const ByteVector &data);
|
||||
|
||||
CC_253x_2540(USB_Device &programmer, ProgressWatcher &pw);
|
||||
|
||||
private:
|
||||
// virtual bool read_info_page(ByteVector &info_page);
|
||||
// virtual bool flash_write(uint_t offset, const ByteVector &flash_data);
|
||||
|
||||
//virtual void flash_read(ByteVector &flash_data);
|
||||
|
||||
// uint16_t calc_block_crc();
|
||||
//void flash_lock_bits_read(ByteVector &lock_data);
|
||||
|
||||
virtual void flash_read_block(size_t offset, size_t size, ByteVector &flash_data);
|
||||
|
||||
// void flash_read_page(uint16_t address, ByteVector &flash_data);
|
||||
void flash_select_bank(uint_t bank);
|
||||
// void flash_read_start();
|
||||
// void flash_read_end();
|
||||
|
||||
};
|
||||
|
||||
#endif // !_CC_253X_2540_H_
|
54
src/programmer/cc_debug_interface.h
Normal file
54
src/programmer/cc_debug_interface.h
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* cc_debug_interface.h
|
||||
*
|
||||
* Created on: Jul 28, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CC_DEBUG_INTERFACE_H_
|
||||
#define _CC_DEBUG_INTERFACE_H_
|
||||
|
||||
#include "common.h"
|
||||
|
||||
const uint8_t ENDPOINT_IN = 0x84;
|
||||
const uint8_t ENDPOINT_OUT = 0x04;
|
||||
|
||||
const uint8_t
|
||||
DEBUG_STATUS_STACK_OVERFLOW = 0x01,
|
||||
DEBUG_STATUS_OSCILLATOR_STABLE = 0x02,
|
||||
DEBUG_STATUS_DEBUG_LOCKED = 0x04,
|
||||
DEBUG_STATUS_HALT_STATUS = 0x08,
|
||||
DEBUG_STATUS_PM_ACTIVE = 0x10,
|
||||
DEBUG_STATUS_CPU_HALTED = 0x20,
|
||||
DEBUG_STATUS_PCON_IDLE = 0x40,
|
||||
DEBUG_STATUS_CHIP_ERASE_BUSY = 0x80;
|
||||
|
||||
const uint8_t
|
||||
DEBUG_CONFIG_SEL_FLASH_INFO_PAGE = 0x01,
|
||||
DEBUG_CONFIG_TIMER_SUSPEND = 0x02,
|
||||
DEBUG_CONFIG_DMA_PAUSE = 0x04,
|
||||
DEBUG_CONFIG_TIMERS_OFF = 0x08,
|
||||
DEBUG_CONFIG_SOFT_POWER_MODE = 0x20;
|
||||
|
||||
const uint8_t
|
||||
DEBUG_COMMAND_CHIP_ERASE = 0x14,
|
||||
DEBUG_COMMAND_WR_CONFIG = 0x1D,
|
||||
DEBUG_COMMAND_RD_CONFIG = 0x24,
|
||||
DEBUG_COMMAND_GET_PC = 0x28,
|
||||
DEBUG_COMMAND_READ_STATUS = 0x34,
|
||||
DEBUG_COMMAND_SET_HW_BRKPNT = 0x3F,
|
||||
DEBUG_COMMAND_HALT = 0x44,
|
||||
DEBUG_COMMAND_RESUME = 0x4C,
|
||||
DEBUG_COMMAND_DEBUG_INSTR = 0x55,
|
||||
DEBUG_COMMAND_STEP_INSTR = 0x5C,
|
||||
DEBUG_COMMAND_GET_BM = 0x00,// ??
|
||||
DEBUG_COMMAND_GET_CHIP_ID = 0x68,
|
||||
DEBUG_COMMAND_BURST_WRITE = 0x80;
|
||||
|
||||
#define LOBYTE(w) ((uint8_t)(w))
|
||||
#define HIBYTE(w) ((uint8_t)(((uint16_t)(w) >> 8) & 0xFF))
|
||||
|
||||
#endif // !_CC_DEBUG_INTERFACE_H_
|
381
src/programmer/cc_programmer.cpp
Normal file
381
src/programmer/cc_programmer.cpp
Normal file
@ -0,0 +1,381 @@
|
||||
/*
|
||||
* cc_programmer.cpp
|
||||
*
|
||||
* Created on: Aug 4, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "cc_programmer.h"
|
||||
#include "cc_251x_111x.h"
|
||||
#include "cc_253x_2540.h"
|
||||
#include "cc_243x.h"
|
||||
#include "log.h"
|
||||
|
||||
const uint_t DEFAULT_TIMEOUT = 3000;
|
||||
const uint_t MAX_ERASE_TIME = 8000;
|
||||
|
||||
const static USB_DeviceID DeviceTable[] = {
|
||||
{ 0x0451, 0x16A2, "CC Debugger" },
|
||||
{ 0x11A0, 0xDB20, "SmartRF04 Evaluation Board" },
|
||||
{ 0x0451, 0x16A0, "SmartRF05 Evaluation Board" },
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
static void log_add_target_info(const UnitInfo &unit_info)
|
||||
{
|
||||
log_info("target, name: %s, chip ID: %02Xh, rev. %02Xh, flash: %u, ram: %u, flags: %02Xh",
|
||||
unit_info.name.c_str(),
|
||||
unit_info.internal_ID,
|
||||
unit_info.revision,
|
||||
unit_info.flash_size,
|
||||
unit_info.ram_size,
|
||||
unit_info.flags);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static void log_add_programmer_info(const CC_ProgrammerInfo &info)
|
||||
{
|
||||
log_info("device, name: %s, ID: %s, version: %04Xh, revision: %04Xh",
|
||||
info.name.c_str(),
|
||||
info.debugger_id.c_str(),
|
||||
info.fw_version,
|
||||
info.fw_revision);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
CC_Programmer::CC_Programmer()
|
||||
{
|
||||
usb_device_.set_transfer_timeout(DEFAULT_TIMEOUT);
|
||||
|
||||
unit_drviers_.push_back(CC_UnitDriverPtr(new CC_253x_2540(usb_device_, pw_)));
|
||||
unit_drviers_.push_back(CC_UnitDriverPtr(new CC_251x_111x(usb_device_, pw_)));
|
||||
unit_drviers_.push_back(CC_UnitDriverPtr(new CC_243x(usb_device_, pw_)));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
USB_DeviceIDVector CC_Programmer::supported_devices() const
|
||||
{
|
||||
USB_DeviceIDVector result;
|
||||
foreach (const USB_DeviceID &item, DeviceTable)
|
||||
result.push_back(item);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
StringVector CC_Programmer::supported_unit_names() const
|
||||
{
|
||||
StringVector names;
|
||||
foreach (const CC_UnitDriverPtr &item, unit_drviers_)
|
||||
{
|
||||
Unit_ID_List units;
|
||||
item->supported_units(units);
|
||||
|
||||
foreach (Unit_ID &unit, units)
|
||||
names.push_back(unit.name);
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool CC_Programmer::set_debug_interface_speed(CC_Programmer::InterfaceSpeed speed)
|
||||
{
|
||||
log_info("programmer, set debug interface speed %u", speed);
|
||||
|
||||
if (!opened())
|
||||
return false;
|
||||
|
||||
const uint8_t USB_SET_DEBUG_INTERFACE_SPEED = 0xCF;
|
||||
uint16_t value = (speed == CC_Programmer::IS_FAST) ? 0 : 1;
|
||||
|
||||
usb_device_.control_write(LIBUSB_REQUEST_TYPE_VENDOR,
|
||||
USB_SET_DEBUG_INTERFACE_SPEED,
|
||||
value, 0, NULL, 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool CC_Programmer::programmer_info(CC_ProgrammerInfo &info)
|
||||
{
|
||||
if (opened())
|
||||
{
|
||||
info = programmer_info_;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Programmer::init_device()
|
||||
{
|
||||
usb_device_.set_configuration(1);
|
||||
usb_device_.claim_interface(0);
|
||||
request_device_info();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
CC_Programmer::OpenResult CC_Programmer::open(uint_t bus, uint_t device)
|
||||
{
|
||||
if (!usb_device_.open_by_address(bus, device))
|
||||
return OR_NOT_FOUND;
|
||||
|
||||
libusb_device_descriptor descriptor;
|
||||
usb_device_.device_decriptor(descriptor);
|
||||
|
||||
foreach (const USB_DeviceID &item, DeviceTable)
|
||||
{
|
||||
if (descriptor.idProduct == item.product_id &&
|
||||
descriptor.idVendor == item.vendor_id)
|
||||
{
|
||||
init_device();
|
||||
return OR_OK;
|
||||
}
|
||||
}
|
||||
return OR_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
CC_Programmer::OpenResult CC_Programmer::open()
|
||||
{
|
||||
foreach (const USB_DeviceID &item, DeviceTable)
|
||||
{
|
||||
if (usb_device_.open_by_vid_pid(item.vendor_id, item.product_id))
|
||||
{
|
||||
programmer_info_.descripton = item.description;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!usb_device_.opened())
|
||||
return OR_NOT_FOUND;
|
||||
init_device();
|
||||
return OR_OK;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Programmer::close()
|
||||
{ usb_device_.close(); }
|
||||
|
||||
//==============================================================================
|
||||
bool CC_Programmer::opened() const
|
||||
{ return usb_device_.opened(); }
|
||||
|
||||
//==============================================================================
|
||||
void CC_Programmer::request_device_info()
|
||||
{
|
||||
libusb_device_descriptor device_descriptor;
|
||||
usb_device_.device_decriptor(device_descriptor);
|
||||
|
||||
char DID[16];
|
||||
sprintf(DID, "%02X%02X",
|
||||
device_descriptor.bcdDevice >> 8,
|
||||
device_descriptor.bcdDevice & 0xFF);
|
||||
programmer_info_.debugger_id = DID;
|
||||
|
||||
usb_device_.string_descriptor_ascii(device_descriptor.iProduct, programmer_info_.name);
|
||||
|
||||
const uint8_t USB_REQUEST_GET_STATE = 0xC0;
|
||||
|
||||
log_info("programmer, request device state");
|
||||
|
||||
uint8_t info[8];
|
||||
usb_device_.control_read(LIBUSB_REQUEST_TYPE_VENDOR, USB_REQUEST_GET_STATE,
|
||||
0, 0, info, 8);
|
||||
|
||||
programmer_info_.fw_version = info[2] | info[3] << 8;
|
||||
programmer_info_.fw_revision = info[4] | info[5] << 8;
|
||||
|
||||
unit_info_.ID = info[0] | info[1] << 8;
|
||||
foreach (CC_UnitDriverPtr &driver, unit_drviers_)
|
||||
{
|
||||
Unit_ID_List units;
|
||||
driver->supported_units(units);
|
||||
foreach (Unit_ID &unit, units)
|
||||
{
|
||||
if (unit.ID == unit_info_.ID)
|
||||
{
|
||||
unit_info_.name = unit.name;
|
||||
driver_ = driver;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!driver_ && unit_info_.ID)
|
||||
{
|
||||
std::swap(info[0], info[1]);
|
||||
unit_info_.name = "CC" + binary_to_hex(info, 2, "");
|
||||
}
|
||||
|
||||
log_add_programmer_info(programmer_info_);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Programmer::unit_status(String &name, bool &supported) const
|
||||
{
|
||||
name = unit_info_.name;
|
||||
supported = (driver_ != NULL);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Programmer::unit_close()
|
||||
{ driver_->reset(false); }
|
||||
|
||||
//==============================================================================
|
||||
void CC_Programmer::enter_debug_mode()
|
||||
{
|
||||
log_info("programmer, enter debug mode");
|
||||
|
||||
const uint8_t USB_PREPARE_DEBUG_MODE = 0xC5;
|
||||
const uint8_t USB_SET_CHIP_INFO = 0xC8;
|
||||
|
||||
usb_device_.control_write(LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT,
|
||||
USB_PREPARE_DEBUG_MODE, 0, 0, NULL, 0);
|
||||
|
||||
ByteVector command(0x30, ' ');
|
||||
memcpy(&command[0x00], unit_info_.name.c_str(), unit_info_.name.size());
|
||||
memcpy(&command[0x10], "DID:", 4);
|
||||
memcpy(&command[0x15], programmer_info_.debugger_id.c_str(), programmer_info_.debugger_id.size());
|
||||
|
||||
usb_device_.control_write(LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT,
|
||||
USB_SET_CHIP_INFO, 1, 1, &command[0], command.size());
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool CC_Programmer::unit_locked()
|
||||
{
|
||||
log_info("programmer, check if unit locked");
|
||||
|
||||
uint8_t status = 0;
|
||||
driver_->read_debug_status(status);
|
||||
return (status & DEBUG_STATUS_DEBUG_LOCKED);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool CC_Programmer::unit_connect(UnitInfo &info)
|
||||
{
|
||||
log_info("programmer, connect target");
|
||||
|
||||
enter_debug_mode();
|
||||
driver_->reset(true);
|
||||
|
||||
uint8_t status = 0;
|
||||
driver_->read_debug_status(status);
|
||||
|
||||
if ((status & DEBUG_STATUS_DEBUG_LOCKED))
|
||||
{
|
||||
log_info("programmer, target is locked");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(status & DEBUG_STATUS_CPU_HALTED))
|
||||
{
|
||||
log_info("programmer, halt failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
driver_->write_debug_config(DEBUG_CONFIG_TIMER_SUSPEND | DEBUG_CONFIG_SOFT_POWER_MODE);
|
||||
driver_->find_unit_info(unit_info_);
|
||||
|
||||
log_add_target_info(unit_info_);
|
||||
|
||||
info = unit_info_;
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool CC_Programmer::unit_reset()
|
||||
{
|
||||
driver_->reset(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool CC_Programmer::unit_erase()
|
||||
{
|
||||
driver_->erase_start();
|
||||
|
||||
uint_t erase_timer = get_tick_count();
|
||||
do
|
||||
{
|
||||
if (driver_->erase_check_comleted())
|
||||
return true;
|
||||
usleep(500 * 1000);
|
||||
}
|
||||
while ((get_tick_count() - erase_timer) <= MAX_ERASE_TIME);
|
||||
|
||||
return false; // erase timeout
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Programmer::unit_read_info_page(ByteVector &info_page)
|
||||
{
|
||||
pw_.enable(false);
|
||||
driver_->read_info_page(info_page);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Programmer::unit_mac_address_read(size_t index, ByteVector &mac_address)
|
||||
{
|
||||
pw_.enable(false);
|
||||
driver_->mac_address_read(index, mac_address);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Programmer::unit_mac_address_write(ByteVector &mac_address)
|
||||
{ }
|
||||
|
||||
//==============================================================================
|
||||
void CC_Programmer::unit_flash_read(ByteVector &flash_data)
|
||||
{
|
||||
pw_.enable(true);
|
||||
pw_.read_start(unit_info_.actual_flash_size());
|
||||
|
||||
driver_->flash_read_start();
|
||||
driver_->flash_read_block(0, unit_info_.actual_flash_size(), flash_data);
|
||||
driver_->flash_read_end();
|
||||
|
||||
pw_.read_finish();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool CC_Programmer::unit_flash_verify(const DataSectionStore §ions,
|
||||
CC_Programmer::VerifyMethod method)
|
||||
{
|
||||
log_info("programmer, verify flash, %u", method);
|
||||
|
||||
pw_.enable(true);
|
||||
|
||||
if (method == VM_BY_CRC)
|
||||
return driver_->flash_verify_by_crc(sections);
|
||||
return driver_->flash_verify_by_read(sections);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Programmer::unit_flash_write(const DataSectionStore §ions)
|
||||
{
|
||||
pw_.enable(true);
|
||||
driver_->flash_write(sections);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool CC_Programmer::unit_lock_write(const ByteVector &lock_data)
|
||||
{
|
||||
pw_.enable(false);
|
||||
return driver_->lock_write(lock_data);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_Programmer::do_on_flash_read_progress(
|
||||
const ProgressWatcher::OnProgress::slot_type &slot)
|
||||
{ pw_.do_on_read_progress(slot); }
|
||||
|
||||
//==============================================================================
|
||||
void CC_Programmer::do_on_flash_write_progress(
|
||||
const ProgressWatcher::OnProgress::slot_type &slot)
|
||||
{ pw_.do_on_write_progress(slot); }
|
103
src/programmer/cc_programmer.h
Normal file
103
src/programmer/cc_programmer.h
Normal file
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* cc_programmer.h
|
||||
*
|
||||
* Created on: Aug 2, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CC_PROGRAMMER_H_
|
||||
#define _CC_PROGRAMMER_H_
|
||||
|
||||
#include "cc_unit_driver.h"
|
||||
#include "usb/usb_device.h"
|
||||
#include "data/data_section_store.h"
|
||||
|
||||
const size_t CC_BREAKPOINT_COUNT = 4;
|
||||
|
||||
struct CC_ProgrammerInfo
|
||||
{
|
||||
String name;
|
||||
String descripton;
|
||||
String debugger_id; // 4 unique digits
|
||||
uint16_t fw_version;
|
||||
uint16_t fw_revision;
|
||||
};
|
||||
|
||||
struct USB_DeviceID
|
||||
{
|
||||
uint16_t vendor_id;
|
||||
uint16_t product_id;
|
||||
char description[256];
|
||||
};
|
||||
|
||||
struct CC_Breakpoint
|
||||
{
|
||||
size_t number;
|
||||
size_t address;
|
||||
};
|
||||
|
||||
typedef std::vector<CC_Breakpoint> CC_BreakpointVector;
|
||||
typedef std::vector<USB_DeviceID> USB_DeviceIDVector;
|
||||
|
||||
///
|
||||
class CC_Programmer : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
enum OpenResult { OR_OK, OR_NOT_FOUND, OR_NOT_SUPPORTED };
|
||||
|
||||
OpenResult open();
|
||||
OpenResult open(uint_t bus, uint_t device);
|
||||
bool opened() const;
|
||||
void close();
|
||||
|
||||
bool programmer_info(CC_ProgrammerInfo &info);
|
||||
|
||||
StringVector supported_unit_names() const;
|
||||
USB_DeviceIDVector supported_devices() const;
|
||||
|
||||
enum InterfaceSpeed { IS_SLOW, IS_FAST };
|
||||
bool set_debug_interface_speed(InterfaceSpeed speed);
|
||||
|
||||
void unit_status(String &name, bool &supported) const;
|
||||
bool unit_connect(UnitInfo &info);
|
||||
void unit_close();
|
||||
bool unit_reset();
|
||||
|
||||
bool unit_locked();
|
||||
bool unit_erase();
|
||||
|
||||
void unit_read_info_page(ByteVector &info_page);
|
||||
|
||||
void unit_mac_address_read(size_t index, ByteVector &mac_address);
|
||||
void unit_mac_address_write(ByteVector &mac_address);
|
||||
|
||||
void unit_flash_read(ByteVector &flash_data);
|
||||
void unit_flash_write(const DataSectionStore §ions);
|
||||
|
||||
enum VerifyMethod { VM_BY_CRC, VM_BY_READ };
|
||||
bool unit_flash_verify(const DataSectionStore §ions, VerifyMethod method);
|
||||
bool unit_lock_write(const ByteVector &lock_data);
|
||||
|
||||
void do_on_flash_read_progress(const ProgressWatcher::OnProgress::slot_type&);
|
||||
void do_on_flash_write_progress(const ProgressWatcher::OnProgress::slot_type&);
|
||||
|
||||
CC_Programmer();
|
||||
|
||||
private:
|
||||
void request_device_info();
|
||||
void enter_debug_mode();
|
||||
void init_device();
|
||||
|
||||
CC_ProgrammerInfo programmer_info_;
|
||||
UnitInfo unit_info_;
|
||||
USB_Device usb_device_;
|
||||
CC_UnitDriverPtrList unit_drviers_;
|
||||
CC_UnitDriverPtr driver_;
|
||||
ProgressWatcher pw_;
|
||||
CC_Breakpoint bps_[CC_BREAKPOINT_COUNT];
|
||||
};
|
||||
|
||||
#endif // !_CC_PROGRAMMER_H_
|
545
src/programmer/cc_unit_driver.cpp
Normal file
545
src/programmer/cc_unit_driver.cpp
Normal file
@ -0,0 +1,545 @@
|
||||
/*
|
||||
* cc_unit_driver.cpp
|
||||
*
|
||||
* Created on: Aug 2, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#include <boost/crc.hpp>
|
||||
#include "cc_unit_driver.h"
|
||||
#include "cc_programmer.h"
|
||||
#include "log.h"
|
||||
#include "cc_debug_interface.h"
|
||||
|
||||
#include "data/binary_file.h" // remove
|
||||
#include "data/hex_file.h" // remove
|
||||
|
||||
typedef boost::crc_optimal<16, 0x8005, 0xFFFF, 0, false, false> CrcCalculator;
|
||||
|
||||
//==============================================================================
|
||||
CC_UnitDriver::CC_UnitDriver(USB_Device &programmer, ProgressWatcher &pw) :
|
||||
usb_device_(programmer),
|
||||
pw_(pw)
|
||||
{ }
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::reset(bool debug_mode)
|
||||
{
|
||||
log_info("programmer, reset target, debug mode: %u", debug_mode);
|
||||
|
||||
const uint8_t USB_REQUEST_RESET = 0xC9;
|
||||
uint16_t index = debug_mode ? 1 : 0;
|
||||
|
||||
usb_device_.control_write(LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT,
|
||||
USB_REQUEST_RESET, 0, index, NULL, 0);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::read_debug_status(uint8_t &status)
|
||||
{
|
||||
log_info("programmer, read debug status");
|
||||
|
||||
uint8_t command[] = { 0x1F, DEBUG_COMMAND_READ_STATUS };
|
||||
|
||||
status = 0;
|
||||
|
||||
usb_device_.bulk_write(ENDPOINT_OUT, sizeof(command), command);
|
||||
usb_device_.bulk_read(ENDPOINT_IN, 1, &status);
|
||||
|
||||
log_info("programmer, debug status, %02Xh", status);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::read_debug_config(uint8_t &config)
|
||||
{
|
||||
log_info("programmer, read debug config");
|
||||
|
||||
uint8_t command[] = { 0x1F, DEBUG_COMMAND_RD_CONFIG };
|
||||
|
||||
usb_device_.bulk_write(ENDPOINT_OUT, sizeof(command), command);
|
||||
usb_device_.bulk_read(ENDPOINT_IN, 1, &config);
|
||||
|
||||
log_info("programmer, debug config, %02Xh", config);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::write_debug_config(uint8_t config)
|
||||
{
|
||||
log_info("programmer, write debug config, %02Xh", config);
|
||||
|
||||
uint8_t command[] = { 0x4C, DEBUG_COMMAND_WR_CONFIG, config };
|
||||
|
||||
usb_device_.bulk_write(ENDPOINT_OUT, sizeof(command), command);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::erase_start()
|
||||
{
|
||||
log_info("programmer, erase");
|
||||
|
||||
uint8_t command[] = { 0x1C, DEBUG_COMMAND_CHIP_ERASE };
|
||||
|
||||
usb_device_.bulk_write(ENDPOINT_OUT, sizeof(command), command);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::write_sfr(uint8_t address, uint8_t value)
|
||||
{
|
||||
log_info("write sfr at %02Xh, value: %02Xh", address, value);
|
||||
|
||||
uint8_t header[] = { 0x40, 0x55, 0x00, };
|
||||
uint8_t mov_a_direct[] = { 0xBE, 0x57, 0x75, address, value };
|
||||
uint8_t footer[] = { 0x90, 0x56, 0x74 };
|
||||
|
||||
ByteVector command;
|
||||
vector_append(command, header, sizeof(header));
|
||||
vector_append(command, mov_a_direct, sizeof(mov_a_direct));
|
||||
vector_append(command, footer, sizeof(footer));
|
||||
|
||||
usb_device_.bulk_write(ENDPOINT_OUT, command.size(), &command[0]);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::read_sfr(uint8_t address, uint8_t &value)
|
||||
{
|
||||
log_info("programmer, read sfr at %02Xh", address);
|
||||
|
||||
uint8_t header[] = { 0x40, 0x55, 0x00, };
|
||||
uint8_t mov_a_direct[] = { 0x7F, 0x56, 0xE5, address };
|
||||
uint8_t footer[] = { 0x90, 0x56, 0x74 };
|
||||
|
||||
ByteVector command;
|
||||
vector_append(command, header, sizeof(header));
|
||||
vector_append(command, mov_a_direct, sizeof(mov_a_direct));
|
||||
vector_append(command, footer, sizeof(footer));
|
||||
|
||||
usb_device_.bulk_write(ENDPOINT_OUT, command.size(), &command[0]);
|
||||
usb_device_.bulk_read(ENDPOINT_IN, 1, &value);
|
||||
|
||||
log_info("programmer, sfr value: %02Xh", value);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
uint8_t CC_UnitDriver::read_xdata_memory(uint16_t address)
|
||||
{
|
||||
ByteVector data;
|
||||
read_xdata_memory(address, 1, data);
|
||||
return data[0];
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::read_xdata_memory(uint16_t address, size_t count, ByteVector &data)
|
||||
{
|
||||
log_info("programmer, read xdata memory at %04Xh, count: %u", address, count);
|
||||
|
||||
uint8_t header[] = {
|
||||
0x40, 0x55, 0x00, 0x72, 0x56, 0xE5, 0x92, 0xBE, 0x57, 0x75,
|
||||
0x92, 0x00, 0x74, 0x56, 0xE5, 0x83, 0x76, 0x56, 0xE5, 0x82 };
|
||||
|
||||
uint8_t footer[] = { 0xD4, 0x57, 0x90, 0xC2, 0x57, 0x75, 0x92, 0x90, 0x56, 0x74 };
|
||||
|
||||
uint8_t load_dtpr[] = { 0xBE, 0x57, 0x90, 0x00, 0x00 };
|
||||
uint8_t mov_a_dtpr[] = { 0x4E, 0x55, 0xE0 };
|
||||
uint8_t inc_dtpr[] = { 0x5E, 0x55, 0xA3 };
|
||||
|
||||
ByteVector command;
|
||||
vector_append(command, header, sizeof(header));
|
||||
|
||||
load_dtpr[sizeof(load_dtpr) - 1] = address;
|
||||
load_dtpr[sizeof(load_dtpr) - 2] = address >> 8;
|
||||
vector_append(command, load_dtpr, sizeof(load_dtpr));
|
||||
|
||||
for (size_t i = 0; i < count; i++)
|
||||
{
|
||||
if (i == (count - 1) || !((i + 1) % 64))
|
||||
mov_a_dtpr[0] |= 1;
|
||||
else
|
||||
mov_a_dtpr[0] &= ~1;
|
||||
|
||||
vector_append(command, mov_a_dtpr, sizeof(mov_a_dtpr));
|
||||
vector_append(command, inc_dtpr, sizeof(inc_dtpr));
|
||||
}
|
||||
vector_append(command, footer, sizeof(footer));
|
||||
|
||||
data.resize(count);
|
||||
|
||||
usb_device_.bulk_write(ENDPOINT_OUT, command.size(), &command[0]);
|
||||
usb_device_.bulk_read(ENDPOINT_IN, count, &data[0]);
|
||||
|
||||
log_info("programmer, read xdata memory, data: %s", binary_to_hex(&data[0], count, " ").c_str());
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::read_info_page(ByteVector &info_page)
|
||||
{ }
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::mac_address_read(size_t index, ByteVector &mac_address)
|
||||
{ }
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::mac_address_write(ByteVector &mac_address)
|
||||
{ }
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::write_xdata_memory(uint16_t address, uint8_t data)
|
||||
{ write_xdata_memory(address, &data, 1); }
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::write_xdata_memory(uint16_t address, const ByteVector &data)
|
||||
{ write_xdata_memory(address, &data[0], data.size()); }
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::write_xdata_memory(uint16_t address, const uint8_t data[], size_t size)
|
||||
{
|
||||
log_info("programmer, write xdata memory at %04Xh, count: %u", address, size);
|
||||
|
||||
uint8_t header[] = {
|
||||
0x40, 0x55, 0x00, 0x72, 0x56, 0xE5, 0x92, 0xBE, 0x57, 0x75, 0x92, 0x00,
|
||||
0x74, 0x56, 0xE5, 0x83, 0x76, 0x56, 0xE5, 0x82 };
|
||||
|
||||
uint8_t footer[] = { 0xD4, 0x57, 0x90, 0xC2, 0x57, 0x75, 0x92, 0x90, 0x56, 0x74 };
|
||||
|
||||
uint8_t load_dtpr[] = { 0xBE, 0x57, 0x90, address >> 8, address };
|
||||
uint8_t mov_a_data[] = { 0x8E, 0x56, 0x74, 0x00 };
|
||||
uint8_t mov_dtpr_a[] = { 0x5E, 0x55, 0xF0 };
|
||||
uint8_t inc_dtpr[] = { 0x5E, 0x55, 0xA3 };
|
||||
|
||||
ByteVector command;
|
||||
vector_append(command, header, sizeof(header));
|
||||
vector_append(command, load_dtpr, sizeof(load_dtpr));
|
||||
|
||||
for (size_t i = 0; i < size; i++)
|
||||
{
|
||||
mov_a_data[3] = data[i];
|
||||
vector_append(command, mov_a_data, sizeof(mov_a_data));
|
||||
vector_append(command, mov_dtpr_a, sizeof(mov_dtpr_a));
|
||||
vector_append(command, inc_dtpr, sizeof(inc_dtpr));
|
||||
}
|
||||
vector_append(command, footer, sizeof(footer));
|
||||
|
||||
usb_device_.bulk_write(ENDPOINT_OUT, command.size(), &command[0]);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::select_info_page_flash(bool select_info_pages)
|
||||
{
|
||||
uint8_t config = 0;
|
||||
read_debug_config(config);
|
||||
|
||||
if (select_info_pages)
|
||||
config |= DEBUG_CONFIG_SEL_FLASH_INFO_PAGE;
|
||||
else
|
||||
config &= ~DEBUG_CONFIG_SEL_FLASH_INFO_PAGE;
|
||||
|
||||
write_debug_config(config);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool CC_UnitDriver::flash_verify_by_read(const DataSectionStore §ion_store)
|
||||
{
|
||||
ByteVector data;
|
||||
bool result = true;
|
||||
|
||||
pw_.read_start(section_store.actual_size());
|
||||
|
||||
flash_read_start();
|
||||
foreach (const DataSection &item, section_store.sections())
|
||||
{
|
||||
flash_read_block(item.address, item.size(), data);
|
||||
if (memcmp(&data[0], &item.data[0], item.size()))
|
||||
{
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
data.clear();
|
||||
}
|
||||
flash_read_end();
|
||||
|
||||
pw_.read_finish();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool CC_UnitDriver::flash_verify_by_crc(const DataSectionStore §ion_store)
|
||||
{
|
||||
// Channel 0: Flash mapped to Xdata -> CRC shift register
|
||||
uint8_t dma_desc[8] = {
|
||||
HIBYTE(reg_info_.xbank_offset), // src[15:8]
|
||||
LOBYTE(reg_info_.xbank_offset), // src[7:0]
|
||||
HIBYTE(reg_info_.rndh), // dest[15:8]
|
||||
LOBYTE(reg_info_.rndh), // dest[7:0]
|
||||
HIBYTE(reg_info_.verify_block_size),// block size[15:8]
|
||||
LOBYTE(reg_info_.verify_block_size),// block size[7:0]
|
||||
0x20, // no trigger event, block mode
|
||||
0x42, // increment source
|
||||
};
|
||||
|
||||
write_xdata_memory(reg_info_.dma_arm, 0x00);
|
||||
|
||||
// set the pointer to the DMA descriptors
|
||||
write_xdata_memory(reg_info_.dma0_cfgl, LOBYTE(reg_info_.dma0_cfg_offset));
|
||||
write_xdata_memory(reg_info_.dma0_cfgh, HIBYTE(reg_info_.dma0_cfg_offset));
|
||||
|
||||
size_t flash_bank = 0xFF; // correct flash bank will be set later
|
||||
|
||||
pw_.read_start(section_store.actual_size());
|
||||
|
||||
foreach (const DataSection §ion, section_store.sections())
|
||||
{
|
||||
size_t section_offset = section.address;
|
||||
size_t total_size = section.size();
|
||||
size_t bank_offset = section_offset % FLASH_BANK_SIZE;
|
||||
while (total_size)
|
||||
{
|
||||
size_t count = std::min(total_size, reg_info_.verify_block_size);
|
||||
size_t flash_bank_0 = section_offset / FLASH_BANK_SIZE;
|
||||
size_t flash_bank_1 = (section_offset + count) / FLASH_BANK_SIZE;
|
||||
|
||||
if (flash_bank_0 != flash_bank_1)
|
||||
count = FLASH_BANK_SIZE - (section_offset % FLASH_BANK_SIZE);
|
||||
|
||||
if (flash_bank != flash_bank_0)
|
||||
{
|
||||
flash_bank = flash_bank_0;
|
||||
if (reg_info_.memctr)
|
||||
write_xdata_memory(reg_info_.memctr, flash_bank);
|
||||
bank_offset = section_offset % FLASH_BANK_SIZE;
|
||||
}
|
||||
|
||||
dma_desc[0] = HIBYTE(bank_offset + reg_info_.xbank_offset);
|
||||
dma_desc[1] = LOBYTE(bank_offset + reg_info_.xbank_offset);
|
||||
dma_desc[4] = HIBYTE(count);
|
||||
dma_desc[5] = LOBYTE(count);
|
||||
write_xdata_memory(reg_info_.dma0_cfg_offset, dma_desc, sizeof(dma_desc));
|
||||
|
||||
CrcCalculator crc_calc;
|
||||
crc_calc.process_bytes(§ion.data[section.size() - total_size], count);
|
||||
if (calc_block_crc() != crc_calc.checksum())
|
||||
return false;
|
||||
|
||||
total_size -= count;
|
||||
section_offset += count;
|
||||
bank_offset += count;
|
||||
|
||||
pw_.read_progress(count);
|
||||
}
|
||||
}
|
||||
pw_.read_finish();
|
||||
return true;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
uint16_t CC_UnitDriver::calc_block_crc()
|
||||
{
|
||||
write_xdata_memory(reg_info_.rndl, 0xFF);
|
||||
write_xdata_memory(reg_info_.rndl, 0xFF);
|
||||
write_xdata_memory(reg_info_.dma_arm, 0x01);
|
||||
write_xdata_memory(reg_info_.dma_req, 0x01);
|
||||
|
||||
while (!(read_xdata_memory(reg_info_.dma_irq) & 0x01));
|
||||
|
||||
ByteVector xsfr;
|
||||
read_xdata_memory(reg_info_.rndl, 2, xsfr);
|
||||
return xsfr[0] | (xsfr[1] << 8);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static void create_read_proc(size_t count, ByteVector &proc)
|
||||
{
|
||||
uint8_t clr_a[] = { 0x5E, 0x55, 0xE4 };
|
||||
uint8_t mov_c_a_dptr_a[]= { 0x4E, 0x55, 0x93 };
|
||||
uint8_t inc_dptr[] = { 0x5E, 0x55, 0xA3 };
|
||||
|
||||
proc.clear();
|
||||
for (size_t i = 0; i < count; i++)
|
||||
{
|
||||
vector_append(proc, clr_a, sizeof(clr_a));
|
||||
if (!((i + 1) % 64) || i == (count - 1))
|
||||
mov_c_a_dptr_a[0] |= 0x01;
|
||||
vector_append(proc, mov_c_a_dptr_a, sizeof(mov_c_a_dptr_a));
|
||||
mov_c_a_dptr_a[0] &= ~0x01;
|
||||
vector_append(proc, inc_dptr, sizeof(inc_dptr));
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::flash_read_32k(size_t address, size_t size, ByteVector &data)
|
||||
{
|
||||
if (((address % 0x8000) + size) > 0x8000)
|
||||
throw std::runtime_error("flash_read_32k, incorrect parameters");
|
||||
|
||||
const uint8_t load_dtpr[] = { 0xBE, 0x57, 0x90, address >> 8, address };
|
||||
usb_device_.bulk_write(ENDPOINT_OUT, sizeof(load_dtpr), load_dtpr);
|
||||
|
||||
size_t offset = data.size();
|
||||
data.resize(offset + size, 0xFF);
|
||||
|
||||
ByteVector command;
|
||||
for (size_t i = 0; i < size / FLASH_READ_CHUNK_SIZE; i++)
|
||||
{
|
||||
if (command.empty())
|
||||
create_read_proc(FLASH_READ_CHUNK_SIZE, command);
|
||||
|
||||
usb_device_.bulk_write(ENDPOINT_OUT, command.size(), &command[0]);
|
||||
usb_device_.bulk_read(ENDPOINT_IN, FLASH_READ_CHUNK_SIZE, &data[offset]);
|
||||
offset += FLASH_READ_CHUNK_SIZE;
|
||||
|
||||
pw_.read_progress(FLASH_READ_CHUNK_SIZE);
|
||||
}
|
||||
|
||||
if ((size % FLASH_READ_CHUNK_SIZE))
|
||||
{
|
||||
create_read_proc(size % FLASH_READ_CHUNK_SIZE, command);
|
||||
|
||||
usb_device_.bulk_write(ENDPOINT_OUT, command.size(), &command[0]);
|
||||
usb_device_.bulk_read(ENDPOINT_IN, size - offset, &data[offset]);
|
||||
|
||||
pw_.read_progress(size - offset);
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::flash_large_read_block(size_t offset, size_t size,
|
||||
ByteVector &flash_data)
|
||||
{
|
||||
uint8_t flash_bank = 0xFF;
|
||||
|
||||
while (size)
|
||||
{
|
||||
size_t bank_offset = offset % FLASH_BANK_SIZE;
|
||||
size_t count = std::min(size, (size_t)0x8000);
|
||||
uint8_t flash_bank_0 = offset / FLASH_BANK_SIZE;
|
||||
uint8_t flash_bank_1 = (offset + count) / FLASH_BANK_SIZE;
|
||||
|
||||
if (flash_bank_0 != flash_bank_1)
|
||||
size_t count = ((offset + count) % FLASH_BANK_SIZE);
|
||||
|
||||
if (flash_bank != flash_bank_0)
|
||||
{
|
||||
flash_bank = flash_bank_0;
|
||||
write_xdata_memory(reg_info_.fmap, flash_bank);
|
||||
bank_offset = offset % FLASH_BANK_SIZE;
|
||||
}
|
||||
|
||||
flash_read_32k(bank_offset + reg_info_.xbank_offset, count, flash_data);
|
||||
|
||||
size -= count;
|
||||
offset += count;
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::flash_read_start()
|
||||
{
|
||||
const uint8_t USB_PREPARE = 0xC6;
|
||||
|
||||
uint8_t byte = 0;
|
||||
usb_device_.control_read(LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_IN,
|
||||
USB_PREPARE, 0, 0, &byte, 1);
|
||||
reset(true);
|
||||
|
||||
uint8_t header[] = {
|
||||
0x40, 0x55, 0x00, 0x72, 0x56, 0xE5, 0xD0, 0x74, 0x56, 0xE5, 0x92, 0xBE,
|
||||
0x57, 0x75, 0x92, 0x00, 0x76, 0x56, 0xE5, 0x83, 0x78, 0x56, 0xE5, 0x82,
|
||||
0x7A, 0x56, 0xE5, 0x9F
|
||||
};
|
||||
|
||||
usb_device_.bulk_write(ENDPOINT_OUT, sizeof(header), header);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::flash_read_end()
|
||||
{
|
||||
uint8_t command[] = {
|
||||
0xCA, 0x57, 0x75, 0x9F, 0xD6, 0x57, 0x90, 0xC4, 0x57,
|
||||
0x75, 0x92, 0xC2, 0x57, 0x75, 0xD0, 0x90, 0x56, 0x74
|
||||
};
|
||||
usb_device_.bulk_write(ENDPOINT_OUT, sizeof(command), command);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::write_lock_to_info_page(uint8_t lock_byte)
|
||||
{
|
||||
select_info_page_flash(true);
|
||||
|
||||
ByteVector data;
|
||||
data.push_back(0xFF);
|
||||
data.push_back(lock_byte);
|
||||
|
||||
DataSectionStore store;
|
||||
store.add_section(DataSection(0, data), true);
|
||||
write_flash_slow(store);
|
||||
|
||||
select_info_page_flash(false);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::set_reg_info(const UnitCoreInfo ®_info)
|
||||
{ reg_info_ = reg_info; }
|
||||
|
||||
//==============================================================================
|
||||
void CC_UnitDriver::write_flash_slow(const DataSectionStore §ion_store)
|
||||
{
|
||||
const size_t WRITE_BLOCK_SIZE = reg_info_.write_block_size;
|
||||
|
||||
// Channel 0: Xdata buffer -> Flash controller
|
||||
uint8_t dma_desc[8] = {
|
||||
HIBYTE(reg_info_.dma_data_offset),// src[15:8]
|
||||
LOBYTE(reg_info_.dma_data_offset),// src[7:0]
|
||||
HIBYTE(reg_info_.fwdata), // dest[15:8]
|
||||
LOBYTE(reg_info_.fwdata), // dest[7:0]
|
||||
HIBYTE(WRITE_BLOCK_SIZE), // block size[15:8]
|
||||
LOBYTE(WRITE_BLOCK_SIZE), // block size[7:0]
|
||||
18, // trigger FLASH
|
||||
0x42 // increment source
|
||||
};
|
||||
|
||||
// Load dma descriptors
|
||||
write_xdata_memory(reg_info_.dma0_cfg_offset, dma_desc, sizeof(dma_desc));
|
||||
|
||||
// Set the pointer to the DMA descriptors
|
||||
write_xdata_memory(reg_info_.dma0_cfgl, LOBYTE(reg_info_.dma0_cfg_offset));
|
||||
write_xdata_memory(reg_info_.dma0_cfgh, HIBYTE(reg_info_.dma0_cfg_offset));
|
||||
|
||||
size_t faddr = 0xFFFF;
|
||||
|
||||
ByteVector data;
|
||||
section_store.create_image(0xFF, data);
|
||||
data.resize((section_store.upper_address() + (WRITE_BLOCK_SIZE- 1)) &
|
||||
~(WRITE_BLOCK_SIZE - 1), 0xFF);
|
||||
|
||||
pw_.write_start(data.size());
|
||||
|
||||
ByteVector empty_block;
|
||||
empty_block.resize(WRITE_BLOCK_SIZE, 0xFF);
|
||||
|
||||
for (size_t i = 0; i < (data.size() / WRITE_BLOCK_SIZE); i++)
|
||||
{
|
||||
pw_.write_progress(WRITE_BLOCK_SIZE);
|
||||
|
||||
size_t offset = WRITE_BLOCK_SIZE * i;
|
||||
if (!memcmp(&data[offset], &empty_block[0], WRITE_BLOCK_SIZE))
|
||||
continue;
|
||||
|
||||
size_t new_faddr = WRITE_BLOCK_SIZE * i / reg_info_.flash_word_size;
|
||||
if (new_faddr != faddr)
|
||||
{
|
||||
faddr = WRITE_BLOCK_SIZE * i / reg_info_.flash_word_size;
|
||||
write_xdata_memory(reg_info_.faddrl, LOBYTE(faddr));
|
||||
write_xdata_memory(reg_info_.faddrh, HIBYTE(faddr));
|
||||
faddr += WRITE_BLOCK_SIZE / reg_info_.flash_word_size;
|
||||
}
|
||||
|
||||
write_xdata_memory(reg_info_.dma_data_offset, &data[offset], WRITE_BLOCK_SIZE);
|
||||
|
||||
write_xdata_memory(reg_info_.dma_arm, 0x01);
|
||||
write_xdata_memory(reg_info_.fctl, reg_info_.fctl_write);
|
||||
while ((read_xdata_memory(reg_info_.fctl) & 0x80));
|
||||
}
|
||||
pw_.write_finish();
|
||||
}
|
90
src/programmer/cc_unit_driver.h
Normal file
90
src/programmer/cc_unit_driver.h
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* cc_unit_driver.h
|
||||
*
|
||||
* Created on: Aug 4, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CC_UNIT_DRIVER_H_
|
||||
#define _CC_UNIT_DRIVER_H_
|
||||
|
||||
#include "data/data_section_store.h"
|
||||
#include "data/progress_watcher.h"
|
||||
#include "usb/usb_device.h"
|
||||
#include "cc_unit_info.h"
|
||||
|
||||
const size_t XDATA_READ_CHUNK_SIZE = 128;
|
||||
const size_t FLASH_READ_CHUNK_SIZE = 128;
|
||||
const size_t FLASH_BANK_SIZE = 1024 * 32;
|
||||
const size_t FLASH_MAPPED_BANK_OFFSET = 1024 * 32;
|
||||
|
||||
class CC_UnitDriver : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
virtual void supported_units(Unit_ID_List &units) = 0;
|
||||
virtual void find_unit_info(UnitInfo &info) = 0;
|
||||
|
||||
virtual void read_info_page(ByteVector &info_page);
|
||||
|
||||
/// @param index 0 - primary address, 1 - secondary address
|
||||
virtual void mac_address_read(size_t index, ByteVector &mac_address);
|
||||
virtual void mac_address_write(ByteVector &mac_address);
|
||||
|
||||
virtual void erase_start();
|
||||
virtual bool erase_check_comleted() = 0;
|
||||
virtual void flash_write(const DataSectionStore §ions) = 0;
|
||||
virtual bool flash_verify_by_crc(const DataSectionStore §ions);
|
||||
virtual bool flash_verify_by_read(const DataSectionStore §ions);
|
||||
virtual void flash_read_block(size_t offset, size_t size, ByteVector &data) = 0;
|
||||
virtual bool lock_write(const ByteVector &data) = 0;
|
||||
|
||||
void read_debug_status(uint8_t &status);
|
||||
void read_debug_config(uint8_t &config);
|
||||
void write_debug_config(uint8_t config);
|
||||
|
||||
void read_sfr(uint8_t address, uint8_t &value);
|
||||
void write_sfr(uint8_t address, uint8_t value);
|
||||
|
||||
void write_xdata_memory(uint16_t address, const ByteVector &data);
|
||||
void write_xdata_memory(uint16_t address, const uint8_t data[], size_t size);
|
||||
void write_xdata_memory(uint16_t address, uint8_t data);
|
||||
|
||||
void read_xdata_memory(uint16_t address, size_t count, ByteVector &out);
|
||||
uint8_t read_xdata_memory(uint16_t address);
|
||||
|
||||
void reset(bool debug_mode);
|
||||
|
||||
void flash_read_start();
|
||||
void flash_read_end();
|
||||
|
||||
CC_UnitDriver(USB_Device &programmer, ProgressWatcher &pw);
|
||||
|
||||
protected:
|
||||
// some procedures is valid only for subset of targets
|
||||
void select_info_page_flash(bool select_info_page);
|
||||
|
||||
// Out data will be put in the end of data
|
||||
void flash_read_32k(size_t address, size_t size, ByteVector &data);
|
||||
void flash_large_read_block(size_t offset, size_t size, ByteVector &data);
|
||||
void set_reg_info(const UnitCoreInfo &);
|
||||
void write_flash_slow(const DataSectionStore §ions);
|
||||
void write_lock_to_info_page(uint8_t lock_byte);
|
||||
|
||||
USB_Device &usb_device_;
|
||||
ProgressWatcher &pw_;
|
||||
UnitInfo unit_info_;
|
||||
|
||||
private:
|
||||
uint16_t calc_block_crc();
|
||||
|
||||
UnitCoreInfo reg_info_;
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<CC_UnitDriver> CC_UnitDriverPtr;
|
||||
typedef std::list<CC_UnitDriverPtr> CC_UnitDriverPtrList;
|
||||
|
||||
#endif // !_CC_UNIT_DRIVER_H_
|
||||
|
30
src/programmer/cc_unit_info.cpp
Normal file
30
src/programmer/cc_unit_info.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* cc_uint_info.cpp
|
||||
*
|
||||
* Created on: Nov 7, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cc_unit_info.h"
|
||||
|
||||
//==============================================================================
|
||||
UnitInfo::UnitInfo() :
|
||||
ID(0),
|
||||
internal_ID(0),
|
||||
revision(0),
|
||||
flags(0),
|
||||
flash_size(0),
|
||||
ram_size(0),
|
||||
flash_page_size(0)
|
||||
{ }
|
||||
|
||||
//==============================================================================
|
||||
UnitCoreInfo::UnitCoreInfo()
|
||||
{ memset(this, 0, sizeof(UnitCoreInfo)); }
|
||||
|
||||
//==============================================================================
|
||||
size_t UnitInfo::actual_flash_size() const
|
||||
{ return 1024 * (flash_size ? flash_size : max_flash_size); }
|
82
src/programmer/cc_unit_info.h
Normal file
82
src/programmer/cc_unit_info.h
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* cc_uint_info.h
|
||||
*
|
||||
* Created on: Aug 2, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _CC_UNIT_INFO_H_
|
||||
#define _CC_UNIT_INFO_H_
|
||||
|
||||
#include "common.h"
|
||||
#include "data/data_section.h"
|
||||
|
||||
struct Unit_ID
|
||||
{
|
||||
uint_t ID;
|
||||
String name;
|
||||
|
||||
Unit_ID() : ID(0) { }
|
||||
Unit_ID(uint_t ID_, const String &name_) : ID(ID_), name(name_) { }
|
||||
};
|
||||
|
||||
struct UnitInfo
|
||||
{
|
||||
enum Flags {
|
||||
SUPPORT_USB = 0x01,
|
||||
SUPPORT_MAC_ADDRESS = 0x02,
|
||||
SUPPORT_INFO_PAGE = 0x04
|
||||
};
|
||||
|
||||
uint_t ID; // ID used by programmer
|
||||
String name; // like 'CCxxxx'
|
||||
uint8_t internal_ID; // read from chip
|
||||
uint8_t revision; // read from chip
|
||||
uint_t flags;
|
||||
uint_t flash_size; // in KB
|
||||
uint_t max_flash_size; // in KB
|
||||
uint_t ram_size; // in KB
|
||||
uint_t mac_address_count;
|
||||
uint_t flash_page_size; // in KB // todo: remove
|
||||
uint_t lock_size; //
|
||||
|
||||
size_t actual_flash_size() const;
|
||||
|
||||
UnitInfo();
|
||||
};
|
||||
|
||||
struct UnitCoreInfo
|
||||
{
|
||||
size_t flash_word_size;
|
||||
size_t verify_block_size;
|
||||
size_t write_block_size;
|
||||
uint16_t xbank_offset;
|
||||
uint16_t dma0_cfg_offset;
|
||||
uint16_t dma_data_offset;
|
||||
|
||||
// Xdata registers addresses;
|
||||
uint16_t memctr;
|
||||
uint16_t fmap;
|
||||
uint16_t rndl;
|
||||
uint16_t rndh;
|
||||
uint16_t fctl;
|
||||
uint16_t fwdata;
|
||||
uint16_t faddrl;
|
||||
uint16_t faddrh;
|
||||
uint16_t dma0_cfgl;
|
||||
uint16_t dma0_cfgh;
|
||||
uint16_t dma_arm;
|
||||
uint16_t dma_req;
|
||||
uint16_t dma_irq;
|
||||
|
||||
uint8_t fctl_write;
|
||||
|
||||
UnitCoreInfo();
|
||||
};
|
||||
|
||||
typedef std::list<Unit_ID> Unit_ID_List;
|
||||
|
||||
#endif // !_CC_UNIT_INFO_H_
|
366
src/usb/usb_device.cpp
Normal file
366
src/usb/usb_device.cpp
Normal file
@ -0,0 +1,366 @@
|
||||
/*
|
||||
* usb_device.cpp
|
||||
*
|
||||
* Created on: Aug 2, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#include "usb_device.h"
|
||||
#include "log.h"
|
||||
|
||||
static void on_error(const String &context, int error = LIBUSB_ERROR_OTHER);
|
||||
|
||||
typedef std::vector<libusb_device *> libusb_device_vector;
|
||||
|
||||
//==============================================================================
|
||||
class USB_Enumerator
|
||||
{
|
||||
public:
|
||||
USB_Enumerator(USB_ContextPtr context, libusb_device_vector &devices);
|
||||
~USB_Enumerator();
|
||||
|
||||
private:
|
||||
libusb_device **list_;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
USB_Enumerator::USB_Enumerator(USB_ContextPtr context, libusb_device_vector &devices)
|
||||
{
|
||||
ssize_t count = libusb_get_device_list(context.get(), &list_);
|
||||
if (count < 0)
|
||||
on_error("libusb_get_device_list", count);
|
||||
|
||||
for (ssize_t i = 0; i < count; i++)
|
||||
devices.push_back(list_[i]);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
USB_Enumerator::~USB_Enumerator()
|
||||
{ libusb_free_device_list(list_, true); }
|
||||
|
||||
//==============================================================================
|
||||
static const char* libusb_error_string(enum libusb_error errcode)
|
||||
{
|
||||
switch (errcode)
|
||||
{
|
||||
case LIBUSB_SUCCESS:
|
||||
return "Success";
|
||||
case LIBUSB_ERROR_IO:
|
||||
return "Input/output error";
|
||||
case LIBUSB_ERROR_INVALID_PARAM:
|
||||
return "Invalid parameter";
|
||||
case LIBUSB_ERROR_ACCESS:
|
||||
return "Access denied (insufficient permissions)";
|
||||
case LIBUSB_ERROR_NO_DEVICE:
|
||||
return "No such device (it may have been disconnected)";
|
||||
case LIBUSB_ERROR_NOT_FOUND:
|
||||
return "Entity not found";
|
||||
case LIBUSB_ERROR_BUSY:
|
||||
return "Resource busy";
|
||||
case LIBUSB_ERROR_TIMEOUT:
|
||||
return "Operation timed out";
|
||||
case LIBUSB_ERROR_OVERFLOW:
|
||||
return "Overflow";
|
||||
case LIBUSB_ERROR_PIPE:
|
||||
return "Pipe error";
|
||||
case LIBUSB_ERROR_INTERRUPTED:
|
||||
return "System call interrupted (perhaps due to signal)";
|
||||
case LIBUSB_ERROR_NO_MEM:
|
||||
return "Insufficient memory";
|
||||
case LIBUSB_ERROR_NOT_SUPPORTED:
|
||||
return "Operation not supported or unimplemented on this platform";
|
||||
case LIBUSB_ERROR_OTHER:
|
||||
return "Other error";
|
||||
|
||||
default:
|
||||
return "Unknown error";
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static void on_error(const String &context, int error)
|
||||
{
|
||||
throw std::runtime_error(context + " failed, " +
|
||||
libusb_error_string((libusb_error)error));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
static void on_timeout_error(const String &context, ssize_t total,
|
||||
ssize_t transfered)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << context << " timeout, transfered " << transfered << " from " << total;
|
||||
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
USB_Device::USB_Device() :
|
||||
handle_(NULL),
|
||||
device_(NULL),
|
||||
timeout_(0)
|
||||
{ }
|
||||
|
||||
//==============================================================================
|
||||
USB_Device::~USB_Device()
|
||||
{ close(); }
|
||||
|
||||
//==============================================================================
|
||||
void USB_Device::init_context()
|
||||
{
|
||||
if (context_)
|
||||
return;
|
||||
|
||||
libusb_context *context = NULL;
|
||||
int result = libusb_init(&context);
|
||||
if (result != LIBUSB_SUCCESS)
|
||||
on_error("Failed to init USB context", result);
|
||||
|
||||
context_ = USB_ContextPtr(context, libusb_exit);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool USB_Device::opened() const
|
||||
{
|
||||
return handle_ != NULL;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void USB_Device::close()
|
||||
{
|
||||
if (handle_)
|
||||
{
|
||||
libusb_close(handle_);
|
||||
handle_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool USB_Device::open_by_vid_pid(uint16_t vendor_id, uint16_t product_id)
|
||||
{
|
||||
init_context();
|
||||
close();
|
||||
|
||||
libusb_device_vector devices;
|
||||
USB_Enumerator enumerator(context_, devices);
|
||||
libusb_device_descriptor descriptor;
|
||||
|
||||
foreach (libusb_device *item, devices)
|
||||
{
|
||||
if (!libusb_get_device_descriptor(item, &descriptor) &&
|
||||
descriptor.idVendor == vendor_id &&
|
||||
descriptor.idProduct == product_id)
|
||||
{
|
||||
int result = libusb_open(item, &handle_);
|
||||
if (result < 0)
|
||||
on_error("libusb_open", result);
|
||||
device_ = libusb_get_device(handle_);
|
||||
|
||||
log_info("usb, open device, VID: %04Xh, PID: %04Xh", vendor_id, product_id);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
bool USB_Device::open_by_address(uint8_t bus_number, uint8_t device_address)
|
||||
{
|
||||
init_context();
|
||||
close();
|
||||
|
||||
libusb_device_vector devices;
|
||||
USB_Enumerator enumerator(context_, devices);
|
||||
|
||||
foreach (libusb_device *item, devices)
|
||||
{
|
||||
if (libusb_get_bus_number(item) == bus_number &&
|
||||
libusb_get_device_address(item) == device_address)
|
||||
{
|
||||
int result = libusb_open(item, &handle_);
|
||||
if (result < 0)
|
||||
on_error("libusb_open", result);
|
||||
device_ = libusb_get_device(handle_);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void USB_Device::check_open()
|
||||
{
|
||||
if (!opened())
|
||||
on_error("try using not-opened device");
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void USB_Device::device_decriptor(libusb_device_descriptor &descriptor)
|
||||
{
|
||||
check_open();
|
||||
|
||||
int result = libusb_get_device_descriptor(device_, &descriptor);
|
||||
if (result != LIBUSB_SUCCESS)
|
||||
on_error("Failed to get device descriptor", (libusb_error)result);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void USB_Device::string_descriptor_utf8(uint8_t index, uint16_t language, String &data)
|
||||
{
|
||||
check_open();
|
||||
|
||||
uint8_t raw_data[256];
|
||||
int result = libusb_get_string_descriptor(handle_, index, language, raw_data,
|
||||
sizeof(raw_data));
|
||||
if (result < 0)
|
||||
on_error("Failed to get string descriptor " + number_to_string(index),
|
||||
(libusb_error)result);
|
||||
|
||||
data.assign(raw_data, raw_data + result);
|
||||
|
||||
raw_data[result] = '\0';
|
||||
log_info("usb, get string descriptor %u, language: %u, data: %s", index, language, raw_data);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void USB_Device::string_descriptor_ascii(uint8_t index, String &data)
|
||||
{
|
||||
check_open();
|
||||
|
||||
uint8_t raw_data[256];
|
||||
int result = libusb_get_string_descriptor_ascii(handle_, index, raw_data,
|
||||
sizeof(raw_data));
|
||||
if (result < 0)
|
||||
on_error("Failed to get string descriptor " + number_to_string(index),
|
||||
(libusb_error)result);
|
||||
|
||||
data.assign(raw_data, raw_data + result);
|
||||
|
||||
raw_data[result] = '\0';
|
||||
log_info("usb, get string descriptor %u, data: %s", index, raw_data);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void USB_Device::set_transfer_timeout(uint_t timeout)
|
||||
{
|
||||
log_info("usb, set timeout %u ms", timeout);
|
||||
|
||||
timeout_ = timeout;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void USB_Device::set_debug_mode(DebugLevel level)
|
||||
{
|
||||
libusb_set_debug(context_.get(), level);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void USB_Device::claim_interface(uint_t interface_number)
|
||||
{
|
||||
log_info("usb, claim interface %u", interface_number);
|
||||
|
||||
int result = libusb_claim_interface(handle_, interface_number);
|
||||
if (result < 0)
|
||||
on_error("claim_interface", result);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void USB_Device::release_interface(uint_t interface_number)
|
||||
{
|
||||
log_info("usb, release interface %u", interface_number);
|
||||
|
||||
int result = libusb_release_interface(handle_, interface_number);
|
||||
if (result < 0)
|
||||
on_error("release_interface", result);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void USB_Device::set_configuration(uint_t configuration)
|
||||
{
|
||||
log_info("usb, set configuration %u", configuration);
|
||||
|
||||
int result = libusb_set_configuration(handle_, configuration);
|
||||
if (result < 0)
|
||||
on_error("set_configuration", result);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void USB_Device::bulk_read(uint8_t endpoint, size_t count, uint8_t data[])
|
||||
{
|
||||
int transfered = 0;
|
||||
endpoint |= LIBUSB_ENDPOINT_IN;
|
||||
|
||||
ssize_t result = libusb_bulk_transfer(handle_, endpoint, data, count,
|
||||
&transfered, timeout_);
|
||||
|
||||
log_info("usb, bulk read, count %u: data: %s",
|
||||
count, binary_to_hex(data, transfered, " ").c_str());
|
||||
|
||||
if (result < 0)
|
||||
on_error("libusb_bulk_transfer (in)", result);
|
||||
|
||||
if ((int)count != transfered)
|
||||
on_timeout_error("libusb_bulk_transfer (in)", count, transfered);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void USB_Device::bulk_write(uint8_t endpoint, size_t count, const uint8_t data[])
|
||||
{
|
||||
log_info("usb, bulk write, count: %u, data: %s", count,
|
||||
binary_to_hex(data, count, " ").c_str());
|
||||
|
||||
int transfered = 0;
|
||||
endpoint |= LIBUSB_ENDPOINT_OUT;
|
||||
|
||||
ssize_t result = libusb_bulk_transfer(handle_, endpoint, const_cast<uint8_t*>(data), count,
|
||||
&transfered, timeout_);
|
||||
if (result < 0)
|
||||
on_error("libusb_bulk_transfer (out)", result);
|
||||
|
||||
if ((int)count != transfered)
|
||||
on_timeout_error("libusb_bulk_transfer (out)", count, transfered);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void USB_Device::control_write(uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue,
|
||||
uint16_t wIndex, const uint8_t data[], size_t count)
|
||||
{
|
||||
bmRequestType |= LIBUSB_ENDPOINT_OUT;
|
||||
|
||||
log_info("usb, control write, request_type: %02Xh, request: %02Xh, value: %04Xh, index: %04Xh, count: %u",
|
||||
bmRequestType, bRequest, wIndex, wValue, count);
|
||||
if (count)
|
||||
log_info("usb, control write, data: %s", binary_to_hex(data, count, " ").c_str());
|
||||
|
||||
ssize_t result = libusb_control_transfer(handle_, bmRequestType, bRequest,
|
||||
wValue, wIndex, const_cast<uint8_t*>(data), count, timeout_);
|
||||
if (result < 0)
|
||||
on_error("libusb_control_transfer (out)", result);
|
||||
|
||||
if (count && (ssize_t)count != result)
|
||||
on_timeout_error("libusb_control_transfer (out)", count, result);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
void USB_Device::control_read(uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue,
|
||||
uint16_t wIndex, uint8_t data[], size_t count)
|
||||
{
|
||||
bmRequestType |= LIBUSB_ENDPOINT_IN;
|
||||
|
||||
log_info("usb, control read, request_type: %02Xh, request: %02Xh, value: %04Xh, index: %04Xh, count: %u",
|
||||
bmRequestType, bRequest, wValue, wIndex, count);
|
||||
|
||||
ssize_t result = libusb_control_transfer(handle_, bmRequestType, bRequest,
|
||||
wValue, wIndex, data, count, timeout_);
|
||||
if (result < 0)
|
||||
on_error("libusb_control_transfer (in)", result);
|
||||
|
||||
if (count && (ssize_t)count != result)
|
||||
on_timeout_error("libusb_control_transfer (in)", count, result);
|
||||
|
||||
log_info("usb, control read, data: %s", binary_to_hex(data, count, " ").c_str());
|
||||
}
|
65
src/usb/usb_device.h
Normal file
65
src/usb/usb_device.h
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* usb_device.h
|
||||
*
|
||||
* Created on: Aug 2, 2011
|
||||
* Author: George Stark <george-u@yandex.com>
|
||||
*
|
||||
* License: GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _USB_DEVICE_H_
|
||||
#define _USB_DEVICE_H_
|
||||
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include "common.h"
|
||||
|
||||
typedef boost::shared_ptr<libusb_context> USB_ContextPtr;
|
||||
|
||||
class USB_Device : boost::noncopyable
|
||||
{
|
||||
public:
|
||||
enum DebugLevel { DL_OFF = 0, DL_ERROR, DL_WARNING, DL_INFORMATION };
|
||||
void set_debug_mode(DebugLevel level);
|
||||
|
||||
void set_transfer_timeout(uint_t timeout);
|
||||
|
||||
void set_configuration(uint_t configuration); // throw
|
||||
void claim_interface(uint_t interface_number); // throw
|
||||
void release_interface(uint_t interface_number); // throw
|
||||
|
||||
void device_decriptor(libusb_device_descriptor &descriptor); // throw
|
||||
void string_descriptor_utf8(uint8_t index, uint16_t language, String &data); // throw
|
||||
void string_descriptor_ascii(uint8_t index, String &data); // throw
|
||||
|
||||
void clear_halt(uint8_t endpoint);
|
||||
|
||||
void bulk_read(uint8_t endpoint, size_t count, uint8_t data[]); // throw
|
||||
void bulk_write(uint8_t endpoint, size_t count, const uint8_t data[]); // throw
|
||||
|
||||
void control_write(uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue,
|
||||
uint16_t wIndex, const uint8_t data[], size_t count); // throw
|
||||
|
||||
void control_read(uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue,
|
||||
uint16_t wIndex, uint8_t data[], size_t count); // throw
|
||||
|
||||
bool open_by_vid_pid(uint16_t vendor_id, uint16_t product_id); // throw
|
||||
bool open_by_address(uint8_t bus_number, uint8_t device_address); // throw
|
||||
bool opened() const;
|
||||
void close();
|
||||
|
||||
USB_Device();
|
||||
~USB_Device();
|
||||
|
||||
private:
|
||||
void init_context();
|
||||
void check_open();
|
||||
|
||||
USB_ContextPtr context_;
|
||||
libusb_device_handle *handle_;
|
||||
libusb_device *device_;
|
||||
uint_t timeout_;
|
||||
};
|
||||
|
||||
#endif // !_USB_DEVICE_H_
|
22
src/version.h
Normal file
22
src/version.h
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* File : version.h
|
||||
* Last changed : $Date: 2011-12-13 01:50:21 +0400 (Tue, 13 Dec 2011) $
|
||||
* Revision : $Rev: 189 $
|
||||
*
|
||||
* Author : George Stark <george-u@yandex.com>
|
||||
* License : GNU GPL v2
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _VERSION_H_
|
||||
#define _VERSION_H_
|
||||
|
||||
#include "common.h"
|
||||
|
||||
const uint_t VERSION_MAJOR = 0;
|
||||
const uint_t VERSION_MINOR = 16;
|
||||
|
||||
const char MODULE_NAME[] = "cc-tool";
|
||||
const char MODULE_DESCRIPTION[] = "Texas Instruments 8051-based System-On-Chip devices programmer using TI CC Debugger";
|
||||
|
||||
#endif // !_VERSION_H_
|
Loading…
x
Reference in New Issue
Block a user