-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[refactoring] Clean-up for stlink-flash & -info
- Ensure proper function declaration - Checked & revised header includes
- Loading branch information
1 parent
5d3f3ec
commit 2c33761
Showing
16 changed files
with
155 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,18 @@ | ||
/* | ||
* File: flash.h | ||
* | ||
* Tool st-flash | ||
*/ | ||
|
||
#ifndef FLASH_H | ||
#define FLASH_H | ||
|
||
#include <stdint.h> | ||
|
||
#include <stlink.h> | ||
|
||
#define DEBUG_LOG_LEVEL 100 | ||
#define STND_LOG_LEVEL 50 | ||
#define ENABLE_OPT 1 | ||
|
||
enum flash_cmd {FLASH_CMD_NONE = 0, FLASH_CMD_WRITE = 1, FLASH_CMD_READ = 2, FLASH_CMD_ERASE = 3, CMD_RESET = 4}; | ||
enum flash_format {FLASH_FORMAT_BINARY = 0, FLASH_FORMAT_IHEX = 1}; | ||
enum flash_area {FLASH_MAIN_MEMORY = 0, FLASH_SYSTEM_MEMORY = 1, FLASH_OTP = 2, FLASH_OPTION_BYTES = 3, FLASH_OPTION_BYTES_BOOT_ADD = 4, FLASH_OPTCR = 5, FLASH_OPTCR1 = 6}; | ||
struct flash_opts { | ||
enum flash_cmd cmd; | ||
uint8_t serial[STLINK_SERIAL_BUFFER_SIZE]; | ||
const char* filename; | ||
stm32_addr_t addr; | ||
uint32_t size; | ||
int32_t reset; | ||
int32_t log_level; | ||
enum flash_format format; | ||
enum flash_area area; | ||
uint32_t val; | ||
uint32_t flash_size; // --flash=n[k, M] | ||
int32_t opt; // enable empty tail data drop optimization | ||
int32_t freq; // --freq=n[k, M] frequency of JTAG/SWD | ||
enum connect_type connect; | ||
}; | ||
|
||
#define FLASH_OPTS_INITIALIZER {0, { 0 }, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | ||
|
||
int32_t flash_get_opts(struct flash_opts* o, int32_t ac, char** av); | ||
// static stlink_t *connected_stlink = NULL; | ||
// static void cleanup(int32_t signum); | ||
// static void usage(void); | ||
|
||
#endif // FLASH_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* File: flash_opts.h | ||
* | ||
* Flash Options | ||
*/ | ||
|
||
#ifndef FLASH_OPTS_H | ||
#define FLASH_OPTS_H | ||
|
||
#define FLASH_OPTS_INITIALIZER {0, { 0 }, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | ||
|
||
enum flash_cmd {FLASH_CMD_NONE = 0, FLASH_CMD_WRITE = 1, FLASH_CMD_READ = 2, FLASH_CMD_ERASE = 3, CMD_RESET = 4}; | ||
enum flash_format {FLASH_FORMAT_BINARY = 0, FLASH_FORMAT_IHEX = 1}; | ||
enum flash_area {FLASH_MAIN_MEMORY = 0, FLASH_SYSTEM_MEMORY = 1, FLASH_OTP = 2, FLASH_OPTION_BYTES = 3, FLASH_OPTION_BYTES_BOOT_ADD = 4, FLASH_OPTCR = 5, FLASH_OPTCR1 = 6}; | ||
|
||
struct flash_opts { | ||
enum flash_cmd cmd; | ||
uint8_t serial[STLINK_SERIAL_BUFFER_SIZE]; | ||
const char* filename; | ||
stm32_addr_t addr; | ||
uint32_t size; | ||
int32_t reset; | ||
int32_t log_level; | ||
enum flash_format format; | ||
enum flash_area area; | ||
uint32_t val; | ||
uint32_t flash_size; // --flash=n[k, M] | ||
int32_t opt; // enable empty tail data drop optimization | ||
int32_t freq; // --freq=n[k, M] frequency of JTAG/SWD | ||
enum connect_type connect; | ||
}; | ||
|
||
// static bool starts_with(const char * str, const char * prefix); | ||
// static int32_t get_long_integer_from_char_array (const char *const str, uint64_t *read_value); | ||
// static int32_t get_integer_from_char_array (const char *const str, uint32_t *read_value); | ||
// static int32_t invalid_args(const char *expected); | ||
// static int32_t bad_arg(const char *arg); | ||
int32_t flash_get_opts(struct flash_opts* o, int32_t ac, char** av); | ||
|
||
#endif // FLASH_OPTS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* File: info.h | ||
* | ||
* Tool st-info | ||
*/ | ||
|
||
#ifndef INFO_H | ||
#define INFO_H | ||
|
||
// static void usage(void); | ||
// static void stlink_print_version(stlink_t *sl); | ||
// static void stlink_print_info(stlink_t *sl); | ||
|
||
// static void stlink_probe(enum connect_type connect, int32_t freq) { }; | ||
static int32_t print_data(int32_t ac, char **av); | ||
int32_t main(int32_t ac, char** av); | ||
|
||
#endif // INFO_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.