[PATCH 1/1] arm: cpu: armv7m: add required .type name, %function directive
Johannes Krottmayer
johannes at krotti42.com
Wed May 7 23:18:25 CEST 2025
Hello Tom, Patrick and Patrice!
For the ARMv7-M architecture depended code and for the boards as
example from STMicroelectronics:
There are a few missing but 'maybe' required initialization steps
which I haven't seen yet in the U-Boot code:
1) AHB (Advanced High-performance Bus)
According the TRM from the ARMv7-M architecture, this peripheral
bus should be enabled in the startup code.
2) ITCM/DTCM Tightly Coupled Memory (Instruction/Data)
Some ARMv7-M includes this memory type and should also be enabled
in the startup code.
3) Low-level init (currently not implemented)
STMicroelectronis SoC's need a low-level initialization for
the AXI-SRAM. To use this RAM type, there must be a few steps
done into the PWR (power) register from the SoC. If not
the SoC runs in limited mode (Run*) and write/reads to this
RAM might be corrupted. If U-Boot use this RAM for itself
then this step should be done before any stack usage.
I hope Patrick or Patrice can clarify that. Could also be possible
that I have misunderstood the ST TRM's.
4) Doesn't U-Boot use an ICache and DCache for itself?
Invalidation also missing in the startup code. I have seen the
ICache/DCache will disabled before Linux, but currently I
didn't seen if U-Boot use also the caches.
On 5/7/25 21:07, Johannes Krottmayer wrote:
> Hi Tom!
>
> Okay, STT_FUNC is an alternative spelling for %function, didn't
> know that before. So my question is deprecated.
>
> Sorry, for wasting your time.
>
> BTW, I will add the required macros and also try to add the VFP
> support. But I think it's better in two different patches. First
> patch with the ENTRY/ENDPROC macros and later with the VFP patch.
>
> On 5/7/25 20:17, Johannes Krottmayer wrote:
>> Hi Tom!
>>
>> Thanks for the quick response!
>>
>> On 5/7/25 18:55, Tom Rini wrote:
>>> On Wed, May 07, 2025 at 06:07:54AM +0000, Johannes Krottmayer wrote:
>>>
>>>> Since GNU binutils version 2.44, assembly functions must include
>>>> the assembler directive .type name, %function. If not a call to
>>>> these functions fails with the error message 'Unknown destination
>>>> type (ARM/Thumb)' and the error message 'dangerous relocation:
>>>> unsupported relocation' at linking.
>>>>
>>>> Signed-off-by: Johannes Krottmayer <johannes at krotti42.com>
>>>> Cc: Tom Rini <trini at konsulko.com>
>>>> ---
>>>> arch/arm/cpu/armv7m/start.S | 1 +
>>>> 1 file changed, 1 insertion(+)
>>>>
>>>> diff --git a/arch/arm/cpu/armv7m/start.S b/arch/arm/cpu/armv7m/start.S
>>>> index 0c07f2140c7..c20f01a0aed 100644
>>>> --- a/arch/arm/cpu/armv7m/start.S
>>>> +++ b/arch/arm/cpu/armv7m/start.S
>>>> @@ -12,5 +12,6 @@ reset:
>>>> W(b) _main
>>>>
>>>> .globl c_runtime_cpu_setup
>>>> +.type c_runtime_cpu_setup, %function
>>>> c_runtime_cpu_setup:
>>>> mov pc, lr
>>>
>>> Thanks for making the patch. There's an argument that this should use
>>> the ENTRY / ENDPROC macros from <linux/linkage.h> but that also shows
>>> that we're missing commit 5d4cae5fe2ea ("[ARM] VFP: fix section mismatch
>>> error") from the kernel. And so I'm fine with making a TODO to clean
>>> this up later if you don't want to embark on something a bit more
>>> complicated here.
>>>
>>
>> No problem for me to creating my simple patch. It's also not a problem
>> for me to use the required macros (ENTRY, ENDPROC). Use some similar
>> macros on my own projects too.
>>
>> I have searched for your mentioned commit from Linux, and it's okay
>> when I try to add this too in further patches. For the correct
>> initialization from the floating point unit I must look more
>> precisely into the U-Boot and Linux source code.
>>
>> But I have a question according the ENPROC macro:
>>
>> include/linux/linkage.h (from U-Boot):
>> #ifndef ENDPROC
>> #define ENDPROC(name) \
>> .type name STT_FUNC ASM_NL \
>> END(name)
>> #endif
>>
>> Especially the macro/define STT_FUNC. I have thought STT_FUNC is
>> %function, but haven't found these in the current U-Boot master
>> branch.
>>
>> Simple search with grep on the shell:
>> "
>> jk at workstation:~/Projects/U-Boot/src> grep -R STT_FUNC
>> include/linux/linkage.h: .type name STT_FUNC ASM_NL \
>> include/elf.h:#define STT_FUNC 2 /* function */
>> jk at workstation:~/Projects/U-Boot/src>
>> "
>>
>> Also tried a much more comfortable search with the elixir.bootlin
>> identifier search. As you can see STT_FUNC is defined only in the
>> ELF header. 'include/linux/linkage.h' doesn't include the ELF
>> header. And I don't know if the value 2 for STT_FUNC is an alternative
>> usage from the .type directive. 'include/linux/linkage.h' includes
>> 'asm/linkage.h'. I'm still a newbie with the U-Boot build process
>> and I think on build the machine dependent header will included
>> (arch/arm/include/linkage.h). Correct me if I'm wrong please.
>> Also there will be elf.h not included.
>>
>> Maybe the STT_FUNC will defined in build process, but shouldn't
>> I find this in a specific Makefile with a simple search with grep?
>>
>> By the I could change STT_FUNC to %function, but I didn't know
>> (not tried yet) if this has other bad effects.
>>
>> Thanks in advance!
>>
>> Kind regards,
>>
>> Johannes
>>
>>
>>
>>
>
>
More information about the U-Boot
mailing list