Skip to content

Commit

Permalink
Merge pull request #5 from siemens/staging
Browse files Browse the repository at this point in the history
Merge staging to master for V2.1.2
  • Loading branch information
SaschaWeisenberger authored Dec 21, 2016
2 parents 276da25 + 6ebfb9c commit d8990d1
Show file tree
Hide file tree
Showing 23 changed files with 884 additions and 113 deletions.
32 changes: 27 additions & 5 deletions meta-iot2000-bsp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ $ source poky/oe-init-build-env iot2000-build
## Configure:

```diff
--- conf/bblayers.conf.old
+++ conf/bblayers.conf
--- iot2000-build/conf/bblayers.conf.old
+++ iot2000-build/conf/bblayers.conf
@@ -9,4 +9,6 @@
/home/build/poky/meta \
/home/build/poky/meta-poky \
Expand All @@ -73,8 +73,8 @@ $ source poky/oe-init-build-env iot2000-build
```

```diff
--- conf/local.conf.old
+++ conf/local.conf
--- iot2000-build/conf/local.conf.old
+++ iot2000-build/conf/local.conf
@@ -34,7 +34,7 @@
#MACHINE ?= "edgerouter"
#
Expand All @@ -93,7 +93,7 @@ $ bitbake core-image-minimal
```


Booting the Image
Booting the Image from SD card
=================

Under Linux, insert an unused SD card. Assuming the SD card takes device
Expand All @@ -107,3 +107,25 @@ If you want to ssh into the system, you can use the root terminal to
ifconfig the IP address and use that to ssh in. The root password is
empty, so to log in type 'root' for the user name and hit 'Enter' at
the Password prompt and you should be in.


Booting the Image from USB stick
=================

Under Linux, insert an unused USB stick. Assuming the USB stcik takes device
/dev/sda, use dd to copy the image to it. For example:

```shell
$ sudo dd if=tmp/deploy/images/iot2000/core-image-minimal-iot2000.wic of=/dev/sda bs=4M oflag=sync
```

In addition, you have to change the boot config. On the first partition, navigate to the folder loader/entries, open the file boot.conf and change the following:

```diff
--- loader/entries/boot.conf.old
+++ loader/entries/boot.conf
title boot
linux /bzImage
-options LABEL=Boot root=/dev/mmcblk0p2 console=ttyS1,115200n8 reboot=efi,warm rw LABEL=boot debugshell=5
+options LABEL=Boot root=/dev/sda2 console=ttyS1,115200n8 reboot=efi,warm rw LABEL=boot debugshell=5 rootdelay=1
```
2 changes: 2 additions & 0 deletions meta-iot2000-bsp/conf/layer.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ BBFILE_PRIORITY_iot2000-bsp = "6"

IOT2000_MIT_LICENSE = "${LAYERDIR}/COPYING.MIT"
IOT2000_GPLv2_LICENSE = "${LAYERDIR}/COPYING.GPLv2"

PACKAGE_CLASSES = "package_ipk"
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
From 403bfe046b658799a8735cf890da21f8e42280bc Mon Sep 17 00:00:00 2001
From: Frank Ehlis <[email protected]>
Date: Thu, 29 Sep 2016 14:48:52 +0200
Subject: [PATCH] serial: 8250_pci: Add support for accessing red LED via ledfs

The LED-init was moved past pci_default_setup() so that
port.membase is valid when saving it to our private data.

Signed-off-by: Frank Ehlis <[email protected]>
---
drivers/tty/serial/8250/8250_pci.c | 72 +++++++++++++++++++++++++++++++++++++-
1 file changed, 71 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index 34baa78..829e9fc 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -23,6 +23,7 @@
#include <linux/bitops.h>
#include <linux/rational.h>
#include <linux/dmi.h>
+#include <linux/leds.h>

#include <asm/byteorder.h>
#include <asm/io.h>
@@ -1806,6 +1807,12 @@ xr17v35x_has_slave(struct serial_private *priv)

/* IOT2000 MPIOs 8..15 */
#define IOT2000_UARTS_ENABLE 0x03
+#define IOT2000_UART_LED_RED 0x04
+
+#define IOT2000_UART_LEDFS_NAME "mpio_uart_led:red:user"
+static struct iot2000_serial_private {
+ u8 __iomem *membase;
+}iot2000_priv;

static int pci_iot2000_rs485_config(struct uart_port *port,
struct serial_rs485 *rs485)
@@ -1851,11 +1858,47 @@ static int pci_iot2000_rs485_config(struct uart_port *port,
return 0;
}

+static void
+iot2000_brightness_set(struct led_classdev *cdev,
+ enum led_brightness brightness)
+{
+ u8 __iomem *p = iot2000_priv.membase;
+ u8 value;
+
+ if ( iot2000_priv.membase == NULL )
+ return;
+
+ value = readb(p + UART_EXAR_MPIOLVL_15_8);
+ if (brightness == LED_OFF)
+ value &= ~IOT2000_UART_LED_RED;
+ else
+ value |= IOT2000_UART_LED_RED;
+
+ writeb(value, p + UART_EXAR_MPIOLVL_15_8);
+}
+
+static enum led_brightness
+iot2000_brightness_get(struct led_classdev *cdev)
+{
+ u8 __iomem *p = iot2000_priv.membase;
+ u8 value;
+
+ if ( iot2000_priv.membase == NULL )
+ return LED_OFF;
+
+ value = readb(p + UART_EXAR_MPIOLVL_15_8);
+ if (value & IOT2000_UART_LED_RED)
+ return 1;
+
+ return LED_OFF;
+}
+
static int
pci_xr17v35x_setup(struct serial_private *priv,
const struct pciserial_board *board,
struct uart_8250_port *port, int idx)
{
+ int ret;
bool is_iot2000;
u8 __iomem *p;

@@ -1901,9 +1944,36 @@ pci_xr17v35x_setup(struct serial_private *priv,
writeb(UART_FCTR_EXAR_TRGD, p + UART_EXAR_FCTR);
writeb(128, p + UART_EXAR_TXTRG);
writeb(128, p + UART_EXAR_RXTRG);
+
iounmap(p);

- return pci_default_setup(priv, board, port, idx);
+ ret = pci_default_setup(priv, board, port, idx);
+
+ /* on IOT2000, register the red LED attached to the MPIO */
+ if (is_iot2000 && (ret == 0) && (idx == 0)) {
+ int err;
+ struct led_classdev *led;
+ char *name;
+ size_t namesz = strlen(IOT2000_UART_LEDFS_NAME) + 1;
+
+ led = kzalloc(sizeof(*led) + namesz, GFP_KERNEL);
+ if (led)
+ {
+ name = (void*)&led[1];
+ snprintf(name, namesz, "%s", IOT2000_UART_LEDFS_NAME);
+ iot2000_priv.membase = port->port.membase;
+ led->name = name;
+ led->max_brightness = 1;
+ led->brightness_set = iot2000_brightness_set;
+ led->brightness_get = iot2000_brightness_get;
+ led->default_trigger = name;
+ err = led_classdev_register((struct device *)
+ port->port.dev, led);
+ printk("IOT2000: Registered Led with err=%d\n", err);
+ }
+ }
+
+ return ret;
}

#define PCI_DEVICE_ID_COMMTECH_4222PCI335 0x0004
--
2.1.4

3 changes: 3 additions & 0 deletions meta-iot2000-bsp/recipes-kernel/linux/files/iot2000.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ CONFIG_IE6XX_WDT=y

CONFIG_IP_NF_NAT=y

CONFIG_R8712U=y
CONFIG_RTL8XXXU=y
CONFIG_RTL8192CU=y
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ SRC_URI += " \
file://0004-serial-8250_pci-Fix-EXAR-feature-control-register-co.patch \
file://0005-serial-8250_pci-Add-support-for-IOT2000-platform.patch \
file://0006-x86-efi-Add-capsule-update-driver-for-Intel-Quark.patch \
file://0007-serial-8250_pci-Add-support-for-accessing-red-LED-vi.patch \
file://iot2000.cfg"

LINUX_VERSION_iot2000 = "${LINUX_VERSION_INTEL_COMMON}"
Expand Down
50 changes: 50 additions & 0 deletions meta-iot2000-bsp/recipes-tools/setledcolor/files/setledcolor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/python


import mraa
import sys
import os

def redled(state):
redLedFile = "/sys/class/leds/mpio_uart_led:red:user/brightness"
if(not os.path.isfile(redledFile)):
print("Red LED not available")
return
file = open(redLedFile,'w')
if(1==state):
file.write("1")
else:
file.write("0")
file.close()

def greenled(state):
ledpin = mraa.Gpio(13)
ledpin.dir(mraa.DIR_OUT)
if(1==state):
ledpin.write(1)
else:
ledpin.write(0)

if(len(sys.argv)<2):
print("Usage: " + sys.argv[0] + " color")
print("color:")
print("0\t\tout")
print("1\t\tgreen")
print("2\t\tred")
print("3\t\torange")
sys.exit()

x = int(sys.argv[1])

if(x%2 == 0):
greenled(0)
else:
greenled(1)

if(x/2 == 0):
redled(0)
else:
redled(1)



17 changes: 17 additions & 0 deletions meta-iot2000-bsp/recipes-tools/setledcolor/setledcolor_0.1.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
DESCRIPTION = "This installs a small python script to handle the led color for the SIMATIC IOT2040"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${IOT2000_MIT_LICENSE};md5=838c366f69b72c5df05c96dff79b35f2"

SRC_URI = "file://setledcolor.py"

S = "${WORKDIR}"

FILES_${PN} += "${sysconfdir}/setledcolor/setledcolor.py \
${bindir}/setledcolor"

do_install() {
install -d ${D}${sysconfdir}/setledcolor
install -d ${D}${bindir}
install -m 755 ${WORKDIR}/setledcolor.py ${D}${sysconfdir}/setledcolor/
ln -sf /etc/setledcolor/setledcolor.py ${D}${bindir}/setledcolor
}
24 changes: 22 additions & 2 deletions meta-iot2000-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ environment.
## Configure:

```diff
--- conf/bblayers.conf.old
+++ conf/bblayers.conf
--- iot2000-build/conf/bblayers.conf.old
+++ iot2000-build/conf/bblayers.conf
@@ -9,4 +9,10 @@
/home/build/poky/meta \
/home/build/poky/meta-poky \
Expand All @@ -79,6 +79,26 @@ environment.
This replaces the changes to conf/bblayers.conf documented in
()[../meta-iot2000-bsp/README.md]. The changes to conf/local.conf are the same.

## The opkg package manager:

If you want to use the opkg package manager, we highly recommend changing the following line in the local.conf:

```diff
--- iot2000-build/conf/local.conf.old
+++ iot2000-build/conf/local.conf
@@ -120,7 +120,7 @@
# - 'package_rpm' for rpm style packages
# E.g.: PACKAGE_CLASSES ?= "package_rpm package_deb package_ipk"
# We default to rpm:
-PACKAGE_CLASSES ?= "package_rpm"
+PACKAGE_CLASSES ?= "package_ipk"

#
# SDK target architecture
```

This configures yocto to use the ipk format to build the image itself, so opkg knows which packages are already installed.

## Create Example Image:

```shell
Expand Down
18 changes: 18 additions & 0 deletions meta-iot2000-example/recipes-core/firmware/firmware-nonfree.bb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
DESCRIPTION = "includes the firmware files for broadcom and realtek wifi devices"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${IOT2000_MIT_LICENSE};md5=838c366f69b72c5df05c96dff79b35f2"

SRC_URI = "git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git"
SRCREV = "a179db97914da5e650c21ba8f9b0bae04a0f8a41"
S = "${WORKDIR}"
INSTDIR = "/lib/firmware/"

FILES_${PN} = "${INSTDIR}*"

do_install() {
install -d ${D}${INSTDIR}
install -d ${D}${INSTDIR}brcm/
install -d ${D}${INSTDIR}rtlwifi/
cp -R ${S}/git/brcm/* ${D}${INSTDIR}brcm/
cp -R ${S}/git/rtlwifi/* ${D}${INSTDIR}rtlwifi/
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,22 @@ IMAGE_FEATURES += " tools-sdk"
IMAGE_INSTALL_append = " switchmode"
IMAGE_INSTALL_append = " opkg"
IMAGE_INSTALL_append = " imageversionfile"
IMAGE_INSTALL_append = " modules-load-entries"
IMAGE_INSTALL_append = " dmidecode"
IMAGE_INSTALL_append = " openssh"
IMAGE_INSTALL_append = " screen minicom"
IMAGE_INSTALL_append = " mraa upm"
IMAGE_INSTALL_append = " parted e2fsprogs dosfstools"
IMAGE_INSTALL_append = " nodejs"
IMAGE_INSTALL_append = " nodejs nodejs-npm"
IMAGE_INSTALL_append = " node-red node-red-dashboard node-mraa node-red-node-intel-gpio"
IMAGE_INSTALL_append = " curl"
IMAGE_INSTALL_append = " pciutils"
IMAGE_INSTALL_append = " iptables"
IMAGE_INSTALL_append = " cmake"
IMAGE_INSTALL_append = " nano"
IMAGE_INSTALL_append = " iw wpa-supplicant"
IMAGE_INSTALL_append = " nano tree"
IMAGE_INSTALL_append = " iw wpa-supplicant wireless-tools"
IMAGE_INSTALL_append = " galileo-target"
IMAGE_INSTALL_append = " firmware-nonfree"
IMAGE_INSTALL_append = " iot2000setup"
IMAGE_INSTALL_append = " sqlite3"
IMAGE_INSTALL_append = " i2c-tools"
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

SRC_URI_append = " file://arp.cfg"
SRC_URI_append = " file://lsusb.cfg"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_LSUSB=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#This recipe adds "resize2fs" as dependencie so it will be installed with the
#default package

RDEPENDS_e2fsprogs += " e2fsprogs-resize2fs"
Loading

0 comments on commit d8990d1

Please sign in to comment.