.. index:: ihex .. _ihex32: Ihex 32 Bit =========== Forth Project Cloning --------------------- When projects are built using the non-interactive C Programming Language, the Source Code is compiled to Machine Code on a PC. This leaves a single binary file on the PC ready to flash to more MCU's if required. When projects are built using interactive Mecrisp-Stellaris Forth, the Source Code is compiled to Machine Code on the MCU itself. The only compiled Machine Code resides in the MCU "Dictionary". To create multiple identical MCU's with Mecrisp-Stellaris Forth there are two choices. 1. Upload all the Forth source files again to additional MCU(s). This means there is no binary file record of the project. 2. Use iHex.fs below to produce a single, bootable Machine Code binary file on a PC ready to flash to more MCU's if required. This also allows easy redistribution of the Forth project and is the method used for all binaries distributed via this site. iHex.fs ------- iHex.fs dumps the complete Dictionary binary content when the target is cloned. This method uses "arm-none-eabi-objcopy" to then convert the ASCII data back into a bootable binary image file on your PC so it may be flashed to another MCU thereby "cloning" the target chip. Intel Hex --------- The "Intel Hex" (iHex) format is used to transfer binary data over ASCII mediums, such as via a serial terminal. The data is also checksummed for later verification. Ihex 04 Type Extended Addresses ------------------------------- Intel Hex is a old format from the 8 bit MCU days, when 16 addressing was common. Nowadays MCU's have much larger address with 32 bit addressing used in ARM Cortex-M. Extended Addressing is used to extend the capability of Intel Hex from a maximum of 64kB to 4GB. It does this by inserting 'extended addresses' into the iHex file every 64kB as shown below. Ihex 04 Type Extended Addresses Example --------------------------------------- Showing type 04 Type Ihex Extended Addresses. These are calculated in ihex.fs up to 4GB. ======== ================ ======= Hex Extended Address Bytes ======== ================ ======= $10000 :020000040001F9 64 kB $20000 :020000040002F8 128 kB $30000 :020000040003F7 192 kB $40000 :020000040004F6 256 kB $50000 :020000040005F5 320 kB $60000 :020000040006F4 384 kB $70000 :020000040007F3 448 kB $80000 :020000040008F2 512 kB $90000 :020000040009F1 576 kB $A0000 :02000004000AF0 640 kB $B0000 :02000004000BEF 720 kB $C0000 :02000004000CEE 786 kB $D0000 :02000004000DED 851 kB $E0000 :02000004000EEC 917 kB $F0000 :02000004000FEB 983 kB $100000 :020000040010EA 1 MB ======== ================ ======= Ihex Dump Example ----------------- Showing first extended address insertion ":020000040001F9" at $10000 - 64kB .. image:: pics/ihex-extended.jpg .. note:: This page replaces older versions :ref:`cloning` and :ref:`cloning-integrated` Description ----------- Ihex.fs dumps the entire Dictionary contents to the terminal in Intel Hex Extended Ascii format, and can handle sizes up to the maximum 4GB available with 32 bit addressing as used by Cortex-M. ihex.fs reads the STM32 MCU "Flash Size Register" to determine the maximum size and won't attempt to read beyond that. This is to prevent a 'exception' being thrown by the MCU. This works fine except where STM have actually included more Flash than stated in the "Flash Size Register", such as in the :ref:`STM32F103C8` which declares 64kB but usually has 128kB of Flash. This situation is handled with a parameter option to "clone", see below. .. Note:: The "Flash Size Register" address is *DIFFERENT BETWEEN DIFFERENT MODELS* and must be changed to suit *YOUR* MCU. The address is given in the STM Technical Reference Manual and a few examples below. Operation --------- * Load ihex.fs * Enable your terminal log to capture the output, and then run the "clone" program as shown below. "Clone" requires TWO parameters, the first is a "flash-size-register-address" modifier, the second is the "flash-size-register-address" itself. This may be in Hex or Decimal as desired. * There is *NO PARAMETER CHECKING*. If you make a mistake the program will probably generate a Exception and/or produce incorrect results. Usage: "1|2 flash-size-register-address clone" '1' = normal use '2' = only for a STM32F103C8 which reports 64kB of Flash but actually has double (128kB) OR if you suspect your chip MAY have double the flash advertized. Note: will crash this program with a Exception if it doesn't! 'flash-size-register-address' = "Flash size data register address". Check your STM reference manual "Device electronic signature" section. 'clone' name of the Forth program as listed below in the source Example usage for: STM32F051: "1 $1FFFF7CC clone" STM32F103CB: "1 $1FFFF7E0 clone" STM32F103C8: "2 $1FFFF7E0 clone" The iHex dump starts with the word "clone" and ends with the word "clone_end" for easy parsing to remove any extraneous text before using 'arm-none-eabi-objcopy'. Once you have the clean iHex File process it as below. Note that any junk,extra text or checksum errors in this file will cause arm-none-eabi-objcopy to abort with a error message. " arm-none-eabi-objcopy -I ihex -O binary " * After the dump is complete, save/disable your terminal log and edit-out the pre-amble (everything before and including "clone") and post-amble (remove "clone_end" at the very end of the file) text. .. note:: Arm-none-eabi is required but you should have it installed if you have compiled Mecrisp-Stellaris previously. Sourcecode ---------- :download:`Download: ihex.fs` .. raw:: html :file: library/ihex.fs.html