ARM: Add ARMv7-M support
RFC 1/1 ARM: Add ARMv7-M support
From: Kamil Lulko <[email protected]>
I am working on STM32F429-Discovery board support for U-Boot. This is a low-cost and fun board boasting LCD screen, bells and whistles for just under 24$. This board seems to be popular in commercial environments for evaluating ARM in deeply embedded applications. I would like to add support for this board in the mainline U-Boot but "new" architecture support is needed first (ARMv7-M variant is slightly different from other ARMs). This patch implements basic architecture support which I am already using for my own Linux booting setup with this board. I would really appreciate your opinion on feasibility of this board in mainline U-Boot tree and correctness (or not) of this patch. I tried to re-use as much as possible from existing ARM code.
--- arch/arm/cpu/armv7m/Makefile | 9 ++++ arch/arm/cpu/armv7m/config.mk | 8 ++++ arch/arm/cpu/armv7m/cpu.c | 51 +++++++++++++++++++++++ arch/arm/cpu/armv7m/start.S | 18 ++++++++ arch/arm/include/asm/armv7m.h | 60 +++++++++++++++++++++++++++ arch/arm/lib/Makefile | 8 ++++ arch/arm/lib/crt0.S | 33 +++++++++++++++ arch/arm/lib/interrupts_m.c | 95 +++++++++++++++++++++++++++++++++++++++++++ arch/arm/lib/relocate.S | 4 ++ arch/arm/lib/vectors_m.S | 58 ++++++++++++++++++++++++++ 10 files changed, 344 insertions(+) create mode 100644 arch/arm/cpu/armv7m/Makefile create mode 100644 arch/arm/cpu/armv7m/config.mk create mode 100644 arch/arm/cpu/armv7m/cpu.c create mode 100644 arch/arm/cpu/armv7m/start.S create mode 100644 arch/arm/include/asm/armv7m.h create mode 100644 arch/arm/lib/interrupts_m.c create mode 100644 arch/arm/lib/vectors_m.S
arch/arm/cpu/armv7m/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +# +# (C) Copyright 2000-2006 +# Wolfgang Denk, DENX Software Engineering, wd at denx.de. +# +# SPDX-License-Identifier: GPL-2.0+ +# + +extra-y = start.o +obj-y = cpu.o
arch/arm/cpu/armv7m/config.mk new file +8 -0
@@ -0,0 +1,8 @@ +# +# (C) Copyright 2014 +# Kamil Lulko, <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# + +PLATFORM_CPPFLAGS += -march=armv7-m -mthumb
arch/arm/cpu/armv7m/cpu.c new file +51 -0
51 lines not on this page · raw message
arch/arm/cpu/armv7m/start.S new file +18 -0
@@ -0,0 +1,18 @@ +/* + * (C) Copyright 2014 + * Kamil Lulko, <[email protected]> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <config.h> +#include <linux/linkage.h> + +.globl reset +.type reset, %function +reset: + bl _main + +.globl c_runtime_cpu_setup +c_runtime_cpu_setup: + mov pc, lr
arch/arm/include/asm/armv7m.h new file +60 -0
60 lines not on this page · raw message
arch/arm/lib/Makefile +8 -0
@@ -8,11 +8,15 @@ lib-$(CONFIG_USE_PRIVATE_LIBGCC) += _ashldi3.o _ashrdi3.o _divsi3.o \ _lshrdi3.o _modsi3.o _udivsi3.o _umodsi3.o div0.o +ifdef CONFIG_ARMV7M +obj-y += vectors_m.o crt0.o +else ifdef CONFIG_ARM64 obj-y += crt0_64.o else obj-y += vectors.o crt0.o endif +endif ifndef CONFIG_SPL_BUILD ifdef CONFIG_ARM64
@@ -35,12 +39,16 @@ endif obj-$(CONFIG_SEMIHOSTING) += semihosting.o obj-y += sections.o +ifdef CONFIG_ARMV7M +obj-y += interrupts_m.o +else ifdef CONFIG_ARM64 obj-y += gic_64.o obj-y += interrupts_64.o else obj-y += interrupts.o endif +endif obj-y += reset.o obj-y += cache.o
arch/arm/lib/crt0.S +33 -0
@@ -9,6 +9,9 @@ #include <config.h> #include <asm-offsets.h> #include <linux/linkage.h> +#if defined(CONFIG_ARMV7M) +#include <asm/armv7m.h> +#endif /* * This file handles the target-independent stages of the U-Boot
@@ -66,15 +69,32 @@ ENTRY(_main) #else ldr sp, =(CONFIG_SYS_INIT_SP_ADDR) #endif +#if defined(CONFIG_ARMV7M) + /* 8-byte alignment for ABI compliance armv7-m version */ + mov r3, sp + bic r3, r3, #7 + mov sp, r3 +#else bic sp, sp, #7 /* 8-byte alignment for ABI compliance */ +#endif mov r2, sp sub sp, sp, #GD_SIZE /* allocate one GD above SP */ +#if defined(CONFIG_ARMV7M) + /* 8-byte alignment for ABI compliance armv7-m version */ + mov r3, sp + bic r3, r3, #7 + mov sp, r3 +#else bic sp, sp, #7 /* 8-byte alignment for ABI compliance */ +#endif mov r9, sp /* GD is above SP */ mov r1, sp mov r0, #0 clr_gd: cmp r1, r2 /* while not at end of GD */ +#if defined(CONFIG_ARMV7M) + itt lo +#endif strlo r0, [r1] /* clear 32-bit GD word */ addlo r1, r1, #4 /* move to next */ blo clr_gd
@@ -94,13 +114,23 @@ clr_gd: */ ldr sp, [r9, #GD_START_ADDR_SP] /* sp = gd->start_addr_sp */ +#if defined(CONFIG_ARMV7M) + /* 8-byte alignment for ABI compliance armv7-m version */ + mov r3, sp + bic r3, r3, #7 + mov sp, r3 +#else bic sp, sp, #7 /* 8-byte alignment for ABI compliance */ +#endif ldr r9, [r9, #GD_BD] /* r9 = gd->bd */ sub r9, r9, #GD_SIZE /* new GD is below bd */ adr lr, here ldr r0, [r9, #GD_RELOC_OFF] /* r0 = gd->reloc_off */ add lr, lr, r0 +#if defined(CONFIG_ARMV7M) + orr lr, #1 /* Set bit 0 as required by Thumb-2 */ +#endif ldr r0, [r9, #GD_RELOCADDR] /* r0 = gd->relocaddr */ b relocate_code here:
@@ -120,6 +150,9 @@ here: mov r2, #0x00000000 /* prepare zero to clear BSS */ clbss_l:cmp r0, r1 /* while not at end of BSS */ +#if defined(CONFIG_ARMV7M) + itt lo +#endif strlo r2, [r0] /* clear 32-bit BSS word */ addlo r0, r0, #4 /* move to next */ blo clbss_l
arch/arm/lib/interrupts_m.c new file +95 -0
95 lines not on this page · raw message
arch/arm/lib/relocate.S +4 -0
@@ -9,6 +9,10 @@ #include <asm-offsets.h> #include <config.h> #include <linux/linkage.h> +#include <config.h> +#if defined(CONFIG_ARMV7M) +#include <asm/armv7m.h> +#endif /* * Default/weak exception vectors relocation routine
arch/arm/lib/vectors_m.S new file +58 -0
58 lines not on this page · raw message
Signature · 1 line
2.2.1.212.gc5b9256
RFC 1/1 ARM: Add ARMv7-M support
Quoted 5 lines · On Wed, Jan 07, 2015 at 12:57:27AM +0100, rev13 at wp.pl wrote:
From: Kamil Lulko <[email protected]>
I am working on STM32F429-Discovery board support for U-Boot. This is a low-cost and fun board boasting LCD screen, bells and whistles for just under 24$. This board seems to be popular in commercial environments for evaluating ARM in deeply embedded applications. I would like to add support for this board in the mainline U-Boot but "new" architecture support is needed first (ARMv7-M variant is slightly different from other ARMs). This patch implements basic architecture support which I am already using for my own Linux booting setup with this board. I would really appreciate your opinion on feasibility of this board in mainline U-Boot tree and correctness (or not) of this patch. I tried to re-use as much as possible from existing ARM code.
Signed-off-by Kamil Lulko <[email protected]>
In general this looks OK. Can you also post the STM32F429 board port code? Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150120/04761bd1/attachment.pgp>
RFC 1/1 ARM: Add ARMv7-M support
Quoted 8 lines · Tom Rini
Quoted 3 lines · On Wed, Jan 07, 2015 at 12:57:27AM +0100, rev13 at wp.pl wrote:
From: Kamil Lulko <[email protected]>
<cut>
In general this looks OK. Can you also post the STM32F429 board port code? Thanks!
Yes, I will submit a complete patch set for STM32F429 Discovery board support soon.
The only thing I am missing right now is internal flash driver and some minor fixes in the existing code.
Best regards,
Kamil Lulko