Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Arduino Core for SAMD21 CPU
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
josc941e
Arduino Core for SAMD21 CPU
Commits
f7faa197
Commit
f7faa197
authored
10 years ago
by
Cristian Maglie
Committed by
Cristian Maglie
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Bootloader: added erase flash command.
parent
0e4e0a97
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bootloaders/zero/sam_ba_monitor.c
+33
-0
33 additions, 0 deletions
bootloaders/zero/sam_ba_monitor.c
bootloaders/zero/samd21_sam_ba.bin
+0
-0
0 additions, 0 deletions
bootloaders/zero/samd21_sam_ba.bin
with
33 additions
and
0 deletions
bootloaders/zero/sam_ba_monitor.c
+
33
−
0
View file @
f7faa197
...
...
@@ -36,6 +36,7 @@
#include
"cdc_enumerate.h"
const
char
RomBOOT_Version
[]
=
SAM_BA_VERSION
;
const
char
RomBOOT_ExtendedCapabilities
[]
=
"[Arduino:X]"
;
/* Provides one common interface to handle both USART and USB-CDC */
typedef
struct
...
...
@@ -166,12 +167,18 @@ uint8_t command, *ptr_data, *ptr, data[SIZEBUFMAX];
uint8_t
j
;
uint32_t
u32tmp
;
uint32_t
PAGE_SIZE
,
PAGES
,
MAX_FLASH
;
/**
* \brief This function starts the SAM-BA monitor.
*/
void
sam_ba_monitor_run
(
void
)
{
uint32_t
pageSizes
[]
=
{
8
,
16
,
32
,
64
,
128
,
256
,
512
,
1024
};
PAGE_SIZE
=
pageSizes
[
NVMCTRL
->
PARAM
.
bit
.
PSZ
];
PAGES
=
NVMCTRL
->
PARAM
.
bit
.
NVMP
;
MAX_FLASH
=
PAGE_SIZE
*
PAGES
;
ptr_data
=
NULL
;
command
=
'z'
;
while
(
1
)
{
...
...
@@ -277,6 +284,9 @@ void sam_ba_monitor_loop(void)
ptr_monitor_if
->
putdata
((
uint8_t
*
)
RomBOOT_Version
,
strlen
(
RomBOOT_Version
));
ptr_monitor_if
->
putdata
(
" "
,
1
);
ptr_monitor_if
->
putdata
((
uint8_t
*
)
RomBOOT_ExtendedCapabilities
,
strlen
(
RomBOOT_ExtendedCapabilities
));
ptr_monitor_if
->
putdata
(
" "
,
1
);
ptr
=
(
uint8_t
*
)
&
(
__DATE__
);
i
=
0
;
while
(
*
ptr
++
!=
'\0'
)
...
...
@@ -290,6 +300,29 @@ void sam_ba_monitor_loop(void)
ptr_monitor_if
->
putdata
((
uint8_t
*
)
&
(
__TIME__
),
i
);
ptr_monitor_if
->
putdata
(
"
\n\r
"
,
2
);
}
else
if
(
command
==
'X'
)
{
// Syntax: X[ADDR]#
// Erase the flash memory starting from ADDR to the end of flash.
// Note: the flash memory is erased in ROWS, that is in block of 4 pages.
// Even if the starting address is the last byte of a ROW the entire
// ROW is erased anyway.
uint32_t
dst_addr
=
current_number
;
// starting address
while
(
dst_addr
<
MAX_FLASH
)
{
// Execute "ER" Erase Row
NVMCTRL
->
ADDR
.
reg
=
dst_addr
/
2
;
NVMCTRL
->
CTRLA
.
reg
=
NVMCTRL_CTRLA_CMDEX_KEY
|
NVMCTRL_CTRLA_CMD_ER
;
while
(
NVMCTRL
->
INTFLAG
.
bit
.
READY
==
0
)
;
dst_addr
+=
PAGE_SIZE
*
4
;
// Skip a ROW
}
// Notify command completed
ptr_monitor_if
->
putdata
(
"X
\n\r
"
,
3
);
}
command
=
'z'
;
current_number
=
0
;
...
...
This diff is collapsed.
Click to expand it.
bootloaders/zero/samd21_sam_ba.bin
+
0
−
0
View file @
f7faa197
No preview for this file type
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