Re: [U-Boot] [PATCH 8/8] mips: bmips: add support for raw .elf images

Am 13.04.2017 um 17:52 schrieb Álvaro Fernández Rojas:
CFE supports loading .elf images instead of raw binaries.
Signed-off-by: Álvaro Fernández Rojas noltari@gmail.com
Makefile | 22 ++++++++++++++++++++++ arch/mips/cpu/u-boot-elf.lds | 10 ++++++++++ 2 files changed, 32 insertions(+) create mode 100644 arch/mips/cpu/u-boot-elf.lds
diff --git a/Makefile b/Makefile index 09b597d..667b5f2 100644 --- a/Makefile +++ b/Makefile @@ -568,6 +568,15 @@ ifndef LDSCRIPT endif endif
+ifndef LDSCRIPT_ELF
- ifeq ($(wildcard $(LDSCRIPT_ELF)),)
LDSCRIPT_ELF := $(srctree)/$(CPUDIR)/u-boot-elf.lds
- endif
- ifeq ($(wildcard $(LDSCRIPT_ELF)),)
LDSCRIPT_ELF := $(srctree)/arch/$(ARCH)/cpu/u-boot-elf.lds
- endif
+endif
could you try to build the ELF binary without a custom linker script? I think the built-in one should work too.
else # Dummy target needed, because used as prerequisite include/config/auto.conf: ; @@ -786,6 +795,7 @@ ifneq ($(CONFIG_SPL_TARGET),) ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%) endif ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf +ALL-$(CONFIG_ARCH_BMIPS) += u-boot-bmips.elf ALL-$(CONFIG_EFI_APP) += u-boot-app.efi ALL-$(CONFIG_EFI_STUB) += u-boot-payload.efi
@@ -1192,6 +1202,15 @@ u-boot.elf: u-boot.bin --defsym=_start=$(CONFIG_SYS_TEXT_BASE) \ -Ttext=$(CONFIG_SYS_TEXT_BASE)
+# Rules to link u-boot-bmips +quiet_cmd_u-boot-bmips ?= LD $@
- cmd_u-boot-bmips ?= $(LD) -e startup -T u-boot-elf.lds \
- -Ttext $(CONFIG_SYS_TEXT_BASE) -o $@ u-boot-bmips.o
+u-boot-bmips.elf: u-boot.bin u-boot-elf.lds
- $(Q)$(LD) -r -b binary --oformat elf32-tradbigmips -o u-boot-bmips.o $<
- $(call if_changed,u-boot-bmips)
could you try to generate the ELF binary like in the existing rule above? If that works, we could refactor the generic rule to remove the hard-coded aarch64 flags. If not, move this code and the "ALL-$(CONFIG_ARCH_BMIPS) += u-boot-bmips.elf" to arch/mips/Makefile
Also don't forget to add new binaries to .gitignore and the Makefile clean targets.
# Rule to link u-boot # May be overridden by arch/$(ARCH)/config.mk quiet_cmd_u-boot__ ?= LD $@ @@ -1340,6 +1359,9 @@ cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) \ u-boot.lds: $(LDSCRIPT) prepare FORCE $(call if_changed_dep,cpp_lds)
+u-boot-elf.lds: $(LDSCRIPT_ELF) prepare
- $(call if_changed_dep,cpp_lds)
spl/u-boot-spl.bin: spl/u-boot-spl @: spl/u-boot-spl: tools prepare \ diff --git a/arch/mips/cpu/u-boot-elf.lds b/arch/mips/cpu/u-boot-elf.lds new file mode 100644 index 0000000..db0bb46 --- /dev/null +++ b/arch/mips/cpu/u-boot-elf.lds @@ -0,0 +1,10 @@ +OUTPUT_ARCH(mips) +SECTIONS {
- .text : {
startup = .;
*(.text)
*(.text.*)
*(.data)
*(.data.*)
- }
+}

El 14/04/2017 a las 21:05, Daniel Schwierzeck escribió:
Am 13.04.2017 um 17:52 schrieb Álvaro Fernández Rojas:
CFE supports loading .elf images instead of raw binaries.
Signed-off-by: Álvaro Fernández Rojas noltari@gmail.com
Makefile | 22 ++++++++++++++++++++++ arch/mips/cpu/u-boot-elf.lds | 10 ++++++++++ 2 files changed, 32 insertions(+) create mode 100644 arch/mips/cpu/u-boot-elf.lds
diff --git a/Makefile b/Makefile index 09b597d..667b5f2 100644 --- a/Makefile +++ b/Makefile @@ -568,6 +568,15 @@ ifndef LDSCRIPT endif endif
+ifndef LDSCRIPT_ELF
- ifeq ($(wildcard $(LDSCRIPT_ELF)),)
LDSCRIPT_ELF := $(srctree)/$(CPUDIR)/u-boot-elf.lds
- endif
- ifeq ($(wildcard $(LDSCRIPT_ELF)),)
LDSCRIPT_ELF := $(srctree)/arch/$(ARCH)/cpu/u-boot-elf.lds
- endif
+endif
could you try to build the ELF binary without a custom linker script? I think the built-in one should work too.
else # Dummy target needed, because used as prerequisite include/config/auto.conf: ; @@ -786,6 +795,7 @@ ifneq ($(CONFIG_SPL_TARGET),) ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%) endif ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf +ALL-$(CONFIG_ARCH_BMIPS) += u-boot-bmips.elf ALL-$(CONFIG_EFI_APP) += u-boot-app.efi ALL-$(CONFIG_EFI_STUB) += u-boot-payload.efi
@@ -1192,6 +1202,15 @@ u-boot.elf: u-boot.bin --defsym=_start=$(CONFIG_SYS_TEXT_BASE) \ -Ttext=$(CONFIG_SYS_TEXT_BASE)
+# Rules to link u-boot-bmips +quiet_cmd_u-boot-bmips ?= LD $@
- cmd_u-boot-bmips ?= $(LD) -e startup -T u-boot-elf.lds \
- -Ttext $(CONFIG_SYS_TEXT_BASE) -o $@ u-boot-bmips.o
+u-boot-bmips.elf: u-boot.bin u-boot-elf.lds
- $(Q)$(LD) -r -b binary --oformat elf32-tradbigmips -o u-boot-bmips.o $<
- $(call if_changed,u-boot-bmips)
could you try to generate the ELF binary like in the existing rule above? If that works, we could refactor the generic rule to remove the hard-coded aarch64 flags. If not, move this code and the "ALL-$(CONFIG_ARCH_BMIPS) += u-boot-bmips.elf" to arch/mips/Makefile
Sure, I will try and see if it works.
Also don't forget to add new binaries to .gitignore and the Makefile clean targets.
Right, my fault :).
# Rule to link u-boot # May be overridden by arch/$(ARCH)/config.mk quiet_cmd_u-boot__ ?= LD $@ @@ -1340,6 +1359,9 @@ cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) \ u-boot.lds: $(LDSCRIPT) prepare FORCE $(call if_changed_dep,cpp_lds)
+u-boot-elf.lds: $(LDSCRIPT_ELF) prepare
- $(call if_changed_dep,cpp_lds)
spl/u-boot-spl.bin: spl/u-boot-spl @: spl/u-boot-spl: tools prepare \ diff --git a/arch/mips/cpu/u-boot-elf.lds b/arch/mips/cpu/u-boot-elf.lds new file mode 100644 index 0000000..db0bb46 --- /dev/null +++ b/arch/mips/cpu/u-boot-elf.lds @@ -0,0 +1,10 @@ +OUTPUT_ARCH(mips) +SECTIONS {
- .text : {
startup = .;
*(.text)
*(.text.*)
*(.data)
*(.data.*)
- }
+}

Hi,
El 15/04/2017 a las 19:19, Álvaro Fernández Rojas escribió:
El 14/04/2017 a las 21:05, Daniel Schwierzeck escribió:
Am 13.04.2017 um 17:52 schrieb Álvaro Fernández Rojas:
CFE supports loading .elf images instead of raw binaries.
Signed-off-by: Álvaro Fernández Rojas noltari@gmail.com
Makefile | 22 ++++++++++++++++++++++ arch/mips/cpu/u-boot-elf.lds | 10 ++++++++++ 2 files changed, 32 insertions(+) create mode 100644 arch/mips/cpu/u-boot-elf.lds
diff --git a/Makefile b/Makefile index 09b597d..667b5f2 100644 --- a/Makefile +++ b/Makefile @@ -568,6 +568,15 @@ ifndef LDSCRIPT endif endif
+ifndef LDSCRIPT_ELF
- ifeq ($(wildcard $(LDSCRIPT_ELF)),)
LDSCRIPT_ELF := $(srctree)/$(CPUDIR)/u-boot-elf.lds
- endif
- ifeq ($(wildcard $(LDSCRIPT_ELF)),)
LDSCRIPT_ELF := $(srctree)/arch/$(ARCH)/cpu/u-boot-elf.lds
- endif
+endif
could you try to build the ELF binary without a custom linker script? I think the built-in one should work too.
else # Dummy target needed, because used as prerequisite include/config/auto.conf: ; @@ -786,6 +795,7 @@ ifneq ($(CONFIG_SPL_TARGET),) ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%) endif ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf +ALL-$(CONFIG_ARCH_BMIPS) += u-boot-bmips.elf ALL-$(CONFIG_EFI_APP) += u-boot-app.efi ALL-$(CONFIG_EFI_STUB) += u-boot-payload.efi
@@ -1192,6 +1202,15 @@ u-boot.elf: u-boot.bin --defsym=_start=$(CONFIG_SYS_TEXT_BASE) \ -Ttext=$(CONFIG_SYS_TEXT_BASE)
+# Rules to link u-boot-bmips +quiet_cmd_u-boot-bmips ?= LD $@
- cmd_u-boot-bmips ?= $(LD) -e startup -T u-boot-elf.lds \
- -Ttext $(CONFIG_SYS_TEXT_BASE) -o $@ u-boot-bmips.o
+u-boot-bmips.elf: u-boot.bin u-boot-elf.lds
- $(Q)$(LD) -r -b binary --oformat elf32-tradbigmips -o u-boot-bmips.o $<
- $(call if_changed,u-boot-bmips)
could you try to generate the ELF binary like in the existing rule above? If that works, we could refactor the generic rule to remove the hard-coded aarch64 flags. If not, move this code and the "ALL-$(CONFIG_ARCH_BMIPS) += u-boot-bmips.elf" to arch/mips/Makefile
Sure, I will try and see if it works.
It works, but it has to be changed: u-boot.elf: u-boot.bin @$(OBJCOPY) -B mips -I binary -O elf32-tradbigmips \ $< u-boot-elf.o @$(LD) u-boot-elf.o -o $@ \ --defsym=__start=$(CONFIG_SYS_TEXT_BASE) \ -Ttext=$(CONFIG_SYS_TEXT_BASE) Changes: 1) __start symbol instead of _start 2) mips instead of aarch64 3) elf32-tradbigmips instead of elf64-littleaarch64
Also don't forget to add new binaries to .gitignore and the Makefile clean targets.
Right, my fault :).
# Rule to link u-boot # May be overridden by arch/$(ARCH)/config.mk quiet_cmd_u-boot__ ?= LD $@ @@ -1340,6 +1359,9 @@ cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) \ u-boot.lds: $(LDSCRIPT) prepare FORCE $(call if_changed_dep,cpp_lds)
+u-boot-elf.lds: $(LDSCRIPT_ELF) prepare
- $(call if_changed_dep,cpp_lds)
spl/u-boot-spl.bin: spl/u-boot-spl @: spl/u-boot-spl: tools prepare \ diff --git a/arch/mips/cpu/u-boot-elf.lds b/arch/mips/cpu/u-boot-elf.lds new file mode 100644 index 0000000..db0bb46 --- /dev/null +++ b/arch/mips/cpu/u-boot-elf.lds @@ -0,0 +1,10 @@ +OUTPUT_ARCH(mips) +SECTIONS {
- .text : {
startup = .;
*(.text)
*(.text.*)
*(.data)
*(.data.*)
- }
+}

Am 15.04.2017 um 20:10 schrieb Álvaro Fernández Rojas:
Hi,
El 15/04/2017 a las 19:19, Álvaro Fernández Rojas escribió:
El 14/04/2017 a las 21:05, Daniel Schwierzeck escribió:
Am 13.04.2017 um 17:52 schrieb Álvaro Fernández Rojas:
CFE supports loading .elf images instead of raw binaries.
Signed-off-by: Álvaro Fernández Rojas noltari@gmail.com
Makefile | 22 ++++++++++++++++++++++ arch/mips/cpu/u-boot-elf.lds | 10 ++++++++++ 2 files changed, 32 insertions(+) create mode 100644 arch/mips/cpu/u-boot-elf.lds
diff --git a/Makefile b/Makefile index 09b597d..667b5f2 100644 --- a/Makefile +++ b/Makefile @@ -568,6 +568,15 @@ ifndef LDSCRIPT endif endif
+ifndef LDSCRIPT_ELF
- ifeq ($(wildcard $(LDSCRIPT_ELF)),)
LDSCRIPT_ELF := $(srctree)/$(CPUDIR)/u-boot-elf.lds
- endif
- ifeq ($(wildcard $(LDSCRIPT_ELF)),)
LDSCRIPT_ELF := $(srctree)/arch/$(ARCH)/cpu/u-boot-elf.lds
- endif
+endif
could you try to build the ELF binary without a custom linker script? I think the built-in one should work too.
else # Dummy target needed, because used as prerequisite include/config/auto.conf: ; @@ -786,6 +795,7 @@ ifneq ($(CONFIG_SPL_TARGET),) ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%) endif ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf +ALL-$(CONFIG_ARCH_BMIPS) += u-boot-bmips.elf ALL-$(CONFIG_EFI_APP) += u-boot-app.efi ALL-$(CONFIG_EFI_STUB) += u-boot-payload.efi
@@ -1192,6 +1202,15 @@ u-boot.elf: u-boot.bin --defsym=_start=$(CONFIG_SYS_TEXT_BASE) \ -Ttext=$(CONFIG_SYS_TEXT_BASE)
+# Rules to link u-boot-bmips +quiet_cmd_u-boot-bmips ?= LD $@
- cmd_u-boot-bmips ?= $(LD) -e startup -T u-boot-elf.lds \
- -Ttext $(CONFIG_SYS_TEXT_BASE) -o $@ u-boot-bmips.o
+u-boot-bmips.elf: u-boot.bin u-boot-elf.lds
- $(Q)$(LD) -r -b binary --oformat elf32-tradbigmips -o u-boot-bmips.o $<
- $(call if_changed,u-boot-bmips)
could you try to generate the ELF binary like in the existing rule above? If that works, we could refactor the generic rule to remove the hard-coded aarch64 flags. If not, move this code and the "ALL-$(CONFIG_ARCH_BMIPS) += u-boot-bmips.elf" to arch/mips/Makefile
Sure, I will try and see if it works.
It works, but it has to be changed: u-boot.elf: u-boot.bin @$(OBJCOPY) -B mips -I binary -O elf32-tradbigmips \ $< u-boot-elf.o @$(LD) u-boot-elf.o -o $@ \ --defsym=__start=$(CONFIG_SYS_TEXT_BASE) \ -Ttext=$(CONFIG_SYS_TEXT_BASE) Changes:
- __start symbol instead of _start
- mips instead of aarch64
- elf32-tradbigmips instead of elf64-littleaarch64
2) and 3) are expected, that's what could be fixed with a small refactoring. But why --defsym=__start? The U-Boot entry point is _start.
Also don't forget to add new binaries to .gitignore and the Makefile clean targets.
Right, my fault :).
# Rule to link u-boot # May be overridden by arch/$(ARCH)/config.mk quiet_cmd_u-boot__ ?= LD $@ @@ -1340,6 +1359,9 @@ cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) \ u-boot.lds: $(LDSCRIPT) prepare FORCE $(call if_changed_dep,cpp_lds)
+u-boot-elf.lds: $(LDSCRIPT_ELF) prepare
- $(call if_changed_dep,cpp_lds)
spl/u-boot-spl.bin: spl/u-boot-spl @: spl/u-boot-spl: tools prepare \ diff --git a/arch/mips/cpu/u-boot-elf.lds b/arch/mips/cpu/u-boot-elf.lds new file mode 100644 index 0000000..db0bb46 --- /dev/null +++ b/arch/mips/cpu/u-boot-elf.lds @@ -0,0 +1,10 @@ +OUTPUT_ARCH(mips) +SECTIONS {
- .text : {
startup = .;
*(.text)
*(.text.*)
*(.data)
*(.data.*)
- }
+}

Hi,
El 15/04/2017 a las 20:54, Daniel Schwierzeck escribió:
Am 15.04.2017 um 20:10 schrieb Álvaro Fernández Rojas:
Hi,
El 15/04/2017 a las 19:19, Álvaro Fernández Rojas escribió:
El 14/04/2017 a las 21:05, Daniel Schwierzeck escribió:
Am 13.04.2017 um 17:52 schrieb Álvaro Fernández Rojas:
CFE supports loading .elf images instead of raw binaries.
Signed-off-by: Álvaro Fernández Rojas noltari@gmail.com
Makefile | 22 ++++++++++++++++++++++ arch/mips/cpu/u-boot-elf.lds | 10 ++++++++++ 2 files changed, 32 insertions(+) create mode 100644 arch/mips/cpu/u-boot-elf.lds
diff --git a/Makefile b/Makefile index 09b597d..667b5f2 100644 --- a/Makefile +++ b/Makefile @@ -568,6 +568,15 @@ ifndef LDSCRIPT endif endif
+ifndef LDSCRIPT_ELF
- ifeq ($(wildcard $(LDSCRIPT_ELF)),)
LDSCRIPT_ELF := $(srctree)/$(CPUDIR)/u-boot-elf.lds
- endif
- ifeq ($(wildcard $(LDSCRIPT_ELF)),)
LDSCRIPT_ELF := $(srctree)/arch/$(ARCH)/cpu/u-boot-elf.lds
- endif
+endif
could you try to build the ELF binary without a custom linker script? I think the built-in one should work too.
else # Dummy target needed, because used as prerequisite include/config/auto.conf: ; @@ -786,6 +795,7 @@ ifneq ($(CONFIG_SPL_TARGET),) ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%) endif ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf +ALL-$(CONFIG_ARCH_BMIPS) += u-boot-bmips.elf ALL-$(CONFIG_EFI_APP) += u-boot-app.efi ALL-$(CONFIG_EFI_STUB) += u-boot-payload.efi
@@ -1192,6 +1202,15 @@ u-boot.elf: u-boot.bin --defsym=_start=$(CONFIG_SYS_TEXT_BASE) \ -Ttext=$(CONFIG_SYS_TEXT_BASE)
+# Rules to link u-boot-bmips +quiet_cmd_u-boot-bmips ?= LD $@
- cmd_u-boot-bmips ?= $(LD) -e startup -T u-boot-elf.lds \
- -Ttext $(CONFIG_SYS_TEXT_BASE) -o $@ u-boot-bmips.o
+u-boot-bmips.elf: u-boot.bin u-boot-elf.lds
- $(Q)$(LD) -r -b binary --oformat elf32-tradbigmips -o u-boot-bmips.o $<
- $(call if_changed,u-boot-bmips)
could you try to generate the ELF binary like in the existing rule above? If that works, we could refactor the generic rule to remove the hard-coded aarch64 flags. If not, move this code and the "ALL-$(CONFIG_ARCH_BMIPS) += u-boot-bmips.elf" to arch/mips/Makefile
Sure, I will try and see if it works.
It works, but it has to be changed: u-boot.elf: u-boot.bin @$(OBJCOPY) -B mips -I binary -O elf32-tradbigmips \ $< u-boot-elf.o @$(LD) u-boot-elf.o -o $@ \ --defsym=__start=$(CONFIG_SYS_TEXT_BASE) \ -Ttext=$(CONFIG_SYS_TEXT_BASE) Changes:
- __start symbol instead of _start
- mips instead of aarch64
- elf32-tradbigmips instead of elf64-littleaarch64
- and 3) are expected, that's what could be fixed with a small
refactoring. But why --defsym=__start? The U-Boot entry point is _start.
--defsym=_start throws the following error: mips-openwrt-linux-ld.bfd: warning: cannot find entry symbol __start; defaulting to 0000000080010000 However, --defsym=__start throws no errors...
Also don't forget to add new binaries to .gitignore and the Makefile clean targets.
Right, my fault :).
# Rule to link u-boot # May be overridden by arch/$(ARCH)/config.mk quiet_cmd_u-boot__ ?= LD $@ @@ -1340,6 +1359,9 @@ cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) \ u-boot.lds: $(LDSCRIPT) prepare FORCE $(call if_changed_dep,cpp_lds)
+u-boot-elf.lds: $(LDSCRIPT_ELF) prepare
- $(call if_changed_dep,cpp_lds)
spl/u-boot-spl.bin: spl/u-boot-spl @: spl/u-boot-spl: tools prepare \ diff --git a/arch/mips/cpu/u-boot-elf.lds b/arch/mips/cpu/u-boot-elf.lds new file mode 100644 index 0000000..db0bb46 --- /dev/null +++ b/arch/mips/cpu/u-boot-elf.lds @@ -0,0 +1,10 @@ +OUTPUT_ARCH(mips) +SECTIONS {
- .text : {
startup = .;
*(.text)
*(.text.*)
*(.data)
*(.data.*)
- }
+}

Hi,
El 15/04/2017 a las 21:14, Álvaro Fernández Rojas escribió:
Hi,
El 15/04/2017 a las 20:54, Daniel Schwierzeck escribió:
Am 15.04.2017 um 20:10 schrieb Álvaro Fernández Rojas:
Hi,
El 15/04/2017 a las 19:19, Álvaro Fernández Rojas escribió:
El 14/04/2017 a las 21:05, Daniel Schwierzeck escribió:
Am 13.04.2017 um 17:52 schrieb Álvaro Fernández Rojas:
CFE supports loading .elf images instead of raw binaries.
Signed-off-by: Álvaro Fernández Rojas noltari@gmail.com
Makefile | 22 ++++++++++++++++++++++ arch/mips/cpu/u-boot-elf.lds | 10 ++++++++++ 2 files changed, 32 insertions(+) create mode 100644 arch/mips/cpu/u-boot-elf.lds
diff --git a/Makefile b/Makefile index 09b597d..667b5f2 100644 --- a/Makefile +++ b/Makefile @@ -568,6 +568,15 @@ ifndef LDSCRIPT endif endif
+ifndef LDSCRIPT_ELF
- ifeq ($(wildcard $(LDSCRIPT_ELF)),)
LDSCRIPT_ELF := $(srctree)/$(CPUDIR)/u-boot-elf.lds
- endif
- ifeq ($(wildcard $(LDSCRIPT_ELF)),)
LDSCRIPT_ELF := $(srctree)/arch/$(ARCH)/cpu/u-boot-elf.lds
- endif
+endif
could you try to build the ELF binary without a custom linker script? I think the built-in one should work too.
else # Dummy target needed, because used as prerequisite include/config/auto.conf: ; @@ -786,6 +795,7 @@ ifneq ($(CONFIG_SPL_TARGET),) ALL-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%) endif ALL-$(CONFIG_REMAKE_ELF) += u-boot.elf +ALL-$(CONFIG_ARCH_BMIPS) += u-boot-bmips.elf ALL-$(CONFIG_EFI_APP) += u-boot-app.efi ALL-$(CONFIG_EFI_STUB) += u-boot-payload.efi
@@ -1192,6 +1202,15 @@ u-boot.elf: u-boot.bin --defsym=_start=$(CONFIG_SYS_TEXT_BASE) \ -Ttext=$(CONFIG_SYS_TEXT_BASE)
+# Rules to link u-boot-bmips +quiet_cmd_u-boot-bmips ?= LD $@
- cmd_u-boot-bmips ?= $(LD) -e startup -T u-boot-elf.lds \
- -Ttext $(CONFIG_SYS_TEXT_BASE) -o $@ u-boot-bmips.o
+u-boot-bmips.elf: u-boot.bin u-boot-elf.lds
- $(Q)$(LD) -r -b binary --oformat elf32-tradbigmips -o u-boot-bmips.o $<
- $(call if_changed,u-boot-bmips)
could you try to generate the ELF binary like in the existing rule above? If that works, we could refactor the generic rule to remove the hard-coded aarch64 flags. If not, move this code and the "ALL-$(CONFIG_ARCH_BMIPS) += u-boot-bmips.elf" to arch/mips/Makefile
Sure, I will try and see if it works.
It works, but it has to be changed: u-boot.elf: u-boot.bin @$(OBJCOPY) -B mips -I binary -O elf32-tradbigmips \ $< u-boot-elf.o @$(LD) u-boot-elf.o -o $@ \ --defsym=__start=$(CONFIG_SYS_TEXT_BASE) \ -Ttext=$(CONFIG_SYS_TEXT_BASE) Changes:
- __start symbol instead of _start
- mips instead of aarch64
- elf32-tradbigmips instead of elf64-littleaarch64
- and 3) are expected, that's what could be fixed with a small
refactoring. But why --defsym=__start? The U-Boot entry point is _start.
--defsym=_start throws the following error: mips-openwrt-linux-ld.bfd: warning: cannot find entry symbol __start; defaulting to 0000000080010000 However, --defsym=__start throws no errors...
Is this reasonable? https://gist.github.com/Noltari/d259af2709ac4cb9e091f291d7cf5e6f
Also don't forget to add new binaries to .gitignore and the Makefile clean targets.
Right, my fault :).
# Rule to link u-boot # May be overridden by arch/$(ARCH)/config.mk quiet_cmd_u-boot__ ?= LD $@ @@ -1340,6 +1359,9 @@ cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) \ u-boot.lds: $(LDSCRIPT) prepare FORCE $(call if_changed_dep,cpp_lds)
+u-boot-elf.lds: $(LDSCRIPT_ELF) prepare
- $(call if_changed_dep,cpp_lds)
spl/u-boot-spl.bin: spl/u-boot-spl @: spl/u-boot-spl: tools prepare \ diff --git a/arch/mips/cpu/u-boot-elf.lds b/arch/mips/cpu/u-boot-elf.lds new file mode 100644 index 0000000..db0bb46 --- /dev/null +++ b/arch/mips/cpu/u-boot-elf.lds @@ -0,0 +1,10 @@ +OUTPUT_ARCH(mips) +SECTIONS {
- .text : {
startup = .;
*(.text)
*(.text.*)
*(.data)
*(.data.*)
- }
+}
participants (2)
-
Daniel Schwierzeck
-
Álvaro Fernández Rojas