From patchwork Thu Mar 3 20:44:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1600620 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.a=rsa-sha256 header.s=selector1 header.b=dunOKimp; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K8jjZ23LWz9sG1 for ; Fri, 4 Mar 2022 07:47:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 30C0583D5F; Thu, 3 Mar 2022 21:45:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.b="dunOKimp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B5BBE82A53; Thu, 3 Mar 2022 21:44:57 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,WEIRD_QUOTING autolearn=ham autolearn_force=no version=3.4.2 Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-ve1eur02on0602.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe06::602]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 40D5781CFC for ; Thu, 3 Mar 2022 21:44:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AKT1wuGx+QCXtkoF0oavMGhNq3ddZSF3oHHJ8ZRbuw3JgESXCzdz8+f0gdC5pFycKIxFSbDUyvu6xM/ylVFYCEAbM9ykafTKNzeILu6nS8zm9dnyGGFXeNmJLy7fM+dKH1WL6DU8Y7Jar1f42xXAvDEJDas6lZFERXjw3t8qgsBnc7gVnKaB2ESu7aD5iM0WUntzzLy4glMwqqlZqEVlNeYtay2ZYhiDb4jCSn16hcmJkOD7ngGAZ5y+HYQL7FrWt/Pufdrd204xI1BYKWxx5xE6hrggfS3vHjpb7sz7Mbrl56OO5lmQC66peWfov8BthJYSLc9z1SkfPsqZ0rb6Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=naFcqp/ZoMhktxSLp5rjKAtLYO5Ohcfm7PcgOhBny40=; b=MtAPXv89sRCWQnEEg6jSCQ9Hk8WM6bIU+pGBnMBEPVFVJtHtrpZTKKwZTtXUZvhuUy+/PzqMOUJaugE8InNTKM3jweXRoRr/KBt3FipQE5hlcTy32UvB6wk3WO4TP7RaOhOuKZCHoAcq3iwu3LaN2EC0VY3V/xyX7aptk7fhN1iaOCfc2iZIZw2i2fYAsDT76z5uu9G/C2xZlVMkOgbtO6nehSY4u2vrG4EOwuSJ3bn+UnP5CeM9PzGdPVEjX0FukRTPDL/uA7BMRLm5oiyQVw6xXmOFETGNvKL9mAej/TvjCtP3Lx4TmqN+fEXFnlXL1uR7Xe+K3qStCmyU8pg92g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=naFcqp/ZoMhktxSLp5rjKAtLYO5Ohcfm7PcgOhBny40=; b=dunOKimp66Rw8WW+CTOWNuj3cyCVwzKXCpiABahr0+2O5YHLIywEhUTy322YSjPGzlDzYD88pB/kdFBL7MVOko2Zk2Zaj9akTD/6ggDz3XlkruOpQ3I5/aSDOrK04GhjYF1DnPKS6HXgq7aLutjQN09jD+uaQok0+wtaCmkyB3qtpCTCAnobQhU3g94w3U7eWrmNN+cC6ZIDvN6gk1P15UfUgYu3GeUirUqUyY30lgsgXrW0PdpmKX5aWhZzWsCArOmd0Cnk0+RNdBGRwmDxxJeq3WiZnf+wvm0ELOKpAnoaAbZqEAcIkm3EQxipKPoydR4sG45Oy/JXAppAxfqEgg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by AM6PR03MB3573.eurprd03.prod.outlook.com (2603:10a6:209:2f::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5017.26; Thu, 3 Mar 2022 20:44:38 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::9130:93ae:6e27:e9a]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::9130:93ae:6e27:e9a%4]) with mapi id 15.20.5038.014; Thu, 3 Mar 2022 20:44:38 +0000 From: Sean Anderson To: Simon Glass Cc: Linus Walleij , Tom Rini , u-boot@lists.denx.de, Sean Anderson , Mingkai Hu , Priyanka Jain , Rajesh Bhagat Subject: [PATCH 17/17] ls1046ardb: Add support for JTAG boot Date: Thu, 3 Mar 2022 15:44:00 -0500 Message-Id: <20220303204400.2787389-18-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220303204400.2787389-1-sean.anderson@seco.com> References: <20220303204400.2787389-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR16CA0013.namprd16.prod.outlook.com (2603:10b6:208:134::26) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 33e534a6-948b-4b74-80d4-08d9fd56a294 X-MS-TrafficTypeDiagnostic: AM6PR03MB3573:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EhMKdX6Uek5W7GLIgLW+XczK/LNyPODtMfFz4CZLT8OBdOG1z+hAW7qegZD0pr9WxGlnOAvDmTLvvo7f/ICHVPykZHqArFbeO+DLdxBP0puOhsp6g8IAH9ZRQMMW6w3pVNAoj8cjK2QpGIZBrm+hzJdVYPlE35QPIDMZuvftLaiUxQaD0ShJx/aHGsr7tH9ewoUDOQC1c6yMjJF85E+ArWShigcsI7sBbES1h85jr9X5lf9vGvY8W1YoOlwcwcfFM9cWEZYUdHBlMTjlz3RbbY08D74JJ54ddD5ezNYRgO0YlC8pt35vaUgVWqr6a3IbGNoDJgaZsf46xjilgeryd6fG/S8/eAkrpJcfrLVqTRLOmdj1tRoohTSqepwU5j7YMar95qXTv8hcLKLMBizynagmdPR9ijkO/cF+/DwnwW75vgunTd/Tm7UByO9By4dlKKOWWsnBmiXhaSRav+Hs3GmlL6FiOs7VoxpjlYoAncaGBP56F8G/OxERel4nQqT9JwOGn9LXwcFEKFaZmZBjoxX230og4xHAJEEJd7VjXbq+xEIecy4yNXiC3TtiPOd1j/4azfcxjig3nhE5c5Yd0loTjsSX2CJMTSlcTzuZCCrNEwswmIuiZC5hqgZruxcWCzWJabQvIQcs/HHikdVrnARSSe+p3+AkEPSrSmqPDFk06/PuobcYNGlCkG6MIkL47JnsOMcgA3EMCEkCBSvd+TNrZdFexs32unwwt79G/EesZn3Y5zxXxcpPJCATB4jKKDvO+Ft8zqK4KKARov0Xs6WK6EK2/JdHPLgiqPpPCd4= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4523.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(6916009)(36756003)(54906003)(1076003)(2616005)(83380400001)(316002)(38100700002)(38350700002)(186003)(26005)(4326008)(6506007)(6666004)(508600001)(6512007)(2906002)(52116002)(86362001)(5660300002)(966005)(6486002)(8676002)(44832011)(66476007)(66946007)(66556008)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +GoYRA43I7szYf6GKiO52lpmAuXi5LH3cGYd9+Ql7ivr8+gaB1swVzX66KKV6/JvRZHoj1MLFi7jTe0tNJqVaOgwDnsBrnUnKCJF3fOtkheop28WUjIsNFpI8qG5ACWeos1QQuuI+i3n577O72gUfOjtmuGyYohH3ZseaNyuSmpDbzdIvhdHFIN9109yOOUG/QEJZ98sKRFaKuQ0CX6UXWno/xjCZ88JXEUrn/LtXeDRldH8GZ5gKwzU4O64RJ2oDleKeJ6bSFRA+RIwgaG2nyp5vg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p0urZmj3Jsbx/NM2qF6qftBgq3s5JHRUgUrL+1uewyoANexGz7reU5xFGpeqMlolsSP9vI2vGIsJi58JaiINpUjmAxC42Voo+InXzwjn0BHo8L/ow962rjKrp57GPTsRIIw8l7UONDNjsAjpKoJLomk8YQFcdAtnhFDnCjCHpaex9QseKqqZC8v2Z1/xip7P9h3OW94Wx7u+lsnLSZwdIE1Mbr/x6grvC3EO4wV0jPHaJ5V09TwWB8oCyk9WxUGxI0TibBgj0ODDQ= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 33e534a6-948b-4b74-80d4-08d9fd56a294 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2022 20:44:38.7541 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: V8bPvaoNt5KjXqI6Agsg1FKU7DJIp6wv8rkWF9CscY/NxZUtO4ayZtiHKRkbjBu6FYUOclq0xuxYuoDFdNknxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB3573 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.5 at phobos.denx.de X-Virus-Status: Clean This adds support for booting entirely from JTAG while using a hard-coded RCW. With these steps, it is not necessary to program a "good" RCW using CodeWarrior. The method here can be performed with any JTAG adapter supported by OpenOCD, including the on-board CMSIS-DAP (albeit very slowly). These steps require LS1046A support in OpenOCD, which is currently in the process of being upstreamed [1]. [1] https://review.openocd.org/c/openocd/+/6855 Signed-off-by: Sean Anderson --- arch/arm/cpu/armv8/fsl-layerscape/spl.c | 2 + doc/board/nxp/ls1046ardb.rst | 71 +++++++++++++++++++++++++ include/configs/ls1046ardb.h | 2 + 3 files changed, 75 insertions(+) diff --git a/arch/arm/cpu/armv8/fsl-layerscape/spl.c b/arch/arm/cpu/armv8/fsl-layerscape/spl.c index 564cc27c8b..1a7dde30a5 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/spl.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/spl.c @@ -27,6 +27,8 @@ DECLARE_GLOBAL_DATA_PTR; u32 spl_boot_device(void) { + if (IS_ENABLED(CONFIG_SPL_SEMIHOSTING)) + return BOOT_DEVICE_SMH; #ifdef CONFIG_SPL_MMC return BOOT_DEVICE_MMC1; #endif diff --git a/doc/board/nxp/ls1046ardb.rst b/doc/board/nxp/ls1046ardb.rst index c73516c070..ffb9d4550b 100644 --- a/doc/board/nxp/ls1046ardb.rst +++ b/doc/board/nxp/ls1046ardb.rst @@ -109,3 +109,74 @@ SD boot and eMMC boot ``{ SW5[0:8], SW4[0] }`` should be ``0010_0000_0``. eMMC is selected only if there is no SD card in the slot. + +JTAG boot +^^^^^^^^^ + +To recover a bricked board, or to perform initial programming, the ls1046 +supports using two hard-coded Reset Configuration Words (RCWs). Unfortunately, +this configuration disables most functionality, including the uarts and ethernet. +However, the SD/MMC and flash controllers are still functional. To get around +the lack of a serial console, we will use ARM semihosting instead. When +enabled, OpenOCD will interpret certain instructions as calls to the host +operating system. This allows U-Boot to use the console, read/write files, or +run arbitrary commands (!). + +When configuring U-Boot, ensure that ``CONFIG_SEMIHOSTING``, +``CONFIG_SPL_SEMIHOSTING``, and ``CONFIG_SEMIHOSTING_SERIAL`` are enabled, and +``CONFIG_SYS_NS16550`` is disabled. ``{ SW5[0:8], SW4[0] }`` should be +``0100_1111_0``. Additionally, ``SW4[7]`` should be set to ``0``. Connect to +the "console" USB connector on the front of the enclosure. + +Create a new file called ``u-boot.tcl`` (or whatever you choose) with the +following contents:: + + # Load the configuration for the LS1046ARDB + source [find board/nxp_rdb-ls1046a.cfg] + # Initialize the scan chain + init + # Stop the processor + halt + # Enable semihosting + arm semihosting enable + # Load U-Boot SPL + load_image spl/u-boot-spl 0 elf + # Start executing SPL at the beginning of OCRAM + resume 0x10000000 + +Then, launch openocd like:: + + openocd -f u-boot.tcl + +You should see the U-boot SPL banner followed by the banner for U-Boot proper +in the output of openocd. The CMSIS-DAP adapter is slow, so this can take a +long time. If you don't see it, something has gone wrong. After a while, you +should see the prompt. You can load an image using semihosting by running:: + + => load hostfs $loadaddr + +Note that openocd's terminal is "cooked," so commands will only be sent to +U-Boot when you press enter, and all commands will be echoed twice. +Additionally, openocd will block when waiting for input, ignoring gdb, JTAG +events, and Ctrl-Cs. To make openocd process these events, just hit enter. + +Using an external JTAG adapter +"""""""""""""""""""""""""""""" + +The CMSIS-DAP adapter can be rather slow. To speed up booting, use an external +JTAG adapter. The following examples assume you are using a J-Link, though any +adapter supported by OpenOCD will do. Ensure that ``SW4[7]`` is ``1``. Attach +your jtag adapter to J22. Modify ``u-boot.tcl`` and replace the first two lines +with the following:: + + # Load the J-Link configuration (or whatever your adapter is) + source [find interface/jlink.cfg] + # Use JTAG, since the J-Link also supports SWD + transport select jtag + # The reset pin resets the whole CPU + reset_config srst_only + # Load the LS1046A config + source [find target/ls1046a.cfg] + +You can proceed as normal through the rest of the steps above. I got a speedup +of around 100x by using a J-Link. diff --git a/include/configs/ls1046ardb.h b/include/configs/ls1046ardb.h index 8ed1dceb23..ed549c33b6 100644 --- a/include/configs/ls1046ardb.h +++ b/include/configs/ls1046ardb.h @@ -143,6 +143,8 @@ #endif #endif +#define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME "u-boot.img" + #include #endif /* __LS1046ARDB_H__ */