Firmware formats and conversion

Any file in the digital world has a name and extension, which is indicated after the dot (if your OS does not specify file extensions, see Start => Control Panel => Folder Options). An extension is needed in order to understand what type of data is in the file and what program to run to open it. For example, at a construction site there are different types of nails and when a builder needs to hammer a nail, he understands that he needs a hammer, which is a tool (program), and the nails can be completely different: 5 * 50mm nail or roofing nail or 35mm finishing galvanized nail and All these nails as files have the extension (a sign of belonging to the type) nail and all of them require a hammer. If you take a screw, it’s clear that you need another tool and you can’t help with a hammer.
Зажим для микроконтроллеров.jpg
Зажим для микроконтроллеров.jpg

File Extension

A file extension is an identifier that tells the computer or user what program to apply to a given file.

Firmware in household appliances is usually used in .bin or .eep formats, while many programmers support many more extensions, and some can only work with files of one extension (for example, the USBDM programmer works with the .S19 extension)

The file can be renamed by the user, but its contents will not change, and only the program that launches it (shows, executes, allows editing, etc.) changes.
69d131fb56eef57d5d654e7e43caaec320210327102424.jpg

Firmware Conversion

In order to translate from one format to another, there are many programs called converters, which work on the principle of translators, translating one language into another, but the meaning (data) remains unchanged. In such a translation (conversion), it is very important that all conditions are met and the meaning (data) is conveyed 100% and no human language is suitable for this, since many words can be distorted during translation, but computer technology, which is partly a microcontroller, understands only clear commands (open the water, close the water, rotate the drum to the left 50 rpm), the washing machine cannot be told to wash as you wash, it cannot decide when enough is enough and how long to continue, so in the digital world they use the language of numbers.
cfb983d11f9ef5010262a47c870af83620170918125041 (1).jpg

Different calculus systems

Those. the same thing can be written in different languages, but always means the same thing, each character in ASCII is characterized by two characters in hexadecimal form, which, in turn, is characterized by a unique set of 0 and 1 (bits) in the amount of 8, which is equal to one byte. If the firmware is 512 bytes in size, then there are 512 ASCII characters or 512 groups of 8 characters 0 or 1.
Any hex editor (editor of hexadecimal files, usually firmware) has 3 fields, the first field is the address of the line, the second field is data in hexadecimal format (form) and the third field is the same data only in ASCII format. This is needed for greater clarity during visual data analysis.
3b4c4b481ba30cd56d6864b149f1c3fd20170918125010.jpg

Inverted bytes

In the firmware of washing machines, the concept of an upside down byte is very often encountered, this means that the data inside the file was upside down for some reason, perhaps the programmer saved the data this way, for some microcircuits it is saved this way, etc. This is not particularly important to us, what is really important to us is that the data in such firmware may not be accepted by our processor and, as many incorrectly believe, “byte inversion”does not depend on the format, since the user can name the file whatever he wants. Therefore, you need to look at the data inside the file using our hex editors and here you need to divide the firmware into many platforms and using the example of two we will try to understand (in general) how they are structured (see lesson 4). To convert from a regular format to a flipped one or vice versa, just load it into any Hex editor and click flip

S19 format

With the advent of new Arcadia control modules, the S19 or SREC format began to make its way to us, a text format of firmware used on Freescale processors from Motorola, which has a number of design features and can be opened in any text editor.

Each Arcadia control module has a tag indicating the SW (software) version, and it was this combination SW+S19=SW19.RU that gave the name to the domain of our website SW19.ru, because one of the first programs was a firmware converter that allows you to convert the config ) for the required module version.

The conversion program essentially did two things at once, converted our config from eep or bin format to S19 format, adding S10F0000 to the beginning of the data line and counting the checksum added to the end of the line. Let's look at the same file in different formats
7375b1d140cf1ab05972ee8c0ed9e53a20170918125010.jpg

SW + config

This is the same file only shown in different formats, apparently, there is nothing difficult in identifying the pattern, but as we know, the complete firmware of the microcontroller (see Lesson 1) consists not only of configuration data, but also of the main firmware, data which the S19 converter adds to the beginning and end of config, so at the output we get a much larger file (about 150 kb compared to 6-8 of the original size).
f9b97f55d8a5c2df02566a7cb6067d5f20170918125041.jpg
Offcanvas
Some text as placeholder. In real life you can have the elements you have chosen. Like, text, images, lists, etc.