Reading ADC on M4 and Accessing Data from A7 on Colibri iMX7D

Hello Community,

I’m working with the Colibri Evaluation Board using the Colibri iMX7D 1GB eMMC SoM. I would like to read ADC values using the M4 core running FreeRTOS, and then send or share this data with the A7 core running Linux.

Could you please guide me on the recommended procedure to achieve this inter-core communication? Any references or example projects using RPMsg or other suitable methods would be greatly appreciated.

Thank you!

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Hello! Thank you for your question.

For your use case with the Colibri iMX7D, the recommended and supported method for inter-core communication between the M4 core (running FreeRTOS) and the A7 core (running Linux) is the RPMsg (Remote Processor Messaging) framework. This allows you to efficiently share data, such as ADC readings, between the two cores.

High-Level Steps

  1. Set up the FreeRTOS environment for the M4 core:

    • Install the required build tools on your Linux PC:
      sudo apt-get install make cmake libc6:i386 libncurses6:i386
      
    • Clone the Toradex FreeRTOS repository and prepare your working directory:
      git clone -b master https://github.com/toradex/FreeRTOS-Colibri-iMX7 freertos-colibri-imx7/
      cd freertos-colibri-imx7/
      
    • Download and set up the GCC ARM Embedded toolchain, then build the FreeRTOS example:
      export ARMGCC_DIR=~/gcc-arm-none-eabi-4_9-2015q3/
      cd examples/imx7_colibri_m4/demo_apps/hello_world/armgcc
      ./build_all.sh
      
  2. Use the RPMsg demo projects as a base for your application:

    • For inter-core data exchange, inspect these FreeRTOS demo applications:
      • examples/imx7_colibri_m4/demo_apps/rpmsg/str_echo_freertos/
      • examples/imx7_colibri_m4/demo_apps/rpmsg/str_echo_bm/
    • These demos show how to set up an RPMsg endpoint on the M4 core and exchange messages with Linux.
  3. Communicate from Linux using the RPMsg character driver:

    • Example C code for opening a channel, exchanging data, and closing the channel:
      #include <stdio.h>
      #include <sys/types.h>
      #include <sys/stat.h>
      #include <fcntl.h>
      #include <linux/rpmsg.h>
      #include <sys/ioctl.h>
      #include <unistd.h>
      
      int main(void) {
          char data_buf[] = {'a', 'b', 'c', 'd', 'e', '\0'};
          struct rpmsg_endpoint_info ept_info = {"rpmsg-openamp-demo-channel", 0x2, 0x1};
          int fd = open("/dev/rpmsg_ctrl0", O_RDWR);
          ioctl(fd, RPMSG_CREATE_EPT_IOCTL, &ept_info); // /dev/rpmsg0 is created
          int fd_ept = open("/dev/rpmsg0", O_RDWR);
          read(fd_ept, &data_buf, sizeof(data_buf));
          write(fd_ept, &data_buf, sizeof(data_buf));
          ioctl(fd_ept, RPMSG_DESTROY_EPT_IOCTL);
          close(fd_ept);
          close(fd);
      }
      
    • This can be adapted to handle ADC data from the M4.
  4. Load and run your FreeRTOS firmware:

    • Use UART_B for console/debug output at 115200 baud.
    • Load the compiled binary into the M4 core using U-Boot and the ext4load method.

References and Further Reading

For detailed, step-by-step guidance, including how to set up the SDK, load the firmware, and more RPMsg examples, please see:

You can use these examples as a starting point and adapt the communication part to transmit your ADC readings from the M4 (FreeRTOS) side to the A7 (Linux) side using RPMsg.

If you need more detailed steps on any of these points, feel free to ask!

Best regards,
Toradex AI Assistant.

@ToradexAI

I have successfully built the hello_world.elf example for the M4 core. Could you please guide me on how to modify or extend this to read ADC values using FreeRTOS on the M4?

A simple example or pointers to the correct ADC initialization and read APIs would be very helpful.

Thanks in advance!

Thanks for your response.

Please remember to tick the “Solution” checkbox below if my response solves your question. If you have follow-up questions, just continue to tag me using @ToradexAI in your new posts.

Did you like my answer? :+1: :-1:


Hello!

Great job on building the hello_world example for the M4 core!

Here’s how you can proceed to get ADC readings on the Colibri iMX7 M4 core with FreeRTOS:


1. Locate ADC Examples and Drivers


2. General Steps to Read ADC on M4/FreeRTOS

a) Investigate the SDK/Source Tree

  • Check the platform/drivers/ directory for the ADC driver (commonly named adc_imx or similar).
  • Review its header file for function prototypes and available APIs.

b) Example Workflow

Here’s a typical workflow using the NXP/MCUXpresso-style peripheral drivers included in the Toradex FreeRTOS BSP:

  1. Initialize the ADC Peripheral
    Set configuration parameters (clock source, resolution, etc.) using the initialization APIs.
  2. Configure the Proper Channel
    Choose the analog input you want to read from, based on the board’s schematic.
  3. Start a Conversion
    Trigger a conversion (often with a “software trigger” function).
  4. Read the Result
    Wait for conversion complete flag, then read the result register.

Pseudocode outline:

#include "fsl_adc.h"   // Use the correct ADC header file

void app_adc_init(void) {
    adc_config_t adcConfig;
    ADC_GetDefaultConfig(&adcConfig);
    ADC_Init(ADC1, &adcConfig);
    // Optionally configure auto-calibration, reference voltage, etc.
}

uint32_t app_adc_read_channel(uint32_t channel) {
    adc_channel_config_t channelConfig = {
        .channelNumber = channel,
        .enableInterruptOnConversionCompleted = false
    };
    ADC_SetChannelConfig(ADC1, 0, &channelConfig);
    while (0U == (ADC_GetChannelStatusFlags(ADC1, 0) & kADC_ChannelConversionCompletedFlag)) {
    }
    return ADC_GetChannelConversionValue(ADC1, 0);
}
  • The actual function names and structures may differ based on the SDK version, so adapt accordingly.
  • Check the available channel numbers and their pin mappings in the Colibri iMX7 datasheet or FreeRTOS documentation.

3. Assign the ADC Peripheral to the M4


4. Build the Modified Application

Once you’ve added your ADC code, build it as you did with hello_world:

export ARMGCC_DIR=~/gcc-arm-none-eabi-4_9-2015q3/
cd examples/imx7_colibri_m4/driver_examples/YOUR_ADC_EXAMPLE/armgcc
./build_all.sh

5. References

If you need more concrete code or run into issues with the peripheral driver APIs, please let me know which specific files you are looking at, and I can help you tailor the code further.

Best regards,
Toradex AI Assistant.

Hi @Uday10122 ,
ADC demo is already available inside the SDK package (driver_examples/lpadc).
Please take reference from there and you can use RpMsg to share the ADC value to the main core

Hi @sahil.tx, @ToradexAI

Thanks for your response

First, I’d like to focus on getting the ADC value printed. After that, I’ll proceed with implementing RPMsg to transfer the data to the A7 core.

So far, I have created the DTS file.

// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/*
 * Copyright 2020-2021 Toradex
 */

// Disable UART2, aka UART_B on the Colibri iMX7

/dts-v1/;
/plugin/;

/ {
	compatible = "toradex,colibri-imx7d",
		     "toradex,colibri-imx7d-emmc",
		     "toradex,colibri-imx7s";
};

&uart2 {
	status = "disabled";
};

/* Colibri AD0 to AD3 */
&adc1 {
    status = "disabled";
};

got this dtbo using dtc compiler then copied to /boot/overlays directory
and then i added this overlays.txt

hen, I ran the following commands:

ext4ls mmc 0:2 /root

setenv load_cmd "ext4load mmc 0:2"
setenv m4image "/root/adc_imx7d.elf"
setenv loadm4image "${load_cmd} ${loadaddr} ${m4image}"
setenv m4boot "${loadm4image}; dcache flush; bootaux ${loadaddr}"

run m4boot

and to run automatically on every boot
setenv bootcmd "run m4boot; $bootcmd}"
saveenv
reset

After this, in UART_A, I see a kernel panic log and the machine stops booting.

[    1.403209] 5dc0:                                     00000000 00000000 00000                                                                             000 00000000
[    1.411419] 5de0: 00000000 fffffffa 00000000 c228bec0 00000000 00000000 00000                                                                             000 1ce50d41
[    1.419630] 5e00: 00000000 00000000 c2134810 c0f8ea78 00000000 c26529b8 c0e4d                                                                             834 c0e62da8
[    1.427840] 5e20: 00000000 c06fd344 c2134810 00000000 c0f8ea78 00000000 c2652                                                                             9b8 c06fa78c
[    1.436050] 5e40: c2134894 c070934c c2134810 c2134810 c0f8ea78 c2134810 00000                                                                             000 c06fab10
[    1.444261] 5e60: 60000013 c0e4d834 c1004568 c0f8ea78 c2134810 00000000 c2652                                                                             9b8 c06fac98
[    1.452471] 5e80: c2134810 c0f8ea78 c2134854 c223d000 c26529b8 c06faf0c 00000                                                                             000 c0f8ea78
[    1.460681] 5ea0: c06fae34 c06f86c4 c0fc4000 c223d058 c228f234 1ce50d41 00000                                                                             000 c0f8ea78
[    1.468892] 5ec0: c2652980 00000000 c223d000 c06f99d0 c0ccf324 00000006 c0f8e                                                                             a78 c20d8000
[    1.477102] 5ee0: 00000006 00000000 c0fc4000 c06fbe00 00000000 c20d8000 00000                                                                             006 c0e2f720
[    1.485313] 5f00: c0e2f6fc c01014fc 000000ec c204ac26 c204ac2e 00000000 00000                                                                             000 00000000
[    1.493522] 5f20: 00000000 00000000 00000000 00000000 00000000 00000000 00000                                                                             000 00000000
[    1.501732] 5f40: 00000000 00000000 00000000 00000000 00000000 1ce50d41 c204a                                                                             c00 000000ec
[    1.509942] 5f60: c204ac00 00000006 c0d3e988 c0e4d854 c0e4d834 c0e012c0 00000                                                                             006 00000006
[    1.518152] 5f80: 00000000 c0e004d0 c0f04d00 c0abd5dc 00000000 00000000 00000                                                                             000 00000000
[    1.526362] 5fa0: 00000000 c0abd5f4 00000000 c010014c 00000000 00000000 00000                                                                             000 00000000
[    1.534572] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000                                                                             000 00000000
[    1.542781] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000                                                                             000 00000000
[    1.550995]  imx_uart_probe from platform_probe+0x5c/0xb0
[    1.556438]  platform_probe from really_probe+0xd0/0x3c8
[    1.561792]  really_probe from __driver_probe_device+0x8c/0x1e4
[    1.567757]  __driver_probe_device from driver_probe_device+0x30/0xc0
[    1.574243]  driver_probe_device from __driver_attach+0xd8/0x1b0
[    1.580295]  __driver_attach from bus_for_each_dev+0x7c/0xcc
[    1.585999]  bus_for_each_dev from bus_add_driver+0xf0/0x214
[    1.591700]  bus_add_driver from driver_register+0x7c/0x114
[    1.597317]  driver_register from imx_uart_init+0x24/0x40
[    1.602766]  imx_uart_init from do_one_initcall+0x58/0x23c
[    1.608296]  do_one_initcall from kernel_init_freeable+0x1f0/0x24c
[    1.614518]  kernel_init_freeable from kernel_init+0x18/0x130
[    1.620305]  kernel_init from ret_from_fork+0x14/0x28
[    1.625390] Exception stack(0xf0825fb0 to 0xf0825ff8)
[    1.630465] 5fa0:                                     00000000 00000000 00000                                                                             000 00000000
[    1.638675] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000                                                                             000 00000000
[    1.646883] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[    1.653527] Code: ebea8db5 e5943008 e5838080 e5938084 (f57ff04f)
[    1.659648] ---[ end trace 0000000000000000 ]---
[    1.664284] note: swapper/0[1] exited with irqs disabled
[    1.669744] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00                                                                             00000b
[    1.677444] CPU1: stopping
[    1.677455] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G      D            6.6.95                                                                             -7.3.0 #1
[    1.677469] Hardware name: Freescale i.MX7 Dual (Device Tree)
[    1.677482]  unwind_backtrace from show_stack+0x10/0x14
[    1.677522]  show_stack from dump_stack_lvl+0x40/0x4c
[    1.677550]  dump_stack_lvl from do_handle_IPI+0xe8/0x110
[    1.677570]  do_handle_IPI from ipi_handler+0x18/0x20
[    1.677588]  ipi_handler from handle_percpu_devid_irq+0x78/0x134
[    1.677615]  handle_percpu_devid_irq from handle_irq_desc+0x50/0x80
[    1.677646]  handle_irq_desc from gic_handle_irq+0x64/0x78
[    1.677668]  gic_handle_irq from generic_handle_arch_irq+0x34/0x44
[    1.677689]  generic_handle_arch_irq from call_with_stack+0x18/0x20
[    1.677719]  call_with_stack from __irq_svc+0x98/0xc8
[    1.677739] Exception stack(0xf08edf58 to 0xf08edfa0)
[    1.677749] df40:                                                       00000                                                                             003 00000001
[    1.677762] df60: 00001c8c 40000000 c20e1b00 00000001 c0f04d54 c0f04d9c 00000                                                                             000 00000000
[    1.677775] df80: 00000000 00000000 0000b50e f08edfa8 c0abc8c4 c0abd300 60000                                                                             013 ffffffff
[    1.677783]  __irq_svc from default_idle_call+0x2c/0x30
[    1.677804]  default_idle_call from do_idle+0x208/0x290
[    1.677836]  do_idle from cpu_startup_entry+0x28/0x2c
[    1.677866]  cpu_startup_entry from secondary_start_kernel+0x11c/0x140
[    1.677891]  secondary_start_kernel from 0x80101320
[    1.807023] ---[ end Kernel panic - not syncing: Attempted to kill init! exit                                                                             code=0x0000000b ]---

machine not booting after this

and

In UART_B, I see repeated output:

Current analog value: fv
Current analog value: fv
Current analog value: fv
Current analog value: fv
Current analog value: fv
Current analog value: fv
Current analog value: fv
Current analog value: fv
Current analog value: fv
Current analog value: fv
Current analog value: fv

I assume this is expected since no ADC device is connected yet.

My question is: why is the machine failing to boot after these changes?

Thanks & regards,
Uday

Hi @sahil.tx, @ToradexAI

Thanks for your response

First, I’d like to focus on getting the ADC value printed. After that, I’ll proceed with implementing RPMsg to transfer the data to the A7 core.

So far, I have created the DTS file.

// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/*
 * Copyright 2020-2021 Toradex
 */

// Disable UART2, aka UART_B on the Colibri iMX7

/dts-v1/;
/plugin/;

/ {
	compatible = "toradex,colibri-imx7d",
		     "toradex,colibri-imx7d-emmc",
		     "toradex,colibri-imx7s";
};

&uart2 {
	status = "disabled";
};

/* Colibri AD0 to AD3 */
&adc1 {
    status = "disabled";
};

got this dtbo using dtc compiler then copied to /boot/overlays directory
and then i added this overlays.txt

Then, I ran the following commands:

ext4ls mmc 0:2 /root

setenv load_cmd "ext4load mmc 0:2"
setenv m4image "/root/adc_imx7d.elf"
setenv loadm4image "${load_cmd} ${loadaddr} ${m4image}"
setenv m4boot "${loadm4image}; dcache flush; bootaux ${loadaddr}"

run m4boot

and to run automatically on every boot
setenv bootcmd "run m4boot; $bootcmd}"
saveenv
reset

After this, in UART_A, I see a kernel panic log and the machine stops booting.

[    1.403209] 5dc0:                                     00000000 00000000 00000                                                                             000 00000000
[    1.411419] 5de0: 00000000 fffffffa 00000000 c228bec0 00000000 00000000 00000                                                                             000 1ce50d41
[    1.419630] 5e00: 00000000 00000000 c2134810 c0f8ea78 00000000 c26529b8 c0e4d                                                                             834 c0e62da8
[    1.427840] 5e20: 00000000 c06fd344 c2134810 00000000 c0f8ea78 00000000 c2652                                                                             9b8 c06fa78c
[    1.436050] 5e40: c2134894 c070934c c2134810 c2134810 c0f8ea78 c2134810 00000                                                                             000 c06fab10
[    1.444261] 5e60: 60000013 c0e4d834 c1004568 c0f8ea78 c2134810 00000000 c2652                                                                             9b8 c06fac98
[    1.452471] 5e80: c2134810 c0f8ea78 c2134854 c223d000 c26529b8 c06faf0c 00000                                                                             000 c0f8ea78
[    1.460681] 5ea0: c06fae34 c06f86c4 c0fc4000 c223d058 c228f234 1ce50d41 00000                                                                             000 c0f8ea78
[    1.468892] 5ec0: c2652980 00000000 c223d000 c06f99d0 c0ccf324 00000006 c0f8e                                                                             a78 c20d8000
[    1.477102] 5ee0: 00000006 00000000 c0fc4000 c06fbe00 00000000 c20d8000 00000                                                                             006 c0e2f720
[    1.485313] 5f00: c0e2f6fc c01014fc 000000ec c204ac26 c204ac2e 00000000 00000                                                                             000 00000000
[    1.493522] 5f20: 00000000 00000000 00000000 00000000 00000000 00000000 00000                                                                             000 00000000
[    1.501732] 5f40: 00000000 00000000 00000000 00000000 00000000 1ce50d41 c204a                                                                             c00 000000ec
[    1.509942] 5f60: c204ac00 00000006 c0d3e988 c0e4d854 c0e4d834 c0e012c0 00000                                                                             006 00000006
[    1.518152] 5f80: 00000000 c0e004d0 c0f04d00 c0abd5dc 00000000 00000000 00000                                                                             000 00000000
[    1.526362] 5fa0: 00000000 c0abd5f4 00000000 c010014c 00000000 00000000 00000                                                                             000 00000000
[    1.534572] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000                                                                             000 00000000
[    1.542781] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000                                                                             000 00000000
[    1.550995]  imx_uart_probe from platform_probe+0x5c/0xb0
[    1.556438]  platform_probe from really_probe+0xd0/0x3c8
[    1.561792]  really_probe from __driver_probe_device+0x8c/0x1e4
[    1.567757]  __driver_probe_device from driver_probe_device+0x30/0xc0
[    1.574243]  driver_probe_device from __driver_attach+0xd8/0x1b0
[    1.580295]  __driver_attach from bus_for_each_dev+0x7c/0xcc
[    1.585999]  bus_for_each_dev from bus_add_driver+0xf0/0x214
[    1.591700]  bus_add_driver from driver_register+0x7c/0x114
[    1.597317]  driver_register from imx_uart_init+0x24/0x40
[    1.602766]  imx_uart_init from do_one_initcall+0x58/0x23c
[    1.608296]  do_one_initcall from kernel_init_freeable+0x1f0/0x24c
[    1.614518]  kernel_init_freeable from kernel_init+0x18/0x130
[    1.620305]  kernel_init from ret_from_fork+0x14/0x28
[    1.625390] Exception stack(0xf0825fb0 to 0xf0825ff8)
[    1.630465] 5fa0:                                     00000000 00000000 00000                                                                             000 00000000
[    1.638675] 5fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000                                                                             000 00000000
[    1.646883] 5fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[    1.653527] Code: ebea8db5 e5943008 e5838080 e5938084 (f57ff04f)
[    1.659648] ---[ end trace 0000000000000000 ]---
[    1.664284] note: swapper/0[1] exited with irqs disabled
[    1.669744] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00                                                                             00000b
[    1.677444] CPU1: stopping
[    1.677455] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G      D            6.6.95                                                                             -7.3.0 #1
[    1.677469] Hardware name: Freescale i.MX7 Dual (Device Tree)
[    1.677482]  unwind_backtrace from show_stack+0x10/0x14
[    1.677522]  show_stack from dump_stack_lvl+0x40/0x4c
[    1.677550]  dump_stack_lvl from do_handle_IPI+0xe8/0x110
[    1.677570]  do_handle_IPI from ipi_handler+0x18/0x20
[    1.677588]  ipi_handler from handle_percpu_devid_irq+0x78/0x134
[    1.677615]  handle_percpu_devid_irq from handle_irq_desc+0x50/0x80
[    1.677646]  handle_irq_desc from gic_handle_irq+0x64/0x78
[    1.677668]  gic_handle_irq from generic_handle_arch_irq+0x34/0x44
[    1.677689]  generic_handle_arch_irq from call_with_stack+0x18/0x20
[    1.677719]  call_with_stack from __irq_svc+0x98/0xc8
[    1.677739] Exception stack(0xf08edf58 to 0xf08edfa0)
[    1.677749] df40:                                                       00000                                                                             003 00000001
[    1.677762] df60: 00001c8c 40000000 c20e1b00 00000001 c0f04d54 c0f04d9c 00000                                                                             000 00000000
[    1.677775] df80: 00000000 00000000 0000b50e f08edfa8 c0abc8c4 c0abd300 60000                                                                             013 ffffffff
[    1.677783]  __irq_svc from default_idle_call+0x2c/0x30
[    1.677804]  default_idle_call from do_idle+0x208/0x290
[    1.677836]  do_idle from cpu_startup_entry+0x28/0x2c
[    1.677866]  cpu_startup_entry from secondary_start_kernel+0x11c/0x140
[    1.677891]  secondary_start_kernel from 0x80101320
[    1.807023] ---[ end Kernel panic - not syncing: Attempted to kill init! exit                                                                             code=0x0000000b ]---

machine not booting after this

and

In UART_B, I see repeated output:

Current analog value: fv
Current analog value: fv
Current analog value: fv
Current analog value: fv
Current analog value: fv
Current analog value: fv
Current analog value: fv
Current analog value: fv
Current analog value: fv
Current analog value: fv
Current analog value: fv

I assumed this is ok
now i connected potentiometer now also i ma getting the same value connected to sodimm pin 2

My question is: why is the machine failing to boot after these changes?
and why i am not reading any value

Thanks & regards,
Uday

Thanks for your response.

Please remember to tick the “Solution” checkbox below if my response solves your question. If you have follow-up questions, just continue to tag me using @ToradexAI in your new posts.

Did you like my answer? :+1: :-1:


Hello Uday,

Thank you for sharing all the details of your setup. The issue you are experiencing—where the kernel panics and the machine fails to boot after your M4 firmware is run—typically results from a resource conflict between Linux (A7 core) and FreeRTOS (M4 core) due to both attempting to access the same hardware peripherals, such as UART_B and ADC1.

Why Does the Kernel Panic Occur?

By default, all peripherals are reserved by Linux at boot through the Resource Domain Controller (RDC). If Linux tries to probe/init a device that has already been taken over by the M4 (e.g., because your FreeRTOS application is running early), you can get a kernel panic, especially if the device drivers are not expecting this situation.

Disabling UART_B and ADC1 in your device tree overlay (which you did correctly) is necessary, but sometimes timing or the way U-Boot runs your M4 firmware in bootcmd can result in conflicts, as the M4 firmware starts before Linux has fully relinquished control of those peripherals.

Step-by-Step Solution

  1. Test Your Device Tree Overlay

    • Disable your M4 firmware auto-boot for now.
    • Boot into Linux with your overlay loaded and confirm that both UART2 and ADC1 are disabled by checking dmesg and using:
      ls /sys/bus/platform/devices/ | grep uart
      ls /sys/bus/platform/devices/ | grep adc
      
      They should not appear as enabled devices.
    • If Linux boots correctly at this point, your overlay is working.
  2. Manually Load M4 Firmware

    • After Linux is fully booted, manually load and run your M4 firmware using U-Boot:
      ext4load mmc 0:2 ${loadaddr} /root/adc_imx7d.elf
      bootaux ${loadaddr}
      
    • Check UART_B for output.
  3. Automate M4 Boot Carefully

    • Only after confirming the steps above should you automate the M4 firmware loading in bootcmd.

    • Make sure the M4 firmware is not loaded before Linux has finished device tree and overlay initialization.

    • A recommended bootcmd approach is:

      setenv bootcmd 'run m4boot; ${bootcmd}'
      saveenv
      reset
      

      Note: Be careful, as a typo in bootcmd or running your M4 firmware before overlays are loaded may re-trigger the panic.

  4. Understand RDC (Resource Domain Controller)

    • The RDC will only assign the ADC and UART to the M4 if your M4 firmware does so. Double-check your FreeRTOS code or use the example applications to ensure the initialization includes necessary RDC steps.
  5. Expected Output on UART_B

    • The “Current analog value: fv” message means your M4 firmware is running and attempting to read from the ADC, but the input is floating or not connected.

References


In summary:

  • The kernel panic is due to a resource conflict; ensure Linux and FreeRTOS are not trying to access the same peripherals.
  • Test overlays by booting Linux first without running M4 firmware.
  • Only start M4 code after confirming Linux has relinquished peripheral control.
  • Follow this guide step by step for robust cohabitation of both OSes.

If you follow these steps and confirm each stage, your board should boot without kernel panic and your M4 firmware should work as intended.

Let me know if you need help debugging a specific step above!

Best regards,
Toradex AI Assistant.