Starting m4 application from ocram imx7

I want to start a m4 application from ocram to communicate with a7 over rpmsg.
I’m using ARM compiler to compile m4 application.
Compiling the example rpmsg_str_echo_freertos_example with tcm scatter file works fine and runs with linux image 2.8b6.
Compiling with ocram scatter file works and I can start the app.
But there is no communication over rpmsg.
Think # modprobe imx_rpmsg_tty is ok.

root@colibri-imx7:~# ls /dev/ | grep RPMSG
ttyRPMSG0

I followed this tutorial.
ocram scatter file looks as follow:

#define m_interrupts_start             0x00000000
#define m_interrupts_size              0x00000240

#define m_text_start                   0x00910240
#define m_text_size                    0x00007DC0

/* m_data_size includes stack and heap */
#define m_data_start                   0x20200000
#define m_data_size                    0x7800

/* Sizes */
#if (defined(__stack_size__))
  #define Stack_Size                   __stack_size__
#else
  #define Stack_Size                   0x0200
#endif

#if (defined(__heap_size__))
  #define Heap_Size                    __heap_size__
#else
  #define Heap_Size                    0x0200
#endif

Also tried a mix scatter file with tcm and ocram:

#define m_interrupts_start             0x00000000
#define m_interrupts_size              0x00000240

#define m_text_start                   0x1FFF8240
#define m_text_size                    0x0000FDB0

/* m_data_size includes stack and heap */
#define m_data_start                   0x20200000
#define m_data_size                    0x00020000

/* Sizes */
#if (defined(__stack_size__))
  #define Stack_Size                   __stack_size__
#else
  #define Stack_Size                   0x8000
#endif

#if (defined(__heap_size__))
  #define Heap_Size                    __heap_size__
#else
  #define Heap_Size                    0xE000
#endif

On WinCE, application runs with all three scatter files.
Am I doing something wrong?

Kind regards,
kuzco

HI @Kuzco

Regarding your issue: What are you trying to do?
What is exactly your application?

Have you done any changes to the Bsp? If yes could you share your changes.
Which changes have you done to the free RTOS code?

Best regards,
Jaski

Hi @jaski.tx,
I try to start the example str_echo_freertos in ocram respectively in my mix scatter file using Arm Compilers 5.
I did not made changes in code. Neither in BSP nor in FreeRTOS.
First I compiled the example as given in tcm memory (scatter file) with Arm Compilers 5 → works fine.
After that I tried exactly the same only with ocram scatter file → no communication over rpmsg between the applications.
On console I can see that application is starting in ocram. But there is no communication between cores.

Regards,
kuzco

Dear @jaski.tx,
again I tried both examples:
TCM:

Colibri iMX7 # fatload mmc 0:1 ${loadaddr} rpmsg_tcm.elf                                                                            
reading rpmsg_tcm.elf                                                                                                               
4955108 bytes read in 234 ms (20.2 MiB/s)                                                                                           
Colibri iMX7 # bootaux ${loadaddr}                                                                                                  
## Starting auxiliary core at 0x1FFF83D9 ...                                                                                        
Colibri iMX7 # boot
[..]
colibri-imx7 login: root                                                                                                            
Last login: Mon Apr  1 17:34:31 UTC 2019 on ttymxc0                                                                                 
root@colibri-imx7:~# stty -F /dev/ttyRPMSG0 -echo                                                                                   
root@colibri-imx7:~# exec 3<> /dev/ttyRPMSG0                                                                                        
root@colibri-imx7:~# echo Test >&3                                                                                                  
root@colibri-imx7:~# cat <&3                                                                                                        
Test                                                                                                                                
                                                                                                                                    
^C                                                                                                                                  
root@colibri-imx7:~# exec 3>&-                                                                                                      
root@colibri-imx7:~# 

Exactly what i expected.

OCRAM:

Colibri iMX7 # fatload mmc 0:1 ${loadaddr} rpmsg_ocram.elf                                                                          
reading rpmsg_ocram.elf                                                                                                             
4955112 bytes read in 234 ms (20.2 MiB/s)                                                                                           
Colibri iMX7 # bootaux ${loadaddr}                                                                                                  
## Starting auxiliary core at 0x009103D9 ...                                                                                        
Colibri iMX7 # boot

colibri-imx7 login: root                                                                                                            
Last login: Mon Apr  1 17:34:49 UTC 2019 on ttymxc0                                                                                 
root@colibri-imx7:~# stty -F /dev/ttyRPMSG0 -echo                                                                                   
root@colibri-imx7:~# exec 3<> /dev/ttyRPMSG0                                                                                        
root@colibri-imx7:~# echo Test >&3                                                                                                  
[   73.025169] INFO: rcu_sched self-detected stall on CPU                                                                           
[   73.030349]  0-...: (2099 ticks this GP) idle=e99/140000000000001/0 softirq=3597/3597 fqs=1050                                   
[   73.039047]   (t=2100 jiffies g=757 c=756 q=149)                                                                                 
[   73.043680] Task dump for CPU 0:                                                                                                 
[   73.046908] sh              R  running task        0   456    385 0x00000002                                                     
[   73.054009] [<8010e12c>] (unwind_backtrace) from [<8010ade0>] (show_stack+0x10/0x14)                                             
[   73.061762] [<8010ade0>] (show_stack) from [<801b684c>] (rcu_dump_cpu_stacks+0xa8/0xc0)                                          
[   73.069777] [<801b684c>] (rcu_dump_cpu_stacks) from [<80177064>] (rcu_check_callbacks+0x5a4/0x81c)                               
[   73.078745] [<80177064>] (rcu_check_callbacks) from [<8017a17c>] (update_process_times+0x34/0x5c)                                
[   73.087624] [<8017a17c>] (update_process_times) from [<8018b30c>] (tick_sched_timer+0x48/0x8c)                                   
[   73.096242] [<8018b30c>] (tick_sched_timer) from [<8017b1d0>] (__hrtimer_run_queues+0x11c/0x1a8)                                 
[   73.105034] [<8017b1d0>] (__hrtimer_run_queues) from [<8017b414>] (hrtimer_interrupt+0xa8/0x204)                                 
[   73.113827] [<8017b414>] (hrtimer_interrupt) from [<805f5430>] (arch_timer_handler_phys+0x28/0x30)                               
[   73.122793] [<805f5430>] (arch_timer_handler_phys) from [<8016de3c>] (handle_percpu_devid_irq+0x78/0x138)                        
[   73.132366] [<8016de3c>] (handle_percpu_devid_irq) from [<8016931c>] (generic_handle_irq+0x24/0x34)                              
[   73.141418] [<8016931c>] (generic_handle_irq) from [<80169820>] (__handle_domain_irq+0x5c/0xb4)                                  
[   73.150123] [<80169820>] (__handle_domain_irq) from [<80101474>] (gic_handle_irq+0x48/0x8c)                                      
[   73.158478] [<80101474>] (gic_handle_irq) from [<8010b8cc>] (__irq_svc+0x6c/0x90)                                                
[   73.165962] Exception stack(0x8d49bd78 to 0x8d49bdc0)                                                                            
[   73.171016] bd60:                                                       f5aa0000 00000001                                        
[   73.179197] bd80: 00010000 00300200 8c247f00 00010000 90060400 8c245400 8c24a180 8083235c                                        
[   73.187379] bda0: 8c245400 0000000a 00400000 8d49bdcc f5aa0020 8047acc0 40000013 ffffffff                                        
[   73.195566] [<8010b8cc>] (__irq_svc) from [<8047acc0>] (MU_SendMessage+0x28/0x5c)                                                
[   73.203057] [<8047acc0>] (MU_SendMessage) from [<8060d628>] (imx_rpmsg_notify+0x30/0x44)                                         
[   73.211154] [<8060d628>] (imx_rpmsg_notify) from [<8047c248>] (virtqueue_kick+0x2c/0x50)                                         
[   73.219250] [<8047c248>] (virtqueue_kick) from [<8060cc64>] (rpmsg_send_offchannel_raw+0x264/0x318)                              
[   73.228300] [<8060cc64>] (rpmsg_send_offchannel_raw) from [<8060ce30>] (virtio_rpmsg_send+0x2c/0x34)                             
[   73.237446] [<8060ce30>] (virtio_rpmsg_send) from [<7f020130>] (rpmsgtty_write+0x48/0x8c [imx_rpmsg_tty])                        
[   73.247025] [<7f020130>] (rpmsgtty_write [imx_rpmsg_tty]) from [<8048a75c>] (do_output_char+0x160/0x1e4)                         
[   73.256510] [<8048a75c>] (do_output_char) from [<8048b75c>] (n_tty_write+0x204/0x440)                                            
[   73.264345] [<8048b75c>] (n_tty_write) from [<80486f1c>] (tty_write+0x180/0x358)                                                 
[   73.271749] [<80486f1c>] (tty_write) from [<801fda8c>] (__vfs_write+0x1c/0x110)                                                  
[   73.279064] [<801fda8c>] (__vfs_write) from [<801fe90c>] (vfs_write+0xa4/0x1b0)                                                  
[   73.286380] [<801fe90c>] (vfs_write) from [<801ff9e4>] (SyS_write+0x3c/0x90)                                                     
[   73.293436] [<801ff9e4>] (SyS_write) from [<80107580>] (ret_fast_syscall+0x0/0x48)
[  100.005174] NMI watchdog: BUG: soft lockup - CPU#0 stuck for 23s! [sh:456]                                                       
[  100.012064] Modules linked in: bluetooth(O) compat(O) usb_f_rndis u_ether imx_rpmsg_tty libcomposite configfs                    
[  100.022094] CPU: 0 PID: 456 Comm: sh Tainted: G           O    4.9.166-2.8.6+gd899927728be #1                                    
[  100.030617] Hardware name: Freescale i.MX7 Dual (Device Tree)                                                                    
[  100.036365] task: 8c51f300 task.stack: 8d49a000                                                                                  
[  100.040907] PC is at MU_SendMessage+0x28/0x5c                                                                                    
[  100.045266] LR is at 0xf5aa0020                                                                                                  
[  100.048410] pc : [<8047acc0>]    lr : [<f5aa0020>]    psr: 40000013                                                              
[  100.048410] sp : 8d49bdcc  ip : 00400000  fp : 0000000a                                                                          
[  100.059888] r10: 8c245400  r9 : 8083235c  r8 : 8c24a180                                                                          
[  100.065114] r7 : 8c245400  r6 : 90060400  r5 : 00010000  r4 : 8c247f00                                                           
[  100.071642] r3 : 00300200  r2 : 00010000  r1 : 00000001  r0 : f5aa0000                                                           
[  100.078173] Flags: nZcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none                                                    
[  100.085309] Control: 10c5387d  Table: 8d4ac06a  DAC: 00000051                                                                    
[  100.091057] CPU: 0 PID: 456 Comm: sh Tainted: G           O    4.9.166-2.8.6+gd899927728be #1                                    
[  100.099580] Hardware name: Freescale i.MX7 Dual (Device Tree)                                                                    
[  100.105344] [<8010e12c>] (unwind_backtrace) from [<8010ade0>] (show_stack+0x10/0x14)                                             
[  100.113094] [<8010ade0>] (show_stack) from [<8040dc8c>] (dump_stack+0x88/0x9c)                                                   
[  100.120325] [<8040dc8c>] (dump_stack) from [<801a03b8>] (watchdog_timer_fn+0x260/0x2d8)                                          
[  100.128337] [<801a03b8>] (watchdog_timer_fn) from [<8017b1d0>] (__hrtimer_run_queues+0x11c/0x1a8)                                
[  100.137216] [<8017b1d0>] (__hrtimer_run_queues) from [<8017b414>] (hrtimer_interrupt+0xa8/0x204)                                 
[  100.146009] [<8017b414>] (hrtimer_interrupt) from [<805f5430>] (arch_timer_handler_phys+0x28/0x30)                               
[  100.154976] [<805f5430>] (arch_timer_handler_phys) from [<8016de3c>] (handle_percpu_devid_irq+0x78/0x138)                        
[  100.164551] [<8016de3c>] (handle_percpu_devid_irq) from [<8016931c>] (generic_handle_irq+0x24/0x34)                              
[  100.173603] [<8016931c>] (generic_handle_irq) from [<80169820>] (__handle_domain_irq+0x5c/0xb4)                                  
[  100.182307] [<80169820>] (__handle_domain_irq) from [<80101474>] (gic_handle_irq+0x48/0x8c)                                      
[  100.190663] [<80101474>] (gic_handle_irq) from [<8010b8cc>] (__irq_svc+0x6c/0x90)                                                
[  100.198146] Exception stack(0x8d49bd78 to 0x8d49bdc0)                                                                            
[  100.203200] bd60:                                                       f5aa0000 00000001                                        
[  100.211382] bd80: 00010000 00300200 8c247f00 00010000 90060400 8c245400 8c24a180 8083235c                                        
[  100.219565] bda0: 8c245400 0000000a 00400000 8d49bdcc f5aa0020 8047acc0 40000013 ffffffff                                        
[  100.227749] [<8010b8cc>] (__irq_svc) from [<8047acc0>] (MU_SendMessage+0x28/0x5c)                                                
[  100.235240] [<8047acc0>] (MU_SendMessage) from [<8060d628>] (imx_rpmsg_notify+0x30/0x44)                                         
[  100.243337] [<8060d628>] (imx_rpmsg_notify) from [<8047c248>] (virtqueue_kick+0x2c/0x50)                                         
[  100.251433] [<8047c248>] (virtqueue_kick) from [<8060cc64>] (rpmsg_send_offchannel_raw+0x264/0x318)                              
[  100.260482] [<8060cc64>] (rpmsg_send_offchannel_raw) from [<8060ce30>] (virtio_rpmsg_send+0x2c/0x34)                             
[  100.269627] [<8060ce30>] (virtio_rpmsg_send) from [<7f020130>] (rpmsgtty_write+0x48/0x8c [imx_rpmsg_tty])                        
[  100.279204] [<7f020130>] (rpmsgtty_write [imx_rpmsg_tty]) from [<8048a75c>] (do_output_char+0x160/0x1e4)                         
[  100.288689] [<8048a75c>] (do_output_char) from [<8048b75c>] (n_tty_write+0x204/0x440)                                            
[  100.296524] [<8048b75c>] (n_tty_write) from [<80486f1c>] (tty_write+0x180/0x358)                                                 
[  100.303927] [<80486f1c>] (tty_write) from [<801fda8c>] (__vfs_write+0x1c/0x110)                                                  
[  100.311244] [<801fda8c>] (__vfs_write) from [<801fe90c>] (vfs_write+0xa4/0x1b0)                                                  
[  100.318560] [<801fe90c>] (vfs_write) from [<801ff9e4>] (SyS_write+0x3c/0x90)                                                     
[  100.325616] [<801ff9e4>] (SyS_write) from [<80107580>] (ret_fast_syscall+0x0/0x48)

Don’t know what all the messages mean.
I can send you the binary .elf files.
OCRAM example is compiled with the scatter file mentioned above.

Hope this helps.
Kind regards,
kuzco

Dear @Kuzco

Linux seems to somewhat use two OCRAM ranges:

  1. 4kB at the start of OCRAM
    0x2020_0000 - 0x2020_0FFF / 0x0090_0000 - 0x0090_0FFF
  2. 60kB at offset 0x1000
    0x2020_1000 - 0x2020_FFFF / 0x0090_1000 - 0x0090_FFFF

I verified that the first 4kB get overwritten during Linux boot, the other 60kB seem to be left untouched.
I didn’t analyze in detail which Linux functionality uses the memory, and how to disable it.

Can you try to modify your scatter file to not use the first 4kB?

Regards, Andy

Dear @andy.tx,
thanks for your answer.
It seems that this is a solution.
Now the str_echo_freertos example and my own M4 application are running with ocram and my mix scatter file.
Thank you!

Kind regards,
kuzco