Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pull in Windows Bootstrap Loader Python Package #249

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

kb1lqc
Copy link
Member

@kb1lqc kb1lqc commented Jul 19, 2017

This PR creates a faraday-bsl program which pulls in a lot of @kb1lqd code used to bootstrap load the FaradayRF hardware. This ONLY works in windows and please be sure to have the FTDI drivers installed (http://www.ftdichip.com/Drivers/D2XX.htm). This whole operation isn't ideal but it's what works for the time being.

Changes

  • Creates a faraday-bsl package
  • Copies necessary files (python scripts/classes, exe files, etc) into etc/faraday, also utilizes the classes folder
  • Utilizes faraday-help menu to indicate possible command line operations
  • Downloads latest firmware from github master with --getmaster operation, saves to /.faraday/firmware/master.txt
  • programs firmware onto Faraday at specified --port PORT using USB cable

Operation

After configuring the config files, updating the master firmware from the internet, it's as simple as...
bsl

@el-iso @reillyeon @jbemenheiser

kb1lqc added 24 commits July 12, 2017 07:56
Added setup.cfg entry points as well as skeleton application code.
Moved to createtiscript.py and also created new folder classes in the
faraday folder.
Imported createtiscript.py as a module from the bootstrap loader
application.
I can get to the end of creating TI scripts. This required some hard
coding of file locations and moving some .txt files into /etc/faraday.
Removed file that is created everytime bootstrap loader is used. Then I
added it to the .gitignore file so we won't accidentally add it later.
revamped a decent amount of .gitignore for all applications. Also updated
filenames in bootstrap.py
importing faradyFTDI class now after moving it into the project.
First time completely working through load of firware with new packaged
command. Still need to correct loading of files from setup.cfg. Also
updated .gitignore to remove a filename error.
Also added sample INI file. This now completes obtaining most data from
the package. Including a prior commit that added an EXE file (oh god...).
A must for now. Still need to automate obtaining latest firmware file and
starting to use the INI configuration to remove the hard-coding.
Boostrap.py now reads in the filename and com port from bsl.ini.
Most of the filenames needed are now pulled in from the configuration INI
file.
Didn't want it to be test so I changed it to script.
Indicated required FTDI drivers.
The getMaster command option downloads the latest master firmware and
places it in <user>/.faraday/firmware/master.txt
Updated bsl.sample.ini with all fields currently in use. Also started
using downloaded firmware located in <user>/.faraday/firmware/master.txt
Now using --port to set the UART port in bsl.ini. Also, changed the ini
file to match proxy terminology for ports in INI file.
Added a try/except for firmware master.txt opening.
Cleaned up commented out code, updated comments, and added a try/except
statement for the FTDI drivers.
Removed commented out code, commented where appropriate, and generally
cleaned up the file. Also added docstrings.
Quick docstring fix on createtiscript.py and a big commenting/cleanup of
faradayFTDI.py. Ideally there were no functional changes in this commit.
Passes pytest after these commits.
Try and excepts now work better and the package is cleaned up from a
command line and config operational flow.
@kb1lqc kb1lqc added this to the Alpha Software milestone Jul 19, 2017
@kb1lqc kb1lqc self-assigned this Jul 19, 2017
@kb1lqc kb1lqc requested a review from kb1lqd July 19, 2017 07:44
@kb1lqd
Copy link
Contributor

kb1lqd commented Jul 20, 2017

@kb1lqc

It won't work for me (com port setup earlier):

Brent@Brent-surface MINGW64 ~/Documents/Faraday_GIthub_Software/Pull_Request_Reviews/firmwareinstall/Faraday-Software (bsl)
$ faraday-bsl --getmaster --start
2017-07-20 01:03:23,871 - BSL - INFO - Downloading latest Master firmware...
2017-07-20 01:03:24,503 - BSL - INFO - Download complete
2017-07-20 01:03:24,503 - BSL - INFO - Starting Faraday Bootstrap Loader application
---------------------------------------------------------
BSL Scripter 3.1.0.0
PC software for BSL programming
2017-Jul-20 01:03:30
---------------------------------------------------------
Input file script is : C:/Users/Brent/Documents/Faraday_GIthub_Software/Pull_Request_Reviews/firmwareinstall/Faraday-Software/etc/faraday/faradayFirmwareUpgradeScript.txt
MODE 6xx UART 9600 com112 PARITY
CHANGE_BAUD_RATE 115200
        BSL ACK is received.
VERBOSE


RX_PASSWORD pass32_wrong.txt

Brent@Brent-surface MINGW64 ~/Documents/Faraday_GIthub_Software/Pull_Request_Reviews/firmwareinstall/Faraday-Software (bsl)

@kb1lqc
Copy link
Member Author

kb1lqc commented Jul 20, 2017

Is there any other info? What you posted doesn't tell me much unless I'm missing something.

@kb1lqc
Copy link
Member Author

kb1lqc commented Jul 20, 2017

Yeah @kb1lqd we will need to figure out what you're doing. I uninstalled all Faraday software from my computer and cleaned out config/file directories followed by installing with a wheel file (same as installing from PyPI). Bootstrap loading worked for me fine.

I did notice that I still had some issues with having to run it from the github directory but that is not the issue you seem to be having. In order for this to move forward I need more info from you on what isn't working.

@kb1lqd
Copy link
Contributor

kb1lqd commented Jul 20, 2017

@kb1lqc Below is a BSL test from a clean install:

Brent@Brent-surface MINGW64 ~/Documents/Faraday_GIthub_Software/Pull_Request_Reviews/firmwareinstall/Faraday-Software (bsl)
$ ls
Applications/    etc/                        LICENSE.md        setup.cfg
CONTRIBUTING.md  faraday/                    Proxy/            setup.py*
Debug/           faraday.egg-info/           README            Tutorials/
Device_Test/     Firmware_Bootstrap_Loader/  README.md
docs/            images/                     requirements.txt

Brent@Brent-surface MINGW64 ~/Documents/Faraday_GIthub_Software/Pull_Request_Reviews/firmwareinstall/Faraday-Software (bsl)
$ faraday-bsl --init-config
2017-07-20 08:55:48,802 - BSL - INFO - Initializing BSL
2017-07-20 08:55:48,818 - BSL - INFO - Initialization complete

Brent@Brent-surface MINGW64 ~/Documents/Faraday_GIthub_Software/Pull_Request_Reviews/firmwareinstall/Faraday-Software (bsl)
$ faraday-bsl --help
usage: faraday-bsl [-h] [--init-config] [--start] [--getmaster] [--port PORT]

BSL will Boostrap load firmware onto Faraday via USB connection. Requires
http://www.ftdichip.com/Drivers/D2XX.htm

optional arguments:
  -h, --help     show this help message and exit
  --init-config  Initialize BSL configuration file
  --start        Start Boostrap loader
  --getmaster    Download newest firmware from master firmware repository
  --port PORT    Set UART port to bootstrap load firmware

Brent@Brent-surface MINGW64 ~/Documents/Faraday_GIthub_Software/Pull_Request_Reviews/firmwareinstall/Faraday-Software (bsl)
$ faraday-bsl --port COM21 --getmaster
2017-07-20 08:56:18,016 - BSL - INFO - Downloading latest Master firmware...
2017-07-20 08:56:18,737 - BSL - INFO - Download complete
2017-07-20 08:56:18,737 - BSL - WARNING - --start option not present, exiting BSL server!

Brent@Brent-surface MINGW64 ~/Documents/Faraday_GIthub_Software/Pull_Request_Reviews/firmwareinstall/Faraday-Software (bsl)
$ faraday-bsl --start
2017-07-20 08:56:31,440 - BSL - INFO - Starting Faraday Bootstrap Loader application
---------------------------------------------------------
BSL Scripter 3.1.0.0
PC software for BSL programming
2017-Jul-20 08:56:37
---------------------------------------------------------
Input file script is : C:/Users/Brent/Documents/Faraday_GIthub_Software/Pull_Request_Reviews/firmwareinstall/Faraday-Software/etc/faraday/faradayFirmwareUpgradeScript.txt
MODE 6xx UART 9600 COM21 PARITY
CHANGE_BAUD_RATE 115200
        BSL ACK is received.
VERBOSE


RX_PASSWORD pass32_wrong.txt

Brent@Brent-surface MINGW64 ~/Documents/Faraday_GIthub_Software/Pull_Request_Reviews/firmwareinstall/Faraday-Software (bsl)

@kb1lqd
Copy link
Contributor

kb1lqd commented Jul 20, 2017

First, the unit trying to be reprogrammed does get RESET and reboots but doesn't reprogram due to the BSL program failing.

Interesting, when I run in from windows command line:

image

@kb1lqc
Copy link
Member Author

kb1lqc commented Jul 21, 2017

Strange @kb1lqd I tried this on my Microsoft Surface Pro 4 and it worked fine. Can you try installing from a fresh git? Have you rebooted your computer and tried?

@kb1lqc
Copy link
Member Author

kb1lqc commented Jul 21, 2017

Oh snap the problem maybe that my setup.cfg never pulls in etc/faraday/bsl-scripter-windows.exe as a package element. etc/faraday may not be the best folder but it works for now. On both my computers I probably manually moved this so it's present in both locations as I developed on it. I thought I cleaned it out though but this definitely needs to be included in setup.cfg along with any other exe required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

2 participants