I would like to program and debug the M4 (0 and 1) in the Apalis iMX8QM module on a EVB + Segger Jlink.
Debugging is unexpected. Most reliable only after a complete hardware reboot and in a stopped U-Boot.
In particular, after executing a faulty program, a new debug session fails.
I suspect that a clean reset is not being performed.
Which reset strategy is used on the M4 in the imx8qm? Are there any known problems?
Could you specify which kind of faulty program? There are different kinds of faulty programs. Depending on the kind of fault on the Cortex M, you might be blocking it in a way that simply starting a new debug session might be not enough to start the core again.
I am not aware of any problems. The knowledge that we have around it is the content in the article I shared above.
Digging into SCU’s API it could be possible to find a (cold) reset function to forcibly restart the Cortex-M. However, I am just not aware of the effects of doing it as the power domain of the Cortex-M might be shared with other important interfaces/devices.
Is resetting the whole CPU a problem for you (is it blocking you)? From resetting until U-Boot and loading the firmware to the Cortex-M doesn’t take so long.
A possible cause for blocking the Cortex-M is that it is falling into some exception that your firmware is not treating accordingly. To do so, you would need to follow the related manuals to find out how to do it.
Depending on the type of the exception, a full reset of the hardware is the only way of recovering from it.
I actually wanted to keep the thread general. But yes, we have to differentiate between handled and unhandled exceptions. And also the case when NO error has occurred and you want to change a value of a constant, for example.
However, to be clear, here are 2 examples:
Deviating from the article above, I use Windows 11 and VSCode.
From the MCUXpresso SDK Builder I load a demo standalone project ‘hello_world_m41’.
I use the ‘build_debug.bat’ to build the program and get a .elf and a .bin file.
I configure the ‘launch.json’ so that the *.elf file is loaded onto the module before the debug process
A UART transceiver attached to the corresponding pins receives the ‘hello world’ and entered characters are sent back
… everything works as it should
Second
I copy the *.bin file into the /var folder on the module and have the program pushed onto the M4 via the U-Boot an run it. (You can find instructions for this here How to Load Compiled Binaries into Cortex-M)
Now I can attach the debugger to the current running process
for this I use a new entry in the ‘launch.json’ > “configurations” where “request” is changed to “launch”.
works the same way
I just want to describe how it should normally work.
Here I have to point out another problem.
I’m using ‘Arm GNU Toolchain arm-none-eabi/12.2 rel1’. When calling ‘build_debug.bat’ from powershell the build process runs without an error message.
However, if the batch file is started as a ‘preLaunchTask’, a number of error messages appear. e.g.:
…\hello_world_m41\utilities\fsl_sbrk.c:22:1: error: unknown type name ‘caddr_t’
Apparently '__GNUC__' is not defined.
But that’s another problem. A debug without prelaunch works. I have to run the build prozess manually.
Or I use this as env in ‘tasks.json’ "ARMGCC_DIR": "C:/Program Files (x86)/GNU Tools ARM Embedded/8 2018-q4-major"
This also needs to be solved. I still have to check whether there are different behaviors.
Now I have to work out a concrete example in which the strangeness occurs.
It probably boils down to the fact that, especially under freeRTOS, you can provoke undefined states that require a complete reset.
However, this reset is a little more special in multi-core processors.
Thanks for marking this topic as solved, but would you be able to explicitly state what you did to solve your issue? It would be valuable for other Community users
There’s no way to say “OK, I have to deal with it.”
In particular, developing an RPMSG in x tasks application can be extremely stressful.
Now I also had to realize that the #.bin file that you store under /var and then load into the M4 via UBOOT when booting up is not always exactly the one you just copied. Not even after a sync or sync -f. I’m completely at a loss.