Developing software for ARM Cortex-M1 processors can be done using various tools and SDKs. Two popular options are Keil MDK and Xilinx Vivado SDK. This guide will provide an overview of using these tools to create, build, and debug embedded software projects targeting Cortex-M1 chips.
Introduction to Cortex-M1
The Cortex-M1 processor from ARM is a 32-bit RISC core designed for microcontroller and deeply embedded applications. It has features like Thumb instruction set, NVIC interrupt controller, and Embedded Trace Macrocell. Cortex-M1 is licensable IP and has been used in various SoC devices from vendors like Actel, Cypress, Xilinx etc.
Software development for Cortex-M1 relies on having the right set of tools – compiler, debugger, editor, build utilities etc. The choice of tools depends on factors like budget, ease of use, feature requirements etc. We’ll look at two popular options – Keil MDK and Xilinx Vivado SDK.
Keil MDK Overview
Keil MDK (Microcontroller Development Kit) from ARM includes the μVision IDE, C/C++ compiler, debugger and software packs for Cortex-M devices. The complete MDK toolkit includes:
- μVision IDE – Integrated Development Environment with editor, project manager etc.
- Compiler – Supports C and C++ languages with optimization for code density and performance.
- Debugger – Provides JTAG/SWD hardware interface for debugging Cortex-M chips.
- Software Packs – Device family specific packs with CMSIS libraries and example code.
Key components like the compiler and debugger are proprietary commercial offerings from Keil. But the IDE itself is available in limited functional mode for free. The free MDK-Lite allows builds up to 32KB code size.
Setting up Keil MDK
You can download the latest version of MDK from the ARM Keil website. Both paid and free MDK-Lite options are available. Installation is straightforward – just follow the wizard steps.
After installing, start the μVision IDE. It provides a modern graphical interface with features like tabbed editor, Python scripting support etc. You can create a new project by clicking Project -> New μVision Project. Configure the target device settings from the Device tab. For Cortex-M1 you need to select ARM7/ARM9/Cortex-M0/M0+/M1 as the core.
The required software packs can be downloaded from the Pack Installer. These include CMSIS libraries, startup code and examples for the chip family. Finally you can add your source files and start writing C/C++ code with Keil!
Building with Keil
The Keil environment provides many options to customize your build. You can select configurations like debug/release, optimization level etc from Project -> Options for Target. The C/C++ compiler can be configured from Options for C/C++ tab.
Common compiler settings to tune for Cortex-M1 are:
- Code optimization – Use -O1 or -O2 for code size vs performance tradeoff.
- Tail-call optimizations – Enable for inter-function optimizations.
- Loop unrolling – Helps reduce overhead of small loops.
- Enable Thumb-2 instruction set – Better performance than Thumb-1.
Builds can be started from the Build or Rebuild menu options. This will compile, assemble and link the sources to produce the output executable file. Any errors or warnings will be displayed in the Build Output window.
For deployment to the target hardware, you can configure flashing tools like ULINKme, J-Link etc. via the Debug menu. The Program File option will flash the built executable to memory address 0x0 on the device.
Debugging with Keil
Keil provides a full-featured debugger that integrates nicely with the IDE. After building, you can start a debug session via Debug -> Start/Stop Debug Session. This will connect to the target hardware and load the executable.
During debug, you can view variables, registers, memory etc. in the debugger windows. Code can be stepped through line-by-line. Breakpoints and watchpoints can be set for stopping at specific conditions.
The debugger supports advanced functionality like instruction trace, performance analysis, code coverage etc. These require a paid license and JTAG probe hardware that supports these features.
In summary, Keil MDK provides a professional grade embedded development environment for Cortex-M1 and is widely used commercially.
Xilinx Vivado SDK Overview
Xilinx Vivado SDK (Software Development Kit) is a free IDE for developing embedded software to run on Xilinx devices like Zynq SoCs. It includes:
- Eclipse based IDE with source editor, debugger etc.
- C/C++ Compiler – Based on the GNU toolchain with support for optimization.
- Libraries – Drivers, RTOS, middleware stacks for Xilinx devices.
- Debugger – Supports hardware debug via JTAG for Cortex cores.
The SDK is designed for Xilinx SoCs but can be used for Cortex-M1 development by creating suitable Board Support Packages.
Setting up Vivado SDK
Download Vivado SDK from Xilinx’s website. Make sure you meet the minimum system requirements. The SDK is installed as an Eclipse plugin so ensure you have a compatible Eclipse version.
After installing SDK, you can launch the Eclipse IDE. Create a new Board Support Package (BSP) from the menu. This will allow you to configure the target processor settings. Select Cortex-M1 as the CPU. You can customize the toolchain, compiler flags etc from Properties.
The BSP creation will generate the basic SDK project templates, linker scripts, startup code etc. Your application code goes into the src folder. The SDK examples are useful for getting started.
Building with Vivado SDK
With the Eclipse IDE, building software projects is straightforward. The project settings allow you to select debug/release builds and additional compiler options. Some key settings for optimizing Cortex-M1 code are:
- Optimization level – Higher levels like Os optimize for size.
- Instruction set – Use -mthumb for Thumb-2 instructions.
- Loop unrolling – Can benefit small loops to reduce overhead.
- Tail call merging – Enable inter-function optimizations.
The SDK build process will compile C/C++ sources into objects, link them using gcc/ld and generate the executable elf file. The full build steps are automated via Makefiles.
For deployment to hardware, SDK integrates with programming tools like OpenOCD. These can flash the built image to device memory via JTAG interface.
Debugging with Vivado SDK
The SDK includes debugger based on GDB and equipment from Eclipse. It allows interacting with the target via JTAG or SWD debug probes.Main debugging features are:
- View variable values during program execution.
- Set breakpoints and watchpoints.
- Step through code line-by-line.
- Inspect memory and peripheral registers.
Additional functionality like instruction trace requires hardware support like ARM CoreSight. But the SDK provides a full-featured and capable debugger for Cortex-M1 platforms.
In summary, Vivado SDK is a free yet powerful toolchain for embedded projects using Cortex-M1 and Xilinx devices.
Conclusion
Keil MDK and Xilinx Vivado SDK both provide quality C/C++ development environments for Cortex-M1 based software. While Keil is more full-featured and optimized, Vivado SDK offers a free and open-source toolchain.
For professional and commercial development, Keil MDK has rich functionality, vendor support and expert communities suited for it. Vivado SDK is a great low-cost option for academic, hobbyist and non-commercial use cases.
Ultimately the choice depends on specific requirements. Both allow high quality embedded software projects using the Cortex-M1 processor.