Firmata: kernel panic accessing /dev/ttyMCC

Discussion in 'UDOO NEO' started by maleadt, Mar 6, 2016.

  1. maleadt

    maleadt New Member

    Joined:
    Feb 15, 2016
    Messages:
    8
    Likes Received:
    0
    EDIT: see below, this only happens when running Firmata on the M4.

    I'm following the tutorial at http://www.udoo.org/docs-neo/Arduino_M4_Processor/Communication.html, programming the M4 with the on-device arduino IDE and using minicom to connect to /dev/ttyMCC.
    As soon as I start minicom, I get a kernel panic:

    Code:
    Kernel panic - not syncing: Aiee, killing interrupt handler!
    This is on a fully updated UDOObuntu, running kernel 02003-g19d1e35.
    Needless to say, without access to /dev/ttyMCC the M4 is pretty useless to me.
     
    Last edited: Mar 7, 2016
  2. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    I haven't tried minicom on my Neo. With the Arduino IDE Serioal Monitor I have no issues, also not when I connect with Python with serial library. PHP also seems to work.
    Bash (and perhaps also minicom) seems not to work when I read other issues here on the forum. So /dev/ttyMCC is accessible but for some reason not with all applications.
     
  3. maleadt

    maleadt New Member

    Joined:
    Feb 15, 2016
    Messages:
    8
    Likes Received:
    0
    Oh for the love of... The IDE's serial monitor works perfectly indeed, whilst the (documented!) procedure of using minicom -- or the random serial port library I was using in my project -- doesn't... Guess I'll be stracing both to see which syscall trips ups the driver. Thanks for the suggestion.

    In case any of the devs is listening, sending back data using the serial monitor, using the sketch from the documentation linked above, yields another oops:

    Code:
    [19303.504573] Unable to handle kernel paging request at virtual address c1279a48
    [19303.531172] pgd = 80004000
    [19303.548954] [c1279a48] *pgd=a89a6811, *pte=00000000, *ppte=00000000
    [19303.587225] Internal error: Oops: 7 [#1] PREEMPT SMP ARM
    [19303.592542] Modules linked in: usb_f_acm u_serial g_serial libcomposite 8021q cmac ipt_MASQUERADE iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat ip_tables ipv6 rfcomm bnep wl18xx wlcore mac80211 cfg80211 mxc_vadc mx6s_capture mpl3115 industrialio_triggered_buffer tsl2563 lm75 hwmon wlcore_sdio ci_hdrc_imx usbmisc_imx ci_hdrc udc_core ehci_hcd usbcore usb_common btwilink bluetooth rfkill st_drv fuse
    [19303.629871] CPU: 0 PID: 1837 Comm: pradeep Not tainted 3.14.56-udooneo-02003-g19d1e35 #2
    [19303.637965] task: a94ac480 ti: a95a0000 task.ti: a95a0000
    [19303.643374] PC is at memcpy+0x84/0x330
    [19303.647133] LR is at mcc_recv+0x7c/0x164
    [19303.651060] pc : [<801e4d64>]  lr : [<80020444>]  psr: 00070013
    [19303.651060] sp : a95a1b0c  ip : 00000014  fp : 00000000
    [19303.662540] r10: 00000000  r9 : 00000000  r8 : 00000000
    [19303.667767] r7 : 80a9967c  r6 : a95a1b70  r5 : 000003e8  r4 : 00000000
    [19303.674296] r3 : c1279a48  r2 : ffffffec  r1 : c1279a48  r0 : 80a9967c
    [19303.680827] Flags: nzcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
    [19303.688138] Control: 10c53c7d  Table: a8ac004a  DAC: 00000015
    [19303.693885] Process pradeep (pid: 1837, stack limit = 0xa95a0240)
    ...
    [19304.501238] drivers/char/imx_amp/imx_sema4.c -> _imx_sema4_mutex_lock 137 already locked, wait! num 1 val 1.
    ...
    [19658.486395] ttymcc_thread_exit!!
    
     
  4. maleadt

    maleadt New Member

    Joined:
    Feb 15, 2016
    Messages:
    8
    Likes Received:
    0
    Small update: the panic is sketch dependent. I wasn't using the actual "Hello World" sketch (FOTA doesn't error when unable to flash the firmware, ie. when you need to rm /var/opt/m4/m4last.fw), and the panic only happens when running a Firmata-based sketch. Although it seems to be using Arduino's Serial, there must be an incompatibility somewhere else.

    FWIW, I was using the following board definition in Firmata's board.h (might not be fully correct, but I didn't get to test it -- the panic occurs when running the EchoString demo):

    Code:
    // UDOO Neo (M4)
    #elif defined(PSP_CPU_IMX6SX_M4)
    #define TOTAL_ANALOG_PINS  6
    #define TOTAL_PINS  20 // 14 digital + 6 analog
    #define VERSION_BLINK_PIN  13
    #define IS_PIN_DIGITAL(p)  ((p) >= 2 && (p) <= 19)
    #define IS_PIN_ANALOG(p)  ((p) >= 14 && (p) < 14 + TOTAL_ANALOG_PINS)
    #define IS_PIN_PWM(p)  ((p) >= 3 && (p) != 8 && (p) < 11)
    #define IS_PIN_SERVO(p)  (IS_PIN_PWM(p) && (p) - 2 < MAX_SERVOS)
    #define IS_PIN_I2C(p)  ((p) == 18 || (p) == 19)
    #define IS_PIN_SPI(p)  ((p) == SS || (p) == MOSI || (p) == MISO || (p) == SCK)
    #define PIN_TO_DIGITAL(p)  (p)
    #define PIN_TO_ANALOG(p)  ((p) - 14)
    #define PIN_TO_PWM(p)  PIN_TO_DIGITAL(p)
    #define PIN_TO_SERVO(p)  ((p) - 2)

    What are people using to communicate efficiently between the A9 and M4? I didn't feel like rolling my own serial protocol, which is why I looked at Firmata.
     
  5. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Last edited: Apr 12, 2017
  6. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Just tested the same:
    • Edited Firmata board.h as proposed earlier.
    • uploaded Firmata example SimpleDigitalFirmata, it compiled and uploaded fine.
    • Open Arduino IDE Serial Monitor: The Neo crashes instantly. Nothing was sent or received on the /dev/ttyMCC port. The Neo has to be reset and the file /var/opt/m4/m4last.fw has to be removed.
    If I look into the source https://github.com/firmata/arduino is has references to Arduino libraries HardwareSerial.h, string.h and Stream.h
    Anyone any thoughts on this what could crash the Neo by just opening the serial device /dev/ttyMCC?
     
  7. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    Update: I tried to use Arduino Serial1 and hardwire that to UART6 (/dev/ttymxc5). You have to patch Udoobuntu 2 first, then enable UART6 in the Device Tree Editor and reboot.
    In the Firmata sketches you have to edit:

    Code:
    //Firmata.begin(57600);
      Serial0.begin(115200);
      Firmata.begin(Serial0);
      while (!Serial0) {
    I now have (unreadable binary) data coming out /dev/ttymxc5. Still strugling to get contact from A9 with PyFirmata (Python). But at least it is not crashing anymore. Another indication that /dev/ttyMCC is a root cause.
     
    Last edited: May 3, 2017

Share This Page