Skip to content

Commit

Permalink
Add NSIS installer, fix a few minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
multiplemonomials committed Oct 16, 2023
1 parent d03b736 commit 80a7be7
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 51 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/compile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,19 @@ jobs:
C:\vcpkg\vcpkg.exe install libusb:x64-windows
- name: Compile project
run: |
$env:PATH = "C:\vcpkg\installed\x64-windows\bin;$env:PATH"
mkdir build
cd build
cmake .. -DUSE_WERROR=TRUE -DCMAKE_PREFIX_PATH=C:\vcpkg\installed\x64-windows
cmake --build .
cmake --build . -t package
- uses: actions/upload-artifact@v3
if: ${{success()}}
with:
name: Windows Installer
if-no-files-found: error
path: |
build/FXLoad-*.exe
build-windows-mingw:
runs-on: windows-latest
Expand Down
22 changes: 21 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,24 @@ target_include_directories(CLI11 INTERFACE CLI11/include)
# Add subdirs
# ----------------------------------------------------------
add_subdirectory(src)
add_subdirectory(resources)
add_subdirectory(resources)

# Set up packaging (on windows)
# ----------------------------------------------------------
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
# General CPack options
set(CPACK_PACKAGE_NAME "FXLoad")
set(CPACK_PACKAGE_VENDOR "Mbed CE")
set(CPACK_PACKAGE_DESCRIPTION "FXLoad is a tool for flashing firmware to the EZ-USB series of USB interface microcontrollers.")
set(CPACK_PACKAGE_VERSION ${fxload_VERSION})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "FXLoad")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/mbed-ce/fxload")
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/copying.txt)

# NSIS specific options
set(CPACK_GENERATOR NSIS)
# Make sure the installer provides an option to add fxload to the path
set(CPACK_NSIS_MODIFY_PATH TRUE)

include(CPack)
endif()
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ More info about the EZ-USB series of micros can be found [here](http://www.linux

FXLoad is licensed under the GNU General Public License, Version 2.

The last original version of fxload was published in 2008 by David Brownell at http://linux-hotplug.sourceforge.net. This version is Linux only as it uses Linux-specific ioctls to talk to the device instead of libusb.
The original version of fxload was published from 2001-2008 by David Brownell and others at http://linux-hotplug.sourceforge.net. This version is Linux only as it uses Linux-specific ioctls to talk to the device instead of libusb.

In 2010, Wolfgang Wieser created some patches to make assigning VIDs and PIDs easier [here](https://www.triplespark.net/elec/periph/USB-FX2/eeprom/) (these currently are not merged into this version).

Expand Down Expand Up @@ -125,7 +125,7 @@ First, add your user to the "plugdev" group:
```
sudo usermod -G plugdev $(whoami)
```
We will use ths group to control access to USB devices. Next, sign out and back in again to make the change effective.
We will use ths group to control access to USB devices. After running this, sign out and back in again to make the change effective.

Second, run `sudo vim /etc/udev/rules.d/99-ezusb.rules` to create a new rules file with the following content:
```
Expand Down
16 changes: 15 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,18 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
target_link_libraries(fxload Shlwapi)
endif()

install(TARGETS fxload DESTINATION bin)
# On Windows, we also want to install any runtime dependencies needed by the executable,
# other than the Microsoft UCRT.
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
# This block from https://stackoverflow.com/a/72088102/7083698
set(RUNTIME_DEPENDENCIES_CLAUSE RUNTIME_DEPENDENCIES
PRE_EXCLUDE_REGEXES "api-ms-" "ext-ms-" "hvsifiletrust" "C:/msys64/mingw64/bin.*" ".*/msys64/mingw64/bin.*"
POST_EXCLUDE_REGEXES ".*system32/.*\\.dll" ".*/msys64/mingw64/bin.*"
DIRECTORIES $ENV{PATH}
)
else()
set(RUNTIME_DEPENDENCIES_CLAUSE "")
endif()


install(TARGETS fxload DESTINATION bin ${RUNTIME_DEPENDENCIES_CLAUSE})
55 changes: 8 additions & 47 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ libusb_device_handle *get_usb_device(struct device_spec *wanted) {

int
parse_device_path(const std::string & device_path, struct device_spec *spec) {
std::string::size_type colonIdx = device_path.find(":");
std::string::size_type dotIdx = device_path.find(".");
std::string::size_type atIndex = device_path.find("@");
std::string::size_type colonIdx = device_path.find(':');
std::string::size_type dotIdx = device_path.find('.');
std::string::size_type atIndex = device_path.find('@');
if (colonIdx != std::string::npos) {

// Always expect 4 hex digits in each part
Expand Down Expand Up @@ -236,7 +236,7 @@ const std::map<std::string, ezusb_chip_t> DeviceTypeNames

int main(int argc, char*argv[])
{
CLI::App app{std::string(FXLOAD_VERSION_STR) + "\nA utility to load the Cypress FX2 family of microcontrollers over USB."};
CLI::App app{std::string(FXLOAD_VERSION_STR) + "\nA utility to load the EZ-USB family of microcontrollers over USB."};

// Variables written to by CLI options
std::string ihex_path;
Expand All @@ -259,7 +259,7 @@ int main(int argc, char*argv[])
->transform(CLI::CheckedTransformer(DeviceTypeNames, CLI::ignore_case));
app.add_option("-D,--device", device_spec_string, "Select device by vid:pid(@index) or bus.port(@index). If not provided, all discovered USB devices will be displayed as options.");
auto eeprom_first_byte_opt = app.add_option("-c,--eeprom-first-byte", eeprom_first_byte, "Value programmed to first byte of EEPROM to set chip behavior. e.g. for FX2LP this should be 0xC0 or 0xC2")
->check(CLI::Range(std::numeric_limits<uint8_t>::min(), std::numeric_limits<uint8_t>::max()));
->check(CLI::Range(static_cast<uint16_t>(std::numeric_limits<uint8_t>::min()), static_cast<uint16_t>(std::numeric_limits<uint8_t>::max())));
auto eeprom_opt = app.add_flag("-e, --eeprom", load_to_eeprom, "Load the hex file to EEPROM via a 1st stage loader instead of directly to RAM")
->needs(eeprom_first_byte_opt);
app.add_option("-s,--stage1", stage1_loader, "Path to the stage 1 loader file to use when flashing EEPROM. Default: " + stage1_loader)
Expand Down Expand Up @@ -317,46 +317,7 @@ int main(int argc, char*argv[])

libusb_close(device);

exit(0);
}
printf("Done.\n");


/*
* $Log: main.c,v $
* Revision 1.2 2007/03/20 14:31:50 cfavi
* *** empty log message ***
*
* Revision 1.1 2007/03/19 20:46:30 cfavi
* fxload ported to use libusb
*
* Revision 1.8 2005/01/11 03:58:02 dbrownell
* From Dirk Jagdmann <[email protected]>: optionally output messages to
* syslog instead of stderr.
*
* Revision 1.7 2002/04/12 00:28:22 dbrownell
* support "-t an21" to program EEPROMs for those microcontrollers
*
* Revision 1.6 2002/04/02 05:26:15 dbrownell
* version display now noiseless (-V);
* '-?' (usage info) convention now explicit
*
* Revision 1.5 2002/02/26 20:10:28 dbrownell
* - "-s loader" option for 2nd stage loader
* - "-c byte" option to write EEPROM with 2nd stage
* - "-V" option to dump version code
*
* Revision 1.4 2002/01/17 14:19:28 dbrownell
* fix warnings
*
* Revision 1.3 2001/12/27 17:54:04 dbrownell
* forgot an important character :)
*
* Revision 1.2 2001/12/27 17:43:29 dbrownell
* fail on firmware download errors; add "-v" flag
*
* Revision 1.1 2001/06/12 00:00:50 stevewilliams
* Added the fxload program.
* Rework root makefile and hotplug.spec to install in prefix
* location without need of spec file for install.
*
*/
exit(0);
}

0 comments on commit 80a7be7

Please sign in to comment.