diff --git a/conf/machine/am335x-nbhw16.conf b/conf/machine/am335x-nbhw16.conf index 7238537..000d66c 100644 --- a/conf/machine/am335x-nbhw16.conf +++ b/conf/machine/am335x-nbhw16.conf @@ -18,8 +18,8 @@ KERNEL_DEVICETREE = "am335x-nbhw16.dtb \ " KERNEL_IMAGETYPE = "zImage" -PREFERRED_PROVIDER_virtual/kernel ?= "linux-netmodule" -PV_pn-linux-netmodule ?= "4.4.71-${SRCPV}" -SRC_URI_pn-linux-netmodule ?= "git://github.com/netmodule/linux.git;protocol=https;branch=nbhw16-4.4-pm-ti" -SRCREV_pn-linux-netmodule ?= "6b0c567a305f65601d5bf32768a0a1080b1db051" +PREFERRED_PROVIDER_virtual/kernel = "linux-netmodule" +PV_pn-linux-netmodule = "4.4.71-${SRCPV}" +SRC_URI_pn-linux-netmodule = "git://github.com/netmodule/linux.git;protocol=https;branch=nbhw16-4.4-pm-ti" +SRCREV_pn-linux-netmodule = "cc8b47ba4afeb67ce82d98fb5c36c321ade8270f" diff --git a/conf/machine/am335x-nrhw20.conf b/conf/machine/am335x-nrhw20.conf index b017715..237e9fc 100644 --- a/conf/machine/am335x-nrhw20.conf +++ b/conf/machine/am335x-nrhw20.conf @@ -16,6 +16,6 @@ KERNEL_IMAGETYPE = "zImage" PREFERRED_PROVIDER_virtual/kernel = "linux-netmodule" PV_pn-linux-netmodule = "4.14.14-${SRCPV}" -SRC_URI_pn-linux-netmodule ?= "git://git.netmodule.intranet/nmrouter/linux.git;protocol=https;branch=nrhw20-4.14" +SRC_URI_pn-linux-netmodule ?= "git://github.com/netmodule/linux.git;protocol=https;branch=nrhw20-4.14" SRCREV_pn-linux-netmodule ?= "bc588eccf4d375d6a5c4fc1ff2584e4e7d550b65" diff --git a/conf/machine/armada-385-nrhw18.conf b/conf/machine/armada-385-nrhw18.conf new file mode 100644 index 0000000..e4fbdf4 --- /dev/null +++ b/conf/machine/armada-385-nrhw18.conf @@ -0,0 +1,21 @@ +#@TYPE: Machine +#@NAME: NRHW18 based routers like NB1800 +#@DESCRIPTION: Machine configuration for the NRHW18 based routers + +require conf/machine/include/armada.inc + +IMAGE_FSTYPES += "tar.gz cpio cpio.gz.u-boot" +IMAGE_CLASSES += "image_types_uboot" + +SERIAL_CONSOLE = "115200 ttyS1" +MACHINE_EXTRA_RRECOMMENDS = " kernel-modules kernel-devicetree" + +KERNEL_DEFCONFIG = "armada-385-nrhw18_defconfig" +KERNEL_DEVICETREE = "armada-385-nrhw18-prod3.dtb" +KERNEL_IMAGETYPE = "zImage" + +PREFERRED_PROVIDER_virtual/kernel = "linux-netmodule" +PV_pn-linux-netmodule = "4.14.0-${SRCPV}" +SRC_URI_pn-linux-netmodule ?= "git://github.com/netmodule/linux.git;protocol=https;branch=nrhw18-4.14" +SRCREV_pn-linux-netmodule ?= "2fb3360ec3cf672c74321e1dbe5c04e59d1ced11" + diff --git a/recipes-bsp/u-boot/u-boot-am335x-nbhw16-v1_git.bb b/recipes-bsp/u-boot/u-boot-am335x-nbhw16-v1_git.bb index 103385f..8cb370e 100644 --- a/recipes-bsp/u-boot/u-boot-am335x-nbhw16-v1_git.bb +++ b/recipes-bsp/u-boot/u-boot-am335x-nbhw16-v1_git.bb @@ -3,16 +3,24 @@ UBOOT_MACHINE = "am335x_nbhw16_defconfig" require u-boot-nm.inc -SRC_URI = "git://gitolite@git/usr/se/u-boot;protocol=ssh;branch=nbhw16-2016.04" +# Be aware github/netmodule git +SRC_URI = "git://github.com/netmodule/u-boot.git;protocol=https;branch=nbhw16-2016.04" -SRCREV ?= "${AUTOREV}" +# Should be updated when a new U-Boot Version is available +SRCREV ?= "a6f157c6dbd048b452c7e2640215c55be658780c" PV = "v2016.04+git${SRCPV}" SPL_BINARY = "MLO" UBOOT_SUFFIX = "img" do_deploy_append() { + rm -f ${DEPLOYDIR}/${PN}-spl.bin + rm -f ${DEPLOYDIR}/${PN}.bin + rm -f ${DEPLOYDIR}/${PN}.img + rm -f ${DEPLOYDIR}/MLO-${PN} cp ${S}/spl/u-boot-spl.bin ${DEPLOYDIR}/${PN}-spl.bin cp ${S}/u-boot.bin ${DEPLOYDIR}/${PN}.bin + cp ${S}/u-boot.img ${DEPLOYDIR}/${PN}.img + cp ${S}/MLO ${DEPLOYDIR}/MLO-${PN} } diff --git a/recipes-bsp/u-boot/u-boot-am335x-nbhw16-v2_git.bb b/recipes-bsp/u-boot/u-boot-am335x-nbhw16-v2_git.bb index 5d2fd4c..01579a8 100644 --- a/recipes-bsp/u-boot/u-boot-am335x-nbhw16-v2_git.bb +++ b/recipes-bsp/u-boot/u-boot-am335x-nbhw16-v2_git.bb @@ -1,18 +1,7 @@ +require u-boot-am335x-nbhw16-v1_git.bb + # Force machine configuration for this recipe UBOOT_MACHINE = "am335x_nbhw16_v2_defconfig" -require u-boot-nm.inc - -SRC_URI = "git://gitolite@git/usr/se/u-boot;protocol=ssh;branch=nbhw16-2016.04" - -SRCREV ?= "${AUTOREV}" -PV = "v2016.04+git${SRCPV}" - -SPL_BINARY = "MLO" -UBOOT_SUFFIX = "img" - -do_deploy_append() { - cp ${S}/spl/u-boot-spl.bin ${DEPLOYDIR}/${PN}-spl.bin - cp ${S}/u-boot.bin ${DEPLOYDIR}/${PN}.bin -} +SRCREV = "0b985705d558caceeb968b234af27cfc536ef019" diff --git a/recipes-bsp/u-boot/u-boot-am335x-nrhw20-v1_git.bb b/recipes-bsp/u-boot/u-boot-am335x-nrhw20-v1_git.bb new file mode 100644 index 0000000..64ca76e --- /dev/null +++ b/recipes-bsp/u-boot/u-boot-am335x-nrhw20-v1_git.bb @@ -0,0 +1,27 @@ +require u-boot-nm.inc + +# Force machine configuration for this recipe +UBOOT_MACHINE = "am335x_nrhw20_defconfig" + +# Be aware github/netmodule git +SRC_URI = "git://github.com/netmodule/u-boot.git;protocol=https;branch=nrhw20-2016.04" + +# Should be updated when a new U-Boot Version is available +SRCREV ?= "297c60c69942e7d377925181b29a1f8e9515284d" + +PV = "v2016.04+git${SRCPV}" + +SPL_BINARY = "MLO" +UBOOT_SUFFIX = "img" + +do_deploy_append() { + rm -f ${DEPLOYDIR}/${PN}-spl.bin + rm -f ${DEPLOYDIR}/${PN}.bin + rm -f ${DEPLOYDIR}/${PN}.img + rm -f ${DEPLOYDIR}/MLO-${PN} + cp ${S}/spl/u-boot-spl.bin ${DEPLOYDIR}/${PN}-spl.bin + cp ${S}/u-boot.bin ${DEPLOYDIR}/${PN}.bin + cp ${S}/u-boot.img ${DEPLOYDIR}/${PN}.img + cp ${S}/MLO ${DEPLOYDIR}/MLO-${PN} +} + diff --git a/recipes-bsp/u-boot/u-boot-armada-nrhw18-v1_git.bb b/recipes-bsp/u-boot/u-boot-armada-nrhw18-v1_git.bb new file mode 100644 index 0000000..d8c9632 --- /dev/null +++ b/recipes-bsp/u-boot/u-boot-armada-nrhw18-v1_git.bb @@ -0,0 +1,25 @@ +require u-boot-nm.inc + +# Force machine configuration for this recipe +UBOOT_MACHINE = "armada-385-nbhw18-v1_defconfig" + +# Be aware github/netmodule git +SRC_URI = "git://github.com/netmodule/u-boot.git;protocol=https;branch=nbhw-armada-v2017.11" + +# Should be updated when a new U-Boot Version is available +SRCREV ?= "43f3c912f8f0130c75bb9daf71386fc63ed193fd" + +PV = "v2017.11+git${SRCPV}" + +UBOOT_SUFFIX = "kwb" +UBOOT_BINARY = "u-boot-spl.${UBOOT_SUFFIX}" + +do_deploy() { + rm -f ${DEPLOYDIR}/${PN}-spl.bin + rm -f ${DEPLOYDIR}/${PN}.bin + rm -f ${DEPLOYDIR}/${PN}-spl.kwb + cp ${S}/spl/u-boot-spl.bin ${DEPLOYDIR}/${PN}-spl.bin + cp ${S}/u-boot.bin ${DEPLOYDIR}/${PN}.bin + cp ${S}/u-boot-spl.kwb ${DEPLOYDIR}/${PN}.kwb +} + diff --git a/recipes-connectivity/bluez5/bluez5/fix-out-of-bounds-heap-read.patch b/recipes-connectivity/bluez5/bluez5/fix-out-of-bounds-heap-read.patch new file mode 100644 index 0000000..05359da --- /dev/null +++ b/recipes-connectivity/bluez5/bluez5/fix-out-of-bounds-heap-read.patch @@ -0,0 +1,26 @@ +From 9e009647b14e810e06626dde7f1bb9ea3c375d09 Mon Sep 17 00:00:00 2001 +From: Luiz Augusto von Dentz +Date: Wed, 13 Sep 2017 10:01:40 +0300 +Subject: sdp: Fix Out-of-bounds heap read in service_search_attr_req function + +Check if there is enough data to continue otherwise return an error. +--- + src/sdpd-request.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/sdpd-request.c b/src/sdpd-request.c +index 1eefdce..318d044 100644 +--- a/src/sdpd-request.c ++++ b/src/sdpd-request.c +@@ -917,7 +917,7 @@ static int service_search_attr_req(sdp_req_t *req, sdp_buf_t *buf) + } else { + /* continuation State exists -> get from cache */ + sdp_buf_t *pCache = sdp_get_cached_rsp(cstate); +- if (pCache) { ++ if (pCache && cstate->cStateValue.maxBytesSent < pCache->data_size) { + uint16_t sent = MIN(max, pCache->data_size - cstate->cStateValue.maxBytesSent); + pResponse = pCache->data; + memcpy(buf->data, pResponse + cstate->cStateValue.maxBytesSent, sent); +-- +cgit v1.1 + diff --git a/recipes-connectivity/bluez5/bluez5_5.44.bb b/recipes-connectivity/bluez5/bluez5_5.44.bb index 2c4f4fe..bcff5e2 100644 --- a/recipes-connectivity/bluez5/bluez5_5.44.bb +++ b/recipes-connectivity/bluez5/bluez5_5.44.bb @@ -4,6 +4,10 @@ SRC_URI[sha256sum] = "0c321e291f8b45e6a78e379dfe80592b65955a0f0ab191f1cca0edd8ec EXTRA_OECONF += "--enable-deprecated" +SRC_URI_append = " file://fix-out-of-bounds-heap-read.patch" + +PR = "r2" + # noinst programs in Makefile.tools that are conditional on READLINE # support NOINST_TOOLS_READLINE ?= " \ diff --git a/recipes-connectivity/gpsd/gpsd/gpsd.service b/recipes-connectivity/gpsd/gpsd/gpsd.service new file mode 100644 index 0000000..8769762 --- /dev/null +++ b/recipes-connectivity/gpsd/gpsd/gpsd.service @@ -0,0 +1,15 @@ +[Unit] +Description=GPS (Global Positioning System) Daemon +Requires=gpsd.socket + +[Service] +ExecStartPre=-/bin/sh -c "/bin/echo 2 > /sys/class/gpio/export" +ExecStartPre=-/bin/sh -c "/bin/echo out > /sys/class/gpio/gpio2/direction" +ExecStartPre=/bin/sh -c "/bin/echo 1 > /sys/class/gpio/gpio2/value" +ExecStopPost=/bin/sh -c "/bin/echo 0 > /sys/class/gpio/gpio2/value" + +EnvironmentFile=/etc/default/gpsd +ExecStart=/usr/sbin/gpsd -N /dev/ttyS3 + +[Install] +Also=gpsd.socket diff --git a/recipes-connectivity/gpsd/gpsd_3.14.bbappend b/recipes-connectivity/gpsd/gpsd_3.14.bbappend new file mode 100644 index 0000000..98cb56f --- /dev/null +++ b/recipes-connectivity/gpsd/gpsd_3.14.bbappend @@ -0,0 +1 @@ +FILESEXTRAPATHS_prepend_am335x-nrhw20 := "${THISDIR}/${PN}:" \ No newline at end of file diff --git a/recipes-connectivity/libmbim/libmbim_1.16.0.bb b/recipes-connectivity/libmbim/libmbim_1.16.0.bb new file mode 100644 index 0000000..aa5e1ea --- /dev/null +++ b/recipes-connectivity/libmbim/libmbim_1.16.0.bb @@ -0,0 +1,18 @@ +SUMMARY = "libmbim is library for talking to WWAN devices by MBIM protocol" +DESCRIPTION = "libmbim is a glib-based library for talking to WWAN modems and devices which speak the Mobile Interface Broadband Model (MBIM) protocol" +HOMEPAGE = "http://www.freedesktop.org/wiki/Software/libmbim/" +LICENSE = "GPLv2 & LGPLv2.1" +LIC_FILES_CHKSUM = " \ + file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ + file://COPYING.LIB;md5=4fbd65380cdd255951079008b364516c \ +" + +DEPENDS = "glib-2.0 libgudev" + +inherit autotools pkgconfig + +SRC_URI = "http://www.freedesktop.org/software/${BPN}/${BPN}-${PV}.tar.xz" +SRC_URI[md5sum] = "76ea4d8381989919b1d9b91c818fed80" +SRC_URI[sha256sum] = "c8ca50beeddd4b43309df5b698917268303bf176cea58fe4fe53d5bf0e93fac2" + +FILES_${PN}_append = " ${datadir}/bash-completion" diff --git a/recipes-connectivity/libqmi/libqmi_1.20.0.bb b/recipes-connectivity/libqmi/libqmi_1.20.0.bb new file mode 100644 index 0000000..66b56db --- /dev/null +++ b/recipes-connectivity/libqmi/libqmi_1.20.0.bb @@ -0,0 +1,19 @@ +SUMMARY = "libqmi is a library for talking to WWAN devices by QMI protocol" +DESCRIPTION = "libqmi is a glib-based library for talking to WWAN modems and devices which speak the Qualcomm MSM Interface (QMI) protocol" +HOMEPAGE = "http://www.freedesktop.org/wiki/Software/libqmi" +LICENSE = "GPLv2 & LGPLv2.1" +LIC_FILES_CHKSUM = " \ + file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ + file://COPYING.LIB;md5=4fbd65380cdd255951079008b364516c \ +" + +DEPENDS = "glib-2.0" + +inherit autotools pkgconfig + +SRC_URI = "http://www.freedesktop.org/software/${BPN}/${BPN}-${PV}.tar.xz" +SRC_URI[md5sum] = "797e365521df76b77b067e6317618b41" +SRC_URI[sha256sum] = "21428cd3749c56246565123f707fee51238651a22c60bdc85ebce97388626eb4" + +FILES_${PN}_append = " ${datadir}/bash-completion" + diff --git a/recipes-connectivity/modemmanager/modemmanager/make-compilable.patch b/recipes-connectivity/modemmanager/modemmanager/make-compilable.patch new file mode 100644 index 0000000..4f59d91 --- /dev/null +++ b/recipes-connectivity/modemmanager/modemmanager/make-compilable.patch @@ -0,0 +1,13 @@ +diff --git a/configure.ac b/configure.ac +index ce1e2ea..6615c08 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -26,7 +26,7 @@ dnl----------------------------------------------------------------------------- + dnl autoconf, automake, libtool initialization + dnl + AC_INIT([ModemManager],[mm_version],[modemmanager-devel@lists.freedesktop.org],[ModemManager]) +-AM_INIT_AUTOMAKE([1.11.2 subdir-objects tar-ustar no-dist-gzip dist-xz -Wno-portability]) ++AM_INIT_AUTOMAKE([1.11.2 subdir-objects tar-ustar no-dist-gzip dist-xz -Wno-portability foreign]) + m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + + AM_MAINTAINER_MODE([enable]) diff --git a/recipes-connectivity/modemmanager/modemmanager_1.8.0.bb b/recipes-connectivity/modemmanager/modemmanager_1.8.0.bb new file mode 100644 index 0000000..8860349 --- /dev/null +++ b/recipes-connectivity/modemmanager/modemmanager_1.8.0.bb @@ -0,0 +1,51 @@ +SUMMARY = "ModemManager is a daemon controlling broadband devices/connections" +DESCRIPTION = "ModemManager is a DBus-activated daemon which controls mobile broadband (2G/3G/4G) devices and connections" +HOMEPAGE = "http://www.freedesktop.org/wiki/Software/ModemManager/" +LICENSE = "GPLv2 & LGPLv2.1" +LIC_FILES_CHKSUM = " \ + file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \ + file://COPYING.LIB;md5=4fbd65380cdd255951079008b364516c \ +" + +inherit autotools gettext gtk-doc systemd + +DEPENDS = "glib-2.0 libmbim libqmi polkit libgudev dbus-glib libxslt-native" + +SRC_URI = " \ + git://anongit.freedesktop.org/ModemManager/ModemManager \ + file://make-compilable.patch \ + " + +SRCREV = "223b754fccba28dbb3ce950058a81bd133c8ce86" + +S = "${WORKDIR}/git" + +FILES_${PN} += " \ + ${datadir}/icons \ + ${datadir}/polkit-1 \ + ${datadir}/bash-completion \ + ${libdir}/ModemManager \ + ${systemd_unitdir}/system \ +" + +FILES_${PN}-dev += " \ + ${datadir}/dbus-1 \ + ${libdir}/ModemManager/*.la \ +" + +FILES_${PN}-staticdev += " \ + ${libdir}/ModemManager/*.a \ +" + +FILES_${PN}-dbg += "${libdir}/ModemManager/.debug" + +SYSTEMD_SERVICE_${PN} = "ModemManager.service" + +do_install_append_am335x-nbhw16-fct() { + sed -i 's/ExecStart=.*/ExecStart=\/usr\/sbin\/ModemManager --debug/g' ${D}/lib/systemd/system/ModemManager.service +} + +do_install_append_am335x-nrhw20-fct() { + sed -i 's/ExecStart=.*/ExecStart=\/usr\/sbin\/ModemManager --debug/g' ${D}/lib/systemd/system/ModemManager.service +} + diff --git a/recipes-connectivity/tibluetooth/tibluetooth.bb b/recipes-connectivity/tibluetooth/tibluetooth.bb index 5ef1e14..586865f 100644 --- a/recipes-connectivity/tibluetooth/tibluetooth.bb +++ b/recipes-connectivity/tibluetooth/tibluetooth.bb @@ -26,7 +26,7 @@ FILES_${PN}_append = " \ /lib \ " -do_install_am335x-nbhw16 () { +install_nbhw16 () { install -d ${D}${systemd_unitdir}/system/ install -m 0644 tibluetooth-nbhw16.service ${D}${systemd_unitdir}/system/tibluetooth.service @@ -34,6 +34,14 @@ do_install_am335x-nbhw16 () { install -m 0644 TIInit_11.8.32.bts ${D}/lib/firmware/ti-connectivity/ } +do_install_am335x-nbhw16 () { + install_nbhw16 +} + +do_install_am335x-nbhw16-fct () { + install_nbhw16 +} + install_nrhw20 () { install -d ${D}${systemd_unitdir}/system/ install -m 0644 tibluetooth-nrhw20.service ${D}${systemd_unitdir}/system/tibluetooth.service diff --git a/recipes-connectivity/tibluetooth/tibluetooth/tibluetooth-nbhw16.service b/recipes-connectivity/tibluetooth/tibluetooth/tibluetooth-nbhw16.service index 18bd305..0c69a95 100644 --- a/recipes-connectivity/tibluetooth/tibluetooth/tibluetooth-nbhw16.service +++ b/recipes-connectivity/tibluetooth/tibluetooth/tibluetooth-nbhw16.service @@ -1,6 +1,6 @@ [Unit] Description=Attach ti bluetooth -Before=bluetooth +Before=bluetooth.target Requires=bluetooth.target [Service] diff --git a/recipes-connectivity/tibluetooth/tibluetooth/tibluetooth-nrhw20.service b/recipes-connectivity/tibluetooth/tibluetooth/tibluetooth-nrhw20.service index 6ad68d8..4489bc3 100644 --- a/recipes-connectivity/tibluetooth/tibluetooth/tibluetooth-nrhw20.service +++ b/recipes-connectivity/tibluetooth/tibluetooth/tibluetooth-nrhw20.service @@ -1,6 +1,6 @@ [Unit] Description=Attach ti bluetooth -Before=bluetooth +Before=bluetooth.target Requires=bluetooth.target [Service] diff --git a/recipes-core/board-descriptor/board-descriptor.bb b/recipes-core/board-descriptor/board-descriptor.bb index e4fc40a..531e6eb 100644 --- a/recipes-core/board-descriptor/board-descriptor.bb +++ b/recipes-core/board-descriptor/board-descriptor.bb @@ -9,7 +9,7 @@ LICENSE = "GPLv2+" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" PR = "r0" -RDEPENDS_${PN} = "python-json" +RDEPENDS_${PN} = "python-json python-textutils" SRC_URI = " \ file://bd.py \ diff --git a/recipes-core/board-descriptor/board-descriptor/bd.json b/recipes-core/board-descriptor/board-descriptor/bd.json index 2abd114..0df4417 100644 --- a/recipes-core/board-descriptor/board-descriptor/bd.json +++ b/recipes-core/board-descriptor/board-descriptor/bd.json @@ -58,6 +58,9 @@ "pd_usbhost": { "id": 4124, "type": "String"}, "pd_dev_tree": { "id": 4125, "type": "String"}, "patch_ver": { "id": 4126, "type": "UInt8"}, + "pd_phy2": { "id": 4127, "type": "String"}, + "pd_serdes": { "id": 4128, "type": "UInt16"}, + "pd_shield": { "id": 4129, "type": "UInt16"}, "boot_part": { "id": 32768, "type": "UInt8"}, "factory_reset": { "id": 32769, "type": "UInt8"} diff --git a/recipes-core/board-descriptor/board-descriptor/bd.py b/recipes-core/board-descriptor/board-descriptor/bd.py index b3d94c5..b36cf51 100755 --- a/recipes-core/board-descriptor/board-descriptor/bd.py +++ b/recipes-core/board-descriptor/board-descriptor/bd.py @@ -63,7 +63,7 @@ def read_descriptors(config): desc = descriptor.Descriptor(eeprom["path"], valid_bd["start"], valid_bd["size"], - config_table) + json.loads(config_table)) desc.read() descs.append(desc) return descs diff --git a/recipes-core/board-descriptor/board-descriptor/config.json b/recipes-core/board-descriptor/board-descriptor/config.json index a3ab00c..1ca6a6d 100644 --- a/recipes-core/board-descriptor/board-descriptor/config.json +++ b/recipes-core/board-descriptor/board-descriptor/config.json @@ -2,7 +2,8 @@ "tag_list": "/etc/bd/bd.json", "eeprom": [ { "path": "/sys/bus/i2c/devices/0-0050/eeprom", "valid_bds": [ - {"name": "info", "start": 0, "size": 1024}, + {"name": "board", "start": 0, "size": 1024}, + {"name": "platform", "start": 512, "size": 512}, {"name": "settings", "start": 1536, "size": 512} ] } diff --git a/recipes-core/board-descriptor/board-descriptor/descriptor.py b/recipes-core/board-descriptor/board-descriptor/descriptor.py index d4c78d1..922e9ba 100644 --- a/recipes-core/board-descriptor/board-descriptor/descriptor.py +++ b/recipes-core/board-descriptor/board-descriptor/descriptor.py @@ -1,5 +1,3 @@ -import json - def _array_to_int(data): # This one works for python2.7 and python3 @@ -31,8 +29,6 @@ def _array_to_partition(data): return part - return _array_to_parition_gen(data, 4) - def _array_to_partition64(data): import codecs @@ -112,6 +108,7 @@ def _dict_to_partition64(data): def _not_supported_yet(data): + del data raise NotImplementedError("Setting this type is not supported yet") _type_to_value = { @@ -185,12 +182,12 @@ class _BdRaw: class _BdParsed: - def __init__(self, strtype, value): - self.value = self._value_type(strtype, value) + def __init__(self, str_type, value): + self.value = self._value_type(str_type, value) - def _value_type(self, strtype, value): + def _value_type(self, str_type, value): for key, fun in _string_to_type.items(): - if key == strtype: + if key == str_type: return fun(value) @@ -199,7 +196,10 @@ class Descriptor: self.file = file self.offset = offset self.max_size = max_size - self.config_table = json.loads(config_table) + self.config_table = config_table + self.bd_raw = None + self.bd_parsed = None + self.tlv_by_name = None def _read_raw_bd(self): fd = open(self.file, "rb") @@ -218,6 +218,7 @@ class Descriptor: if tlv.tag == value["id"]: parsed = _BdParsed(value["type"], tlv.value) return key, parsed.value + return "unknown_" + str(tlv.tag), tlv.value def _parse_data(self, bdraw): bdparsed = {} @@ -228,26 +229,26 @@ class Descriptor: i = 1 while key in bdparsed: key = name + "_" + str(i) - i = i + 1 + i += 1 bdparsed[key] = value tlv_by_name[key] = tlv return bdparsed, tlv_by_name def read(self): - self.bdraw = self._read_raw_bd() - self.bdparsed, self.tlv_by_name = self._parse_data(self.bdraw) + self.bd_raw = self._read_raw_bd() + self.bd_parsed, self.tlv_by_name = self._parse_data(self.bd_raw) def get_list(self): - return self.bdparsed + return self.bd_parsed def get(self, name): name = name.split(".") - element = self.bdparsed + element = self.bd_parsed # Search the final element to print - # This allows names in the form parition64.flags + # This allows names in the form partition64.flags for key in name: - if not key in element: + if key not in element: return None element = element[key] return element @@ -269,6 +270,8 @@ class Descriptor: return dictionary def _do_set(self, name, value, tlv): + tlv_type = None + for key, config_item in self.config_table.items(): if tlv.tag == config_item["id"]: tlv_type = config_item["type"] @@ -282,11 +285,11 @@ class Descriptor: if not type(name) is list: self._write_bd(tlv.pos, fun(value), tlv.length) else: - element = self.bdparsed[name[0]] + element = self.bd_parsed[name[0]] # if we have changed the element it will be our value again value = self._update_dict(element, name[1:], value) self._write_bd(tlv.pos, fun(value), tlv.length) - self.bdparsed[name[0]] = value + self.bd_parsed[name[0]] = value def set(self, name, value): if self.tlv_by_name is None: @@ -298,7 +301,7 @@ class Descriptor: if tlv is None: return False - if not self.bdraw.is_writable: + if not self.bd_raw.is_writable: raise IOError("This operation is not permitted on " "this descriptor (ro)")