[Armadeus-commitlog] armadeus branch, buildroot-update, updated. armadeus-6.0-136-gce9622b
Brought to you by:
sszy
|
From: Julien B a. A. <ar...@us...> - 2016-10-10 13:10:02
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "armadeus".
The branch, buildroot-update has been updated
via ce9622b9ebc113ac6d8734754ef243bf96c05f70 (commit)
via e48e7de35ccd7111a4c7e3ead23f08eed8a3aded (commit)
via 69741676613080447ae0b7aa356b9ec6d0358eda (commit)
via faddf8dc2b4a5453c00caa13dcc706e656385ede (commit)
from db53ae09f6da3f0c062c57d9a25bf8f15fda412c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ce9622b9ebc113ac6d8734754ef243bf96c05f70
Author: Julien BOIBESSOT <jul...@ar...>
Date: Mon Oct 10 15:03:38 2016 +0200
[BUILDROOT] Rename opos6ulfailsafe_defconfig to opos6ul_recovery_defconfig
commit e48e7de35ccd7111a4c7e3ead23f08eed8a3aded
Author: Julien BOIBESSOT <jul...@ar...>
Date: Thu Oct 6 16:33:39 2016 +0200
[ASDEVICES] Add drivers for BMP180 (pressure) & HMC5883L (accelerometer) I2C sensors
commit 69741676613080447ae0b7aa356b9ec6d0358eda
Author: Julien BOIBESSOT <jul...@ar...>
Date: Wed Sep 28 19:05:07 2016 +0200
[BUILDROOT] post_build.sh: remove unneeded brcm firmwares on OPOS6UL
commit faddf8dc2b4a5453c00caa13dcc706e656385ede
Author: Julien BOIBESSOT <jul...@ar...>
Date: Wed Sep 28 19:03:55 2016 +0200
[BUILDROOT] post_image_creation.sh: no need for boot.ext4 on OPOS6UL
-----------------------------------------------------------------------
Summary of changes:
...ilsafe_defconfig => opos6ul_recovery_defconfig} | 0
.../target/device/armadeus/rootfs/post_build.sh | 10 ++
.../device/armadeus/rootfs/post_image_creation.sh | 5 +-
.../packages/as_devices/python/AsDevices/bmp180.py | 159 ++++++++++++++++++++
.../as_devices/python/AsDevices/hmc5883l.py | 86 +++++++++++
5 files changed, 257 insertions(+), 3 deletions(-)
rename buildroot/configs/{opos6ulfailsafe_defconfig => opos6ul_recovery_defconfig} (100%)
create mode 100644 target/packages/as_devices/python/AsDevices/bmp180.py
create mode 100644 target/packages/as_devices/python/AsDevices/hmc5883l.py
diff --git a/buildroot/configs/opos6ulfailsafe_defconfig b/buildroot/configs/opos6ul_recovery_defconfig
similarity index 100%
rename from buildroot/configs/opos6ulfailsafe_defconfig
rename to buildroot/configs/opos6ul_recovery_defconfig
diff --git a/buildroot/target/device/armadeus/rootfs/post_build.sh b/buildroot/target/device/armadeus/rootfs/post_build.sh
index 3b06084..21c1f6a 100755
--- a/buildroot/target/device/armadeus/rootfs/post_build.sh
+++ b/buildroot/target/device/armadeus/rootfs/post_build.sh
@@ -35,4 +35,14 @@ if [ "$3" != "imx6" ]; then
rm -rf $1/etc/init.d/S30wifi
fi
+# Remove unneeded firmware on OPOS6UL:
+if [ "$3" == "imx6ul" ]; then
+ UNNEEDED_FIRM=`ls -ad $1/lib/firmware/brcm/* | grep -v brcmfmac43430`
+ for firmware in $UNNEEDED_FIRM; do
+ if [ -f "$firmware" ]; then
+ rm -rf "$firmware"
+ fi
+ done
+fi
+
exit 0
diff --git a/buildroot/target/device/armadeus/rootfs/post_image_creation.sh b/buildroot/target/device/armadeus/rootfs/post_image_creation.sh
index a477a99..f89a763 100755
--- a/buildroot/target/device/armadeus/rootfs/post_image_creation.sh
+++ b/buildroot/target/device/armadeus/rootfs/post_image_creation.sh
@@ -40,7 +40,6 @@ if [ "$2" != "" ]; then
# APF6
symlink_image $1 SPL $2-u-boot.spl
symlink_image $1 u-boot.img $2-u-boot.img
-
else
# Old BR compat
BOARD_NAME=`grep 'BR2_BOARD_NAME=' $BUILDROOT_CONFIG | cut -d = -f 2 | sed s/\"//g`
@@ -49,8 +48,8 @@ else
fi
fi
-# if target uses ext4 for rootfs,
-if [ -f "$1/rootfs.ext4" ]; then
+# if target uses ext4 for rootfs and is not an opos6ul,
+if [ -f "$1/rootfs.ext4" ] && [ "$3" != "imx6ul" ]; then
# generate also boot.ext4:
mke2img -d $1/../target/boot/ -G 4 -R 1 -l BOOT -b 49152 -o $1/boot.ext4
symlink_image $1 boot.ext4 $2-boot.ext4
diff --git a/target/packages/as_devices/python/AsDevices/bmp180.py b/target/packages/as_devices/python/AsDevices/bmp180.py
new file mode 100644
index 0000000..7828095
--- /dev/null
+++ b/target/packages/as_devices/python/AsDevices/bmp180.py
@@ -0,0 +1,159 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# License: GNU LESSER GENERAL PUBLIC LICENSE, see COPYING.
+#
+
+__doc__ = "This class drives BMP180 digital pressure sensor"
+__version__ = "0.1.0"
+__versionTime__ = "06/10/2016"
+__author__ = "Julien Boibessot <jul...@ar...>"
+
+import smbus
+import time
+
+BMP_I2C_ADDR = 0x77
+
+class BMP180(object):
+ def __init__(self, bus_id, address):
+ self._bus = smbus.SMBus(bus_id)
+ if address is not None:
+ self._address = address
+ else:
+ self._address = BMP_I2C_ADDR
+ self._get_id()
+ self._load_calibration_coeffs()
+ self.display_calibration_coeffs()
+
+ def _get_id(self):
+ id = self._bus.read_byte_data(self._address, 0xd0)
+ if id != 0x55:
+ print "No valid BMP180 ID found ! (0x%02x != 0x55)" % id
+ return id
+
+ def _be_conv(self, le):
+ """little endian -> big endian"""
+ be = ((le << 8) & 0xFF00) + (le >> 8)
+ return be
+
+ def _get_unsigned_calib_coeff(self, reg_addr):
+ result = self._bus.read_word_data(self._address, reg_addr)
+ result = self._be_conv(result)
+ return result
+
+ def _get_signed_calib_coeff(self, reg_addr):
+ result = self._get_unsigned_calib_coeff(reg_addr)
+ if result > 32767:
+ result -= 65536
+ return result
+
+ def _load_calibration_coeffs(self):
+ self._AC1 = self._get_signed_calib_coeff(0xaa)
+ self._AC2 = self._get_signed_calib_coeff(0xac)
+ self._AC3 = self._get_signed_calib_coeff(0xae)
+ self._AC4 = self._get_unsigned_calib_coeff(0xb0)
+ self._AC5 = self._get_unsigned_calib_coeff(0xb2)
+ self._AC6 = self._get_unsigned_calib_coeff(0xb4)
+ self._B1 = self._get_signed_calib_coeff(0xb6)
+ self._B2 = self._get_signed_calib_coeff(0xb8)
+ self._MB = self._get_signed_calib_coeff(0xba)
+ self._MC = self._get_signed_calib_coeff(0xbc)
+ self._MD = self._get_signed_calib_coeff(0xbe)
+
+ def _load_datasheet_calibration_coeffs(self):
+ self._AC1 = 408
+ self._AC2 = -72
+ self._AC3 = -14383
+ self._AC4 = 32741
+ self._AC5 = 32757
+ self._AC6 = 23153
+ self._B1 = 6190
+ self._B2 = 4
+ self._MB = -32767
+ self._MC = -8711
+ self._MD = 2868
+
+ def display_calibration_coeffs(self):
+ """Printout calibration coefficients of chips. Mainly
+ for debug purpose."""
+ print "AC1 = %d" % self._AC1
+ print "AC2 = %d" % self._AC2
+ print "AC3 = %d" % self._AC3
+ print "AC4 = %d" % self._AC4
+ print "AC5 = %d" % self._AC5
+ print "AC6 = %d" % self._AC6
+ print "B1 = %d" % self._B1
+ print "B2 = %d" % self._B2
+ print "MB = %d" % self._MB
+ print "MC = %d" % self._MC
+ print "MD = %d" % self._MD
+
+ def get_temperature(self):
+ """Return temperature measured by BMP180 in Celsius degrees"""
+ # read uncompensated temperature value:
+ self._bus.write_byte_data(self._address, 0xf4, 0x2e)
+ time.sleep(0.005)
+ MSB = self._bus.read_byte_data(self._address, 0xf6)
+ LSB = self._bus.read_byte_data(self._address, 0xf7)
+ UT = (MSB << 8) + LSB
+ #
+# UT = 27898
+ #
+ # calculate true temperature:
+ X1 = (UT-self._AC6)*(self._AC5 / 32768.0)
+ X2 = (self._MC * 2048.0) / (X1 + self._MD)
+ self._B5 = int(X1) + int(X2)
+ print "UT = %d\nX1 = %d\nX2 = %d\nB5 = %d" % (UT, X1, X2, self._B5)
+ T = (self._B5 + 8) / 16
+ T = T / 10.0
+ return T
+
+ def get_pressure(self, oss=0):
+ """Return pressure measured by BMP180 in HPa"""
+ self.get_temperature() # -> B5
+ # read uncompensated pressure value:
+ self._bus.write_byte_data(self._address, 0xf4, (0x34+(oss<<6)))
+ time.sleep(0.03) # 30ms, should depend on mode
+ MSB = self._bus.read_byte_data(self._address, 0xf6)
+ LSB = self._bus.read_byte_data(self._address, 0xf7)
+ XLSB = self._bus.read_byte_data(self._address, 0xf8)
+ UP = ((MSB << 16) + (LSB << 8) + XLSB) >> (8 - oss)
+ #
+# self._load_datasheet_calibration_coeffs()
+# self._B5 = 2399
+# UP = 23843
+# oss = 0
+ #
+ print "UP = %d" % UP
+ # calculate true pressure:
+ B6 = self._B5 - 4000
+ X1 = int(self._B2 * (B6 * B6 >> 12)) >> 11
+ X2 = (self._AC2 * B6) >> 11
+ X3 = X1 + X2
+ B3 = ((int(self._AC1 * 4 + X3) << oss) + 2) >> 2
+ print "B6 = %d\nX1 = %d\nX2 = %d\nX3 = %d\nB3 = %d" % (B6, X1, X2, X3, B3)
+ X1 = self._AC3 * B6 / 8192
+ X2 = (self._B1 * ((B6 * B6 >> 12))) >> 16
+ X3 = ((X1+X2)+2)/4
+ B4 = self._AC4 * (X3+32768) >> 15
+ B7 = (UP-B3)*(50000>>oss)
+ print "X1 = %d\nX2 = %d\nX3 = %d\nB4 = %d\nB7 = %d" % (X1, X2, X3, B4, B7)
+ if B7 < 0x80000000:
+ p = (B7 * 2) / B4
+ else:
+ p = (B7 / B4) * 2
+ X1 = (p >> 8) * (p >> 8)
+ print "X1 = %d" % X1
+ X1 = (X1*3038) >> 16
+ X2 = (-7357*p) >> 16
+ print "X1 = %d\nX2 = %d" % (X1, X2)
+ p = p+((X1+X2+3791) >> 4)
+ p = p / 100.0
+ return p
+
+# For test purpose:
+bmp = BMP180(bus_id=1, address=0x77)
+temp = bmp.get_temperature()
+print ">>> Temperature = %02.02f oC" % temp
+pressure = bmp.get_pressure(3)
+print ">>> Pressure = %04.02f HPa" % pressure
diff --git a/target/packages/as_devices/python/AsDevices/hmc5883l.py b/target/packages/as_devices/python/AsDevices/hmc5883l.py
new file mode 100644
index 0000000..a4874b7
--- /dev/null
+++ b/target/packages/as_devices/python/AsDevices/hmc5883l.py
@@ -0,0 +1,86 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# License: GNU LESSER GENERAL PUBLIC LICENSE, see COPYING.
+#
+
+__doc__ = "This class drives HMC5883L 3-axis digital compass"
+__version__ = "0.1.0"
+__versionTime__ = "06/10/2016"
+__author__ = "Julien Boibessot <jul...@ar...>"
+
+import smbus
+import time
+
+HMC_I2C_ADDR = 0x1e
+
+class HMC5883L(object):
+ def __init__(self, bus_id, address):
+ self._bus = smbus.SMBus(bus_id)
+ if address is not None:
+ self._address = address
+ else:
+ self._address = HMC_I2C_ADDR
+ self._get_id()
+# self._dump_regs()
+
+ def _read_reg(self, id):
+ self._bus.write_byte(self._address, id)
+ reg = self._bus.read_byte(self._address)
+ return reg
+
+ def _get_id(self):
+ self._bus.write_byte(self._address, 10)
+ id_a = self._read_reg(10)
+ id_b = self._read_reg(11)
+ id_c = self._read_reg(12)
+ if id_a != 0x48 or id_b != 0x34 or id_c != 0x33:
+ print "No valid HMC5883L IDs found ! (0x%02x 0x%02x 0x%02x != 0x48 0x34 0x33)" % (id_a, id_b, id_c)
+ return id
+
+ def _dump_regs(self):
+ for i in range(0,13):
+ self._bus.write_byte(self._address, i)
+ reg = self._bus.read_byte(self._address)
+ print "reg%d = 0x%02x" % (i, reg)
+
+ def _twos_comp(self, val, bits):
+ """compute the 2's compliment of int value val"""
+ if (val & (1 << (bits - 1))) != 0: # if sign bit is set e.g., 8bit: 128-255
+ val = val - (1 << bits) # compute negative value
+ return val
+
+ def _be_conv(self, le):
+ be = ((le << 8) & 0xFF00) + (le >> 8)
+ return be
+
+ def _get_unsigned_calib_coeff(self, reg_addr):
+ result = self._bus.read_word_data(self._address, reg_addr)
+ result = self._be_conv(result)
+ return result
+
+ def _get_signed_calib_coeff(self, reg_addr):
+ result = self._get_unsigned_calib_coeff(reg_addr)
+ if result > 32767:
+ result -= 65536
+ return result
+
+ def start_single_measurement(self):
+ data = [0, 0, 0]
+ self._bus.write_byte_data(self._address, 0, 0x70)
+ self._bus.write_byte_data(self._address, 1, 0xe0)
+ self._bus.write_byte_data(self._address, 2, 0x01)
+ time.sleep(0.006) # 6ms
+# reg = self._bus.read_block_data(self._address, 6)
+ for i in (0, 2, 4):
+ MSB = self._read_reg(3+i)
+ LSB = self._read_reg(4+i)
+ print "MSB = 0x%02x LSB = 0x%02x" % (MSB, LSB)
+ val = (MSB << 8) + LSB
+ val = self._twos_comp(val, 16)
+ data[i/2] = val
+ print data
+
+# For test purpose:
+hmc = HMC5883L(bus_id=1, address=0x1e)
+hmc.start_single_measurement()
hooks/post-receive
--
armadeus
|