<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en" style="--code-editor-font: var(--default-mono-font, "GitLab Mono"), JetBrains Mono, Menlo, DejaVu Sans Mono, Liberation Mono, Consolas, Ubuntu Mono, Courier New, andale mono, lucida console, monospace;">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<title>
GitLab
</title>

<style data-premailer="ignore" type="text/css">
a { color: #1068bf; }
</style>

<style>img {
max-width: 100%; height: auto;
}
body {
font-size: .875rem;
}
body {
-webkit-text-shadow: rgba(255,255,255,.01) 0 0 1px;
}
body {
font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"; font-size: inherit;
}
</style>
</head>
<body style="font-size: inherit; -webkit-text-shadow: rgba(255,255,255,.01) 0 0 1px; font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";">
<div class="content">

<p style="color: #777777;">
<a href="https://gitlab.rtems.org/ppisa">Pavel Pisa</a>
<a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5537#note_147874">commented</a>:
</p>
<div class="md" style="position: relative; z-index: 1; color: #3a383f; word-wrap: break-word;">
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Some more testing. I have analyzed how, why interrupts processing works when I run code from internal SRAM and do not have proper RTEMS image and its start vector table stored at the start of Flash (from address 0x00000000). And the <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">ticker.exe</code> works thanks to some unrelated application Flashed into memory. The original application starts by</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-plaintext" v-pre="true" style="display: block; font-size: 14px; color: #3a383f; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 1rem; padding: 12px; border: 1px solid #dcdcde;"><code style="font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; overflow-wrap: normal; padding: unset;"><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">   0x0:   b       0x7680</span>
<span id="LC2" class="line" lang="plaintext">   0x4:        b       0x4</span>
<span id="LC3" class="line" lang="plaintext">   0x8:        b       0x8</span>
<span id="LC4" class="line" lang="plaintext">   0xc:        b       0xc</span>
<span id="LC5" class="line" lang="plaintext">   0x10:       b       0x10</span>
<span id="LC6" class="line" lang="plaintext">   0x14:       b       0x78b0</span>
<span id="LC7" class="line" lang="plaintext">   0x18:       ldr     pc, [pc, #-432] @ 0xfffffe70</span>
<span id="LC8" class="line" lang="plaintext">   0x1c:       ldr     pc, [pc, #-432] @ 0xfffffe74</span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">The last two instructions ensure that interrupt and FIQ service routine address is taken from VIM which is reset to <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">_ARMV4_Exception_interrupt</code> for all IRQ vectors.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">This setup is not optimal for case that there is some random code reminder in the Flash.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">The TMS570LC4357 BSP keep our logic from TMS570LS3137 BSP for internal SRAM and SDRAM builds which replaces vector table targets in Flash by start of the internal SRAM whith the help of POM module (see <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">tms570_pom_remap</code>). But there has been problem that only data has been fetched reliably from POM overlay on TMS570LS3137, so the design expect that Flash starts with eight <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">ldr pc, [pc,#0x38]</code> instructions and then only data part (jump target addresses) of the vector table from <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">0x00000040</code> to <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">0x00000040</code> is replace by POM.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">But because do not have proper startup code Flashed in the chip, I have tried to return to replacement of the whole block instructions and data in the whole <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">0x00000000</code> to <code style="font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;">0x00000040</code>. This seems to work so it is possible that the issues with instruction fetching from POM overlay is not present on TMS570LC4357. This would be great because code with next changes should allow to test it from internal SRAM even if the chip Flash is fully erased or filled by some unrelated/incompatible content.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">The modification for full vector table replacement by POM is there</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-plaintext" v-pre="true" style="display: block; font-size: 14px; color: #3a383f; line-height: 1.6em; overflow-x: auto; border-radius: .25rem; position: relative; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: break-all; word-wrap: break-word; background-color: #fbfafd; margin: 0 0 1rem; padding: 12px; border: 1px solid #dcdcde;"><code style="font-size: inherit; color: inherit; word-wrap: normal; word-break: keep-all; background-color: inherit; border-radius: .25rem; white-space: pre; margin-top: 0; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; overflow-wrap: normal; padding: unset;"><span id="LC1" class="line" lang="plaintext" style="margin-top: 0;">diff --git a/bsps/arm/tms570/start/tms570-pom.c b/bsps/arm/tms570/start/tms570-pom.c</span>
<span id="LC2" class="line" lang="plaintext">index 82e9389785..d465f05cd6 100644</span>
<span id="LC3" class="line" lang="plaintext">--- a/bsps/arm/tms570/start/tms570-pom.c</span>
<span id="LC4" class="line" lang="plaintext">+++ b/bsps/arm/tms570/start/tms570-pom.c</span>
<span id="LC5" class="line" lang="plaintext">@@ -108,7 +108,7 @@ void tms570_pom_initialize_and_clear(void)</span>
<span id="LC6" class="line" lang="plaintext"> void tms570_pom_remap(void)</span>
<span id="LC7" class="line" lang="plaintext"> {</span>
<span id="LC8" class="line" lang="plaintext">   void *vec_overlay_start = (void *) pom_global_overlay_target_address_start;</span>
<span id="LC9" class="line" lang="plaintext">-  void *addr_tab = (char *) bsp_start_vector_table_begin + 64;</span>
<span id="LC10" class="line" lang="plaintext">+  void *addr_tab = (char *) bsp_start_vector_table_begin + 0;</span>
<span id="LC11" class="line" lang="plaintext"></span>
<span id="LC12" class="line" lang="plaintext">   if (vec_overlay_start == addr_tab) {</span>
<span id="LC13" class="line" lang="plaintext">     return;</span>
<span id="LC14" class="line" lang="plaintext">@@ -124,10 +124,10 @@ void tms570_pom_remap(void)</span>
<span id="LC15" class="line" lang="plaintext">    * table found in</span>
<span id="LC16" class="line" lang="plaintext">    *   bsps/arm/shared/start/start.S</span>
<span id="LC17" class="line" lang="plaintext">    */</span>
<span id="LC18" class="line" lang="plaintext">-  rtems_cache_invalidate_multiple_data_lines(addr_tab, 64);</span>
<span id="LC19" class="line" lang="plaintext">-  memcpy(vec_overlay_start, addr_tab, 64);</span>
<span id="LC20" class="line" lang="plaintext">-  rtems_cache_flush_multiple_data_lines(vec_overlay_start, 64);</span>
<span id="LC21" class="line" lang="plaintext">-  rtems_cache_invalidate_multiple_instruction_lines(vec_overlay_start, 64);</span>
<span id="LC22" class="line" lang="plaintext">+  rtems_cache_invalidate_multiple_data_lines(addr_tab, 128);</span>
<span id="LC23" class="line" lang="plaintext">+  memcpy(vec_overlay_start, addr_tab, 128);</span>
<span id="LC24" class="line" lang="plaintext">+  rtems_cache_flush_multiple_data_lines(vec_overlay_start, 128);</span>
<span id="LC25" class="line" lang="plaintext">+  rtems_cache_invalidate_multiple_instruction_lines(vec_overlay_start, 128);</span>
<span id="LC26" class="line" lang="plaintext"></span>
<span id="LC27" class="line" lang="plaintext">   #if 0</span>
<span id="LC28" class="line" lang="plaintext">   {</span>
<span id="LC29" class="line" lang="plaintext">@@ -154,9 +154,9 @@ void tms570_pom_remap(void)</span>
<span id="LC30" class="line" lang="plaintext">    * (opcode 0xe59ff058) then the jump target addresses are replaced</span>
<span id="LC31" class="line" lang="plaintext">    * by pointers to actual RTEMS exceptions service functions.</span>
<span id="LC32" class="line" lang="plaintext">    */</span>
<span id="LC33" class="line" lang="plaintext">-  TMS570_POM.REG[0].PROGSTART = TMS570_POM_PROGSTART_STARTADDRESS(64);</span>
<span id="LC34" class="line" lang="plaintext">+  TMS570_POM.REG[0].PROGSTART = TMS570_POM_PROGSTART_STARTADDRESS(0);</span>
<span id="LC35" class="line" lang="plaintext">   TMS570_POM.REG[0].OVLSTART = TMS570_POM_OVLSTART_STARTADDRESS(vec_overlay_start);</span>
<span id="LC36" class="line" lang="plaintext">-  TMS570_POM.REG[0].REGSIZE = TMS570_POM_REGSIZE_SIZE(TMS570_POM_REGSIZE_64B);</span>
<span id="LC37" class="line" lang="plaintext">+  TMS570_POM.REG[0].REGSIZE = TMS570_POM_REGSIZE_SIZE(TMS570_POM_REGSIZE_128B);</span>
<span id="LC38" class="line" lang="plaintext">   TMS570_POM.GLBCTRL = TMS570_POM_GLBCTRL_ON_OFF(0xa) |</span>
<span id="LC39" class="line" lang="plaintext">                        TMS570_POM_GLBCTRL_ETO(0xa) |</span>
<span id="LC40" class="line" lang="plaintext">                        (TMS570_POM_GLBCTRL_OTADDR(~0) &</span></code></pre>
<copy-code></copy-code><insert-code-snippet></insert-code-snippet>
</div>
<p dir="auto" style="color: #3a383f; margin: 0;" align="initial">I have checked that the interrupt service routine is reached by POM path and not through VIM workaround. It seems to be working well on TMS570LC4357 but do not rely on it in the production environment. Only safe way for available RTEMS options is to run code from Flash. But if it is found that POM way is reliable on TMS570LC4357, then it simplifies development a lot.</p>
</div>


</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #626168;">

<br>
<a href="https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5537#note_147874">View it on GitLab</a>.
<br>
You're receiving this email because of your account on <a target="_blank" rel="noopener noreferrer" href="https://gitlab.rtems.org">gitlab.rtems.org</a>. <a href="https://gitlab.rtems.org/-/sent_notifications/2-2lf5vvvmf6664gje9o2sw36e9/unsubscribe" target="_blank" rel="noopener noreferrer">Unsubscribe</a> from this thread · <a href="https://gitlab.rtems.org/-/profile/notifications" target="_blank" rel="noopener noreferrer" class="mng-notif-link">Manage all notifications</a> · <a href="https://gitlab.rtems.org/help" target="_blank" rel="noopener noreferrer" class="help-link">Help</a>
<span style="color: transparent; font-size: 0; display: none; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0;">
Notification message regarding https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5537#note_147874 at 1775086736
</span>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Issue","url":"https://gitlab.rtems.org/rtems/rtos/rtems/-/issues/5537#note_147874"}}</script>


</p>
</div>
</body>
</html>