{"id":58968,"date":"2022-12-20T19:43:39","date_gmt":"2022-12-21T00:43:39","guid":{"rendered":"https:\/\/pappp.net\/?p=58968"},"modified":"2022-12-20T19:43:39","modified_gmt":"2022-12-21T00:43:39","slug":"porting-labs-from-arm-compiler-v5-to-v6","status":"publish","type":"post","link":"https:\/\/pappp.net\/?p=58968","title":{"rendered":"Porting Labs from ARM Compiler V5 to V6"},"content":{"rendered":"\n<p>I spent the last two afternoons procrastinating from other work doing a deferred maintenance project, porting the labs for UK&#8217;s CPE287 Introduction to Embedded Systems from the &#8220;V5&#8221; armcc to the &#8220;V6&#8221; armclang compiler, since the most recent releases of Keil (the IDE we use in the class) have dropped support for the older compiler, and all our materials were written against V5.  It has been a somewhat interesting porting exercise for a &#8220;same vendor, same platform&#8221; situation.   <br \/><br \/>We have some slightly unusual circumstances: First, because the class starts in writing pure assembly, proceeds through manual bit manipulation in C, and eventually starts to write high-level software driver model code, we hit all the styles and interfaces.  Secondly, we have an <a href=\"http:\/\/users.ece.utexas.edu\/~valvano\/\">inexpensive textbook and supporting materials<\/a> we rather like, but all the examples use the old style assembly syntax, which differs significantly from the more modern GCC\/LLVM style, and for pedagogical consistency reasons we&#8217;d like to write our code in that style.  <br \/><br \/>ARM\/Keil have produced a document <a href=\"https:\/\/www.keil.com\/appnotes\/files\/apnt_298.pdf\">AN298 \u2013 Migrate ARM Compiler 5 to ARM Compiler 6<\/a> which covers most of the important details, but it was still a bit of a skilled process. <br \/><br \/>Some notes: <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>For the time being, Keil with the V6 toolchain includes the older <code>armasm<\/code> binary, so separate pure-assembly .s sources written in the old syntax can still be ingested, you only <em>have<\/em> to port inline assembly. <\/li>\n\n\n\n<li> Keil&#8217;s debugger doesn&#8217;t appear to be able to keep source lines of inline assembly and the disassembly view synchronized for GCC-style inlined assembly the way it could with <code>armcc<\/code>. Unfortunate, and a bit klutzy for setting breakpoints, but not a deal-breaker.<\/li>\n\n\n\n<li><code>armclang<\/code> defines <code>__ARMCC_VERSION<\/code> as 6something so various pieces of existing code have pre-processor directives that will decide to use the <code>armcc<\/code> style inline assembly instead of the gcc style ones.  Particularly irritating, TI&#8217;s first party <a href=\"https:\/\/www.ti.com\/tool\/SW-TM4C\">TivaWare<\/a> library has this problem in both <code>cpu.c<\/code> and <code>sysctl.c<\/code>, so I had to make a hacked version with the <code>#ifdef<\/code> s swirled around appropriately.  The code in TivaWare intended for IAR <code>ewarm<\/code> is suitable for <code>armclang<\/code> &#8230; as long as you remove some spare ewarm-specific pragmas embedded here and there for suppressing return value warnings; I ended up putting <code>-Wno-return-type<\/code> in the extended compiler options for projects depending on those files.  <\/li>\n\n\n\n<li><code>armclang<\/code> is much more aggressive about optimization by default than <code>armcc<\/code> was.  In particular, you could get away without marking variables used in busy wait loops or ISRs volatile in armcc, and armclang will happily optimize them out if you forget. <\/li>\n\n\n\n<li><code>armclang<\/code> is more vocal about implicit type conversion than <code>armcc<\/code>, especially where it might affect signedness.  This is triggered a lot by the <code>REGISTER_NAME &amp;= ~0xMASK<\/code> bit-specific addressing idiom.  I sprinkled in lots of <code>UL<\/code> suffixes on literals to avoid the issue.  <\/li>\n<\/ul>\n\n\n\n<p>Long term we might try to get off of Keil, though my experiences with CodeComposerStudio have been sufficiently frustrating that I&#8217;m in no hurry to move to it for the TI TivaC boards we&#8217;ve been using, and while I like ST&#8217;s Cube environment, it would both be a major change of materials and a potential supply-chain nightmare (when is the last time you saw a legitimate major electronics vendor with STM32 parts in a stock status other than &#8220;Expected Date: Eventually&#8221;?)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I spent the last two afternoons procrastinating from other work doing a deferred maintenance project, porting the labs for UK&#8217;s CPE287 Introduction to Embedded Systems from the &#8220;V5&#8221; armcc to the &#8220;V6&#8221; armclang compiler, since the most recent releases of &hellip; <a href=\"https:\/\/pappp.net\/?p=58968\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,1,3],"tags":[],"class_list":["post-58968","post","type-post","status-publish","format-standard","hentry","category-computers","category-general","category-school"],"_links":{"self":[{"href":"https:\/\/pappp.net\/index.php?rest_route=\/wp\/v2\/posts\/58968","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pappp.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pappp.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pappp.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pappp.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=58968"}],"version-history":[{"count":0,"href":"https:\/\/pappp.net\/index.php?rest_route=\/wp\/v2\/posts\/58968\/revisions"}],"wp:attachment":[{"href":"https:\/\/pappp.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=58968"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pappp.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=58968"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pappp.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=58968"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}