Hi,
When poking around some startup files I have found interesting place related to RAM_VECTORS support
CMSIS have __PROGRAM_START macro which is different for each compiler. For GCC it uses __cmsis_start, for ARMClang - __main and for IAR - __iar_program_start
Basically each of the functions should copy several sections (.TFM_DATA for example) from FLASH to RAM and zero out some parts of RAM (for .TFM_BSS for example)
In current implementation GCC __cmsis_start function also copies the vector table from FLASH to SRAM (if RAM_VECTORS are enabled) But ARMClang and IAR equivalents of that function (__main, __iar_program_start) does not seem to take care of copying vector table, so platforms startup should do that
I wonder if there is a way to change linker script in a way which will make copying of vector table automatic (by compiler dependent function). This will make platform startups a bit cleaner and will allow platform to just use __PROGRAM_START macro without any additional code to copy vector table.
From what I see IAR has "initialize by copy" syntaxis so I think it may be used to tell IAR to automatically copy vector table. It is a bit more tricky with ARMClang as I have not found a way to do that there.
I am not a big expert in ARMClang and IAR so maybe someone may help me here, give some directions or confirm that currently there is no way to make this idea work.
Basically the intention is to simplify platform startup code and offload common operations to compiler specific platform independent functions.
Regards, Bohdan Hunko
Cypress Semiconductor Ukraine Engineer CSUKR CSS ICW SW FW Mobile: +38099 50 19 714 Bohdan.Hunko@infineon.commailto:Bohdan.Hunko@infineon.com
Hi, I would highly appreciate any help on this one. Thanks!
Regards, Bohdan Hunko
Cypress Semiconductor Ukraine Engineer CSUKR CSS ICW SW FW Mobile: +38099 50 19 714 Bohdan.Hunko@infineon.commailto:Bohdan.Hunko@infineon.com
From: Bohdan.Hunko--- via TF-M tf-m@lists.trustedfirmware.org Sent: Wednesday, 13 April 2022 21:46 To: tf-m@lists.trustedfirmware.org Subject: [TF-M] Automatically copy RAM_VECTORS when using ARMClang and IAR
Caution: This e-mail originated outside Infineon Technologies. Do not click on links or open attachments unless you validate it is safehttps://intranet-content.infineon.com/explore/aboutinfineon/rules/informationsecurity/ug/SocialEngineering/Pages/SocialEngineeringElements_en.aspx.
Hi,
When poking around some startup files I have found interesting place related to RAM_VECTORS support
CMSIS have __PROGRAM_START macro which is different for each compiler. For GCC it uses __cmsis_start, for ARMClang - __main and for IAR - __iar_program_start
Basically each of the functions should copy several sections (.TFM_DATA for example) from FLASH to RAM and zero out some parts of RAM (for .TFM_BSS for example)
In current implementation GCC __cmsis_start function also copies the vector table from FLASH to SRAM (if RAM_VECTORS are enabled) But ARMClang and IAR equivalents of that function (__main, __iar_program_start) does not seem to take care of copying vector table, so platforms startup should do that
I wonder if there is a way to change linker script in a way which will make copying of vector table automatic (by compiler dependent function). This will make platform startups a bit cleaner and will allow platform to just use __PROGRAM_START macro without any additional code to copy vector table.
From what I see IAR has "initialize by copy" syntaxis so I think it may be used to tell IAR to automatically copy vector table. It is a bit more tricky with ARMClang as I have not found a way to do that there.
I am not a big expert in ARMClang and IAR so maybe someone may help me here, give some directions or confirm that currently there is no way to make this idea work.
Basically the intention is to simplify platform startup code and offload common operations to compiler specific platform independent functions.
Regards, Bohdan Hunko
Cypress Semiconductor Ukraine Engineer CSUKR CSS ICW SW FW Mobile: +38099 50 19 714 Bohdan.Hunko@infineon.commailto:Bohdan.Hunko@infineon.com
Hi Bohdan,
I don't know about IAR. For Armclang, I think __main does copy codes and data: https://developer.arm.com/documentation/100748/0618/Embedded-Software-Develo... "__main performs code and data copying, decompression, and zero initialization of the ZI data."
I had a quick look, so probably I'm wrong.
* I don't see any codes or data put into ER_RAM_VECTORS? * They copying code in startup does not copy ER_RAM_VECTORS either?
Best Regards, Kevin
From: Bohdan.Hunko--- via TF-M tf-m@lists.trustedfirmware.org Sent: Monday, June 27, 2022 10:02 PM To: tf-m@lists.trustedfirmware.org Subject: [TF-M] Re: Automatically copy RAM_VECTORS when using ARMClang and IAR
Hi, I would highly appreciate any help on this one. Thanks!
Regards, Bohdan Hunko
Cypress Semiconductor Ukraine Engineer CSUKR CSS ICW SW FW Mobile: +38099 50 19 714 Bohdan.Hunko@infineon.commailto:Bohdan.Hunko@infineon.com
From: Bohdan.Hunko--- via TF-M <tf-m@lists.trustedfirmware.orgmailto:tf-m@lists.trustedfirmware.org> Sent: Wednesday, 13 April 2022 21:46 To: tf-m@lists.trustedfirmware.orgmailto:tf-m@lists.trustedfirmware.org Subject: [TF-M] Automatically copy RAM_VECTORS when using ARMClang and IAR
Caution: This e-mail originated outside Infineon Technologies. Do not click on links or open attachments unless you validate it is safehttps://intranet-content.infineon.com/explore/aboutinfineon/rules/informationsecurity/ug/SocialEngineering/Pages/SocialEngineeringElements_en.aspx.
Hi,
When poking around some startup files I have found interesting place related to RAM_VECTORS support
CMSIS have __PROGRAM_START macro which is different for each compiler. For GCC it uses __cmsis_start, for ARMClang - __main and for IAR - __iar_program_start
Basically each of the functions should copy several sections (.TFM_DATA for example) from FLASH to RAM and zero out some parts of RAM (for .TFM_BSS for example)
In current implementation GCC __cmsis_start function also copies the vector table from FLASH to SRAM (if RAM_VECTORS are enabled) But ARMClang and IAR equivalents of that function (__main, __iar_program_start) does not seem to take care of copying vector table, so platforms startup should do that
I wonder if there is a way to change linker script in a way which will make copying of vector table automatic (by compiler dependent function). This will make platform startups a bit cleaner and will allow platform to just use __PROGRAM_START macro without any additional code to copy vector table.
From what I see IAR has "initialize by copy" syntaxis so I think it may be used to tell IAR to automatically copy vector table. It is a bit more tricky with ARMClang as I have not found a way to do that there.
I am not a big expert in ARMClang and IAR so maybe someone may help me here, give some directions or confirm that currently there is no way to make this idea work.
Basically the intention is to simplify platform startup code and offload common operations to compiler specific platform independent functions.
Regards, Bohdan Hunko
Cypress Semiconductor Ukraine Engineer CSUKR CSS ICW SW FW Mobile: +38099 50 19 714 Bohdan.Hunko@infineon.commailto:Bohdan.Hunko@infineon.com
Hi Kevin,
So the situation is as follows:
* For GCC both .data and .ram_vectors are copied automatically in __cmsis_start * For Clang and IAR .data is copied automatically in __cmsis_start, but .ram_vectors is not Therefore it is a bit inconvenient to copy .ram_vectors manually for IAR and Clang
As for now ER_RAM_VECTORS is copied in startup file for Clang and IAR manually and for GCC automatically. So currently there is no bug and everything works as expected.
But I am trying to understand whether there is a way to change Clang and IAR startups so ER_RAM_VECTORS will be copied automatically for these compilers too. So far I have not been able to find such a way, so I will appreciate if someone knows how to do this. But if no one knows the solution we can leave it as is.
Regards, Bohdan Hunko
Cypress Semiconductor Ukraine Engineer CSUKR CSS ICW SW FW Mobile: +38099 50 19 714 Bohdan.Hunko@infineon.commailto:Bohdan.Hunko@infineon.com
From: Kevin Peng Kevin.Peng@arm.com Sent: Tuesday, 28 June 2022 06:20 To: Hunko Bohdan (CSUKR CSS ICW SW FW) Bohdan.Hunko@infineon.com; tf-m@lists.trustedfirmware.org Subject: RE: Automatically copy RAM_VECTORS when using ARMClang and IAR
Caution: This e-mail originated outside Infineon Technologies. Do not click on links or open attachments unless you validate it is safehttps://intranet-content.infineon.com/explore/aboutinfineon/rules/informationsecurity/ug/SocialEngineering/Pages/SocialEngineeringElements_en.aspx.
Hi Bohdan,
I don't know about IAR. For Armclang, I think __main does copy codes and data: https://developer.arm.com/documentation/100748/0618/Embedded-Software-Develo... "__main performs code and data copying, decompression, and zero initialization of the ZI data."
I had a quick look, so probably I'm wrong.
* I don't see any codes or data put into ER_RAM_VECTORS? * They copying code in startup does not copy ER_RAM_VECTORS either?
Best Regards, Kevin
From: Bohdan.Hunko--- via TF-M <tf-m@lists.trustedfirmware.orgmailto:tf-m@lists.trustedfirmware.org> Sent: Monday, June 27, 2022 10:02 PM To: tf-m@lists.trustedfirmware.orgmailto:tf-m@lists.trustedfirmware.org Subject: [TF-M] Re: Automatically copy RAM_VECTORS when using ARMClang and IAR
Hi, I would highly appreciate any help on this one. Thanks!
Regards, Bohdan Hunko
Cypress Semiconductor Ukraine Engineer CSUKR CSS ICW SW FW Mobile: +38099 50 19 714 Bohdan.Hunko@infineon.commailto:Bohdan.Hunko@infineon.com
From: Bohdan.Hunko--- via TF-M <tf-m@lists.trustedfirmware.orgmailto:tf-m@lists.trustedfirmware.org> Sent: Wednesday, 13 April 2022 21:46 To: tf-m@lists.trustedfirmware.orgmailto:tf-m@lists.trustedfirmware.org Subject: [TF-M] Automatically copy RAM_VECTORS when using ARMClang and IAR
Caution: This e-mail originated outside Infineon Technologies. Do not click on links or open attachments unless you validate it is safehttps://intranet-content.infineon.com/explore/aboutinfineon/rules/informationsecurity/ug/SocialEngineering/Pages/SocialEngineeringElements_en.aspx.
Hi,
When poking around some startup files I have found interesting place related to RAM_VECTORS support
CMSIS have __PROGRAM_START macro which is different for each compiler. For GCC it uses __cmsis_start, for ARMClang - __main and for IAR - __iar_program_start
Basically each of the functions should copy several sections (.TFM_DATA for example) from FLASH to RAM and zero out some parts of RAM (for .TFM_BSS for example)
In current implementation GCC __cmsis_start function also copies the vector table from FLASH to SRAM (if RAM_VECTORS are enabled) But ARMClang and IAR equivalents of that function (__main, __iar_program_start) does not seem to take care of copying vector table, so platforms startup should do that
I wonder if there is a way to change linker script in a way which will make copying of vector table automatic (by compiler dependent function). This will make platform startups a bit cleaner and will allow platform to just use __PROGRAM_START macro without any additional code to copy vector table.
From what I see IAR has "initialize by copy" syntaxis so I think it may be used to tell IAR to automatically copy vector table. It is a bit more tricky with ARMClang as I have not found a way to do that there.
I am not a big expert in ARMClang and IAR so maybe someone may help me here, give some directions or confirm that currently there is no way to make this idea work.
Basically the intention is to simplify platform startup code and offload common operations to compiler specific platform independent functions.
Regards, Bohdan Hunko
Cypress Semiconductor Ukraine Engineer CSUKR CSS ICW SW FW Mobile: +38099 50 19 714 Bohdan.Hunko@infineon.commailto:Bohdan.Hunko@infineon.com
Hi Bohdan,
Sorry I'm not an expert of linker scripts. Here's my understanding.
For GCC, as long as you add the item in the .copy.table, the toolchain would generate corresponding code to copy codes and data. For Armclang, you don't even need the copy table. The toolchain does the copy as long as the addresses of the "load region (LR)" and "execution region (ER)" are different. For IAR, I have no knowledge of it.
One thing I noticed is that GCC picks up the (.ram_vectors) into the ram vector section while Armclang pick the * (RESET_RAM). i
Best Regards, Kevin
From: Bohdan.Hunko@infineon.com Bohdan.Hunko@infineon.com Sent: Wednesday, July 6, 2022 3:01 AM To: Kevin Peng Kevin.Peng@arm.com; tf-m@lists.trustedfirmware.org Subject: RE: Automatically copy RAM_VECTORS when using ARMClang and IAR
Hi Kevin,
So the situation is as follows:
* For GCC both .data and .ram_vectors are copied automatically in __cmsis_start * For Clang and IAR .data is copied automatically in __cmsis_start, but .ram_vectors is not Therefore it is a bit inconvenient to copy .ram_vectors manually for IAR and Clang
As for now ER_RAM_VECTORS is copied in startup file for Clang and IAR manually and for GCC automatically. So currently there is no bug and everything works as expected.
But I am trying to understand whether there is a way to change Clang and IAR startups so ER_RAM_VECTORS will be copied automatically for these compilers too. So far I have not been able to find such a way, so I will appreciate if someone knows how to do this. But if no one knows the solution we can leave it as is.
Regards, Bohdan Hunko
Cypress Semiconductor Ukraine Engineer CSUKR CSS ICW SW FW Mobile: +38099 50 19 714 Bohdan.Hunko@infineon.commailto:Bohdan.Hunko@infineon.com
From: Kevin Peng <Kevin.Peng@arm.commailto:Kevin.Peng@arm.com> Sent: Tuesday, 28 June 2022 06:20 To: Hunko Bohdan (CSUKR CSS ICW SW FW) <Bohdan.Hunko@infineon.commailto:Bohdan.Hunko@infineon.com>; tf-m@lists.trustedfirmware.orgmailto:tf-m@lists.trustedfirmware.org Subject: RE: Automatically copy RAM_VECTORS when using ARMClang and IAR
Caution: This e-mail originated outside Infineon Technologies. Do not click on links or open attachments unless you validate it is safehttps://intranet-content.infineon.com/explore/aboutinfineon/rules/informationsecurity/ug/SocialEngineering/Pages/SocialEngineeringElements_en.aspx.
Hi Bohdan,
I don't know about IAR. For Armclang, I think __main does copy codes and data: https://developer.arm.com/documentation/100748/0618/Embedded-Software-Develo... "__main performs code and data copying, decompression, and zero initialization of the ZI data."
I had a quick look, so probably I'm wrong.
* I don't see any codes or data put into ER_RAM_VECTORS? * They copying code in startup does not copy ER_RAM_VECTORS either?
Best Regards, Kevin
From: Bohdan.Hunko--- via TF-M <tf-m@lists.trustedfirmware.orgmailto:tf-m@lists.trustedfirmware.org> Sent: Monday, June 27, 2022 10:02 PM To: tf-m@lists.trustedfirmware.orgmailto:tf-m@lists.trustedfirmware.org Subject: [TF-M] Re: Automatically copy RAM_VECTORS when using ARMClang and IAR
Hi, I would highly appreciate any help on this one. Thanks!
Regards, Bohdan Hunko
Cypress Semiconductor Ukraine Engineer CSUKR CSS ICW SW FW Mobile: +38099 50 19 714 Bohdan.Hunko@infineon.commailto:Bohdan.Hunko@infineon.com
From: Bohdan.Hunko--- via TF-M <tf-m@lists.trustedfirmware.orgmailto:tf-m@lists.trustedfirmware.org> Sent: Wednesday, 13 April 2022 21:46 To: tf-m@lists.trustedfirmware.orgmailto:tf-m@lists.trustedfirmware.org Subject: [TF-M] Automatically copy RAM_VECTORS when using ARMClang and IAR
Caution: This e-mail originated outside Infineon Technologies. Do not click on links or open attachments unless you validate it is safehttps://intranet-content.infineon.com/explore/aboutinfineon/rules/informationsecurity/ug/SocialEngineering/Pages/SocialEngineeringElements_en.aspx.
Hi,
When poking around some startup files I have found interesting place related to RAM_VECTORS support
CMSIS have __PROGRAM_START macro which is different for each compiler. For GCC it uses __cmsis_start, for ARMClang - __main and for IAR - __iar_program_start
Basically each of the functions should copy several sections (.TFM_DATA for example) from FLASH to RAM and zero out some parts of RAM (for .TFM_BSS for example)
In current implementation GCC __cmsis_start function also copies the vector table from FLASH to SRAM (if RAM_VECTORS are enabled) But ARMClang and IAR equivalents of that function (__main, __iar_program_start) does not seem to take care of copying vector table, so platforms startup should do that
I wonder if there is a way to change linker script in a way which will make copying of vector table automatic (by compiler dependent function). This will make platform startups a bit cleaner and will allow platform to just use __PROGRAM_START macro without any additional code to copy vector table.
From what I see IAR has "initialize by copy" syntaxis so I think it may be used to tell IAR to automatically copy vector table. It is a bit more tricky with ARMClang as I have not found a way to do that there.
I am not a big expert in ARMClang and IAR so maybe someone may help me here, give some directions or confirm that currently there is no way to make this idea work.
Basically the intention is to simplify platform startup code and offload common operations to compiler specific platform independent functions.
Regards, Bohdan Hunko
Cypress Semiconductor Ukraine Engineer CSUKR CSS ICW SW FW Mobile: +38099 50 19 714 Bohdan.Hunko@infineon.commailto:Bohdan.Hunko@infineon.com
Sorry, something wrong with my keyboard. I sent an unfinished email. It is completed as below now.
Best Regards, Kevin
From: Kevin Peng Sent: Wednesday, July 6, 2022 2:45 PM To: 'Bohdan.Hunko@infineon.com' Bohdan.Hunko@infineon.com; tf-m@lists.trustedfirmware.org Subject: RE: Automatically copy RAM_VECTORS when using ARMClang and IAR
Hi Bohdan,
Sorry I'm not an expert of linker scripts. Here's my understanding.
For GCC, as long as you add the item in the .copy.table, the toolchain would generate corresponding code to copy codes and data. For Armclang, you don't even need the copy table. The toolchain does the copy as long as the addresses of the "load region (LR)" and "execution region (ER)" are different. For IAR, I have no knowledge of it.
One thing I noticed is that GCC picks up the (.ram_vectors) into the ram vector section while Armclang pick the * (RESET_RAM). Is this something to be noticed?
Best Regards, Kevin
From: Bohdan.Hunko@infineon.commailto:Bohdan.Hunko@infineon.com <Bohdan.Hunko@infineon.commailto:Bohdan.Hunko@infineon.com> Sent: Wednesday, July 6, 2022 3:01 AM To: Kevin Peng <Kevin.Peng@arm.commailto:Kevin.Peng@arm.com>; tf-m@lists.trustedfirmware.orgmailto:tf-m@lists.trustedfirmware.org Subject: RE: Automatically copy RAM_VECTORS when using ARMClang and IAR
Hi Kevin,
So the situation is as follows:
* For GCC both .data and .ram_vectors are copied automatically in __cmsis_start * For Clang and IAR .data is copied automatically in __cmsis_start, but .ram_vectors is not Therefore it is a bit inconvenient to copy .ram_vectors manually for IAR and Clang
As for now ER_RAM_VECTORS is copied in startup file for Clang and IAR manually and for GCC automatically. So currently there is no bug and everything works as expected.
But I am trying to understand whether there is a way to change Clang and IAR startups so ER_RAM_VECTORS will be copied automatically for these compilers too. So far I have not been able to find such a way, so I will appreciate if someone knows how to do this. But if no one knows the solution we can leave it as is.
Regards, Bohdan Hunko
Cypress Semiconductor Ukraine Engineer CSUKR CSS ICW SW FW Mobile: +38099 50 19 714 Bohdan.Hunko@infineon.commailto:Bohdan.Hunko@infineon.com
From: Kevin Peng <Kevin.Peng@arm.commailto:Kevin.Peng@arm.com> Sent: Tuesday, 28 June 2022 06:20 To: Hunko Bohdan (CSUKR CSS ICW SW FW) <Bohdan.Hunko@infineon.commailto:Bohdan.Hunko@infineon.com>; tf-m@lists.trustedfirmware.orgmailto:tf-m@lists.trustedfirmware.org Subject: RE: Automatically copy RAM_VECTORS when using ARMClang and IAR
Caution: This e-mail originated outside Infineon Technologies. Do not click on links or open attachments unless you validate it is safehttps://intranet-content.infineon.com/explore/aboutinfineon/rules/informationsecurity/ug/SocialEngineering/Pages/SocialEngineeringElements_en.aspx.
Hi Bohdan,
I don't know about IAR. For Armclang, I think __main does copy codes and data: https://developer.arm.com/documentation/100748/0618/Embedded-Software-Develo... "__main performs code and data copying, decompression, and zero initialization of the ZI data."
I had a quick look, so probably I'm wrong.
* I don't see any codes or data put into ER_RAM_VECTORS? * They copying code in startup does not copy ER_RAM_VECTORS either?
Best Regards, Kevin
From: Bohdan.Hunko--- via TF-M <tf-m@lists.trustedfirmware.orgmailto:tf-m@lists.trustedfirmware.org> Sent: Monday, June 27, 2022 10:02 PM To: tf-m@lists.trustedfirmware.orgmailto:tf-m@lists.trustedfirmware.org Subject: [TF-M] Re: Automatically copy RAM_VECTORS when using ARMClang and IAR
Hi, I would highly appreciate any help on this one. Thanks!
Regards, Bohdan Hunko
Cypress Semiconductor Ukraine Engineer CSUKR CSS ICW SW FW Mobile: +38099 50 19 714 Bohdan.Hunko@infineon.commailto:Bohdan.Hunko@infineon.com
From: Bohdan.Hunko--- via TF-M <tf-m@lists.trustedfirmware.orgmailto:tf-m@lists.trustedfirmware.org> Sent: Wednesday, 13 April 2022 21:46 To: tf-m@lists.trustedfirmware.orgmailto:tf-m@lists.trustedfirmware.org Subject: [TF-M] Automatically copy RAM_VECTORS when using ARMClang and IAR
Caution: This e-mail originated outside Infineon Technologies. Do not click on links or open attachments unless you validate it is safehttps://intranet-content.infineon.com/explore/aboutinfineon/rules/informationsecurity/ug/SocialEngineering/Pages/SocialEngineeringElements_en.aspx.
Hi,
When poking around some startup files I have found interesting place related to RAM_VECTORS support
CMSIS have __PROGRAM_START macro which is different for each compiler. For GCC it uses __cmsis_start, for ARMClang - __main and for IAR - __iar_program_start
Basically each of the functions should copy several sections (.TFM_DATA for example) from FLASH to RAM and zero out some parts of RAM (for .TFM_BSS for example)
In current implementation GCC __cmsis_start function also copies the vector table from FLASH to SRAM (if RAM_VECTORS are enabled) But ARMClang and IAR equivalents of that function (__main, __iar_program_start) does not seem to take care of copying vector table, so platforms startup should do that
I wonder if there is a way to change linker script in a way which will make copying of vector table automatic (by compiler dependent function). This will make platform startups a bit cleaner and will allow platform to just use __PROGRAM_START macro without any additional code to copy vector table.
From what I see IAR has "initialize by copy" syntaxis so I think it may be used to tell IAR to automatically copy vector table. It is a bit more tricky with ARMClang as I have not found a way to do that there.
I am not a big expert in ARMClang and IAR so maybe someone may help me here, give some directions or confirm that currently there is no way to make this idea work.
Basically the intention is to simplify platform startup code and offload common operations to compiler specific platform independent functions.
Regards, Bohdan Hunko
Cypress Semiconductor Ukraine Engineer CSUKR CSS ICW SW FW Mobile: +38099 50 19 714 Bohdan.Hunko@infineon.commailto:Bohdan.Hunko@infineon.com
tf-m@lists.trustedfirmware.org