Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
202c9e17
Commit
202c9e17
authored
7 years ago
by
kYc0o
Browse files
Options
Downloads
Patches
Plain Diff
tests/periph_flashpage: add write_raw command
parent
cb0d0218
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/periph_flashpage/Makefile
+2
-1
2 additions, 1 deletion
tests/periph_flashpage/Makefile
tests/periph_flashpage/main.c
+40
-0
40 additions, 0 deletions
tests/periph_flashpage/main.c
with
42 additions
and
1 deletion
tests/periph_flashpage/Makefile
+
2
−
1
View file @
202c9e17
...
...
@@ -2,7 +2,8 @@ APPLICATION = periph_flashpage
BOARD
?=
iotlab-m3
include
../Makefile.tests_common
FEATURES_REQUIRED
=
periph_flashpage
FEATURES_REQUIRED
+=
periph_flashpage
FEATURES_OPTIONAL
+=
periph_flashpage_raw
USEMODULE
+=
shell
...
...
This diff is collapsed.
Click to expand it.
tests/periph_flashpage/main.c
+
40
−
0
View file @
202c9e17
...
...
@@ -32,6 +32,20 @@
*/
static
uint8_t
page_mem
[
FLASHPAGE_SIZE
];
#ifdef MODULE_PERIPH_FLASHPAGE_RAW
/*
* @brief Allocate an aligned buffer for raw writings
*/
static
char
raw_buf
[
64
]
__attribute__
((
aligned
(
FLASHPAGE_RAW_ALIGNMENT
)));
static
uint32_t
getaddr
(
const
char
*
str
)
{
uint32_t
addr
=
strtol
(
str
,
NULL
,
16
);
return
addr
;
}
#endif
static
int
getpage
(
const
char
*
str
)
{
int
page
=
atoi
(
str
);
...
...
@@ -164,6 +178,29 @@ static int cmd_write(int argc, char **argv)
return
0
;
}
#ifdef MODULE_PERIPH_FLASHPAGE_RAW
static
int
cmd_write_raw
(
int
argc
,
char
**
argv
)
{
uint32_t
addr
;
if
(
argc
<
3
)
{
printf
(
"usage: %s <addr> <data>
\n
"
,
argv
[
0
]);
return
1
;
}
addr
=
getaddr
(
argv
[
1
]);
/* try to align */
memcpy
(
raw_buf
,
argv
[
2
],
strlen
(
argv
[
2
]));
flashpage_write_raw
((
void
*
)
addr
,
raw_buf
,
strlen
(
raw_buf
));
printf
(
"wrote local data to flash address %#lx of len %u
\n
"
,
addr
,
strlen
(
raw_buf
));
return
0
;
}
#endif
static
int
cmd_erase
(
int
argc
,
char
**
argv
)
{
int
page
;
...
...
@@ -248,6 +285,9 @@ static const shell_command_t shell_commands[] = {
{
"dump_local"
,
"Dump the local page buffer to STDOUT"
,
cmd_dump_local
},
{
"read"
,
"Read and output the given page"
,
cmd_read
},
{
"write"
,
"Write (ASCII) data to the given page"
,
cmd_write
},
#ifdef MODULE_PERIPH_FLASHPAGE_RAW
{
"write_raw"
,
"Write (ASCII, max 64B) data to the given address"
,
cmd_write_raw
},
#endif
{
"erase"
,
"Erase the given page"
,
cmd_erase
},
{
"edit"
,
"Write bytes to the local page"
,
cmd_edit
},
{
"test"
,
"Write and verify test pattern"
,
cmd_test
},
...
...
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