cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
huojianyu
Observer
Observer
932 Views
Registered: ‎09-08-2019

Problems with patching fsbl in petalinux

Hi,

I need modify some fsbl code and create a patch for petalinux. I followed the tutorial below but it seems not working. The patch cannot be interpreted.  What's the problem?

By the way, I think source code of fsbl in petalinux install directory is not in a git repo, is the git patch valid?

Thanks in advance!

Tutorial:https://www.beyond-circuits.com/wordpress/2018/05/updating-the-first-stage-bootloader-in-petalinux-v2017-4/ 

patch file:

From 6a4dcf67827814d0d497898dd3eb6b6e584eb592 Mon Sep 17 00:00:00 2001
From: Jianyu Huo <huojianyu@baidu.com>
Date: Mon, 28 Oct 2019 17:14:41 +0800
Subject: [PATCH] set qspi prescale to 2

---
 lib/sw_apps/zynqmp_fsbl/src/xfsbl_qspi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/sw_apps/zynqmp_fsbl/src/xfsbl_qspi.c b/lib/sw_apps/zynqmp_fsbl/src/xfsbl_qspi.c
index 13b98cf..fb37f55 100644
--- a/lib/sw_apps/zynqmp_fsbl/src/xfsbl_qspi.c
+++ b/lib/sw_apps/zynqmp_fsbl/src/xfsbl_qspi.c
@@ -250,7 +250,7 @@ u32 XFsbl_Qspi24Init(u32 DeviceFlags)
 	/*
 	 * Set the pre-scaler for QSPI clock
 	 */
-	Status = XQspiPsu_SetClkPrescaler(&QspiPsuInstance, XQSPIPSU_CLK_PRESCALE_8);
+	Status = XQspiPsu_SetClkPrescaler(&QspiPsuInstance, XQSPIPSU_CLK_PRESCALE_2);
 
 	if (Status != XFSBL_SUCCESS) {
 		UStatus = XFSBL_ERROR_QSPI_PRESCALER_CLK;
@@ -864,7 +864,7 @@ u32 XFsbl_Qspi32Init(u32 DeviceFlags)
 	/*
 	 * Set the pre-scaler for QSPI clock
 	 */
-	Status = XQspiPsu_SetClkPrescaler(&QspiPsuInstance, XQSPIPSU_CLK_PRESCALE_8);
+	Status = XQspiPsu_SetClkPrescaler(&QspiPsuInstance, XQSPIPSU_CLK_PRESCALE_2);
 
 	if (Status != XFSBL_SUCCESS) {
 		UStatus = XFSBL_ERROR_QSPI_PRESCALER_CLK;
-- 
2.7.4

fsbl_%.bbappend:

# Patch for FSBL
# Note: do_configure_prepend task section is required only for 2017.1 release
# Refer https://github.com/Xilinx/meta-xilinx-tools/blob/rel-v2017.2/classes/xsctbase.bbclass#L29-L35
 
do_configure() {
    if [ -d "${S}/patches" ]; then
       rm -rf ${S}/patches
    fi
 
    if [ -d "${S}/.pc" ]; then
       rm -rf ${S}/.pc
    fi
}
 
SRC_URI_append = " \
        0001-set-qspi-prescale-to-2.patch \
        "
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
  
#Add debug for FSBL(optional)
XSCTH_BUILD_DEBUG = "1"
  
#Enable appropriate FSBL debug flags
YAML_COMPILER_FLAGS_append = " -DXPS_BOARD_ZCU102"
  
# Note: This is not required if you are using Yocto
# CAUTION!: EXTERNALXSCTSRC and EXTERNALXSCTSRC_BUILD is required only for 2018.2 and below petalinux releases
EXTERNALXSCTsrc=""
EXTERNALXSCTSRC_BUILD = "" 
0 Kudos
3 Replies
gudishak
Moderator
Moderator
879 Views
Registered: ‎06-27-2017

Hi @huojianyu ,

Have you refered below link?

https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842475/PetaLinux+Yocto+Tips#PetaLinuxYoctoTips-HowtopatchFSBLinPetaLinuxProject

Best Regards
Kranthi
--------------------------
Don't forget to reply, kudo, and accept as solution.
0 Kudos
gudishak
Moderator
Moderator
878 Views
Registered: ‎06-27-2017

Hi @huojianyu ,

Also please refer below forum thread which discussed similar topic.

https://forums.xilinx.com/t5/Embedded-Linux/How-to-regenerate-FSBL-code-in-petalinux/td-p/984919

Best Regards
Kranthi
--------------------------
Don't forget to reply, kudo, and accept as solution.
0 Kudos
huojianyu
Observer
Observer
811 Views
Registered: ‎09-08-2019

Thanks aravindb. I followed the two links to generate patch, but it did same.

Actually, I have found the problem that the format of my patch was wrong. I remove the first and the last several lines and it works fine. I think it is caused by the different configuration or version of git. Below is the new patch.

diff --git a/lib/sw_apps/zynqmp_fsbl/src/xfsbl_qspi.c b/lib/sw_apps/zynqmp_fsbl/src/xfsbl_qspi.c
index 13b98cf..fb37f55 100644
--- a/lib/sw_apps/zynqmp_fsbl/src/xfsbl_qspi.c
+++ b/lib/sw_apps/zynqmp_fsbl/src/xfsbl_qspi.c
@@ -250,7 +250,7 @@ u32 XFsbl_Qspi24Init(u32 DeviceFlags)
 	/*
 	 * Set the pre-scaler for QSPI clock
 	 */
-	Status = XQspiPsu_SetClkPrescaler(&QspiPsuInstance, XQSPIPSU_CLK_PRESCALE_8);
+	Status = XQspiPsu_SetClkPrescaler(&QspiPsuInstance, XQSPIPSU_CLK_PRESCALE_2);
 
 	if (Status != XFSBL_SUCCESS) {
 		UStatus = XFSBL_ERROR_QSPI_PRESCALER_CLK;
@@ -864,7 +864,7 @@ u32 XFsbl_Qspi32Init(u32 DeviceFlags)
 	/*
 	 * Set the pre-scaler for QSPI clock
 	 */
-	Status = XQspiPsu_SetClkPrescaler(&QspiPsuInstance, XQSPIPSU_CLK_PRESCALE_8);
+	Status = XQspiPsu_SetClkPrescaler(&QspiPsuInstance, XQSPIPSU_CLK_PRESCALE_2);
 
 	if (Status != XFSBL_SUCCESS) {
 		UStatus = XFSBL_ERROR_QSPI_PRESCALER_CLK;
0 Kudos