Wednesday, December 23, 2015

Ethernet driver for mcc/rpmsg status

mccethernet is loading on Ubuntu 15.10.:

ifconfig
eth0      Link encap:Ethernet  HWaddr 00:21:70:5a:c0:7d  
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:722 errors:0 dropped:0 overruns:0 frame:0
          TX packets:722 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:88472 (88.4 KB)  TX bytes:88472 (88.4 KB)

mcc0      Link encap:Ethernet  HWaddr 00:00:00:00:00:01  
          UP BROADCAST RUNNING MULTICAST  MTU:1024  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr 00:c0:a8:c3:56:15  
          inet addr:192.168.9.6  Bcast:192.168.9.255  Mask:255.255.255.0
          inet6 addr: fe80::2c0:a8ff:fec3:5615/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8630 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7939 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:4416731 (4.4 MB)  TX bytes:1681525 (1.6 MB)

Background on driver development for mccethernet, mccmulti, and mcctty:

I start by creating a basic driver that can be loaded by my desktop PC, which is running 15.10 Ubuntu.  This way I can load/debug/ etc faster then recompiling the kernel or loading the Udoo Neo.  Also, the Ubuntu is using 4.x and neo is using a 3.4.x and there are some API differences that have to be accounted for in the mccethernet.c 

For example: in 3.4.x alloc_netdev only needs 3 arguments where alloc_netdev in 4.x needs 4 arguments. 
Linux kernel has some macros to help you out:
    
#if LINUX_VERSION_CODE < KERNEL_VERSION(4,0,0)        
mccethernet_dev = alloc_netdev(sizeof(struct mcc_ethernet_device), "mcc0", mcc_setup);
#else
mccethernet_dev = alloc_netdev(sizeof(struct mcc_ethernet_device), "mcc0", NET_NAME_UNKNOWN, mcc_setup);

#endif 

mccmulti driver was a little harder to since it is using MCC api calls; the first pass was to stub MCC calls.


For the mccethernet it is using basic file operations on m4mcc1 on the mccmulti user interface.  Code can be found here.


Monday, December 21, 2015

Progress on TCP/IP via MCC

Have chosen LwIP as the TCP/IP stack for the M4.  LwIP runs on a number of different processors and it has a rich application stack; HTTP, Auto IP, IPv6, etc.

Created a MQX interface following the porting guide and several examples.  Created a loop back interface and able to create sockets.  Working on a modification to the lwIP select function to allow passing a semaphore and a condition variable.    This allows one thread to wait on TCP/UDP sockets and messages from a queue using the passed in semaphore; this helps with multithreading issues with LwIP.

Tasks pending:
- MCC driver for lwIP; it's a simple thread pending on read MCC function; write will be passed via the TCP/IP thread.  MTU size is 1024; based on the MCC buffer size.  Here is the code:
- Ethernet/MCC driver for Linux: pass packets from MCC to Linux TCP/IP stack
- TTY MCC interface.


The reason for doing this:

  1. Applications on the M4 side need a configuration file or script for startup:
    1. Can use TFTP
      1. Setup a TFTP server on the Linux side, M4 can get or write files
    2. Syslog
      1. Create a syslog forwarder on M4, now message so up in Linux log
    3. One MCC port can transport several different messages to several different apps without any forwarder or mux.  TCP/IP uses port numbers for each app. 

Here is a link to a basic drawing of MCC TCP/IP:


Saturday, December 12, 2015

Udoo.org Neo progress Imx6sx Solo

Completed a Linux kernel driver mccmulti; this driver provides 3 dev interfaces:

  • /dev/m4mcc0
    • This has two mcc ports (1) A9 and (1) M4 The goal is to create another driver a ttyMCC0 to allow terminal apps, minicom, screen etc access to the MCC interface.  i.e command line interface etc.
  • /dev/m4mcc1
    • This is the same as above, but on different mcc ports. 
  • /dev/m4mcc2
    • This is the same as above, but on different mcc ports. 
    • The goal is to create another driver, a ethernet HW driver to use the MCC interface for IP.  The M4 needs a IP stack, might use lwIP, Current NXP does not provide the IP stack for the IMX6sx.
Also, created a user space app using epoll to test the mccmulti kernel driver.  This way, it is possible to create an app, with non-blocking IO and use async-io type of programming.

Once the IP stack is working, then will start porting Baseflight.  Just got my NTSC camera, so need to test that also.