From patchwork Thu Jan 11 11:06:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1885491 X-Patchwork-Delegate: festevam@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=efyt/nr4; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=jsdTvPJr; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T9hgf0gSTz1yPw for ; Thu, 11 Jan 2024 22:06:38 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 16C7687A4B; Thu, 11 Jan 2024 12:06:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1704971194; bh=pkKdlSrqyL9/S8Lutqau0MQcWDJBcoh6KpI4PysurG0=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=efyt/nr4Ad9Stls2lB0Q4hg495PSBaKopX4sbOWNfxr9tYWycOXzcbp4oEmpxhi9a Rv5xFzfypnNIjz4QKjjr+NGs0HAOVcgddSG2bJl4ItWE5ZmNnz/ZKWHaL/bvnWeLXs HNPnMQ5szjbG8xW/rkcHeW403D3KjO1U1YpbfpA+HQW2m8eK2ruL950imMdXqivBoL hFMul/nDlXpLWlwnJSBFc7cYJrC7fMxEOdEyhtmCTDlBxfXRKb1ywMcz+GwD01qYTk 7TRg9dO8vq8n8cHMuywYQNGv0JqT4+U3IH9t+Bl5N/QqKkGPGgNpYXBFLh5V5bBXec QORfcjNtp1yJA== Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id A960C87887; Thu, 11 Jan 2024 12:06:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1704971193; bh=pkKdlSrqyL9/S8Lutqau0MQcWDJBcoh6KpI4PysurG0=; h=From:To:Cc:Subject:Date:From; b=jsdTvPJrcRwsU4eCpK9rd50jGO4t7IgKao2ba8IoGJUAjcKXoWAe/i10nPujtp01B EkCy35w0H2QMDojjNXE+cWPHY4bJ1hNFH9rUGngBfFwAGQj2Z+Gv3bRnOiGaojOuH8 B9+W2i7ENWKV8mTIB+SXcWay7dt+gkUePBshSYM9sdmkO0btcsW+9aielrOmBPFkBx OadPw6jMOL6RRxrUx2zy9kLWnjBQCYrLSDX84rYhn1w8kRG/isBkYmmzlnHTBhdAm3 QEp4PBj1NzNy9Iq13vrClC/MyF7es7C55TIu2yawYkLUewkH91u6CwM13ELu2L3Xoh Par9ns5egI3cw== From: Lukasz Majewski To: Stefano Babic , Fabio Estevam , Tom Rini , u-boot@lists.denx.de, NXP u-boot Cc: Lukasz Majewski Subject: [PATCH v2 1/3] arm: xea: Move XEA's environment variables from xea.h to xea.env Date: Thu, 11 Jan 2024 12:06:09 +0100 Message-Id: <20240111110611.2051821-1-lukma@denx.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The default set of environment variables from CFG_EXTRA_ENV_SETTINGS has been moved to a separate file - board/liebherr/xea/xea.env Adjustments done: - fitImage support - SPI-NOR layout re-organization Signed-off-by: Lukasz Majewski --- (no changes since v1) board/liebherr/xea/xea.env | 141 +++++++++++++++++++++++++++++++++++++ include/configs/xea.h | 140 ------------------------------------ 2 files changed, 141 insertions(+), 140 deletions(-) create mode 100644 board/liebherr/xea/xea.env diff --git a/board/liebherr/xea/xea.env b/board/liebherr/xea/xea.env new file mode 100644 index 0000000000..7dcc122626 --- /dev/null +++ b/board/liebherr/xea/xea.env @@ -0,0 +1,141 @@ +bootmode=update +bootpri=mmc_mmc +bootsec=sf_swu +consdev=ttyAMA0 +baudrate=115200 +rootdev=/dev/mmcblk0p2 +netdev=eth0 +swufile=swupdate-image-xea-upd.itb +sf_kernel_offset=0xA0000 +sf_swu_size=0xF40000 +ethact=FEC +arch=xea +serverip=10.8.217.79 +nfs_serverip=10.8.218.113 +gatewayip=10.8.209.250 +lwe_env= + if dhcp ${loadaddr} ${hostname}/${lwe_uenv} ; then + source ${loadaddr}; + fi +lwe_uenv=env_uboot_xea.bin +do_update_mmc= + if mmc rescan ; then + mmc dev 0 ${update_mmc_part} ; + if dhcp ${hostname}/${update_filename} ; then + setexpr fw_sz ${filesize} / 0x200 ; + setexpr fw_sz ${fw_sz} + 1 ; + mmc write ${loadaddr} ${update_offset} ${fw_sz} ; + fi ; + fi +do_update_sf= + if sf probe ; then + if dhcp ${hostname}/${update_filename} ; then + sf erase ${update_offset} +${filesize} ; + sf write ${loadaddr} ${update_offset} ${filesize} ; + fi ; + fi +factory_reset= + if sf probe ; then + run update_swu ; + setenv bootmode update ; + saveenv ; + fi +update_spl_filename=u-boot.sb +update_spl= + setenv update_filename ${update_spl_filename} ; + setenv update_offset 0 ; + run do_update_sf +update_uboot_filename=u-boot.img +update_uboot= + setenv update_filename ${update_uboot_filename} ; + setenv update_offset 0x10000 ; + run do_update_sf ; + setenv update_mmc_part 1 ; + setenv update_offset 0 ; + run do_update_mmc ; + setenv update_mmc_part 2 ; + run do_update_mmc +update_kernel_filename=uImage +update_kernel= + setenv update_mmc_part 1 ; + setenv update_filename ${update_kernel_filename} ; + setenv update_offset 0x800 ; + run do_update_mmc ; + setenv update_filename ${dtbfile} ; + setenv update_offset 0x400 ; + run do_update_mmc +update_swu= + setenv update_filename ${swufile} ; + setenv update_offset ${sf_kernel_offset} ; + run do_update_sf +addcons= + setenv bootargs ${bootargs} + console=${consdev},${baudrate} +addip= + setenv bootargs ${bootargs} + ip=${ipaddr}:${serverip}:${gatewayip}: + ${netmask}:${hostname}:${netdev}:off +addmisc= + setenv bootargs ${bootargs} ${miscargs} +addargs=run addcons addmisc +mmcload= + mmc rescan ; + mmc dev 0 1 ; + mmc read ${loadaddr} 0x800 0x2000 ; + mmc read ${dtbaddr} 0x400 0x80 +netload= + dhcp ${loadaddr} ${hostname}/${bootfile} ; + tftp ${dtbaddr} ${hostname}/${dtbfile} +usbload= + usb start ; + load usb 0:1 ${loadaddr} ${bootfile} +miscargs=panic=1 +mmcargs=setenv bootargs root=${rootdev} rw rootwait +nfsargs= + setenv bootargs root=/dev/nfs rw + nfsroot=${serverip}:${rootpath},v3,tcp +mmc_mmc= + if run mmcload mmcargs addargs ; then + bootm ${loadaddr} - ${dtbaddr} ; + fi +mmc_nfs= + if run mmcload nfsargs addip addargs ; then + bootm ${loadaddr} - ${dtbaddr} ; + fi +sf_mmc= + if run sfload mmcargs addargs ; then + bootm ${loadaddr} - ${dtbaddr} ; + fi +sf_swu= + if sf probe ; then + sf read ${loadaddr} ${sf_kernel_offset} ${sf_swu_size} ; + setenv bootargs root=/dev/ram0 rw ; + run addargs ; + bootm ${loadaddr} ; + fi +net_mmc= + if run netload mmcargs addargs ; then + bootm ${loadaddr} - ${dtbaddr} ; + fi +net_nfs= + if run netload nfsargs addip addargs ; then + bootm ${loadaddr} - ${dtbaddr} ; + fi +prebootcmd= + if test ${envsaved} != y ; then ; + setenv envsaved y ; + saveenv ; + fi ; + if test ${bootmode} = normal ; then + setenv bootdelay 0 ; + setenv bootpri mmc_mmc ; + elif test ${bootmode} = devel ; then + setenv bootdelay 3 ; + setenv bootpri net_mmc ; + else + if test ${bootmode} != update ; then + echo Warning: unknown bootmode ${bootmode} ; + fi ; + setenv bootdelay 1 ; + setenv bootpri sf_swu ; + fi diff --git a/include/configs/xea.h b/include/configs/xea.h index 04ca5aa12a..00d6274873 100644 --- a/include/configs/xea.h +++ b/include/configs/xea.h @@ -25,146 +25,6 @@ #define PHYS_SDRAM_1_SIZE 0x10000000 /* Max 256 MB RAM */ #define CFG_SYS_SDRAM_BASE PHYS_SDRAM_1 -/* Extra Environment */ - -#define CFG_EXTRA_ENV_SETTINGS \ - "bootmode=update\0" \ - "bootpri=mmc_mmc\0" \ - "bootsec=sf_swu\0" \ - "consdev=ttyAMA0\0" \ - "baudrate=115200\0" \ - "dtbaddr=0x44000000\0" \ - "dtbfile=imx28-xea.dtb\0" \ - "rootdev=/dev/mmcblk0p2\0" \ - "netdev=eth0\0" \ - "rdaddr=0x43000000\0" \ - "swufile=swupdate.img\0" \ - "sf_kernel_offset=0x100000\0" \ - "sf_kernel_size=0x400000\0" \ - "sf_swu_offset=0x500000\0" \ - "sf_swu_size=0x800000\0" \ - "rootpath=/opt/eldk-5.5/armv5te/rootfs-qte-sdk\0" \ - "do_update_mmc=" \ - "if mmc rescan ; then " \ - "mmc dev 0 ${update_mmc_part} ; " \ - "if dhcp ${hostname}/${update_filename} ; then " \ - "setexpr fw_sz ${filesize} / 0x200 ; " /* SD block size */ \ - "setexpr fw_sz ${fw_sz} + 1 ; " \ - "mmc write ${loadaddr} ${update_offset} ${fw_sz} ; " \ - "fi ; " \ - "fi\0" \ - "do_update_sf=" \ - "if sf probe ; then " \ - "if dhcp ${hostname}/${update_filename} ; then " \ - "sf erase ${update_offset} +${filesize} ; " \ - "sf write ${loadaddr} ${update_offset} ${filesize} ; " \ - "fi ; " \ - "fi\0" \ - "update_spl_filename=u-boot.sb\0" \ - "update_spl=" \ - "setenv update_filename ${update_spl_filename} ; " \ - "setenv update_offset 0 ; " \ - "run do_update_sf\0" \ - "update_uboot_filename=u-boot.img\0" \ - "update_uboot=" \ - "setenv update_filename ${update_uboot_filename} ; " \ - "setenv update_offset 0x10000 ; " \ - "run do_update_sf ; " \ - "setenv update_mmc_part 1 ; " \ - "setenv update_offset 0 ; " \ - "run do_update_mmc\0" \ - "update_kernel_filename=uImage\0" \ - "update_kernel=" \ - "setenv update_mmc_part 1 ; " \ - "setenv update_filename ${update_kernel_filename} ; " \ - "setenv update_offset 0x800 ; " \ - "run do_update_mmc ; " \ - "setenv update_filename ${dtbfile} ; " \ - "setenv update_offset 0x400 ; " \ - "run do_update_mmc\0" \ - "update_sfkernel=" \ - "setenv update_filename fitImage ; " \ - "setenv update_offset ${sf_kernel_offset} ; " \ - "run do_update_sf\0" \ - "update_swu=" \ - "setenv update_filename ${swufile} ; " \ - "setenv update_offset ${sf_swu_offset} ; " \ - "run do_update_sf\0" \ - "addcons=" \ - "setenv bootargs ${bootargs} " \ - "console=${consdev},${baudrate}\0" \ - "addip=" \ - "setenv bootargs ${bootargs} " \ - "ip=${ipaddr}:${serverip}:${gatewayip}:" \ - "${netmask}:${hostname}:${netdev}:off\0" \ - "addmisc=" \ - "setenv bootargs ${bootargs} ${miscargs}\0" \ - "addargs=run addcons addmisc\0" \ - "mmcload=" \ - "mmc rescan ; " \ - "mmc dev 0 1 ; " \ - "mmc read ${loadaddr} 0x800 0x2000 ; " \ - "mmc read ${dtbaddr} 0x400 0x80\0" \ - "netload=" \ - "dhcp ${loadaddr} ${hostname}/${bootfile} ; " \ - "tftp ${dtbaddr} ${hostname}/${dtbfile}\0" \ - "sfload=" \ - "sf probe ; " \ - "sf read ${loadaddr} ${sf_kernel_offset} ${sf_kernel_size}\0" \ - "usbload=" \ - "usb start ; " \ - "load usb 0:1 ${loadaddr} ${bootfile}\0" \ - "miscargs=panic=1\0" \ - "mmcargs=setenv bootargs root=${rootdev} rw rootwait\0" \ - "nfsargs=" \ - "setenv bootargs root=/dev/nfs rw " \ - "nfsroot=${serverip}:${rootpath},v3,tcp\0" \ - "mmc_mmc=" \ - "if run mmcload mmcargs addargs ; then " \ - "bootm ${loadaddr} - ${dtbaddr} ; " \ - "fi\0" \ - "mmc_nfs=" \ - "if run mmcload nfsargs addip addargs ; then " \ - "bootm ${loadaddr} - ${dtbaddr} ; " \ - "fi\0" \ - "sf_mmc=" \ - "if run sfload mmcargs addargs ; then " \ - "bootm ${loadaddr} - ${dtbaddr} ; " \ - "fi\0" \ - "sf_swu=" \ - "if run sfload ; then " \ - "sf read ${rdaddr} ${sf_swu_offset} ${sf_swu_size} ; " \ - "setenv bootargs root=/dev/ram0 rw ; " \ - "run addargs ; " \ - "bootm ${loadaddr} ${rdaddr} ; " \ - "fi\0" \ - "net_mmc=" \ - "if run netload mmcargs addargs ; then " \ - "bootm ${loadaddr} - ${dtbaddr} ; " \ - "fi\0" \ - "net_nfs=" \ - "if run netload nfsargs addip addargs ; then " \ - "bootm ${loadaddr} - ${dtbaddr} ; " \ - "fi\0" \ - "prebootcmd=" \ - "if test \"${envsaved}\" != y ; then ; " \ - "setenv envsaved y ; " \ - "saveenv ; " \ - "fi ; " \ - "if test \"${bootmode}\" = normal ; then " \ - "setenv bootdelay 0 ; " \ - "setenv bootpri mmc_mmc ; " \ - "elif test \"${bootmode}\" = devel ; then " \ - "setenv bootdelay 3 ; " \ - "setenv bootpri net_mmc ; " \ - "else " \ - "if test \"${bootmode}\" != update ; then " \ - "echo Warning: unknown bootmode \"${bootmode}\" ; " \ - "fi ; " \ - "setenv bootdelay 1 ; " \ - "setenv bootpri sf_swu ; " \ - "fi\0" - /* The rest of the configuration is shared */ #include From patchwork Thu Jan 11 11:06:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1885492 X-Patchwork-Delegate: festevam@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=fByALXq/; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=U7u4bQik; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T9hgq5pkNz1yPp for ; Thu, 11 Jan 2024 22:06:47 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DD9A2878B1; Thu, 11 Jan 2024 12:06:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1704971196; bh=mgRxb0Ute1IXcajlj0ojnGJBNZ1gN923FB5s8DpW6U8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=fByALXq/Q6YOYHs2vlHSle0s6soc61cHqLN5FyrwXunupbTMW5SlryaXYr2jJ+6YQ paGkAe2EB+wNbYIo8883rKhBgvBq9OGwEbvb4+5KU1suh4pcYNlIhtSYsGOQ7MfQf7 ubJFtJyGw6GP8c4edvhNuvKuq6XjRzetNovJ0AzBwMQ/buapKlw7TeryifZMHViFYb EeloA2He72Y18URpHt4iPT308DqWSxIfHLoU+YSiBU0kT8Kt048oq81ik3/Dv6nN+0 DwEi8UlnuaNNQcSjOHpUkVjdLURmHPxO41ICSE2rhfMMgP4boDbvIpjbivwb8k4Hff zxWV2J4GPiUSA== Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 510A9878B1; Thu, 11 Jan 2024 12:06:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1704971193; bh=mgRxb0Ute1IXcajlj0ojnGJBNZ1gN923FB5s8DpW6U8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U7u4bQikFuqo7NBxV025Ti9wPPEaqDiBoIcnnZbrfize5LO2+0bD4AnPRTxgzR0wc pNZ8RKzu9DEO14tlVb5GEZsvi3+E33yzl9RA5RtJhurgSiTkEH+cRILCIgIJ0Xu2OS V65xpIxlZUVXmJees/YUaaXrZ8BiHiPe+2Fp6ClVajphnHCf9fdzvM4UN5hZOvUgfM LGFutWG/OqDlMXZbOpSqucrWq+23MZjZ1lHs0UP1bxQrYY0yAjxCKBFVvpCPJ+n5Rg L2pq5sFgkt/1xmD9oInbjWxtALorXzECg8wlxSoRfPdPOxxnnCWv7dUpWAIPunLnzB H33VQ6hAVNVkQ== From: Lukasz Majewski To: Stefano Babic , Fabio Estevam , Tom Rini , u-boot@lists.denx.de, NXP u-boot Cc: Lukasz Majewski , Simon Glass Subject: [PATCH v2 2/3] arm: config: Enable CRC8 support in SPL on imx287 XEA board Date: Thu, 11 Jan 2024 12:06:10 +0100 Message-Id: <20240111110611.2051821-2-lukma@denx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240111110611.2051821-1-lukma@denx.de> References: <20240111110611.2051821-1-lukma@denx.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The boot0/1 feature uses simple CRC8 to check (in SPL) if SPI-NOR content is not corrupted, hence the need to enable it. Signed-off-by: Lukasz Majewski --- (no changes since v1) configs/imx28_xea_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/imx28_xea_defconfig b/configs/imx28_xea_defconfig index c1b0487f7e..64a0561a34 100644 --- a/configs/imx28_xea_defconfig +++ b/configs/imx28_xea_defconfig @@ -123,4 +123,5 @@ CONFIG_DM_SERIAL=y CONFIG_SPI=y CONFIG_DM_SPI=y CONFIG_MXS_SPI=y +CONFIG_SPL_CRC8=y # CONFIG_SPL_OF_LIBFDT is not set From patchwork Thu Jan 11 11:06:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majewski X-Patchwork-Id: 1885493 X-Patchwork-Delegate: festevam@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=Nuxuynos; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=RoGYB8qZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T9hh30HhWz1yPp for ; Thu, 11 Jan 2024 22:06:59 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2A84C87AC2; Thu, 11 Jan 2024 12:06:38 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1704971198; bh=dUeYcKeDb3iXzQJmjlwQqJ78U+luIblgfVc22xNEafA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Nuxuynospq3P12M6GrI1OkvceKepZ2yU9FjisWE338caTnFmuBIz4NMK9Pm7IOIfe /IDWjzGSFMFSrkpM10Zs1p/iI0b4XEvVESb3TeWlVdAK4bU0VCXqF2URATm7bEzcBr GP2OaepOg2vOAtQq5qQvWK5r2rq8/M9mqTfcGeFQocug+BasZ8fIUWyrM7IKiw6JAi URGv/Re8aCwTzTYJi6yFna3G1oCSf7UK/X6r2xExyocZxmCnIv7m0DDpnMBGGq33P/ iqirwRiKoIgVxZzDNmEBmRw+sYagEeQJHn3zdsx6yPfKvw5tkbztDvDvEwYpNMA2wt OCkmxl2N2UFIQ== Received: from localhost.localdomain (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id CF536878C8; Thu, 11 Jan 2024 12:06:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1704971194; bh=dUeYcKeDb3iXzQJmjlwQqJ78U+luIblgfVc22xNEafA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RoGYB8qZmDAA2UNuOQV3hpEociir9XM7YwYm8IKbslz2MsHcKK00OfL4DMivQpdfK ADaQ9WdH9no7eq+PsD13Wg/JPFm9sjUjNp1/fnQKr2znguhpe1yHatJjZiGRYu+GU6 0V5fZrP0NO8OsOKb9561IcT95hweK92lPlJPsPR1uc6fJ9fqgRaN4eBD8BxghRGM8k PRUi3DCuoUAyqj5Cj9QTNF6yq1vDGJwnPDkyMj39CJpaB4IULC4FEzzEJX3AbKsg2+ anPtFEj7BzvTMxN47VoktKmm1UHCSRuqDcZ5CeTpD6li9ERauzydvNunfiINjALWx0 TdMpKr/QoMS5g== From: Lukasz Majewski To: Stefano Babic , Fabio Estevam , Tom Rini , u-boot@lists.denx.de, NXP u-boot Cc: Anatolij Gustschin , Lukasz Majewski Subject: [PATCH v2 3/3] arm: xea: Add support for boot image source descriptor in SPL Date: Thu, 11 Jan 2024 12:06:11 +0100 Message-Id: <20240111110611.2051821-3-lukma@denx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240111110611.2051821-1-lukma@denx.de> References: <20240111110611.2051821-1-lukma@denx.de> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean From: Anatolij Gustschin We load two boot image source descriptor structures from last two sectors in the SPI NOR flash and determine the boot source for loading the kernel/DTB images, then adjust the boot order for loading image from eMMC boot0 or boot1 partition. Signed-off-by: Anatolij Gustschin Signed-off-by: Lukasz Majewski --- Changes in v2: - Move XEA's env adjustments to xea.env file (from include/configs/xea.h) board/liebherr/xea/boot_img_scr.h | 27 ++++++++++ board/liebherr/xea/xea.c | 85 +++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 board/liebherr/xea/boot_img_scr.h diff --git a/board/liebherr/xea/boot_img_scr.h b/board/liebherr/xea/boot_img_scr.h new file mode 100644 index 0000000000..baa3072b49 --- /dev/null +++ b/board/liebherr/xea/boot_img_scr.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Struct for boot image source description for placing in last + * two SPI NOR flash sectors on legcom. + */ + +struct boot_img_src { + u8 magic; /* Must be 'B' = 0x42 */ + u8 flags; /* flags to specify mmcblk[0|1] boot[0|1] */ + u8 crc8; /* CRC-8 over above two bytes */ +} __packed; + +/* + * Bit definition in boot_img_src.flags: + * Bit 0: mmcblk device 0 or 1 (1 - if this bit set) + * Bit 1: mmcblk boot partition 0 or 1. + * for eMMC: boot0 if this bit is cleared, boot1 - if set + * for SD-card the boot partition value will always be 0 + * (independent of the value of this bit) + * + */ +#define BOOT_SRC_MMC1 BIT(0) +#define BOOT_SRC_PART1 BIT(1) + +/* Offset of the first boot image source descriptor in SPI NOR */ +#define SPI_FLASH_BOOT_SRC_OFFS 0xFE0000 +#define SPI_FLASH_SECTOR_SIZE 0x10000 diff --git a/board/liebherr/xea/xea.c b/board/liebherr/xea/xea.c index e4d2eb65cc..c8ac526cb4 100644 --- a/board/liebherr/xea/xea.c +++ b/board/liebherr/xea/xea.c @@ -32,6 +32,11 @@ #include #include #include +#include +#include "boot_img_scr.h" + +#include +#include #ifdef CONFIG_SPL_BUILD #include @@ -66,6 +71,52 @@ void board_init_f(ulong arg) preloader_console_init(); } +static struct boot_img_src img_src[2]; +static int spi_load_boot_info(void) +{ + struct spi_flash *flash; + int err; + + flash = spi_flash_probe(CONFIG_SF_DEFAULT_BUS, + CONFIG_SF_DEFAULT_CS, + CONFIG_SF_DEFAULT_SPEED, + CONFIG_SF_DEFAULT_MODE); + if (!flash) { + printf("%s: SPI probe err\n", __func__); + return -ENODEV; + } + + /* + * Load both boot info structs from SPI flash + */ + err = spi_flash_read(flash, SPI_FLASH_BOOT_SRC_OFFS, + sizeof(img_src[0]), + (void *)&img_src[0]); + if (err) { + debug("%s: First boot info NOR sector read error %d\n", + __func__, err); + return err; + } + + err = spi_flash_read(flash, + SPI_FLASH_BOOT_SRC_OFFS + SPI_FLASH_SECTOR_SIZE, + sizeof(img_src[0]), + (void *)&img_src[1]); + if (err) { + debug("%s: First boot info NOR sector read error %d\n", + __func__, err); + return err; + } + + debug("%s: BI0 0x%x 0x%x 0x%x\n", __func__, + img_src[0].magic, img_src[0].flags, img_src[0].crc8); + + debug("%s: BI1 0x%x 0x%x 0x%x\n", __func__, + img_src[1].magic, img_src[1].flags, img_src[1].crc8); + + return 0; +} + static int boot_tiva0, boot_tiva1; /* Check if TIVAs request booting via U-Boot proper */ @@ -114,6 +165,40 @@ void spl_board_init(void) boot_tiva1 = dm_gpio_get_value(&btiva1); } +int spl_mmc_emmc_boot_partition(struct mmc *mmc) +{ + int i, src_idx = -1, ret; + + ret = spi_load_boot_info(); + if (ret) { + printf("%s: Cannot read XEA boot info! [%d]\n", __func__, ret); + /* To avoid bricking board - by default boot from boot0 eMMC */ + return 1; + } + + for (i = 0; i < 2; i++) { + if (img_src[i].magic == 'B' && + img_src[i].crc8 == crc8(0, &img_src[i].magic, 2)) { + src_idx = i; + break; + } + } + + debug("%s: src idx: %d\n", __func__, src_idx); + + if (src_idx < 0) + /* + * Always use eMMC (mmcblkX) boot0 if no + * valid image source description found + */ + return 1; + + if (img_src[src_idx].flags & BOOT_SRC_PART1) + return 2; + + return 1; +} + void board_boot_order(u32 *spl_boot_list) { spl_boot_list[0] = BOOT_DEVICE_MMC1;