Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ch32v003fun
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
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Andreas Horn
ch32v003fun
Commits
49e75d02
Commit
49e75d02
authored
1 year ago
by
cnlohr
Browse files
Options
Downloads
Patches
Plain Diff
Fix a little OOO for ESP32S2 programmer + use 64-byte ops when it makes sense for flash writing.
parent
ae422f12
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
minichlink/minichlink.c
+18
-10
18 additions, 10 deletions
minichlink/minichlink.c
minichlink/pgm-esp32s2-ch32xx.c
+5
-2
5 additions, 2 deletions
minichlink/pgm-esp32s2-ch32xx.c
with
23 additions
and
12 deletions
minichlink/minichlink.c
+
18
−
10
View file @
49e75d02
...
@@ -1052,23 +1052,31 @@ int DefaultWriteBinaryBlob( void * dev, uint32_t address_to_write, uint32_t blob
...
@@ -1052,23 +1052,31 @@ int DefaultWriteBinaryBlob( void * dev, uint32_t address_to_write, uint32_t blob
{
{
MCF
.
ReadBinaryBlob
(
dev
,
base
,
64
,
tempblock
);
MCF
.
ReadBinaryBlob
(
dev
,
base
,
64
,
tempblock
);
MCF
.
Erase
(
dev
,
base
,
64
,
0
);
MCF
.
WriteWord
(
dev
,
0x40022010
,
CR_PAGE_PG
);
// THIS IS REQUIRED, (intptr_t)&FLASH->CTLR = 0x40022010
MCF
.
WriteWord
(
dev
,
0x40022010
,
CR_BUF_RST
|
CR_PAGE_PG
);
// (intptr_t)&FLASH->CTLR = 0x40022010
// Permute tempblock
// Permute tempblock
int
tocopy
=
end_o_plus_one_in_block
-
offset_in_block
;
int
tocopy
=
end_o_plus_one_in_block
-
offset_in_block
;
memcpy
(
tempblock
+
offset_in_block
,
blob
+
rsofar
,
tocopy
);
memcpy
(
tempblock
+
offset_in_block
,
blob
+
rsofar
,
tocopy
);
rsofar
+=
tocopy
;
rsofar
+=
tocopy
;
int
j
;
if
(
MCF
.
BlockWrite64
)
for
(
j
=
0
;
j
<
16
;
j
++
)
{
{
MCF
.
WriteWord
(
dev
,
j
*
4
+
base
,
*
(
uint32_t
*
)(
tempblock
+
j
*
4
)
);
int
r
=
MCF
.
BlockWrite64
(
dev
,
base
,
tempblock
);
rsofar
+=
4
;
if
(
r
)
return
r
;
}
else
{
MCF
.
Erase
(
dev
,
base
,
64
,
0
);
MCF
.
WriteWord
(
dev
,
0x40022010
,
CR_PAGE_PG
);
// THIS IS REQUIRED, (intptr_t)&FLASH->CTLR = 0x40022010
MCF
.
WriteWord
(
dev
,
0x40022010
,
CR_BUF_RST
|
CR_PAGE_PG
);
// (intptr_t)&FLASH->CTLR = 0x40022010
int
j
;
for
(
j
=
0
;
j
<
16
;
j
++
)
{
MCF
.
WriteWord
(
dev
,
j
*
4
+
base
,
*
(
uint32_t
*
)(
tempblock
+
j
*
4
)
);
rsofar
+=
4
;
}
MCF
.
WriteWord
(
dev
,
0x40022014
,
base
);
//0x40022014 -> FLASH->ADDR
MCF
.
WriteWord
(
dev
,
0x40022010
,
CR_PAGE_PG
|
CR_STRT_Set
);
// 0x40022010 -> FLASH->CTLR
}
}
MCF
.
WriteWord
(
dev
,
0x40022014
,
base
);
//0x40022014 -> FLASH->ADDR
MCF
.
WriteWord
(
dev
,
0x40022010
,
CR_PAGE_PG
|
CR_STRT_Set
);
// 0x40022010 -> FLASH->CTLR
if
(
MCF
.
WaitForFlash
&&
MCF
.
WaitForFlash
(
dev
)
)
goto
timedout
;
if
(
MCF
.
WaitForFlash
&&
MCF
.
WaitForFlash
(
dev
)
)
goto
timedout
;
}
}
else
else
...
...
This diff is collapsed.
Click to expand it.
minichlink/pgm-esp32s2-ch32xx.c
+
5
−
2
View file @
49e75d02
...
@@ -256,6 +256,7 @@ int ESPBlockWrite64( void * dev, uint32_t address_to_write, uint8_t * data )
...
@@ -256,6 +256,7 @@ int ESPBlockWrite64( void * dev, uint32_t address_to_write, uint8_t * data )
if
(
timeout
>
1000
)
if
(
timeout
>
1000
)
{
{
fprintf
(
stderr
,
"Error: Timed out block-writing 64
\n
"
);
fprintf
(
stderr
,
"Error: Timed out block-writing 64
\n
"
);
return
-
49
;
}
}
}
while
(
eps
->
replylen
<
2
);
}
while
(
eps
->
replylen
<
2
);
...
@@ -364,7 +365,8 @@ int ESPPollTerminal( void * dev, uint8_t * buffer, int maxlen, uint32_t leavefla
...
@@ -364,7 +365,8 @@ int ESPPollTerminal( void * dev, uint8_t * buffer, int maxlen, uint32_t leavefla
int
rlen
=
eps
->
reply
[
0
];
int
rlen
=
eps
->
reply
[
0
];
if
(
rlen
<
1
)
return
-
8
;
if
(
rlen
<
1
)
return
-
8
;
/*
#if 0
int i;
int i;
printf( "RESP (ML %d): %d\n", maxlen,eps->reply[0] );
printf( "RESP (ML %d): %d\n", maxlen,eps->reply[0] );
...
@@ -375,7 +377,8 @@ int ESPPollTerminal( void * dev, uint8_t * buffer, int maxlen, uint32_t leavefla
...
@@ -375,7 +377,8 @@ int ESPPollTerminal( void * dev, uint8_t * buffer, int maxlen, uint32_t leavefla
if( (i % 16) == 15 ) printf( "\n" );
if( (i % 16) == 15 ) printf( "\n" );
}
}
printf( "\n" );
printf( "\n" );
*/
#endif
int
errc
=
eps
->
reply
[
1
];
int
errc
=
eps
->
reply
[
1
];
if
(
errc
>
7
)
return
-
7
;
if
(
errc
>
7
)
return
-
7
;
...
...
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