Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
70fc42cb
Commit
70fc42cb
authored
Jun 30, 2015
by
Daniel Campora
Browse files
Options
Downloads
Patches
Plain Diff
cc3200: Add CA, certificate and key files to the updater list.
parent
5ebf3978
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
cc3200/bootmgr/flc.h
+6
-1
6 additions, 1 deletion
cc3200/bootmgr/flc.h
cc3200/ftp/ftp.c
+13
-17
13 additions, 17 deletions
cc3200/ftp/ftp.c
cc3200/ftp/updater.c
+57
-13
57 additions, 13 deletions
cc3200/ftp/updater.c
cc3200/ftp/updater.h
+26
-0
26 additions, 0 deletions
cc3200/ftp/updater.h
with
102 additions
and
31 deletions
cc3200/bootmgr/flc.h
+
6
−
1
View file @
70fc42cb
...
...
@@ -48,12 +48,17 @@ extern "C"
#define IMG_SRVPACK "/sys/servicepack.ucf"
#define SRVPACK_SIGN "/sys/servicepack.sig"
#define CA_FILE "/cert/ca.pem"
#define CERT_FILE "/cert/cert.pem"
#define KEY_FILE "/cert/private.key"
/******************************************************************************
Image
file sizes
Special
file sizes
*******************************************************************************/
#define IMG_SIZE (232 * 1024)
/* 16KB are reserved for the bootloader and at least 8KB for the heap*/
#define SRVPACK_SIZE (16 * 1024)
#define SIGN_SIZE (2 * 1024)
#define CA_KEY_SIZE (4 * 1024)
/******************************************************************************
Active Image
...
...
This diff is collapsed.
Click to expand it.
cc3200/ftp/ftp.c
+
13
−
17
View file @
70fc42cb
...
...
@@ -137,8 +137,7 @@ typedef struct {
uint8_t
e_open
;
bool
closechild
;
bool
enabled
;
bool
swupdating
;
bool
special_file
;
}
ftp_data_t
;
typedef
struct
{
...
...
@@ -243,7 +242,7 @@ void ftp_init (void) {
ftp_data
.
e_open
=
E_FTP_NOTHING_OPEN
;
ftp_data
.
state
=
E_FTP_STE_DISABLED
;
ftp_data
.
substate
.
data
=
E_FTP_STE_SUB_DISCONNECTED
;
ftp_data
.
s
wupdating
=
false
;
ftp_data
.
s
pecial_file
=
false
;
}
void
ftp_run
(
void
)
{
...
...
@@ -325,7 +324,7 @@ void ftp_run (void) {
ftp_data
.
dtimeout
=
0
;
ftp_data
.
ctimeout
=
0
;
// its a software update
if
(
ftp_data
.
s
wupdating
)
{
if
(
ftp_data
.
s
pecial_file
)
{
if
(
updater_write
(
ftp_data
.
dBuffer
,
len
))
{
break
;
}
...
...
@@ -345,8 +344,8 @@ void ftp_run (void) {
}
}
else
{
if
(
ftp_data
.
s
wupdating
)
{
ftp_data
.
s
wupdating
=
false
;
if
(
ftp_data
.
s
pecial_file
)
{
ftp_data
.
s
pecial_file
=
false
;
updater_finnish
();
}
ftp_close_files
();
...
...
@@ -578,8 +577,8 @@ static void ftp_send_from_fifo (void) {
// close the listening and the data sockets
servers_close_socket
(
&
ftp_data
.
ld_sd
);
servers_close_socket
(
&
ftp_data
.
d_sd
);
if
(
ftp_data
.
s
wupdating
)
{
ftp_data
.
s
wupdating
=
false
;
if
(
ftp_data
.
s
pecial_file
)
{
ftp_data
.
s
pecial_file
=
false
;
}
}
}
...
...
@@ -759,11 +758,8 @@ static void ftp_process_cmd (void) {
ftp_get_param_and_open_child
(
&
bufptr
);
// first check if a software update is being requested
if
(
updater_check_path
(
ftp_path
))
{
// start by erasing the previous status file
// must be done before starting the updater
f_unlink
(
ftp_path
);
if
(
updater_start
())
{
ftp_data
.
s
wupdating
=
true
;
ftp_data
.
s
pecial_file
=
true
;
ftp_data
.
state
=
E_FTP_STE_CONTINUE_FILE_RX
;
ftp_send_reply
(
150
,
NULL
);
}
...
...
@@ -861,9 +857,9 @@ static void ftp_close_files (void) {
static
void
ftp_close_filesystem_on_error
(
void
)
{
ftp_close_files
();
if
(
ftp_data
.
s
wupdating
)
{
if
(
ftp_data
.
s
pecial_file
)
{
updater_finnish
();
ftp_data
.
s
wupdating
=
false
;
ftp_data
.
s
pecial_file
=
false
;
}
}
...
...
This diff is collapsed.
Click to expand it.
cc3200/ftp/updater.c
+
57
−
13
View file @
70fc42cb
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2015 Daniel Campora
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include
<stdint.h>
#include
<stdbool.h>
...
...
@@ -18,6 +44,9 @@
#define UPDATER_IMG_PATH "/flash/sys/mcuimg.bin"
#define UPDATER_SRVPACK_PATH "/flash/sys/servicepack.ucf"
#define UPDATER_SIGN_PATH "/flash/sys/servicepack.sig"
#define UPDATER_CA_PATH "/flash/cert/ca.pem"
#define UPDATER_CERT_PATH "/flash/cert/cert.pem"
#define UPDATER_KEY_PATH "/flash/cert/private.key"
/******************************************************************************
DEFINE TYPES
...
...
@@ -41,24 +70,32 @@ bool updater_check_path (void *path) {
if
(
!
strcmp
(
UPDATER_IMG_PATH
,
path
))
{
updater_data
.
path
=
IMG_UPDATE
;
updater_data
.
fsize
=
IMG_SIZE
;
return
true
;
}
else
if
(
!
strcmp
(
UPDATER_SRVPACK_PATH
,
path
))
{
}
else
if
(
!
strcmp
(
UPDATER_SRVPACK_PATH
,
path
))
{
updater_data
.
path
=
IMG_SRVPACK
;
updater_data
.
fsize
=
SRVPACK_SIZE
;
return
true
;
}
else
if
(
!
strcmp
(
UPDATER_SIGN_PATH
,
path
))
{
}
else
if
(
!
strcmp
(
UPDATER_SIGN_PATH
,
path
))
{
updater_data
.
path
=
SRVPACK_SIGN
;
updater_data
.
fsize
=
SIGN_SIZE
;
return
true
;
}
}
else
if
(
!
strcmp
(
UPDATER_CA_PATH
,
path
))
{
updater_data
.
path
=
CA_FILE
;
updater_data
.
fsize
=
CA_KEY_SIZE
;
}
else
if
(
!
strcmp
(
UPDATER_CERT_PATH
,
path
))
{
updater_data
.
path
=
CERT_FILE
;
updater_data
.
fsize
=
CA_KEY_SIZE
;
}
else
if
(
!
strcmp
(
UPDATER_KEY_PATH
,
path
))
{
updater_data
.
path
=
KEY_FILE
;
updater_data
.
fsize
=
CA_KEY_SIZE
;
}
else
{
return
false
;
}
return
true
;
}
bool
updater_start
(
void
)
{
_u32
AccessModeAndMaxSize
=
FS_MODE_OPEN_WRITE
;
SlFsFileInfo_t
FsFileInfo
;
bool
result
=
false
;
sl_LockObjLock
(
&
wlan_LockObj
,
SL_OS_WAIT_FOREVER
);
if
(
0
!=
sl_FsGetInfo
((
_u8
*
)
updater_data
.
path
,
0
,
&
FsFileInfo
))
{
// file doesn't exist, create it
...
...
@@ -66,18 +103,24 @@ bool updater_start (void) {
}
if
(
!
sl_FsOpen
((
_u8
*
)
updater_data
.
path
,
AccessModeAndMaxSize
,
NULL
,
&
updater_data
.
fhandle
))
{
updater_data
.
foffset
=
0
;
re
turn
true
;
re
sult
=
true
;
}
sl_LockObjUnlock
(
&
wlan_LockObj
);
return
false
;
return
result
;
}
bool
updater_write
(
uint8_t
*
buf
,
uint32_t
len
)
{
bool
result
=
false
;
sl_LockObjLock
(
&
wlan_LockObj
,
SL_OS_WAIT_FOREVER
);
if
(
len
==
sl_FsWrite
(
updater_data
.
fhandle
,
updater_data
.
foffset
,
buf
,
len
))
{
updater_data
.
foffset
+=
len
;
re
turn
true
;
re
sult
=
true
;
}
return
false
;
sl_LockObjUnlock
(
&
wlan_LockObj
);
return
result
;
}
void
updater_finnish
(
void
)
{
...
...
@@ -85,6 +128,7 @@ void updater_finnish (void) {
_i32
fhandle
;
if
(
updater_data
.
fhandle
>
0
)
{
sl_LockObjLock
(
&
wlan_LockObj
,
SL_OS_WAIT_FOREVER
);
// close the file being updated
sl_FsClose
(
updater_data
.
fhandle
,
NULL
,
NULL
,
0
);
...
...
@@ -108,7 +152,7 @@ void updater_finnish (void) {
ASSERT
(
sizeof
(
sBootInfo_t
)
==
sl_FsWrite
(
fhandle
,
0
,
(
unsigned
char
*
)
&
sBootInfo
,
sizeof
(
sBootInfo_t
)));
sl_FsClose
(
fhandle
,
0
,
0
,
0
);
}
sl_LockObjUnlock
(
&
wlan_LockObj
);
}
updater_data
.
fhandle
=
-
1
;
sl_LockObjUnlock
(
&
wlan_LockObj
);
}
This diff is collapsed.
Click to expand it.
cc3200/ftp/updater.h
+
26
−
0
View file @
70fc42cb
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2015 Daniel Campora
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef UPDATER_H_
#define UPDATER_H_
...
...
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