cancel
Showing results for 
Search instead for 
Did you mean: 

Class B safety library issues

ktrofimo
Senior III

1) Right after startup CPU check fails on following code:

MRS R0, APSR              /* Get Status register */
CMP R0, #0xB8000000       /* Verifies that N=C=V=Q=1 */
BNE.W FailSafePOR         /* Fails if Q+N+C=V clear */

because APSR register have also GE bits set: 0xB80F0000. As a workaround I cleared all bits except QNCV that we are going to check:

MRS R1, APSR              /* Get Status register */
AND R0, R1, #0xB8000000   /* Clear GE bits */
CMP R0, #0xB8000000       /* Verifies that N=C=V=Q=1 */
BNE.W FailSafePOR         /* Fails if Q+N+C=V clear */

This works, but if anyone can explain why this happens I would be happy.

2) Firmware CRC generated by the MS DOS/Windows .BAT files. Since I use MacOS it did not work for me and I had to rewrite it in perl (because I do use perl already for scripting in multi-platform development on MacOS and Linux). For those who are interested script attached, Anyway during debug session CubeIDE uses .elf binary with symbolic information and CRC check fail. For now I disabled it with:

#define DEBUG_CRC_CALCULATION

As possible solution I think to flash firmware with CRC using CubeProgrammer and then connect to running program from CubeIDE without reprogramming and then debug as usual. If somebody knows how to do it in a simple way I would appreciate it.

Kirill

3 REPLIES 3
TDK
Guru

> This works, but if anyone can explain why this happens I would be happy.

It's the assembly version of:

If (APSR & 0xB8000000 == 0xB8000000) ...

The AND operation causes it to ignore the value of bits you aren't interested in checking.

> 2)

CubeProgrammer has a CLI interface. If you convert the ELF to a BIN file, it should be straightforward to calculate the CRC, put it in there, and flash the entire file. There are post-build tool options in CubeIDE that you could use to do this. You can disable downloading of a program in Debug Configurations, although if you insert the CRC as a post-build option, you shouldn't need to do this if you specify the BIN file to be loaded, as opposed to the ELF.

If you feel a post has answered your question, please click "Accept as Solution".
ktrofimo
Senior III

1) I know what assembler do in this workaround - I wrote it. The question was why ST libraries (at least 2.3.0 and 3.0.0) did not work from the box in my case.

2) I do use pre-build and post-build options. It works like a charm. But when I tried to specify a .bin file as a program to upload instead of .elf I got an error about missing symbols information.

ktrofimo
Senior III

Update of (2): STM32CubeIDE can't flash .bin file (because of no symbol information) but it can successfully flash .hex file. So automated solution is to build an .elf file, then generate .hex file for CRC32 calculation, and convert it to .bin finally.

After post-build script finishes .hex with CRC can be used for flash from CubeIDE and .bin for another automation processes.

No success yet for flash from CubeIDE while Cube programmer can flash MCU