How to use A20 CAN interface with the A20 universal Armbian image for OLinuXino

CAN-Network-Diagram

To use A20 CAN interface you need A20-OLinuXino board and A20-CAN board.

Then you have to install the armbian A20 CAN overlay:

 

$ sudo armbian-add-overlay <path_to_the_dts_file>

 

  • connect A20-CAN to your OLinuXino and reboot.

You can see if CAN is available now:

$ ifconfig -a

   can0     Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 
            NOARP MTU:16 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:10
            RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
            Interrupt:51

 

To use CAN interface you can install can-utils and setup the CAN interface:

$ sudo apt-get install can-utils 
$ ip link set can0 down
$ ip link set can0 type can bitrate 100000 triple-sampling on loopback off
$ ip link set can0 up

 

Now conect A20-CAN to the CAN network two wire interface.

To send a packet over CAN use :

cansend <can_interface> <packet>

 

For instance:

$ cansend can0 5AA#10.10.10

 

To sniff for CAN network messages you can use candump :

$ candump can0

 

Now you can log your car CAN networking messages and interpret them. There is plenty of info on the web about the different CAN messages which are exchanged on car CAN bus.

Working with A20 OLinuXino or SOM GPIOs when using new Armbian based A20 universal Linux image

a20

A20 GPIO ports are 32 bit registers listed in alphabetical order PA, PB, PC, PD, PE, PF, PG, PH, PI.

In Armbian GPIO ports are numbered from 0 to 287 corresponding from PA0 to PI31.

The GPIO number is calculating using this formula:

gpioNumber = (Port Letter - 'A') * 32 + pinNumber

 

For instance GREEN STATUS LED on A20-OLinuXino-LIME2 is connected to port PH2. This will correspond to GPIO number:

('H'-'A' = 7) * 32 + 2 = 226

 

All GPIO operations in shell should be made as super user. First we have to register the gpio in the Linux Kernel with this command:

sudo echo 226 > /sys/class/gpio/export

 

to check if we did registered this gpio successfully we use ls command:

sudo ls /sys/class/gpio

 

If you did everything correctly you will see gpio226 listed.

Then you have to specify what will be this GPIO input or output. This is done with writing “in” or “out” in gpioxx direction directory. In this case we want to drive the STATUS LED so we have to make it output:

sudo echo out > /sys/class/gpio/gpio226/direction

 

Once we set the GPIO as output we can write 1 or 0 to it’s value and this will make GPIO port to supply 3.3V when 1 is written or 0V when 0 is written.

To switch the LED on we have to write 1:

sudo echo 1 > /sys/class/gpio/gpio226/value

 

Yay the green LED is now lighting. If we want to switch it off we have to write 0:

sudo echo 0 > /sys/class/gpio/gpio226/value

 

To read the GPIO state it has to be set as input first with the command:

sudo echo in > /sys/class/gpio/gpioXXX/direction

 

where XXX is GPIO port number calculated as described above. Then to read the GPIO state you use this command:

sudo cat /sys/class/gpio/gpioXXX/value

the result will be 0 if the GPIO voltage is between 0.0-1.0V and 1 if the voltage is between 2.3-3.3V. If the voltage on the GPIO is between 1.0 and 2.3V the attempt to read will return randomly value 0 or 1.

Be careful when playing with the GPIO ports, some of them are wired to important peripherials like LCD, Ethernet, USB, SATA etc and writing bad values may break the functionality or even damage the board. Test your knowledge on GPIOs which are not connected to anything is best approach.

We are prepare now new version of PyA20 Python module which will add access to GPIO, SPI, I2C, Serial resources of A20 directly from Python code to work with the new universal A20 Armbian Linux image.

EDIT 2019-01-25 14:24:

We got question how fast is the access to the GPIOs via shell. Sure it’s not fast and made just for slow processes like switching on and off relays, or polling status of buttons or sensors which do not change often their state. Running this code below:

nano toggle_led_lime2.sh

 

Enter inside the file this code:

#!/bin/bash
# the lime2 led is PH2 - 32*(8-1) + 2 = 226

echo 226 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio226/direction
while [ 1 -eq 1 ]
do
echo 1 > /sys/class/gpio/gpio226/value
echo 0 > /sys/class/gpio/gpio226/value
done

 

Save and exit, then make executable and run

chmod +x toggle_led_lime2.sh
./toggle_led_lime2.sh

 

We can see square wave with oscilloscope on PH2 with frequency between 3 and 4 kHz. i.e. pulses with high state 125-150uS and low state 125-150uS.

Shell is slow, if we write same code in C:

#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>

#define PH2        226    // (32 * 7) + 2
#define GPIO_PATH  "/sys/class/gpio/gpio226/value"

int main() {
    int ret;
    int fd;

    fd = open(GPIO_PATH, O_RDWR);
    if (fd < 0)
        return errno;

    while(1) {
        ret = write(fd, "1", 1);
        ret = write(fd, "0", 1);
    }

    return 0;
}

 

The new code produces square wave with 2.13 us high and low state i.e. approx 235 kHz or about 50 times faster than access via shell.

A20-OLinuXino universal image updated – now supporting our new boards with SPI+eMMC

d6ndarl

We just uploaded new A20-OLinuXino universal image at our FTP.

With this image we add support for the new OLinuXino boards with eMMC+SPI.

Few things need some more attention and will be fixed in new image next week: boot from SPI with rootFS on HDD or USB Flash. The new LCD-15.6 eDP display also doesn’t like the new kernel and drivers, but will be fixed too. These are explained in the ISSUES.txt.

The new image also support our new 5″, 7″ and 10″ capacitive touch displays (not on our web for sale yet as still testing) automatically i.e. plug and play and no need to run display script, each time at boot it recognizes the connected display and configure the drivers.

All other peripherals and devices are tested to work with: A20-OLinuXino-LIME, A20-OLinuXino-LIME2, A20-OLinuXino-MICRO, A20-SOM and A20-SOM204.

A20-OLinuXino-LIME Revision H is now in stock. The OSHW Linux computer now support eMMC and can be produced with industrial grade temperature -40+85C

Ax0-OLinuXino-LIME-1.jpg

A20-OLinuXino-LIME now is at revision H. What is new?

  • We now support eMMC Flash
  • Ethernet PHY is changed from Realtek to Micrel/Microchip as latter can be purchased in both commercial and industrial grade
  • SPI Flash with hardware write protect is supported which allow board to boot from net.
  • Industrial version of LIME is available with T2 Allwinner with all components -40+85C operating temperature
  • EEPROM now contain unique MAC address , serial number and configuration info

We decided to drop the odd shape which was made specially to fit LIME in the Hammond plastic box, instead it range of Metal Boxes is available.

Latest image supports all new feature.

A20-SOM204 and SOM204-EVB preliminary info is uploaded on our web

A20-SOM204-T

SOM204 is SODIMM form factor System-On-Module we are working for a while (actually from so long time ago that SOM204-EVB platform is made in Eagle which we dropped to use officially from quite some time ago).

The SODIMM connector has these signals:

  • Power supply: +5V, GND, LiPobattery, RTC_backup, Stepup-Output, Stepup-enable, USB+5V
  • Interfaces: Gigabit Ethernet, Megabit Ethernet, CAN, SATA, PCIe, USB2.0 HOST x2, USB-OTG, USB3.0 HOST, HSIC, UARTx3, SPIx2, I2Cx2, CSI, microSD, GPIOs with interrupts,
  • Display: HDMI, VGA
  • Audio: SPDIF, Line-in/out, Microphone, Headphone.

You can see complete SOM204 platform signals here.

The idea behind SOM204 is to make Universal interchangeable SOM with different performance and resources.

Our first SOM204 module is with A20 processor, it’s now in production and will be available for purchase next week.

The second SOM204 module is with A64, the third is with RK3328 which we expect to be ready for production around June. Next to follow is AM335X which will be ready by end of the year together with RK3399. The goal is to have 5 different modules by the end of the year.

A20-SOM204 comes with 1GB RAM, optional SPI Flash or eMMC Flash up to 64GB, two native Ethernets (this is the only A20 board with dual native Ethernets) Gigabit and Megabit, SATA and so on. The USB3.0 interface and PICe interfaces are not wired. On top on SOM204 platform LCD and additional GPIOs are exposed on FPC connectors:

A20-SOM204-F

A20-SOM204-B

The A20-SOM204 schematic is here.

A20-SOM204-EVB is evaluatuon board with A20-SOM204SOM204-EVB2

A20-SOM204 software is Armbian with mainline kernel and support for all SOM peripherials.

 

OLinuXino EEPROM content – one step ahead to single Linux image for all A20 boards

LCD10-METAL-FRAME-1

We are struggling for some time now to make one single image which to work on all A20 boards we have.

Our problem is that we have more than 20 different A20 boards/revisions/ etc and every time we have to add or improve something we have to generate and test enormous amount of images.

It’s not so easy task as this image should run on different boards with differnt memory speed etc settings, different ports connections etc.

To achieve one single image which to boot to all A20 boards our first step is to add some content in the EEPROM which all OLinuXino has.

The EEPROM now contain this info: Header, ID, Revision, Serial number, Configuration, Reserved area for future (MAC etc), Checkcum.

The new image we work on now (based on Armbian with mainline kernel) will automatically recognize the board from the EEPROM content and run.

What will happen if no valid EEPROM content is read (i.e. old boards), there is tool which to be used to write EEPROM content based on board revision.

We are going to release this image soon.

 

More than 300 pcs A20-OLinuXino-MICRO work hard 24/7 in Traffic light controllers in Moscow

IMG_20171027_142604

We got nice e-mail from Andrey Taranov Head of RnD of Voice-Link JSC, Moscow, Russia to let us know that for the last 3 years more than 300 traffic light controllers are build with A20-OLinuXino-MICRO and work in the field in Moscow.

“They works hard in tough mode, 24/7 and shows good stability. We found your product well done, stable, and we glad to have partners, as you, and plan to cooperate in the future.”

Their product looks solid and impressive.

Previous Older Entries