Skip to contentSkip to conversation

LEGO MINDSTORMS EV3 Updates

PATCH New David Lechner 2 participants 9 messages Nov 2, 2016

lore
Share & tools
lore
#0 lore raw

v2 cover LEGO MINDSTORMS EV3 Updates

v2 changes:
* Specified specific U-Boot version
* Using config fragment for linux kernel config changes
* Added dependency host-dosfstool and host-mtools
* Renamed ev3dev package and kernel extension to ev3dev-linux-drivers
* Removed dest variable to simplify kernel extension makefile
* Fixed "from from" typo

David Lechner (4):
configs/lego_ev3: add U-Boot support board/lego/ev3: Create images using genimage
linux: add ev3dev extension
board/lego/ev3: Use ev3dev linux ext for ev3dev drivers

 board/lego/ev3/genimage.cfg                        | 57 +++++++++++++++
 board/lego/ev3/linux.fragment                      |  7 ++
 .../0001-Create-empty-drivers-lego-Kconfig.patch   | 24 -------
 board/lego/ev3/post-image.sh                       | 14 ++++
 board/lego/ev3/readme.txt                          | 84 ++++++----------------
 configs/lego_ev3_defconfig                         | 21 ++++--
 linux/Config.ext.in                                | 10 +++
 linux/linux-ext-ev3dev-linux-drivers.mk            | 12 ++++
 package/Config.in                                  |  1 +
 package/ev3dev-linux-drivers/Config.in             | 12 ++++
 .../ev3dev-linux-drivers/ev3dev-linux-drivers.mk   | 11 +++
 .../ev3dev-linux-drivers/lego-linux-drivers.hash   |  2 +
 support/scripts/pkg-stats                          |  1 +
 13 files changed, 164 insertions(+), 92 deletions(-)
 create mode 100644 board/lego/ev3/genimage.cfg
 create mode 100644 board/lego/ev3/linux.fragment
 delete mode 100644 board/lego/ev3/patches/linux/0001-Create-empty-drivers-lego-Kconfig.patch
 create mode 100755 board/lego/ev3/post-image.sh
 create mode 100644 linux/linux-ext-ev3dev-linux-drivers.mk
 create mode 100644 package/ev3dev-linux-drivers/Config.in
 create mode 100644 package/ev3dev-linux-drivers/ev3dev-linux-drivers.mk
 create mode 100644 package/ev3dev-linux-drivers/lego-linux-drivers.hash
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/4 configs/lego_ev3: add U-Boot support

This adds U-Boot configuration for LEGO MINDSTORMS EV3. U-Boot has had support for LEGO MINDSTORMS EV3 since v2016.05.

---
 configs/lego_ev3_defconfig | 7 +++++++
 1 file changed, 7 insertions(+)
configs/lego_ev3_defconfig +7 -0
index 1ddc4f9..1521fa7 100644
@@ -24,3 +24,10 @@ BR2_LINUX_KERNEL_UIMAGE=y
 BR2_TARGET_ROOTFS_EXT2=y
 BR2_TARGET_ROOTFS_EXT2_3=y
 # BR2_TARGET_ROOTFS_TAR is not set
+
+# U-Boot
+BR2_TARGET_UBOOT=y
+BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
+BR2_TARGET_UBOOT_CUSTOM_VERSION=y
+BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2016.09.01"
+BR2_TARGET_UBOOT_BOARD_DEFCONFIG="legoev3"
Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 1/4 configs/lego_ev3: add U-Boot support

Hello,

Quoted 7 lines · David Lechner

This adds U-Boot configuration for LEGO MINDSTORMS EV3. U-Boot has had support for LEGO MINDSTORMS EV3 since v2016.05.

---
 configs/lego_ev3_defconfig | 7 +++++++
 1 file changed, 7 insertions(+)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#3 lore raw

PATCH v2 2/4 board/lego/ev3: Create images using genimage

In reply to David Lechner

This adds a script to create SD card and flash images for LEGO MINDSTORMS EV3 using the genimage tool.

The default kernel config had to be modifed to add support for squashfs and to add a ram disk.

---
 board/lego/ev3/genimage.cfg   | 57 ++++++++++++++++++++++++++++++
 board/lego/ev3/linux.fragment |  7 ++++
 board/lego/ev3/post-image.sh  | 14 ++++++++
 board/lego/ev3/readme.txt     | 80 ++++++++++---------------------------------
 configs/lego_ev3_defconfig    | 10 +++++-
 5 files changed, 105 insertions(+), 63 deletions(-)
 create mode 100644 board/lego/ev3/genimage.cfg
 create mode 100644 board/lego/ev3/linux.fragment
 create mode 100755 board/lego/ev3/post-image.sh
board/lego/ev3/genimage.cfg new file +57 -0
new file mode 100644
index 0000000..6b8546c
@@ -0,0 +1,57 @@
+# LEGO MINDSTORMS EV3 can boot from a 16MB flash or from a microSD card.
+# The U-Boot bootloader from the flash is always used, even when booting
+# from a microSD card.
+
+# The Flash image
+
+flash nor-16M-256 {
+	pebsize = 4096
+	numpebs = 4096
+	minimum-io-unit-size = 256
+}
+
+image flash.bin {
+	flash {
+	}
+	flashtype = "nor-16M-256"
+	partition uboot {
+		image = "u-boot.bin"
+		size = 320K
+	}
+	partition uimage {
+		image = "uImage"
+		size = 3M
+		offset = 0x50000
+	}
+	partition rootfs {
+		image = "rootfs.squashfs"
+		size = 9600K
+		offset = 0x350000
+	}
+}
+
+# The SD card image
+
+image boot.vfat {
+	vfat {
+		files = {
+			"uImage"
+		}
+	}
+	size = 16M
+}
+
+image sdcard.img {
+	hdimage {
+	}
+	partition boot {
+		partition-type = 0xC
+		bootable = "true"
+		image = "boot.vfat"
+		offset = 4M
+	}
+	partition rootfs {
+		partition-type = 0x83
+		image = "rootfs.ext2"
+	}
+}
board/lego/ev3/linux.fragment new file +7 -0
new file mode 100644
index 0000000..5593636
@@ -0,0 +1,7 @@
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=1
+CONFIG_BLK_DEV_RAM_SIZE=32768
+CONFIG_SQUASHFS=y
+CONFIG_SQUASHFS_LZ4=y
+CONFIG_SQUASHFS_LZO=y
+CONFIG_SQUASHFS_XZ=y
board/lego/ev3/post-image.sh new file +14 -0
new file mode 100755
index 0000000..81626dc
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+BOARD_DIR="$(dirname $0)"
+GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg"
+GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
+
+rm -rf "${GENIMAGE_TMP}"
+
+genimage \
+  --rootpath "${TARGET_DIR}" \
+  --tmppath "${GENIMAGE_TMP}" \
+  --inputpath "${BINARIES_DIR}" \
+  --outputpath "${BINARIES_DIR}" \
+  --config "${GENIMAGE_CFG}"
board/lego/ev3/readme.txt +18 -62

101 lines not on this page · raw message

configs/lego_ev3_defconfig +9 -1
index 1521fa7..ea76d59 100644
@@ -8,7 +8,7 @@ BR2_GLOBAL_PATCH_DIR="board/lego/ev3/patches"
 # system
 BR2_TARGET_GENERIC_GETTY=y
 BR2_TARGET_GENERIC_GETTY_PORT="ttyS1"
-
+BR2_ROOTFS_POST_IMAGE_SCRIPT="board/lego/ev3/post-image.sh"
 # Linux headers same as kernel, a 4.4 series
 BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_4=y
 
@@ -18,11 +18,14 @@ BR2_LINUX_KERNEL_CUSTOM_GIT=y
 BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/ev3dev/ev3dev-kernel.git"
 BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="v4.4.19-15-ev3dev-ev3_1"
 BR2_LINUX_KERNEL_DEFCONFIG="ev3dev"
+BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="board/lego/ev3/linux.fragment"
 BR2_LINUX_KERNEL_UIMAGE=y
 
 # filesystem
 BR2_TARGET_ROOTFS_EXT2=y
 BR2_TARGET_ROOTFS_EXT2_3=y
+BR2_TARGET_ROOTFS_SQUASHFS=y
+BR2_TARGET_ROOTFS_SQUASHFS4_XZ=y
 # BR2_TARGET_ROOTFS_TAR is not set
 
 # U-Boot
@@ -31,3 +34,8 @@ BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y
 BR2_TARGET_UBOOT_CUSTOM_VERSION=y
 BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2016.09.01"
 BR2_TARGET_UBOOT_BOARD_DEFCONFIG="legoev3"
+
+# host
+BR2_PACKAGE_HOST_DOSFSTOOLS=y
+BR2_PACKAGE_HOST_GENIMAGE=y
+BR2_PACKAGE_HOST_MTOOLS=y
Signature · 1 line
2.7.4
#4 lore raw

PATCH v2 2/4 board/lego/ev3: Create images using genimage

Hello,

Quoted 7 lines · David Lechner

This adds a script to create SD card and flash images for LEGO MINDSTORMS EV3 using the genimage tool.

The default kernel config had to be modifed to add support for squashfs and to add a ram disk.

Quoted 10 lines
---
 board/lego/ev3/genimage.cfg   | 57 ++++++++++++++++++++++++++++++
 board/lego/ev3/linux.fragment |  7 ++++
 board/lego/ev3/post-image.sh  | 14 ++++++++
 board/lego/ev3/readme.txt     | 80 ++++++++++---------------------------------
 configs/lego_ev3_defconfig    | 10 +++++-
 5 files changed, 105 insertions(+), 63 deletions(-)
 create mode 100644 board/lego/ev3/genimage.cfg
 create mode 100644 board/lego/ev3/linux.fragment
 create mode 100755 board/lego/ev3/post-image.sh

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#5 lore raw

PATCH v2 3/4 linux: add ev3dev extension

In reply to David Lechner

This adds an ev3dev Linux drivers extension that provides Linux kernel drivers for LEGO MINDSTORMS EV3 from the ev3dev project.

---
 linux/Config.ext.in                                  | 10 ++++++++++
 linux/linux-ext-ev3dev-linux-drivers.mk              | 12 ++++++++++++
 package/Config.in                                    |  1 +
 package/ev3dev-linux-drivers/Config.in               | 12 ++++++++++++
 package/ev3dev-linux-drivers/ev3dev-linux-drivers.mk | 11 +++++++++++
 package/ev3dev-linux-drivers/lego-linux-drivers.hash |  2 ++
 support/scripts/pkg-stats                            |  1 +
 7 files changed, 49 insertions(+)
 create mode 100644 linux/linux-ext-ev3dev-linux-drivers.mk
 create mode 100644 package/ev3dev-linux-drivers/Config.in
 create mode 100644 package/ev3dev-linux-drivers/ev3dev-linux-drivers.mk
 create mode 100644 package/ev3dev-linux-drivers/lego-linux-drivers.hash
linux/Config.ext.in +10 -0
index 5d5e7ef..011dffb 100644
@@ -46,6 +46,16 @@ config BR2_LINUX_KERNEL_EXT_RTAI
 	  RTAI Kernel part.
 
 #-------------------------------------------------------------------------------
+# ev3dev Linux drivers
+config BR2_LINUX_KERNEL_EXT_EV3DEV_LINUX_DRIVERS
+	bool "ev3dev Linux drivers"
+	select BR2_PACKAGE_EV3DEV_LINUX_DRIVERS
+	help
+	  Linux drivers for LEGO MINDSTORMS EV3 from the ev3dev project.
+
+	  https://github.com/ev3dev/lego-linux-drivers
+
+#-------------------------------------------------------------------------------
 # fbtft
 config BR2_LINUX_KERNEL_EXT_FBTFT
 	bool "FB TFT drivers"
linux/linux-ext-ev3dev-linux-drivers.mk new file +12 -0
new file mode 100644
index 0000000..f5fec51
@@ -0,0 +1,12 @@
+################################################################################
+# Linux ev3dev extensions
+#
+# Patch the linux kernel with ev3dev extension
+################################################################################
+
+LINUX_EXTENSIONS += ev3dev-linux-drivers
+
+define EV3DEV_LINUX_DRIVERS_PREPARE_KERNEL
+	mkdir -p $(LINUX_DIR)/drivers/lego; \
+	cp -dpfr $(EV3DEV_LINUX_DRIVERS_DIR)/* $(LINUX_DIR)/drivers/lego/
+endef
package/Config.in +1 -0
index 0f6260b..9ed296f 100644
@@ -369,6 +369,7 @@ endmenu
 	source "package/edid-decode/Config.in"
 	source "package/eeprog/Config.in"
 	source "package/eudev/Config.in"
+	source "package/ev3dev-linux-drivers/Config.in"
 	source "package/evemu/Config.in"
 	source "package/evtest/Config.in"
 	source "package/fan-ctrl/Config.in"
package/ev3dev-linux-drivers/Config.in new file +12 -0
new file mode 100644
index 0000000..9be2f28
@@ -0,0 +1,12 @@
+# Prompt-less option, because this package is not doing anything except
+# downloading the ev3dev driver sources. The real work is done by a Linux
+# extension.
+config BR2_PACKAGE_EV3DEV_LINUX_DRIVERS
+	bool
+	depends on BR2_LINUX_KERNEL
+	help
+	  Linux drivers for LEGO MINDSTORMS EV3
+
+	  This is only the download helper for the kernel patch.
+
+	  https://github.com/ev3dev/lego-linux-drivers
package/ev3dev-linux-drivers/ev3dev-linux-drivers.mk new file +11 -0
new file mode 100644
index 0000000..55e26f0
@@ -0,0 +1,11 @@
+################################################################################
+#
+# ev3dev Linux drivers
+#
+################################################################################
+
+EV3DEV_LINUX_DRIVERS_VERSION = 0e551eb25ae8600c1f178814781bfb42dc835496
+EV3DEV_LINUX_DRIVERS_SITE = $(call github,ev3dev,lego-linux-drivers,$(EV3DEV_LINUX_DRIVERS_VERSION))
+EV3DEV_LINUX_DRIVERS_LICENSE = GPLv2
+
+$(eval $(generic-package))
package/ev3dev-linux-drivers/lego-linux-drivers.hash new file +2 -0
new file mode 100644
index 0000000..cc48f65
@@ -0,0 +1,2 @@
+# locally computed
+sha256  9d2740b348c8d43e7e15fedc4cec99bf351a3a2ba8691f2a07c439a9c034bc04  lego-linux-drivers-0e551eb25ae8600c1f178814781bfb42dc835496.tar.gz
support/scripts/pkg-stats +1 -0
index cc3bef4..421fa5c 100755
@@ -94,6 +94,7 @@ for i in $(find boot/ linux/ package/ -name '*.mk' | sort) ; do
 
     if test \
 	$i = "boot/common.mk" -o \
+	$i = "linux/linux-ext-ev3dev-linux-drivers.mk" -o \
 	$i = "linux/linux-ext-fbtft.mk" -o \
 	$i = "linux/linux-ext-xenomai.mk" -o \
 	$i = "linux/linux-ext-rtai.mk" -o \
Signature · 1 line
2.7.4
#6 lore raw

PATCH v2 3/4 linux: add ev3dev extension

Hello,

Quoted 4 lines · David Lechner

This adds an ev3dev Linux drivers extension that provides Linux kernel drivers for LEGO MINDSTORMS EV3 from the ev3dev project.

I've applied, with one minor change, see below.

linux/linux-ext-ev3dev-linux-drivers.mk line 10

Quoted 2 lines
linux/linux-ext-ev3dev-linux-drivers.mk new file +2 -0
+define EV3DEV_LINUX_DRIVERS_PREPARE_KERNEL
+	mkdir -p $(LINUX_DIR)/drivers/lego; \

The ; \ was useless, those two commands can be separate.

linux/linux-ext-ev3dev-linux-drivers.mk line 11

Quoted 1 line
linux/linux-ext-ev3dev-linux-drivers.mk new file +1 -0
+	cp -dpfr $(EV3DEV_LINUX_DRIVERS_DIR)/* $(LINUX_DIR)/drivers/lego/

The rest is applied as-is.

Could you submit a patch to the DEVELOPERS file that adds you as a developer for the ev3dev package, the linux extension, and the board?

Something along those lines:

N: David Lechner <[email protected]>
F: board/lego/ev3/
F: configs/lego_ev3_defconfig
F: package/ev3dev-linux-drivers/
F: linux/linux-ext-ev3dev-linux-drivers.mk

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#7 lore raw

PATCH v2 4/4 board/lego/ev3: Use ev3dev linux ext for ev3dev drivers

In reply to David Lechner

This uses the ev3dev linux extension to compile the ev3dev drivers for LEGO MINDSTORMS EV3.

---
 .../0001-Create-empty-drivers-lego-Kconfig.patch   | 24 ----------------------
 board/lego/ev3/readme.txt                          |  4 ++--
 configs/lego_ev3_defconfig                         |  4 +---
 3 files changed, 3 insertions(+), 29 deletions(-)
 delete mode 100644 board/lego/ev3/patches/linux/0001-Create-empty-drivers-lego-Kconfig.patch
board/lego/ev3/patches/linux/0001-Create-empty-drivers-lego-Kconfig.patch deleted +0 -24
deleted file mode 100644
index 614d53d..0000000
@@ -1,24 +0,0 @@
-From 72c5727488f10160abfadcc77dd9763c4408b5e9 Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Vincent=20Stehl=C3=A9?= <[email protected]>
-Date: Sat, 15 Oct 2016 16:23:31 +0200
-Subject: [PATCH] Create empty drivers/lego/Kconfig
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Signed-off-by: Vincent Stehl? <[email protected]>
----
- drivers/lego/Kconfig | 1 +
- 1 file changed, 1 insertion(+)
- create mode 100644 drivers/lego/Kconfig
-
-diff --git a/drivers/lego/Kconfig b/drivers/lego/Kconfig
-new file mode 100644
-index 0000000..d7cbf4f
---- /dev/null
-+++ b/drivers/lego/Kconfig
-@@ -0,0 +1 @@
-+# Empty Kconfig just to make source from drivers/Kconfig succeed.
--- 
-2.9.3
-
board/lego/ev3/readme.txt +2 -2
index c075af5..c40907c 100644
@@ -4,8 +4,7 @@ Intro
 =====
 
 This is the buildroot basic board support for the Lego Mindstorms EV3
-programmable brick. No support for sensors and drivers is provided for the
-moment.
+programmable brick.
 
 The Lego Mindstorms EV3 brick comprises a Texas Instruments AM1808 SoC, with
 an ARM 926EJ-S main processor running at 300 MHz.
@@ -17,6 +16,7 @@ See:
 The buildroot configuration uses the Linux kernel of the ev3dev project.
 See:
 - https://github.com/ev3dev/ev3-kernel/
+- https://github.com/ev3dev/lego-linux-drivers/
 - http://www.ev3dev.org/
 
 How it works
configs/lego_ev3_defconfig +1 -3
index ea76d59..543a227 100644
@@ -2,9 +2,6 @@
 BR2_arm=y
 BR2_arm926t=y
 
-# patches
-BR2_GLOBAL_PATCH_DIR="board/lego/ev3/patches"
-
 # system
 BR2_TARGET_GENERIC_GETTY=y
 BR2_TARGET_GENERIC_GETTY_PORT="ttyS1"
@@ -20,6 +17,7 @@ BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="v4.4.19-15-ev3dev-ev3_1"
 BR2_LINUX_KERNEL_DEFCONFIG="ev3dev"
 BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="board/lego/ev3/linux.fragment"
 BR2_LINUX_KERNEL_UIMAGE=y
+BR2_LINUX_KERNEL_EXT_EV3DEV_LINUX_DRIVERS=y
 
 # filesystem
 BR2_TARGET_ROOTFS_EXT2=y
Signature · 1 line
2.7.4
#8 lore raw

PATCH v2 4/4 board/lego/ev3: Use ev3dev linux ext for ev3dev drivers

Hello,

Quoted 10 lines · David Lechner

This uses the ev3dev linux extension to compile the ev3dev drivers for LEGO MINDSTORMS EV3.

---
 .../0001-Create-empty-drivers-lego-Kconfig.patch   | 24 ----------------------
 board/lego/ev3/readme.txt                          |  4 ++--
 configs/lego_ev3_defconfig                         |  4 +---
 3 files changed, 3 insertions(+), 29 deletions(-)
 delete mode 100644 board/lego/ev3/patches/linux/0001-Create-empty-drivers-lego-Kconfig.patch

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com