Know thy compiler toolchain

An embedded systems engineer is only as good as their knowledge of the tools they use. Using the right tool for the job can drastically speed up development but doesn’t necessarily ensure success. The developer needs to understand the intricacies of the tool in order to be successful. Take for example an apparently simple task of setting the configuration bits of an NXP Kinetis-L microcontroller using the IAR compiler and Processor Expert.

The configuration bits control the function of the NMI and Reset pins along with initial clock and boot options. In this sample they are located starting at hex address 0x400 just following the interrupt vector table. Table 1 shows the description of what each address controls.

Table 1 – Configuration Bits

A developer has a number of options available on how to set these memory regions. First, a developer could set the the values using a table mapped within the linker file.  Second, a developer could use Processor Expert to set the values. With the values for the configuration area set, the code could be compiled and loaded onto the target and one would expect the configuration bits to be set in flash. Running the code however would reveal a different story! Despite configuring the bits properly, one would find that on the target, the bits are still set to the default values.

What could possibly have gone wrong? Using IAR, a developer could run a verification check between the code to be loaded and what exists in memory on the target. A developer would find that the verification failed. Something is preventing the configuration bits from being programmed. The culprit turns out the IAR toolchain which is preventing the configuration area from being updated. The reason is that these bits can be dangerous to program as they can lock the entire device. Inadvertently programming them could be disastrous so the toolchain blocks write permission to this area of the target automatically without any mention to the developer. The toolchain assumes the developer knows this.

A developer must override this default behavior manually by adding special parameters to the flash settings configuration that can be found in Figure 1. Only after a developer has done this are they able to successful write the configuration bits. A developer without experience or knowledge of this could easily be thrown off and left scratching their heads for days especially since these parameters are nicely hidden with multiple submenus.


Figure 1 – IAR Overide Paramters

The moral of the story is that developers and project teams need to schedule time to regularly update themselves and learn more about the tools they are using on a day to day basis. Project managers need to recognize that time needs to be allocated in the schedule to learn the tools. Developers are usually aware of the day to day features of their toolchain but it’s the little intricacies of the tool that can truly make the difference and provide the most powerful features.

Do you know all the intricacies of your toolchain and if not what are your next steps?

One thought on “Know thy compiler toolchain”

Leave a Reply

Your email address will not be published. Required fields are marked *