You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-6Lines changed: 14 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -32,10 +32,10 @@ In 2023, the Mbed CE project is now making an updated version of this library wh
32
32
- Improved error messages (esp. for failing to open USB devices)
33
33
- Improved device selection menu
34
34
35
-
## Code Installation
35
+
## Installing FXLoad
36
36
37
37
### Installer
38
-
On Windows, FXLoad can be installed via the Windows installer downloadable from the Releases page. (TODO)
38
+
On Windows, FXLoad can be installed via the Windows installer downloadable from the [Releases](https://github.com/mbed-ce/fxload/releases) page.
39
39
40
40
### Building from Source
41
41
FXLoad can be built from source using CMake and a C/C++ compiler. The first step is to use Git to clone the project. Make sure to pass "--recursive" to get the submodules:
@@ -155,26 +155,34 @@ This version of fxload allows you to specify the device to connect to in three d
155
155
2. You may specify `--device <vid>:<pid>` to select a device by its vendor ID and hardware ID (in hexadecimal). For example, to flash an unconfigured FX2LP, you would pass `--device 04b4:8613`. By default, this will select the first such device found, but you can change that by adding `@N` after the vid and pid to use the Nth device found (where N is the 0-indexed index of the device to use).
156
156
3. You may specify `--device <bus>.<port>` to select a device by its bus and device number, specified as decimal numbers. You can get the bus and device numbers from `lsusb` on Linux, though I'm not aware of a utility to list them on Linux.
157
157
158
+
To list available devices, run the command
159
+
```
160
+
fxload list
161
+
```
162
+
This will list out all available USB devices on your system, so you can pick which device to use.
163
+
158
164
### Loading a Hex File to RAM
159
165
To just load a firmware file into RAM, use a command like:
The `-c` argument gives the value for the command byte (the first byte of the device EEPROM). The value to use here changes based on the device. For FX2LP, 0xC2 causes the device to boot from EEPROM, and 0xC0 causes the device to load the VID, PID, and DID from EEPROM.
183
+
The `--control-byte` argument gives the value for the command byte (the first byte of the device EEPROM). The value to use here changes based on the device. For FX2LP, 0xC2 causes the device to boot from EEPROM, and 0xC0 causes the device to load the VID, PID, and DID from the EEPROM.
184
+
185
+
Note: You may need to reset the chip before the new firmware will load.
178
186
179
187
### Loading Only VID, PID, and DID values to EEPROM
app.add_flag("-v,--verbose", verbose, "Verbose mode. May be supplied up to 3 times for more verbosity."); // note: CLI11 will count the occurrences of a flag when you pass an integer variable to add_flag()
221
-
app.add_option("-I,--ihex-path", ihex_path, "Hex file to program")
250
+
app.add_flag("-V,--version", printVersion, "Print version and exit.");
251
+
252
+
// Subcommands
253
+
CLI::App * load_ram_subcommand = app.add_subcommand("load_ram", "Load a binary into file into the EZ-USB chip's RAM.");
254
+
CLI::App * load_eeprom_subcommand = app.add_subcommand("load_eeprom", "Load a binary into file into the EZ-USB chip's EEPROM.");
255
+
CLI::App * list_usb_subcommand = app.add_subcommand("list", "List all available USB devices and exit");
256
+
257
+
// load_ram options
258
+
load_ram_subcommand->add_option("-I,--ihex-path", ihex_path, "Hex file to program")
259
+
->required()
260
+
->check(CLI::ExistingFile);
261
+
load_ram_subcommand->add_option("-t,--type", type, "Select device type (from AN21|FX|FX2|FX2LP)")
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.");
228
-
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")
"Select device by vid:pid(@index) or bus.port(@index). If not provided, all discovered USB devices will be displayed as options.");
276
+
load_eeprom_subcommand->add_option("-c,--control-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")
load_eeprom_subcommand->add_option("-s,--stage1", stage1_loader, "Path to the stage 1 loader file to use when flashing EEPROM. Default: " + stage1_loader)
234
279
->check(CLI::ExistingFile);
235
280
236
281
CLI11_PARSE(app, argc, argv);
237
282
238
-
// Handle CLI options
239
-
structdevice_spec spec = {0};
240
-
if(!device_spec_string.empty())
283
+
// handle -V
284
+
if(printVersion)
241
285
{
242
-
int parseResult = parse_device_path(device_spec_string, &spec);
243
-
if(parseResult != 0)
286
+
printf("%s\n", FXLOAD_VERSION_STR);
287
+
return0;
288
+
}
289
+
else
290
+
{
291
+
if(app.get_subcommands().size() == 0)
244
292
{
245
-
return parseResult;
293
+
printf("Must specify a subcommand! Run with --help for more information.\n");
294
+
return1;
246
295
}
247
296
}
248
297
249
-
libusb_device_handle *device;
250
-
int status;
298
+
// Handle subcommands
299
+
if(list_usb_subcommand->parsed())
300
+
{
301
+
search_usb_devices(true, nullptr);
302
+
return0;
303
+
}
304
+
else// load_ram or load_eeprom (all commands which open a USB device)
305
+
{
306
+
// Find USB device to operate on
307
+
structdevice_spec spec = {0};
308
+
if(!device_spec_string.empty())
309
+
{
310
+
int parseResult = parse_device_path(device_spec_string, &spec);
0 commit comments