Add software
1
Software/portapack-mayhem/hackrf/.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.brd linguist-language=KiCad
|
126
Software/portapack-mayhem/hackrf/.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
# Run automatically every monday
|
||||
schedule:
|
||||
- cron: 1 12 * * 1
|
||||
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
|
||||
jobs:
|
||||
host:
|
||||
strategy:
|
||||
matrix:
|
||||
os: ['macos-latest', 'ubuntu-latest']
|
||||
|
||||
# Don't cancel all builds when one fails
|
||||
fail-fast: false
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install dependencies (macOS)
|
||||
run: brew install fftw
|
||||
if: matrix.os == 'macos-latest'
|
||||
|
||||
- name: Install dependencies (Ubuntu)
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install libfftw3-dev libusb-1.0-0-dev
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
|
||||
- name: Create Build Environment
|
||||
run: cmake -E make_directory ${{runner.workspace}}/host/build
|
||||
|
||||
- name: Configure CMake
|
||||
shell: bash
|
||||
working-directory: ${{runner.workspace}}/host/build
|
||||
run: cmake $GITHUB_WORKSPACE/host/ -DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{runner.workspace}}/host/build
|
||||
shell: bash
|
||||
run: cmake --build . --config $BUILD_TYPE
|
||||
|
||||
- name: Create Build Environment (libhackrf)
|
||||
run: cmake -E make_directory ${{runner.workspace}}/host/libhackrf/build
|
||||
|
||||
- name: Configure CMake (libhackrf)
|
||||
shell: bash
|
||||
working-directory: ${{runner.workspace}}/host/libhackrf/build
|
||||
run: cmake $GITHUB_WORKSPACE/host/libhackrf/ -DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||
|
||||
- name: Build (libhackrf)
|
||||
working-directory: ${{runner.workspace}}/host/libhackrf/build
|
||||
shell: bash
|
||||
run: cmake --build . --config $BUILD_TYPE
|
||||
|
||||
- name: Install (libhackrf)
|
||||
working-directory: ${{runner.workspace}}/host/libhackrf/build
|
||||
shell: bash
|
||||
run: |
|
||||
sudo cmake --install . --config $BUILD_TYPE
|
||||
|
||||
- name: Create Build Environment (hackrf-tools)
|
||||
run: cmake -E make_directory ${{runner.workspace}}/host/hackrf-tools/build
|
||||
|
||||
- name: Configure CMake (hackrf-tools)
|
||||
shell: bash
|
||||
working-directory: ${{runner.workspace}}/host/hackrf-tools/build
|
||||
run: cmake $GITHUB_WORKSPACE/host/hackrf-tools/ -DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||
|
||||
- name: Build (hackrf-tools)
|
||||
working-directory: ${{runner.workspace}}/host/hackrf-tools/build
|
||||
shell: bash
|
||||
run: cmake --build . --config $BUILD_TYPE
|
||||
|
||||
firmware:
|
||||
strategy:
|
||||
matrix:
|
||||
os: ['macos-latest', 'ubuntu-latest']
|
||||
board: ['HACKRF_ONE', 'JAWBREAKER', 'RAD1O']
|
||||
|
||||
# Don't cancel all builds when one fails
|
||||
fail-fast: false
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Install dependencies (macOS)
|
||||
run: |
|
||||
brew tap armmbed/formulae
|
||||
brew install arm-none-eabi-gcc dfu-util
|
||||
pip install PyYAML
|
||||
if: matrix.os == 'macos-latest'
|
||||
|
||||
- name: Install dependencies (Ubuntu)
|
||||
run: |
|
||||
sudo apt install dfu-util gcc-arm-none-eabi
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
|
||||
- name: Build libopencm3
|
||||
shell: bash
|
||||
working-directory: ${{github.workspace}}/firmware/libopencm3/
|
||||
run: make
|
||||
|
||||
- name: Create Build Environment
|
||||
run: cmake -E make_directory ${{runner.workspace}}/firmware/build
|
||||
|
||||
- name: Configure CMake
|
||||
shell: bash
|
||||
working-directory: ${{runner.workspace}}/firmware/build
|
||||
run: cmake $GITHUB_WORKSPACE/firmware/ -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBOARD=${{ matrix.board }}
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{runner.workspace}}/firmware/build
|
||||
shell: bash
|
||||
run: cmake --build . --config $BUILD_TYPE
|
||||
|
75
Software/portapack-mayhem/hackrf/.gitignore
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
# Compiled output
|
||||
*.bin
|
||||
*.d
|
||||
*.elf
|
||||
*.hex
|
||||
*.srec
|
||||
host/build/
|
||||
host/**/build
|
||||
|
||||
# Operating system spew
|
||||
.DS_Store
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
# Editor junk
|
||||
*.swp
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
.vscode*
|
||||
|
||||
# Documentation Stuff
|
||||
docs/build/
|
||||
|
||||
# Xilinx tools create an enormous amount of poop:
|
||||
firmware/cpld/**/isim/
|
||||
firmware/cpld/**/_ngo/
|
||||
firmware/cpld/**/_xmsgs/
|
||||
firmware/cpld/**/iseconfig/
|
||||
firmware/cpld/**/*_html/
|
||||
firmware/cpld/**/xlnx_auto_0_xdb/
|
||||
firmware/cpld/**/xst/
|
||||
firmware/cpld/**/_*.cmd
|
||||
firmware/cpld/**/_*.log
|
||||
firmware/cpld/**/*.bld
|
||||
firmware/cpld/**/*.chk
|
||||
firmware/cpld/**/*.cmd
|
||||
firmware/cpld/**/*.cmd_log
|
||||
firmware/cpld/**/*.csv
|
||||
firmware/cpld/**/*.cxt
|
||||
firmware/cpld/**/*.dat
|
||||
firmware/cpld/**/*.err
|
||||
firmware/cpld/**/*.exe
|
||||
firmware/cpld/**/*.gise
|
||||
firmware/cpld/**/*.gyd
|
||||
firmware/cpld/**/*.html
|
||||
firmware/cpld/**/*.ini
|
||||
firmware/cpld/**/*.ipf
|
||||
firmware/cpld/**/*.log
|
||||
firmware/cpld/**/*.lso
|
||||
firmware/cpld/**/*.mfd
|
||||
firmware/cpld/**/*.ng[acdr]
|
||||
firmware/cpld/**/*.pad
|
||||
firmware/cpld/**/*.phd
|
||||
firmware/cpld/**/*.pnx
|
||||
firmware/cpld/**/*.prj
|
||||
firmware/cpld/**/*.rpt
|
||||
firmware/cpld/**/*.stx
|
||||
firmware/cpld/**/*.syr
|
||||
firmware/cpld/**/*.tim
|
||||
firmware/cpld/**/*.tspec
|
||||
firmware/cpld/**/*.vm6
|
||||
firmware/cpld/**/*.wcfg
|
||||
firmware/cpld/**/*.wdb
|
||||
firmware/cpld/**/*.xml
|
||||
firmware/cpld/**/*.xmsgs
|
||||
firmware/cpld/**/*.xrpt
|
||||
firmware/cpld/**/*.xsl
|
||||
firmware/cpld/**/*.xst
|
||||
firmware/cpld/**/*.xwbt
|
||||
|
||||
firmware/**/build
|
||||
|
||||
*.pyc
|
6
Software/portapack-mayhem/hackrf/.gitmodules
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
[submodule "firmware/libopencm3"]
|
||||
path = firmware/libopencm3
|
||||
url = https://github.com/mossmann/libopencm3.git
|
||||
[submodule "hardware/gsg-kicad-lib"]
|
||||
path = hardware/gsg-kicad-lib
|
||||
url = https://github.com/greatscottgadgets/gsg-kicad-lib.git
|
128
Software/portapack-mayhem/hackrf/CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,128 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, religion, or sexual identity
|
||||
and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the
|
||||
overall community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or
|
||||
advances of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email
|
||||
address, without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at
|
||||
straithe@greatscottgadgets.com.
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series
|
||||
of actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or
|
||||
permanent ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within
|
||||
the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.0, available at
|
||||
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
||||
|
||||
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
||||
enforcement ladder](https://github.com/mozilla/diversity).
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
https://www.contributor-covenant.org/faq. Translations are available at
|
||||
https://www.contributor-covenant.org/translations.
|
340
Software/portapack-mayhem/hackrf/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, 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) 19yy <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, 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) 19yy 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.
|
33
Software/portapack-mayhem/hackrf/Readme.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# HackRF
|
||||
|
||||
This repository contains hardware designs and software for HackRF,
|
||||
a low cost, open source Software Defined Radio platform.
|
||||
|
||||

|
||||
|
||||
(photo by fd0 from https://github.com/fd0/hackrf-one-pictures)
|
||||
|
||||
principal author: Michael Ossmann <mike@ossmann.com>
|
||||
|
||||
Information on HackRF and purchasing HackRF: https://greatscottgadgets.com/hackrf/
|
||||
|
||||
--------------------
|
||||
|
||||
# Documentation
|
||||
|
||||
Documentation for HackRF can be viewed on [Read the Docs](https://hackrf.readthedocs.io/en/latest/). The raw documenation files for HackRF are in the [docs folder](https://github.com/mossmann/hackrf/tree/master/docs) in this repository and can be built locally by installing [Sphinx Docs](https://www.sphinx-doc.org/en/master/usage/installation.html) and running `make html`. Documentation changes can be submitted through pull request and suggestions can be made as GitHub issues.
|
||||
|
||||
--------------------
|
||||
|
||||
# Getting Help
|
||||
|
||||
|
||||
Before asking for help with HackRF, check to see if your question is listed in the [FAQ](https://hackrf.readthedocs.io/en/latest/faq.html).
|
||||
|
||||
For assistance with HackRF general use or development, please look at the [issues on the GitHub project](https://github.com/greatscottgadgets/hackrf/issues). This is the preferred place to ask questions so that others may locate the answer to your question in the future.
|
||||
|
||||
We invite you to join our community discussions on [Discord](https://discord.gg/rsfMw3rsU8). Note that while technical support requests are welcome here, we do not have support staff on duty at all times. Be sure to also submit an issue on GitHub if you've found a bug or if you want to ensure that your request will be tracked and not overlooked.
|
||||
|
||||
If you wish to see past discussions and questions about HackRF, you may also view the [mailing list archives](https://pairlist9.pair.net/pipermail/hackrf-dev/).
|
||||
|
||||
GitHub issues on this repository that are labelled "technical support" by Great Scott Gadgets employees can expect a response time of two weeks. We currently do not have expected response times for other GitHub issues or pull requests for this repository.
|
3
Software/portapack-mayhem/hackrf/TRADEMARK
Normal file
@@ -0,0 +1,3 @@
|
||||
"HackRF" is a trademark of Great Scott Gadgets. Permission to use the trademark
|
||||
with attribution to Great Scott Gadgets is granted to all licensees of HackRF for
|
||||
the sole purpose of naming or describing copies or derived works. (See COPYING.)
|
52
Software/portapack-mayhem/hackrf/appveyor.yml
Normal file
@@ -0,0 +1,52 @@
|
||||
os: Visual Studio 2017
|
||||
clone_depth: 1
|
||||
|
||||
configuration:
|
||||
- Release
|
||||
|
||||
init:
|
||||
- C:\"Program Files (x86)"\"Microsoft Visual Studio 14.0"\VC\vcvarsall.bat %PLATFORM%
|
||||
install:
|
||||
# Dependencies for libHackRF
|
||||
- appveyor DownloadFile "https://github.com/libusb/libusb/releases/download/v1.0.22/libusb-1.0.22.7z" -FileName "C:\libusb.7z"
|
||||
- 7z x -y "C:\libusb.7z" -o"C:\libusb"
|
||||
- appveyor DownloadFile "http://mirrors.kernel.org/sourceware/pthreads-win32/pthreads-w32-2-9-1-release.zip" -FileName "C:\pthreads-w32-release.zip"
|
||||
- 7z x -y "C:\pthreads-w32-release.zip" -o"C:\pthreads"
|
||||
- appveyor DownloadFile "http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/pkg-config_0.26-1_win32.zip" -FileName "C:\pkg-config_win32.zip"
|
||||
- 7z x -y "C:\pkg-config_win32.zip" -o"C:\pkg-config"
|
||||
# FFTW for hackrf_sweep
|
||||
- curl -fsS -o "C:\fftw-3.3.5.zip" "ftp://ftp.fftw.org/pub/fftw/fftw-3.3.5-dll64.zip"
|
||||
- 7z x -y "C:\fftw-3.3.5.zip" -o"C:\fftw"
|
||||
- cd c:\fftw
|
||||
- ps: lib /machine:x64 /def:libfftw3f-3.def
|
||||
# ARM GCC for firmware builds
|
||||
# - appveyor DownloadFile "https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2017q2/gcc-arm-none-eabi-6-2017-q2-update-win32.zip" -FileName "C:\gcc-arm-none-eabi-win32.zip"
|
||||
# - 7z x -y "C:\gcc-arm-none-eabi-win32.zip" -o"C:\gcc-arm-none-eabi"
|
||||
# - set PATH=%PATH%;c:\gcc-arm-none-eabi\bin
|
||||
|
||||
build_script:
|
||||
# Host library and tools
|
||||
- mkdir c:\projects\hackrf\host\build
|
||||
- cd c:\projects\hackrf\host\build
|
||||
- cmake -G "Visual Studio 14 2015 Win64" \
|
||||
-DLIBUSB_LIBRARIES="C:\libusb\MS64\dll\libusb-1.0.lib" \
|
||||
-DLIBUSB_INCLUDE_DIR="C:\libusb\include\libusb-1.0" \
|
||||
-DTHREADS_PTHREADS_INCLUDE_DIR=c:\pthreads\Pre-built.2\include \
|
||||
-DTHREADS_PTHREADS_WIN32_LIBRARY=c:\pthreads\Pre-built.2\lib\x64\pthreadVC2.lib \
|
||||
-DPKG_CONFIG_EXECUTABLE="C:\pkg-config\bin\pkg-config.exe" \
|
||||
-DFFTW_INCLUDES=C:\fftw \
|
||||
-DFFTW_LIBRARIES=C:\fftw\libfftw3f-3.lib \
|
||||
..
|
||||
- msbuild HackRF.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||
# Firmware
|
||||
# - cd c:\projects\hackrf\
|
||||
# - git submodule init
|
||||
# - git submodule update
|
||||
# - '%CYG_BASH% -lc "cd $APPVEYOR_BUILD_FOLDER && firmware/appveyor.sh"'
|
||||
|
||||
after_build:
|
||||
- 7z a %APPVEYOR_BUILD_FOLDER%\HackRF-Windows-%APPVEYOR_REPO_COMMIT%.zip %APPVEYOR_BUILD_FOLDER%\host\build\libhackrf\src\Release\* %APPVEYOR_BUILD_FOLDER%\host\build\hackrf-tools\src\Release\*
|
||||
|
||||
artifacts:
|
||||
- path: HackRF-Windows-%APPVEYOR_REPO_COMMIT%.zip
|
||||
name: HackRF-Windows-%APPVEYOR_REPO_COMMIT%
|
11
Software/portapack-mayhem/hackrf/docs/.readthedocs.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
build:
|
||||
os: "ubuntu-20.04"
|
||||
tools:
|
||||
python: "3.9"
|
||||
|
||||
sphinx:
|
||||
configuration: conf.py
|
||||
|
||||
python:
|
||||
install:
|
||||
- requirements: requirements.txt
|
19
Software/portapack-mayhem/hackrf/docs/Makefile
Normal file
@@ -0,0 +1,19 @@
|
||||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
SOURCEDIR = source
|
||||
BUILDDIR = build
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
.PHONY: help Makefile
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
After Width: | Height: | Size: 679 KiB |
BIN
Software/portapack-mayhem/hackrf/docs/images/block-diagram.png
Normal file
After Width: | Height: | Size: 238 KiB |
4404
Software/portapack-mayhem/hackrf/docs/images/block-diagram.svg
Normal file
After Width: | Height: | Size: 263 KiB |
After Width: | Height: | Size: 161 KiB |
After Width: | Height: | Size: 127 KiB |
After Width: | Height: | Size: 138 KiB |
After Width: | Height: | Size: 77 KiB |
After Width: | Height: | Size: 162 KiB |
After Width: | Height: | Size: 560 KiB |
After Width: | Height: | Size: 138 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 162 KiB |
After Width: | Height: | Size: 127 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 453 KiB |
BIN
Software/portapack-mayhem/hackrf/docs/images/rf_shield_1.jpeg
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
Software/portapack-mayhem/hackrf/docs/images/rf_shield_2.jpg
Normal file
After Width: | Height: | Size: 51 KiB |
BIN
Software/portapack-mayhem/hackrf/docs/images/rf_shield_3.jpg
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
Software/portapack-mayhem/hackrf/docs/images/rf_shield_4.jpg
Normal file
After Width: | Height: | Size: 42 KiB |
BIN
Software/portapack-mayhem/hackrf/docs/images/rf_shield_5.jpg
Normal file
After Width: | Height: | Size: 292 KiB |
BIN
Software/portapack-mayhem/hackrf/docs/images/rf_shield_6.jpg
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
Software/portapack-mayhem/hackrf/docs/images/rf_shield_7.jpg
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
Software/portapack-mayhem/hackrf/docs/images/rf_shield_8.jpg
Normal file
After Width: | Height: | Size: 46 KiB |
BIN
Software/portapack-mayhem/hackrf/docs/images/rf_shield_9.jpg
Normal file
After Width: | Height: | Size: 36 KiB |
35
Software/portapack-mayhem/hackrf/docs/make.bat
Normal file
@@ -0,0 +1,35 @@
|
||||
@ECHO OFF
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set SOURCEDIR=source
|
||||
set BUILDDIR=build
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
%SPHINXBUILD% >NUL 2>NUL
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.http://sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
|
||||
goto end
|
||||
|
||||
:help
|
||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
|
||||
|
||||
:end
|
||||
popd
|
4
Software/portapack-mayhem/hackrf/docs/requirements.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
sphinx==1.8.5
|
||||
sphinx_rtd_theme==1.0.0
|
||||
readthedocs-sphinx-search==0.1.1
|
||||
jinja2==3.0.0
|
168
Software/portapack-mayhem/hackrf/docs/source/LPC4350.rst
Normal file
@@ -0,0 +1,168 @@
|
||||
================================================
|
||||
LPC4350 SGPIO Experimentation
|
||||
================================================
|
||||
|
||||
The NXP LPC43xx microcontrollers have an interesting, programmable serial peripheral called the SGPIO (Serial GPIO). It consists of a slew of counters and shift registers that can be configured to serialize and deserialize many channels of data. Channels can be grouped to create multi-bit parallel data streams.
|
||||
|
||||
The current HackRF design entails using the SGPIO peripheral to move quadrature baseband receive and transmit data between the USB interface and the baseband ADC/DAC IC. Because the baseband ADC/DAC IC (MAX5864) uses DDR signaling, we expect to use a CPLD to convert bus signaling. The CPLD may also help manage bus turnaround (between transmit and receive modes) or interfacing two narrower but faster interfaces to the LPC43xx to facilitate full-duplex.
|
||||
|
||||
Because the Jellybean board wasn't completed at the time of these experiments, I used the Diolan LPC-4350-DB1-A development board. Despite using an LPC4350 in an BGA256 package, the SGPIO peripheral's signals can be mapped to many different pins. So reworking code to a new set of SGPIO pins should be a trivial matter of switching the SGU configuration for the affected pins.
|
||||
|
||||
|
||||
|
||||
SGPIO Examples
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
Some SGPIO peripheral examples can be found in `the LPCWare repository <http://sw.lpcware.com/?p=lpc43xx.git&a=summary>`__. All source I've found so far is focused on generating many I2S interfaces, which is not very similar to HackRF's needs. But reviewing the code is still valuable in grasping how the SGPIO peripheral operates.
|
||||
|
||||
There are a few common details to setting up the SGPIO peripheral:
|
||||
|
||||
.. code-block :: C
|
||||
|
||||
// Configure the PLL to generate a reasonable clock. The SGPIO
|
||||
// will operate with a clock of up to 204MHz (the same as the
|
||||
// M4 clock.
|
||||
CGU_SetPLL1(12);
|
||||
|
||||
// Set the BASE_PERIPH clock to come from PLL1.
|
||||
CGU_EnableEntity(CGU_BASE_PERIPH, ENABLE);
|
||||
CGU_EntityConnect(CGU_CLKSRC_PLL1, CGU_BASE_PERIPH);
|
||||
|
||||
// Compute and commit clock configuration changes.
|
||||
CGU_UpdateClock();
|
||||
|
||||
|
||||
|
||||
Jiggle SGPIO Pins From GPIO Mode
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
My first test was to ensure I had the right pin(s) hooked up to my scope:
|
||||
|
||||
.. code-block :: C
|
||||
|
||||
// Jiggle one of the SGPIO pins in GPIO mode, to make sure
|
||||
// I'm looking at the right pin on the scope.
|
||||
scu_pinmux(9, 0, MD_PLN_FAST, 0);
|
||||
|
||||
GPIO_SetDir(4, 1L << 12, 1);
|
||||
|
||||
while(1) {
|
||||
volatile int i;
|
||||
GPIO_SetValue(4, 1L << 12);
|
||||
for(i=0; i<1000; i++);
|
||||
GPIO_ClearValue(4, 1L << 12);
|
||||
for(i=0; i<1000; i++);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Jiggle Pins from SGPIO Mode
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
You can also control SGPIO pins, GPIO-style, from within the SGPIO peripheral. This helped me understand the basics of operating the SGPIO output mux.
|
||||
|
||||
.. code-block :: C
|
||||
|
||||
// Set pin to SGPIO mode, toggle output using SGPIO
|
||||
// peripheral registers.
|
||||
scu_pinmux(9, 0, MD_PLN_FAST, 6); // SGPIO0
|
||||
|
||||
// P_OUT_CFG = 4, gpio_out
|
||||
// P_OE_CFG = X
|
||||
LPC_SGPIO->OUT_MUX_CFG[0] = (0L << 4) | (4L << 0);
|
||||
LPC_SGPIO->GPIO_OENREG |= (1L << 0);
|
||||
|
||||
while(1) {
|
||||
volatile int i;
|
||||
LPC_SGPIO->GPIO_OUTREG |= (1L << 0);
|
||||
for(i=0; i<1000; i++);
|
||||
LPC_SGPIO->GPIO_OUTREG &= ~(1L << 0);
|
||||
for(i=0; i<1000; i++);
|
||||
}
|
||||
|
||||
|
||||
Serializing Data With Slice Clock Source
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
My first full-on SGPIO experiment involved serializing a data pattern from slice A, using slice D to generate a SGPIO_CLK/2 data rate. I derived the code from examples that configured the SGPIO as I2S interfaces:
|
||||
|
||||
.. code-block :: C
|
||||
|
||||
// Disable all counters during configuration
|
||||
LPC_SGPIO->CTRL_ENABLED = 0;
|
||||
|
||||
// Configure pin functions.
|
||||
scu_pinmux(9, 0, MD_PLN_FAST, 6); // SGPIO0
|
||||
scu_pinmux(2, 3, MD_PLN_FAST, 0); // SGPIO12
|
||||
|
||||
// Enable SGPIO pin outputs.
|
||||
LPC_SGPIO->GPIO_OENREG =
|
||||
(1L << 12) | // SGPIO12
|
||||
(1L << 0); // SGPIO0
|
||||
|
||||
// SGPIO pin 0 outputs slice A bit 0.
|
||||
LPC_SGPIO->OUT_MUX_CFG[0] =
|
||||
(0L << 4) | // P_OE_CFG = X
|
||||
(0L << 0); // P_OUT_CFG = 0, dout_doutm1 (1-bit mode)
|
||||
|
||||
// SGPIO pin 12 outputs slice D bit 0.
|
||||
LPC_SGPIO->OUT_MUX_CFG[12] =
|
||||
(0L << 4) | // P_OE_CFG = X
|
||||
(0L << 0); // P_OUT_CFG = 0, dout_doutm1 (1-bit mode)
|
||||
|
||||
// Slice A
|
||||
LPC_SGPIO->SGPIO_MUX_CFG[0] =
|
||||
(0L << 12) | // CONCAT_ORDER = 0 (self-loop)
|
||||
(1L << 11) | // CONCAT_ENABLE = 1 (concatenate data)
|
||||
(0L << 9) | // QUALIFIER_SLICE_MODE = X
|
||||
(0L << 7) | // QUALIFIER_PIN_MODE = X
|
||||
(0L << 5) | // QUALIFIER_MODE = 0 (enable)
|
||||
(0L << 3) | // CLK_SOURCE_SLICE_MODE = 0, slice D
|
||||
(0L << 1) | // CLK_SOURCE_PIN_MODE = X
|
||||
(0L << 0); // EXT_CLK_ENABLE = 0, internal clock signal (slice)
|
||||
|
||||
LPC_SGPIO->SLICE_MUX_CFG[0] =
|
||||
(0L << 8) | // INV_QUALIFIER = 0 (use normal qualifier)
|
||||
(0L << 6) | // PARALLEL_MODE = 0 (shift 1 bit per clock)
|
||||
(0L << 4) | // DATA_CAPTURE_MODE = 0 (detect rising edge)
|
||||
(0L << 3) | // INV_OUT_CLK = 0 (normal clock)
|
||||
(0L << 2) | // CLKGEN_MODE = 0 (use clock from COUNTER)
|
||||
(0L << 1) | // CLK_CAPTURE_MODE = 0 (use rising clock edge)
|
||||
(0L << 0); // MATCH_MODE = 0 (do not match data)
|
||||
|
||||
LPC_SGPIO->PRESET[0] = 1;
|
||||
LPC_SGPIO->COUNT[0] = 0;
|
||||
LPC_SGPIO->POS[0] = (0x1FL << 8) | (0x1FL << 0);
|
||||
LPC_SGPIO->REG[0] = 0xAAAAAAAA; // Primary output data register
|
||||
LPC_SGPIO->REG_SS[0] = 0xAAAAAAAA; // Shadow output data register
|
||||
|
||||
// Slice D (clock for Slice A)
|
||||
LPC_SGPIO->SGPIO_MUX_CFG[3] =
|
||||
(0L << 12) | // CONCAT_ORDER = 0 (self-loop)
|
||||
(1L << 11) | // CONCAT_ENABLE = 1 (concatenate data)
|
||||
(0L << 9) | // QUALIFIER_SLICE_MODE = X
|
||||
(0L << 7) | // QUALIFIER_PIN_MODE = X
|
||||
(0L << 5) | // QUALIFIER_MODE = 0 (enable)
|
||||
(0L << 3) | // CLK_SOURCE_SLICE_MODE = 0, slice D
|
||||
(0L << 1) | // CLK_SOURCE_PIN_MODE = X
|
||||
(0L << 0); // EXT_CLK_ENABLE = 0, internal clock signal (slice)
|
||||
|
||||
LPC_SGPIO->SLICE_MUX_CFG[3] =
|
||||
(0L << 8) | // INV_QUALIFIER = 0 (use normal qualifier)
|
||||
(0L << 6) | // PARALLEL_MODE = 0 (shift 1 bit per clock)
|
||||
(0L << 4) | // DATA_CAPTURE_MODE = 0 (detect rising edge)
|
||||
(0L << 3) | // INV_OUT_CLK = 0 (normal clock)
|
||||
(0L << 2) | // CLKGEN_MODE = 0 (use clock from COUNTER)
|
||||
(0L << 1) | // CLK_CAPTURE_MODE = 0 (use rising clock edge)
|
||||
(0L << 0); // MATCH_MODE = 0 (do not match data)
|
||||
|
||||
LPC_SGPIO->PRESET[3] = 0;
|
||||
LPC_SGPIO->COUNT[3] = 0;
|
||||
LPC_SGPIO->POS[3] = (0x1FL << 8) | (0x1FL << 0);
|
||||
LPC_SGPIO->REG[0] = 0xAAAAAAAA; // Primary output data register
|
||||
LPC_SGPIO->REG_SS[0] = 0xAAAAAAAA; // Shadow output data register
|
||||
|
||||
// Start SGPIO operation by enabling slice clocks.
|
||||
LPC_SGPIO->CTRL_ENABLED =
|
||||
(1L << 3) | // Slice D
|
||||
(1L << 0); // Slice A
|
@@ -0,0 +1,206 @@
|
||||
================================================
|
||||
LPC43xx Debugging
|
||||
================================================
|
||||
|
||||
Various debugger options for the LPC43xx exist.
|
||||
|
||||
Black Magic Probe
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
`https://github.com/blacksphere/blackmagic <https://github.com/blacksphere/blackmagic>`__
|
||||
|
||||
An example of using gdb with the Black Magic Probe:
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
arm-none-eabi-gdb -n blinky.elf
|
||||
target extended-remote /dev/ttyACM0
|
||||
monitor swdp_scan
|
||||
attach 1
|
||||
set {int}0x40043100 = 0x10000000
|
||||
load
|
||||
cont
|
||||
|
||||
It is possible to attach to the M0 instead of the M4 if you use jtag_scan instead of swdp_scan, but the Black Magic Probe had some bugs when trying to work with the M0 the last time I tried it.
|
||||
|
||||
|
||||
|
||||
LPC-Link
|
||||
~~~~~~~~
|
||||
|
||||
(included with LPCXpresso boards)
|
||||
|
||||
TitanMKD has had some success. See the tutorial in hackrf/doc/LPCXPresso_Flash_Debug_Tutorial.pdf or .odt (PDF and OpenOffice document) Doc Link [https://github.com/mossmann/hackrf/tree/master/doc)
|
||||
|
||||
|
||||
|
||||
ST-LINK/V2
|
||||
~~~~~~~~~~
|
||||
|
||||
Hardware Configuration
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Start with an STM32F4-Discovery board. Remove the jumpers from CN3. Connect the target's SWD interface to CN2 "SWD" connector.
|
||||
|
||||
|
||||
|
||||
Software Configuration
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
I'm using libusb-1.0.9.
|
||||
|
||||
Install OpenOCD-0.6.0 dev
|
||||
+++++++++++++++++++++++++
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
# Cloned at hash a21affa42906f55311ec047782a427fcbcb98994
|
||||
git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd
|
||||
cd openocd
|
||||
./bootstrap
|
||||
./configure --enable-stlink --enable-buspirate --enable-jlink --enable-maintainer-mode
|
||||
make
|
||||
sudo make install
|
||||
|
||||
|
||||
|
||||
OpenOCD configuration files
|
||||
+++++++++++++++++++++++++++
|
||||
|
||||
openocd.cfg
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
#debug_level 3
|
||||
source [find interface/stlink-v2.cfg]
|
||||
source ./lpc4350.cfg
|
||||
|
||||
lpc4350.cfg
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
set _CHIPNAME lpc4350
|
||||
set _M0_CPUTAPID 0x4ba00477
|
||||
set _M4_SWDTAPID 0x2ba01477
|
||||
set _M0_TAPID 0x0BA01477
|
||||
set _TRANSPORT stlink_swd
|
||||
|
||||
transport select $_TRANSPORT
|
||||
|
||||
stlink newtap $_CHIPNAME m4 -expected-id $_M4_SWDTAPID
|
||||
stlink newtap $_CHIPNAME m0 -expected-id $_M0_TAPID
|
||||
|
||||
target create $_CHIPNAME.m4 stm32_stlink -chain-position $_CHIPNAME.m4
|
||||
#target create $_CHIPNAME.m0 stm32_stlink -chain-position $_CHIPNAME.m0
|
||||
|
||||
target.xml, nabbed from an OpenOCD mailing list thread, to fix a communication problem between GDB and newer OpenOCD builds.
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE target SYSTEM "gdb-target.dtd">
|
||||
<target>
|
||||
<feature name="org.gnu.gdb.arm.core">
|
||||
<reg name="r0" bitsize="32" type="uint32"/>
|
||||
<reg name="r1" bitsize="32" type="uint32"/>
|
||||
<reg name="r2" bitsize="32" type="uint32"/>
|
||||
<reg name="r3" bitsize="32" type="uint32"/>
|
||||
<reg name="r4" bitsize="32" type="uint32"/>
|
||||
<reg name="r5" bitsize="32" type="uint32"/>
|
||||
<reg name="r6" bitsize="32" type="uint32"/>
|
||||
<reg name="r7" bitsize="32" type="uint32"/>
|
||||
<reg name="r8" bitsize="32" type="uint32"/>
|
||||
<reg name="r9" bitsize="32" type="uint32"/>
|
||||
<reg name="r10" bitsize="32" type="uint32"/>
|
||||
<reg name="r11" bitsize="32" type="uint32"/>
|
||||
<reg name="r12" bitsize="32" type="uint32"/>
|
||||
<reg name="sp" bitsize="32" type="data_ptr"/>
|
||||
<reg name="lr" bitsize="32"/>
|
||||
<reg name="pc" bitsize="32" type="code_ptr"/>
|
||||
<reg name="cpsr" bitsize="32" regnum="25"/>
|
||||
</feature>
|
||||
<feature name="org.gnu.gdb.arm.fpa">
|
||||
<reg name="f0" bitsize="96" type="arm_fpa_ext" regnum="16"/>
|
||||
<reg name="f1" bitsize="96" type="arm_fpa_ext"/>
|
||||
<reg name="f2" bitsize="96" type="arm_fpa_ext"/>
|
||||
<reg name="f3" bitsize="96" type="arm_fpa_ext"/>
|
||||
<reg name="f4" bitsize="96" type="arm_fpa_ext"/>
|
||||
<reg name="f5" bitsize="96" type="arm_fpa_ext"/>
|
||||
<reg name="f6" bitsize="96" type="arm_fpa_ext"/>
|
||||
<reg name="f7" bitsize="96" type="arm_fpa_ext"/>
|
||||
<reg name="fps" bitsize="32"/>
|
||||
</feature>
|
||||
</target>
|
||||
|
||||
|
||||
Run ARM GDB
|
||||
~~~~~~~~~~~
|
||||
|
||||
Soon, I should dump this stuff into a .gdbinit file.
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
arm-none-eabi-gdb -n
|
||||
target extended-remote localhost:3333
|
||||
set tdesc filename target.xml
|
||||
monitor reset init
|
||||
monitor mww 0x40043100 0x10000000
|
||||
monitor mdw 0x40043100 # Verify 0x0 shadow register is set properly.
|
||||
file lpc4350-test.axf # This is an ELF file.
|
||||
load # Place image into RAM.
|
||||
monitor reset init
|
||||
break main # Set a breakpoint.
|
||||
continue # Run to breakpoint.
|
||||
continue # To continue from the breakpoint.
|
||||
step # Step-execute the next source line.
|
||||
stepi # Step-execute the next processor instruction.
|
||||
info reg # Show processor registers.
|
||||
|
||||
More GDB tips for the GDB-unfamiliar:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
# Write the variable "buffer" (an array) to file "buffer.u8".
|
||||
dump binary value buffer.u8 buffer
|
||||
|
||||
# Display the first 32 values in buffer whenever you halt
|
||||
# execution.
|
||||
display/32xh buffer
|
||||
|
||||
# Print the contents of a range of registers (in this case the
|
||||
# CGU peripheral, starting at 0x40050014, for 46 words):
|
||||
x/46 0x40050014
|
||||
|
||||
And still more, for debugging ARM Cortex-M4 Hard Faults:
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
# Assuming you have a hard-fault handler wired in:
|
||||
display/8xw args
|
||||
|
||||
# Examine fault-related registers:
|
||||
|
||||
# Configurable Fault Status Register (CFSR) contains:
|
||||
# CFSR[15:8]: BusFault Status Register (BFSR)
|
||||
# "Shows the status of bus errors resulting from instruction
|
||||
# prefetches and data accesses."
|
||||
# BFSR[7]: BFARVALID: BFSR contents valid.
|
||||
# BFSR[5]: LSPERR: fault during FP lazy state preservation.
|
||||
# BFSR[4]: STKERR: derived bus fault on exception entry.
|
||||
# BFSR[3]: UNSTKERR: derived bus fault on exception return.
|
||||
# BFSR[2]: IMPRECISERR: imprecise data access error.
|
||||
# BFSR[1]: PRECISERR: precise data access error, faulting
|
||||
# address in BFAR.
|
||||
# BFSR[0]: IBUSERR: bus fault on instruction prefetch. Occurs
|
||||
# only if instruction is issued.
|
||||
display/xw 0xE000ED28
|
||||
|
||||
# BusFault Address Register (BFAR)
|
||||
# "Shows the address associated with a precise data access fault."
|
||||
# "This is the location addressed by an attempted data access that
|
||||
# was faulted. The BFSR shows the reason for the fault and whether
|
||||
# BFAR_ADDRESS is valid..."
|
||||
# "For unaligned access faults, the value returned is the address
|
||||
# requested by the instruction. This might not be the address that
|
||||
# faulted."
|
||||
display/xw 0xE000ED38
|
@@ -0,0 +1,28 @@
|
||||
================================================
|
||||
LPC43xx SGPIO Configuration
|
||||
================================================
|
||||
|
||||
The LPC43xx SGPIO peripheral is used to move samples between USB and the ADC/DAC chip (MAX5864). The SGPIO is a peripheral that has a bunch of 32-bit shift registers. These shift registers can be configured to act as a parallel interface of different widths. For HackRF, we configure the SGPIO to transfer eight bits at a time. The SGPIO interface can also accept an external clock, which we use to synchronize transfers with the sample clock.
|
||||
|
||||
In the current HackRF design, there is a CPLD which manages the interface between the MAX5864 and the SGPIO interface. There are four SGPIO signals that control the SGPIO data transfer:
|
||||
|
||||
* Clock: Determines when a value on the SGPIO data bus is transferred.
|
||||
* Direction: Determines whether the MAX5864 DA (ADC) data is driven onto the SGPIO lines, or if the SGPIO lines drive the data bus with data for the MAX5864 DD (DAC) signals.
|
||||
* Data Valid: Indicates a sample on the SGPIO data bus is valid data.
|
||||
* Transfer Enable: Allows SGPIO to synchronize with the I/Q data stream. The MAX5864 produces/consumes two values (quadrature/complex value) per sample period -- an I value and a Q value. These two values are multiplexed on the SGPIO lines. This signal suspends data valid until the I value should be transferred.
|
||||
|
||||
|
||||
|
||||
Frequently Asked Questions
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Why not use GPDMA to transfer samples through SGPIO?
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
It would be great if we could, as that would free up lots of processor time. Unfortunately, the GPDMA scheme in the LPC43xx does not seem to support peripheral-to-memory and memory-to-peripheral transfers with the SGPIO peripheral.
|
||||
|
||||
You might observe that the SGPIO peripheral can generate requests from SGPIO14 and SGPIO15, using an arbitrary bit pattern in the slice shift register. The pattern in the slice determines the request interval. That's a good start. However, how do you specify which SGPIO shadow registers are read/written at each request, and in which order those registers are transferred with memory? It turns out you can't. In fact, it appears that an SGPIO request doesn't cause any transfer at all, if your source or destination is "peripheral". Instead, the SGPIO request is intended to perform a memory-to-memory transfer synchronized with SGPIO. But you're on your own as far as getting data to/from the SGPIO shadow registers. I believe this is why the SGPIO camera example in the user manual describes an SGPIO interrupt doing the SGPIO shadow register transfer, and the GPDMA doing moves from one block of RAM to another.
|
||||
|
||||
Perhaps if we transfer only one SGPIO shadow register, using memory-to-memory? Then we don't have to worry about the order of SGPIO registers, or which ones need to be transferred. It turns out that when you switch over to memory-to-memory transfers, you lose peripheral request generation. So the GPDMA will transfer as fast as possible -- far faster than words are produced/consumed by SGPIO.
|
||||
|
||||
I'd really love to be wrong about all this, but all my testing has indicated there's no workable solution to using GPDMA that's any better than using SGPIO interrupts to transfer samples. If you want some sample GPDMA code to experiment with, please contact Jared (sharebrained on #hackrf in Discord or IRC).
|
38
Software/portapack-mayhem/hackrf/docs/source/clocking.rst
Normal file
@@ -0,0 +1,38 @@
|
||||
================================================
|
||||
Clocking Signals
|
||||
================================================
|
||||
|
||||
|
||||
|
||||
HackRF clock signals are generated by the Si5351. The plan so far:
|
||||
|
||||
* crystal frequency: 25 MHz (supports 25 or 27 MHz)
|
||||
* optional clock input frequency: 10 MHz recommended (supports 10 to 40 MHz, or higher with division)
|
||||
* VCO frequency: 800 MHz (supports 600 to 900 MHz)
|
||||
* MAX2837 clock: 40 MHz
|
||||
* preferred MAX5864 clocks: 8, 10, 12.5, 16, 20 MHz
|
||||
* A clock at double the MAX5864 rate will be delivered to the CPLD and SGPIO.
|
||||
* LPC43xx clock: 12 MHz (from separate crystal so the ROM-based USB DFU will work)
|
||||
|
||||
Lemondrop+Jellybean Si5351 output mapping:
|
||||
|
||||
* CLK0 -> MAX2837
|
||||
* CLK1 -> MAX5864/CPLD
|
||||
* CLK2 -> CPLD
|
||||
* CLK3 -> CPLD
|
||||
* CLK4 -> LPC4330
|
||||
* CLK5 -> RFFC5072
|
||||
* CLK6 -> extra
|
||||
* CLK7 -> extra
|
||||
|
||||
Jawbreaker output mapping:
|
||||
|
||||
* CLK0 -> MAX5864/CPLD
|
||||
* CLK1 -> CPLD
|
||||
* CLK2 -> SGPIO
|
||||
* CLK3 -> external clock output
|
||||
* CLK4 -> RFFC5072
|
||||
* CLK5 -> MAX2837
|
||||
* CLK6 -> none
|
||||
* CLK7 -> LPC4330 (but LPC4330 will start up on its own crystal)
|
||||
|
32
Software/portapack-mayhem/hackrf/docs/source/conf.py
Normal file
@@ -0,0 +1,32 @@
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = 'HackRF'
|
||||
copyright = '2021, Great Scott Gadgets'
|
||||
author = 'Great Scott Gadgets'
|
||||
|
||||
# The short X.Y version
|
||||
version = ''
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = ''
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc'
|
||||
]
|
||||
|
||||
templates_path = ['_templates']
|
||||
exclude_patterns = ['_build']
|
||||
source_suffix = '.rst'
|
||||
master_doc = 'index'
|
||||
language = None
|
||||
exclude_patterns = []
|
||||
pygments_style = None
|
||||
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
html_css_files = ['status.css']
|
||||
|
@@ -0,0 +1,29 @@
|
||||
================================================
|
||||
Design Goals
|
||||
================================================
|
||||
|
||||
Eventually, the HackRF project may result in multiple hardware designs, but the initial goal is to build a single wideband transceiver peripheral that can be attached to a general purpose computer for software radio functions.
|
||||
|
||||
Primary goals:
|
||||
|
||||
* half-duplex transceiver
|
||||
* operating freq: 100 MHz to 6 GHz
|
||||
* maximum sample rate: 20 Msps
|
||||
* resolution: 8 bits
|
||||
* interface: High Speed USB
|
||||
* power supply: USB bus power
|
||||
* portable
|
||||
* open source
|
||||
|
||||
Wish list:
|
||||
|
||||
* full-duplex (at reduced max sample rate)
|
||||
* external clock reference
|
||||
* dithering
|
||||
* parallel interface for external FPGA, etc.
|
||||
|
||||
If there is a primary goal we miss, it will probably be the operating frequency range. The wideband front end is the part of the design furthest from completion. At an absolute minimum, the board should do 900 MHz and 2.4 GHz.
|
||||
|
||||
The design is FPGA-less. There will be a tiny bit of DSP capability (ARM Cortex-M4), but mostly we're just trying to get samples to and from a host computer.
|
||||
|
||||
We are trading resolution and DSP capability for cost, portability, and frequency range. Considering that we'll be able to support oversampling for many applications and that we should be able to implement AGC, it should be a pretty good trade.
|
@@ -0,0 +1,8 @@
|
||||
Enclosure Options
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
The commercial version of HackRF One from Great Scott Gadgets ships with an injection molded plastic enclosure, but it is designed to fit two optional enclosures:
|
||||
|
||||
* Hammond 1455J1201: HackRF One fits this extruded aluminum enclosure and other similar models from Hammond Manufacturing. In order to use the enclosure's end plates, you will have to drill them. An end plate template can be found in the HackRF One KiCad layout.
|
||||
|
||||
* Acrylic sandwich: You can also use a laser cut acrylic enclosure with HackRF One. This is a good option for access to the expansion headers. A design can be found in the HackRF One hardware directory. Use any laser cutting service or purchase from a `reseller <http://greatscottgadgets.com/acrylic_case/>`__.
|
@@ -0,0 +1,236 @@
|
||||
Expansion Interface
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The HackRF One expansion interface consists of headers P9, P20, P22, and P28. These four headers are installed on the commercial HackRF One from Great Scott Gadgets.
|
||||
|
||||
|
||||
|
||||
P9 Baseband
|
||||
^^^^^^^^^^^
|
||||
|
||||
A direct analog interface to the high speed dual ADC and dual DAC.
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1
|
||||
|
||||
* - Pin
|
||||
- Function
|
||||
* - 1
|
||||
- GND
|
||||
* - 2
|
||||
- GND
|
||||
* - 3
|
||||
- GND
|
||||
* - 4
|
||||
- RXBBQ-
|
||||
* - 5
|
||||
- RXBBI-
|
||||
* - 6
|
||||
- RXBBQ+
|
||||
* - 7
|
||||
- RXBBI+
|
||||
* - 8
|
||||
- GND
|
||||
* - 9
|
||||
- GND
|
||||
* - 10
|
||||
- TXBBI-
|
||||
* - 11
|
||||
- TXBBQ+
|
||||
* - 12
|
||||
- TXBBI+
|
||||
* - 13
|
||||
- TXBBQ-
|
||||
* - 14
|
||||
- GND
|
||||
* - 15
|
||||
- GND
|
||||
* - 16
|
||||
- GND
|
||||
|
||||
|
||||
|
||||
P20 GPIO
|
||||
^^^^^^^^
|
||||
|
||||
Providing access to GPIO, ADC, RTC, and power.
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1
|
||||
|
||||
* - Pin
|
||||
- Function
|
||||
* - 1
|
||||
- VBAT
|
||||
* - 2
|
||||
- RTC_ALARM
|
||||
* - 3
|
||||
- VCC
|
||||
* - 4
|
||||
- WAKEUP
|
||||
* - 5
|
||||
- GPIO3_8
|
||||
* - 6
|
||||
- GPIO3_0
|
||||
* - 7
|
||||
- GPIO3_10
|
||||
* - 8
|
||||
- GPIO3_11
|
||||
* - 9
|
||||
- GPIO3_12
|
||||
* - 10
|
||||
- GPIO3_13
|
||||
* - 11
|
||||
- GPIO3_14
|
||||
* - 12
|
||||
- GPIO3_15
|
||||
* - 13
|
||||
- GND
|
||||
* - 14
|
||||
- ADC0_6
|
||||
* - 15
|
||||
- GND
|
||||
* - 16
|
||||
- ADC0_2
|
||||
* - 17
|
||||
- VBUSCTRL
|
||||
* - 18
|
||||
- ADC0_5
|
||||
* - 19
|
||||
- GND
|
||||
* - 20
|
||||
- ADC0_0
|
||||
* - 21
|
||||
- VBUS
|
||||
* - 22
|
||||
- VIN
|
||||
|
||||
|
||||
|
||||
P22 I2S
|
||||
^^^^^^^
|
||||
|
||||
I2S, SPI, I2C, UART, GPIO, and clocks.
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1
|
||||
|
||||
* - Pin
|
||||
- Function
|
||||
* - 1
|
||||
- CLKOUT
|
||||
* - 2
|
||||
- CLKIN
|
||||
* - 3
|
||||
- RESET
|
||||
* - 4
|
||||
- GND
|
||||
* - 5
|
||||
- I2C1_SCL
|
||||
* - 6
|
||||
- I2C1_SDA
|
||||
* - 7
|
||||
- SPIFI_MISO
|
||||
* - 8
|
||||
- SPIFI_SCK
|
||||
* - 9
|
||||
- SPIFI_MOSI
|
||||
* - 10
|
||||
- GND
|
||||
* - 11
|
||||
- VCC
|
||||
* - 12
|
||||
- I2S0_RX_SCK
|
||||
* - 13
|
||||
- I2S_RX_SDA
|
||||
* - 14
|
||||
- I2S0_RX_MCLK
|
||||
* - 15
|
||||
- I2S0_RX_WS
|
||||
* - 16
|
||||
- I2S0_TX_SCK
|
||||
* - 17
|
||||
- I2S0_TX_MCLK
|
||||
* - 18
|
||||
- GND
|
||||
* - 19
|
||||
- U0_RXD
|
||||
* - 20
|
||||
- U0_TXD
|
||||
* - 21
|
||||
- P2_9
|
||||
* - 22
|
||||
- P2_13
|
||||
* - 23
|
||||
- P2_8
|
||||
* - 24
|
||||
- SDA
|
||||
* - 25
|
||||
- CLK6
|
||||
* - 26
|
||||
- SCL
|
||||
|
||||
|
||||
|
||||
P28 SD
|
||||
^^^^^^
|
||||
|
||||
SDIO, GPIO, clocks, and CPLD.
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1
|
||||
|
||||
* - Pin
|
||||
- Function
|
||||
* - 1
|
||||
- VCC
|
||||
* - 2
|
||||
- GND
|
||||
* - 3
|
||||
- SD_CD
|
||||
* - 4
|
||||
- SD_DAT3
|
||||
* - 5
|
||||
- SD_DAT2
|
||||
* - 6
|
||||
- SD_DAT1
|
||||
* - 7
|
||||
- SD_DAT0
|
||||
* - 8
|
||||
- SD_VOLT0
|
||||
* - 9
|
||||
- SD_CMD
|
||||
* - 10
|
||||
- SD_POW
|
||||
* - 11
|
||||
- SD_CLK
|
||||
* - 12
|
||||
- GND
|
||||
* - 13
|
||||
- GCK2
|
||||
* - 14
|
||||
- GCK1
|
||||
* - 15
|
||||
- B1AUX14
|
||||
* - 16
|
||||
- B1AUX13
|
||||
* - 17
|
||||
- CPLD_TCK
|
||||
* - 18
|
||||
- BANK2F3M2
|
||||
* - 19
|
||||
- CPLD_TDI
|
||||
* - 20
|
||||
- BANK2F3M6
|
||||
* - 21
|
||||
- BANK2F3M12
|
||||
* - 22
|
||||
- BANK2F3M4
|
||||
|
||||
Additional unpopulated headers and test points are available for test and development, but they may be incompatible with some enclosure or expansion options.
|
||||
|
||||
Refer to the schematics and component documentation for more information.
|
@@ -0,0 +1,11 @@
|
||||
===========================================
|
||||
External Clock Interface (CLKIN and CLKOUT)
|
||||
===========================================
|
||||
|
||||
HackRF One produces a 10 MHz clock signal on CLKOUT. The signal is a 10 MHz square wave from 0 V to 3 V intended for a high impedance load.
|
||||
|
||||
The CLKIN port on HackRF One is a high impedance input that expects a 0 V to 3 V square wave at 10 MHz. Do not exceed 3.3 V or drop below 0 V on this input. Do not connect a clock signal at a frequency other than 10 MHz (unless you modify the firmware to support this). You may directly connect the CLKOUT port of one HackRF One to the CLKIN port of another HackRF One.
|
||||
|
||||
HackRF One uses CLKIN instead of the internal crystal when a clock signal is detected on CLKIN. The switch to or from CLKIN only happens when a transmit or receive operation begins.
|
||||
|
||||
To verify that a signal has been detected on CLKIN, use ``hackrf_debug --si5351c -n 0 -r``. The expected output with a clock detected is `[ 0] -> 0x01`. The expected output with no clock detected is `[ 0] -> 0x51`.
|
144
Software/portapack-mayhem/hackrf/docs/source/faq.rst
Normal file
@@ -0,0 +1,144 @@
|
||||
.. _faq:
|
||||
|
||||
================================================
|
||||
FAQ
|
||||
================================================
|
||||
|
||||
|
||||
What is the Transmit Power of HackRF?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
HackRF One's absolute maximum TX power varies by operating frequency:
|
||||
|
||||
* 1 MHz to 10 MHz: 5 dBm to 15 dBm, generally increasing as frequency increases (see this `blog post <https://greatscottgadgets.com/2015/05-15-hackrf-one-at-1-mhz/>`__)
|
||||
* 10 MHz to 2150 MHz: 5 dBm to 15 dBm, generally decreasing as frequency increases
|
||||
* 2150 MHz to 2750 MHz: 13 dBm to 15 dBm
|
||||
* 2750 MHz to 4000 MHz: 0 dBm to 5 dBm, decreasing as frequency increases
|
||||
* 4000 MHz to 6000 MHz: -10 dBm to 0 dBm, generally decreasing as frequency increases
|
||||
|
||||
Through most of the frequency range up to 4 GHz, the maximum TX power is between 0 and 10 dBm. The frequency range with best performance is 2150 MHz to 2750 MHz.
|
||||
|
||||
Overall, the output power is enough to perform over-the-air experiments at close range or to drive an external amplifier. If you connect an external amplifier, you should also use an external bandpass filter for your operating frequency.
|
||||
|
||||
Before you transmit, know your laws. HackRF One has not been tested for compliance with regulations governing transmission of radio signals. You are responsible for using your HackRF One legally.
|
||||
|
||||
|
||||
----
|
||||
|
||||
|
||||
What is the Receive Power of HackRF?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The maximum RX power of HackRF One is -5 dBm. Exceeding -5 dBm can result in permanent damage!
|
||||
|
||||
In theory, HackRF One can safely accept up to 10 dBm with the front-end RX amplifier disabled. However, a simple software or user error could enable the amplifier, resulting in permanent damage. It is better to use an external attenuator than to risk damage.
|
||||
|
||||
|
||||
----
|
||||
|
||||
|
||||
What is the minimum signal power level that can be detected by HackRF?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This isn't a question that can be answered for a general purpose SDR platform such as HackRF. Any answer would be very specific to a particular application. For example, an answerable question might be: What is the minimum power level in dBm of modulation M at frequency F that can be detected by HackRF One with software S under configuration C at a bit error rate of no more than E%? Changing any of those variables (M, F, S, C, or E) would change the answer to the question. Even a seemingly minor software update might result in a significantly different answer. To learn the exact answer for a specific application, you would have to measure it yourself.
|
||||
|
||||
HackRF's concrete specifications include operating frequency range, maximum sample rate, and dynamic range in bits. These specifications can be used to roughly determine the suitability of HackRF for a given application. Testing is required to finely measure performance in an application. Performance can typically be enhanced significantly by selecting an appropriate antenna, external amplifier, and/or external filter for the application.
|
||||
|
||||
|
||||
----
|
||||
|
||||
|
||||
Is HackRF full-duplex?
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
HackRF One is a half-duplex transceiver. This means that it can transmit or receive but not both at the same time.
|
||||
|
||||
|
||||
----
|
||||
|
||||
|
||||
Why isn't HackRF One full-duplex?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
HackRF One is designed to support the widest possible range of SDR applications in a single, low cost, portable device. Many applications do not require full-duplex operation. Full-duplex support would have made HackRF larger and more expensive, and it would have required an external power supply. Since full-duplex needs can be met by simply using a second HackRF One, it made sense to keep the device small, portable, and low cost for everyone who does not require full-duplex operation.
|
||||
|
||||
|
||||
----
|
||||
|
||||
|
||||
How could the HackRF One design be changed to make it full-duplex?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The HackRF One hardware design is actually full-duplex (at lower sample rates) from the USB connection through the ADC/DAC. The RF section is the only part of the design that cannot support full-duplex operation. The easiest way to make HackRF One full-duplex would be to create an add-on board that duplicates the RF section and also provides an external power input (from a wall wart, for example) for the additional power required. This would also require software effort; the firmware, CPLD, libhackrf, and other host software would all need work to support full-duplex operation.
|
||||
|
||||
If you were to try to redesign the RF section on HackRF One to support full-duplex, the main thing to focus on would be the MAX2837 (intermediate frequency transceiver). This part is half-duplex, so you would either need two of them or you would have to redesign the RF section to use something other than the MAX2837, likely resulting in a radically different design. If you used two MAX2837s you might be able to use one RFFC5071 instead of two RFFC5072s.
|
||||
|
||||
|
||||
----
|
||||
|
||||
|
||||
Are those connectors SMA or RP-SMA?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Some connectors that appear to be SMA are actually RP-SMA. If you connect an RP-SMA antenna to HackRF One, it will seem to connect snugly but won't function at all because neither the male nor female side has a center pin. RP-SMA connectors are most common on 2.4 GHz antennas and are popular on Wi-Fi equipment. Adapters are available.
|
||||
|
||||
|
||||
----
|
||||
|
||||
|
||||
.. _bigspike:
|
||||
|
||||
What is the big spike in the center of my received spectrum?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
If you see a large spike in the center of your FFT display regardless of the frequenecy you are tuned to, you are seeing a DC offset (or component or bias). The term "DC" comes from "Direct Current" in electronics. It is the unchanging aspect of a signal as opposed to the "alternating" part of the signal (AC) that changes over time. Take, for example, the signal represented by the digital sequence:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
-2, -1, 1, 6, 8, 9, 8, 6, 1, -1, -2, -1, 1, 6, 8, 9, 8, 6, 1, -1, -2, -1, 1, 6, 8, 9, 8, 6, 1, -1
|
||||
|
||||
This periodic signal contains a strong sinusoidal component spanning from -2 to 9. If you were to plot the spectrum of this signal, you would see one spike at the frequency of this sinusoid and a second spike at 0 Hz (DC). If the signal spanned from values -2 to 2 (centered around zero), there would be no DC offset. Since it is centered around 3.5 (the number midway between -2 and 9), there is a DC component.
|
||||
|
||||
Samples produced by HackRF are measurements of radio waveforms, but the measurement method is prone to a DC bias introduced by HackRF. It's an artifact of the measurement system, not an indication of a received radio signal. DC offset is not unique to HackRF; it is common to all quadrature sampling systems.
|
||||
|
||||
There was a bug in the HackRF firmware (through release 2013.06.1) that made the DC offset worse than it should have been. In the worst cases, certain Jawbreakers experienced a DC offset that drifted to a great extreme over several seconds of operation. This bug has been fixed. The fix reduces DC offset but does not do away with it entirely. It is something you have to live with when using any quadrature sampling system like HackRF.
|
||||
|
||||
A high DC offset is also one of a few symptoms that can be caused by a software version mismatch. A common problem is that people run an old version of gr-osmosdr with newer firmware.
|
||||
|
||||
|
||||
----
|
||||
|
||||
|
||||
What gain controls are provided by HackRF?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
HackRF (both Jawbreaker and One) provides three different analog gain controls on RX and two on TX. The three RX gain controls are at the RF ("amp", 0 or 14 dB), IF ("lna", 0 to 40 dB in 8 dB steps), and baseband ("vga", 0 to 62 dB in 2 dB steps) stages. The two TX gain controls are at the RF (0 or 14 dB) and IF (0 to 47 dB in 1 dB steps) stages.
|
||||
|
||||
|
||||
----
|
||||
|
||||
|
||||
Why is the RF gain setting restricted to two values?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
HackRF has two RF amplifiers close to the antenna port, one for TX and one for RX. These amplifiers have two settings: on or off. In the off state, the amps are completely bypassed. They nominally provide 14 dB of gain when on, but the actual amount of gain varies by frequency. In general, expect less gain at higher frequencies. For fine control of gain, use the IF and/or baseband gain options.
|
||||
|
||||
|
||||
----
|
||||
|
||||
|
||||
Why are the LEDs on HackRF different colours?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Each LED is a single color. There are no multi-colored LEDs on HackRF One. Adjacent LEDs are different colors in order to make them easier to distinguish from one another. The colors do not mean anything.
|
||||
|
||||
|
||||
----
|
||||
|
||||
|
||||
Where can I purchase HackRF?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
HackRF is designed and manufactured by Great Scott Gadgets. We do not sell low volumes of HackRFs to people individually; instead we have agreements with specific resellers. Please see our reseller list on the Great Scott Gadgets website for availability: `http://greatscottgadgets.com/hackrf/ <http://greatscottgadgets.com/hackrf/>`__.
|
||||
|
||||
HackRF is open source hardware, so you can also build your own.
|
@@ -0,0 +1,7 @@
|
||||
================================================
|
||||
Firmware Development Setup
|
||||
================================================
|
||||
|
||||
Firmware build instructions are included in the repository under firmware/README:
|
||||
|
||||
`https://github.com/mossmann/hackrf/blob/master/firmware/README <https://github.com/mossmann/hackrf/blob/master/firmware/README>`__
|
@@ -0,0 +1,98 @@
|
||||
================================================
|
||||
Future Hardware Modifications
|
||||
================================================
|
||||
|
||||
Things to consider for post-Jawbreaker hardware designs:
|
||||
|
||||
----
|
||||
|
||||
Antenna
|
||||
^^^^^^^
|
||||
|
||||
The PCB antenna on Jawbreaker was included to facilitate beta testing. Future designs likely will not include a PCB antenna.
|
||||
|
||||
SMA connectors will be PCB edge-mounted.
|
||||
|
||||
----
|
||||
|
||||
Baseband
|
||||
^^^^^^^^
|
||||
|
||||
The interfaces between the MAX2837 and MAX5864 have some signals inverted. Theoretically, that's fine if compensated for in software. However, I'm theorizing that RX/ADC DC offset compensation assumes that both channels have the same DC polarity. I've fixed the inversion in the CPLD. However, a PCB experiment should be conducted to see if the DC offset is reduced by un-inverting the RX Q channel connections to the MAX5864.
|
||||
|
||||
----
|
||||
|
||||
CPLD
|
||||
^^^^
|
||||
|
||||
The CPLD could be removed, but some sort of multiplexer would be needed to meet the MAX5864 i/o requirements. Depending on the particular LPC43xx part used, it might be possible to use the System Control Unit (SCU) for this.
|
||||
|
||||
----
|
||||
|
||||
Clocking
|
||||
^^^^^^^^
|
||||
|
||||
The clock signal from the Si5351C to the LPC43xx's GP_CLKIN pin may need different passives, but the documentation on that clock input is thin (acceptable peak-to-peak voltage anyone?).
|
||||
|
||||
An unpopulated footprint for a 32.768 kHz RTC crystal would be nice. Also break out RTC battery pins to an expansion header.
|
||||
|
||||
----
|
||||
|
||||
USB
|
||||
^^^
|
||||
|
||||
Would support for host mode on the second USB PHY be useful somehow? This is only possible with a larger LPC43xx package that exposes the second PHY's ULPI signals. Unless, of course, a mere full-speed PHY is acceptable.
|
||||
|
||||
----
|
||||
|
||||
Power Management
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
The MAX5864 appears to come up in "Tx" or "Rcvr" mode -- I have observed that the part will pass DA bus data to ID/QD without any SPI configuration. If we're worried about USB power and minimizing current consumption, it might be good to have this device on a power regulator with an ENABLE pin, or have a FET power switch. Yes, let's add a high side switch for the whole RF section.
|
||||
|
||||
----
|
||||
|
||||
Regulators
|
||||
^^^^^^^^^^
|
||||
|
||||
U21 (the TPS62410) FB1 pin is connected on the far side of jumper P8 (VCC), which puts the jumper inside the feedback path. If the jumper trace is cut, the regulator may go nuts because the FB pin is floating.
|
||||
|
||||
----
|
||||
|
||||
Buttons
|
||||
^^^^^^^
|
||||
|
||||
Add a reset button (for the LPC43xx). Maybe add a DFU button too.
|
||||
|
||||
----
|
||||
|
||||
Shielding
|
||||
^^^^^^^^^
|
||||
|
||||
Maybe add a can around the RF section.
|
||||
|
||||
----
|
||||
|
||||
Footprints
|
||||
^^^^^^^^^^
|
||||
|
||||
Tighten up holes for USB connector support legs to improve placement consistency. Make some of the QFN pads bigger (especially on the RF switches) for better soldering.
|
||||
|
||||
----
|
||||
|
||||
Shield Support
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
If support for add-on shields is considered valuable, here are some tweaks I'd suggest:
|
||||
|
||||
Any reason P28 (SD) pin 12 isn't grounded or doing something useful? Same goes for P25 (LPC_ISP) pin 3 -- maybe make it VCC, the signaling voltage for the ISP interface? The SPIFI connector could also use a reference voltage (GND?).
|
||||
|
||||
I'd like to see an I2C bus exposed somewhere, and perhaps an I2S0_RX_SDA signal, so I don't have to steal it from the CPLD interface. The I2S0 will function in "four-wire mode" with only one more pin (RX_SDA), so why not?
|
||||
|
||||
Provide a way to inject a supply voltage into the board? Having diodes managing multiple voltage sources would be lossy, so a more expensive solution would be necessary on the Jawbreaker board, adding cost.
|
||||
|
||||
If an LPC43xx package with a higher pin-count is used, it would be stellar to expose the LCD interface and quadrature encoder peripheral pins.
|
||||
|
||||
The RTC would be handy for stand-alone use. This would require a crystal (32.768kHz) between RTCX1 and RTCX2, and exposing VBAT to a shield for battery backup (disconnecting it from VCC) or providing a coin cell footprint on the HackRF PCB.
|
||||
|
||||
Coalesce separate headers into fewer, larger banks of headers, to reduce the number of unique, small header receptacles required for mating? Reducing the header count will also increase the amount of board space around the perimeter of a shield for components and connectors.
|
@@ -0,0 +1,9 @@
|
||||
================================================
|
||||
Getting Help
|
||||
================================================
|
||||
|
||||
Before asking for help with HackRF, check to see if your question is listed in the :ref:`FAQ <faq>` or has already been answered in `GitHub issues <https://github.com/mossmann/hackrf/issues>`__ or the `mailing list archives <https://pairlist9.pair.net/pipermail/hackrf-dev/>`__.
|
||||
|
||||
For assistance with HackRF use or development, please look at the `issues on the GitHub project <https://github.com/mossmann/hackrf/issues>`__. This is the preferred place to ask questions so that others may locate the answer to your question in the future.
|
||||
|
||||
Many users spend time in the `#hackrf channel on Discord <https://discord.gg/rsfMw3rsU8>`__.
|
@@ -0,0 +1,69 @@
|
||||
================================================
|
||||
Getting Started with HackRF and GNU Radio
|
||||
================================================
|
||||
|
||||
We recommend getting started by watching the `Software Defined Radio with HackRF <https://greatscottgadgets.com/sdr/>`__ video series. This series will introduce you to HackRF One, software including GNU Radio, and teach you the fundamentals of Digital Signal Processing (DSP) needed to take full advantage of the power of Software Defined Radio (SDR). Additional helpful information follows.
|
||||
|
||||
.. _try_pentoo:
|
||||
|
||||
Try Your HackRF with Pentoo Linux
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The easiest way to get started with your HackRF and ensure that it works is to use Pentoo, a Linux distribution with full support for HackRF and GNU Radio. Download the latest Pentoo .iso image from one of the mirrors listed at `http://pentoo.ch/downloads/ <https://pentoo.ch/downloads>`__. Then burn the .iso to a DVD or use `UNetbootin <http://unetbootin.sourceforge.net/>`__ to install the .iso on a USB flash drive. Boot your computer using the DVD or USB flash drive to run Pentoo. Do this natively, not in a virtual machine. (Unfortunately high speed USB operation invariably fails when people try to run HackRF from a virtual machine.)
|
||||
|
||||
Once Pentoo is running, you can immediately use it to :ref:`update firmware <updating_firmware>` on your HackRF or use other HackRF command line tools. For a walkthrough, watch `SDR with HackRF, Lesson 5: HackRF One <http://greatscottgadgets.com/sdr/5/>`__.
|
||||
|
||||
To verify that your HackRF is detected, type ``hackrf_info`` at the command line. It should produce a few lines of output including "Found HackRF board." The 3V3, 1V8, RF, and USB LEDs should all be illuminated and are various colors.
|
||||
|
||||
You can type ``startx`` at the command line to launch a desktop environment. Accept the "default config" in the first dialog box. The desktop environment is useful for GNU Radio Companion and other graphical applications but is not required for basic operations such as firmware updates.
|
||||
|
||||
Now you can use programs such as gnuradio-companion or gqrx to start experimenting with your HackRF. Try the Examples below. If you are new to GNU Radio, an excellent place to start is with the `SDR with HackRF <http://greatscottgadgets.com/sdr/>`__ video series or with the `GNU Radio guided tutorials <https://wiki.gnuradio.org/index.php/Tutorials>`__.
|
||||
|
||||
**Alternative: GNU Radio Live SDR Environment**
|
||||
|
||||
The `GNU Radio Live SDR Environment <https://wiki.gnuradio.org/index.php/GNU_Radio_Live_SDR_Environment>`__ is another nice bootable Linux .iso with support for HackRF and, of course, GNU Radio.
|
||||
|
||||
Software Setup
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
As mentioned above, the best way to get started with HackRF is to use Pentoo Linux. Eventually you may want to install software to use HackRF with your favorite operating system.
|
||||
|
||||
If your package manager includes the most recent release of libhackrf and gr-osmosdr, then use it to install those packages in addition to GNU Radio. Otherwise, the recommended way to install these tools is by using `PyBOMBS <https://github.com/gnuradio/pybombs>`__.
|
||||
|
||||
See the :ref:`Operating System Tips <operating_system_tips>` page for information on setting up HackRF software on particular Operating Systems and Linux distributions.
|
||||
|
||||
If you have any trouble, make sure that things work when booted to Pentoo. This will allow you to easily determine if your problem is being caused by hardware or software, and it will give you a way to see how the software is supposed to function.
|
||||
|
||||
Examples
|
||||
~~~~~~~~
|
||||
|
||||
A great way to get started with HackRF is the `SDR with HackRF <http://greatscottgadgets.com/sdr/>`__ video series. Additional examples follow:
|
||||
|
||||
Testing the HackRF
|
||||
|
||||
#. Plug in the HackRF
|
||||
#. run the hackrf_info command ``$ hackrf_info``
|
||||
|
||||
If everything is OK, you should see something similar to the following:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
hackrf_info version: 2017.02.1
|
||||
libhackrf version: 2017.02.1 (0.5)
|
||||
Found HackRF
|
||||
Index: 0
|
||||
Serial number: 0000000000000000################
|
||||
Board ID Number: 2 (HackRF One)
|
||||
Firmware Version: 2017.02.1 (API:1.02)
|
||||
Part ID Number: 0x######## 0x########
|
||||
|
||||
**FM Radio Example**
|
||||
|
||||
This Example was derived from the following works:
|
||||
|
||||
* `RTL-SDR FM radio receiver with GNU Radio Companion <http://www.instructables.com/id/RTL-SDR-FM-radio-receiver-with-GNU-Radio-Companion/>`__
|
||||
* `How To Build an FM Receiver with the USRP in Less Than 10 Minutes <https://www.youtube.com/watch?v=KWeY2yqwVA0>`__
|
||||
|
||||
#. Download the FM Radio Receiver python file `here <https://raw.githubusercontent.com/rrobotics/hackrf-tests/master/fm_radio/fm_radio_rx.py>`__
|
||||
#. Run the file ``$ python ./fm_radio_rx.py``
|
||||
#. You can find the GNU Radio Companion source file `here <https://raw.githubusercontent.com/rrobotics/hackrf-tests/master/fm_radio/fm_radio_rx.grc>`__
|
25
Software/portapack-mayhem/hackrf/docs/source/hackrf_one.rst
Normal file
@@ -0,0 +1,25 @@
|
||||
================================================
|
||||
HackRF One
|
||||
================================================
|
||||
|
||||
HackRF One is the current hardware platform for the HackRF project. It is a Software Defined Radio peripheral capable of transmission or reception of radio signals from 1 MHz to 6 GHz. Designed to enable test and development of modern and next generation radio technologies, HackRF One is an open source hardware platform that can be used as a USB peripheral or programmed for stand-alone operation.
|
||||
|
||||
|
||||
|
||||
Features
|
||||
~~~~~~~~
|
||||
|
||||
* half-duplex transceiver
|
||||
* operating freq: 1 MHz to 6 GHz
|
||||
* supported sample rates: 2 Msps to 20 Msps (quadrature)
|
||||
* resolution: 8 bits
|
||||
* interface: High Speed USB (with USB Micro-B connector)
|
||||
* power supply: USB bus power
|
||||
* software-controlled antenna port power (max 50 mA at 3.3 V)
|
||||
* SMA female antenna connector (50 ohms)
|
||||
* SMA female clock input and output for synchronization
|
||||
* convenient buttons for programming
|
||||
* pin headers for expansion
|
||||
* portable
|
||||
* open source
|
||||
|
@@ -0,0 +1,20 @@
|
||||
================================================
|
||||
HackRF Community Projects and Mentions
|
||||
================================================
|
||||
|
||||
Have you done something cool with HackRF or mentioned HackRF in one of your presentations? Let us know and we might post a link here!
|
||||
|
||||
* `HackRF vs. Tesla Model S <https://www.youtube.com/watch?v=575TcQJJWok>`__ (Sam Edwards)
|
||||
* `Jawbreaker/VFD spectrum analyzer <http://www.sharebrained.com/2013/05/21/maker-faire-radio-spectrum-analyzer/>`__ (Jared Boone)
|
||||
* `LEGO car <http://ossmann.blogspot.com/2013/06/hackrf-lego-car.html>`__ (Michael Ossmann)
|
||||
* `wireless microphones <http://www.sharebrained.com/2013/06/15/wireless-microphones-and-hackrf/>`__ (Jared Boone)
|
||||
* `Tesla Charging Port Opener <https://github.com/rgerganov/tesla-opener>`__ (Radoslav Gerganov)
|
||||
|
||||
|
||||
|
||||
Retired Projects
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
* Automotive Remote Keyless Entry Systems (Mike Kershaw)
|
||||
* Decoding Pocsag Pagers With The HackRF (BinaryRF)
|
||||
* Sniffing GSM with HackRF (BinaryRF)
|
119
Software/portapack-mayhem/hackrf/docs/source/hackrf_sweep.rst
Normal file
@@ -0,0 +1,119 @@
|
||||
================================================
|
||||
hackrf_sweep
|
||||
================================================
|
||||
|
||||
Usage
|
||||
~~~~~
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
[-h] # this help
|
||||
[-d serial_number] # Serial number of desired HackRF
|
||||
[-a amp_enable] # RX RF amplifier 1=Enable, 0=Disable
|
||||
[-f freq_min:freq_max] # minimum and maximum frequencies in MHz
|
||||
[-p antenna_enable] # Antenna port power, 1=Enable, 0=Disable
|
||||
[-l gain_db] # RX LNA (IF) gain, 0-40dB, 8dB steps
|
||||
[-g gain_db] # RX VGA (baseband) gain, 0-62dB, 2dB steps
|
||||
[-n num_samples] # Number of samples per frequency, 8192-4294967296
|
||||
[-w bin_width] # FFT bin width (frequency resolution) in Hz
|
||||
[-1] # one shot mode
|
||||
[-B] # binary output
|
||||
[-I] # binary inverse FFT output
|
||||
-r filename # output file
|
||||
|
||||
|
||||
|
||||
Output fields
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
``date, time, hz_low, hz_high, hz_bin_width, num_samples, dB, dB, ...``
|
||||
|
||||
Running ``hackrf_sweep -f 2400:2490`` gives the following example results:
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1 1 1 1 1 1 1 1 1 1
|
||||
|
||||
* - Date
|
||||
- Time
|
||||
- Hz Low
|
||||
- Hz High
|
||||
- Hz bin width
|
||||
- Num Samples
|
||||
- dB
|
||||
- dB
|
||||
- dB
|
||||
- dB
|
||||
- dB
|
||||
* - 2019-01-03
|
||||
- 11:57:34.967805
|
||||
- 2400000000
|
||||
- 2405000000
|
||||
- 1000000.00
|
||||
- 20
|
||||
- -64.72
|
||||
- -63.36
|
||||
- -60.91
|
||||
- -61.74
|
||||
- -58.58
|
||||
* - 2019-01-03
|
||||
- 11:57:34.967805
|
||||
- 2410000000
|
||||
- 2415000000
|
||||
- 1000000.00
|
||||
- 20
|
||||
- -69.22
|
||||
- -60.67
|
||||
- -59.50
|
||||
- -61.81
|
||||
- -58.16
|
||||
* - 2019-01-03
|
||||
- 11:57:34.967805
|
||||
- 2405000000
|
||||
- 2410000000
|
||||
- 1000000.00
|
||||
- 20
|
||||
- -61.19
|
||||
- -70.14
|
||||
- -60.10
|
||||
- -57.91
|
||||
- -61.97
|
||||
* - 2019-01-03
|
||||
- 11:57:34.967805
|
||||
- 2415000000
|
||||
- 2420000000
|
||||
- 1000000.00
|
||||
- 20
|
||||
- -72.93
|
||||
- -79.14
|
||||
- -68.79
|
||||
- -70.71
|
||||
- -82.78
|
||||
* - 2019-01-03
|
||||
- 11:57:34.967805
|
||||
- 2420000000
|
||||
- 2425000000
|
||||
- 1000000.00
|
||||
- 20
|
||||
- -67.57
|
||||
- -61.61
|
||||
- -57.29
|
||||
- -61.90
|
||||
- -70.19
|
||||
* - 2019-01-03
|
||||
- 11:57:34.967805
|
||||
- 2430000000
|
||||
- 2435000000
|
||||
- 1000000.00
|
||||
- 20
|
||||
- -56.04
|
||||
- -59.58
|
||||
- -66.24
|
||||
- -66.02
|
||||
- -62.12
|
||||
|
||||
Two ranges of 5 MHz are analyzed at once from the same set of samples, so a single timestamp applies to the whole range.
|
||||
|
||||
The fifth column tells you the width in Hz (1 MHz in this case) of each frequency bin, which you can set with ``-w``. The sixth column is the number of samples analyzed to produce that row of data.
|
||||
|
||||
Each of the remaining columns shows the power detected in each of several frequency bins. In this case there are five bins, the first from 2400 to 2401 MHz, the second from 2401 to 2402 MHz, and so forth.
|
@@ -0,0 +1,11 @@
|
||||
====================
|
||||
HackRF One's Buttons
|
||||
====================
|
||||
|
||||
The RESET button resets the microcontroller. This is a reboot that should result in a USB re-enumeration.
|
||||
|
||||
The DFU button invokes a USB DFU bootloader located in the microcontroller's ROM. This bootloader makes it possible to unbrick a HackRF One with damaged firmware because the ROM cannot be overwritten.
|
||||
|
||||
To invoke DFU mode: Press and hold the DFU button. While holding the DFU button, reset the HackRF One either by pressing and releasing the RESET button or by powering on the HackRF One. Release the DFU button.
|
||||
|
||||
The DFU button only invokes the bootloader during reset. This means that it can be used for other functions by custom firmware.
|
@@ -0,0 +1,35 @@
|
||||
================================================
|
||||
Hardware Components
|
||||
================================================
|
||||
|
||||
Major parts used in HackRF One:
|
||||
|
||||
* `MAX2837 2.3 to 2.7 GHz transceiver <https://www.maximintegrated.com/en/products/comms/wireless-rf/MAX2837.html>`__
|
||||
* `Datasheet <https://datasheets.maximintegrated.com/en/ds/MAX2837.pdf>`__
|
||||
* There's also a register map document that Mike received directly from Maxim. Send an email to Mike or submit a support request to Maxim if you want a copy.
|
||||
* `MAX5864 ADC/DAC <http://www.maxim-ic.com/datasheet/index.mvp/id/3946/t/do>`__
|
||||
* `Datasheet <http://datasheets.maxim-ic.com/en/ds/MAX5864.pdf>`__
|
||||
* `Si5351 clock generator <http://www.silabs.com/products/clocksoscillators/clock-generator/Pages/lvcmos-clocks-5-outputs.aspx>`__
|
||||
* `AN619: Manually Generating an Si5351 Register Map <http://www.silabs.com/Support%20Documents/TechnicalDocs/AN619.pdf>`__
|
||||
* `Datasheet <http://www.silabs.com/Support%20Documents/TechnicalDocs/Si5351.pdf>`__ - this document is a mess of typos, and best used in conjunction with AN619, which has its own typos. Usually, you can reconcile what's true by comparison and a bit of thought.
|
||||
* `Other Documentation <http://www.silabs.com/products/clocksoscillators/clock-generators-and-buffers/Pages/clock+vcxo.aspx>`__ - includes application notes, user guides, and white papers.
|
||||
* CoolRunner-II CPLD
|
||||
* `LPC43xx ARM Cortex-M4 microcontroller <http://www.nxp.com/products/microcontrollers-and-processors/arm-processors/lpc-arm-cortex-m-mcus/lpc-dual-core-cortex-m0-m4f/lpc4300:MC_1403790133078>`__
|
||||
* `User Manual <http://www.nxp.com/documents/user_manual/UM10503.pdf>`__
|
||||
* `Datasheet <http://www.nxp.com/documents/data_sheet/LPC4350_30_20_10.pdf>`__
|
||||
* `Other Documentation (LPC4330FBD144) <http://www.nxp.com/products/microcontrollers/cortex_m4/lpc4300/LPC4330FBD144.html#documentation>`__ - includes errata and application notes.
|
||||
* `ARM-standard JTAG/SWD connector pinout <http://www.keil.com/support/man/docs/ulink2/ulink2_hw_connectors.htm>`__
|
||||
* `BSDL file for the LPC43xx (For boundary scan) <http://www.lpcware.com/system/files/LPC18xx_43xx%20BSDL%20files%2020121127_0.zip>`__
|
||||
* `RFFC5072 mixer/synthesizer <http://www.rfmd.com/store/rffc5072-1.html>`__
|
||||
* `Datasheet <http://www.rfmd.com/CS/Documents/RFFC5071_2DS.pdf>`__
|
||||
* `Other Documentation <http://www.rfmd.com/store/rffc5072-1.html>`__ ; click "Technical Documents" - includes programming guides and application notes.
|
||||
* `W25Q80BV 8M-bit Flash <https://www.winbond.com/resource-files/w25q80bv%20revk%2020151203.pdf>`__
|
||||
|
||||
|
||||
|
||||
|
||||
Block Diagram
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
.. image:: ../images/block-diagram.png
|
||||
:align: center
|
59
Software/portapack-mayhem/hackrf/docs/source/index.rst
Normal file
@@ -0,0 +1,59 @@
|
||||
==================================
|
||||
Welcome to HackRF's documentation!
|
||||
==================================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: User Documentation
|
||||
|
||||
hackrf_one
|
||||
opera_cake
|
||||
faq
|
||||
troubleshooting
|
||||
getting_help
|
||||
tips_tricks
|
||||
hackrf_projects_mentions
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Software
|
||||
|
||||
installing_hackrf_software
|
||||
getting_started_hackrf_gnuradio
|
||||
software_support
|
||||
libhackrf_api
|
||||
hackrf_sweep
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Firmware
|
||||
|
||||
updating_firmware
|
||||
firmware_development_setup
|
||||
LPC43XX_Debugging
|
||||
LPC43XX_SGPIO_Configuration
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Hardware
|
||||
|
||||
list_of_hardware_revisions
|
||||
hardware_components
|
||||
enclosure_options
|
||||
hackrfs_buttons
|
||||
external_clock_interface
|
||||
clocking
|
||||
expansion_interface
|
||||
multiple_device_hardware_synch
|
||||
rf_shield_installation
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Retired Content
|
||||
|
||||
jawbreaker
|
||||
design_goals
|
||||
future_hardware_modifications
|
||||
lemondrop_bringup
|
||||
LPC4350
|
||||
|
@@ -0,0 +1,143 @@
|
||||
.. _operating_system_tips:
|
||||
|
||||
================================================
|
||||
Installing HackRF Software
|
||||
================================================
|
||||
|
||||
Install Using Package Managers
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Unless developing or testing new features for HackRF, we highly recommend that most users use build systems or package managers provided for their operating system. **Our suggested operating system for use with HackRF is Ubuntu**.
|
||||
|
||||
FreeBSD
|
||||
+++++++
|
||||
|
||||
You can use the binary package: ``# pkg install hackrf``
|
||||
|
||||
You can also build and install from ports:
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
# cd /usr/ports/comms/hackrf
|
||||
# make install
|
||||
|
||||
Linux: Arch
|
||||
+++++++++++
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
pacman -S hackrf
|
||||
|
||||
Linux: Fedora / Red Hat
|
||||
+++++++++++++++++++++++
|
||||
|
||||
``sudo dnf install hackrf -y``
|
||||
|
||||
Linux: Gentoo
|
||||
+++++++++++++
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
emerge -a net-wireless/hackrf-tools
|
||||
|
||||
Linux: Ubuntu / Debian
|
||||
++++++++++++++++++++++
|
||||
|
||||
``sudo apt-get install hackrf``
|
||||
|
||||
OS X (10.5+): Homebrew
|
||||
++++++++++++++++++++++
|
||||
|
||||
``brew install hackrf``
|
||||
|
||||
OS X (10.5+): MacPorts
|
||||
++++++++++++++++++++++
|
||||
|
||||
``sudo port install hackrf``
|
||||
|
||||
Windows: Binaries
|
||||
+++++++++++++++++
|
||||
|
||||
Binaries are provided as part of the PothosSDR project, they can be downloaded `here <http://downloads.myriadrf.org/builds/PothosSDR/?C=M;O=D>`__.
|
||||
|
||||
-----------
|
||||
|
||||
Installing From Source
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Linux / OS X / \*BSD: Building HackRF Software From Source
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
Acquire the source for the HackRF tools from either a `release archive <https://github.com/mossmann/hackrf/releases>`__ or git: ``git clone https://github.com/mossmann/hackrf.git``
|
||||
|
||||
Once you have the source downloaded, the host tools can be built as follows:
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
cd hackrf/host
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make
|
||||
sudo make install
|
||||
sudo ldconfig
|
||||
|
||||
If you have HackRF hardware, you may need to :ref:`update the firmware <updating_firmware>` to match the host tools versions.
|
||||
|
||||
|
||||
|
||||
Windows: Prerequisites for Cygwin, MinGW, or Visual Studio
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
* cmake-2.8.12.1 or later from http://www.cmake.org/cmake/resources/software.html
|
||||
* libusbx-1.0.18 or later from http://sourceforge.net/projects/libusbx/files/latest/download?source=files
|
||||
* fftw-3.3.5 or later from http://www.fftw.org/install/windows.html
|
||||
* Install Windows driver for HackRF hardware or use Zadig see http://sourceforge.net/projects/libwdi/files/zadig
|
||||
* If you want to use Zadig select HackRF USB device and just install/replace it with WinUSB driver.
|
||||
|
||||
Note for Windows build: You shall always execute hackrf-tools from Windows command shell and not from Cygwin or MinGW shell because on Cygwin/MinGW Ctrl+C is not managed correctly and especially for hackrf_transfer the Ctrl+C (abort) will not stop correctly and will corrupt the file.
|
||||
|
||||
|
||||
|
||||
Windows: Installing HackRF Software via Cygwin
|
||||
++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
mkdir host/build
|
||||
cd host/build
|
||||
cmake ../ -G "Unix Makefiles" -DCMAKE_LEGACY_CYGWIN_WIN32=1 -DLIBUSB_INCLUDE_DIR=/usr/local/include/libusb-1.0/
|
||||
make
|
||||
make install
|
||||
|
||||
|
||||
|
||||
Windows: Installing HackRF Software via MinGW
|
||||
+++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
mkdir host/build
|
||||
cd host/build
|
||||
cmake ../ -G "MSYS Makefiles" -DLIBUSB_INCLUDE_DIR=/usr/local/include/libusb-1.0/
|
||||
make
|
||||
make install
|
||||
|
||||
|
||||
|
||||
Windows: Installing HackRF Software via Visual Studio 2015 x64
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
Create library definition for MSVC to link to ``C:\fftw-3.3.5-dll64> lib /machine:x64 /def:libfftw3f-3.def``
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
c:\hackrf\host\build> cmake ../ -G "Visual Studio 14 2015 Win64" \
|
||||
-DLIBUSB_INCLUDE_DIR=c:\libusb-1.0.21\libusb \
|
||||
-DLIBUSB_LIBRARIES=c:\libusb-1.0.21\MS64\dll\lib\libusb-1.0.lib \
|
||||
-DTHREADS_PTHREADS_INCLUDE_DIR=c:\pthreads-w32-2-9-1-release\Pre-built.2\include \
|
||||
-DTHREADS_PTHREADS_WIN32_LIBRARY=c:\pthreads-w32-2-9-1-release\Pre-built.2\lib\x64\pthreadVC2.lib \
|
||||
-DFFTW_INCLUDES=C:\fftw-3.3.5-dll64 \
|
||||
-DFFTW_LIBRARIES=C:\fftw-3.3.5-dll64\libfftw3f-3.lib
|
||||
|
||||
CMake will produce a solution file named ``HackRF.sln`` and a series of project files which can be built with msbuild as follows: ``c:\hackrf\host\build> msbuild HackRF.sln``
|
560
Software/portapack-mayhem/hackrf/docs/source/jawbreaker.rst
Normal file
@@ -0,0 +1,560 @@
|
||||
================================================
|
||||
Jawbreaker
|
||||
================================================
|
||||
|
||||
HackRF Jawbreaker is the beta test hardware platform for the HackRF project.
|
||||
|
||||
|
||||
|
||||
Features
|
||||
~~~~~~~~
|
||||
|
||||
* half-duplex transceiver
|
||||
* operating freq: 30 MHz to 6 GHz
|
||||
* supported sample rates: 8 Msps to 20 Msps (quadrature)
|
||||
* resolution: 8 bits
|
||||
* interface: High Speed USB (with USB Micro-B connector)
|
||||
* power supply: USB bus power
|
||||
* portable
|
||||
* open source
|
||||
|
||||
|
||||
|
||||
Set your Jawbreaker Free!
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Jawbreaker has an SMA antenna connector but also includes a built-in PCB antenna intended for operation near 900 MHz. It isn't a very good antenna. Seriously. A paperclip stuck into the SMA connector would probably be better. You can free your Jawbreaker to operate with better antennas by cutting the PCB trace to the PCB antenna with a knife. This enables the SMA connector to be used without interference from the PCB antenna.
|
||||
|
||||
A video that demonstrates the antenna modification is on YouTube: `HackRF Antenna Modification <http://youtu.be/B2gwgNoqMxI>`__
|
||||
|
||||
The trace to be cut is between the two solder pads inside a box labeled R44 in the `assembly diagram <https://github.com/mossmann/hackrf/blob/master/doc/hardware/jawbreaker-assembly.pdf?raw=true>`__. There is an arrow pointing to it printed on the board.
|
||||
|
||||
Due to a manufacturing error, there is solder on R44. R44 may appear as a single solder blob. If you have a soldering iron and solder wick/braid, use a soldering iron and fine solder wick to remove as much solder as you can from the two R44 pads. Then, use a pen knife to gently cut away the area between the two R44 pads. Make multiple, gentle cuts, instead of one or two forceful cuts. As you cut, you'll break through the black solder mask, then the copper trace between the pads, and stop when you reach fiberglass. Remove the copper trace completely, so just the two R44 pads remain. Use a multimeter or continuity tester to verify that the two R44 pads are no longer connected.
|
||||
|
||||
If you don't have a soldering iron, you can cut through the copper trace and the solder blob all at once, but it requires a bit more effort.
|
||||
|
||||
The only reason not to do this is if you want to try Jawbreaker but don't have any antenna with an SMA connector (or adapter).
|
||||
|
||||
If you want to restore the PCB antenna for some reason, you can install a 10 nF capacitor or a 0 ohm resistor on the R44 pads or you may be able to simply create a solder bridge.
|
||||
|
||||
|
||||
|
||||
SMA, not RP-SMA
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Some connectors that appear to be SMA are actually RP-SMA. If you connect an RP-SMA antenna to Jawbreaker, it will seem to connect snugly but won't function at all because neither the male nor female side has a center pin. RP-SMA connectors are most common on 2.4 GHz antennas and are popular on Wi-Fi equipment.
|
||||
|
||||
|
||||
|
||||
Transmit Power
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
The maximum TX power varies by operating frequency:
|
||||
|
||||
* 30 MHz to 100 MHz: 5 dBm to 15 dBm, increasing as frequency decreases
|
||||
* 100 MHz to 2300 MHz: 0 dBm to 10 dBm, increasing as frequency decreases
|
||||
* 2300 MHz to 2700 MHz: 10 dBm to 15 dBm
|
||||
* 2700 MHz to 4000 MHz: -5 dBm to 5 dBm, increasing as frequency decreases
|
||||
* 4000 MHz to 6000 MHz: -15 dBm to 0 dBm, increasing as frequency decreases
|
||||
|
||||
Overall, the output power is enough to perform over-the-air experiments at close range or to drive an external amplifier. If you connect an external amplifier, you should also use an external bandpass filter for your operating frequency.
|
||||
|
||||
Before you transmit, know your laws. Jawbreaker has not been tested for compliance with regulations governing transmission of radio signals. You are responsible for using your Jawbreaker legally.
|
||||
|
||||
|
||||
|
||||
Hardware Documentation
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Schematic diagram, assembly diagram,and bill of materials can be found at `https://github.com/mossmann/hackrf/tree/master/doc/hardware <https://github.com/mossmann/hackrf/tree/master/doc/hardware>`__
|
||||
|
||||
|
||||
|
||||
Expansion Interface
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
LPC
|
||||
^^^
|
||||
Boot config
|
||||
+++++++++++
|
||||
|
||||
Default boot configuration is SPIFI. Install headers and jumpers (and optionally resistors) to reconfigure.
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1 1 1 1
|
||||
|
||||
* - Pin
|
||||
- P43
|
||||
- P32
|
||||
- P42
|
||||
- P27
|
||||
* - 1
|
||||
- VCC
|
||||
- VCC
|
||||
- VCC
|
||||
- VCC
|
||||
* - 2
|
||||
- P2_9
|
||||
- P2_8
|
||||
- P1_2
|
||||
- P1_1
|
||||
* - 3
|
||||
- GND
|
||||
- GND
|
||||
- GND
|
||||
- GND
|
||||
|
||||
The table below shows which pins to short per header for a given selection.
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1 1 1 1
|
||||
|
||||
* - Selection
|
||||
- P43
|
||||
- P32
|
||||
- P42
|
||||
- P27
|
||||
* - USART0
|
||||
- 2-3
|
||||
- 2-3
|
||||
- 2-3
|
||||
- 2-3
|
||||
* - SPIFI
|
||||
- 2-3
|
||||
- 2-3
|
||||
- 2-3
|
||||
- 1-2
|
||||
* - USB0
|
||||
- 2-3
|
||||
- 1-2
|
||||
- 2-3
|
||||
- 1-2
|
||||
* - USSP0
|
||||
- 2-3
|
||||
- 1-2
|
||||
- 1-2
|
||||
- 1-2
|
||||
* - USART3
|
||||
- 1-2
|
||||
- 2-3
|
||||
- 2-3
|
||||
- 2-3
|
||||
|
||||
|
||||
|
||||
P19 SPIFI Intercept header
|
||||
++++++++++++++++++++++++++
|
||||
|
||||
Traces may be cut to install header and jumpers or use off-board SPI flash.
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1
|
||||
|
||||
* - Pin
|
||||
- Function
|
||||
* - 1
|
||||
- Flash DO
|
||||
* - 2
|
||||
- SPIFI_MISO
|
||||
* - 3
|
||||
- Flash DI
|
||||
* - 4
|
||||
- SPIFI_MOSI
|
||||
* - 5
|
||||
- Flash CLK
|
||||
* - 6
|
||||
- SPIFI_SCK
|
||||
* - 7
|
||||
- Flash CS
|
||||
* - 8
|
||||
- SPIFI_CS
|
||||
* - 9
|
||||
- Flash Hold
|
||||
* - 10
|
||||
- SPIFI_SIO3
|
||||
* - 11
|
||||
- Flash WP
|
||||
* - 12
|
||||
- SPIFI_SIO2
|
||||
|
||||
|
||||
|
||||
P20 GPIO
|
||||
++++++++
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1
|
||||
|
||||
* - Pin
|
||||
- Function
|
||||
* - 1
|
||||
- GPIO3_8
|
||||
* - 2
|
||||
- GPIO3_9
|
||||
* - 3
|
||||
- GPIO3_10
|
||||
* - 4
|
||||
- GPIO3_11
|
||||
* - 5
|
||||
- GPIO3_12
|
||||
* - 6
|
||||
- GPIO3_13
|
||||
* - 7
|
||||
- GPIO3_14
|
||||
* - 8
|
||||
- GPIO3_15
|
||||
* - 9
|
||||
- GND
|
||||
* - 10
|
||||
- GND
|
||||
|
||||
|
||||
|
||||
P21 Analog
|
||||
++++++++++
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1
|
||||
|
||||
* - Pin
|
||||
- Function
|
||||
* - 1
|
||||
- GND
|
||||
* - 2
|
||||
- ADC0_6
|
||||
* - 3
|
||||
- GND
|
||||
* - 4
|
||||
- ADC0_2
|
||||
* - 5
|
||||
- GND
|
||||
* - 6
|
||||
- ADC0_5
|
||||
* - 7
|
||||
- GND
|
||||
* - 8
|
||||
- ADC0_0
|
||||
|
||||
|
||||
|
||||
P22 I2S
|
||||
+++++++
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1
|
||||
|
||||
* - Pin
|
||||
- Function
|
||||
* - 1
|
||||
- VCC
|
||||
* - 2
|
||||
- I2S0_TX_SDA
|
||||
* - 3
|
||||
- I2S0_TX_WS
|
||||
* - 4
|
||||
- I2S0_TX_SCK
|
||||
* - 5
|
||||
- I2S0_TX_MCLK
|
||||
* - 6
|
||||
- GND
|
||||
|
||||
|
||||
|
||||
P25 LPC_ISP
|
||||
+++++++++++
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1
|
||||
|
||||
* - Pin
|
||||
- Function
|
||||
* - 1
|
||||
- GND
|
||||
* - 2
|
||||
- ISP
|
||||
* - 3
|
||||
- NC
|
||||
* - 4
|
||||
- U0_RXD
|
||||
* - 5
|
||||
- U0_TXD
|
||||
* - 6
|
||||
- RESET
|
||||
|
||||
|
||||
|
||||
P26 LPC_JTAG
|
||||
++++++++++++
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1
|
||||
|
||||
* - Pin
|
||||
- Function
|
||||
* - 1
|
||||
- VCC
|
||||
* - 2
|
||||
- TMS
|
||||
* - 3
|
||||
- GND
|
||||
* - 4
|
||||
- TCK
|
||||
* - 5
|
||||
- GND
|
||||
* - 6
|
||||
- TDO
|
||||
* - 7
|
||||
- NC
|
||||
* - 8
|
||||
- TDI
|
||||
* - 9
|
||||
- GND
|
||||
* - 10
|
||||
- RESET
|
||||
|
||||
|
||||
|
||||
P28 SD
|
||||
++++++
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1
|
||||
|
||||
|
||||
* - Pin
|
||||
- Function
|
||||
* - 1
|
||||
- GND
|
||||
* - 2
|
||||
- VCC
|
||||
* - 3
|
||||
- SD_CD
|
||||
* - 4
|
||||
- SD_DAT3
|
||||
* - 5
|
||||
- SD_DAT2
|
||||
* - 6
|
||||
- SD_DAT1
|
||||
* - 7
|
||||
- SD_DAT0
|
||||
* - 8
|
||||
- SD_VOLT0
|
||||
* - 9
|
||||
- SD_CMD
|
||||
* - 10
|
||||
- SD_POW
|
||||
* - 11
|
||||
- SD_CLK
|
||||
* - 12
|
||||
- NC
|
||||
|
||||
|
||||
|
||||
CPLD
|
||||
^^^^
|
||||
|
||||
P29 CPLD_JTAG
|
||||
+++++++++++++
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1
|
||||
|
||||
* - Pin
|
||||
- Function
|
||||
* - 1
|
||||
- CPLD_TMS
|
||||
* - 2
|
||||
- CPLD_TDI
|
||||
* - 3
|
||||
- CPLD_TDO
|
||||
* - 4
|
||||
- CPLD_TCK
|
||||
* - 5
|
||||
- GND
|
||||
* - 6
|
||||
- NCC
|
||||
|
||||
|
||||
|
||||
P30 BANK2_AUX
|
||||
+++++++++++++
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1
|
||||
|
||||
* - Pin
|
||||
- Function
|
||||
* - 1
|
||||
- B2AUX1
|
||||
* - 2
|
||||
- B2AUX2
|
||||
* - 3
|
||||
- B2AUX3
|
||||
* - 4
|
||||
- B2AUX4
|
||||
* - 5
|
||||
- B2AUX5
|
||||
* - 6
|
||||
- B2AUX6
|
||||
* - 7
|
||||
- B2AUX7
|
||||
* - 8
|
||||
- B2AUX8
|
||||
* - 9
|
||||
- B2AUX9
|
||||
* - 10
|
||||
- B2AUX10
|
||||
* - 11
|
||||
- B2AUX11
|
||||
* - 12
|
||||
- B2AUX12
|
||||
* - 13
|
||||
- B2AUX13
|
||||
* - 14
|
||||
- B2AUX14
|
||||
* - 15
|
||||
- B2AUX15
|
||||
* - 16
|
||||
- B2AUX16
|
||||
|
||||
|
||||
|
||||
P31 BANK1_AUX
|
||||
+++++++++++++
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1
|
||||
|
||||
* - Pin
|
||||
- Function
|
||||
* - 1
|
||||
- B1AUX9
|
||||
* - 2
|
||||
- B1AUX10
|
||||
* - 3
|
||||
- B1AUX11
|
||||
* - 4
|
||||
- B1AUX12
|
||||
* - 5
|
||||
- B1AUX13
|
||||
* - 6
|
||||
- B1AUX14
|
||||
* - 7
|
||||
- B1AUX15
|
||||
* - 8
|
||||
- B1AUX16
|
||||
* - 9
|
||||
- GND
|
||||
* - 10
|
||||
- GND
|
||||
|
||||
|
||||
|
||||
External clock
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
P2 CLKOUT
|
||||
+++++++++
|
||||
|
||||
Install C165 and R92 as necessary to match output. For CMOS output, install 0 ohm resistor in place of C165; do not install R92.
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1
|
||||
|
||||
* - Pin
|
||||
- Function
|
||||
* - 1
|
||||
- CLKOUT
|
||||
* - 2
|
||||
- GND
|
||||
* - 3
|
||||
- GND
|
||||
* - 4
|
||||
- GND
|
||||
* - 5
|
||||
- GND
|
||||
|
||||
|
||||
|
||||
P16 CLKIN
|
||||
+++++++++
|
||||
|
||||
Install C118, C164, R45, R84 and R85 as necessary to match input.
|
||||
|
||||
For CMOS input, install 0 ohm resistors in place of C118 and C164; do not install R45, R84, or R85.
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1
|
||||
|
||||
* - Pin
|
||||
- Function
|
||||
* - 1
|
||||
- CLKIN
|
||||
* - 2
|
||||
- GND
|
||||
* - 3
|
||||
- GND
|
||||
* - 4
|
||||
- GND
|
||||
* - 5
|
||||
- GND
|
||||
|
||||
|
||||
|
||||
P17 CLKIN_JMP
|
||||
+++++++++++++
|
||||
|
||||
Cut P17 short (trace) to enable external clock input. If short is cut, a jumper should be used on P17 at all times when an external clock is not connected to P16.
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1
|
||||
|
||||
* - Pin
|
||||
- Function
|
||||
* - 1
|
||||
- GND
|
||||
* - 2
|
||||
- CLKIN
|
||||
|
||||
|
||||
|
||||
More
|
||||
^^^^
|
||||
|
||||
Additional headers are available. See the `board files <https://github.com/mossmann/hackrf/tree/master/hardware/jawbreaker>`__ for additional details.
|
||||
|
||||
|
||||
|
||||
Differences between Jawbreaker and HackRF One
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Jawbreaker was the beta platform that preceded HackRF One. HackRF One incorporates the following changes and enhancements:
|
||||
|
||||
* Antenna port: No modification is necessary to use the SMA antenna port on HackRF One.
|
||||
* PCB antenna: Removed.
|
||||
* Size: HackRF One is smaller at 120 mm x 75 mm (PCB size).
|
||||
* Enclosure: The commercial version of HackRF One from Great Scott Gadgets ships with an injection molded plastic enclosure. HackRF One is also designed to fit other enclosure options.
|
||||
* Buttons: HackRF One has a RESET button and a DFU button for easy programming.
|
||||
* Clock input and output: Installed and functional without modification.
|
||||
* USB connector: HackRF One features a new USB connector and improved USB layout.
|
||||
* Expansion interface: More pins are available for expansion, and pin headers are installed on HackRF One.
|
||||
* Real-Time Clock: An RTC is installed on HackRF One.
|
||||
* LPC4320 microcontroller: Jawbreaker had an LPC4330.
|
||||
* RF shield footprint: An optional shield may be installed over HackRF One's RF section.
|
||||
* Antenna port power: HackRF One can supply up to 50 mA at 3.3 V DC on the antenna port for compatibility with powered antennas and other low power amplifiers.
|
||||
* Enhanced frequency range: The RF performance of HackRF One is better than Jawbreaker, particularly at the high and low ends of the operating frequency range. HackRF One can operate at 1 MHz or even lower.
|
@@ -0,0 +1,239 @@
|
||||
================================================
|
||||
Lemondrop Bring Up
|
||||
================================================
|
||||
|
||||
Board draws approximately 24mA from +3V3 when power is applied. This seems a bit high, but may be expected if not all parts are capable of low-power mode, or aren't configured for low power at power-on. I need to review the schematic and datasheets and see what can be done.
|
||||
|
||||
When I put my finger on the MAX2837, current consumption goes up. This suggests there may be floating nodes in that region of the circuit.
|
||||
|
||||
|
||||
Si5351 I2C
|
||||
~~~~~~~~~~
|
||||
|
||||
Attached crystal is 25MHz. For now, I'm assuming 10pF "internal load capacitance" is good enough to get the crystal oscillating. The crystal datasheet should be reviewed and measurements made...
|
||||
|
||||
Be sure to reference Silicon Labs application note 619 (AN619). The datasheet is a terrible mess (typos and lack of some details). AN619 appears to be less of a mess, on the whole. And as a bonus, AN619 has PDF bookmarks for each register.
|
||||
|
||||
|
||||
|
||||
Connections
|
||||
^^^^^^^^^^^
|
||||
|
||||
* Bus Pirate GND to P7 pin 1
|
||||
* Bus Pirate +3V3 to P7 pin 2 (through multimeter set to 200mA range)
|
||||
* Bus Pirate CLK to P7 pin 3
|
||||
* Bus Pirate MOSI to P7 pin 5
|
||||
|
||||
|
||||
|
||||
Bus Pirate I2C Initialization
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
# set mode
|
||||
m
|
||||
# I2C mode
|
||||
4
|
||||
# ~100kHz speed
|
||||
3
|
||||
# power supplies ON
|
||||
W
|
||||
# macro 1: 7-bit address search
|
||||
(1)
|
||||
Searching I2C address space. Found devices at:
|
||||
0xC0(0x60 W) 0xC1(0x60 R)
|
||||
|
||||
I2C A0 address configuration pin (not available on QFN20 package) is apparently forced to "0".
|
||||
|
||||
|
||||
|
||||
Reading registers
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
# Read register 0
|
||||
I2C>[0xc0 0[0xc1 r]]
|
||||
...
|
||||
# Register 0: SYS_INIT=0, LOL_B=0, LOL_A=0, LOS=1, REVID=0
|
||||
READ: 0x10
|
||||
...
|
||||
# Read 16 registers, starting with register 0
|
||||
I2C>[0xc0 0[0xc1 r:16]]
|
||||
...
|
||||
READ: 0x10 ACK 0xF8 ACK 0x03 ACK 0x00 ACK 0x00 ACK 0x00 ACK 0x8F ACK 0x01 ACK
|
||||
0x00 ACK 0x00 ACK 0x00 ACK 0x00 ACK 0x00 ACK 0x00 ACK 0x90 ACK 0x00
|
||||
...
|
||||
# Read 16 registers, starting with register 16
|
||||
I2C>[0xc0 16[0xc1 r:16]]
|
||||
...
|
||||
READ: 0x00 ACK 0x00 ACK 0x00 ACK 0x00 ACK 0x00 ACK 0x00 ACK 0x00 ACK 0x00 ACK
|
||||
0x00 ACK 0x00 ACK 0x00 ACK 0x00 ACK 0x00 ACK 0x00 ACK 0x00 ACK 0x00
|
||||
...
|
||||
|
||||
|
||||
|
||||
Writing registers
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
Simple XTAL passthrough to CLK0
|
||||
+++++++++++++++++++++++++++++++
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
# Disable all CLKx outputs.
|
||||
[0xC0 3 0xFF]
|
||||
|
||||
# Turn off OEB pin control for all CLKx
|
||||
[0xC0 9 0xFF]
|
||||
|
||||
# Power down all CLKx
|
||||
[0xC0 16 0x80 0x80 0x80 0x80 0x80 0x80 0x80 0x80]
|
||||
|
||||
# Register 183: Crystal Internal Load Capacitance
|
||||
# Reads as 0xE4 on power-up
|
||||
# Set to 10pF (until I find out what loading the crystal/PCB likes best)
|
||||
[0xC0 183 0xE4]
|
||||
|
||||
# Register 187: Fanout Enable
|
||||
# Turn on XO fanout only.
|
||||
[0xC0 187 0x40]
|
||||
|
||||
# Register 15: PLL Input Source
|
||||
# CLKIN_DIV=0 (Divide by 1)
|
||||
# PLLB_SRC=0 (XTAL input)
|
||||
# PLLA_SRC=0 (XTAL input)
|
||||
[0xC0 15 0x00]
|
||||
|
||||
# Registers 16 through 23: CLKx Control
|
||||
# CLK0:
|
||||
# CLK0_PDN=0 (powered up)
|
||||
# MS0_INT=1 (integer mode)
|
||||
# MS0_SRC=0 (PLLA as source for MultiSynth 0)
|
||||
# CLK0_INV=0 (not inverted)
|
||||
# CLK0_SRC=0 (XTAL as clock source for CLK0)
|
||||
# CLK0_IDRV=3 (8mA)
|
||||
[0xC0 16 0x43 0x80 0x80 0x80 0x80 0x80 0x80 0x80]
|
||||
|
||||
# Enable CLK0 output only.
|
||||
[0xC0 3 0xFE]
|
||||
|
||||
|
||||
|
||||
Clocking Scheme (Work In Progress)
|
||||
++++++++++++++++++++++++++++++++++
|
||||
|
||||
From AN619: If Fxtal=25MHz, Fvco = Fxtal * (a + (b / c)). If we want Fvco = 800MHz, a = 32, b = 0, c = don't care.
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
MSNA_P1[17:0] = 128 * a + floor(128 * b / c) - 512
|
||||
= 128 * a + floor(0) - 512
|
||||
= 128 * 32 + 0 - 512
|
||||
= 3584 = 0xE00
|
||||
MSNA_P1[17:16] (register 28) = 0x00
|
||||
MSNA_P1[15: 8] (register 29) = 0x0E
|
||||
MSNA_P1[ 7: 0] (register 30) = 0x00
|
||||
MSNA_P2[19:0] = 128 * b - c * floor(128 * b / c)
|
||||
= 128 * 0 - 0 * floor(128 * 0 / X)
|
||||
= 0
|
||||
MSNA_P3[19:0] = 0
|
||||
|
||||
MultiSynth0 should output 40MHz (800MHz VCO divided by 20):
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
a = 20, b = 0, c = X
|
||||
MS0_P1[17: 0] = 128 * a + floor(128 * b / c) - 512
|
||||
= 2048 = 0x800
|
||||
MS0_P1[17:16] (register 44) = 0x00
|
||||
MS0_P1[15: 8] (register 45) = 0x08
|
||||
MS0_P1[ 7: 0] (register 46) = 0x00
|
||||
MS0_P2[19:0] = 0
|
||||
MS0_P3[19:0] = 0
|
||||
|
||||
MultiSynth1 should output 20MHz (800MHz VCO divided by 40) or some smaller integer fraction of the VCO:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
a = 40, b = 0, c = X
|
||||
MS1_P1[17: 0] = 128 * a + floor(128 * b / c) - 512
|
||||
= 4608 = 0x1200
|
||||
MS1_P1[17:16] (register 52) = 0x00
|
||||
MS1_P1[15: 8] (register 53) = 0x12
|
||||
MS1_P1[ 7: 0] (register 54) = 0x00
|
||||
MS1_P2[19:0] = 0
|
||||
MS1_P3[19:0] = 0
|
||||
|
||||
Initialization:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
# Disable all CLKx outputs.
|
||||
[0xC0 3 0xFF]
|
||||
|
||||
# Turn off OEB pin control for all CLKx
|
||||
[0xC0 9 0xFF]
|
||||
|
||||
# Power down all CLKx
|
||||
[0xC0 16 0x80 0x80 0x80 0x80 0x80 0x80 0x80 0x80]
|
||||
|
||||
# Register 183: Crystal Internal Load Capacitance
|
||||
# Reads as 0xE4 on power-up
|
||||
# Set to 10pF (until I find out what loading the crystal/PCB likes best)
|
||||
[0xC0 183 0xE4]
|
||||
|
||||
# Register 187: Fanout Enable
|
||||
# Turn on XO and MultiSynth fanout only.
|
||||
[0xC0 187 0x50]
|
||||
|
||||
# Register 15: PLL Input Source
|
||||
# CLKIN_DIV=0 (Divide by 1)
|
||||
# PLLB_SRC=0 (XTAL input)
|
||||
# PLLA_SRC=0 (XTAL input)
|
||||
[0xC0 15 0x00]
|
||||
|
||||
# MultiSynth NA (PLL1)
|
||||
[0xC0 26 0x00 0x00 0x00 0x0E 0x00 0x00 0x00 0x00]
|
||||
|
||||
# MultiSynth NB (PLL2)
|
||||
...
|
||||
|
||||
# MultiSynth 0
|
||||
[0xC0 42 0x00 0x00 0x00 0x08 0x00 0x00 0x00 0x00]
|
||||
|
||||
# MultiSynth 1
|
||||
[0xC0 50 0x00 0x00 0x00 0x12 0x00 0x00 0x00 0x00]
|
||||
|
||||
# Registers 16 through 23: CLKx Control
|
||||
# CLK0:
|
||||
# CLK0_PDN=0 (powered up)
|
||||
# MS0_INT=1 (integer mode)
|
||||
# MS0_SRC=0 (PLLA as source for MultiSynth 0)
|
||||
# CLK0_INV=0 (not inverted)
|
||||
# CLK0_SRC=3 (MS0 as input source)
|
||||
# CLK0_IDRV=3 (8mA)
|
||||
# CLK1:
|
||||
# CLK1_PDN=0 (powered up)
|
||||
# MS1_INT=1 (integer mode)
|
||||
# MS1_SRC=0 (PLLA as source for MultiSynth 1)
|
||||
# CLK1_INV=0 (not inverted)
|
||||
# CLK1_SRC=3 (MS1 as input source)
|
||||
# CLK1_IDRV=3 (8mA)
|
||||
[0xC0 16 0x4F 0x4F 0x80 0x80 0x80 0x80 0x80 0x80]
|
||||
|
||||
# Enable CLK0 output only.
|
||||
[0xC0 3 0xFC]
|
||||
|
||||
|
||||
|
||||
Si5351 output phase relationships
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Tested CLK4 and CLK5 (integer division only):
|
||||
|
||||
With CLK4 set to MS4 and CLK5 set to MS5, even with both multisynths configured identically, there was no consistent phase between the two. Once started, the clocks maintained relative phase with each other, but when stopped and restarted the initial phase offset was unpredictable.
|
||||
|
||||
With CLK4 and CLK5 both set to MS4, the phase of both outputs was identical when no output (R) divider was selected. When an output divider was selected on both MS4 and MS5, the relative phase became predictable only within the constraints of the divider (e.g. with R=2 the relative phase was always either 0 or half a cycle, with R=4 the relative phase was always either 0, a quarter, a half, or three quarters of a cycle). With R=1 on MS4 and R=2 on MS5, the two outputs were consistently in phase with each other. The output (R) dividers supposedly tied to the multisynths are actually tied to the outputs.
|
568
Software/portapack-mayhem/hackrf/docs/source/libhackrf_api.rst
Normal file
@@ -0,0 +1,568 @@
|
||||
================================================
|
||||
libhackRF API
|
||||
================================================
|
||||
|
||||
|
||||
|
||||
This document describes the functions, data structures and constants that libHackRF provides. It should be used as a reference for using libHackRF and the HackRF hardware.
|
||||
|
||||
If you are writing a generic SDR application, i.e. not tied to the HackRF hardware, we strongly recommend that you use either gr-osmosdr or SoapySDR to provide support for the broadest possible range of software defined radio hardware.
|
||||
|
||||
For example usage of many of these functions, see the `hackrf_transfer <https://github.com/mossmann/hackrf/blob/master/host/hackrf-tools/src/hackrf_transfer.c>`__ tool.
|
||||
|
||||
|
||||
|
||||
Setup, Initialization and Shutdown
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
HackRF Init
|
||||
^^^^^^^^^^^
|
||||
|
||||
Initialize libHackRF, including global libUSB context to support multiple HackRF hardware devices.
|
||||
|
||||
**Syntax:** ``int hackrf_init()``
|
||||
|
||||
**Returns:** A value from the hackrf_error constants listed below.
|
||||
|
||||
|
||||
|
||||
HackRF Open
|
||||
^^^^^^^^^^^
|
||||
|
||||
**Syntax:** ``int hackrf_open(hackrf_device** device)``
|
||||
|
||||
**Returns:** A value from the hackrf_error constants listed below.
|
||||
|
||||
|
||||
|
||||
HackRF Device List
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Retrieve a list of HackRF devices attached to the system. This function finds all devices, regardless of permissions or availability of the hardware.
|
||||
|
||||
**Syntax:** ``hackrf_device_list_t* hackrf_device_list()``
|
||||
|
||||
**Returns:** A pointer to a hackrf_device_list_t struct, a list of HackRF devices attached to the system. The contents of the hackrf_device_list_t struct are decribed in the data structures section below.
|
||||
|
||||
|
||||
|
||||
|
||||
HackRF Device List Open
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Open and acquire a handle on a device from the hackrf_device_list_t struct.
|
||||
|
||||
**Syntax:** ``int hackrf_device_list_open(hackrf_device_list_t* list, int idx, hackrf_device** device)``
|
||||
|
||||
**Params:**
|
||||
|
||||
``list`` - A pointer to a hackrf_device_list_t returned by ``hackrf_device_list()``
|
||||
|
||||
``idx`` - The list index of the HackRF device to open
|
||||
|
||||
``device`` - Output location for hackrf_device pointer. Only valid when return value is HACKRF_SUCCESS.
|
||||
|
||||
**Returns:** A value from the hackrf_error constants listed below.
|
||||
|
||||
|
||||
|
||||
HackRF Device List Free
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
**Syntax:** ``void hackrf_device_list_free(hackrf_device_list_t* list)``
|
||||
|
||||
**Params:**
|
||||
|
||||
``list`` - A pointer to a hackrf_device_list_t returned by ``hackrf_device_list()``
|
||||
|
||||
|
||||
|
||||
|
||||
HackRF Open By Serial
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
**Syntax:** ``int hackrf_open_by_serial(const char* const desired_serial_number, hackrf_device** device)``
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
||||
|
||||
HackRF Close
|
||||
^^^^^^^^^^^^
|
||||
|
||||
**Syntax:** ``int hackrf_close(hackrf_device* device)``
|
||||
|
||||
**Returns:** A value from the hackrf_error constants listed below.
|
||||
|
||||
|
||||
|
||||
HackRF Exit
|
||||
^^^^^^^^^^^
|
||||
|
||||
Cleanly shutdown libHackRF and the underlying USB context. This does not stop in progress transfers or close the HackRF hardware. ``hackrf_close()`` should be called before this to cleanly close the connection to the hardware.
|
||||
|
||||
**Syntax:** ``int hackrf_exit()``
|
||||
|
||||
**Returns:** A value from the hackrf_error constants listed below.
|
||||
|
||||
|
||||
|
||||
Using the Radio
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
HackRF Start Rx
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
**Syntax:** ``int hackrf_start_rx(hackrf_device*, hackrf_sample_block_cb_fn, void* rx_ctx)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:** A value from the hackrf_error constants listed below.
|
||||
|
||||
|
||||
|
||||
|
||||
HackRF Stop Rx
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
**Syntax:** ``int hackrf_stop_rx(hackrf_device*)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:** A value from the hackrf_error constants listed below.
|
||||
|
||||
|
||||
|
||||
|
||||
HackRF Start Tx
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
**Syntax:** ``int hackrf_start_tx(hackrf_device*, hackrf_sample_block_cb_fn, void* tx_ctx)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:** A value from the hackrf_error constants listed below.
|
||||
|
||||
|
||||
|
||||
HackRF Stop Tx
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
**Syntax:** ``int hackrf_stop_tx(hackrf_device*)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:** A value from the hackrf_error constants listed below.
|
||||
|
||||
|
||||
|
||||
HackRF Set Baseband Filter Bandwidth
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
**Syntax:** ``int hackrf_set_baseband_filter_bandwidth(hackrf_device*, const uint32_t bandwidth_hz)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:** A value from the hackrf_error constants listed below.
|
||||
|
||||
|
||||
|
||||
HackRF Compute Baseband Filter BW
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Compute best default value depending on sample rate (auto filter).
|
||||
|
||||
**Syntax:** ``uint32_t hackrf_compute_baseband_filter_bw(const uint32_t bandwidth_hz)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:** A valid baseband filter width available from the Maxim MAX2837 frontend used by the radio.
|
||||
|
||||
|
||||
|
||||
|
||||
HackRF Compute Baseband Filter BW Round Down LT
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Compute nearest freq for bw filter (manual filter)
|
||||
|
||||
**Syntax:** ``uint32_t hackrf_compute_baseband_filter_bw_round_down_lt(const uint32_t bandwidth_hz)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:** A valid baseband filter width available from the Maxim MAX2837 frontend used by the radio.
|
||||
|
||||
|
||||
|
||||
Reading and Writing Registers
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
HackRF MAX2837 Read
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Read register values from the MAX2837 Baseband IC.
|
||||
|
||||
**Syntax:** ``int hackrf_max2837_read(hackrf_device* device, uint8_t register_number, uint16_t* value)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
||||
|
||||
HackRF MAX2837 Write
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Write register values to the MAX2837 Baseband IC.
|
||||
|
||||
**Syntax:** ``int hackrf_max2837_write(hackrf_device* device, uint8_t register_number, uint16_t value)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
||||
|
||||
HackRF Si5351C Read
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Read register values from the Si5351C clock generator IC.
|
||||
|
||||
**Syntax:** ``int hackrf_si5351c_read(hackrf_device* device, uint16_t register_number, uint16_t* value)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
||||
|
||||
HackRF Si5351C Write
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Write register values to the Si5351C clock generator IC.
|
||||
|
||||
**Syntax:** ``int hackrf_si5351c_write(hackrf_device* device, uint16_t register_number, uint16_t value)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
||||
|
||||
HackRF RFFC5071 Read
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Read register values from the RFFC5071 mixer IC.
|
||||
|
||||
**Syntax:** ``int hackrf_rffc5071_read(hackrf_device* device, uint8_t register_number, uint16_t* value)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
||||
|
||||
HackRF RFFC5071 Write
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Write register values to the RFFC5071 mixer IC.
|
||||
|
||||
**Syntax:** ``int hackrf_rffc5071_write(hackrf_device* device, uint8_t register_number, uint16_t value)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
||||
|
||||
Updating Firmware
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
HackRF CPLD Write
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
Device will need to be reset after hackrf_cpld_write.
|
||||
|
||||
**Syntax:** ``int hackrf_cpld_write(hackrf_device* device, unsigned char* const data, const unsigned int total_length)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
||||
|
||||
|
||||
HackRF SPI Flash Erase
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
**Syntax:** ``int hackrf_spiflash_erase(hackrf_device* device)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
||||
|
||||
HackRF SPI Flash Write
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
**Syntax:** ``int hackrf_spiflash_write(hackrf_device* device, const uint32_t address, const uint16_t length, unsigned char* const data)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
||||
|
||||
HackRF SPI Flash Read
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
**Syntax:** ``int hackrf_spiflash_read(hackrf_device* device, const uint32_t address, const uint16_t length, unsigned char* data)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
||||
|
||||
Board Identifiers
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
HackRF Board ID Read
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
**Syntax:** ``int hackrf_board_id_read(hackrf_device* device, uint8_t* value)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
||||
|
||||
HackRF Version String Read
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
**Syntax:** ``int hackrf_version_string_read(hackrf_device* device, char* version, uint8_t length)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
||||
|
||||
HackRF Board Part ID Serial Number Read
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
**Syntax:** ``int hackrf_board_partid_serialno_read(hackrf_device* device, read_partid_serialno_t* read_partid_serialno)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
||||
|
||||
Miscellaneous
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
HackRF Error Name
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
**Syntax:** ``const char* hackrf_error_name(enum hackrf_error errcode)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
||||
|
||||
HackRF Board ID Name
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
**Syntax:** ``const char* hackrf_board_id_name(enum hackrf_board_id board_id)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
||||
|
||||
HackRF USB Board ID Name
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
**Syntax:** ``const char* hackrf_usb_board_id_name(enum hackrf_usb_board_id usb_board_id)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
||||
|
||||
HackRF Filter Path Name
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
**Syntax:** ``const char* hackrf_filter_path_name(const enum rf_path_filter path)``
|
||||
|
||||
**Params:**
|
||||
|
||||
**Returns:**
|
||||
|
||||
|
||||
|
||||
Data Structures
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
``typedef struct hackrf_device hackrf_device``
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
typedef struct {
|
||||
hackrf_device* device;
|
||||
uint8_t* buffer;
|
||||
int buffer_length;
|
||||
int valid_length;
|
||||
void* rx_ctx;
|
||||
void* tx_ctx;
|
||||
} hackrf_transfer;
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
typedef struct {
|
||||
uint32_t part_id[2];
|
||||
uint32_t serial_no[4];
|
||||
} read_partid_serialno_t;
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
typedef struct {
|
||||
char **serial_numbers;
|
||||
enum hackrf_usb_board_id *usb_board_ids;
|
||||
int *usb_device_index;
|
||||
int devicecount;
|
||||
|
||||
void **usb_devices;
|
||||
int usb_devicecount;
|
||||
} hackrf_device_list_t;
|
||||
|
||||
``typedef int (*hackrf_sample_block_cb_fn)(hackrf_transfer* transfer)``
|
||||
|
||||
|
||||
|
||||
Enumerations
|
||||
~~~~~~~~~~~~
|
||||
|
||||
Supported board versions
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
These values identify the board type of the connected hardware. This value can be used as an indicator of capabilities, such as frequency range, bandwidth or antenna port power.
|
||||
|
||||
.. list-table ::
|
||||
:header-rows: 1
|
||||
:widths: 1 1 1 1
|
||||
|
||||
* - Board
|
||||
- Frequency range
|
||||
- Bandwidth
|
||||
- Antenna port power
|
||||
* - HackRF One
|
||||
- 1MHz - 6Ghz
|
||||
- 20MHz
|
||||
- Yes
|
||||
* - Jawbreaker
|
||||
- 10MHz - 6GHz
|
||||
- 20MHz
|
||||
- No
|
||||
* - Rad1o
|
||||
- 50MHz - 4GHz
|
||||
- 20MHz
|
||||
- Unknown
|
||||
* - Jellybean
|
||||
- N/A
|
||||
- 20MHz
|
||||
- No
|
||||
|
||||
Most boards will identify as HackRF One, Jawbreaker or Rad1o. Jellybean was a pre-production revision of HackRF. No hardware device should intentionally report itself with an invalid board ID.
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
enum hackrf_board_id {
|
||||
BOARD_ID_JELLYBEAN = 0,
|
||||
BOARD_ID_JAWBREAKER = 1,
|
||||
BOARD_ID_HACKRF_ONE = 2,
|
||||
BOARD_ID_RAD1O = 3,
|
||||
BOARD_ID_INVALID = 0xFF,
|
||||
};
|
||||
|
||||
|
||||
|
||||
USB Product IDs
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
enum hackrf_usb_board_id {
|
||||
USB_BOARD_ID_JAWBREAKER = 0x604B,
|
||||
USB_BOARD_ID_HACKRF_ONE = 0x6089,
|
||||
USB_BOARD_ID_RAD1O = 0xCC15,
|
||||
USB_BOARD_ID_INVALID = 0xFFFF,
|
||||
};
|
||||
|
||||
|
||||
|
||||
Transceiver Mode
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
HackRF can operate in three main transceiver modes, Receive, Transmit and Signal Source. There is also a CPLD update mode which is used to write firmware images to the CPLD.
|
||||
|
||||
The transceiver mode can be changed with ``hackrf_set_transceiver_mode`` with the value parameter set to one of the following:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
enum transceiver_mode_t {
|
||||
TRANSCEIVER_MODE_OFF = 0,
|
||||
TRANSCEIVER_MODE_RX = 1,
|
||||
TRANSCEIVER_MODE_TX = 2,
|
||||
TRANSCEIVER_MODE_SS = 3,
|
||||
TRANSCEIVER_MODE_CPLD_UPDATE = 4
|
||||
};
|
||||
|
||||
Receive mode (TRANSCEIVER_MODE_RX) is used to stream samples from the radio to the host system. Use ``hackrf_set_freq`` to set the center frequency of receiver and ``hackrf_set_sample_rate`` to set the sample rate (effective bandwidth).
|
||||
|
||||
Transmit mode (TRANSCEIVER_MODE_TX) is used to stream samples from the host to the radio.
|
||||
|
||||
See `hackrf_transfer <https://github.com/mossmann/hackrf/blob/master/host/hackrf-tools/src/hackrf_transfer.c>`__ for an example of setting transmit and receive mode and transferring data over USB.
|
||||
|
||||
|
||||
|
||||
Function return values
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block::sh
|
||||
|
||||
enum hackrf_error {
|
||||
HACKRF_SUCCESS = 0,
|
||||
HACKRF_TRUE = 1,
|
||||
HACKRF_ERROR_INVALID_PARAM = -2,
|
||||
HACKRF_ERROR_NOT_FOUND = -5,
|
||||
HACKRF_ERROR_BUSY = -6,
|
||||
HACKRF_ERROR_NO_MEM = -11,
|
||||
HACKRF_ERROR_LIBUSB = -1000,
|
||||
HACKRF_ERROR_THREAD = -1001,
|
||||
HACKRF_ERROR_STREAMING_THREAD_ERR = -1002,
|
||||
HACKRF_ERROR_STREAMING_STOPPED = -1003,
|
||||
HACKRF_ERROR_STREAMING_EXIT_CALLED = -1004,
|
||||
HACKRF_ERROR_OTHER = -9999,
|
||||
};
|
||||
|
||||
|
||||
|
||||
RF Filter Path
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
enum rf_path_filter {
|
||||
RF_PATH_FILTER_BYPASS = 0,
|
||||
RF_PATH_FILTER_LOW_PASS = 1,
|
||||
RF_PATH_FILTER_HIGH_PASS = 2,
|
||||
};
|
@@ -0,0 +1,33 @@
|
||||
================================================
|
||||
List of Hardware Revisions
|
||||
================================================
|
||||
|
||||
HackRF One r1–r4
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
The first revision of HackRF One shipped by Great Scott Gadgets starting in 2014 was labeled r1. Subsequent manufacturing runs incremented the revision number up to r4 without modification to the hardware design. Manufacturing years: 2014–2020
|
||||
|
||||
HackRF One r5
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
This experimental revision has not been manufactured.
|
||||
|
||||
HackRF One r6
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
SKY13350 RF switches were replaced by SKY13453 due to component availability. Although the SKY13453 uses simplified control logic, it did not require a firmware modification. Manufacturing year: 2020
|
||||
|
||||
HackRF One r7
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
SKY13453 RF switches were reverted to SKY13350 due to component availability. USB VBUS detection resistor values were changed to better protect the LPC4320. Manufacturing year: 2021
|
||||
|
||||
HackRF One r8
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
SKY13350 RF switches were replaced by SKY13453 due to component availability. Manufacturing years: 2021–2022
|
||||
|
||||
Hardware Revision Identification
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
HackRF Ones manufactured by Great Scott Gadgets have the revision number printed on the PCB top silkscreen layer near the MAX5864 (U18).
|
@@ -0,0 +1,147 @@
|
||||
================================================
|
||||
Multiple Device Hardware Level Synchronization
|
||||
================================================
|
||||
|
||||
Purpose
|
||||
~~~~~~~
|
||||
|
||||
This page describes the modifications required to get multiple HackRF hardware-level synchronisation working. Synchronisation is required for many applications where a single HackRF isn't sufficient:
|
||||
|
||||
* phase correlation
|
||||
* oversampling using multiple devices
|
||||
* 40MHz (or more) protocols such as WiFi
|
||||
|
||||
The HackRFs will start transmitting USB packets at the same time, which results in an inter-device offset of ~50 samples at a sample rate of 20MSps. Without this synchronisation, the offset is in the range of thousands to tens of thousands of samples. This is due to the USB start command being called sequentially for each device, along with USB buffering, OS-level timing etc.
|
||||
|
||||
|
||||
|
||||
**BE WARNED** you will have to open your HackRFs, which is most likely going to destroy the plastic case it comes in. You will also be electrically connecting them together. If you do this incorrectly, there is a good chance one or all of the devices will be permanently destroyed.
|
||||
|
||||
|
||||
|
||||
Related work
|
||||
~~~~~~~~~~~~
|
||||
|
||||
\"bardi\_\" on the #hackrf channel pointed out his paper on synchronising HackRFs. This uses the HackRF CPLD to synchronise multiple devices.
|
||||
|
||||
|
||||
|
||||
Requirements
|
||||
~~~~~~~~~~~~
|
||||
|
||||
For this to work you will need:
|
||||
|
||||
* at least two devices
|
||||
* a clock sync cable
|
||||
* some connecting cables (pin header-type)
|
||||
* a breadboard
|
||||
|
||||
|
||||
.. _opening_your_hackrf:
|
||||
|
||||
Opening your HackRF
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The HackRF case has small plastic clips holding it together. These are usually destroyed when the case is opened. Please follow the instructions in `this video <https://www.youtube.com/watch?v=zuXJtpTSEJM>`__ by `Jared Boone <https://twitter.com/sharebrained>`__.
|
||||
|
||||
|
||||
|
||||
Connect the clocks
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Connecting the HackRF clocks together will force them to sample at precisely the same rate. The individual samples will most likely be sampled at slightly different times due to phase offsets in the clock ICs, but for most purposes this is acceptable.
|
||||
|
||||
Choose a **primary** HackRF, and connect the clock sync cable from the clock out connector to the clock in connector of the **second** HackRF. If you're using another HackRF, connect the second HackRF's clock out to the **third** HackRF's clock in.
|
||||
|
||||
Your HackRFs should look like this:
|
||||
|
||||
.. image:: ../images/hackrf-clock-sync.jpg
|
||||
:align: center
|
||||
|
||||
|
||||
|
||||
Identify the pin headers
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Firstly, this has only been tested on official HackRF Ones. If you have a jawbreaker, HackRF blue or another HackRF-inspired device, you will have to figure out how to connect the devices correctly, using the schematics.
|
||||
|
||||
The hackrf has four pin headers, three of which are arranged in a 'C' shape. On the board these are marked as *P28*, *P22* and *P20*. *P20* is the header closest to the *clock in/clock out* connectors. For this exercise we will only be discussing *P20*. The `hackrf schematics <https://github.com/mossmann/hackrf/tree/master/hardware/hackrf-one>`__ are a very good reference for this activity. The relevant part can been seen in the following image:
|
||||
|
||||
.. image:: ../images/hackrf-pin-headers.jpg
|
||||
:align: center
|
||||
|
||||
This is the P20 schematic diagram:
|
||||
|
||||
.. image:: ../images/hackrf-pin-headers-p20.png
|
||||
:align: center
|
||||
|
||||
|
||||
|
||||
Wire up the pin headers
|
||||
~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
As mentioned before **BE WARNED**, this step could easily result in **one or all** of your HackRFs being **permanently damaged**.
|
||||
|
||||
Now that's out of the way, let me describe what we're doing here. The first part of this exercise is to give both devices a common ground. This is really important for any inter-device electrical connections, as it prevents ICs from seeing slight differences in the respective GND levels as legitimate signals. As shown on the schematic, many of the pins in P20 are GND pins. We use P20-PIN19 on both devices and connect them together like so:
|
||||
|
||||
.. image:: ../images/hackrf-pin-headers-p20-19-gnd.jpg
|
||||
:align: center
|
||||
|
||||
.. image:: ../images/hackrfs-gnd-connection.jpg
|
||||
:align: center
|
||||
|
||||
We then need a *positive* (+5v) connection to 'fake' the *third* hackrf if it's not present. We use *P20-PIN3* from the **primary** hackrf for this, and bring it down to the breadboard. *primary:P20-PIN8* and *secondary:P20-PIN8* are ready input GPIO pins for the missing third HackRF. Connect these to the breadboard *positive* line. After this your setup should look like so:
|
||||
|
||||
.. image:: ../images/hackrf-pin-headers-p20-3-positive.jpg
|
||||
:align: center
|
||||
|
||||
.. image:: ../images/hackrf-pin-headers-p20-3-8-3rd.png
|
||||
:align: center
|
||||
|
||||
Next we connect the *primary:P20-PIN7 ready* GPIO pin input to the *secondary:P20-PIN5 ready* GPIO pin output, and the *primary:P20-PIN5 ack* GPIO pin output to the *secondary:P20-PIN7* ack GPIO pin input. This is the final step, and should look as follows:
|
||||
|
||||
.. image:: ../images/hackrf-pin-headers-ack-ready-colours.jpg
|
||||
:align: center
|
||||
|
||||
.. image:: ../images/hackrf-pin-headers-ack-ready.jpg
|
||||
:align: center
|
||||
|
||||
|
||||
|
||||
Upgrade
|
||||
~~~~~~~
|
||||
|
||||
Now that the hardware is setup, you need to upgrade your HackRFs' firmware, and your *libhackrf* to at least `v2017.02.1 <https://github.com/mossmann/hackrf/releases/tag/v2017.02.1>`__ as per :ref:`this documentation page <updating_firmware>`.
|
||||
|
||||
|
||||
|
||||
Testing with hackrf_transfer
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The latest version of *hackrf_transfer* includes the '-H' flag, which will activate hardware synchronisation (via libhackrf via the firmware). Testing this way is a little tricky because neither HackRF will start sending data until they are synched, and *hackrf_transfer* will time out if it hasn't received any data within one second. So the test requires that **two** copies of _hackrf_transfer are started within 1 second of each other. My approach is to have two terminal windows with the relevant commands waiting, and quickly run them.
|
||||
|
||||
This test will fail if:
|
||||
|
||||
* your hackrf firmware or libhackrf are out of date
|
||||
* your connectors are incorrectly set up
|
||||
* your timing is too slow when running hackrf_transfer
|
||||
|
||||
Run the following command:
|
||||
|
||||
* hackrf_transfer -d <device A> -r <filename-A> -H &; hackrf_transfer -d <device B> -r <filename-B> -H
|
||||
|
||||
If the test runs correctly, you have successfully streamed synchronised data from two HackRFs!
|
||||
|
||||
The two streams can be merged into one using GnuRadio, and then viewed using `this hacky piece of PyQt <https://github.com/dodgymike/direction-finding/blob/master/decode_remote_dual_stream.py>`__.
|
||||
|
||||
|
||||
|
||||
What next?
|
||||
~~~~~~~~~~
|
||||
|
||||
Obviously the method of wiring up multiple HackRFs described above is fragile and prone to error. Perhaps a PCB could be designed that will connect up to four HackRFs together by plugging into the 'C-shape' pin headers.
|
||||
|
||||
Usually the *Osmocom source* can be used for multi-device streaming, as it can be configured to pull from more than one device. Unfortunately the current version does not have hardware synchronisation built in. Work is being done to make the *Osmocom source* compatible with these changes.
|
||||
|
||||
.. image:: ../images/grc-hw-sync-streaming.png
|
||||
:align: center
|
164
Software/portapack-mayhem/hackrf/docs/source/opera_cake.rst
Normal file
@@ -0,0 +1,164 @@
|
||||
================================================
|
||||
Opera Cake
|
||||
================================================
|
||||
|
||||
Opera Cake is an antenna switching add-on board for HackRF One. Consisting of two 1x4 switches, Opera Cake also has a cross-over switch that permits operation as a 1x8 switch. Up to eight Opera Cakes may be stacked onto a single HackRF One provided that each Opera Cake is configured with a different board address.
|
||||
|
||||
Opera Cake is configured with the ``hackrf_operacake`` command-line tool.
|
||||
|
||||
|
||||
Using Opera Cake
|
||||
~~~~~~~~~~~~~~~~
|
||||
|
||||
Banks
|
||||
^^^^^
|
||||
|
||||
Opera Cake's ports are grouped in two banks (or "sides"), one on each end of the board. Bank A consists of ports A0 through A4 while bank B consists of ports B0 through B4.
|
||||
|
||||
Ports
|
||||
^^^^^
|
||||
|
||||
Opera Cake has two primary ports, A0 and B0, each of which can be switched to any of eight secondary ports, A1-A4 and B1-B4. Each primary port is always connected to one secondary port. By default, A0 is connected to A1, and B0 is connected to B1. It is not possible to connect both primary ports to secondary ports in the same bank at the same time.
|
||||
|
||||
Port connections may be configured manually. For example, to connect A0 to A2 and B0 to B3:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
hackrf_operacake -a A2 -b B3
|
||||
|
||||
To connect A0 to B2 and B0 to A4:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
hackrf_operacake -a B2 -b A4
|
||||
|
||||
If only one primary port is configured, the other primary port will be connected to the first secondary port on the opposite side. For example, after the next two commands B0 will be connected to A1:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
hackrf_operacake -a A2 -b B3
|
||||
hackrf_operacake -a B2
|
||||
|
||||
LEDs
|
||||
^^^^
|
||||
|
||||
Port selections are indicated by LEDs next to each port's connector. Port A0 and the secondary port connected to A0 are indicated with a green LED. Port B0 and the secondary port connected to B0 are indicated with a yellow LED.
|
||||
|
||||
Board Address
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
Each Opera Cake has a numeric address set by optional jumpers installed on header P1. The default address (without jumpers) is 0. The ``--list`` or ``-l`` option can be used to list the address(es) of one or more Opera Cakes installed on a HackRF One:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
hackrf_operacake -l
|
||||
|
||||
The address may be set to any number from 0 to 7 by installing jumpers across the A0, A1, and/or A2 pins of header P1.
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
:widths: 1 1 1 1
|
||||
|
||||
* - Address
|
||||
- A2 Jumper
|
||||
- A1 Jumper
|
||||
- A0 Jumper
|
||||
* - 0
|
||||
- No
|
||||
- No
|
||||
- No
|
||||
* - 1
|
||||
- No
|
||||
- No
|
||||
- Yes
|
||||
* - 2
|
||||
- No
|
||||
- Yes
|
||||
- No
|
||||
* - 3
|
||||
- No
|
||||
- Yes
|
||||
- Yes
|
||||
* - 4
|
||||
- Yes
|
||||
- No
|
||||
- No
|
||||
* - 5
|
||||
- Yes
|
||||
- No
|
||||
- Yes
|
||||
* - 6
|
||||
- Yes
|
||||
- Yes
|
||||
- No
|
||||
* - 7
|
||||
- Yes
|
||||
- Yes
|
||||
- Yes
|
||||
|
||||
When configuring an Opera Cake, the address may be specified with the ``--address`` or ``-o`` option:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
hackrf_operacake -o 1 -a A1 -b B2
|
||||
|
||||
If the address is unspecified, 0 is assumed. It is only necessary to specify the address if the address has been changed with the addition of jumpers, typically required only if multiple Opera Cakes are stacked onto a single HackRF One.
|
||||
|
||||
|
||||
Modes of Operation
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Opera Cake supports three modes of operation: ``manual``, ``frequency``, and ``time``. The operating mode can be set with the ``--mode`` or ``-m`` option, and the active operating mode is displayed with the ``--list`` or ``-l`` option.
|
||||
|
||||
Manual Mode
|
||||
^^^^^^^^^^^
|
||||
|
||||
The default mode of operation is ``manual``. In manual mode, fixed port connections are configured with the ``-a`` and ``-b`` options as in the port configuration examples above. If the operating mode has been changed, it can be changed back to manual mode with:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
hackrf_operacake -m manual
|
||||
|
||||
Frequency Mode
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
In frequency mode, the A0 port connection switches automatically whenever the HackRF is tuned to a different frequency. This is useful when antennas for different frequency bands are connected to various ports.
|
||||
|
||||
The bands are specified in priority order. The final band specified will be used for frequencies not covered by the other bands specified.
|
||||
|
||||
To assign frequency bands to ports you must use the ``-f <port:min:max>`` option for each band, with the minimum and maximum frequencies specified in MHz. For example, to use port A1 for 100 MHz to 600 MHz, A3 for 600 MHz to 1200 MHz, and B2 for 0 MHz to 4 GHz:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
hackrf_operacake -m frequency -f A1:100:600 -f A3:600:1200 -f B2:0:4000
|
||||
|
||||
If tuning to precisely 600 MHz, A1 will be used as it is listed first. Tuning to any frequency over 4 GHz will use B2 as it is the last listed and therefore the default port.
|
||||
|
||||
Only the A0 port connection is specified in frequency mode. Whenever the A0 connection is switched, the B0 connection is also switched to the secondary port mirroring A0's secondary port. For example, when A0 switches to B2, B0 is switched to A2.
|
||||
|
||||
Once configured, an Opera Cake will remain in frequency mode until the mode is reconfigured or until the HackRF One is reset. You can pre-configure the Opera Cake in frequency mode, and the automatic switching will continue to work while using other software.
|
||||
|
||||
Although multiple Opera Cakes on a single HackRF One may be set to frequency mode at the same time, they share a single switching plan. This can be useful, for example, for a filter bank consisting of eight filters.
|
||||
|
||||
Time Mode
|
||||
^^^^^^^^^
|
||||
|
||||
In time mode, the A0 port connection switches automatically over time, counted in units of the sample period. This is useful for experimentation with pseudo-doppler direction finding.
|
||||
|
||||
To cycle through four ports, one port every 1000 samples:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
hackrf_operacake -m time -t A1:1000 -t A2:1000 -t A3:1000 -t A4:1000
|
||||
|
||||
When the duration on multiple ports is the same, the ``-w`` option can be used to set the default dwell time:
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
hackrf_operacake --mode time -w 1000 -t A1 -t A2 -t A3 -t A4
|
||||
|
||||
Only the A0 port connection is specified in time mode. Whenever the A0 connection is switched, the B0 connection is switched to the secondary port mirroring A0's secondary port. For example, when A0 switches to B2, B0 is switched to A2.
|
||||
|
||||
Once configured, an Opera Cake will remain in time mode until the mode is reconfigured or until the HackRF One is reset. You can pre-configure the Opera Cake in time mode, and the automatic switching will continue to work while using other software.
|
||||
|
||||
Although multiple Opera Cakes on a single HackRF One may be set to time mode at the same time, they share a single switching plan.
|
@@ -0,0 +1,72 @@
|
||||
===============================================
|
||||
RF Shield Installation Instructions
|
||||
===============================================
|
||||
|
||||
Official Great Scott Gadgets HackRF Ones do not come from the factory with an RF shield installed around the radio section of the PCB. They do, however, have pads in place so that one may be installed if a user has a reason and an inclination to do so. The reason that they do not come preinstalled is that early testing revealed that the RF shield did little to improve the performance of the HackRF One. The recommended RF shield is the BMI-S-230-F-R (frame) with the BMI-S-230-C (shield). A two part RF shield is recommended because the shield section can be removed to allow access to the RF section of the HackRF One. This can be important if it becomes necessary to probe any part of the RF section, or to replace any parts of the RF section. However, even with a two part RF shield, it can be difficult to access the RF section of the HackRF One in certain situations. The following steps are a basic set of instructions for installing a RF shield on a HackRF One.
|
||||
|
||||
**CAUTION: Soldering a RF shield onto a HackRF One comes with a certain amount of risk. Beyond the inherent risks of soldering itself, this process may damage the HackRF One and no warranty is available to cover damage incurred from this process. If you do choose to install a RF shield on your HackRF One please proceed with caution.**
|
||||
|
||||
1. Remove the HackRF One from the injection molded plastic case.
|
||||
|
||||
**BE WARNED: Opening the plastic case of your HackRF One will most likely destroy the tabs that hold it together.**
|
||||
|
||||
Instructions for removing a HackRF One from it's case can be found :ref:`here <opening_your_hackrf>`.
|
||||
|
||||
|
||||
|
||||
2. Prepare the HackRF One PCB for soldering on the shield frame, by adding flux to the RF shield pads around the radio section on the PCB.
|
||||
|
||||
.. image:: ../images/rf_shield_1.jpeg
|
||||
:align: center
|
||||
|
||||
|
||||
|
||||
3. Place the RF shield frame on the HackRF One, aligning it so that it makes contact with all of the pads around the RF section of the board.
|
||||
|
||||
.. image:: ../images/rf_shield_2.jpg
|
||||
:align: center
|
||||
|
||||
|
||||
|
||||
4. Solder the shield to one pad to anchor it to the H1. Visually inspect the frame to assure that it is still aligned properly.
|
||||
|
||||
+---------------------------------------+---------------------------------------+
|
||||
| .. image:: ../images/rf_shield_3.jpg | .. image:: ../images/rf_shield_4.jpg |
|
||||
+---------------------------------------+---------------------------------------+
|
||||
|
||||
|
||||
|
||||
5. Connect the frame to another pad on the opposite side from the first connection. Again, check that the frame is still aligned properly.
|
||||
|
||||
+---------------------------------------+---------------------------------------+
|
||||
| .. image:: ../images/rf_shield_5.jpg | .. image:: ../images/rf_shield_6.jpg |
|
||||
+---------------------------------------+---------------------------------------+
|
||||
|
||||
|
||||
|
||||
6. Connect at least one more pad, and then remove the pick and place bridge from the frame. *Removing the pick and place bridge is optional, but it is recommended.*
|
||||
|
||||
.. image:: ../images/rf_shield_7.jpg
|
||||
:align: center
|
||||
|
||||
|
||||
|
||||
7. Continue soldering the rest of the pads to the frame.
|
||||
|
||||
.. image:: ../images/rf_shield_8.jpg
|
||||
:align: center
|
||||
|
||||
|
||||
|
||||
8. Clean the flux and soldering residue with the appropriate solvent for the type of flux used. Be sure to let the HackRF One dry completely before plugging it in to a power source.
|
||||
|
||||
|
||||
|
||||
9. Place the RF shield onto the frame and snap it into place.
|
||||
|
||||
.. image:: ../images/rf_shield_9.jpg
|
||||
:align: center
|
||||
|
||||
|
||||
|
||||
10. If desired, put the HackRF One back into the plastic case, if it is still able to click together.
|
@@ -0,0 +1,85 @@
|
||||
================================================
|
||||
HackRF Compatible Software
|
||||
================================================
|
||||
|
||||
Software with HackRF Support
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This is intended to be a list of software known to work with the HackRF. There are three sections, GNU Radio Based software, those that have direct support, and those that can work with data from the HackRF.
|
||||
|
||||
|
||||
|
||||
GNU Radio Based
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
GNU Radio Mode-S/ADS-B - `https://github.com/bistromath/gr-air-modes <https://github.com/bistromath/gr-air-modes>`__
|
||||
|
||||
GQRX - `http://gqrx.dk/ <http://gqrx.dk/>`__
|
||||
|
||||
|
||||
|
||||
Direct Support
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
SDR# (Windows only) - `https://airspy.com/download/ <https://airspy.com/download/>`__
|
||||
|
||||
* Only nightly builds currently support HackRF One - `http://sdrsharp.com/downloads/sdr-nightly.zip <http://sdrsharp.com/downloads/sdr-nightly.zip>`__
|
||||
|
||||
SDR_Radio.com V2 - `http://v2.sdr-radio.com/Radios/HackRF.aspx <http://v2.sdr-radio.com/Radios/HackRF.aspx>`__
|
||||
|
||||
Universal Radio Hacker (Windows/Linux) - `https://github.com/jopohl/urh <https://github.com/jopohl/urh>`__
|
||||
|
||||
QSpectrumAnalyzer - `https://github.com/xmikos/qspectrumanalyzer <https://github.com/xmikos/qspectrumanalyzer>`__
|
||||
|
||||
Spectrum Analyzer GUI for hackrf_sweep for Windows - `https://github.com/pavsa/hackrf-spectrum-analyzer <https://github.com/pavsa/hackrf-spectrum-analyzer>`__
|
||||
|
||||
Web-based APRS tracker `https://xakcop.com/aprs-sdr <https://xakcop.com/aprs-sdr/>`__
|
||||
|
||||
|
||||
Can use HackRF data
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Inspectrum `https://github.com/miek/inspectrum <https://github.com/miek/inspectrum>`__
|
||||
|
||||
* Capture analysis tool with advanced features
|
||||
|
||||
Baudline `http://www.baudline.com/ <http://www.baudline.com/>`__ (Can view/process HackRF data, e.g. hackrf_transfer)
|
||||
|
||||
|
||||
|
||||
HackRF Tools
|
||||
~~~~~~~~~~~~
|
||||
|
||||
In addition to third party tools that support HackRF, we provide some commandline tools for interacting with HackRF. For information on how to use each tool look at the help information provided (e.g. ``hackrf_transfer -h``) or the `manual pages <http://manpages.ubuntu.com/manpages/utopic/man1/hackrf_info.1.html>`__.
|
||||
|
||||
The first two tools (``hackrf_info`` and ``hackrf_transfer``) should cover most usage. The remaining tools are provided for debugging and general interest; beware, they have the potential to damage HackRF if used incorrectly.
|
||||
|
||||
* **hackrf_info** Read device information from HackRF such as serial number and firmware version.
|
||||
|
||||
* **hackrf_transfer** Send and receive signals using HackRF. Input/output can be 8bit signed quadrature files or wav files.
|
||||
|
||||
* **hackrf_max2837** Read and write registers in the Maxim 2837 transceiver chip. For most tx/rx purposes hackrf_transfer or other tools will take care of this for you.
|
||||
|
||||
* **hackrf_rffc5071** Read and write registers in the RFFC5071 mixer chip. As above, this is for curiosity or debugging only, most tools will take care of these settings automatically.
|
||||
|
||||
* **hackrf_si5351c** Read and write registers in the Silicon Labs Si5351C clock generator chip. This should also be unnecessary for most operation.
|
||||
|
||||
* **hackrf_spiflash** A tool to write new firmware to HackRF. This is mostly used for :ref:`Updating Firmware <updating_firmware>`.
|
||||
|
||||
* **hackrf_cpldjtag** A tool to update the CPLD on HackRF. This is needed only when :ref:`Updating Firmware <updating_firmware>` to a version prior to 2021.03.1.
|
||||
|
||||
|
||||
|
||||
Handling HackRF data
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Matlab
|
||||
^^^^^^
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
fid = open('samples.bin', 'r');
|
||||
len = 1000; % 1000 samples
|
||||
y = fread(fid, 2*len, 'int8');
|
||||
y = y(1:2:end) + 1j*y(2:2:end);
|
||||
fclose(fid)
|
40
Software/portapack-mayhem/hackrf/docs/source/tips_tricks.rst
Normal file
@@ -0,0 +1,40 @@
|
||||
================================================
|
||||
Tips and Tricks
|
||||
================================================
|
||||
|
||||
USB Cables (and why to use a noise reducing one)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The USB cable you choose can make a big difference in what you see when using your HackRF and especially when using it around between 120 and 480 MHz where USB is doing all its work.
|
||||
|
||||
#. Use a shielded USB cable. The best way to guarantee RF interference from USB is to use an unshielded cable. You can test that your cable is shielded by using a continuity tester to verify that the shield on one connector has continuity to the shield on the connector at the other end of the cable.
|
||||
|
||||
#. Use a short USB cable. Trying anything larger than a 6ft cable may yield poor results. The longer the cable, the more loss you can expect and when making this post a 15ft cable was tried and the result was the HackRF would only power up half way.
|
||||
|
||||
#. For best results, select a cable with a ferrite core. These cables are usually advertised to be noise reducing and are recognizable from the plastic block towards one end.
|
||||
|
||||
Screenshot before and after changing to a noise reducing cable (`view full size image <http://i.imgur.com/e64LASK.jpg>`__):
|
||||
|
||||
.. image:: ../images/noisereducingcablescreenshot.jpeg
|
||||
:align: center
|
||||
|
||||
A shielded cable with ferrite core was used in the right-hand image.
|
||||
|
||||
The before and after images were both taken with the preamp on and the LNA and VGA both set to 24db.
|
||||
|
||||
|
||||
|
||||
Sampling Rate and Baseband Filters
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Using a sampling rate of less than 8MHz is not recommended. Partly, this is because the MAX5864 (ADC/DAC chip) isn't specified to operate at less than 8MHz, and therefore, no promises are made by Maxim about how it performs. But more importantly, the baseband filter in the MAX2837 has a minimum bandwidth of 1.75MHz. It can't provide enough filtering at 2MHz sampling rate to remove substantial signal energy in adjacent spectrum (more than +/-1MHz from the tuned frequency). The MAX2837 datasheet suggests that at +/-1MHz, the filter provides only 4dB attenuation, and at +/-2MHz (where a signal would alias right into the center of your 2MHz spectrum), it attenuates about 33dB. That's significant. Here's a picture:
|
||||
|
||||
.. image:: ../images/max2837-1m75bw-at-2m.png
|
||||
:align: center
|
||||
|
||||
At 8MHz sampling rate, and using the minimum 1.75MHz bandwidth filter, this is the response:
|
||||
|
||||
.. image:: ../images/max2837-1m75bw-at-8m.png
|
||||
:align: center
|
||||
|
||||
You can see that the attenuation is more than 60dB at +/-2.8MHz, which is more than sufficient to remove significant adjacent spectrum interference before the ADC digitizes the baseband. If using this configuration to get a 2MHz sampling rate, use a GNU Radio block after the 8MHz source that performs a 4:1 decimation with a decently sharp low pass filter (complex filter with a cut-off of <1MHz).
|
143
Software/portapack-mayhem/hackrf/docs/source/troubleshooting.rst
Normal file
@@ -0,0 +1,143 @@
|
||||
.. _troubleshooting:
|
||||
|
||||
===============
|
||||
Troubleshooting
|
||||
===============
|
||||
|
||||
|
||||
How do I deal with the big spike in the middle of my spectrum?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Start by reading :ref:`our FAQ Response on the DC Spike <bigspike>`. After that, there are a few options:
|
||||
|
||||
#. Ignore it. For many applications it isn't a problem. You'll learn to ignore it.
|
||||
|
||||
#. Avoid it. The best way to handle DC offset for most applications is to use offset tuning; instead of tuning to your exact frequency of interest, tune to a nearby frequency so that the entire signal you are interested in is shifted away from 0 Hz but still within the received bandwidth. If your algorithm works best with your signal centered at 0 Hz (many do), you can shift the frequency in the digital domain, moving your signal of interest to 0 Hz and your DC offset away from 0 Hz. HackRF's high maximum sampling rate can be a big help as it allows you to use offset tuning even for relatively wideband signals.
|
||||
|
||||
#. Correct it. There are various ways of removing the DC offset in software. However, these techniques may degrade parts of the signal that are close to 0 Hz. It may look better, but that doesn't necessarily mean that it is better from the standpoint of a demodulator algorithm, for example. Still, correcting the DC offset is often a good choice.
|
||||
|
||||
|
||||
----
|
||||
|
||||
|
||||
How should I set the gain controls for RX?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
A good default setting to start with is RF=0 (off), IF=16, baseband=16. Increase or decrease the IF and baseband gain controls roughly equally to find the best settings for your situation. Turn on the RF amp if you need help picking up weak signals. If your gain settings are too low, your signal may be buried in the noise. If one or more of your gain settings is too high, you may see distortion (look for unexpected frequencies that pop up when you increase the gain) or the noise floor may be amplified more than your signal is.
|
||||
|
||||
|
||||
----
|
||||
|
||||
|
||||
What are the minimum system requirements for using HackRF?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
The most important requirement is that you supply 500 mA at 5 V DC to your HackRF via the USB port. If your host computer has difficulty meeting this requirement, you may need to use a powered USB hub.
|
||||
|
||||
Most users will want to stream data to or from the HackRF at high speeds. This requires that the host computer supports Hi-Speed USB. Some Hi-Speed USB hosts are better than others, and you may have multiple host controllers on your computer. If you have difficulty operating your HackRF at high sample rates (10 Msps to 20 Msps), try using a different USB port on your computer. If possible, arrange things so that the HackRF is the only device on the bus.
|
||||
|
||||
There is no specific minimum CPU requirement for the host computer, but SDR is generally a CPU-intensive application. If you have a slower CPU, you may be unable to run certain SDR software or you may only be able to operate at lower sample rates.
|
||||
|
||||
|
||||
----
|
||||
|
||||
|
||||
Why isn't HackRF working with my virtual machine (VM)?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
HackRF requires the ability to stream data at very high rates over USB. Unfortunately VM software typically has problems with continuous high speed USB transfers.
|
||||
|
||||
There are some known bugs with the HackRF firmware's USB implementation. It is possible that fixing these bugs will improve the ability to operate HackRF with a VM, but there is a very good chance that operation at higher sample rates will still be limited.
|
||||
|
||||
|
||||
----
|
||||
|
||||
|
||||
What LEDs should be illuminated on the HackRF?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
When HackRF One is plugged in to a USB host, four LEDs should turn on: 3V3, 1V8, RF, and USB. The 3V3 LED indicates that the primary internal power supply is working properly. The 1V8 and RF LEDs indicate that firmware is running and has switched on additional internal power supplies. The USB LED indicates that the HackRF One is communicating with the host over USB.
|
||||
|
||||
The RX and TX LEDs indicate that a receive or transmit operation is currently in progress.
|
||||
|
||||
|
||||
----
|
||||
|
||||
|
||||
.. _faq_hackrf_under_linux:
|
||||
|
||||
I can't seem to access my HackRF under Linux
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
If you run ``hackrf_info`` or any other command which tries to communicate with the HackRF and get one of the following error messages
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
hackrf_open() failed: HACKRF_ERROR_NOT_FOUND (-5)
|
||||
|
||||
or:
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
hackrf_open() failed: HACKRF_ERROR_LIBUSB (-1000)
|
||||
|
||||
there are a few steps you can try:
|
||||
|
||||
#. Make sure that you are running the latest version of libhackrf and hackrf-tools. HackRF One, for example, is only supported by release 2014.04.1 or newer. Try running ``hackrf_info`` again to see if the updates have addressed your issue.
|
||||
|
||||
#. Write a udev rule to instruct udev to set permissions for the device in a way that it can be accessed by any user on the system who is a member of a specific group.
|
||||
|
||||
A normal user under Linux doesn't have the permissions to access arbitrary USB devices because of security reasons. The first solution would be to run every command which tries to access the HackRF as root which is not recommended for daily usage, but at least shows you if your HackRF really works.
|
||||
|
||||
To write a udev rule, you need to create a new rules file in the ``/etc/udev/rules.d`` folder. I called mine ``52-hackrf.rules``. Here is the content:
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
ATTR{idVendor}=="1d50", ATTR{idProduct}=="604b", SYMLINK+="hackrf-jawbreaker-%k", MODE="660", GROUP="plugdev"
|
||||
ATTR{idVendor}=="1d50", ATTR{idProduct}=="6089", SYMLINK+="hackrf-one-%k", MODE="660", GROUP="plugdev"
|
||||
ATTR{idVendor}=="1fc9", ATTR{idProduct}=="000c", SYMLINK+="hackrf-dfu-%k", MODE="660", GROUP="plugdev"
|
||||
|
||||
The content of the file instructs udev to look out for devices with Vendor ID and Product ID matching HackRF devices. It then sets the UNIX permissions to ``660`` and the group to ``plugdev`` and creates a symlink in ``/dev`` to the device.
|
||||
|
||||
After creating the rules file you can either reboot or run the command ``udevadm control --reload-rules`` as root to instruct udev to reload all rule files. After replugging your HackRF board, you should be able to access the device with all utilities as a normal user. If you still can't access the device, make sure that you are a member of the plugdev group.
|
||||
|
||||
(These instructions have been tested on Ubuntu and Gentoo and may need to be adapted to other Linux distributions. In particular, your distro may have a group named something other than plugdev for this purpose.)
|
||||
|
||||
#. Disable USB autosuspend for HackRF. A common problem for laptop users could power management enabling USB autosuspend, which is likely if ``hackrf_info`` returns an error of ``hackrf_open() failed: Input/Output Error (-1000)`` on the first execution, and works if you run it a second time directly afterwards. This can be confirmed by running ``LIBUSB_DEBUG=3 hackrf_info`` and checking that the error is a ``broken pipe``. \
|
||||
|
||||
If you use the TLP power manager you can add the HackRF USB VID/PIDs to the ``USB_BLACKLIST`` line in ``/etc/default/tlp`` (under Archlinux create a file ``/etc/tlp.d/10-usb-blacklist.conf``, under Ubuntu the config file can be found at ``/etc/tlp.conf``):
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
USB_BLACKLIST="1d50:604b 1d50:6089 1d50:cc15 1fc9:000c"
|
||||
|
||||
and restart TLP using ``tlp restart`` or ``systemctl restart tlp``.
|
||||
|
||||
|
||||
----
|
||||
|
||||
|
||||
The command hackrf_info failed with "hackrf_open() .. HACKRF_ERROR_NOT_FOUND"
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
This could be a problem of a kernel driver. Some ubuntu versions, like Ubuntu 15.04 with installed gnuradio has a kernel driver pre-installed. In this case you probably will get some syslog kernel messages like:
|
||||
|
||||
* kernel: [ 8932.297074] hackrf 1-9.4:1.0: Board ID: 02
|
||||
* kernel: [ 8932.297076] hackrf 1-9.4:1.0: Firmware version: 2014.08.1
|
||||
* kernel: [ 8932.297261] hackrf 1-9.4:1.0: Registered as swradio0
|
||||
* kernel: [ 8932.297262] hackrf 1-9.4:1.0: SDR API is still slightly experimental and functionality changes may follow
|
||||
|
||||
when you plug in the the HackRF module. Use the command ``dmesg`` to check the last system log entries. If you try to start ``hackrf_info`` it will terminate with the error message and the system log will show a message like:
|
||||
|
||||
* kernel: [ 8967.263268] usb 1-9.4: usbfs: interface 0 claimed by hackrf while 'hackrf_info' sets config #1
|
||||
|
||||
To solve this issue check under root account if is there is a kernel module ``hackrf`` loaded: ``lsmod | grep hackrf``. If there is a hackrf kernel module, try to unload it with ``rmmod hackrf``. You must do this command as root, too. After this the command ``hackrf_info`` (and all other hackrf related stuff) should work and the syslog usbfs massage should vanish.
|
||||
|
||||
After a reset or USB unplug/plug this kernel module will load again and block the access again. To solve this you have to blacklist the hackrf kernel module in /etc/modprobe.d/blacklist(.conf) The current filename of the blacklist file may differ, it depends on the current ubuntu version. In ubuntu 15.04 it is located in /etc/modprobe.d/blacklist.conf. Open this file under root account with a text editor an add the following line at the end:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
blacklist hackrf
|
||||
|
||||
After a system-restart, to get the updated modprobe working, the hackrf worked under ubuntu 15.04 with the upstream packages (Firmware version: 2014.08.1) out-of-the-box.
|
@@ -0,0 +1,100 @@
|
||||
.. _updating_firmware:
|
||||
|
||||
================================================
|
||||
Updating Firmware
|
||||
================================================
|
||||
|
||||
HackRF devices ship with firmware on the SPI flash memory. The firmware can be updated with nothing more than a USB cable and host computer.
|
||||
|
||||
These instructions allow you to upgrade the firmware in order to take advantage of new features or bug fixes.
|
||||
|
||||
If you have any difficulty making this process work from your native operating system, you can :ref:`use Pentoo or the GNU Radio Live DVD <try_pentoo>` to perform the updates.
|
||||
|
||||
|
||||
|
||||
Updating the SPI Flash Firmware
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
To update the firmware on a working HackRF One, use the hackrf_spiflash program:
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
hackrf_spiflash -w hackrf_one_usb.bin
|
||||
|
||||
You can find the firmware binary (hackrf_one_usb.bin) in the firmware-bin directory of the latest `release package <https://github.com/mossmann/hackrf/releases/latest>`__ or you can compile your own from the `source <https://github.com/mossmann/hackrf/tree/master/firmware>`__. For Jawbreaker, use hackrf_jawbreaker_usb.bin. If you compile from source, the file will be called hackrf_usb.bin.
|
||||
|
||||
The hackrf_spiflash program is part of hackrf-tools.
|
||||
|
||||
When writing a firmware image to SPI flash, be sure to select firmware with a filename ending in ".bin".
|
||||
|
||||
After writing the firmware to SPI flash, you may need to reset the HackRF device by pressing the RESET button or by unplugging it and plugging it back in.
|
||||
|
||||
If you get an error that mentions HACKRF_ERROR_NOT_FOUND, check out the :ref:`FAQ <faq_hackrf_under_linux>`. It's often a permissions problem that can be quickly solved.
|
||||
|
||||
|
||||
|
||||
Updating the CPLD
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
Older versions of HackRF firmware (prior to release 2021.03.1) require an additional step to program a bitstream into the CPLD.
|
||||
|
||||
To update the CPLD image, first update the SPI flash firmware, libhackrf, and hackrf-tools to the version you are installing. Then:
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
hackrf_cpldjtag -x firmware/cpld/sgpio_if/default.xsvf
|
||||
|
||||
After a few seconds, three LEDs should start blinking. This indicates that the CPLD has been programmed successfully. Reset the HackRF device by pressing the RESET button or by unplugging it and plugging it back in.
|
||||
|
||||
|
||||
|
||||
Only if Necessary: DFU Boot
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
DFU boot mode is normally only needed if the firmware is not working properly or has never been installed.
|
||||
|
||||
The LPC4330 microcontroller on HackRF is capable of booting from several different code sources. By default, HackRF boots from SPI flash memory (SPIFI). It can also boot HackRF in DFU (USB) boot mode. In DFU boot mode, HackRF will enumerate over USB, wait for code to be delivered using the DFU (Device Firmware Update) standard over USB, and then execute that code from RAM. The SPIFI is normally unused and unaltered in DFU mode.
|
||||
|
||||
To start up HackRF One in DFU mode, hold down the DFU button while powering it on or while pressing and releasing the RESET button. Release the DFU button after the 3V3 LED illuminates. The 1V8 LED should remain off. At this point HackRF One is ready to receive firmware over USB.
|
||||
|
||||
To start up Jawbreaker in DFU mode, short two pins on one of the "BOOT" headers while power is first supplied. The pins that must be shorted are pins 1 and 2 of header P32 on Jawbreaker. Header P32 is labeled "P2_8" on most Jawbreakers but may be labeled "2" on prototype units. Pin 1 is labeled "VCC". Pin 2 is the center pin. After DFU boot, you should see VCCLED illuminate and note that 1V8LED does not illuminate. At this point Jawbreaker is ready to receive firmware over USB.
|
||||
|
||||
You should only use a firmware image with a filename ending in ".dfu" over DFU, not firmware ending in ".bin".
|
||||
|
||||
|
||||
|
||||
Only if Necessary: Recovering the SPI Flash Firmware
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
If the firmware installed in SPI flash has been damaged or if you are programming a home-made HackRF for the first time, you will not be able to immediately use the hackrf_spiflash program as listed in the above procedure. Follow these steps instead:
|
||||
|
||||
#. Follow the DFU Boot instructions to start the HackRF in DFU boot mode.
|
||||
#. Type ``dfu-util --device 1fc9:000c --alt 0 --download hackrf_one_usb.dfu`` to load firmware from a release package into RAM. If you have a Jawbreaker, use hackrf_jawbreaker_usb.dfu instead. Alternatively, use ``make -e BOARD=HACKRF_ONE RUN_FROM=RAM program`` to load the firmware into RAM and start it.
|
||||
#. Follow the SPI flash firmware update procedure above to write the ".bin" firmware image to SPI flash.
|
||||
|
||||
|
||||
|
||||
Obtaining DFU-Util
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
On fresh installs of your OS, you may need obtain a copy of DFU-Util. For most Linux distributions it should be available as a package, for example on Debian/Ubuntu
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
sudo apt-get install dfu-util
|
||||
|
||||
If you are using a platform without a dfu-util package, build instruction can be found `here on the dfu-util source forge build page <http://dfu-util.sourceforge.net/build.html>`__.
|
||||
|
||||
.. code-block :: sh
|
||||
|
||||
cd ~
|
||||
sudo apt-get build-dep dfu-util
|
||||
sudo apt-get install libusb-1.0-0-dev
|
||||
git clone git://git.code.sf.net/p/dfu-util/dfu-util
|
||||
cd dfu-util
|
||||
./autogen.sh
|
||||
./configure
|
||||
make
|
||||
sudo make install
|
||||
|
||||
Now you will have the current version of DFU Util installed on your system.
|
9
Software/portapack-mayhem/hackrf/firmware/.gitignore
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
*.bin
|
||||
*.d
|
||||
*.elf
|
||||
*.hex
|
||||
*.list
|
||||
*.map
|
||||
*.o
|
||||
*.srec
|
||||
*.dfu
|
29
Software/portapack-mayhem/hackrf/firmware/CMakeLists.txt
Normal file
@@ -0,0 +1,29 @@
|
||||
# Copyright 2012 Jared Boone <jared@sharebrained.com>
|
||||
#
|
||||
# This file is part of HackRF.
|
||||
#
|
||||
# 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; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
# Top directory CMake project for HackRF firmware
|
||||
|
||||
cmake_minimum_required(VERSION 3.1.3)
|
||||
set(CMAKE_TOOLCHAIN_FILE toolchain-arm-cortex-m.cmake)
|
||||
|
||||
project (hackrf_firmware_all C)
|
||||
|
||||
add_subdirectory(blinky)
|
||||
add_subdirectory(hackrf_usb)
|
50
Software/portapack-mayhem/hackrf/firmware/README
Normal file
@@ -0,0 +1,50 @@
|
||||
The primary firmware source code for USB HackRF devices is hackrf_usb. Most of
|
||||
the other directories contain firmware source code for test and development.
|
||||
The common directory contains source code shared by multiple HackRF firmware
|
||||
projects. The cpld directory contains HDL source for the CPLD.
|
||||
|
||||
|
||||
The firmware is set up for compilation with the GCC toolchain available here:
|
||||
|
||||
https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
|
||||
|
||||
Required dependency:
|
||||
|
||||
https://github.com/mossmann/libopencm3
|
||||
|
||||
If you are using git, the preferred way to install libopencm3 is to use the
|
||||
submodule:
|
||||
|
||||
$ cd ..
|
||||
$ git submodule init
|
||||
$ git submodule update
|
||||
|
||||
To build and install a standard firmware image for HackRF One:
|
||||
|
||||
$ cd hackrf_usb
|
||||
$ mkdir build
|
||||
$ cd build
|
||||
$ cmake ..
|
||||
$ make
|
||||
$ hackrf_spiflash -w hackrf_usb.bin
|
||||
|
||||
If you have a Jawbreaker, add -DBOARD=JAWBREAKER to the cmake command.
|
||||
If you have a rad1o, use -DBOARD=RAD1O instead.
|
||||
|
||||
It is possible to use a USB Device Firmware Upgrade (DFU) method to load
|
||||
firmware into RAM. This is normally only required to recover a device that has
|
||||
had faulty firmware loaded, but it can also be useful for firmware developers.
|
||||
|
||||
For loading firmware into RAM with DFU you will need:
|
||||
|
||||
http://dfu-util.sourceforge.net/
|
||||
|
||||
To start up HackRF One in DFU mode, hold down the DFU button while powering it
|
||||
on or while pressing and releasing the RESET button. Release the DFU button
|
||||
after the 3V3 LED illuminates.
|
||||
|
||||
A .dfu file is built by default when building firmware. Alternatively you can
|
||||
use a known good .dfu file from a release package. Load the firmware into RAM
|
||||
with:
|
||||
|
||||
$ dfu-util --device 1fc9:000c --alt 0 --download hackrf_usb.dfu
|
14
Software/portapack-mayhem/hackrf/firmware/appveyor.sh
Normal file
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
/usr/bin/env python -m ensurepip
|
||||
/usr/bin/env python -m pip install pyyaml
|
||||
|
||||
cd firmware/libopencm3
|
||||
export SRCLIBDIR='c:\projects\hackrf\firmware\libopencm3\lib\'
|
||||
make lib/lpc43xx/m0
|
||||
make lib/lpc43xx/m4
|
||||
cd ..
|
||||
mkdir build-hackrf-one
|
||||
cd build-hackrf-one
|
||||
cmake -G "Unix Makefiles" ..
|
||||
make VERBOSE=1
|
@@ -0,0 +1,33 @@
|
||||
# Copyright 2012 Michael Ossmann <mike@ossmann.com>
|
||||
# Copyright 2012 Jared Boone <jared@sharebrained.com>
|
||||
#
|
||||
# This file is part of HackRF.
|
||||
#
|
||||
# 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; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
cmake_minimum_required(VERSION 3.1.3)
|
||||
set(CMAKE_TOOLCHAIN_FILE ../toolchain-arm-cortex-m.cmake)
|
||||
|
||||
project(blinky C)
|
||||
|
||||
include(../hackrf-common.cmake)
|
||||
|
||||
set(SRC_M4
|
||||
blinky.c
|
||||
)
|
||||
|
||||
DeclareTargets()
|
1
Software/portapack-mayhem/hackrf/firmware/blinky/README
Normal file
@@ -0,0 +1 @@
|
||||
This is the simplest example firmware for HackRF. It flashes three LEDs.
|
48
Software/portapack-mayhem/hackrf/firmware/blinky/blinky.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2010 - 2012 Michael Ossmann
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "hackrf_core.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
pin_setup();
|
||||
|
||||
/* enable all power supplies */
|
||||
enable_1v8_power();
|
||||
|
||||
/* Blink LED1/2/3 on the board. */
|
||||
while (1)
|
||||
{
|
||||
led_on(LED1);
|
||||
led_on(LED2);
|
||||
led_on(LED3);
|
||||
|
||||
delay(2000000);
|
||||
|
||||
led_off(LED1);
|
||||
led_off(LED2);
|
||||
led_off(LED3);
|
||||
|
||||
delay(2000000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2012 Michael Ossmann <mike@ossmann.com>
|
||||
* Copyright 2012 Jared Boone <jared@sharebrained.com>
|
||||
*
|
||||
* This file is part of HackRF
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/* Linker script for HackRF One (LPC4320, 1M SPI flash, 200K SRAM). */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
/* rom is really the shadow region that points to SPI flash or elsewhere */
|
||||
rom (rx) : ORIGIN = 0x00000000, LENGTH = 96K
|
||||
ram_local1 (rwx) : ORIGIN = 0x10000000, LENGTH = 96K
|
||||
ram_local2 (rwx) : ORIGIN = 0x10080000, LENGTH = 32K
|
||||
ram_sleep (rwx) : ORIGIN = 0x10088000, LENGTH = 8K
|
||||
}
|
||||
|
||||
INCLUDE LPC43xx_M4_memory.ld
|
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2012 Michael Ossmann <mike@ossmann.com>
|
||||
* Copyright 2012 Jared Boone <jared@sharebrained.com>
|
||||
*
|
||||
* This file is part of HackRF
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
/* Linker script for Rad1o badge - (LPC4330, 1M SPI flash, 264K SRAM). */
|
||||
|
||||
MEMORY
|
||||
{
|
||||
/* rom is really the shadow region that points to SPI flash or elsewhere */
|
||||
rom (rx) : ORIGIN = 0x00000000, LENGTH = 128K
|
||||
ram_local1 (rwx) : ORIGIN = 0x10000000, LENGTH = 128K
|
||||
ram_local2 (rwx) : ORIGIN = 0x10080000, LENGTH = 64K
|
||||
ram_sleep (rwx) : ORIGIN = 0x10090000, LENGTH = 8K
|
||||
}
|
||||
|
||||
INCLUDE LPC43xx_M4_memory.ld
|
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2012 Michael Ossmann <mike@ossmann.com>
|
||||
* Copyright 2012 Jared Boone <jared@sharebrained.com>
|
||||
*
|
||||
* This file is part of HackRF
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
ram (rwx) : ORIGIN = 0x00000000, LENGTH = 28K
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2012 Michael Ossmann <mike@ossmann.com>
|
||||
* Copyright 2012 Jared Boone <jared@sharebrained.com>
|
||||
*
|
||||
* This file is part of HackRF
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.m0_text : {
|
||||
PROVIDE(__m0_start__ = .);
|
||||
KEEP(*(.m0_bin*));
|
||||
. = ALIGN(4);
|
||||
PROVIDE(__m0_end__ = .);
|
||||
} >rom
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2012 Michael Ossmann <mike@ossmann.com>
|
||||
* Copyright 2012 Jared Boone <jared@sharebrained.com>
|
||||
*
|
||||
* This file is part of HackRF
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
MEMORY
|
||||
{
|
||||
/* Physical address in Flash used to copy Code from Flash to RAM */
|
||||
rom_flash (rx) : ORIGIN = 0x80000000, LENGTH = 1M
|
||||
ram_m0 (rwx) : ORIGIN = 0x20000000, LENGTH = 28K
|
||||
ram_shared (rwx) : ORIGIN = 0x20007000, LENGTH = 4K
|
||||
ram_usb (rwx) : ORIGIN = 0x20008000, LENGTH = 32K
|
||||
/* ram_usb: USB buffer. Straddles two blocks of RAM
|
||||
* to get performance benefit of having two USB buffers addressable
|
||||
* simultaneously (on two different buses of the AHB multilayer matrix)
|
||||
*/
|
||||
}
|
||||
|
||||
usb_bulk_buffer = ORIGIN(ram_usb);
|
||||
m0_state = ORIGIN(ram_shared);
|
||||
PROVIDE(__ram_m0_start__ = ORIGIN(ram_m0));
|
2
Software/portapack-mayhem/hackrf/firmware/common/README
Normal file
@@ -0,0 +1,2 @@
|
||||
This directory contains things shared by multiple HackRF firmware
|
||||
implementations.
|
45
Software/portapack-mayhem/hackrf/firmware/common/bitband.c
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone <jared@sharebrained.com>
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "bitband.h"
|
||||
|
||||
volatile uint32_t* peripheral_bitband_address(volatile void* const address, const uint_fast8_t bit_number) {
|
||||
const uint32_t bit_band_base = 0x42000000;
|
||||
const uint32_t byte_offset = (uint32_t)address - 0x40000000;
|
||||
const uint32_t bit_word_offset = (byte_offset * 32) + (bit_number * 4);
|
||||
const uint32_t bit_word_address = bit_band_base + bit_word_offset;
|
||||
return (volatile uint32_t*)bit_word_address;
|
||||
}
|
||||
|
||||
void peripheral_bitband_set(volatile void* const peripheral_address, const uint_fast8_t bit_number) {
|
||||
volatile uint32_t* const bitband_address = peripheral_bitband_address(peripheral_address, bit_number);
|
||||
*bitband_address = 1;
|
||||
}
|
||||
|
||||
void peripheral_bitband_clear(volatile void* const peripheral_address, const uint_fast8_t bit_number) {
|
||||
volatile uint32_t* const bitband_address = peripheral_bitband_address(peripheral_address, bit_number);
|
||||
*bitband_address = 0;
|
||||
}
|
||||
|
||||
uint32_t peripheral_bitband_get(volatile void* const peripheral_address, const uint_fast8_t bit_number) {
|
||||
volatile uint32_t* const bitband_address = peripheral_bitband_address(peripheral_address, bit_number);
|
||||
return *bitband_address;
|
||||
}
|
32
Software/portapack-mayhem/hackrf/firmware/common/bitband.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone <jared@sharebrained.com>
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __BITBAND_H__
|
||||
#define __BITBAND_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
volatile uint32_t* peripheral_bitband_address(volatile void* const address, const uint_fast8_t bit_number);
|
||||
void peripheral_bitband_set(volatile void* const peripheral_address, const uint_fast8_t bit_number);
|
||||
void peripheral_bitband_clear(volatile void* const peripheral_address, const uint_fast8_t bit_number);
|
||||
uint32_t peripheral_bitband_get(volatile void* const peripheral_address, const uint_fast8_t bit_number);
|
||||
|
||||
#endif//__BITBAND_H__
|
@@ -0,0 +1,4 @@
|
||||
configure_file(
|
||||
${SRC}
|
||||
${DEST}
|
||||
)
|
101
Software/portapack-mayhem/hackrf/firmware/common/cpld_jtag.c
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright 2013 Michael Ossmann <mike@ossmann.com>
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "cpld_jtag.h"
|
||||
#include "hackrf_core.h"
|
||||
#include "xapp058/micro.h"
|
||||
#include <libopencm3/lpc43xx/scu.h>
|
||||
#include <stdint.h>
|
||||
|
||||
static refill_buffer_cb refill_buffer;
|
||||
static uint32_t xsvf_buffer_len, xsvf_pos;
|
||||
static unsigned char* xsvf_buffer;
|
||||
|
||||
void cpld_jtag_take(jtag_t* const jtag) {
|
||||
const jtag_gpio_t* const gpio = jtag->gpio;
|
||||
|
||||
/* Set initial GPIO state to the voltages of the internal or external pull-ups/downs,
|
||||
* to avoid any glitches.
|
||||
*/
|
||||
#ifdef HACKRF_ONE
|
||||
gpio_set(gpio->gpio_pp_tms);
|
||||
#endif
|
||||
gpio_set(gpio->gpio_tms);
|
||||
gpio_set(gpio->gpio_tdi);
|
||||
gpio_clear(gpio->gpio_tck);
|
||||
|
||||
#ifdef HACKRF_ONE
|
||||
/* Do not drive PortaPack-specific TMS pin initially, just to be cautious. */
|
||||
gpio_input(gpio->gpio_pp_tms);
|
||||
gpio_input(gpio->gpio_pp_tdo);
|
||||
#endif
|
||||
gpio_output(gpio->gpio_tms);
|
||||
gpio_output(gpio->gpio_tdi);
|
||||
gpio_output(gpio->gpio_tck);
|
||||
gpio_input(gpio->gpio_tdo);
|
||||
}
|
||||
|
||||
void cpld_jtag_release(jtag_t* const jtag) {
|
||||
const jtag_gpio_t* const gpio = jtag->gpio;
|
||||
|
||||
/* Make all pins inputs when JTAG interface not active.
|
||||
* Let the pull-ups/downs do the work.
|
||||
*/
|
||||
#ifdef HACKRF_ONE
|
||||
/* Do not drive PortaPack-specific pins, initially, just to be cautious. */
|
||||
gpio_input(gpio->gpio_pp_tms);
|
||||
gpio_input(gpio->gpio_pp_tdo);
|
||||
#endif
|
||||
gpio_input(gpio->gpio_tms);
|
||||
gpio_input(gpio->gpio_tdi);
|
||||
gpio_input(gpio->gpio_tck);
|
||||
gpio_input(gpio->gpio_tdo);
|
||||
}
|
||||
|
||||
/* return 0 if success else return error code see xsvfExecute() */
|
||||
int cpld_jtag_program(
|
||||
jtag_t* const jtag,
|
||||
const uint32_t buffer_length,
|
||||
unsigned char* const buffer,
|
||||
refill_buffer_cb refill
|
||||
) {
|
||||
int error;
|
||||
cpld_jtag_take(jtag);
|
||||
xsvf_buffer = buffer;
|
||||
xsvf_buffer_len = buffer_length;
|
||||
refill_buffer = refill;
|
||||
error = xsvfExecute(jtag->gpio);
|
||||
cpld_jtag_release(jtag);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/* this gets called by the XAPP058 code */
|
||||
unsigned char cpld_jtag_get_next_byte(void) {
|
||||
if (xsvf_pos == xsvf_buffer_len) {
|
||||
refill_buffer();
|
||||
xsvf_pos = 0;
|
||||
}
|
||||
|
||||
unsigned char byte = xsvf_buffer[xsvf_pos];
|
||||
xsvf_pos++;
|
||||
return byte;
|
||||
}
|
62
Software/portapack-mayhem/hackrf/firmware/common/cpld_jtag.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2013 Michael Ossmann <mike@ossmann.com>
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CPLD_JTAG_H__
|
||||
#define __CPLD_JTAG_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "gpio.h"
|
||||
|
||||
typedef struct jtag_gpio_t {
|
||||
gpio_t gpio_tms;
|
||||
gpio_t gpio_tck;
|
||||
gpio_t gpio_tdi;
|
||||
gpio_t gpio_tdo;
|
||||
#ifdef HACKRF_ONE
|
||||
gpio_t gpio_pp_tms;
|
||||
gpio_t gpio_pp_tdo;
|
||||
#endif
|
||||
} jtag_gpio_t;
|
||||
|
||||
typedef struct jtag_t {
|
||||
jtag_gpio_t* const gpio;
|
||||
} jtag_t;
|
||||
|
||||
typedef void (*refill_buffer_cb)(void);
|
||||
|
||||
void cpld_jtag_take(jtag_t* const jtag);
|
||||
void cpld_jtag_release(jtag_t* const jtag);
|
||||
|
||||
/* Return 0 if success else return error code see xsvfExecute() see micro.h.
|
||||
*
|
||||
* We expect the buffer to be initially full of data. After the entire
|
||||
* contents of the buffer has been streamed to the CPLD the given
|
||||
* refill_buffer callback will be called. */
|
||||
int cpld_jtag_program(
|
||||
jtag_t* const jtag,
|
||||
const uint32_t buffer_length,
|
||||
unsigned char* const buffer,
|
||||
refill_buffer_cb refill
|
||||
);
|
||||
unsigned char cpld_jtag_get_next_byte(void);
|
||||
|
||||
#endif//__CPLD_JTAG_H__
|
418
Software/portapack-mayhem/hackrf/firmware/common/cpld_xc2c.c
Normal file
@@ -0,0 +1,418 @@
|
||||
/*
|
||||
* Copyright 2019 Jared Boone <jared@sharebrained.com>
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "cpld_xc2c.h"
|
||||
|
||||
#include "crc.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef enum {
|
||||
CPLD_XC2C_IR_INTEST = 0b00000010,
|
||||
CPLD_XC2C_IR_BYPASS = 0b11111111,
|
||||
CPLD_XC2C_IR_SAMPLE = 0b00000011,
|
||||
CPLD_XC2C_IR_EXTEST = 0b00000000,
|
||||
CPLD_XC2C_IR_IDCODE = 0b00000001,
|
||||
CPLD_XC2C_IR_USERCODE = 0b11111101,
|
||||
CPLD_XC2C_IR_HIGHZ = 0b11111100,
|
||||
CPLD_XC2C_IR_ISC_ENABLE_CLAMP = 0b11101001,
|
||||
CPLD_XC2C_IR_ISC_ENABLE_OTF = 0b11100100,
|
||||
CPLD_XC2C_IR_ISC_ENABLE = 0b11101000,
|
||||
CPLD_XC2C_IR_ISC_SRAM_READ = 0b11100111,
|
||||
CPLD_XC2C_IR_ISC_WRITE = 0b11100110,
|
||||
CPLD_XC2C_IR_ISC_ERASE = 0b11101101,
|
||||
CPLD_XC2C_IR_ISC_PROGRAM = 0b11101010,
|
||||
CPLD_XC2C_IR_ISC_READ = 0b11101110,
|
||||
CPLD_XC2C_IR_ISC_INIT = 0b11110000,
|
||||
CPLD_XC2C_IR_ISC_DISABLE = 0b11000000,
|
||||
CPLD_XC2C_IR_TEST_ENABLE = 0b00010001,
|
||||
CPLD_XC2C_IR_BULKPROG = 0b00010010,
|
||||
CPLD_XC2C_IR_ERASE_ALL = 0b00010100,
|
||||
CPLD_XC2C_IR_MVERIFY = 0b00010011,
|
||||
CPLD_XC2C_IR_TEST_DISABLE = 0b00010101,
|
||||
CPLD_XC2C_IR_STCTEST = 0b00010110,
|
||||
CPLD_XC2C_IR_ISC_NOOP = 0b11100000,
|
||||
} cpld_xc2c_ir_t;
|
||||
|
||||
static bool cpld_xc2c_jtag_clock(const jtag_t* const jtag, const uint32_t tms, const uint32_t tdi) {
|
||||
// 8 ns TMS/TDI to TCK setup
|
||||
gpio_write(jtag->gpio->gpio_tdi, tdi);
|
||||
gpio_write(jtag->gpio->gpio_tms, tms);
|
||||
|
||||
// 20 ns TCK high time
|
||||
__asm__("nop");
|
||||
__asm__("nop");
|
||||
__asm__("nop");
|
||||
__asm__("nop");
|
||||
__asm__("nop");
|
||||
|
||||
gpio_clear(jtag->gpio->gpio_tck);
|
||||
|
||||
// 25 ns TCK falling edge to TDO valid
|
||||
// 20 ns TCK low time
|
||||
__asm__("nop");
|
||||
__asm__("nop");
|
||||
__asm__("nop");
|
||||
__asm__("nop");
|
||||
__asm__("nop");
|
||||
__asm__("nop");
|
||||
__asm__("nop");
|
||||
|
||||
gpio_set(jtag->gpio->gpio_tck);
|
||||
|
||||
// 15 ns TCK to TMS/TDI hold time
|
||||
__asm__("nop");
|
||||
__asm__("nop");
|
||||
__asm__("nop");
|
||||
__asm__("nop");
|
||||
|
||||
return gpio_read(jtag->gpio->gpio_tdo);
|
||||
}
|
||||
|
||||
static void cpld_xc2c_jtag_shift_ptr_tms(const jtag_t* const jtag, uint8_t* const tdi_tdo, const size_t start, const size_t end, const bool tms) {
|
||||
for(size_t i=start; i<end; i++) {
|
||||
const size_t byte_n = i >> 3;
|
||||
const size_t bit_n = i & 7;
|
||||
const uint32_t mask = (1U << bit_n);
|
||||
|
||||
const uint32_t tdo = cpld_xc2c_jtag_clock(jtag, tms, tdi_tdo[byte_n] & mask) ? 1 : 0;
|
||||
|
||||
tdi_tdo[byte_n] &= ~mask;
|
||||
tdi_tdo[byte_n] |= (tdo << bit_n);
|
||||
}
|
||||
}
|
||||
|
||||
static void cpld_xc2c_jtag_shift_ptr(const jtag_t* const jtag, uint8_t* const tdi_tdo, const size_t count) {
|
||||
if( count > 0 ) {
|
||||
cpld_xc2c_jtag_shift_ptr_tms(jtag, tdi_tdo, 0, count - 1, false);
|
||||
cpld_xc2c_jtag_shift_ptr_tms(jtag, tdi_tdo, count - 1, count, true);
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t cpld_xc2c_jtag_shift_u32(const jtag_t* const jtag, const uint32_t tms, const uint32_t tdi, const size_t count) {
|
||||
uint32_t tdo = 0;
|
||||
|
||||
for(size_t i=0; i<count; i++) {
|
||||
const uint32_t mask = (1U << i);
|
||||
tdo |= cpld_xc2c_jtag_clock(jtag, tms & mask, tdi & mask) << i;
|
||||
}
|
||||
|
||||
return tdo;
|
||||
}
|
||||
|
||||
static void cpld_xc2c_jtag_clocks(const jtag_t* const jtag, const size_t count) {
|
||||
for(size_t i=0; i<count; i++) {
|
||||
cpld_xc2c_jtag_clock(jtag, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void cpld_xc2c_jtag_pause(const jtag_t* const jtag, const size_t count) {
|
||||
for(size_t i=0; i<count; i++) {
|
||||
cpld_xc2c_jtag_clock(jtag, (i == (count - 1)), 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void cpld_xc2c_jtag_shift_dr_ir(const jtag_t* const jtag, uint8_t* const tdi_tdo, const size_t bit_count, const size_t pause_count) {
|
||||
/* Run-Test/Idle or Select-DR-Scan -> Shift-DR or Shift-IR */
|
||||
cpld_xc2c_jtag_shift_u32(jtag, 0b001, 0b000, 3);
|
||||
/* Shift-[DI]R -> Exit1-[DI]R */
|
||||
cpld_xc2c_jtag_shift_ptr(jtag, tdi_tdo, bit_count);
|
||||
if( pause_count ) {
|
||||
/* Exit1-[DI]R -> Pause-[DI]R */
|
||||
cpld_xc2c_jtag_shift_u32(jtag, 0b0, 0, 1);
|
||||
/* Pause-[DI]R -> Exit2-[DI]R */
|
||||
cpld_xc2c_jtag_pause(jtag, pause_count);
|
||||
}
|
||||
/* Exit1-[DI]R or Exit2-[DI]R -> Run-Test/Idle */
|
||||
cpld_xc2c_jtag_shift_u32(jtag, 0b01, 0, 2);
|
||||
}
|
||||
|
||||
static void cpld_xc2c_jtag_shift_dr(const jtag_t* const jtag, uint8_t* const tdi_tdo, const size_t bit_count, const size_t pause_count) {
|
||||
cpld_xc2c_jtag_shift_dr_ir(jtag, tdi_tdo, bit_count, pause_count);
|
||||
}
|
||||
|
||||
static uint8_t cpld_xc2c_jtag_shift_ir_pause(const jtag_t* const jtag, const cpld_xc2c_ir_t ir, const size_t pause_count) {
|
||||
/* Run-Test/Idle -> Select-DR-Scan */
|
||||
cpld_xc2c_jtag_shift_u32(jtag, 0b1, 0b0, 1);
|
||||
uint8_t value = ir;
|
||||
cpld_xc2c_jtag_shift_dr_ir(jtag, &value, 8, pause_count);
|
||||
return value;
|
||||
}
|
||||
|
||||
static uint8_t cpld_xc2c_jtag_shift_ir(const jtag_t* const jtag, const cpld_xc2c_ir_t ir) {
|
||||
return cpld_xc2c_jtag_shift_ir_pause(jtag, ir, 0);
|
||||
}
|
||||
|
||||
static void cpld_xc2c_jtag_reset(const jtag_t* const jtag) {
|
||||
/* Five TMS=1 to reach Test-Logic-Reset from any point in the TAP state diagram.
|
||||
*/
|
||||
cpld_xc2c_jtag_shift_u32(jtag, 0b11111, 0, 5);
|
||||
}
|
||||
|
||||
static void cpld_xc2c_jtag_reset_and_idle(const jtag_t* const jtag) {
|
||||
/* Five TMS=1 to reach Test-Logic-Reset from any point in the TAP state diagram.
|
||||
* One TMS=0 to move from Test-Logic-Reset to Run-Test-Idle.
|
||||
*/
|
||||
cpld_xc2c_jtag_reset(jtag);
|
||||
cpld_xc2c_jtag_shift_u32(jtag, 0, 0, 1);
|
||||
}
|
||||
|
||||
static uint32_t cpld_xc2c_jtag_idcode(const jtag_t* const jtag) {
|
||||
/* Enter and end at Run-Test-Idle state. */
|
||||
cpld_xc2c_jtag_shift_ir(jtag, CPLD_XC2C_IR_IDCODE);
|
||||
uint32_t result = 0;
|
||||
cpld_xc2c_jtag_shift_dr(jtag, (uint8_t*)&result, 32, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool cpld_xc2c64a_jtag_idcode_ok(const jtag_t* const jtag) {
|
||||
return ((cpld_xc2c_jtag_idcode(jtag) ^ 0xf6e5f093) & 0x0fff8fff) == 0;
|
||||
}
|
||||
|
||||
static void cpld_xc2c_jtag_conld(const jtag_t* const jtag) {
|
||||
cpld_xc2c_jtag_shift_ir(jtag, CPLD_XC2C_IR_ISC_DISABLE);
|
||||
cpld_xc2c_jtag_clocks(jtag, 100);
|
||||
}
|
||||
|
||||
static void cpld_xc2c_jtag_enable(const jtag_t* const jtag) {
|
||||
cpld_xc2c_jtag_shift_ir(jtag, CPLD_XC2C_IR_ISC_ENABLE);
|
||||
cpld_xc2c_jtag_clocks(jtag, 800);
|
||||
}
|
||||
|
||||
static void cpld_xc2c_jtag_disable(const jtag_t* const jtag) {
|
||||
cpld_xc2c_jtag_shift_ir(jtag, CPLD_XC2C_IR_ISC_DISABLE);
|
||||
cpld_xc2c_jtag_clocks(jtag, 100);
|
||||
}
|
||||
|
||||
static void cpld_xc2c_jtag_sram_write(const jtag_t* const jtag) {
|
||||
cpld_xc2c_jtag_shift_ir(jtag, CPLD_XC2C_IR_ISC_WRITE);
|
||||
}
|
||||
|
||||
static void cpld_xc2c_jtag_sram_read(const jtag_t* const jtag) {
|
||||
cpld_xc2c_jtag_shift_ir(jtag, CPLD_XC2C_IR_ISC_SRAM_READ);
|
||||
}
|
||||
|
||||
static uint32_t cpld_xc2c_jtag_bypass(const jtag_t* const jtag, const bool shift_dr) {
|
||||
const uint8_t result = cpld_xc2c_jtag_shift_ir(jtag, CPLD_XC2C_IR_BYPASS);
|
||||
if( shift_dr ) {
|
||||
uint8_t dr = 0;
|
||||
cpld_xc2c_jtag_shift_dr(jtag, &dr, 1, 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool cpld_xc2c_jtag_read_write_protect(const jtag_t* const jtag) {
|
||||
/* Enter and end at Run-Test-Idle state. */
|
||||
return ((cpld_xc2c_jtag_bypass(jtag, false) ^ 0x01) & 0x03) == 0;
|
||||
}
|
||||
|
||||
static bool cpld_xc2c_jtag_is_done(const jtag_t* const jtag) {
|
||||
return ((cpld_xc2c_jtag_bypass(jtag, false) ^ 0x05) & 0x07) == 0;
|
||||
}
|
||||
|
||||
static void cpld_xc2c_jtag_init_special(const jtag_t* const jtag) {
|
||||
cpld_xc2c_jtag_shift_ir(jtag, CPLD_XC2C_IR_ISC_INIT);
|
||||
cpld_xc2c_jtag_clocks(jtag, 20);
|
||||
/* Run-Test/Idle -> Shift-IR */
|
||||
cpld_xc2c_jtag_shift_u32(jtag, 0b0011, 0b0000, 4);
|
||||
/* Shift-IR: 0xf0 -> Exit1-IR */
|
||||
cpld_xc2c_jtag_shift_u32(jtag, 0x80, CPLD_XC2C_IR_ISC_INIT, 8);
|
||||
/* Exit1-IR -> Pause-IR */
|
||||
cpld_xc2c_jtag_shift_u32(jtag, 0b0, 0, 1);
|
||||
/* Pause-IR -> Exit2-IR -> Update-IR -> Select-DR-Scan -> Capture-DR -> Exit1-DR -> Update-DR -> Run-Test/Idle */
|
||||
cpld_xc2c_jtag_shift_u32(jtag, 0b0110111, 0, 7);
|
||||
cpld_xc2c_jtag_clocks(jtag, 800);
|
||||
}
|
||||
|
||||
static void cpld_xc2c_jtag_read(const jtag_t* const jtag) {
|
||||
cpld_xc2c_jtag_shift_ir_pause(jtag, CPLD_XC2C_IR_ISC_READ, 1);
|
||||
}
|
||||
|
||||
static void cpld_xc2c64a_jtag_read_row(const jtag_t* const jtag, uint8_t address, uint8_t* const dr) {
|
||||
cpld_xc2c_jtag_shift_dr(jtag, &address, 7, 20);
|
||||
cpld_xc2c_jtag_clocks(jtag, 100);
|
||||
|
||||
/* Set array to all ones so we don't transmit memory contents over TDI, and if we're not
|
||||
* reading a full byte's worth of bits, the excess bits will be zero.
|
||||
*/
|
||||
memset(dr, 0xff, CPLD_XC2C64A_BYTES_IN_ROW);
|
||||
cpld_xc2c_jtag_shift_dr(jtag, dr, CPLD_XC2C64A_BITS_IN_ROW, 0);
|
||||
cpld_xc2c_jtag_clocks(jtag, 100);
|
||||
}
|
||||
|
||||
bool cpld_xc2c64a_jtag_checksum(
|
||||
const jtag_t* const jtag,
|
||||
const cpld_xc2c64a_verify_t* const verify,
|
||||
uint32_t* const crc_value
|
||||
) {
|
||||
cpld_xc2c_jtag_reset_and_idle(jtag);
|
||||
|
||||
if( cpld_xc2c64a_jtag_idcode_ok(jtag) && cpld_xc2c_jtag_read_write_protect(jtag) &&
|
||||
cpld_xc2c64a_jtag_idcode_ok(jtag) && cpld_xc2c_jtag_read_write_protect(jtag) ) {
|
||||
|
||||
cpld_xc2c_jtag_bypass(jtag, false);
|
||||
|
||||
cpld_xc2c_jtag_enable(jtag);
|
||||
cpld_xc2c_jtag_enable(jtag);
|
||||
cpld_xc2c_jtag_enable(jtag);
|
||||
|
||||
cpld_xc2c_jtag_read(jtag);
|
||||
|
||||
crc32_t crc;
|
||||
crc32_init(&crc);
|
||||
|
||||
uint8_t dr[CPLD_XC2C64A_BYTES_IN_ROW];
|
||||
for(size_t row=0; row<CPLD_XC2C64A_ROWS; row++) {
|
||||
const size_t address = cpld_hackrf_row_addresses.address[row];
|
||||
cpld_xc2c64a_jtag_read_row(jtag, address, dr);
|
||||
|
||||
const size_t mask_index = verify->mask_index[row];
|
||||
for(size_t i=0; i<CPLD_XC2C64A_BYTES_IN_ROW; i++) {
|
||||
dr[i] &= verify->mask[mask_index].value[i];
|
||||
}
|
||||
|
||||
/* Important checksum calculation NOTE:
|
||||
* Do checksum of all bits in row bytes, but ensure that invalid bits
|
||||
* are set to zero by masking. This subtlety just wasted several hours
|
||||
* of my life...
|
||||
*/
|
||||
crc32_update(&crc, dr, CPLD_XC2C64A_BYTES_IN_ROW);
|
||||
}
|
||||
|
||||
*crc_value = crc32_digest(&crc);
|
||||
|
||||
cpld_xc2c_jtag_init_special(jtag);
|
||||
cpld_xc2c_jtag_conld(jtag);
|
||||
|
||||
if( cpld_xc2c64a_jtag_idcode_ok(jtag) && cpld_xc2c_jtag_is_done(jtag) ) {
|
||||
cpld_xc2c_jtag_conld(jtag);
|
||||
cpld_xc2c_jtag_bypass(jtag, false);
|
||||
cpld_xc2c_jtag_bypass(jtag, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
cpld_xc2c_jtag_reset_and_idle(jtag);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void cpld_xc2c64a_jtag_sram_write_row(const jtag_t* const jtag, uint8_t address, const uint8_t* const data) {
|
||||
uint8_t write[CPLD_XC2C64A_BYTES_IN_ROW];
|
||||
memcpy(&write[0], data, sizeof(write));
|
||||
|
||||
/* Update-IR or Run-Test/Idle -> Shift-DR */
|
||||
cpld_xc2c_jtag_shift_u32(jtag, 0b001, 0b000, 3);
|
||||
|
||||
/* Shift-DR -> Shift-DR */
|
||||
cpld_xc2c_jtag_shift_ptr_tms(jtag, &write[0], 0, CPLD_XC2C64A_BITS_IN_ROW, false);
|
||||
|
||||
/* Shift-DR -> Exit1-DR */
|
||||
cpld_xc2c_jtag_shift_u32(jtag, 0b1000000, address, 7);
|
||||
|
||||
/* Exit1-DR -> Update-DR -> Run-Test/Idle */
|
||||
cpld_xc2c_jtag_shift_u32(jtag, 0b01, 0b00, 2);
|
||||
}
|
||||
|
||||
static void cpld_xc2c64a_jtag_sram_read_row(const jtag_t* const jtag, uint8_t* const data, const uint8_t next_address) {
|
||||
/* Run-Test/Idle -> Shift-DR */
|
||||
cpld_xc2c_jtag_shift_u32(jtag, 0b001, 0b000, 3);
|
||||
|
||||
/* Shift-DR */
|
||||
cpld_xc2c_jtag_shift_ptr_tms(jtag, data, 0, CPLD_XC2C64A_BITS_IN_ROW, false);
|
||||
|
||||
/* Shift-DR -> Exit1-DR */
|
||||
cpld_xc2c_jtag_shift_u32(jtag, 0b1000000, next_address, 7);
|
||||
|
||||
/* Weird, non-IEEE1532 compliant path through TAP machine, described in Xilinx
|
||||
* Programmer Qualification Specification, applicable only to XC2C64/A.
|
||||
* Exit1-DR -> Pause-DR -> Exit2-DR -> Update-DR -> Run-Test/Idle
|
||||
*/
|
||||
cpld_xc2c_jtag_shift_u32(jtag, 0b0110, 0b0000, 4);
|
||||
}
|
||||
|
||||
static bool cpld_xc2c64a_jtag_sram_compare_row(const jtag_t* const jtag, const uint8_t* const expected, const uint8_t* const mask, const uint8_t next_address) {
|
||||
/* Run-Test/Idle -> Shift-DR */
|
||||
uint8_t read[CPLD_XC2C64A_BYTES_IN_ROW];
|
||||
memset(read, 0xff, sizeof(read));
|
||||
cpld_xc2c64a_jtag_sram_read_row(jtag, &read[0], next_address);
|
||||
|
||||
bool matched = true;
|
||||
if( (expected != NULL) && (mask != NULL) ) {
|
||||
for(size_t i=0; i<CPLD_XC2C64A_BYTES_IN_ROW; i++) {
|
||||
const uint8_t significant_differences = (read[i] ^ expected[i]) & mask[i];
|
||||
matched &= (significant_differences == 0);
|
||||
}
|
||||
}
|
||||
|
||||
return matched;
|
||||
}
|
||||
|
||||
void cpld_xc2c64a_jtag_sram_write(
|
||||
const jtag_t* const jtag,
|
||||
const cpld_xc2c64a_program_t* const program
|
||||
) {
|
||||
cpld_xc2c_jtag_reset_and_idle(jtag);
|
||||
cpld_xc2c_jtag_enable(jtag);
|
||||
|
||||
cpld_xc2c_jtag_sram_write(jtag);
|
||||
|
||||
for(size_t row=0; row<CPLD_XC2C64A_ROWS; row++) {
|
||||
const uint8_t address = cpld_hackrf_row_addresses.address[row];
|
||||
cpld_xc2c64a_jtag_sram_write_row(jtag, address, &program->row[row].data[0]);
|
||||
}
|
||||
|
||||
cpld_xc2c_jtag_disable(jtag);
|
||||
cpld_xc2c_jtag_bypass(jtag, false);
|
||||
cpld_xc2c_jtag_reset(jtag);
|
||||
}
|
||||
|
||||
bool cpld_xc2c64a_jtag_sram_verify(
|
||||
const jtag_t* const jtag,
|
||||
const cpld_xc2c64a_program_t* const program,
|
||||
const cpld_xc2c64a_verify_t* const verify
|
||||
) {
|
||||
cpld_xc2c_jtag_reset_and_idle(jtag);
|
||||
cpld_xc2c_jtag_enable(jtag);
|
||||
|
||||
cpld_xc2c_jtag_sram_read(jtag);
|
||||
|
||||
/* Tricky loop to read dummy row first, then first address, then loop back to get
|
||||
* the first row's data.
|
||||
*/
|
||||
bool matched = true;
|
||||
for(size_t address_row=0; address_row<=CPLD_XC2C64A_ROWS; address_row++) {
|
||||
const int data_row = (int)address_row - 1;
|
||||
const size_t mask_index = (data_row >= 0) ? verify->mask_index[data_row] : 0;
|
||||
const uint8_t* const expected = (data_row >= 0) ? &program->row[data_row].data[0] : NULL;
|
||||
const uint8_t* const mask = (data_row >= 0) ? &verify->mask[mask_index].value[0] : NULL;
|
||||
const uint8_t next_address = (address_row < CPLD_XC2C64A_ROWS) ? cpld_hackrf_row_addresses.address[address_row] : 0;
|
||||
matched &= cpld_xc2c64a_jtag_sram_compare_row(jtag, expected, mask, next_address);
|
||||
}
|
||||
|
||||
cpld_xc2c_jtag_disable(jtag);
|
||||
cpld_xc2c_jtag_bypass(jtag, false);
|
||||
cpld_xc2c_jtag_reset(jtag);
|
||||
|
||||
return matched;
|
||||
}
|
75
Software/portapack-mayhem/hackrf/firmware/common/cpld_xc2c.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright 2019 Jared Boone <jared@sharebrained.com>
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CPLD_XC2C_H__
|
||||
#define __CPLD_XC2C_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "cpld_jtag.h"
|
||||
|
||||
/* Xilinx CoolRunner II XC2C64A bitstream attributes */
|
||||
#define CPLD_XC2C64A_ROWS (98)
|
||||
#define CPLD_XC2C64A_BITS_IN_ROW (274)
|
||||
#define CPLD_XC2C64A_BYTES_IN_ROW ((CPLD_XC2C64A_BITS_IN_ROW + 7) / 8)
|
||||
|
||||
typedef struct {
|
||||
uint8_t data[CPLD_XC2C64A_BYTES_IN_ROW];
|
||||
} cpld_xc2c64a_row_data_t;
|
||||
|
||||
typedef struct {
|
||||
cpld_xc2c64a_row_data_t row[CPLD_XC2C64A_ROWS];
|
||||
} cpld_xc2c64a_program_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t value[CPLD_XC2C64A_BYTES_IN_ROW];
|
||||
} cpld_xc2c64a_row_mask_t;
|
||||
|
||||
typedef struct {
|
||||
cpld_xc2c64a_row_mask_t mask[6];
|
||||
uint8_t mask_index[CPLD_XC2C64A_ROWS];
|
||||
} cpld_xc2c64a_verify_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t address[CPLD_XC2C64A_ROWS];
|
||||
} cpld_xc2c64a_row_addresses_t;
|
||||
|
||||
bool cpld_xc2c64a_jtag_checksum(
|
||||
const jtag_t* const jtag,
|
||||
const cpld_xc2c64a_verify_t* const verify,
|
||||
uint32_t* const crc_value
|
||||
);
|
||||
void cpld_xc2c64a_jtag_sram_write(
|
||||
const jtag_t* const jtag,
|
||||
const cpld_xc2c64a_program_t* const program
|
||||
);
|
||||
bool cpld_xc2c64a_jtag_sram_verify(
|
||||
const jtag_t* const jtag,
|
||||
const cpld_xc2c64a_program_t* const program,
|
||||
const cpld_xc2c64a_verify_t* const verify
|
||||
);
|
||||
|
||||
extern const cpld_xc2c64a_program_t cpld_hackrf_program_sram;
|
||||
extern const cpld_xc2c64a_verify_t cpld_hackrf_verify;
|
||||
extern const cpld_xc2c64a_row_addresses_t cpld_hackrf_row_addresses;
|
||||
|
||||
#endif/*__CPLD_XC2C_H__*/
|
49
Software/portapack-mayhem/hackrf/firmware/common/crc.c
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2019 Jared Boone <jared@sharebrained.com>
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "crc.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
void crc32_init(crc32_t* const crc) {
|
||||
crc->remainder = 0xffffffff;
|
||||
crc->reversed_polynomial = 0xedb88320;
|
||||
crc->final_xor = 0xffffffff;
|
||||
}
|
||||
|
||||
void crc32_update(crc32_t* const crc, const uint8_t* const data, const size_t byte_count) {
|
||||
uint32_t remainder = crc->remainder;
|
||||
const size_t bit_count = byte_count * 8;
|
||||
for(size_t bit_n=0; bit_n<bit_count; bit_n++) {
|
||||
const bool bit_in = data[bit_n >> 3] & (1 << (bit_n & 7));
|
||||
remainder ^= (bit_in ? 1 : 0);
|
||||
const bool bit_out = (remainder & 1);
|
||||
remainder >>= 1;
|
||||
if( bit_out ) {
|
||||
remainder ^= crc->reversed_polynomial;
|
||||
}
|
||||
}
|
||||
crc->remainder = remainder;
|
||||
}
|
||||
|
||||
uint32_t crc32_digest(const crc32_t* const crc) {
|
||||
return crc->remainder ^ crc->final_xor;
|
||||
}
|
38
Software/portapack-mayhem/hackrf/firmware/common/crc.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2019 Jared Boone <jared@sharebrained.com>
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __CRC_H__
|
||||
#define __CRC_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct {
|
||||
uint32_t remainder;
|
||||
uint32_t reversed_polynomial;
|
||||
uint32_t final_xor;
|
||||
} crc32_t;
|
||||
|
||||
void crc32_init(crc32_t* const crc);
|
||||
void crc32_update(crc32_t* const crc, const uint8_t* const data, const size_t byte_count);
|
||||
uint32_t crc32_digest(const crc32_t* const crc);
|
||||
|
||||
#endif//__CRC_H__
|
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone <jared@sharebrained.com>
|
||||
* Copyright 2013 Benjamin Vernoux <titanmkd@gmail.com>
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "fault_handler.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t r0;
|
||||
uint32_t r1;
|
||||
uint32_t r2;
|
||||
uint32_t r3;
|
||||
uint32_t r12;
|
||||
uint32_t lr; /* Link Register. */
|
||||
uint32_t pc; /* Program Counter. */
|
||||
uint32_t psr;/* Program Status Register. */
|
||||
} hard_fault_stack_t;
|
||||
|
||||
__attribute__((naked))
|
||||
void hard_fault_handler(void) {
|
||||
__asm__("TST LR, #4");
|
||||
__asm__("ITE EQ");
|
||||
__asm__("MRSEQ R0, MSP");
|
||||
__asm__("MRSNE R0, PSP");
|
||||
__asm__("B hard_fault_handler_c");
|
||||
}
|
||||
|
||||
volatile hard_fault_stack_t* hard_fault_stack_pt;
|
||||
|
||||
__attribute__((used)) void hard_fault_handler_c(uint32_t* args)
|
||||
{
|
||||
/* hard_fault_stack_pt contains registers saved before the hard fault */
|
||||
hard_fault_stack_pt = (hard_fault_stack_t*)args;
|
||||
|
||||
// args[0-7]: r0, r1, r2, r3, r12, lr, pc, psr
|
||||
// Other interesting registers to examine:
|
||||
// CFSR: Configurable Fault Status Register
|
||||
// HFSR: Hard Fault Status Register
|
||||
// DFSR: Debug Fault Status Register
|
||||
// AFSR: Auxiliary Fault Status Register
|
||||
// MMAR: MemManage Fault Address Register
|
||||
// BFAR: Bus Fault Address Register
|
||||
|
||||
/*
|
||||
if( SCB->HFSR & SCB_HFSR_FORCED ) {
|
||||
if( SCB->CFSR & SCB_CFSR_BFSR_BFARVALID ) {
|
||||
SCB->BFAR;
|
||||
if( SCB->CFSR & CSCB_CFSR_BFSR_PRECISERR ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
while(1);
|
||||
}
|
||||
|
||||
void mem_manage_handler() {
|
||||
while(1);
|
||||
}
|
||||
|
||||
void bus_fault_handler() {
|
||||
while(1);
|
||||
}
|
||||
|
||||
void usage_fault_handler() {
|
||||
while(1);
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2012 Jared Boone <jared@sharebrained.com>
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __FAULT_HANDLER__
|
||||
#define __FAULT_HANDLER__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <libopencm3/cm3/memorymap.h>
|
||||
|
||||
// TODO: Move all this to a Cortex-M(?) include file, since these
|
||||
// structures are supposedly the same between processors (to an
|
||||
// undetermined extent).
|
||||
typedef struct armv7m_scb_t armv7m_scb_t;
|
||||
struct armv7m_scb_t {
|
||||
volatile const uint32_t CPUID;
|
||||
volatile uint32_t ICSR;
|
||||
volatile uint32_t VTOR;
|
||||
volatile uint32_t AIRCR;
|
||||
volatile uint32_t SCR;
|
||||
volatile uint32_t CCR;
|
||||
volatile uint32_t SHPR1;
|
||||
volatile uint32_t SHPR2;
|
||||
volatile uint32_t SHPR3;
|
||||
volatile uint32_t SHCSR;
|
||||
volatile uint32_t CFSR;
|
||||
volatile uint32_t HFSR;
|
||||
volatile uint32_t DFSR;
|
||||
volatile uint32_t MMFAR;
|
||||
volatile uint32_t BFAR;
|
||||
volatile uint32_t AFSR;
|
||||
volatile const uint32_t ID_PFR0;
|
||||
volatile const uint32_t ID_PFR1;
|
||||
volatile const uint32_t ID_DFR0;
|
||||
volatile const uint32_t ID_AFR0;
|
||||
volatile const uint32_t ID_MMFR0;
|
||||
volatile const uint32_t ID_MMFR1;
|
||||
volatile const uint32_t ID_MMFR2;
|
||||
volatile const uint32_t ID_MMFR3;
|
||||
volatile const uint32_t ID_ISAR0;
|
||||
volatile const uint32_t ID_ISAR1;
|
||||
volatile const uint32_t ID_ISAR2;
|
||||
volatile const uint32_t ID_ISAR3;
|
||||
volatile const uint32_t ID_ISAR4;
|
||||
volatile const uint32_t __reserved_0x74_0x87[5];
|
||||
volatile uint32_t CPACR;
|
||||
} __attribute__((packed));
|
||||
|
||||
static armv7m_scb_t* const SCB = (armv7m_scb_t*)SCB_BASE;
|
||||
|
||||
#define SCB_HFSR_DEBUGEVT (1 << 31)
|
||||
#define SCB_HFSR_FORCED (1 << 30)
|
||||
#define SCB_HFSR_VECTTBL (1 << 1)
|
||||
|
||||
#endif//__FAULT_HANDLER__
|
62
Software/portapack-mayhem/hackrf/firmware/common/gpdma.c
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright 2013 Jared Boone <jared@sharebrained.com>
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <gpdma.h>
|
||||
|
||||
#include <libopencm3/lpc43xx/gpdma.h>
|
||||
|
||||
void gpdma_controller_enable() {
|
||||
GPDMA_CONFIG |= GPDMA_CONFIG_E(1);
|
||||
while( (GPDMA_CONFIG & GPDMA_CONFIG_E_MASK) == 0 );
|
||||
}
|
||||
|
||||
void gpdma_channel_enable(const uint_fast8_t channel) {
|
||||
GPDMA_CCONFIG(channel) |= GPDMA_CCONFIG_E(1);
|
||||
}
|
||||
|
||||
void gpdma_channel_disable(const uint_fast8_t channel) {
|
||||
GPDMA_CCONFIG(channel) &= ~GPDMA_CCONFIG_E_MASK;
|
||||
while( (GPDMA_ENBLDCHNS & GPDMA_ENBLDCHNS_ENABLEDCHANNELS(1 << channel)) );
|
||||
}
|
||||
|
||||
void gpdma_channel_interrupt_tc_clear(const uint_fast8_t channel) {
|
||||
GPDMA_INTTCCLEAR = GPDMA_INTTCCLEAR_INTTCCLEAR(1 << channel);
|
||||
}
|
||||
|
||||
void gpdma_channel_interrupt_error_clear(const uint_fast8_t channel) {
|
||||
GPDMA_INTERRCLR = GPDMA_INTERRCLR_INTERRCLR(1 << channel);
|
||||
}
|
||||
|
||||
void gpdma_lli_enable_interrupt(gpdma_lli_t* const lli) {
|
||||
lli->ccontrol |= GPDMA_CCONTROL_I(1);
|
||||
}
|
||||
|
||||
void gpdma_lli_create_loop(gpdma_lli_t* const lli, const size_t lli_count) {
|
||||
for(size_t i=0; i<lli_count; i++) {
|
||||
gpdma_lli_t* const next_lli = &lli[(i + 1) % lli_count];
|
||||
lli[i].clli = (lli[i].clli & ~GPDMA_CLLI_LLI_MASK) | GPDMA_CLLI_LLI((uint32_t)next_lli >> 2);
|
||||
}
|
||||
}
|
||||
|
||||
void gpdma_lli_create_oneshot(gpdma_lli_t* const lli, const size_t lli_count) {
|
||||
gpdma_lli_create_loop(lli, lli_count);
|
||||
lli[lli_count - 1].clli &= ~GPDMA_CLLI_LLI_MASK;
|
||||
}
|
43
Software/portapack-mayhem/hackrf/firmware/common/gpdma.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2013 Jared Boone <jared@sharebrained.com>
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GPDMA_H__
|
||||
#define __GPDMA_H__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <libopencm3/lpc43xx/gpdma.h>
|
||||
|
||||
void gpdma_controller_enable();
|
||||
|
||||
void gpdma_channel_enable(const uint_fast8_t channel);
|
||||
void gpdma_channel_disable(const uint_fast8_t channel);
|
||||
|
||||
void gpdma_channel_interrupt_tc_clear(const uint_fast8_t channel);
|
||||
void gpdma_channel_interrupt_error_clear(const uint_fast8_t channel);
|
||||
|
||||
void gpdma_lli_enable_interrupt(gpdma_lli_t* const lli);
|
||||
|
||||
void gpdma_lli_create_loop(gpdma_lli_t* const lli, const size_t lli_count);
|
||||
void gpdma_lli_create_oneshot(gpdma_lli_t* const lli, const size_t lli_count);
|
||||
|
||||
#endif/*__GPDMA_H__*/
|
38
Software/portapack-mayhem/hackrf/firmware/common/gpio.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GPIO_H__
|
||||
#define __GPIO_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef const struct gpio_t* gpio_t;
|
||||
|
||||
void gpio_init();
|
||||
void gpio_set(gpio_t gpio);
|
||||
void gpio_clear(gpio_t gpio);
|
||||
void gpio_toggle(gpio_t gpio);
|
||||
void gpio_output(gpio_t gpio);
|
||||
void gpio_input(gpio_t gpio);
|
||||
void gpio_write(gpio_t gpio, const bool value);
|
||||
bool gpio_read(gpio_t gpio);
|
||||
|
||||
#endif/*__GPIO_H__*/
|
58
Software/portapack-mayhem/hackrf/firmware/common/gpio_lpc.c
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "gpio_lpc.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
void gpio_init() {
|
||||
for(size_t i=0; i<8; i++) {
|
||||
GPIO_LPC_PORT(i)->dir = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void gpio_set(gpio_t gpio) {
|
||||
gpio->port->set = gpio->mask;
|
||||
}
|
||||
|
||||
void gpio_clear(gpio_t gpio) {
|
||||
gpio->port->clr = gpio->mask;
|
||||
}
|
||||
|
||||
void gpio_toggle(gpio_t gpio) {
|
||||
gpio->port->not = gpio->mask;
|
||||
}
|
||||
|
||||
void gpio_output(gpio_t gpio) {
|
||||
gpio->port->dir |= gpio->mask;
|
||||
}
|
||||
|
||||
void gpio_input(gpio_t gpio) {
|
||||
gpio->port->dir &= ~gpio->mask;
|
||||
}
|
||||
|
||||
void gpio_write(gpio_t gpio, const bool value) {
|
||||
*gpio->gpio_w = value;
|
||||
}
|
||||
|
||||
bool gpio_read(gpio_t gpio) {
|
||||
return *gpio->gpio_w;
|
||||
}
|
70
Software/portapack-mayhem/hackrf/firmware/common/gpio_lpc.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
*
|
||||
* This file is part of HackRF.
|
||||
*
|
||||
* 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; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GPIO_LPC_H__
|
||||
#define __GPIO_LPC_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "gpio.h"
|
||||
|
||||
/* NOTE: libopencm3 constants and functions not used here due to naming
|
||||
* conflicts. I'd recommend changes to libopencm3 design to separate
|
||||
* register #defines and API declarations into separate header files.
|
||||
*/
|
||||
|
||||
typedef struct gpio_port_t {
|
||||
volatile uint32_t dir; /* +0x000 */
|
||||
uint32_t _reserved0[31];
|
||||
volatile uint32_t mask; /* +0x080 */
|
||||
uint32_t _reserved1[31];
|
||||
volatile uint32_t pin; /* +0x100 */
|
||||
uint32_t _reserved2[31];
|
||||
volatile uint32_t mpin; /* +0x180 */
|
||||
uint32_t _reserved3[31];
|
||||
volatile uint32_t set; /* +0x200 */
|
||||
uint32_t _reserved4[31];
|
||||
volatile uint32_t clr; /* +0x280 */
|
||||
uint32_t _reserved5[31];
|
||||
volatile uint32_t not; /* +0x300 */
|
||||
} gpio_port_t;
|
||||
|
||||
struct gpio_t {
|
||||
const uint32_t mask;
|
||||
gpio_port_t* const port;
|
||||
volatile uint32_t* const gpio_w;
|
||||
};
|
||||
|
||||
#define GPIO_LPC_BASE (0x400f4000)
|
||||
#define GPIO_LPC_B_OFFSET (0x0)
|
||||
#define GPIO_LPC_W_OFFSET (0x1000)
|
||||
#define GPIO_LPC_PORT_OFFSET (0x2000)
|
||||
|
||||
#define GPIO_LPC_PORT(_n) ((gpio_port_t*)((GPIO_LPC_BASE + GPIO_LPC_PORT_OFFSET) + (_n) * 4))
|
||||
#define GPIO_LPC_W(_port_num, _pin_num) (volatile uint32_t*)((GPIO_LPC_BASE + GPIO_LPC_W_OFFSET) + ((_port_num) * 0x80) + ((_pin_num) * 4))
|
||||
|
||||
#define GPIO(_port_num, _pin_num) { \
|
||||
.mask = (1UL << (_pin_num)), \
|
||||
.port = GPIO_LPC_PORT(_port_num), \
|
||||
.gpio_w = GPIO_LPC_W(_port_num, _pin_num), \
|
||||
}
|
||||
|
||||
#endif/*__GPIO_LPC_H__*/
|