<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Vector Table relocation on M33/M55</title><link>https://community.arm.com/developer/ip-products/processors/f/cortex-m-forum/48091/vector-table-relocation-on-m33-m55</link><description> I&amp;#39;m trying to relocate and dynamically change the vector table&amp;#39;s contents. Keeping this in mind, I have the following code: 
 sample.c: 
 
 extern void svc_handler(void); volatile uint32_t *VTOR; stl_vect_t *vect = ptr; // I&amp;#39;ve ensured that ptr is aligned</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Vector Table relocation on M33/M55</title><link>https://community.arm.com/thread/169156?ContentTypeID=1</link><pubDate>Tue, 15 Dec 2020 10:03:11 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1b8493fc-6181-4fc9-84f8-4c1b8b1910b3</guid><dc:creator>Brijesh Reddy</dc:creator><description>&lt;p&gt;Thanks for all the help. Was finally able to figure out the solution. Caches!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Vector Table relocation on M33/M55</title><link>https://community.arm.com/thread/169155?ContentTypeID=1</link><pubDate>Tue, 15 Dec 2020 10:02:34 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6eb6d54b-a811-4e91-a584-55337cdfcb25</guid><dc:creator>Brijesh Reddy</dc:creator><description>&lt;p&gt;Finally found the root-cause for this:&lt;br /&gt;The issue was related to a bad handling of memory in the D-cache.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;extern void svc_handler(void);
const stl_vect_t vect = {.SVC = svc_handler}; // Global allocated in CODE-Region

....
volatile uint32_t *VTOR;
VTOR = 0xE000ED08u;
*VTOR = (uint32_t) &amp;amp;vect;
// ......
// Some Code
// ......
svc #0&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This works because the I-cache actually fetches the correct data at vect.SVC which is initialized before any instruction execution. In the second case i.e.,&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;extern void svc_handler(void);
stl_vect_t vect; // Global allocated in SRAM-Region

....
volatile uint32_t *VTOR;
VTOR = 0xE000ED08u;
vect.SVC = svc_handler;
*VTOR = (uint32_t) &amp;amp;vect;
// ......
// Some Code
// ......
svc #0&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;did not actually flush out the write from the D-cache. As a result, a stale copy in the I-cache kept being invoked on the SVC. The fix would be:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;extern void svc_handler(void);
stl_vect_t vect; // Global allocated in SRAM-Region

....
volatile uint32_t *VTOR, *DCCIMVAC, *ICCIALLU;
VTOR = 0xE000ED08u;
DCCIMVAC = 0xE000EF70u;
ICCIALLU = 0xE000EF50u;
vect.SVC = svc_handler;
*VTOR = (uint32_t) &amp;amp;vect;
*DCCIMVAC = &amp;amp;vect.SVC;
*ICCIALLU = 0x0u;
// ......
// Some Code
// ......
svc #0&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This works! I should have been more careful here as ARM&amp;nbsp;v8M&amp;nbsp;does say &amp;quot;If the vector table is located in a region of memory&amp;nbsp;that is cacheable, you must treat any store to the vector as self-modifying code and use cache maintenance instructions to synchronize the update&amp;quot;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Vector Table relocation on M33/M55</title><link>https://community.arm.com/thread/168813?ContentTypeID=1</link><pubDate>Thu, 26 Nov 2020 07:23:29 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:7c606983-d85e-465e-b989-440c82545832</guid><dc:creator>Brijesh Reddy</dc:creator><description>&lt;p&gt;Regarding bit[0] of the vector table entry - Yes. Double checked this. This is set to 0xe9d, where, bit[0] is 1&amp;#39;b1.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Vector Table relocation on M33/M55</title><link>https://community.arm.com/thread/168799?ContentTypeID=1</link><pubDate>Wed, 25 Nov 2020 05:30:23 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ec0ed98b-cac9-4de5-890d-22947d1c712c</guid><dc:creator>Brijesh Reddy</dc:creator><description>&lt;p&gt;Regarding exception being caused by SVC - Yes. I can confirm after testing that the SVC causes the exception. Removing the SVC causes no problems with the code.&lt;/p&gt;
&lt;p&gt;Regarding initialisation of vect - Not all handlers are initialized. Just the the SVC vector-table entry is initialized. Is this potentially problematic? In (&lt;span&gt;Update 24/11/2020), the first example does not intialize all the other handlers, but this still works i.e., the SVC handler is taken and executed correctly.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Vector Table relocation on M33/M55</title><link>https://community.arm.com/thread/168798?ContentTypeID=1</link><pubDate>Wed, 25 Nov 2020 05:22:50 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0e6049d4-40ff-4ae1-853a-ee21a5a8b835</guid><dc:creator>42Bastian Schick</dc:creator><description>&lt;p&gt;Are you sure, that the exception is caused by the SVC? (So if you do not call it, your code runs w/o problem.)&lt;br /&gt;Is vect (if in RAM) completely initialized (esp. Interrupts, systick)?&lt;/p&gt;
&lt;p&gt;Did you double check bit[0]?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Vector Table relocation on M33/M55</title><link>https://community.arm.com/thread/168793?ContentTypeID=1</link><pubDate>Tue, 24 Nov 2020 17:42:45 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d0105a94-ed13-4c3a-a40f-5502796ca1ef</guid><dc:creator>Brijesh Reddy</dc:creator><description>&lt;p&gt;Yeah - Thought so as it is one of the 3 reasons for EPSR.T being affected. But the RAM area is part of secure memory. So, still can&amp;#39;t understand the reason for it.&lt;/p&gt;
&lt;p&gt;PS: I also tried placing the vector-table in non-secure memory (which does not look right), but it has the same problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Vector Table relocation on M33/M55</title><link>https://community.arm.com/thread/168789?ContentTypeID=1</link><pubDate>Tue, 24 Nov 2020 15:56:15 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f9a159b0-2e19-4676-b6cb-54291b166e37</guid><dc:creator>42Bastian Schick</dc:creator><description>&lt;p&gt;I have no experience with m33, but could it be related to secure/non secure?&lt;/p&gt;
&lt;p&gt;Is the RAM area where the vector table is in non-secure RAM?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Vector Table relocation on M33/M55</title><link>https://community.arm.com/thread/168771?ContentTypeID=1</link><pubDate>Tue, 24 Nov 2020 06:27:20 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8dea1b1d-e93e-4a55-9817-1eaa1bfa9ab7</guid><dc:creator>Brijesh Reddy</dc:creator><description>&lt;p&gt;The issue is the SVC handler is not taken here. (Update-24/11/2020) - clarifies this. I understand the reason for the escalation to HardFault, but not the reason for the INVSTATE fault upon an attempt to handle the SVC.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Vector Table relocation on M33/M55</title><link>https://community.arm.com/thread/168769?ContentTypeID=1</link><pubDate>Mon, 23 Nov 2020 18:32:05 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a1279de5-2c63-464f-a8d9-0a3fb2573aef</guid><dc:creator>42Bastian Schick</dc:creator><description>&lt;p&gt;Check the hard fault criterion: Exception during exception handling.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Vector Table relocation on M33/M55</title><link>https://community.arm.com/thread/168766?ContentTypeID=1</link><pubDate>Mon, 23 Nov 2020 16:20:11 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:10be3982-e990-462a-9ae3-9d45285a8bd9</guid><dc:creator>Brijesh Reddy</dc:creator><description>&lt;p&gt;Hi - I can confirm that the SVC is executed in Thread mode. Any reason why this wouldn&amp;#39;t work?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Vector Table relocation on M33/M55</title><link>https://community.arm.com/thread/168735?ContentTypeID=1</link><pubDate>Fri, 20 Nov 2020 11:16:50 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:729477aa-da0c-4467-bc4d-97291964d102</guid><dc:creator>42Bastian Schick</dc:creator><description>&lt;p&gt;Check if you are in handler mode already before doing the SVC. This will not work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>