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
3a1c4549
Commit
3a1c4549
authored
10 years ago
by
Cristian Maglie
Committed by
Cristian Maglie
10 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Bootloader: added multi-page flash write command.
parent
8d22aee1
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
+56
-1
56 additions, 1 deletion
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
56 additions
and
1 deletion
bootloaders/zero/sam_ba_monitor.c
+
56
−
1
View file @
3a1c4549
...
...
@@ -36,7 +36,7 @@
#include
"cdc_enumerate.h"
const
char
RomBOOT_Version
[]
=
SAM_BA_VERSION
;
const
char
RomBOOT_ExtendedCapabilities
[]
=
"[Arduino:X]"
;
const
char
RomBOOT_ExtendedCapabilities
[]
=
"[Arduino:X
Y
]"
;
/* Provides one common interface to handle both USART and USB-CDC */
typedef
struct
...
...
@@ -338,6 +338,61 @@ void sam_ba_monitor_loop(void)
// Notify command completed
ptr_monitor_if
->
putdata
(
"X
\n\r
"
,
3
);
}
else
if
(
command
==
'Y'
)
{
// This command writes the content of a buffer in SRAM into flash memory.
// Syntax: Y[ADDR],0#
// Set the starting address of the SRAM buffer.
// Syntax: Y[ROM_ADDR],[SIZE]#
// Write the first SIZE bytes from the SRAM buffer (previously set) into
// flash memory starting from address ROM_ADDR
static
uint32_t
*
src_buff_addr
=
NULL
;
if
(
current_number
==
0
)
{
// Set buffer address
src_buff_addr
=
ptr_data
;
}
else
{
// Write to flash
uint32_t
size
=
current_number
/
4
;
uint32_t
*
src_addr
=
src_buff_addr
;
uint32_t
*
dst_addr
=
ptr_data
;
// Set automatic page write
NVMCTRL
->
CTRLB
.
bit
.
MANW
=
0
;
// Do writes in pages
while
(
size
)
{
// Execute "PBC" Page Buffer Clear
NVMCTRL
->
CTRLA
.
reg
=
NVMCTRL_CTRLA_CMDEX_KEY
|
NVMCTRL_CTRLA_CMD_PBC
;
while
(
NVMCTRL
->
INTFLAG
.
bit
.
READY
==
0
)
;
// Fill page buffer
uint32_t
i
;
for
(
i
=
0
;
i
<
(
PAGE_SIZE
/
4
)
&&
i
<
size
;
i
++
)
{
dst_addr
[
i
]
=
src_addr
[
i
];
}
// Execute "WP" Write Page
//NVMCTRL->ADDR.reg = ((uint32_t)dst_addr) / 2;
NVMCTRL
->
CTRLA
.
reg
=
NVMCTRL_CTRLA_CMDEX_KEY
|
NVMCTRL_CTRLA_CMD_WP
;
while
(
NVMCTRL
->
INTFLAG
.
bit
.
READY
==
0
)
;
// Advance to next page
dst_addr
+=
i
;
src_addr
+=
i
;
size
-=
i
;
}
}
// Notify command completed
ptr_monitor_if
->
putdata
(
"Y
\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 @
3a1c4549
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