From patchwork Tue Mar 22 21:16:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1608367 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=GaMZm52B; 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 4KNPSr4wvvz9s1l for ; Wed, 23 Mar 2022 08:17:14 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2391A83B49; Tue, 22 Mar 2022 22:17:09 +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="GaMZm52B"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3F73983B4F; Tue, 22 Mar 2022 22:17:07 +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 EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on20616.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e1a::616]) (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 95AD583B3B for ; Tue, 22 Mar 2022 22:17:02 +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=Vic+VUv8LJh6L0nbFBt4gYOHZHNyM1z4QbBLuyIM0BpFuQRmRIE25bSIEsDMYvfOeV1srwbzgXD2h/UOLBbCjCbAxNR803aRuj1g0O+jiKbYV+JyrvnDcndfVkyZFaYQ0xWoi2ovQ4t71Y0YXv/DGPeCtI9MYLt7v2bo9WEx+FuXOvVbPTvsFIZnfyNHMd0hOLKqFIRUg9XXF6DkADVq5APuDuNkeyuRa1YFEbwHxoamhXTeFK7oGH/6b3l2ZKBALk2mYcQ1PkZWHM5sUOmUZquZkX+2qPbS4JSpkMdVo0rYgACjnnG4TuY/rpOALW9lNnHx4SMeWda5r5wBGwSwFA== 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=XD7VxtAWWDCprt4w88DIZnhSzRC/gIpfbAAv27cISpg=; b=OFgwUxUdxDSDbCnhN8rQ3IEQq4Ort8Mgmy+R6ppumjramEpqyPlLQeDDHqszmbJ+HaT5G2IC8RjBRIVPSmnzBGr+BTC1E21dnMP5MvuEVvJBTUJ64mZJ/DWf5qQT6vExWZA4mbHO93fX1O2CXt7S2hW3tQlYB0uW8kiGcuyePZivfB3TldphIISlhz/tYgbjElk4tUsYI2K0Q7cf4wlLGliOtI6IRFpXhttJZcUHZlh3flcQLiHBG1br6ECmY7QijHRYH8tutRPibEmcCmAkoMwKCtJ5uHNmzwLc9gZW2+obDM2To874uf6F3Cplrl2bL0O9dUxrhyq3XdOlO/eBeg== 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=XD7VxtAWWDCprt4w88DIZnhSzRC/gIpfbAAv27cISpg=; b=GaMZm52B6Jy7wPCKr9keeA0HbjKwMg+G/2NF9Wjsx0Y53QNuJBYnpWvU5tEBYGkszBmqijnBWJjiBOP2A59ARFXB85M6DmhpeXCxm7exu93mHXo9I46oaD40jo3lO5jpMhvefFqterduya1ln3PNOILM7b+KNza7tGD2POlldLuTc5oQH0k7UmUALg4YYZ2RjJmqi1uItMs7Nbef0bfZ25oXWOwEY4XXiQPF9h1tK479eeIfB4Wbjuk3e2lpvdI9VzH8V1Y0i2yps471oRDITRz6YN5f054g7XTy8ncbQ5dWmlmdN3uDa2uVjqoEHmg5RQokC6Oe+bKECR2bepM7RA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by AM6PR03MB3736.eurprd03.prod.outlook.com (2603:10a6:209:2d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.22; Tue, 22 Mar 2022 21:17:01 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::2414:8ad5:9fd6:3bff]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::2414:8ad5:9fd6:3bff%5]) with mapi id 15.20.5081.023; Tue, 22 Mar 2022 21:17:00 +0000 From: Sean Anderson To: u-boot@lists.denx.de Cc: Sean Anderson Subject: [RESEND PATCH v3 18/29] ls1046ardb: Add support for JTAG boot Date: Tue, 22 Mar 2022 17:16:05 -0400 Message-Id: <20220322211605.1723837-1-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220322205938.1721846-1-sean.anderson@seco.com> References: <20220322205938.1721846-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR19CA0057.namprd19.prod.outlook.com (2603:10b6:208:19b::34) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: da025622-a27d-4ae7-f619-08da0c494de3 X-MS-TrafficTypeDiagnostic: AM6PR03MB3736: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: 9W7ZiHG9jkJxAc2jQcFvup4eW8XpSckYHW7nUBSKRRLZif2GxDh4x6r/Uuld6r046MjMo1Nj98VFooPMcrFpmJn1NNn8ok+iHPKrlsy8vAW5DvwnTRxii/ATa9Lk+UkLoTBkFx+GdrtX3PfLTc4QQAAqyxYs+TA/gl3Nb2JlUIGH1utEYiE9Sgq3pXOQr4OJU3ek1pzbJ79V3mKxNl3TM/2miCL5pQy08FygFYVMnRlB3SEgVGGqmCdQXdH3HScYCJT1HgwCLuchTKdF5yKvDrYT61ojVxPxAESZXDerCnsAdsYOHdiiltV9SW8rp01ezKQTyWvgoGMpUjcNBFU8BmJlMu5KWAWFQ3t5c41LHGiW7f8y6HVBbju52XbT7JQIhc7f6NdJ6kiRTYEMN/UTI3nQ569T6aoZquvtBcZavjEJ3qCtxvPJBH3nt+fhTvJfZjh37OB0znq+Y1kA3vKubzGt203VGs+ggGGmgHA3UVYjOMCZM7gHnHqmyE2giJcbS6MmfgCS4lFoFS2miFXjkwexGGpmYt1WTLKHMI26qZLdviDl3luGUlvEG5sFGPgvl1g3kx+uo24ngBedk8adomOHKjb/0mAxR4avlpUlTpfNmDRf0ObRgHVGY037jjitEnYAQx1K1iRyCA+eaibjjI61/k+/GIoP2OOqiA8rVWHnZTCTA+ge12WAL2/iXM9A8F8sXR9YDH4flTAzIy79mI7IxGomBvelATTbm8QUXj7ig90o4ujs6H5Q/zlY+nfvH4j0GEACXYj9RUkV0Y+RTgDmcNvmgqa8oM9MNw1OvBo= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4972.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(52116002)(2906002)(6486002)(6506007)(6512007)(508600001)(966005)(8936002)(44832011)(36756003)(5660300002)(66556008)(38350700002)(38100700002)(66476007)(83380400001)(66946007)(86362001)(6916009)(316002)(8676002)(4326008)(2616005)(1076003)(107886003)(186003)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Go6dkDYiHq5QkBBT0F/99QLzZH86c56kIxDjVovDcB3u/lbfRpqhghNpSWWDUl3eXTuTOh1D+s9vhA2bk2r6itRGWlwAbFLR7PfqvnuChRJRmrXmaTO8P0NVczA+4xt5WvHf+sDRepHSA6oloGN370QPLbilU5vivg59uF8Lg++3KY+YgE0GUhejwxqQ+XV4LHmlrQGZyQQItgt2hRmbla3K+45AUZ0L/8adVgjjJALCIJjpQKi1ZmhwikAU/jv9OLuXTH2HCwG1O0kJAtlAtjGG+oZ9B24s1CUOia3Y30gKq8lUW2xKQTV6RCRdQca8rjbjtjzlyG5pArlAOI6TWs4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+mkua08yGiPKNNzotFwz2auy78b6yvby/7qy/ja64tQOdb6hKd3edK4RlO5rcdRfDtH/0Q== X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: da025622-a27d-4ae7-f619-08da0c494de3 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Mar 2022 21:17:00.7152 (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: sE0j3tC6sksTHJHK2xg47c1nCDijj99YRVxosi6DUxE0B7BB4iDk2XP7OOphqBO/WicdanpzYFoh5nllE8QGVw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB3736 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 was added in [1]. [1] https://sourceforge.net/p/openocd/code/ci/5b70c1f679755677c925b4e6dd2c3d8be4715717/ Signed-off-by: Sean Anderson --- Changes in v3: - Add dummy device number for hostfs arch/arm/cpu/armv8/fsl-layerscape/spl.c | 2 + board/freescale/ls1046ardb/ls1046ardb.c | 10 ++++ doc/board/nxp/ls1046ardb.rst | 71 +++++++++++++++++++++++++ doc/usage/semihosting.rst | 3 +- include/configs/ls1046ardb.h | 2 + 5 files changed, 87 insertions(+), 1 deletion(-) 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/board/freescale/ls1046ardb/ls1046ardb.c b/board/freescale/ls1046ardb/ls1046ardb.c index d0abfe8869..9af7cf763b 100644 --- a/board/freescale/ls1046ardb/ls1046ardb.c +++ b/board/freescale/ls1046ardb/ls1046ardb.c @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include #include #include @@ -27,6 +29,14 @@ DECLARE_GLOBAL_DATA_PTR; +struct serial_device *default_serial_console(void) +{ +#if IS_ENABLED(CONFIG_SEMIHOSTING_SERIAL) + return &serial_smh_device; +#endif + return &eserial1_device; +} + int board_early_init_f(void) { fsl_lsch2_early_init_f(); diff --git a/doc/board/nxp/ls1046ardb.rst b/doc/board/nxp/ls1046ardb.rst index e4499a13fb..08d81e385a 100644 --- a/doc/board/nxp/ls1046ardb.rst +++ b/doc/board/nxp/ls1046ardb.rst @@ -110,6 +110,77 @@ 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. +``{ 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. + Debug UART ---------- diff --git a/doc/usage/semihosting.rst b/doc/usage/semihosting.rst index 1d793983a7..6a280b455e 100644 --- a/doc/usage/semihosting.rst +++ b/doc/usage/semihosting.rst @@ -62,7 +62,8 @@ so you will need to enable it:: 'arm semihosting enable' -c resume Note that enabling semihosting can only be done after attaching to the -board with ``init``, and must be done while the CPU is halted. +board with ``init``, and must be done while the CPU is halted. For a more +extended example, refer to the :ref:`LS1046ARDB docs `. Loading files ------------- diff --git a/include/configs/ls1046ardb.h b/include/configs/ls1046ardb.h index 04c3ad02c8..df699bca34 100644 --- a/include/configs/ls1046ardb.h +++ b/include/configs/ls1046ardb.h @@ -140,6 +140,8 @@ #endif #endif +#define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME "u-boot.img" + #include #endif /* __LS1046ARDB_H__ */