Hi Kevin,
It works as I expected. Thanks for the help.
Best regards.
Michel
From: Kevin Peng <Kevin.Peng@arm.com>
Sent: vendredi 19 mars 2021 03:48
To: Michel JAOUEN <michel.jaouen@st.com>; tf-m@lists.trustedfirmware.org
Subject: RE: [TF-M] Armclang linker alignement question
Hi Michel,
Please try the following:
TFM_UNPRIV_CODE AlignExpr(+0, 0x2000)
FIXED …
This would make the execution region TFM_UNPRIV_CODE aligned to 0x2000 without propagating the alignment requirement to the load regions.
And the FIXED attribute make she load address and execution address of the TFM_UNPRIV_CODE the same which is import for XIP.
Best Regards,
Kevin
From: Michel JAOUEN <michel.jaouen@st.com>
Sent: Wednesday, March 17, 2021 6:02 PM
To: Kevin Peng <Kevin.Peng@arm.com>;
tf-m@lists.trustedfirmware.org
Subject: RE: [TF-M] Armclang linker alignement question
Hello Kevin,
Yes, it works if LR_CODE is aligned to 0x2000.
But, for the other compiler (GNUARM and IAR) , I don’t need to align and it links successfully.
Regarding the alignment to 0x2000 : I need to keep LR_CODE with this 0x400 offset (not aligned on 0x2000) , which is relative to BL2_HEADER_SIZE
In fact LR_CODE is S_CODE_START defined as follow
#define S_IMAGE_PRIMARY_AREA_OFFSET (S_IMAGE_PRIMARY_PARTITION_OFFSET + BL2_HEADER_SIZE)
#define S_CODE_START (S_ROM_ALIAS(S_IMAGE_PRIMARY_AREA_OFFSET))
Best regards,
Michel
From: Kevin Peng <Kevin.Peng@arm.com>
Sent: mercredi 17 mars 2021 10:52
To: Michel JAOUEN <michel.jaouen@st.com>;
tf-m@lists.trustedfirmware.org
Subject: RE: [TF-M] Armclang linker alignement question
Hi Michel,
I see the problem: if it is XIP, then both LR and ER need to aligned.
I guess you have to align the base address(0x0c024400) of LR_CODE to align 0x2000.
Best Regards,
Kevin
From: Michel JAOUEN <michel.jaouen@st.com>
Sent: Wednesday, March 17, 2021 5:33 PM
To: Kevin Peng <Kevin.Peng@arm.com>;
tf-m@lists.trustedfirmware.org
Subject: RE: [TF-M] Armclang linker alignement question
Hello Kevin,
The image need padding to be added because the region is executed in place on flash.
So the issue is that the compiler does link successfully if the start address (LR_CODE 0x0c024400)
Is not aligned on 0x2000.
Best Regards
From: Kevin Peng <Kevin.Peng@arm.com>
Sent: mercredi 17 mars 2021 03:08
To: Michel JAOUEN <michel.jaouen@st.com>;
tf-m@lists.trustedfirmware.org
Subject: RE: [TF-M] Armclang linker alignement question
Hi Michel,
Quote from the armlink user guide:
ALIGN
on an execution region causes both the load address and execution address to be aligned.
This can result in padding being added to the ELF file. To align only the execution address, use
the
AlignExpr
expression on the base address.
So I guess the alignment on execution regions (TFM_UNPRIV_CODE) overrides the alignment
of the Load Region.
And the fix is easy – as the user guide suggests – use AlignExpr
In you case, could you try:
+0 ALIGN
0x2000
-> AlignExpr(+0, 0x2000)
Best Regards,
Kevin
From: TF-M <tf-m-bounces@lists.trustedfirmware.org>
On Behalf Of Michel JAOUEN via TF-M
Sent: Tuesday, March 16, 2021 10:33 PM
To: tf-m@lists.trustedfirmware.org
Subject: [TF-M] Armclang linker alignement question
Hello,
This question is relative to linker script with Compiler armclang 'V6.14' (For the other toolchain IAR , GNUARM ,it works )
I need to place code aligned to flash PAGE SIZE (0x2000 or 8192) to be able to set hardware protection.
As follow , here is the description of the issue.
With a Linker file having the following value for Code placement
LR_CODE 0x0c024400 0x20000 {
ER_TFM_CODE 0x0c024400 {
*.o (RESET +First)
* (+RO)
}
TFM_UNPRIV_CODE +0 ALIGN
0x2000 {
stm32u5xx_hal*.o (+RO)
tick.o (+RO)
*(SFN)
*armlib*
}
}
We get the following error :
Build started: Project: Project_s
*** Using Compiler 'V6.14', folder: 'C:\Keil_v5\ARM\ARMCLANG\Bin'
Build Project 'Project_s' - Target xxxxxxxxxxx _TFM_Appli_S'
linking...
xxxxxxxxxxx_S\Exe\Project.axf: Error: L6244E: Load region LR_CODE address (0x0c024400) not aligned on a 8192 byte boundary.
Not enough information to list image symbols.
Finished: 1 information, 0 warning and 1 error messages.
" xxxxxxxxxxx _S\Exe\Project.axf" - 1 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed: 00:00:03
If we change the linker file as follow :
LR_CODE 0x0c024400 0x20000 {
ER_TFM_CODE 0x0c024400 {
*.o (RESET +First)
* (+RO)
}
TFM_UNPRIV_CODE +0 ALIGN
0x400 {
stm32u5xx_hal*.o (+RO)
tick.o (+RO)
*(SFN)
*armlib*
}
}
No Error is reported.
Is this an known issue with ARMCLANG ?
Best Regards
.