From patchwork Fri Mar 18 21:08:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 599712 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ozlabs.org (Postfix) with ESMTP id 3qRdCk52ctz9s9j for ; Sat, 19 Mar 2016 08:10:10 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 8E01992253; Fri, 18 Mar 2016 21:10:08 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FlHTLU1f3Qho; Fri, 18 Mar 2016 21:10:04 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id C14CB91697; Fri, 18 Mar 2016 21:09:03 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 336B81CE7D3 for ; Fri, 18 Mar 2016 21:08:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 195FF8B53A for ; Fri, 18 Mar 2016 21:08:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ty52aSMwUxze for ; Fri, 18 Mar 2016 21:08:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail.free-electrons.com (down.free-electrons.com [37.187.137.238]) by whitealder.osuosl.org (Postfix) with ESMTP id 8FEC18AFED for ; Fri, 18 Mar 2016 21:08:35 +0000 (UTC) Received: by mail.free-electrons.com (Postfix, from userid 110) id 6242F205; Fri, 18 Mar 2016 22:08:34 +0100 (CET) Received: from localhost (AToulouse-657-1-41-6.w92-146.abo.wanadoo.fr [92.146.39.6]) by mail.free-electrons.com (Postfix) with ESMTPSA id 28A201B9; Fri, 18 Mar 2016 22:08:34 +0100 (CET) From: Thomas Petazzoni To: Buildroot List Date: Fri, 18 Mar 2016 22:08:17 +0100 Message-Id: <1458335299-27409-16-git-send-email-thomas.petazzoni@free-electrons.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1458335299-27409-1-git-send-email-thomas.petazzoni@free-electrons.com> References: <1458335299-27409-1-git-send-email-thomas.petazzoni@free-electrons.com> Cc: Thomas Petazzoni , Lee Jones , Maxime Coquelin Subject: [Buildroot] [PATCH v2 15/17] afboot-stm32: use the Buildroot toolchain X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" By default, the afboot-stm32 Makefile uses "CROSS_COMPILE = arm-none-eabi-". Since I had such a toolchain installed on my system when testing afboot-stm32, I didn't realize it wasn't using the Buildroot toolchain. However, using the Buildroot toolchain doesn't immediately works for FLAT toolchains, as gcc automatically wants to create a FLAT binary. So we need to adjust the afboot-stm32 Makefile to use directly 'ld' and not 'gcc' when linking. Signed-off-by: Thomas Petazzoni --- .../0001-Use-ld-instead-of-gcc-for-linking.patch | 61 ++++++++++++++++++++++ boot/afboot-stm32/afboot-stm32.mk | 2 +- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 boot/afboot-stm32/0001-Use-ld-instead-of-gcc-for-linking.patch diff --git a/boot/afboot-stm32/0001-Use-ld-instead-of-gcc-for-linking.patch b/boot/afboot-stm32/0001-Use-ld-instead-of-gcc-for-linking.patch new file mode 100644 index 0000000..3f359dc --- /dev/null +++ b/boot/afboot-stm32/0001-Use-ld-instead-of-gcc-for-linking.patch @@ -0,0 +1,61 @@ +From 0d581abe6620ac69adec321b94390e009802f36a Mon Sep 17 00:00:00 2001 +From: Thomas Petazzoni +Date: Sun, 13 Mar 2016 14:32:33 +0100 +Subject: [PATCH] Use ld instead of gcc for linking + +Signed-off-by: Thomas Petazzoni +--- + Makefile | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/Makefile b/Makefile +index ce40314..271bb4f 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,7 @@ + CROSS_COMPILE ?= arm-none-eabi- + + CC = $(CROSS_COMPILE)gcc ++LD = $(CROSS_COMPILE)ld + OBJCOPY = $(CROSS_COMPILE)objcopy + OBJDUMP = $(CROSS_COMPILE)objdump + SIZE = $(CROSS_COMPILE)size +@@ -10,7 +11,7 @@ OPENOCD = openocd + CFLAGS := -mthumb -mcpu=cortex-m4 + CFLAGS += -ffunction-sections -fdata-sections + CFLAGS += -Os -std=gnu99 -Wall +-LDFLAGS := -nostartfiles -Wl,--gc-sections ++LINKERFLAGS := -nostartfiles --gc-sections + + obj-y += gpio.o mpu.o + obj-f4 += $(obj-y) usart-f4.o +@@ -22,22 +23,22 @@ all: stm32f429i-disco stm32429i-eval stm32f469i-disco stm32746g-eval + $(CC) -c $(CFLAGS) $< -o $@ + + stm32f429i-disco: stm32f429i-disco.o $(obj-f4) +- $(CC) -T stm32f429.lds $(LDFLAGS) -o stm32f429i-disco.elf stm32f429i-disco.o $(obj-f4) ++ $(LD) -T stm32f429.lds $(LINKERFLAGS) -o stm32f429i-disco.elf stm32f429i-disco.o $(obj-f4) + $(OBJCOPY) -Obinary stm32f429i-disco.elf stm32f429i-disco.bin + $(SIZE) stm32f429i-disco.elf + + stm32429i-eval: stm32429i-eval.o $(obj-f4) +- $(CC) -T stm32f429.lds $(LDFLAGS) -o stm32429i-eval.elf stm32429i-eval.o $(obj-f4) ++ $(LD) -T stm32f429.lds $(LINKERFLAGS) -o stm32429i-eval.elf stm32429i-eval.o $(obj-f4) + $(OBJCOPY) -Obinary stm32429i-eval.elf stm32429i-eval.bin + $(SIZE) stm32429i-eval.elf + + stm32f469i-disco: stm32f469i-disco.o $(obj-f4) +- $(CC) -T stm32f429.lds $(LDFLAGS) -o stm32f469i-disco.elf stm32f469i-disco.o $(obj-f4) ++ $(LD) -T stm32f429.lds $(LINKERFLAGS) -o stm32f469i-disco.elf stm32f469i-disco.o $(obj-f4) + $(OBJCOPY) -Obinary stm32f469i-disco.elf stm32f469i-disco.bin + $(SIZE) stm32f469i-disco.elf + + stm32746g-eval: stm32746g-eval.o $(obj-f7) +- $(CC) -T stm32f429.lds $(LDFLAGS) -o stm32746g-eval.elf stm32746g-eval.o $(obj-f7) ++ $(LD) -T stm32f429.lds $(LINKERFLAGS) -o stm32746g-eval.elf stm32746g-eval.o $(obj-f7) + $(OBJCOPY) -Obinary stm32746g-eval.elf stm32746g-eval.bin + $(SIZE) stm32746g-eval.elf + +-- +2.6.4 + diff --git a/boot/afboot-stm32/afboot-stm32.mk b/boot/afboot-stm32/afboot-stm32.mk index ac85d58..042b21f 100644 --- a/boot/afboot-stm32/afboot-stm32.mk +++ b/boot/afboot-stm32/afboot-stm32.mk @@ -8,7 +8,7 @@ AFBOOT_STM32_VERSION = v0.1 AFBOOT_STM32_SITE = $(call github,mcoquelin-stm32,afboot-stm32,$(AFBOOT_STM32_VERSION)) define AFBOOT_STM32_BUILD_CMDS - $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) all + $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) CROSS_COMPILE=$(TARGET_CROSS) all endef define AFBOOT_STM32_INSTALL_TARGET_CMDS