SoC
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
  • Arm Cortex M3
  • Contact
Reading: Merging FPGA bitstream with Cortex-M1 application hex file
SUBSCRIBE
SoCSoC
Font ResizerAa
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Search
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Have an existing account? Sign In
Follow US
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
© S-O-C.ORG, All Rights Reserved.
Arm

Merging FPGA bitstream with Cortex-M1 application hex file

Andrew Irwin
Last updated: September 20, 2023 6:52 am
Andrew Irwin 5 Min Read
Share
SHARE

When working with certain ARM Cortex-M1 microcontrollers that have an integrated FPGA fabric, it is necessary to merge the FPGA bitstream file with the Cortex-M1 application hex file into a single binary that can be flashed onto the device. This allows the FPGA fabric to be programmed with custom logic while also loading the Cortex-M1 application code. The key steps are understanding the memory map, generating the bitstream, compiling the Cortex-M1 code, merging the files, and flashing the binary. With the right tools and basic knowledge, this process can be straightforward.

Contents
Overview of the Cortex-M1 and FPGA FabricUnderstanding the Memory MapGenerating the FPGA BitstreamCompiling the Cortex-M1 Application CodeMerging the Bitstream and Hex FilesFlashing the Combined BinaryConclusionReferences

Overview of the Cortex-M1 and FPGA Fabric

The Cortex-M1 processor is a 32-bit ARM microcontroller optimized for low power, low cost applications. Some versions integrate an FPGA fabric on the same chip, allowing custom logic implementation. The FPGA and Cortex-M1 have separate memories and interfaces. The FPGA accesses its own block RAM and flash memory for configuration. The Cortex-M1 loads code and data into the system SRAM and flash. To utilize both, the FPGA bitstream and Cortex-M1 code must be combined.

Understanding the Memory Map

The system memory map provides the addresses for the memories and interfaces. There are regions for the Cortex-M1 code/data, FPGA fabric, peripherals, etc. Addresses may be pre-defined or configurable. It is critical to understand the memory map to properly combine the bitstream and firmware.

For example, the FPGA bitstream may reside in a dedicated region from 0x6000_0000 to 0x7FFF_FFFF. The Cortex-M1 code starts at 0x0000_0000. Configuring the memory map incorrectly during merging could result in overwriting the Cortex-M1 firmware with the bitstream!

Generating the FPGA Bitstream

The FPGA bitstream contains the configuration data defining the custom logic implementation. It is generated from HDL code (Verilog, VHDL) using the FPGA vendor’s synthesis and place-and-route tools. For example, Xilinx Vivado can take RTL code and output a bitstream for Xilinx 7-series FPGAs.

The target device and memory interfaces must be specified. Some tools support generating a raw binary bitstream for easy integration with the Cortex-M1 firmware. The bitstream data should be placed in a binary file for merging later.

Compiling the Cortex-M1 Application Code

The Cortex-M1 application firmware can be written in C/C++ or assembly. It should be compiled into a hex file targeting the appropriate memory range. Most ARM compilers, like ARM Compiler 6, can output Intel HEX or Motorola S-record formats.

Make sure to compile for the correct Cortex-M1 variant. Optimization flags can reduce code size. Debug symbols can be omitted. The linker script should match the expected memory map. This ensures the hex file contains the code and data properly mapped for merging.

Merging the Bitstream and Hex Files

With the bitstream and hex files generated, a merge utility combines them into a single binary for flashing. The open-source Snickerdoodle project provides some simple Python scripts for merging.

The merge utility overlays the bitstream data over the firmware hex file, placing it in the address range configured earlier. With both pieces in place within the merged output, it can be flashed to the device.

Flashing the Combined Binary

The merged binary can be flashed to the device using the standard Cortex-M1 interface, like SWD or JTAG. On reset, the bootloader loads the FPGA bitstream portion to the programmable fabric. Then it copies the Cortex-M1 application code from flash to SRAM for execution.

With the FPGA programmed and Cortex-M1 running, they can interact according to the defined interfaces. This allows custom hardware offloading tasks from software for greater efficiency.

Conclusion

While merging the FPGA bitstream and Cortex-M1 firmware requires some upfront effort, the result is a powerful system with software and hardware working in harmony. With diligence during the build and merge process, the integration can be smooth and effective. The Cortex-M1’s tight coupling with FPGA fabric opens up many possibilities for embedded developers.

References

  • Xilinx Vivado Programming and Debugging
  • Cortex-M1 Technical Reference Manual
  • Snickerdoodle FPGA Tools

Newsletter Form (#3)

More ARM insights right in your inbox

 


Share This Article
Facebook Twitter Email Copy Link Print
Previous Article Running Cortex-M1 on Artix-7 without debugger
Next Article Integrating Cortex-M1 with JTAG debugger
Leave a comment Leave a comment

Leave a Reply Cancel reply

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

2k Followers Like
3k Followers Follow
10.1k Followers Pin
- Sponsored-
Ad image

You Might Also Like

How to make use of the GCC fixed-point types extension on ARM Cortex-M?

The GCC compiler for ARM Cortex-M microcontrollers provides built-in support…

7 Min Read

Primask Register in Cortex-M4

The PRIMASK register is one of the special-purpose program status…

7 Min Read

Is ARM Cortex Little Endian or Big Endian?

ARM Cortex processors can operate in either little endian or…

7 Min Read

Cortex M0+ delay routine without timers

Executing delays and timing operations are common needs in embedded…

10 Min Read
SoCSoC
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
Welcome Back!

Sign in to your account