Skip to content

Commit

Permalink
Forgot an option for fixing configuration tags
Browse files Browse the repository at this point in the history
  • Loading branch information
GabyPCgeeK committed Oct 17, 2021
1 parent 8d24306 commit 72178d4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Options:
-v, --ver S.J.X Change reported STLink sersion.
S is STLink version, J is JTAG version,
X is SWIM or MSD version.
-f, --fix Flash Anti-Clone Tag and Firmware Exists/EOF Tag
Options for Modifying Device Config (Only for STLink v2 and up):
--usb_cur CURRENT Set the MaxPower reported in USB Descriptor
Expand Down Expand Up @@ -131,5 +132,6 @@ make
ST's firmware upload protocol is USB's DFU protocol with some twists. Every DFU command is issued with the 0xF3 prefix, and the command set does not exactly match USB's.

Some documentation :
* http://www.st.com/content/ccc/resource/technical/document/application_note/6a/17/92/02/58/98/45/0c/CD00264379.pdf/files/CD00264379.pdf/jcr:content/translations/en.CD00264379.pdf
* http://www.usb.org/developers/docs/devclass_docs/DFU_1.1.pdf

* <http://www.st.com/content/ccc/resource/technical/document/application_note/6a/17/92/02/58/98/45/0c/CD00264379.pdf/files/CD00264379.pdf/jcr:content/translations/en.CD00264379.pdf>
* <http://www.usb.org/developers/docs/devclass_docs/DFU_1.1.pdf>
16 changes: 12 additions & 4 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ enum OptionsVal {
optSAVE_DEC,
optST_TYPE,
optVERSION,
optFIX,
optUSB_CUR,
optMSD_NAME,
optMBED_NAME,
Expand Down Expand Up @@ -78,6 +79,9 @@ static struct option long_options[] = {

{"ver", 1, 0, optVERSION},
{"v", 1, 0, optVERSION},

{"fix", 0, 0, optFIX},
{"f", 0, 0, optFIX},

{"usb_cur", 1, 0, optUSB_CUR},
{"rm_usb_cur", 0, 0, optUSB_CUR},
Expand Down Expand Up @@ -115,7 +119,8 @@ void print_help(char *argv[]) {
if (st_types[i])
printf("\t\t\t %c for \"%s\"\n", (char)i, st_types[i]);
}
printf(" -v, --ver S.J.X\tChange reported STLink sersion.\n\t\t\t S is STLink version, J is JTAG version,\n\t\t\t X is SWIM or MSD version.\n\n");
printf(" -v, --ver S.J.X\tChange reported STLink sersion.\n\t\t\t S is STLink version, J is JTAG version,\n\t\t\t X is SWIM or MSD version.\n");
printf(" -f, --fix\t\tFlash Anti-Clone Tag and Firmware Exists/EOF Tag\n\n");
printf("Options for Modifying Device Config (Only for STLink v2 and up):\n");
printf(" --usb_cur CURRENT\tSet the MaxPower reported in USB Descriptor\n\t\t\tto CURRENT(mA)\n");
printf(" --msd_name VOLUME\tSet the volsume name of the MSD drive to VOLUME.\n");
Expand All @@ -133,7 +138,7 @@ int main(int argc, char *argv[]) {
struct STLinkInfo info;
struct STLinkConfig config;
int res = EXIT_FAILURE, i, opt;
bool probe = false, decrypt = false, save_decrypted = false, flash_config = false;
bool probe = false, decrypt = false, save_decrypted = false, flash_config = false, fix_config = false;
char* boot_ver = "";
char ver_type = 'S';

Expand Down Expand Up @@ -175,6 +180,9 @@ int main(int argc, char *argv[]) {
config.soft_version = (atoi(st_v) & 0xF) << 12 | (atoi(jt_v) & 0x3F) << 6 | (atoi(sw_v) & 0x3F);
}
break;
case optFIX:
fix_config = true;
break;
case optUSB_CUR:
if (optarg && strlen(optarg) > 0) {
config.modify[confUSB_CUR] = modADD;
Expand Down Expand Up @@ -443,9 +451,9 @@ int main(int argc, char *argv[]) {

if (do_load)
if (stlink_flash(&info, argv[optind], decrypt, save_decrypted))
flash_config = false;
flash_config = fix_config = false;

if (flash_config) {
if (flash_config || fix_config) {
stlink_flash_config_area(&info, &config);
}
stlink_exit_dfu(&info);
Expand Down

0 comments on commit 72178d4

Please sign in to comment.