Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
DIOT Zynq Ultrascale-based System Board
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
9
Issues
9
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Projects
DIOT Zynq Ultrascale-based System Board
Commits
1a673a47
Commit
1a673a47
authored
Jun 30, 2022
by
Adam Wujek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sw/petalinux/diot-util: use PEC for monimod if enabled
Signed-off-by:
Adam Wujek
<
dev_public@wujek.eu
>
parent
e6e095b3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
diot_util_fantray.c
...eta-user/recipes-apps/diot-util/files/diot_util_fantray.c
+35
-0
diot_util_i2c.h
...ec/meta-user/recipes-apps/diot-util/files/diot_util_i2c.h
+1
-0
No files found.
sw/petalinux/project-spec/meta-user/recipes-apps/diot-util/files/diot_util_fantray.c
View file @
1a673a47
...
...
@@ -115,6 +115,7 @@ static int fantray_i2c_reset(void)
{
int
i2cbus
,
i2c_file
;
int
ret
=
0
;
int
use_pec
;
i2cbus
=
atoi
(
FANTRAY_I2C
);
i2c_file
=
open_i2c_dev
(
i2cbus
);
...
...
@@ -126,6 +127,19 @@ static int fantray_i2c_reset(void)
goto
out
;
}
/* If PEC is used by Monimod, it has to be used here too, otherwise writes
* are silently rejected */
/* Read PEC */
use_pec
=
i2c_smbus_read_byte_data
(
i2c_file
,
FANTRAY_I2C_REG_PEC
);
if
(
use_pec
>
0
)
{
/* PEC enabled, use it */
if
(
ioctl
(
i2c_file
,
I2C_PEC
,
1
)
<
0
)
{
printf
(
"Error: Could not set PEC: %s
\n
"
,
strerror
(
errno
));
}
else
{
printf
(
"Using PEC
\n
"
);
}
}
ret
=
i2c_smbus_write_byte_data
(
i2c_file
,
FANTRAY_I2C_REG_RESET
,
UC_RESET_MAGIC
);
...
...
@@ -515,6 +529,7 @@ static int cmd_fantray_load_fw(char *params)
char
*
p
;
FILE
*
fw_file
=
NULL
;
int
errno_local
;
int
use_pec
;
diot_error_clear
();
...
...
@@ -584,6 +599,20 @@ static int cmd_fantray_load_fw(char *params)
if
(
ret
==
FANTRAY_FW_TYPE_MAIN
)
{
printf
(
"Fantray in main mode. Switching to bootloader mode
\n
"
);
/* If PEC is used by Monimod, it has to be used here too otherwise
* writes are silently rejected */
/* Read PEC */
use_pec
=
i2c_smbus_read_byte_data
(
i2c_file
,
FANTRAY_I2C_REG_PEC
);
if
(
use_pec
>
0
)
{
/* PEC enabled, use it */
if
(
ioctl
(
i2c_file
,
I2C_PEC
,
1
)
<
0
)
{
printf
(
"Error: Could not set PEC: %s
\n
"
,
strerror
(
errno
));
use_pec
=
0
;
}
else
{
printf
(
"Using PEC
\n
"
);
}
}
/* Switch to boot loader */
ret
=
i2c_smbus_write_byte_data
(
i2c_file
,
FANTRAY_I2C_REG_BOOT_NEW_FW
,
BOOT_NEW_FW_MAGIC
);
...
...
@@ -592,6 +621,12 @@ static int cmd_fantray_load_fw(char *params)
goto
close_i2c
;
}
/* Disable PEC if was enabled */
if
(
use_pec
>
0
&&
ioctl
(
i2c_file
,
I2C_PEC
,
0
)
<
0
)
{
printf
(
"Error: Could not set PEC: %s
\n
"
,
strerror
(
errno
));
use_pec
=
0
;
}
/* Let the bootloader to start */
sleep
(
2
);
/* Confirm that bootloader is started */
...
...
sw/petalinux/project-spec/meta-user/recipes-apps/diot-util/files/diot_util_i2c.h
View file @
1a673a47
...
...
@@ -36,6 +36,7 @@
#define FANTRAY_I2C_REG_LOCAL_FW_CHKSUM 0xD4
#define FANTRAY_I2C_REG_BOOT_NEW_FW 0xD5
#define FANTRAY_I2C_REG_RESET 0xD6
#define FANTRAY_I2C_REG_PEC 0xD9
#define FANTRAY_FW_TYPE_BOOTLOADER 0x1
#define FANTRAY_FW_TYPE_MAIN 0x2
...
...
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