What is Checksum? Why use it?
Checksum is one of the oldest methods of ensuring that data has not been corrupted during transmission or encryption. Checksum also provides a form of authentication because an invalid checksum suggests that data has been compromised in some fashion.
Let's say a transmission packet has 1,100 bytes and the checksum of a packet is 1 byte long. This means that there is a total of 256 possible combinations. If the sum of the other bytes in the packet is 255 or less, then the checksum will contain that exact value. If the sum of the other bytes is more than 255, then the checksum is the remainder of the total value after it has been divided by 256.
So, in case of a packet with 1100 bytes:
Okay, great! How do I enable checksum?
How to enable checksum to a project using the IAR toolchain WITH build errors
The build fails.
The ielftool executable that is called requires the ";" character to denote the range the checksum will be calculated from, but due to the fact that the makefile commands are called through a bash script, the ";" acts as an command separator and the command falls apart.
One of the ways to ensure the ";" is treated as a range instead of a command separator is to use the escape character. In bash scripts, the escape character is "\". There is some back and forth that needs to be done to fix this, so make sure you follow the instructions carefully.
Steps to be followed to enable checksum without build errors:
Adding escape characters
The text copied from Step 8 will be longer than Step 4. Copy the text in Step 8 that is different from Step 4. It will usually begin with --fill.
This is the default IAR Linker settings
--config "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.5/arm/config/generic_cortex.icf" --no_wrap_diagnostics --semihosting --ihex --bin
When the checksum is added (with the check boxes shown in the figure above), the settings change to this
--config "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.5/arm/config/generic_cortex.icf" --no_wrap_diagnostics --semihosting --ihex --bin --fill 0xFF;0x0-0x0 --checksum __checksum:2,crc16,0x0;0x0-0x0 --place_holder __checksum,2,.checksum,1 --define_symbol __checksum_begin=0x0 --define_symbol __checksum_end=0x0
The text that is different between the two:
--fill 0xFF;0x0-0x0 --checksum __checksum:2,crc16,0x0;0x0-0x0 --place_holder __checksum,2,.checksum,1 --define_symbol __checksum_begin=0x0 --define_symbol __checksum_end=0x0
Now, the "/" escape character needs to be added.
--fill 0xFF\;0x0-0x0 --checksum __checksum:2,crc16,0x0\;0x0-0x0 --place_holder __checksum,2,.checksum,1 --define_symbol __checksum_begin=0x0 --define_symbol __checksum_end=0x0
If one tries to build the project now, the following error message will be seen:
IELFTOOL: "The string '__checksum' was not found in the string table".
This happens becasue our source doesn't use the symbol __checksum. to be able to link anyway, the command line option "--keep __checksum" needs to be added.
Hence the modified setting would be:
--keep __checksum --fill 0xFF\;0x0-0x0 --checksum __checksum:2,crc16,0x0\;0x0-0x0 --place_holder __checksum,2,.checksum,1 --define_symbol __checksum_begin=0x0 --define_symbol __checksum_end=0x0
Where is this modification supposed to be added?
This should be pasted AFTER step 10, by navigating to Project Properties >> C/C++ Build >> Settings >> IAR Linker for ARM >> Extra Options. Paste the text above in the extra options text box:
Build the project once these changes have been made. This will be a one time fix for the project and subsequently checksum can be used for authentication/data corruption checks.
I created/imported a project in Studio, but saw that the project did not have any toolchain associated with it. [(No toolchain) - None Toolchain Configuration] was what I saw next to the project. Why is this happening and how can I fix this?
Why is this happening:
The problem occurred because Simplicity Studio was unable to detect the toolchain correctly. Typically this is because the IAR executables exited with a failure exit code. Although, users would have set the path to an IAR installation, Studio was unable to validate the toolchain there. If Studio can't validate it, then the toolchain will be removed and any subsequent projects would use some other toolchain (normally None).
How to fix this issue:
One of the primary fixes would be to try to manually add the toolchain to the project. This can be done by following these steps:
Step 4: I cannot find the IAR toolchain. Although I am sure IAR toolchain is at the specified location, Simplicity Studio cannot find it there.
Is it possible to change a project's device after it is created?
Yes, you can change the device that the project is configured for by opening the Properties of the project you want to change. Under C/C++ Build -> Board/Part/SDK, there is an option to change the Boards and then Part fields for that particular project.