Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
openocd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
card10
openocd
Commits
ee4723c4
Commit
ee4723c4
authored
15 years ago
by
Zachary T Welch
Browse files
Options
Downloads
Patches
Plain Diff
Improve mflash.c command argument parsing.
parent
c63671e4
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/flash/mflash.c
+9
-6
9 additions, 6 deletions
src/flash/mflash.c
with
9 additions
and
6 deletions
src/flash/mflash.c
+
9
−
6
View file @
ee4723c4
...
@@ -716,7 +716,7 @@ static int mg_write_cmd(struct command_context_s *cmd_ctx, char *cmd, char **arg
...
@@ -716,7 +716,7 @@ static int mg_write_cmd(struct command_context_s *cmd_ctx, char *cmd, char **arg
return
ERROR_COMMAND_SYNTAX_ERROR
;
return
ERROR_COMMAND_SYNTAX_ERROR
;
}
}
address
=
strtoul
(
args
[
2
],
NULL
,
0
);
COMMAND_PARSE_NUMBER
(
u32
,
args
[
2
],
address
);
ret
=
fileio_open
(
&
fileio
,
args
[
1
],
FILEIO_READ
,
FILEIO_BINARY
);
ret
=
fileio_open
(
&
fileio
,
args
[
1
],
FILEIO_READ
,
FILEIO_BINARY
);
if
(
ret
!=
ERROR_OK
)
if
(
ret
!=
ERROR_OK
)
...
@@ -783,8 +783,8 @@ static int mg_dump_cmd(struct command_context_s *cmd_ctx, char *cmd, char **args
...
@@ -783,8 +783,8 @@ static int mg_dump_cmd(struct command_context_s *cmd_ctx, char *cmd, char **args
return
ERROR_COMMAND_SYNTAX_ERROR
;
return
ERROR_COMMAND_SYNTAX_ERROR
;
}
}
address
=
strtoul
(
args
[
2
],
NULL
,
0
);
COMMAND_PARSE_NUMBER
(
u32
,
args
[
2
],
address
);
size
=
strtoul
(
args
[
3
],
NULL
,
0
);
COMMAND_PARSE_NUMBER
(
u32
,
args
[
3
],
size
);
ret
=
fileio_open
(
&
fileio
,
args
[
1
],
FILEIO_WRITE
,
FILEIO_BINARY
);
ret
=
fileio_open
(
&
fileio
,
args
[
1
],
FILEIO_WRITE
,
FILEIO_BINARY
);
if
(
ret
!=
ERROR_OK
)
if
(
ret
!=
ERROR_OK
)
...
@@ -1238,7 +1238,9 @@ int mg_config_cmd(struct command_context_s *cmd_ctx, char *cmd,
...
@@ -1238,7 +1238,9 @@ int mg_config_cmd(struct command_context_s *cmd_ctx, char *cmd,
break
;
break
;
case
3
:
case
3
:
if
(
!
strcmp
(
args
[
1
],
"pll"
))
{
if
(
!
strcmp
(
args
[
1
],
"pll"
))
{
fin
=
strtoul
(
args
[
2
],
NULL
,
0
);
unsigned
long
freq
;
COMMAND_PARSE_NUMBER
(
ulong
,
args
[
2
],
freq
);
fin
=
freq
;
if
(
fin
>
MG_PLL_CLK_OUT
)
{
if
(
fin
>
MG_PLL_CLK_OUT
)
{
LOG_ERROR
(
"mflash: input freq. is too large"
);
LOG_ERROR
(
"mflash: input freq. is too large"
);
...
@@ -1288,7 +1290,6 @@ int mflash_init_drivers(struct command_context_s *cmd_ctx)
...
@@ -1288,7 +1290,6 @@ int mflash_init_drivers(struct command_context_s *cmd_ctx)
static
int
mg_bank_cmd
(
struct
command_context_s
*
cmd_ctx
,
char
*
cmd
,
char
**
args
,
int
argc
)
static
int
mg_bank_cmd
(
struct
command_context_s
*
cmd_ctx
,
char
*
cmd
,
char
**
args
,
int
argc
)
{
{
target_t
*
target
;
target_t
*
target
;
char
*
str
;
int
i
;
int
i
;
if
(
argc
<
4
)
if
(
argc
<
4
)
...
@@ -1303,7 +1304,9 @@ static int mg_bank_cmd(struct command_context_s *cmd_ctx, char *cmd, char **args
...
@@ -1303,7 +1304,9 @@ static int mg_bank_cmd(struct command_context_s *cmd_ctx, char *cmd, char **args
}
}
mflash_bank
=
calloc
(
sizeof
(
mflash_bank_t
),
1
);
mflash_bank
=
calloc
(
sizeof
(
mflash_bank_t
),
1
);
mflash_bank
->
base
=
strtoul
(
args
[
1
],
NULL
,
0
);
COMMAND_PARSE_NUMBER
(
u32
,
args
[
1
],
mflash_bank
->
base
);
/// @todo Verify how this parsing should work, then document it.
char
*
str
;
mflash_bank
->
rst_pin
.
num
=
strtoul
(
args
[
2
],
&
str
,
0
);
mflash_bank
->
rst_pin
.
num
=
strtoul
(
args
[
2
],
&
str
,
0
);
if
(
*
str
)
if
(
*
str
)
mflash_bank
->
rst_pin
.
port
[
0
]
=
(
uint16_t
)
tolower
(
str
[
0
]);
mflash_bank
->
rst_pin
.
port
[
0
]
=
(
uint16_t
)
tolower
(
str
[
0
]);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment