Verdin-imx8mm - Torizon - Accessing UART on Cortex-M4 (UART2) on Verdin Developentboard V1.1->(RS485 UART_1) causes Hard Fault

Hey Everyone,

i use the Easy Installer 5.4 to flash a Torizocore image build by torizon core build tool. The base image is the torizon-core-docker-verdin-imx8mm-Tezi_5.4+build.10.
Everthing is fine.

After i successfully flashed that image i interrupt the boot process to get to the u-boot console. At this point i am able to debug my cortex-m4 firmware from my dev host (Ubuntu / Eclipse CDT / J-Link Plus) on the target.
Linux ist not finally booted.
Everthing is fine.

i’d started first with an easy UART Example for the Cortex-M4. Sending and receiving Characters over the UART4 (Primary debug log output for Corext-M core ).
Everthing is fine.

Then i went ahead and changed UART4 to UART3 routed to RS232 UART_2 on Verding Development board. Therfore i only changed the pinconfiguration (MCUXpresso Config Tool) that the UART3 pins are correctly routed to the SOC Pins D6,B7 (RX/TX).
Everthing is fine.

Then i went another step further and changed UART3 to UART2 routed to RS485 UART_1 on Verding Development board. Therfore i only changed the pinconfiguration (MCUXpresso Config Tool) that the UART2 pins are correctly routed to the SOC Pins AG6(TX),AC6(RX) or AG6(RX),AC6(TX), both tried.

In that moment i try to call the Uart init function or only try to write anything to any of the uart control registers a hard faulty occures. The BusFault Status Register (BFSR) reports bus fault and point to that line of code where the uart is tried to initialize.
FAILD with hard fault (BUS Fault).

I’d a lot of research about the device trees from U-Boot, because i thought the linux device trees don’t matter at this point where linux ist not finally booted up, and other possibilties that could cause that kind of problem. But for now i am not able solve this myself anymore.

I would appreciate it if someone could help me.

Nikolai Fichtner

1 Like

hi Nikolai,
can you please explain me how did you setup Eclipse and J-link to debug applications on the M4? I’m trying to do the same.

Hi Rocco,


yes, i’m feeling with you. This part ist not well documented. I needed some time till i got a working solution and i tried a lot :wink:

Some facts which are very important:

MCUXpresso Studio ist definitly not supportd for the, in my case Imx8mm dual lite, but the toolchain, samples for IAR Embedded Workbench or Development based on GCC is available.

Pinconfiguration ist possible with two different tool, but i use
<<MCUXpresso Config Tools - Pins, Clocks, Peripherals>>, but only Pinconfiguration is supported. MCUXpresso Config Tools complains at the respective sections about it, but it works and correctly updates the code.

Dont use the bare examples from the SDK! This is very painful to cherry pick the needed dependencies. Use MCUXpresso Config Tools and import the SDK. Then you can select the respective example of you choise and generate a folder structure only with the needed source code for your application (RTOS, UART, Timer, Interrupt) (This don’t work for the SDK getting started examples)

Oke first of all it is very important that you use a linux development host. I use a laptop with Ubuntu 18.04. This is caused by the fact that the arm toolchain (was) only available for linux dev hosts, not for windows. (arm-none-linux-gnueabihf)
EDIT: It also available for windows, but i recommend the use of a ubuntu dev hosts instead.
This step is only needed for command line build (installing this is mandatory anyway) with cmake, not for the ide itself. Eclipse installs a independent gnu toolchain with x packs.

Install the Eclipse IDE and toolchain (x packs). J Link like documented on this page.

Get <<Eclipse IDE for Embedded C/C++ Developers>> here

1 Step
Download the SDK from NXP (Therefore the exact SOC Number from the Toradex verdin imx8mm datasheet (eg. MIMX8MM3DVTLZAx) is needed).

2 Step
Follow the getting startet with GCC from the NXP SDK. Install addional software like cmake, putty, etc…
This guide is tageting a simple << hello world >> example, which is a good starting point.

3 Step
You successfully build the << hello world >> example. Some similar examples exists on the toradex developers site.
CMake is used by the sdk to build makefiles for the respective configuration debug, release, debug_ddr on so on … then cmake also starts make to build the final .bin file.

Here is the point where i was starting the reverse enginering process to setup eclipse to build this the same way. Eclipse not suppot this kind of CMake projects. This means you can not simply import this to Eclipse.
In the SDK navigate to the << hello world >> example.

In cotrast to the sdk example run the following commands:

$ ./armgcc/ # This only generates the appropriate makefilefiles (for the debug_configuration) without calling make

$ cd ./armgcc
$ make << generated makefile >> VERBOSE=1 # This runs make an lists all gcc configurations, include paths and options which must mirrored equally to the created eclipse project

Capture the verbose output to a text file. (Later to get the verbose output from the make command a second time, you first have to run $ make clean)

4 Step
You have create a new projekt and import your whole folder structure of the example generated by << MCUXpresso Config Tools >> to your new project. Then delete the debug and release configuration.
Create a new configuration. In this case << Debug_cm4_ram >>.

5 Step
Get the verbose ouput from << 4 Step>> and go through each project option of the eclipse project and mirror the compiler option, includepath, …etc. with the gcc command line options. Don’t forget the linker script!

6 Step
If everything hast correctly configured it succecssfully builds.

7 Step
Debugging needs an .elf file instead of a .bin file, which can be configured in the project options too. Setting up the debugger is good exmplained here

8 Step
Run the M4 code so far i alway had to bring up the imx8mm to the u-boot console. Debugging is then possible.

If you step further and want to boot the cortex a, it is only possible to load the .bin file from the SD Card or TFTP and free run the cortex m without debugging. This works good.
So far i could not debug cortex m code if the cortex a boots completly.


Nikolai Fichtner

1 Like

thank you very much Nikolai,
I will try your guide :wink:


Hey everyone,

i solved the problem with the hard fault by referring to this Post.

I switched the domain in the imx cortex m ATF(ARM TRUSTED FIRMWARE) source to Domain 1 ( D1R | D1W ) →


This all together is included inside the imx-boot file, which can be replaced in order to modify the toradex easy installer compatible images. This process is well documented in chapter: Building U-Boot
Build U-Boot and Linux Kernel from Source Code


Nikolai Fichtner