From patchwork Thu Jan 30 12:42:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukasz Stelmach X-Patchwork-Id: 11357899 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3B03F92A for ; Thu, 30 Jan 2020 12:42:58 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 103842082E for ; Thu, 30 Jan 2020 12:42:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tml1mIGX"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="PE8pXvAi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 103842082E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:References:MIME-Version:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UiIYaCQdR/XC4vVUEgkNXPaRu3YqyXPC4SNOa0nxgEk=; b=tml1mIGXALnvms BtQz6P/vEpSuFLMGX0mo+vu45IdJIX+qPdJhESbcVMhS58LgELTy6sOMvR9Xnbbow3Pj73HovCAv0 /VDQmAe8s4tC2jKrYNrT3UiIzYPnTFImSdrFy23UlEFnZ/FrA6eCjgoithK0JGKThIy0j14XEBdPQ 9aV7wUtZ77wdMK71NBM3Tp1715ft/C3UVXuVIoBJmaB+qrRxRGiX3OAiP9VfOBhLwDJR/xgUA2ahr X/YovhVctrol0+pyHp+nMlwy8xV56MDe+2BuhmdxVAaa+uI7Za3/XTTBwjezIlz+vrOXfbdHQPoAb SUsMsrvXyHscv024KAWg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ix99r-0003Kv-GX; Thu, 30 Jan 2020 12:42:55 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ix99o-0003KO-QM for linux-arm-kernel@lists.infradead.org; Thu, 30 Jan 2020 12:42:54 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200130124251euoutp02fe7bdb458903c0a13dd8cc9a938202db~uqqs1keXa0709607096euoutp02E for ; Thu, 30 Jan 2020 12:42:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200130124251euoutp02fe7bdb458903c0a13dd8cc9a938202db~uqqs1keXa0709607096euoutp02E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1580388171; bh=C2/gDuPh/YjMrhIA5Fi5BfCbgFyvnjBPSfOWNOLrtLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PE8pXvAil21HQuednyUO9bmhdHb0GlV1xrwy+1cJt7cIovJM2icUesFn/z6ZSP+Hz nVm5AuNIz4ZSC9BVmRuAFzvRIySQUr4eJLMW6bAj+XRq96CH19WHwc2oTA8dc7n7N9 9wUD8nPtZws2ujhocRsutypBnBbbLvxEpJTh4n/c= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200130124251eucas1p1278a6ff8d17ec92d81d324786b6049ca~uqqsorbC-0694706947eucas1p1m; Thu, 30 Jan 2020 12:42:51 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id E3.DF.60679.B4FC23E5; Thu, 30 Jan 2020 12:42:51 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200130124251eucas1p2046004a71a1a9ff4274a6d1d96e2c260~uqqsUzrLQ1244712447eucas1p25; Thu, 30 Jan 2020 12:42:51 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200130124251eusmtrp105ee7c9b42a2afb3b7c4060ce748b448~uqqsUPuTd2256122561eusmtrp1H; Thu, 30 Jan 2020 12:42:51 +0000 (GMT) X-AuditID: cbfec7f4-0cbff7000001ed07-e7-5e32cf4b00af Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 4C.2E.08375.A4FC23E5; Thu, 30 Jan 2020 12:42:50 +0000 (GMT) Received: from localhost (unknown [106.120.51.46]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200130124250eusmtip261dbfe54d9ddf3a6aa884504c66b3de0~uqqsHrrF81635516355eusmtip2J; Thu, 30 Jan 2020 12:42:50 +0000 (GMT) From: =?utf-8?q?=C5=81ukasz_Stelmach?= To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [RFC PATCH 1/4] scripts/dtc: update fdtget.c to upstream version v1.4.7-57-gf267e674d145 Date: Thu, 30 Jan 2020 13:42:30 +0100 Message-Id: <20200130124233.4006-1-l.stelmach@samsung.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200130123934.3900-1-l.stelmach@samsung.com> MIME-Version: 1.0 Organization: Samsung R&D Institute Poland X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmleLIzCtJLcpLzFFi42LZduzneV3v80ZxBjuPC1vcPLSC0WLT42us Fpd3zWGzmHF+H5MDi8fmJfUefVtWMXp83iQXwBzFZZOSmpNZllqkb5fAlfGw9y5bwWHXijdn 25kbGA+bdTFyckgImEg8ePiHvYuRi0NIYAWjxNW+3YwQzhdGifmTlzOCVAkJfGaUmHgxCaZj 5p2HLBBFyxkl9v/fA9X+nFFi5b9+JpAqNgFHif6lJ1hBbBGBbInJH7+AxZkF7CUmzvrPBmIL CyRLbG2fBFbDIqAq8WhFE1icV8BKovFeFxvENnmJ873r2EFsTgFriUNTFrJA1AhKnJz5BMzm F9CSWNN0nQVivrxE89bZzCAHSQi0s0ucbOqHGuQisWlLOxOELSzx6vgWdghbRuL05B6gZg4g u15i8iQziN4eRoltc36wQNRYS9w594sNpIZZQFNi/S59iLCjxJX2djaIVj6JG28FIU7gk5i0 bTozRJhXoqNNCKJaRWJd/x6ogVISva9WME5gVJqF5JlZSB6YhbBrASPzKkbx1NLi3PTUYqO8 1HK94sTc4tK8dL3k/NxNjMCkcfrf8S87GHf9STrEKMDBqMTD63HGKE6INbGsuDL3EKMEB7OS CK+oq2GcEG9KYmVValF+fFFpTmrxIUZpDhYlcV7jRS9jhQTSE0tSs1NTC1KLYLJMHJxSDYyb 65bnKjE5+tRNWSVrHTKt+af3Hqabk/s55lxZsF175snkR9FfQ0VeHA656m9RxunJuf3X1abE 67MO1Qbf7Eh3c/3mUq5tv7brkTLP22/32usMaxuvHV96Sf9ERVB5m39q7ms/vRN1M36uubp0 x6RF+VXnNO02/vv5KmZximCVQeCJ99MW+39TYinOSDTUYi4qTgQA06wDwxYDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMIsWRmVeSWpSXmKPExsVy+t/xe7pe543iDDb+sbC4eWgFo8Wmx9dY LS7vmsNmMeP8PiYHFo/NS+o9+rasYvT4vEkugDlKz6Yov7QkVSEjv7jEVina0MJIz9DSQs/I xFLP0Ng81srIVEnfziYlNSezLLVI3y5BL+Nh7122gsOuFW/OtjM3MB4262Lk5JAQMJGYeech SxcjF4eQwFJGifW7frB1MXIAJaQkVs5Nh6gRlvhzrYsNouYpo8SkW2vZQRJsAo4S/UtPsILY IgK5EtcOHQWLMwvYS0yc9Z8NxBYWSJSYdvwWE4jNIqAq8WhFE1icV8BKovFeFxvEAnmJ873r wHo5BawlDk1ZyAJygxBQzevd6hDlghInZz4BCzMLqEusnycEEuYX0JJY03SdBWKrvETz1tnM ExiFZiHpmIXQMQtJ1QJG5lWMIqmlxbnpucWGesWJucWleel6yfm5mxiBEbLt2M/NOxgvbQw+ xCjAwajEw+txxihOiDWxrLgy9xCjBAezkgivqKthnBBvSmJlVWpRfnxRaU5q8SFGU6AvJzJL iSbnA6M3ryTe0NTQ3MLS0NzY3NjMQkmct0PgYIyQQHpiSWp2ampBahFMHxMHp1QDo8//xKnR YTVT8oVq87+cv8MddO/tZcMetfDIPu0tLVOWV/zRFlq+k+Nric9WjiCBrunvq/bMD7+j8/D5 7PM/Fz+Nlv7N/fLJJuuf4moK3dNFm4LDGH/dDvm0ltPio+D/880cim7rvnydzPd+m7Vtx1KZ J5NkGa72i5uqCPefZJ04JWqrnOb8KiWW4oxEQy3mouJEAKKrU/ymAgAA X-CMS-MailID: 20200130124251eucas1p2046004a71a1a9ff4274a6d1d96e2c260 X-Msg-Generator: CA X-RootMTR: 20200130124251eucas1p2046004a71a1a9ff4274a6d1d96e2c260 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200130124251eucas1p2046004a71a1a9ff4274a6d1d96e2c260 References: <20200130123934.3900-1-l.stelmach@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200130_044252_989739_0C0C4959 X-CRM114-Status: GOOD ( 21.01 ) X-Spam-Score: -5.2 (-----) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-5.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [210.118.77.12 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [210.118.77.12 listed in wl.mailspike.net] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?=C5=81ukasz_Stelmach?= Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Build and fdtget and add fdtget.c to the list of update source files. Signed-off-by: Łukasz Stelmach --- scripts/dtc/.gitignore | 4 + scripts/dtc/Makefile | 5 ++ scripts/dtc/fdtget.c | 125 ++++++++++++++++++------------- scripts/dtc/update-dtc-source.sh | 4 +- 4 files changed, 82 insertions(+), 56 deletions(-) diff --git scripts/dtc/.gitignore scripts/dtc/.gitignore index 2e6e60d64ede..80f6b50fdf77 100644 --- scripts/dtc/.gitignore +++ scripts/dtc/.gitignore @@ -1 +1,5 @@ dtc +dtc-lexer.lex.c +dtc-parser.tab.c +dtc-parser.tab.h +fdtget diff --git scripts/dtc/Makefile scripts/dtc/Makefile index b5a5b1c548c9..74322d8dac25 100644 --- scripts/dtc/Makefile +++ scripts/dtc/Makefile @@ -2,12 +2,15 @@ # scripts/dtc makefile hostprogs-$(CONFIG_DTC) := dtc +hostprogs-$(CONFIG_DTC) += fdtget always := $(hostprogs-y) dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \ srcpos.o checks.o util.o dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o +fdtget-objs := fdtget.o util.o + # Source files need to get at the userspace version of libfdt_env.h to compile HOST_EXTRACFLAGS := -I $(srctree)/$(src)/libfdt @@ -26,5 +29,7 @@ endif HOSTCFLAGS_dtc-lexer.lex.o := -I $(srctree)/$(src) HOSTCFLAGS_dtc-parser.tab.o := -I $(srctree)/$(src) +HOSTLDLIBS_fdtget := -L$(obj)/libfdt -lfdt -Wl,-rpath='$$ORIGIN/libfdt' + # dependencies on generated files need to be listed explicitly $(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h diff --git scripts/dtc/fdtget.c scripts/dtc/fdtget.c index c922f82246c6..777582e2d45f 100644 --- scripts/dtc/fdtget.c +++ scripts/dtc/fdtget.c @@ -39,6 +39,37 @@ static void report_error(const char *where, int err) fprintf(stderr, "Error at '%s': %s\n", where, fdt_strerror(err)); } +/** + * Shows a list of cells in the requested format + * + * @param disp Display information / options + * @param data Data to display + * @param len Maximum length of buffer + * @param size Data size to use for display (e.g. 4 for 32-bit) + * @return 0 if ok, -1 on error + */ +static int show_cell_list(struct display_info *disp, const char *data, int len, + int size) +{ + const uint8_t *p = (const uint8_t *)data; + char fmt[3]; + int value; + int i; + + fmt[0] = '%'; + fmt[1] = disp->type ? disp->type : 'd'; + fmt[2] = '\0'; + for (i = 0; i < len; i += size, p += size) { + if (i) + printf(" "); + value = size == 4 ? fdt32_ld((const fdt32_t *)p) : + size == 2 ? (*p << 8) | p[1] : *p; + printf(fmt, value); + } + + return 0; +} + /** * Displays data of a given length according to selected options * @@ -52,12 +83,9 @@ static void report_error(const char *where, int err) */ static int show_data(struct display_info *disp, const char *data, int len) { - int i, size; - const uint8_t *p = (const uint8_t *)data; + int size; const char *s; - int value; int is_string; - char fmt[3]; /* no data, don't print */ if (len == 0) @@ -85,17 +113,8 @@ static int show_data(struct display_info *disp, const char *data, int len) "selected data size\n"); return -1; } - fmt[0] = '%'; - fmt[1] = disp->type ? disp->type : 'd'; - fmt[2] = '\0'; - for (i = 0; i < len; i += size, p += size) { - if (i) - printf(" "); - value = size == 4 ? fdt32_to_cpu(*(const uint32_t *)p) : - size == 2 ? (*p << 8) | p[1] : *p; - printf(fmt, value); - } - return 0; + + return show_cell_list(disp, data, len, size); } /** @@ -107,7 +126,6 @@ static int show_data(struct display_info *disp, const char *data, int len) */ static int list_properties(const void *blob, int node) { - const struct fdt_property *data; const char *name; int prop; @@ -116,8 +134,7 @@ static int list_properties(const void *blob, int node) /* Stop silently when there are no more properties */ if (prop < 0) return prop == -FDT_ERR_NOTFOUND ? 0 : prop; - data = fdt_get_property_by_offset(blob, prop, NULL); - name = fdt_string(blob, fdt32_to_cpu(data->nameoff)); + fdt_getprop_by_offset(blob, prop, &name, NULL); if (name) puts(name); prop = fdt_next_property_offset(blob, prop); @@ -231,7 +248,7 @@ static int show_data_for_item(const void *blob, struct display_info *disp, * @param filename Filename of blob file * @param arg List of arguments to process * @param arg_count Number of arguments - * @param return 0 if ok, -ve on error + * @return 0 if ok, -ve on error */ static int do_fdtget(struct display_info *disp, const char *filename, char **arg, int arg_count, int args_per_step) @@ -240,7 +257,7 @@ static int do_fdtget(struct display_info *disp, const char *filename, const char *prop; int i, node; - blob = utilfdt_read(filename); + blob = utilfdt_read(filename, NULL); if (!blob) return -1; @@ -252,44 +269,50 @@ static int do_fdtget(struct display_info *disp, const char *filename, continue; } else { report_error(arg[i], node); + free(blob); return -1; } } prop = args_per_step == 1 ? NULL : arg[i + 1]; - if (show_data_for_item(blob, disp, node, prop)) + if (show_data_for_item(blob, disp, node, prop)) { + free(blob); return -1; + } } + + free(blob); + return 0; } -static const char *usage_msg = - "fdtget - read values from device tree\n" - "\n" - "Each value is printed on a new line.\n\n" - "Usage:\n" +/* Usage related data. */ +static const char usage_synopsis[] = + "read values from device tree\n" " fdtget
[ ]...\n" " fdtget -p
[ ]...\n" - "Options:\n" - "\t-t \tType of data\n" - "\t-p\t\tList properties for each node\n" - "\t-l\t\tList subnodes for each node\n" - "\t-d\t\tDefault value to display when the property is " - "missing\n" - "\t-h\t\tPrint this help\n\n" + "\n" + "Each value is printed on a new line.\n" USAGE_TYPE_MSG; - -static void usage(const char *msg) -{ - if (msg) - fprintf(stderr, "Error: %s\n\n", msg); - - fprintf(stderr, "%s", usage_msg); - exit(2); -} +static const char usage_short_opts[] = "t:pld:" USAGE_COMMON_SHORT_OPTS; +static struct option const usage_long_opts[] = { + {"type", a_argument, NULL, 't'}, + {"properties", no_argument, NULL, 'p'}, + {"list", no_argument, NULL, 'l'}, + {"default", a_argument, NULL, 'd'}, + USAGE_COMMON_LONG_OPTS, +}; +static const char * const usage_opts_help[] = { + "Type of data", + "List properties for each node", + "List subnodes for each node", + "Default value to display when the property is missing", + USAGE_COMMON_OPTS_HELP +}; int main(int argc, char *argv[]) { + int opt; char *filename = NULL; struct display_info disp; int args_per_step = 2; @@ -298,20 +321,14 @@ int main(int argc, char *argv[]) memset(&disp, '\0', sizeof(disp)); disp.size = -1; disp.mode = MODE_SHOW_VALUE; - for (;;) { - int c = getopt(argc, argv, "d:hlpt:"); - if (c == -1) - break; - - switch (c) { - case 'h': - case '?': - usage(NULL); + while ((opt = util_getopt_long()) != EOF) { + switch (opt) { + case_USAGE_COMMON_FLAGS case 't': if (utilfdt_decode_type(optarg, &disp.type, &disp.size)) - usage("Invalid type string"); + usage("invalid type string"); break; case 'p': @@ -333,7 +350,7 @@ int main(int argc, char *argv[]) if (optind < argc) filename = argv[optind++]; if (!filename) - usage("Missing filename"); + usage("missing filename"); argv += optind; argc -= optind; @@ -344,7 +361,7 @@ int main(int argc, char *argv[]) /* Check for node, property arguments */ if (args_per_step == 2 && (argc % 2)) - usage("Must have an even number of arguments"); + usage("must have an even number of arguments"); if (do_fdtget(&disp, filename, argv, argc, args_per_step)) return 1; diff --git scripts/dtc/update-dtc-source.sh scripts/dtc/update-dtc-source.sh index 7dd29a0362b8..8db277546785 100755 --- scripts/dtc/update-dtc-source.sh +++ scripts/dtc/update-dtc-source.sh @@ -31,8 +31,8 @@ set -ev DTC_UPSTREAM_PATH=`pwd`/../dtc DTC_LINUX_PATH=`pwd`/scripts/dtc -DTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c \ - srcpos.h treesource.c util.c util.h version_gen.h yamltree.c Makefile.dtc \ +DTC_SOURCE="checks.c data.c dtc.c dtc.h fdtget.c flattree.c fstree.c livetree.c + srcpos.c srcpos.h treesource.c util.c util.h version_gen.h Makefile.dtc \ dtc-lexer.l dtc-parser.y" LIBFDT_SOURCE="Makefile.libfdt fdt.c fdt.h fdt_addresses.c fdt_empty_tree.c \ fdt_overlay.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c \ From patchwork Thu Jan 30 12:42:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukasz Stelmach X-Patchwork-Id: 11357903 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B891E1398 for ; Thu, 30 Jan 2020 12:43:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8929D214AF for ; Thu, 30 Jan 2020 12:43:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="S/FY1p4a"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="LQQDXpQL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8929D214AF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:References:MIME-Version:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=goaNQNqm0jWScgRlir5wgIu4ZJypsN/paiYGWDXH8vw=; b=S/FY1p4awM0hz+ GLrkbYXw8k/rlX/4jUqbdw1xaSx9skpelLvoBJrkaFgtiUj6guTNe7L4Bi7cJN4v76iL5EzBEpGuu 47R0HZH0TtX+Quw4WcNsATKz/coSaJh5tO+h15fn75e39MPoP+Rhc7WVQvwk9FBsoeueBQn9/5EKb BALNv00T0lu5/93Drxzi2xvj7YnEf1PU58hVWY1zJ8WB8eHVad2UlYN76rDwmnN3PK2L1/cYZx9Mm JE0WK8EXlNlLboufjmpJxV9WuHXV5d3iwCmeo4Uo8KEfK7HOZm9ix76h6tZ0ObikDqfWmtY+DcjZI P9DMHsSJ0HPCjwE/eq4w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ix9A9-0003ZO-Fq; Thu, 30 Jan 2020 12:43:13 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ix9A2-0003Uy-Om for linux-arm-kernel@lists.infradead.org; Thu, 30 Jan 2020 12:43:11 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200130124304euoutp027e91186d52904feb220efb61f7ef882d~uqq5VKMnO0695306953euoutp02h for ; Thu, 30 Jan 2020 12:43:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200130124304euoutp027e91186d52904feb220efb61f7ef882d~uqq5VKMnO0695306953euoutp02h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1580388185; bh=+P8a2fdMyzXk8luowUxelFub/dwbU2MtPQ3w1czBqRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LQQDXpQLxlZeHlKlKIUQOfpnitWnFxtv4FuQhRs4yOKat8O1xCJkULrYrnKEgXVNF gGMFhQ7nHsnjf0O+084c6Avp42JkkFgQb2TEPCgSap9IwkqHCBOosZH112WsdTHMKb iiR1w+whOMaHQERr8TPLu+X3qJmslcmTDi0GFyNE= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200130124304eucas1p2a579180e27d6d0ad2f7e0fbb5bb06c92~uqq5FRhGh2611426114eucas1p28; Thu, 30 Jan 2020 12:43:04 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 83.D9.61286.85FC23E5; Thu, 30 Jan 2020 12:43:04 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200130124304eucas1p2f3381b1009cd71cd292169d5f10265c1~uqq4krDLU1246012460eucas1p2L; Thu, 30 Jan 2020 12:43:04 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200130124304eusmtrp155ca62ca38ac1f64a26c76184b2bd44c~uqq4kIDIS2256122561eusmtrp1l; Thu, 30 Jan 2020 12:43:04 +0000 (GMT) X-AuditID: cbfec7f2-f0bff7000001ef66-93-5e32cf581f1b Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id A4.3E.08375.85FC23E5; Thu, 30 Jan 2020 12:43:04 +0000 (GMT) Received: from localhost (unknown [106.120.51.46]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200130124303eusmtip2548f372b63f47f071fa7db90415c7968~uqq4Wy6ve1492314923eusmtip2V; Thu, 30 Jan 2020 12:43:03 +0000 (GMT) From: =?utf-8?q?=C5=81ukasz_Stelmach?= To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [RFC PATCH 2/4] scripts: add get_console_base.pl Date: Thu, 30 Jan 2020 13:42:31 +0100 Message-Id: <20200130124233.4006-2-l.stelmach@samsung.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200130124233.4006-1-l.stelmach@samsung.com> MIME-Version: 1.0 Organization: Samsung R&D Institute Poland X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgleLIzCtJLcpLzFFi42LZduzned2I80ZxBusmqlvcPLSC0WLT42us Fpd3zWGzmHF+H5MDi8fmJfUefVtWMXp83iQXwBzFZZOSmpNZllqkb5fAlbF3TnDBbY6KqxMu sTUwrmDvYuTkkBAwkdj2+wNjFyMXh5DACkaJZWs6mSGcL4wSv9+egHI+M0r8P9/KAtPStKuZ DSKxnFHi5vwWVgjnOVD/jh9sIFVsAo4S/UtPsILYIgLZEpM/fmECsZkF7CUmzvoPViMsYClx 5uxXoEM4OFgEVCV+nSsFCfMKWEkcPr4S6j55ifO968BsTgFriY+rf7NC1AhKnJz5BOwgfgEt iTVN11kgxstLNG+dzQzR284usW1KLoTtInGs5y4rhC0s8er4Fqj5MhKnJ/ewgJwgIVAvMXmS GcgrEgI9jBLb5vyAetha4s65X2wgNcwCmhLrd+lDlDtKTP6ZD2HySdx4KwhxAJ/EpG3TmSHC vBIdbUIQM1Qk1vXvgZonJdH7agXjBEalWUhemYXk/FkIqxYwMq9iFE8tLc5NTy02zEst1ytO zC0uzUvXS87P3cQITBen/x3/tIPx66WkQ4wCHIxKPLweZ4zihFgTy4orcw8xSnAwK4nwiroa xgnxpiRWVqUW5ccXleakFh9ilOZgURLnNV70MlZIID2xJDU7NbUgtQgmy8TBKdXAyFevmWf3 zPimtp2CsP7E/uKJHHx8ch9ZZ54q8XC+bDxRRqxsu8Lt4I7fV1Wm7T1lV2PP5rya8dWh30ze kQ0v+PcGHvsoMc88cW9U8syXF55MP3n8WGL/7L/ZthNliqT+NbivZHbbKWDIVv/zyV/WPc/9 deNu2b13npulkmC19WSS2MoTTxS8lFiKMxINtZiLihMBUXfpNhMDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEIsWRmVeSWpSXmKPExsVy+t/xe7oR543iDG4tYba4eWgFo8Wmx9dY LS7vmsNmMeP8PiYHFo/NS+o9+rasYvT4vEkugDlKz6Yov7QkVSEjv7jEVina0MJIz9DSQs/I xFLP0Ng81srIVEnfziYlNSezLLVI3y5BL2PvnOCC2xwVVydcYmtgXMHexcjJISFgItG0q5mt i5GLQ0hgKaPEorWvgBIcQAkpiZVz0yFqhCX+XOuCqnnKKPFyVjcbSIJNwFGif+kJVhBbRCBX 4tqho2BDmQXsJSbO+g9WIyxgKXHm7FewmSwCqhK/zpWChHkFrCQOH18JdYO8xPnedWA2p4C1 xMfVv8FGCglkS3TtecUIUS8ocXLmExaQMcwC6hLr5wmBhPkFtCTWNF1ngdgqL9G8dTbzBEah WUg6ZiF0zEJStYCReRWjSGppcW56brGhXnFibnFpXrpecn7uJkZgfGw79nPzDsZLG4MPMQpw MCrx8HqcMYoTYk0sK67MPcQowcGsJMIr6moYJ8SbklhZlVqUH19UmpNafIjRFOjLicxSosn5 wNjNK4k3NDU0t7A0NDc2NzazUBLn7RA4GCMkkJ5YkpqdmlqQWgTTx8TBKdXAGMt35pJD+7Kc 5clR+zm2Ldz3UudD0+ruya5ss353pX9Z83btg323lsadClk8v/kK46HJjYL+iZ7q15bJrxao elP/xyni66+/XRdO/f8S2Mli+cR2/arodnnjmTeaHki9WfC+p2NSQ9ru798mBC1bHcUzUbz5 ll7rrzUr8lVFX/NlNq2IP++8RE+JpTgj0VCLuag4EQAXSO14pQIAAA== X-CMS-MailID: 20200130124304eucas1p2f3381b1009cd71cd292169d5f10265c1 X-Msg-Generator: CA X-RootMTR: 20200130124304eucas1p2f3381b1009cd71cd292169d5f10265c1 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200130124304eucas1p2f3381b1009cd71cd292169d5f10265c1 References: <20200130123934.3900-1-l.stelmach@samsung.com> <20200130124233.4006-1-l.stelmach@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200130_044307_285310_5F57F670 X-CRM114-Status: UNSURE ( 9.86 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -5.2 (-----) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-5.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [210.118.77.12 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [210.118.77.12 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?=C5=81ukasz_Stelmach?= Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Read UART base address from dtb for compile time configuration. Signed-off-by: Łukasz Stelmach --- scripts/get_console_base.pl | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 scripts/get_console_base.pl diff --git scripts/get_console_base.pl scripts/get_console_base.pl new file mode 100755 index 000000000000..c707ee37a19f --- /dev/null +++ scripts/get_console_base.pl @@ -0,0 +1,26 @@ +#!/usr/bin/perl -w + +use strict; +use File::Basename; +use File::Spec::Functions; + +my $DTB=$ARGV[0]; +die "$0: DTB file not found: $DTB" unless (-f $DTB); + +my $scripts_dir=dirname($0); +my $fdtget=catfile($scripts_dir, 'dtc', 'fdtget'); + +my $stdout_path=`$fdtget -ts "$DTB" /chosen stdout-path`; +chomp $stdout_path; + +if ($stdout_path =~ m#([^/][^:]*)(?::.*)#) { + $stdout_path=`$fdtget -ts "$DTB" /aliases $1`; + chomp $stdout_path; +} + +my $reg = `$fdtget -tx "$DTB" $stdout_path reg`; +unless ($reg =~ m/^([[:xdigit:]]+)/) { + die "Base address not found"; +} +$reg = $1; +print "0x$reg\n"; From patchwork Thu Jan 30 12:42:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukasz Stelmach X-Patchwork-Id: 11357909 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F71392A for ; Thu, 30 Jan 2020 12:43:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 34BED206F0 for ; Thu, 30 Jan 2020 12:43:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="C0jHorV0"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="MHxtAm+u" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 34BED206F0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:References:MIME-Version:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2Njh71N9ayMxbzkB7s29tgjlS115YHOtIjxRtTzfYtQ=; b=C0jHorV0SPZZAy g6HdJOEr/mlwu7FeehzleWwzyYQuRyfPNxlnAqmP/Cz6Ih0I0FKWDwbz9lsfJJUR5zO1sLAPXs8vQ a02uubWQEhCbEON0Acb0RpYjcZ9QKLt/r79xysh7iuasoXXjqmZSmkxeuODq5obCX2CyWCAm7WPPY /R5mRtDczJDAzXyNqyFbnj/o6MXaO1qZVdC1rqQvphYNCTq2lzse58ItnKIpCF3NE8cQIwTXc42sq EFebZHzT/Rb8NjpTqTE04uvMXcy2dCkExwOPEQ4ZtOXWYHsWscnHH2YKSeOrN4bMG/bQ5rcx9KVz0 4NWE361eiHzeBSFKwJuw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ix9AP-0003lF-Si; Thu, 30 Jan 2020 12:43:30 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ix9AD-0003cB-3L for linux-arm-kernel@lists.infradead.org; Thu, 30 Jan 2020 12:43:24 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200130124315euoutp025d7f6608623e56041e4b9a1559b92ad3~uqrDSVVUP0875908759euoutp02D for ; Thu, 30 Jan 2020 12:43:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200130124315euoutp025d7f6608623e56041e4b9a1559b92ad3~uqrDSVVUP0875908759euoutp02D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1580388195; bh=u0T3trcPCRl0Q7vpugRvojgpgGpIu2Bq4V1J0AMOTPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MHxtAm+uTrPEFIVYoldBzRr56lj+GEDAIbv3Ow+rYaQ/lu2pPsuFCkckC1gY//1XV Lb88x8vRNlaaF1uekGHmET1wntNOu7TYKleb5qOAIdBTsLjVYNF6h1k2JT1n9eFKma 4u5PP42l09A2I7Bnfx7eNGOphNOQ+5V2uhujDt6k= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200130124314eucas1p2c80c56755ba2cef935be2df307bd9666~uqrCZJUEQ1245412454eucas1p2S; Thu, 30 Jan 2020 12:43:14 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 47.EF.60679.26FC23E5; Thu, 30 Jan 2020 12:43:14 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200130124314eucas1p11a244e77c9c5f583832832313ba93335~uqrBv1Vko0693106931eucas1p1h; Thu, 30 Jan 2020 12:43:14 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200130124314eusmtrp1a13fac857b1f591d7fd28be841b5bf62~uqrBvOOo92256022560eusmtrp1C; Thu, 30 Jan 2020 12:43:14 +0000 (GMT) X-AuditID: cbfec7f4-0cbff7000001ed07-33-5e32cf627fef Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id F3.6D.07950.16FC23E5; Thu, 30 Jan 2020 12:43:13 +0000 (GMT) Received: from localhost (unknown [106.120.51.46]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200130124313eusmtip1a712638181fb4d06a893d2a4f974e23f~uqrBmpkPc2123221232eusmtip1l; Thu, 30 Jan 2020 12:43:13 +0000 (GMT) From: =?utf-8?q?=C5=81ukasz_Stelmach?= To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [RFC PATCH 3/4] Add tools/hsinit Date: Thu, 30 Jan 2020 13:42:32 +0100 Message-Id: <20200130124233.4006-3-l.stelmach@samsung.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200130124233.4006-1-l.stelmach@samsung.com> MIME-Version: 1.0 Organization: Samsung R&D Institute Poland X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFuplleLIzCtJLcpLzFFi42LZduzned2k80ZxBgd2aFncPLSC0WLT42us Fpd3zWGzmHF+H5PFrecPGR1YPTYvqfc4+G4Pk0ffllWMHp83yQWwRHHZpKTmZJalFunbJXBl LP0ZWfCnpuLQlt/sDYzvUrsYOTkkBEwker6uY+pi5OIQEljBKLH4zHw2COcLo8SpDzNZIZzP jBLzfjYxdjFygLU0P6yDiC9nlNj+bhYzhPOcUWLCrM1MIHPZBBwl+peeYAWxRQSyJSZ//AK2 g1mgg1Fi58YTYEXCApoSF45NYwSxWQRUJbpbnoHZvAJWEvceTGOBOFBe4nzvOnYQm1PAWuLj 6t+sEDWCEidnPgGr4RfQkljTdB3MZgaqb946G+wiCYHp7BKHm+cwQwxykfj1fAfUUGGJV8e3 sEPYMhKnJ/ewQLxWLzF5khlEbw+jxLY5P6DqrSXunPvFBlLDDHT0+l36EGFHiX3v3rNBtPJJ 3HgrCHECn8SkbdOZIcK8Eh1tQhDVKhLr+vdADZSS6H21gnECo9IsJM/MQvLALIRdCxiZVzGK p5YW56anFhvlpZbrFSfmFpfmpesl5+duYgQmktP/jn/ZwbjrT9IhRgEORiUeXo8zRnFCrIll xZW5hxglOJiVRHhFXQ3jhHhTEiurUovy44tKc1KLDzFKc7AoifMaL3oZKySQnliSmp2aWpBa BJNl4uCUamBktljJoi1uHp51T37XbgcVXjPRqH9+/2Su26yqnOv1W2hpn6lpxa4rNe65uQcm XmPfb5XyYXVc/KO4A6sf/DKLOlzwaoZLxNZz/E9lJn4X2NH36cebN4/+Z1ndfJnPkCVzfx4D 1ytRlncxR07F1n1g+ZWbF3eLY1fTTC2Ru8f8Go9stv1r9fC5EktxRqKhFnNRcSIAr+VNUCAD AAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLIsWRmVeSWpSXmKPExsVy+t/xu7qJ543iDHYftLG4eWgFo8Wmx9dY LS7vmsNmMeP8PiaLW88fMjqwemxeUu9x8N0eJo++LasYPT5vkgtgidKzKcovLUlVyMgvLrFV ija0MNIztLTQMzKx1DM0No+1MjJV0rezSUnNySxLLdK3S9DLWPozsuBPTcWhLb/ZGxjfpXYx cnBICJhIND+s62Lk4hASWMoosWDrE2aIuJTEyrnpXYycQKawxJ9rXWwQNU8ZJVYs/MwMkmAT cJToX3qCFcQWEciVuHboKDtIEbNAB6PEzo0nmEASwgKaEheOTWMEsVkEVCW6W56B2bwCVhL3 HkxjgdggL3G+dx07iM0pYC3xcfVvsKFCAtkSXXteQdULSpyc+YQF5DhmAXWJ9fOEQML8AloS a5qug41hBhrTvHU28wRGoVlIOmYhdMxCUrWAkXkVo0hqaXFuem6xkV5xYm5xaV66XnJ+7iZG YNRsO/Zzyw7GrnfBhxgFOBiVeHg9zhjFCbEmlhVX5h5ilOBgVhLhFXU1jBPiTUmsrEotyo8v Ks1JLT7EaAr05kRmKdHkfGBE55XEG5oamltYGpobmxubWSiJ83YIHIwREkhPLEnNTk0tSC2C 6WPi4JRqYFxt1c64UvOSipL5a1m1LQ4rnT7++LLOSs3l2JpHXC3r+X9+MeZb/3k/i3TUNWVz plJj3s44iegJBvKawYurHlxu2lv322v71SptbVdvpmaXi6L+91eaL+aSzYivrnfzS5lff+wR +/qDgesD460iX73Vv1BmFn895K3Kvhd2gs5KfzpKZI75K7EUZyQaajEXFScCAM3VG0ywAgAA X-CMS-MailID: 20200130124314eucas1p11a244e77c9c5f583832832313ba93335 X-Msg-Generator: CA X-RootMTR: 20200130124314eucas1p11a244e77c9c5f583832832313ba93335 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200130124314eucas1p11a244e77c9c5f583832832313ba93335 References: <20200130123934.3900-1-l.stelmach@samsung.com> <20200130124233.4006-1-l.stelmach@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200130_044317_447001_3F84E32D X-CRM114-Status: GOOD ( 20.24 ) X-Spam-Score: -5.2 (-----) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-5.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [210.118.77.12 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [210.118.77.12 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?=C5=81ukasz_Stelmach?= , =?utf-8?q?Mat?= =?utf-8?q?eusz_Mo=C5=9Bcicki?= Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Co-authored by M.Mościcki and Ł.Stelmach. Signed-off-by: Mateusz Mościcki Signed-off-by: Łukasz Stelmach --- tools/hsinit/Makefile.am | 29 ++++ tools/hsinit/README.org | 56 ++++++ tools/hsinit/bootstrap | 7 + tools/hsinit/configure.ac | 128 ++++++++++++++ tools/hsinit/hsinit.c | 299 +++++++++++++++++++++++++++++++++ tools/hsinit/vendor/.gitignore | 5 + tools/hsinit/vendor/SHA256SUMS | 2 + 7 files changed, 526 insertions(+) create mode 100644 tools/hsinit/Makefile.am create mode 100644 tools/hsinit/README.org create mode 100755 tools/hsinit/bootstrap create mode 100644 tools/hsinit/configure.ac create mode 100644 tools/hsinit/hsinit.c create mode 100644 tools/hsinit/vendor/.gitignore create mode 100644 tools/hsinit/vendor/SHA256SUMS diff --git tools/hsinit/Makefile.am tools/hsinit/Makefile.am new file mode 100644 index 000000000000..3c8b3cff1b64 --- /dev/null +++ tools/hsinit/Makefile.am @@ -0,0 +1,29 @@ +INITRAMFS_DIR = ./initramfs + +bin_PROGRAMS=hsinit +hsinit_LDFLAGS = $(ENABLE_STATIC) +hsinit_SOURCES = hsinit.c +hsinit_LINK = $(CCLD) $(hsinit_CFLAGS) $(CFLAGS) $(hsinit_LDFLAGS) \ + $(LDFLAGS) -o $@ + + +data_DATA = initramfs.cpio.xz + +CPIO = @CPIO@ +CPIO_FLAGS = -o --format=newc + +XZ=@XZ@ +XZ_FLAGS = --check=crc32 --lzma2=dict=1MiB -f -k + +ENABLE_STATIC = @ENABLE_STATIC@ + +%.xz : % + xz $(XZ_FLAGS) $< + +initramfs.cpio: hsinit + for d in bin dev etc lib mnt proc root sbin sys; do \ + mkdir -p $(INITRAMFS_DIR)/$$d; \ + done + cp $< $(INITRAMFS_DIR)/init + cd $(INITRAMFS_DIR); find . -print0 | cpio --null $(CPIO_FLAGS) > ../$@ + diff --git tools/hsinit/README.org tools/hsinit/README.org new file mode 100644 index 000000000000..2874781b5e70 --- /dev/null +++ tools/hsinit/README.org @@ -0,0 +1,56 @@ +* hsinit + + hsinit is a minimal init program for boot/loader (a.k.a. k-boot) on + Odroid XU4 and other platforms with limited size of bootloader + image. (1MiB on Odroid XU4). Its sole purpose is to unpack the rest + of the initramfs image from an archive pointed by the 'hs' parameter + in /proc/cmdline. For example: + +#+BEGIN_EXAMPLE: + hs=/dev/mmcblk1p6:uroot.cpio.gz +#+END_EXAMPLE + + will make hsinit mount /dev/mmcblk1p6 and unpack the content of + uroot.cpio.gz onto initramfs. Please note that unlike the old initrd + initramfs hasn't got fixed size and is much more suitable for hsinit + to work with. + +* Building hsinit + + The basic way to build hsinit on a host system is + +#+BEGIN_SRC sh + ./bootstrap && ./configure && make +#+END_SRC + + The only direct dependency of hsinit is [[https://libarchive.org/][libarchive]], which, however, + needs at least zlib to support reasonable compression. You use + libarchive and libz packaged for your system or download appropriate + archives into the vendor directory (see vendor/SHA256SUMS) and the + libraries shall be built automatically. + +* Building for musl + + While it is possible to build hsinit for the host system (e.g. x86) + and link it dynamically, it makes little sens. Most of the time you + will want to compile to for different CPU and link it statically against + a C library other than GNU C Library to make the binary small enough + to fit the image. + + To cross-compile hsinit for ARM and link it statically against musl + run the following command. + +#+BEGIN_SRC sh + ./bootstrap && \ + MUSL_DIR=/usr/lib/arm-linux-musleabi/ \ + GCC_CROSS_DIR=/usr/lib/gcc-cross/arm-linux-gnueabi/8/ \ + CPPFLAGS='-nostdinc -isystem /usr/include/arm-linux-musleabi/' \ + CFLAGS='-mthumb -Os -ffunction-sections -fdata-sections' \ + LIBARCHIVE_CPP_FLAGS=-I/usr/include/arm-linux-musleabi/ \ + LIBARCHIVE_C_FLAGS=$CFLAGS \ + ZLIB_C_FLAGS=$CFLAGS \ + LDFLAGS="-nostdlib -L${MUSL_DIR}/ -L${GCC_CROSS_DIR}/ ${MUSL_DIR}/crt1.o ${MUSL_DIR}/crti.o ${GCC_CROSS_DIR}/crtbegin.o -Wl,--gc-sections -Wl,--start-group ${GCC_CROSS_DIR}/libgcc.a ${GCC_CROSS_DIR}/libgcc_eh.a -Wl,--end-group ${GCC_CROSS_DIR}/crtend.o ${MUSL_DIR}/crtn.o -s" \ + LIBS="-lc -lgcc" + ./configure --enable-local-libraries --host=arm-linux-gnueabi --enable-static && \ + make +#+END_SRC diff --git tools/hsinit/bootstrap tools/hsinit/bootstrap new file mode 100755 index 000000000000..d3e9fbc8a6c3 --- /dev/null +++ tools/hsinit/bootstrap @@ -0,0 +1,7 @@ +#!/bin/sh + +set -x -e +#aclocal +#autoheader +#autoconf +autoreconf -i -f -v diff --git tools/hsinit/configure.ac tools/hsinit/configure.ac new file mode 100644 index 000000000000..135f53354c9a --- /dev/null +++ tools/hsinit/configure.ac @@ -0,0 +1,128 @@ +dnl +dnl configure.ac for hsinit +dnl + +AC_PREREQ(2.69) +AC_INIT(hsinit, 1.0.0) +AC_CONFIG_SRCDIR([./hsinit.c]) +AC_CONFIG_AUX_DIR([build-aux]) +AM_INIT_AUTOMAKE([foreign]) +AC_CONFIG_HEADERS([config.h]) +AC_LANG(C) +AC_PROG_CC +PKG_PROG_PKG_CONFIG + +dnl -- Prepare for cross-compilation +AC_CANONICAL_HOST +if test "${build}" != "${host}" ; then + AC_CHECK_PROGS(BUILD_CC, [${build_alias}-gcc ${build}-gcc gcc]) + AC_CHECK_PROGS(BUILD_LD, [${build_alias}-ld ${build}-ld ld]) + AC_CHECK_PROGS(HOST_CC, [${host_alias}-gcc ${host}-gcc gcc]) + AC_CHECK_PROGS(HOST_LD, [${host_alias}-ld ${host}-ld ld]) +else + BUILD_CC="$CC" + BUILD_LD="$LD" + + HOST_CC="$CC" + HOST_LD="$LD" +fi + + +AC_ARG_ENABLE(local-libraries, + AS_HELP_STRING([--enable-local-libraries],[Build and use local versions of libarchive and zlib]), + ENABLE_LOCAL_LIBS=yes) + +AC_ARG_ENABLE(static, + AS_HELP_STRING([--enable-static], [Build static binary]), + ENABLE_STATIC=-static) + +AC_ARG_VAR(ZLIB_C_FLAGS, [CFLAGS for local zlib compilation]) +AC_ARG_VAR(ZLIB_CPP_FLAGS, [CPPFLAGS for local zlib compilation]) +AC_ARG_VAR(ZLIB_LD_FLAGS, [LDFLAGS for local zlib compilation]) +AC_ARG_VAR(LIBARCHIVE_C_FLAGS, [CFLAGS for local libarchive compilation]) +AC_ARG_VAR(LIBARCHIVE_CPP_FLAGS, [CPPFLAGS for local libarchive compilation]) +AC_ARG_VAR(LIBARCHIVE_LD_FLAGS, [LDFLAGS for local libarchive compilation]) + +AC_SUBST(ENABLE_STATIC) +AC_SUBST(HOST_CFLAGS, ["$CFLAGS"]) +AC_SUBST(HOST_CPPFLAGS, ["$CPPFLAGS"]) +AC_SUBST(HOST_LDFLAGS, ["$LDFLAGS"]) + +AC_PATH_PROG(CPIO, cpio) +AC_PATH_PROG(XZ, xz) +AC_PATH_PROG(SHA256SUM, sha256sum) + + +AS_IF([test -n "${ENABLE_LOCAL_LIBS}"], + AC_MSG_CHECKING([for local libraries]) + AS_IF([cd $srcdir/vendor && $SHA256SUM -c SHA256SUMS --quiet && cd - > /dev/null], + AC_MSG_RESULT([ok]), + AC_MSG_ERROR([error]))) +AS_IF([test -n "${ENABLE_LOCAL_LIBS}" && /bin/true], + pushd vendor + mkdir -p libs + zlib_archive=$(grep -o zlib-.* SHA256SUMS) + zlib_dir=${zlib_archive%.tar.gz} + AC_MSG_NOTICE([Building ${zlib_dir}]) + rm -rf "$zlib_dir" + tar -xf "$zlib_archive" + cd "$zlib_dir" + CFLAGS="${ZLIB_C_FLAGS}" \ + CPPFLAGS="${ZLIB_CPP_FLAGS}" \ + LDFLAGS="${ZLIB_LD_FLAGS}" \ + CROSS_PREFIX="${host_alias:-${host}}-" ./configure ${ENABLE_STATIC:+--static} --prefix=$(pwd)/../libs + make -j8 install + + cd .. + + libarchive_archive=$(grep -o libarchive-.* SHA256SUMS) + libarchive_dir=${libarchive_archive%.tar.gz} + rm -rf "$libarchive_dir" + tar -xf "$libarchive_archive" + cd $libarchive_dir + + PKG_CONFIG_PATH=$(pwd)/../libs/lib/pkgconfig + CFLAGS="${LIBARCHIVE_C_FLAGS}" \ + CPPFLAGS="${LIBARCHIVE_CPP_FLAGS}" \ + LDFLAGS="${LIBARCHIVE_LD_FLAGS}" \ + ./configure --host=${host_alias:-${host}} \ + ${ENABLE_STATIC:+--enable-static --disable-shared} \ + --prefix=$(pwd)/../libs \ + --disable-bsdtar \ + --disable-bsdcat \ + --disable-bsdcpio \ + --disable-xattr \ + --disable-acl \ + --disable-shared \ + --disable-largefile \ + --without-bz2lib \ + --without-iconv \ + --without-lz4 \ + --without-lzma \ + --without-lzo2 \ + --without-cng \ + --without-nettle \ + --without-openssl \ + --without-xml2 \ + --without-expat + make -j8 install + popd +) + +AS_IF([test -n "${ENABLE_LOCAL_LIBS}"], + export PKG_CONFIG_PATH=$(pwd)/vendor/libs/lib/pkgconfig/ +) +AS_IF([test -n "$ENABLE_STATIC"], + [PKG_CHECK_MODULES_STATIC([LIBARCHIVE], [libarchive])], + [PKG_CHECK_MODULES([LIBARCHIVE], [libarchive])]) + +CFLAGS="$CFLAGS $LIBARCHIVE_CFLAGS" +LIBS="$LIBS $LIBARCHIVE_LIBS" + +dnl ---Output +AC_OUTPUT([Makefile]) + +echo +echo Host CC: $HOST_CC +echo Build CC: $BUILD_CC +echo diff --git tools/hsinit/hsinit.c tools/hsinit/hsinit.c new file mode 100644 index 000000000000..8332c06b8501 --- /dev/null +++ tools/hsinit/hsinit.c @@ -0,0 +1,299 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#define COMMAND_LINE_SIZE 512 +#define PARAM_NAME "hs" + +/* + * Based on examples: + * https://github.com/libarchive/libarchive/wiki/Examples + */ +int copy_data(struct archive *ar, struct archive *aw) +{ + int r; + const void *buff; + size_t size; + int64_t offset; + + for (;;) { + r = archive_read_data_block(ar, &buff, &size, &offset); + if (r == ARCHIVE_EOF) + return (ARCHIVE_OK); + if (r < ARCHIVE_OK) + return (r); + r = archive_write_data_block(aw, buff, size, offset); + if (r < ARCHIVE_OK) { + printf("%s\n", archive_error_string(aw)); + return (r); + } + } +} + +static int extract(const char *filename) +{ + struct archive *a; + struct archive *ext; + struct archive_entry *entry; + int flags; + int r; + + flags = ARCHIVE_EXTRACT_TIME; + flags |= ARCHIVE_EXTRACT_PERM; + flags |= ARCHIVE_EXTRACT_ACL; + flags |= ARCHIVE_EXTRACT_FFLAGS; + + a = archive_read_new(); + archive_read_support_format_cpio(a); + archive_read_support_filter_gzip(a); + ext = archive_write_disk_new(); + archive_write_disk_set_options(ext, flags); + archive_write_disk_set_standard_lookup(ext); + + if ((r = archive_read_open_filename(a, filename, 10240))) + return -1; + + for (;;) { + r = archive_read_next_header(a, &entry); + if (r == ARCHIVE_EOF) + break; + if (r < ARCHIVE_OK) + printf("%s\n", archive_error_string(a)); + if (r < ARCHIVE_WARN) + return -1; + r = archive_write_header(ext, entry); + if (r < ARCHIVE_OK) + printf("%s\n", archive_error_string(ext)); + else if (archive_entry_size(entry) > 0) { + r = copy_data(a, ext); + if (r < ARCHIVE_OK) + printf("%s\n", archive_error_string(ext)); + if (r < ARCHIVE_WARN) + return -1; + } + + r = archive_write_finish_entry(ext); + + if (r < ARCHIVE_OK) + printf("%s\n", archive_error_string(ext)); + if (r < ARCHIVE_WARN) + return -1; + } + + archive_read_close(a); + archive_read_free(a); + archive_write_close(ext); + archive_write_free(ext); + + return 1; +} + +int mount_sysfs() +{ + return mount("none", "/sys", "sysfs", MS_NOEXEC | + MS_RELATIME | MS_NODEV | MS_NOSUID, NULL); +} + +int mount_procfs() +{ + return mount("none", "/proc", "proc", MS_NOEXEC | + MS_RELATIME | MS_NODEV | MS_NOSUID, NULL); +} + +int mount_devfs() +{ + return mount("none", "/dev", "devtmpfs", MS_NOEXEC | + MS_RELATIME | MS_NOSUID, NULL); +} + +int mount_storage(char *device) +{ + char BUFF[256]; + sprintf(BUFF, "%s", device); + // mount("/dev/sdb6", "/mnt", "vfat", MS_RDONLY, NULL) = 0 + return mount(BUFF, "/mnt", "vfat", 0, NULL); +} + +void ls(char *dir) +{ + DIR *d = NULL; + struct dirent *de; + + d = opendir(dir); + + if (d == NULL) { + printf("Error opening directory: %s\n", dir); + return; + } + + printf("Reading %s\n", dir); + while ((de = readdir(d)) != NULL) { + printf("%s\n", de->d_name); + } + printf("\n"); +} + +int umount_storage() +{ + return umount("/mnt"); +} + +int read_cmd_params(char *buff) +{ + int fd = open("/proc/cmdline", O_RDONLY); + if (fd < 0) { + printf("Open /proc/cmdline error: %s", strerror(errno)); + return fd; + } + + int readed = read(fd, buff, COMMAND_LINE_SIZE-1); + + if (readed >= 0) + buff[readed] = '\0'; + return readed; +} + +/* + * Get param=value from /proc/cmdline + */ +const char *find_param(const char *cmdline, const char *param_name, char *value) +{ + const char *cur = cmdline; + bool in_quote = false; + bool begin = true; + int param_name_len = strlen(param_name); + int i, length; + + while (*cur != '\0') { + if (begin) { + for (i = 0; *(param_name+i) != '\0' && + *(cur + i) == *(param_name+i); i++); + + if (i == param_name_len && (*(cur+i) == '=')) { + cur += i+1; + break; + } + begin = false; + } + + if (*cur == '\"') + in_quote = !in_quote; + + if (!in_quote && *cur == ' ') + begin = true; + + cur++; + } + + if (*cur > 0) { + for (i = 0; *(cur+i) != ' ' && *(cur+i) != '\0' && *(cur+i) != '\n'; i++); + length = i > (COMMAND_LINE_SIZE - 1) ? (COMMAND_LINE_SIZE - 1) : i; + memcpy(value, cur, length); + value[length] = '\0'; + } + return cur; +} + +int parse_cmdline(const char *cmdline, char *device, char *dest) +{ + char value[COMMAND_LINE_SIZE]; + const char *res = find_param(cmdline, PARAM_NAME, value); + + if (*res == 0) { + printf("hs param not found\n"); + return 0; + } + + char *r = strtok(value, ":"); + if (r == NULL) { + printf("Wrong sh parameter format\n"); + return -1; + } + + strncpy(device, r, NAME_MAX); + + r = strtok(NULL, ":"); + if (r == NULL) { + printf("Wrong hs parameter format\n"); + return -1; + } + + strncpy(dest, r, NAME_MAX); + + return 1; +} + +int main(void) +{ + char params[COMMAND_LINE_SIZE]; + char device[NAME_MAX]; + char initramfs_fn[NAME_MAX]; + char full_irfs_file[PATH_MAX]; + + printf("Hello...\n"); + + if (mount_sysfs() < 0) { + printf("Mount sysfs error: %s\n", strerror(errno)); + exit(1); + } + + if (mount_procfs() < 0) { + printf("Mount procfs error: %s\n", strerror(errno)); + exit(1); + } + + if (mount_devfs() < 0) { + printf("Mount devfs error: %s\n", strerror(errno)); + exit(1); + } + + printf("Sleep zzZZ...\n"); + sleep(1); + printf("Wake up :)\n"); + + ls("/dev"); + + if (read_cmd_params(params) < 0) { + printf("Read cmd_params error: %s\n", strerror(errno)); + exit(1); + } + + if (parse_cmdline(params, device, initramfs_fn) <= 0) + exit(1); + + if (mount_storage(device) < 0) { + printf("Mount %s error: %s\n", device, strerror(errno)); + exit(1); + } + + sprintf(full_irfs_file, "/mnt/%s", initramfs_fn); + + if (extract(full_irfs_file) <= 0) { + printf("Extract error: %s\n", strerror(errno)); + exit(1); + } + + umount_storage(); + + /*if (execl("/bin/busybox", "sh", NULL) <= 0)*/ + /*printf("Execl error: %s\n", strerror(errno));*/ + + printf("Init...\n"); + + if (execl("/init", "/init", (char *)NULL) <= 0) + printf("Execl error: %s\n", strerror(errno)); + + return 0; +} diff --git tools/hsinit/vendor/.gitignore tools/hsinit/vendor/.gitignore new file mode 100644 index 000000000000..07a4d737cb87 --- /dev/null +++ tools/hsinit/vendor/.gitignore @@ -0,0 +1,5 @@ +/zlib-*/ +/libarchive-*/ +/libs/ +/libarchive-*.tar.gz +/zlib-*.tar.gz diff --git tools/hsinit/vendor/SHA256SUMS tools/hsinit/vendor/SHA256SUMS new file mode 100644 index 000000000000..fd42c44ba948 --- /dev/null +++ tools/hsinit/vendor/SHA256SUMS @@ -0,0 +1,2 @@ +c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 zlib-1.2.11.tar.gz +ed2dbd6954792b2c054ccf8ec4b330a54b85904a80cef477a1c74643ddafa0ce libarchive-3.3.2.tar.gz From patchwork Thu Jan 30 12:42:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukasz Stelmach X-Patchwork-Id: 11357911 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 362581398 for ; Thu, 30 Jan 2020 12:43:56 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0221E206D3 for ; Thu, 30 Jan 2020 12:43:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Mr1KauNG"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="GxjEgzKJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0221E206D3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:References:MIME-Version:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KzkfkAIg8IUPnHMWOlXIjjrgwaoR5OvGDPqRCh9Jgt0=; b=Mr1KauNGgTIHnp o8Xyq8dDN1uuYfKLlRM/kUeEHYHRr5BAjohUUD9/UP5mN6MSX0NIIcK/lRuZIdqqORT7ZpHkEDUFg +d63YsJElnuoaNlbdGSqKiOUT0Z6z66KIz71+cv/XIO/5icuvB5q0y8YAMcj2yPLYjcW+paRGQoBu Msgh7JEtyOLsGLav6ZmUZrZ7PzV9718iH4Z95JKOTl0hLz062GLWITpMsr4raFZM0djJfiXSXWYEW bV11rNwbnNgqG/cFeQct/iHcfREC3BwOCqDxM8n/mxzaT373IwHTCkAUo1Rm2q+VlKYbUn6CkSVL5 bNsrfUSecXvz7+cuBCOQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ix9Ai-00040J-JY; Thu, 30 Jan 2020 12:43:48 +0000 Received: from mailout1.w1.samsung.com ([210.118.77.11]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ix9AE-0003cK-6z for linux-arm-kernel@lists.infradead.org; Thu, 30 Jan 2020 12:43:24 +0000 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200130124316euoutp01c0ea3333e3ef63ffc8dd3bd53ae3377c~uqrDrHlmt2932129321euoutp014 for ; Thu, 30 Jan 2020 12:43:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200130124316euoutp01c0ea3333e3ef63ffc8dd3bd53ae3377c~uqrDrHlmt2932129321euoutp014 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1580388196; bh=lT1I19NYIZKRT4a1vnKJnFS8PvPg81U0RYirnuIE4as=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GxjEgzKJINoygEsVV6sN0v/n9E/krYy9QvIo0DqaZiS30WfdjX2NxFcpva+7r3bH9 WlOexxyGAlk9cVfO4g/MS0dUXNftPiQtnJfWtUnzrIJXWExgqBhFtTr8xLgpaRv/HA ERQs3Cr+0tYTE6GcsCpkhOcmgdSDHE72pYraK68w= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200130124315eucas1p195c03b5901c94e88a3a5ebb207e6a12c~uqrDfR3sX1976019760eucas1p1C; Thu, 30 Jan 2020 12:43:15 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 27.BA.60698.36FC23E5; Thu, 30 Jan 2020 12:43:15 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200130124315eucas1p12d5380c44b68d08ae96849056303e175~uqrDPNpNZ0696206962eucas1p1m; Thu, 30 Jan 2020 12:43:15 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200130124315eusmtrp1b7fee25bcd3170c976aa8c63f9fa3529~uqrDOnwd22256122561eusmtrp1E; Thu, 30 Jan 2020 12:43:15 +0000 (GMT) X-AuditID: cbfec7f5-a29ff7000001ed1a-76-5e32cf638755 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 54.6D.07950.36FC23E5; Thu, 30 Jan 2020 12:43:15 +0000 (GMT) Received: from localhost (unknown [106.120.51.46]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200130124315eusmtip2bad2ce430c110ffce79aaf6e8db206ad~uqrDBgM2d1616616166eusmtip2L; Thu, 30 Jan 2020 12:43:15 +0000 (GMT) From: =?utf-8?q?=C5=81ukasz_Stelmach?= To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [RFC PATCH 4/4] boot/loader: Enable building bootloader replacement for Odroid XU4 Date: Thu, 30 Jan 2020 13:42:33 +0100 Message-Id: <20200130124233.4006-4-l.stelmach@samsung.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200130124233.4006-1-l.stelmach@samsung.com> MIME-Version: 1.0 Organization: Samsung R&D Institute Poland X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphleLIzCtJLcpLzFFi42LZduzned3k80ZxBq8eGlvcPLSC0WLT42us Fpd3zWGzmHF+H5MDi8fmJfUefVtWMXp83iQXwBzFZZOSmpNZllqkb5fAlbHt6lr2gk8TGSse N79kbmBcU9nFyMkhIWAiseX0JJYuRi4OIYEVjBKndr1khnC+MEpcb1zOCOF8ZpQ4OnMBUIYD rGXyKx+I+HJGiTNzZ0J1PGeU6D7xnQ1kLpuAo0T/0hOsILaIQLbE5I9fmEBsZgF7iYmz/oPV CAvESnw+uAqshkVAVeLyqlYWEJtXwEpiwb7ZTBD3yUuc713HDmJzClhLfFz9mxWiRlDi5Mwn YPX8AloSa5qus0DMl5do3job7CAJgW52iTMXjrNBDHKRuHf6DDOELSzx6vgWdghbRuL05B4W iM/qJSZPMoPo7WGU2DbnBwtEjbXEnXO/2EBqmAU0Jdbv0ocIO0pMPzePHaKVT+LGW0GIE/gk Jm2bDg0rXomONiGIahWJdf17oAZKSfS+WsE4gVFpFpJnZiF5YBbCrgWMzKsYxVNLi3PTU4uN 81LL9YoTc4tL89L1kvNzNzEC08bpf8e/7mDc9yfpEKMAB6MSD++Cc0ZxQqyJZcWVuYcYJTiY lUR4RV0N44R4UxIrq1KL8uOLSnNSiw8xSnOwKInzGi96GSskkJ5YkpqdmlqQWgSTZeLglGpg lNXzWuFZURfPtVP0Lk+BxdfjHYwmAh1Mb6KXf/c8pqgt+KPENPSLQqNY23n+M41KBouO8/x5 6Ssm3vImzUHmaiPnnN7DnQ3uJvvdrU/8uGBWyFF180982a4lJrnHxPNnpiesuzLxpVbL+ae5 X9fZOvnFzHI8fzmK22xTc9iOKWUFs+smGh5QYinOSDTUYi4qTgQA8oUO6hcDAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprCIsWRmVeSWpSXmKPExsVy+t/xe7rJ543iDN6vlre4eWgFo8Wmx9dY LS7vmsNmMeP8PiYHFo/NS+o9+rasYvT4vEkugDlKz6Yov7QkVSEjv7jEVina0MJIz9DSQs/I xFLP0Ng81srIVEnfziYlNSezLLVI3y5BL2Pb1bXsBZ8mMlY8bn7J3MC4prKLkYNDQsBEYvIr ny5GLg4hgaWMEo//PmSBiEtJrJyb3sXICWQKS/y51sUGUfOUUaJhz0I2kASbgKNE/9ITrCC2 iECuxLVDR9lBbGYBe4mJs/6D1QgLREvcudYLFmcRUJW4vKqVBcTmFbCSWLBvNhPEAnmJ873r wGo4BawlPq7+DTZTSCBbomvPK0aIekGJkzOfgN3GLKAusX6eEEiYX0BLYk3TdRaItfISzVtn M09gFJqFpGMWQscsJFULGJlXMYqklhbnpucWG+kVJ+YWl+al6yXn525iBMbItmM/t+xg7HoX fIhRgINRiYfX44xRnBBrYllxZe4hRgkOZiURXlFXwzgh3pTEyqrUovz4otKc1OJDjKZAb05k lhJNzgfGb15JvKGpobmFpaG5sbmxmYWSOG+HwMEYIYH0xJLU7NTUgtQimD4mDk6pBsaTkh/S kmoiPjyzeavk5x39/Okk9/2/q1yvKhy/uv7YUzbnk9UF2WvUZZpUF+4VUTp+NZDD/2Ja/OIZ lhNuMPYoB97cavRibe6dpY55yU3Vl2+IV0d8uqviZHd4bY9222Yv3tiJp9omNnEqvG2KVDPZ /HPa4n7h99oH79TqlmhfT2VhTOMJ5VBiKc5INNRiLipOBAAsOc8cpwIAAA== X-CMS-MailID: 20200130124315eucas1p12d5380c44b68d08ae96849056303e175 X-Msg-Generator: CA X-RootMTR: 20200130124315eucas1p12d5380c44b68d08ae96849056303e175 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200130124315eucas1p12d5380c44b68d08ae96849056303e175 References: <20200130123934.3900-1-l.stelmach@samsung.com> <20200130124233.4006-1-l.stelmach@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200130_044318_585425_71DA2259 X-CRM114-Status: GOOD ( 17.13 ) X-Spam-Score: -5.2 (-----) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (-5.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at https://www.dnswl.org/, high trust [210.118.77.11 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [210.118.77.11 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders -0.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?=C5=81ukasz_Stelmach?= Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org This code enables booting of Linux kernel on Odroid XU4 without u-boot Signed-off-by: Łukasz Stelmach --- arch/arm/Kconfig | 8 ++ arch/arm/Makefile | 8 +- arch/arm/boot/Makefile | 17 +++ arch/arm/boot/loader/Kconfig | 23 +++ arch/arm/boot/loader/Makefile | 42 ++++++ arch/arm/boot/loader/odroid-console.c | 136 ++++++++++++++++++ arch/arm/boot/loader/odroid-crt0.S | 40 ++++++ arch/arm/boot/loader/piggy.S | 14 ++ arch/arm/boot/loader/vectors.S | 112 +++++++++++++++ arch/arm/boot/loader/vmlinux.lds | 17 +++ .../configs/odroidxu4_bootloader_defconfig | 127 ++++++++++++++++ 11 files changed, 543 insertions(+), 1 deletion(-) create mode 100644 arch/arm/boot/loader/Kconfig create mode 100644 arch/arm/boot/loader/Makefile create mode 100644 arch/arm/boot/loader/odroid-console.c create mode 100644 arch/arm/boot/loader/odroid-crt0.S create mode 100644 arch/arm/boot/loader/piggy.S create mode 100644 arch/arm/boot/loader/vectors.S create mode 100644 arch/arm/boot/loader/vmlinux.lds create mode 100644 arch/arm/configs/odroidxu4_bootloader_defconfig diff --git arch/arm/Kconfig arch/arm/Kconfig index 96dab76da3b3..576d90071ba5 100644 --- arch/arm/Kconfig +++ arch/arm/Kconfig @@ -1715,6 +1715,13 @@ endmenu menu "Boot options" +menu "Bootloader" + depends on BLK_DEV_INITRD + +source "arch/arm/boot/loader/Kconfig" + +endmenu + config USE_OF bool "Flattened Device Tree support" select IRQ_DOMAIN @@ -1982,6 +1989,7 @@ config DMI firmware need to be enabled. This would require the DMI subsystem to be enabled much earlier than we do on ARM, which is non-trivial. + endmenu menu "CPU Power Management" diff --git arch/arm/Makefile arch/arm/Makefile index db857d07114f..0c2c3d0039ec 100644 --- arch/arm/Makefile +++ arch/arm/Makefile @@ -328,11 +328,17 @@ archprepare: # Convert bzImage to zImage bzImage: zImage -BOOT_TARGETS = zImage Image xipImage bootpImage uImage +BOOT_TARGETS = zImage Image xipImage bootImage bootpImage uImage INSTALL_TARGETS = zinstall uinstall install PHONY += bzImage $(BOOT_TARGETS) $(INSTALL_TARGETS) +ifeq ($(compress-y),) +bootImage: Image +else +bootImage: zImage +endif + bootpImage uImage: zImage zImage: Image diff --git arch/arm/boot/Makefile arch/arm/boot/Makefile index 0b3cd7a33a26..20fc5cccaa1e 100644 --- arch/arm/boot/Makefile +++ arch/arm/boot/Makefile @@ -66,8 +66,25 @@ $(obj)/compressed/vmlinux: $(obj)/Image FORCE $(obj)/zImage: $(obj)/compressed/vmlinux FORCE $(call if_changed,objcopy) +compress-$(CONFIG_KERNEL_GZIP) = gzip +compress-$(CONFIG_KERNEL_LZO) = lzo +compress-$(CONFIG_KERNEL_LZMA) = lzma +compress-$(CONFIG_KERNEL_XZ) = xzkern +compress-$(CONFIG_KERNEL_LZ4) = lz4 + +ifeq ($(compress-y),) +$(obj)/loader/vmlinux: $(obj)/Image dtbs FORCE + $(Q)$(MAKE) $(build)=$(obj)/loader $@ +else +$(obj)/loader/vmlinux: $(obj)/zImage FORCE + $(Q)$(MAKE) $(build)=$(obj)/loader $@ +endif + endif +$(obj)/bootImage: $(obj)/loader/vmlinux FORCE + $(call if_changed,objcopy) + ifneq ($(LOADADDR),) UIMAGE_LOADADDR=$(LOADADDR) else diff --git arch/arm/boot/loader/Kconfig arch/arm/boot/loader/Kconfig new file mode 100644 index 000000000000..bc69bf59241a --- /dev/null +++ arch/arm/boot/loader/Kconfig @@ -0,0 +1,23 @@ +choice + prompt "Select platform to boot" + + config BOOT_LOADER_XU4 + bool "Odroid XU4" + depends on ARCH_EXYNOS5 + help + Build a kernel loadable by XU4 firmware + + config BOOT_LOADER_XU3 + bool "Odroid XU3" + depends on ARCH_EXYNOS5 + help + Build a kernel loadable by XU3 firmware +endchoice + +config BOOT_LOADER_PLATFORM + string + default exynos5422-odroidxu4 if BOOT_LOADER_XU4 + default exynos5422-odroidxu3 if BOOT_LOADER_XU3 + default "" + + diff --git arch/arm/boot/loader/Makefile arch/arm/boot/loader/Makefile new file mode 100644 index 000000000000..014ccbf6885a --- /dev/null +++ arch/arm/boot/loader/Makefile @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# linux/arch/arm/boot/loader/Makefile +# +# create a bootable image for selected platform +# + + +DTB := $(subst $(quote),,$(obj)/../dts/$(CONFIG_BOOT_LOADER_PLATFORM).dtb) +OBJS = + +loader-$(CONFIG_BOOT_LOADER_XU3) = odroid-console.o odroid-crt0.o +loader-$(CONFIG_BOOT_LOADER_XU4) = odroid-console.o odroid-crt0.o + +compress-$(CONFIG_KERNEL_GZIP) = gzip +compress-$(CONFIG_KERNEL_LZO) = lzo +compress-$(CONFIG_KERNEL_LZMA) = lzma +compress-$(CONFIG_KERNEL_XZ) = xzkern +compress-$(CONFIG_KERNEL_LZ4) = lz4 + +ifeq ($(compress-y),) +IMAGE = $(obj)/../Image +else +IMAGE = $(obj)/../zImage +endif +AFLAGS_piggy.o = -DIMAGE=\"$(IMAGE)\" -DFDT=\"$(DTB)\" + +$(obj)/piggy.o: $(IMAGE) $(DTB) + +CFLAGS_odroid-console.o = -D__UART_BASE=$(shell $(srctree)/scripts/get_console_base.pl $(obj)/../dts/$(CONFIG_BOOT_LOADER_PLATFORM).dtb) + +targets := vmlinux + +LDFLAGS_vmlinux = +# Next argument is a linker script +LDFLAGS_vmlinux += -Ttext 0x43E00000 -T + +targets := vmlinux vectors.o piggy.o $(loader-y) + +$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/vectors.o $(addprefix $(obj)/, $(loader-y)) \ + $(obj)/piggy.o FORCE + $(call if_changed,ld) diff --git arch/arm/boot/loader/odroid-console.c arch/arm/boot/loader/odroid-console.c new file mode 100644 index 000000000000..40dec77fd0ed --- /dev/null +++ arch/arm/boot/loader/odroid-console.c @@ -0,0 +1,136 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2020 Samsung Electronics, Co. Ltd. */ + +#include + +/* Dummy functions to avoid linker complaints */ +void __aeabi_unwind_cpp_pr0(void) +{ +}; +#define arm_heavy_mb() + +#define GPIO_BASE ((void*)0x14010000) +#define GPA1CON (GPIO_BASE + 0x20) +#define GPA1DAT (GPIO_BASE + 0x24) +#define GPA1PUD (GPIO_BASE + 0x28) +#define GPA1DRV_SR (GPIO_BASE + 0x2c) +#define GPA1CONPDN (GPIO_BASE + 0x20) +#define GPA1PUDPDN (GPIO_BASE + 0x24) + +#define GPA1CON0_UART2RX (0x2 << 0) +#define GPA1CON1_UART2TX (0x2 << 4) +#define GPA1CON2_UART2CTS (0x2 << 8) +#define GPA1CON3_UART2RTS (0x2 << 12) + +#define GPA1_UART2MASK (0xffff) +#define GPA1PUD_UART2MASK (0xff) + +#ifndef __UART_BASE +#error __UART_BASE not defined +#else +#define UART_BASE ((void*)__UART_BASE) +#endif + +#define S3C2410_ULCON (0x00) +#define S3C2410_UCON (0x04) +#define S3C2410_UFCON (0x08) +#define S3C2410_UMCON (0x0C) +#define S3C2410_UBRDIV (0x28) +#define S3C2410_FRACVAL (0x2C) + +#define UART_ULCON (UART_BASE + S3C2410_ULCON) +#define UART_UCON (UART_BASE + S3C2410_UCON) +#define UART_UFCON (UART_BASE + S3C2410_UFCON) +#define UART_UMCON (UART_BASE + S3C2410_UMCON) +#define UART_UBRDIV (UART_BASE + S3C2410_UBRDIV) +#define UART_UFRACVAL (UART_BASE + S3C2410_FRACVAL) + +#define S5PV210_ULCON_CS5 (0) +#define S5PV210_ULCON_CS6 (1) +#define S5PV210_ULCON_CS7 (2) +#define S5PV210_ULCON_CS8 (3) +#define S5PV210_ULCON_CSTOPB (1 << 2) /* two stop bits */ +#define S5PV210_ULCON_PARODD (4 << 3) /* parity check: odd */ +#define S5PV210_ULCON_PAREVN (5 << 3) /* parity check: even */ +#define S5PV210_ULCON_IRDA (1 << 6) /* Infrared Mode */ +#define S5PV210_ULCON_DEFAULT (S5PV210_ULCON_CS8) /* 8N1 */ + +#define S3C2410_UCON_RXIRQMODE (1<<0) +#define S3C2410_UCON_TXIRQMODE (1<<2) +#define S3C2410_UCON_SBREAK (1<<4) +#define S3C2443_UCON_LOOPBACK (1<<5) +#define S3C2443_UCON_RXERR_IRQEN (1<<6) +#define S3C2410_UCON_RXFIFO_TOI (1<<7) +#define S3C2410_UCON_RXILEVEL (1<<8) +#define S3C2410_UCON_TXILEVEL (1<<9) +#define S5PV210_UCON_DEFAULT ( \ + S3C2410_UCON_RXIRQMODE | \ + S3C2410_UCON_TXIRQMODE | \ + S3C2443_UCON_RXERR_IRQEN | 0) + +#define S3C2410_UFCON_FIFOMODE (1<<0) +#define S3C2410_UFCON_RESETRX (1<<1) +#define S3C2410_UFCON_RESETTX (1<<2) +#define S3C2410_UFCON_RESETBOTH (3<<1) + +#define S5PV210_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \ + S3C2410_UFCON_RESETBOTH) + + +/* CLK_SRC_PERIC0 */ +#define PWM_SEL 6 +#define UART3_SEL 6 +#define UART2_SEL 6 +#define UART1_SEL 6 +#define UART0_SEL 6 +/* SRC_CLOCK = SCLK_MPLL */ +#define CLK_SRC_PERIC0_VAL ((PWM_SEL << 24) \ + | (UART3_SEL << 12) \ + | (UART2_SEL << 8) \ + | (UART1_SEL << 4) \ + | (UART0_SEL)) + + +#define UART5_RATIO 7 +#define UART4_RATIO 7 +#define UART3_RATIO 7 +#define UART2_RATIO 7 +#define UART1_RATIO 7 +#define UART0_RATIO 7 + +#define CLK_DIV_PERIC0_VAL ((UART3_RATIO << 12) \ + | (UART2_RATIO << 8) \ + | (UART1_RATIO << 4) \ + | (UART0_RATIO)) + + +#define CLK_SRC_PERIC0 (0x10020250) +#define CLK_DIV_PERIC0 (0x10020558) + +void console_on(void) { + int a; + a = readl(GPA1CON); + a = (a & ~GPA1_UART2MASK) | + GPA1CON0_UART2RX | + GPA1CON1_UART2TX | + GPA1CON2_UART2CTS | + GPA1CON3_UART2RTS; + writel(a, GPA1CON); + + a = readl(GPA1PUD) & ~GPA1PUD_UART2MASK; + writel(a, GPA1PUD); + + /* UART2_SEL: SCLK_MPLL (3)*/ + /* MPLL_M: 266 */ + /* MPLL_P: 3 */ + /* MPLL_S: 2 */ + /* UART2_RATIO: 9 */ + + writel(S5PV210_UFCON_DEFAULT, UART_UFCON); + writel(0, UART_UMCON); + writel(S5PV210_ULCON_DEFAULT, UART_ULCON); + writel(S5PV210_UCON_DEFAULT, UART_UCON); + + writel(0x1b, UART_UBRDIV); + writel(0x0d, UART_UFRACVAL); +} diff --git arch/arm/boot/loader/odroid-crt0.S arch/arm/boot/loader/odroid-crt0.S new file mode 100644 index 000000000000..586bb8e18d78 --- /dev/null +++ arch/arm/boot/loader/odroid-crt0.S @@ -0,0 +1,40 @@ +/* + * crt0 - C-runtime startup Code for ARM + * + * Copyright (c) 2012 Albert ARIBAUD + * Copyright (c) 2020 Samsung Electronics, Co. Ltd. + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#include + +splash: .asciz "boot/loader\r\n\7" +/* + * entry point of crt0 sequence + */ + .arm +ENTRY(_main) + ldr sp, =user_stack_end + bl console_on + mov r0, #0x12C00000 + add r0, r0, #0x20000 + adr r2, splash +_putc: ldrb r1, [r2] + teq r1, #0 + beq _done + strb r1, [r0, #0x20] /* UTXH */ + add r2, r2, #1 + b _putc +_done: + mov r0, #0 + mov r1, #~0 + ldr r2, =dt_blob_start + b zImage +ENDPROC(_main) + + + .align 2 + .section ".stack", "aw", %nobits +user_stack: .space 64 +user_stack_end: diff --git arch/arm/boot/loader/piggy.S arch/arm/boot/loader/piggy.S new file mode 100644 index 000000000000..ae0c9f770741 --- /dev/null +++ arch/arm/boot/loader/piggy.S @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + .section .piggydata,#alloc + .align 12 + .globl dt_blob_start +dt_blob_start: + .incbin FDT + .globl dt_blob_end +dt_blob_end: + .align 12 + .globl zImage +zImage: + .incbin IMAGE + .globl zImage_end +zImage_end: diff --git arch/arm/boot/loader/vectors.S arch/arm/boot/loader/vectors.S new file mode 100644 index 000000000000..744ee4625b6e --- /dev/null +++ arch/arm/boot/loader/vectors.S @@ -0,0 +1,112 @@ +/* + * vectors - Generic ARM exception table code + * + * Copyright (c) 1998 Dan Malek + * Copyright (c) 1999 Magnus Damm + * Copyright (c) 2000 Wolfgang Denk + * Copyright (c) 2001 Alex Züpke + * Copyright (c) 2001 Marius Gröger + * Copyright (c) 2002 Alex Züpke + * Copyright (c) 2002 Gary Jennejohn + * Copyright (c) 2002 Kyle Harris + * Copyright (c) 2020 Samsung Electronics, Co. Ltd. + * + * SPDX-License-Identifier: GPL-2.0 + */ + +/* From head.S */ + AR_CLASS( .arch armv7-a ) + M_CLASS( .arch armv7-m ) + +/* + ************************************************************************* + * + * Symbol _start is referenced elsewhere, so make it global + * + ************************************************************************* + */ + +.globl _start + +/* + ************************************************************************* + * + * Vectors have their own section so linker script can map them easily + * + ************************************************************************* + */ + + .section ".vectors", "ax" + .arm + +/* + ************************************************************************* + * + * Exception vectors as described in ARM reference manuals + * + * Uses indirect branch to allow reaching handlers anywhere in memory. + * + ************************************************************************* + */ + +_start: + b _main + ldr pc, _undefined_instruction + ldr pc, _software_interrupt + ldr pc, _prefetch_abort + ldr pc, _data_abort + ldr pc, _not_used + ldr pc, _irq + ldr pc, _fiq + +/* + ************************************************************************* + * + * Indirect vectors table + * + * Symbols referenced here must be defined somewhere else + * + ************************************************************************* + */ + + .globl _undefined_instruction + .globl _software_interrupt + .globl _prefetch_abort + .globl _data_abort + .globl _not_used + .globl _irq + .globl _fiq + +_undefined_instruction: .word undefined_instruction +_software_interrupt: .word software_interrupt +_prefetch_abort: .word prefetch_abort +_data_abort: .word data_abort +_not_used: .word not_used +_irq: .word irq +_fiq: .word fiq + + .balignl 16,0xdeadbeef + +/* + ************************************************************************* + * + * Interrupt handling + * + ************************************************************************* + */ + +/* SPL interrupt handling: just hang */ + + .align 5 +undefined_instruction: +software_interrupt: +prefetch_abort: +data_abort: +not_used: +irq: +fiq: + +1: + bl 1b /* hang and never return */ + + diff --git arch/arm/boot/loader/vmlinux.lds arch/arm/boot/loader/vmlinux.lds new file mode 100644 index 000000000000..bbd45def56a2 --- /dev/null +++ arch/arm/boot/loader/vmlinux.lds @@ -0,0 +1,17 @@ +OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") +OUTPUT_ARCH(arm) +ENTRY(_start) +SECTIONS +{ + . = 0x00000000; + . = ALIGN(4); + .text : + { + *(.vectors) + *(.text*) + } + . = ALIGN(4096); + .piggydata : { *(.piggydata) } + . = ALIGN(8); + .stack : { *(.stack) } +} diff --git arch/arm/configs/odroidxu4_bootloader_defconfig arch/arm/configs/odroidxu4_bootloader_defconfig new file mode 100644 index 000000000000..88961d952613 --- /dev/null +++ arch/arm/configs/odroidxu4_bootloader_defconfig @@ -0,0 +1,127 @@ +CONFIG_BOOT_LOADER_XU4=y +CONFIG_LOCALVERSION="-boot-loader" +CONFIG_KERNEL_XZ=y +CONFIG_DEFAULT_HOSTNAME="boot-loader" +# CONFIG_SWAP is not set +# CONFIG_CROSS_MEMORY_ATTACH is not set +CONFIG_NO_HZ=y +CONFIG_HIGH_RES_TIMERS=y +CONFIG_BLK_DEV_INITRD=y +CONFIG_INITRAMFS_SOURCE="tools/hsinit/initramfs.cpio" +# CONFIG_RD_GZIP is not set +# CONFIG_RD_BZIP2 is not set +# CONFIG_RD_LZMA is not set +# CONFIG_RD_LZO is not set +# CONFIG_RD_LZ4 is not set +CONFIG_CC_OPTIMIZE_FOR_SIZE=y +# CONFIG_MULTIUSER is not set +# CONFIG_SYSFS_SYSCALL is not set +# CONFIG_FHANDLE is not set +# CONFIG_BUG is not set +# CONFIG_BASE_FULL is not set +# CONFIG_SHMEM is not set +# CONFIG_AIO is not set +# CONFIG_IO_URING is not set +# CONFIG_ADVISE_SYSCALLS is not set +# CONFIG_MEMBARRIER is not set +# CONFIG_KALLSYMS is not set +# CONFIG_RSEQ is not set +CONFIG_EMBEDDED=y +# CONFIG_VM_EVENT_COUNTERS is not set +CONFIG_SLOB=y +CONFIG_ARCH_EXYNOS=y +# CONFIG_ARCH_EXYNOS3 is not set +# CONFIG_ARCH_EXYNOS4 is not set +# CONFIG_SOC_EXYNOS5250 is not set +# CONFIG_SOC_EXYNOS5260 is not set +# CONFIG_SOC_EXYNOS5410 is not set +# CONFIG_SOC_EXYNOS5800 is not set +CONFIG_HAVE_ARM_ARCH_TIMER=y +CONFIG_THUMB2_KERNEL=y +CONFIG_HIGHMEM=y +CONFIG_SECCOMP=y +# CONFIG_ATAGS is not set +CONFIG_ZBOOT_ROM_TEXT=0x0 +CONFIG_ZBOOT_ROM_BSS=0x0 +CONFIG_ARM_APPENDED_DTB=y +CONFIG_CMDLINE="earlycon debug console=ttySAC2,115200n8 clk_ignore_unused hs=/dev/mmcblk1p6:uroot.cpio.gz" +CONFIG_KEXEC=y +CONFIG_VFP=y +# CONFIG_SUSPEND is not set +CONFIG_PM=y +# CONFIG_BLK_DEV_BSG is not set +CONFIG_PARTITION_ADVANCED=y +# CONFIG_MQ_IOSCHED_DEADLINE is not set +# CONFIG_MQ_IOSCHED_KYBER is not set +# CONFIG_COREDUMP is not set +# CONFIG_COMPACTION is not set +CONFIG_DEVTMPFS=y +CONFIG_DEVTMPFS_MOUNT=y +CONFIG_SCSI=y +CONFIG_BLK_DEV_SD=y +CONFIG_CHR_DEV_SG=y +# CONFIG_INPUT is not set +# CONFIG_SERIO is not set +# CONFIG_VT is not set +# CONFIG_LEGACY_PTYS is not set +# CONFIG_DEVMEM is not set +CONFIG_SERIAL_SAMSUNG=y +CONFIG_SERIAL_SAMSUNG_CONSOLE=y +# CONFIG_HW_RANDOM is not set +CONFIG_I2C=y +CONFIG_I2C_CHARDEV=y +CONFIG_I2C_MUX=y +CONFIG_I2C_ARB_GPIO_CHALLENGE=y +CONFIG_I2C_GPIO=y +CONFIG_I2C_S3C2410=y +CONFIG_SENSORS_PWM_FAN=y +CONFIG_THERMAL_EMULATION=y +CONFIG_MFD_SEC_CORE=y +CONFIG_REGULATOR=y +CONFIG_REGULATOR_FIXED_VOLTAGE=y +CONFIG_REGULATOR_GPIO=y +CONFIG_REGULATOR_S2MPS11=y +# CONFIG_USB_SUPPORT is not set +CONFIG_MMC=y +# CONFIG_PWRSEQ_SIMPLE is not set +CONFIG_MMC_BLOCK_MINORS=16 +CONFIG_MMC_SDHCI=y +CONFIG_MMC_SDHCI_S3C=y +CONFIG_MMC_SDHCI_S3C_DMA=y +CONFIG_MMC_DW=y +CONFIG_MMC_DW_EXYNOS=y +CONFIG_NEW_LEDS=y +CONFIG_LEDS_CLASS=y +CONFIG_LEDS_CLASS_FLASH=y +CONFIG_LEDS_GPIO=y +CONFIG_LEDS_PWM=y +CONFIG_LEDS_TRIGGERS=y +CONFIG_LEDS_TRIGGER_HEARTBEAT=y +# CONFIG_VIRTIO_MENU is not set +CONFIG_COMMON_CLK_S2MPS11=y +# CONFIG_EXYNOS_AUDSS_CLK_CON is not set +# CONFIG_IOMMU_SUPPORT is not set +CONFIG_PWM=y +CONFIG_PWM_SAMSUNG=y +# CONFIG_PHY_EXYNOS_DP_VIDEO is not set +# CONFIG_PHY_EXYNOS_MIPI_VIDEO is not set +CONFIG_NVMEM=y +# CONFIG_FILE_LOCKING is not set +# CONFIG_DNOTIFY is not set +# CONFIG_INOTIFY_USER is not set +CONFIG_VFAT_FS=y +# CONFIG_PROC_SYSCTL is not set +# CONFIG_PROC_PAGE_MONITOR is not set +# CONFIG_MISC_FILESYSTEMS is not set +CONFIG_NLS_CODEPAGE_437=y +CONFIG_NLS_ISO8859_1=y +CONFIG_PRINTK_TIME=y +# CONFIG_SECTION_MISMATCH_WARN_ONLY is not set +CONFIG_MAGIC_SYSRQ=y +# CONFIG_DEBUG_MISC is not set +# CONFIG_SCHED_DEBUG is not set +# CONFIG_FTRACE is not set +CONFIG_DEBUG_LL=y +CONFIG_DEBUG_S3C_UART2=y +CONFIG_DEBUG_UNCOMPRESS=y +# CONFIG_RUNTIME_TESTING_MENU is not set