Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Switch - Software
Commits
2a3a1f9e
Commit
2a3a1f9e
authored
Apr 08, 2020
by
Grzegorz Daniluk
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'greg-fixes' into proposed_master
parents
4f596153
bd7988c6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
8 deletions
+70
-8
config-lpcalib.c
userspace/libwr/config-lpcalib.c
+22
-0
config-lpcalib.h
userspace/libwr/include/libwr/config-lpcalib.h
+2
-0
startup-mb.sh
userspace/rootfs_override/wr/sbin/startup-mb.sh
+1
-0
hal_port_fsm_tx.c
userspace/wrsw_hal/hal_port_fsm_tx.c
+45
-8
No files found.
userspace/libwr/config-lpcalib.c
View file @
2a3a1f9e
...
...
@@ -175,6 +175,28 @@ int cfg_set_int(struct config_file *cfg, const char *key, int value)
return
1
;
}
int
cfg_set_str
(
struct
config_file
*
cfg
,
const
char
*
key
,
char
*
value
)
{
struct
key_value
*
kv
=
cfg_find_key
(
cfg
,
key
,
1
);
if
(
!
kv
)
return
0
;
kv
->
value
=
strdup
(
value
);
return
1
;
}
int
cfg_get_str
(
struct
config_file
*
cfg
,
const
char
*
key
,
char
*
value
)
{
struct
key_value
*
kv
=
cfg_find_key
(
cfg
,
key
,
1
);
if
(
!
kv
)
return
0
;
strcpy
(
value
,
kv
->
value
);
return
1
;
}
int
cfg_save
(
struct
config_file
*
cfg
,
const
char
*
filename
)
{
FILE
*
f
=
fopen
(
filename
,
"wb"
);
...
...
userspace/libwr/include/libwr/config-lpcalib.h
View file @
2a3a1f9e
...
...
@@ -10,6 +10,8 @@ struct config_file;
extern
int
cfg_get_int
(
struct
config_file
*
cfg
,
const
char
*
key
,
int
*
value
);
extern
struct
config_file
*
cfg_load
(
const
char
*
filename
,
int
overwrite
);
extern
int
cfg_set_int
(
struct
config_file
*
cfg
,
const
char
*
key
,
int
value
);
extern
int
cfg_set_str
(
struct
config_file
*
cfg
,
const
char
*
key
,
char
*
value
);
extern
int
cfg_get_str
(
struct
config_file
*
cfg
,
const
char
*
key
,
char
*
value
);
extern
int
cfg_save
(
struct
config_file
*
cfg
,
const
char
*
filename
);
extern
void
cfg_free
(
struct
config_file
*
cfg
);
extern
void
cfg_close
(
struct
config_file
*
cfg
);
...
...
userspace/rootfs_override/wr/sbin/startup-mb.sh
View file @
2a3a1f9e
...
...
@@ -52,6 +52,7 @@ $WR_HOME/bin/load-virtex $FP_FILE
if
[
$?
-eq
0
]
;
then
echo
"load_ok"
>
$LOAD_FPGA_STATUS_FILE
md5sum
$FP_FILE
|
cut
-d
' '
-f
1
>>
$LOAD_FPGA_STATUS_FILE
else
echo
"Fatal: load FPGA failed"
>
& 2
echo
"load_error"
>
$LOAD_FPGA_STATUS_FILE
...
...
userspace/wrsw_hal/hal_port_fsm_tx.c
View file @
2a3a1f9e
...
...
@@ -90,8 +90,9 @@ static fsm_event_table_entry_t port_tx_setup_fsm_events[] = {
// hal_port_rts_state
static
struct
rts_pll_state
_pll_state
;
/* path to the file where Low Phase Drift calib parameters are stored */
static
char
*
_calibrationFileName
=
"/
update
/tx_phase_cal.conf"
;
static
char
*
_calibrationFileName
=
"/
wr/etc
/tx_phase_cal.conf"
;
struct
config_file
*
_calibrationConfig
;
// Calibration config form file
static
char
*
_fpgaStatusFileName
=
"/tmp/load_fpga_status"
;
static
inline
void
updatePllState
(
struct
hal_port_state
*
ps
)
{
// update PLL state once for all ports
...
...
@@ -470,11 +471,32 @@ int hal_port_tx_setup_fsm_run( struct hal_port_state * ps )
return
fsm_generic_run
(
&
ps
->
lpdc
.
txSetupFSM
);
}
static
int
get_fpga_md5
(
char
*
buf
)
{
FILE
*
fpga_status
=
fopen
(
_fpgaStatusFileName
,
"r"
);
if
(
!
fpga_status
)
return
0
;
/* first line is the status */
fscanf
(
fpga_status
,
"%33s
\n
"
,
buf
);
if
(
strncmp
(
buf
,
"load_ok"
,
20
)
||
feof
(
fpga_status
))
{
/* something went wrong and FPGA is not loaded or MD5 not
* present in the file */
fclose
(
fpga_status
);
return
0
;
}
fscanf
(
fpga_status
,
"%33s
\n
"
,
buf
);
fclose
(
fpga_status
);
return
1
;
}
/* if config is present then update the calibration data */
static
void
_load_tx_calibration_file
(
struct
hal_port_state
*
ports
)
{
int
i
=
0
;
halGlobalLPDC_t
*
gl
=
ports
[
0
].
lpdc
.
globalLpdc
;
char
md5
[
33
],
lpdc_md5
[
33
];
// Read calibration file, if it exists
_calibrationConfig
=
cfg_load
(
_calibrationFileName
,
0
);
...
...
@@ -485,7 +507,22 @@ static void _load_tx_calibration_file(struct hal_port_state * ports) {
_calibrationFileName
);
gl
->
calFileSynced
=
0
;
return
;
}
}
/* use tx_phase_cal.conf file only if it was generated for the currently
* running FPGA bitstream */
if
(
get_fpga_md5
(
md5
)
&&
cfg_get_str
(
_calibrationConfig
,
"MD5"
,
lpdc_md5
))
{
if
(
strncmp
(
md5
,
lpdc_md5
,
32
))
{
pr_error
(
"FPGA bitstream MD5 not matching, cannot load LPDC file
\n
"
);
pr_error
(
"loaded md5 = %32s
\n
"
,
md5
);
pr_error
(
"lpdc md5 = %32s
\n
"
,
lpdc_md5
);
cfg_close
(
_calibrationConfig
);
return
;
}
else
pr_info
(
"Matched FPGA bitstream MD5, loading LPDC file
\n
"
);
}
else
{
pr_warning
(
"Can't get MD5 of loaded bitstream
\n
"
);
}
pr_info
(
"Loading LPCD config data from %s
\n
"
,
_calibrationFileName
);
...
...
@@ -528,6 +565,7 @@ static void _write_tx_calibration_file(struct hal_port_state * ps)
{
int
i
;
halGlobalLPDC_t
*
gl
=
ps
->
lpdc
.
globalLpdc
;
char
md5
[
33
];
/* Only the first LPDC-supporting port writes the file. Otherwise,
there is problem with pointers when looping through port structures
...
...
@@ -538,16 +576,15 @@ static void _write_tx_calibration_file(struct hal_port_state * ps)
if
(
gl
->
calFileSynced
)
return
;
if
(
file_exists
(
_calibrationFileName
))
{
pr_warning
(
"Tx calibration file exists, yet it has not been"
" synched. Something seems wrong. Should not get here
\n
"
);
return
;
}
struct
config_file
*
cfg
=
cfg_load
(
_calibrationFileName
,
1
);
struct
hal_port_state
*
_ps
=
ps
;
/* first, store MD5 of the bitstream */
if
(
!
get_fpga_md5
(
md5
))
sprintf
(
md5
,
"ERROR"
);
cfg_set_str
(
cfg
,
"MD5"
,
md5
);
for
(
i
=
gl
->
firstLpdcPort
;
i
<=
gl
->
lastLpdcPort
;
i
++
)
{
if
(
_ps
->
in_use
&&
_ps
->
lpdc
.
isSupported
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment