Compare commits

...

36 Commits
HEAD ... sumo

Author SHA1 Message Date
Ramon Moesching 1f08b06381 u-boot-am335x-nmhw21: fix: full git commit id
SRCREV expects full revision identifier.
Only internal variable SRCPV is using shortened id for improving
usability in path an file names.

YP:
https://www.yoctoproject.org/docs/2.6/mega-manual/mega-manual.html

Signed-off-by: Ramon Moesching <ramon.moesching@netmodule.com>
2019-09-16 10:54:12 +02:00
Patrick Zysset 31f86005b3 nmhw21: fix sumo u-boot revision
Signed-off-by: Patrick Zysset <patrick.zysset@netmodule.com>
2019-06-29 00:58:05 +02:00
Alexandre Bard e578b54105 ublox-gsm-config: Add factory reset feature
BugzID: 57487
2019-06-14 11:01:11 +02:00
Alexandre Bard 1658fc3621 ublox-gsm-config: Add service description
BugzID: 57325
2019-06-14 11:01:10 +02:00
Alexandre Bard 2713389914 ublox-gsm-config: Add header to sim.conf
BugzID: 57325
2019-06-14 11:01:10 +02:00
Alexandre Bard 331ff2291b ublox-gsm-config: Improve check of bridge and ecm modes
BugzID: 57325
2019-06-13 16:16:49 +02:00
Alexandre Bard 4f7c0fece9 ublox-gsm-config: Write SIM with capital letters
BugzID: 57325
2019-06-13 16:16:27 +02:00
Alexandre Bard 92654f1907 ublox-config: Rename to ublox-gsm-config
BugzID: 57325
2019-06-13 16:16:01 +02:00
Alexandre Bard 0e0ae3254c ublox-config: Increase poweroff delay
BugzID: 57325
2019-06-13 15:42:18 +02:00
Alexandre Bard b98dbc71a3 ublox-config: Use libgpiod for sim switch
BugzID: 57325
2019-06-13 15:42:17 +02:00
Alexandre Bard 40aca5599e ublox-config: Add poweroff feature
systemctl start ModemManager will start ublox-config first
systemctl stop ublox-config will stop ModemManager first

BugzID: 57325
2019-06-12 19:05:57 +02:00
Alexandre Bard 5fd5028063 Add libgpiod_1.2
This version supports bindings for python.

BugzID: 57325
2019-06-12 15:15:43 +02:00
Alexandre Bard becbb56002 ublox-configuration: Add power on
BugzID: 57325
2019-06-12 13:47:00 +02:00
Alexandre Bard 4f1be4fe1b ublox-config: Merge all modem scripts in one
Features:
  - Settings USB ECM mode and bridge mode
  - SIM switch (auto or according to sim.conf)
  - SW reset instead of HW reset
  - Supports private APN through apn.conf file
     - Now volatile config
  - Dump running config

BugzID: 57321
BugZID: 57325
2019-06-12 13:46:53 +02:00
Alexandre Bard 8cea86285c sim-config: Fix pathname in reset function 2019-06-12 13:46:45 +02:00
Alexandre Bard 50723f08d9 gpsd: Use netmodule fork
BugzID: 57168
2019-05-27 16:07:05 +02:00
Patrick Zysset fa843b5729 imx8-mek: adjust u-boot source tree
u-boot imx8-mek recipe is fetching from 2019.04/standard/imx8-mek
branch.

Signed-off-by: Patrick Zysset <patrick.zysset@netmodule.com>
2019-05-14 09:40:36 +02:00
Andrejs Cainikovs e74942f372 imx8-mek: add imx8-mek target
This is the official NXP imx8 evaluation board used as preview for nmhw23
target.

Signed-off-by: Patrick Zysset <patrick.zysset@netmodule.com>
2019-05-14 08:49:28 +02:00
Alexandre Bard a44eb7a9f6 nmhw16: tibluetooth: Delay startup
Since we moved to kernel 4.19 the WLAN/BT chip needs some time to
be initialized.
2019-05-13 17:58:47 +02:00
Alexandre Bard 0f50b0ad35 nmhw21: mac-address-set: set wlan/bt mac address
on nmhw21 the following mac address scheme is used:
- Ethernet:    xx:xx:xx:50:xx:xx
- User Module: xx:xx:xx:60:xx:xx
- Wifi:        xx:xx:xx:70:xx:xx
- BT:          xx:xx:xx:80:xx:xx

Note: this scheme is only valid for nmhw21.

BugzID: 54514

Signed-off-by: Patrick Zysset <patrick.zysset@netmodule.com>
2019-04-11 00:51:49 +02:00
Alexandre Bard b033cd3f9d modem-config-dump: Create a nice human readable config file
Full config file under /run/modem/modem-at.config
New easily readable file under /run/modem/modem.config

BugzID: 56305
2019-04-03 11:34:03 +02:00
Alexandre Bard 0ab0535705 sim-config: Improve alive check after reset
BugzID: 56371
2019-04-02 18:58:24 +02:00
Alexandre Bard d146532b31 Add sim-config and reorder modem related scripts
BugzID: 56371
2019-04-02 15:04:01 +02:00
Alexandre Bard c3135842b5 ublox-config: Make sure that device is available before sending commands
BugzID: 56371
2019-04-02 15:03:42 +02:00
Alexandre Bard 5116f1802d ublox-config: Remove extension from rootfs binary
BugzID: 56371
2019-04-02 15:03:13 +02:00
Alexandre Bard 011fc23c21 modem-config-dump: Move config to /run and improve failure handling
BugzID: 56305
2019-04-02 15:02:30 +02:00
Alexandre Bard 68af9813d6 Add mac-address-set
This script sets mac address of wifi and bluetooth chip
according to serial number

Also add NetworkManager config to not use random mac address on wifi

BugzID: 54514
2019-04-02 15:01:47 +02:00
Alexandre Bard c001bc907f Add modem-config-dump
This script will dump the config of the modem (ublox l2)
to /tmp/config/ublox-tobyl2.conf on boot

BugzID: 56305
2019-04-02 15:01:13 +02:00
Alexandre Bard 56295e2ed0 ublox-config: Exit script only when modem reset is complete 2019-03-28 15:00:06 +01:00
Patrick Zysset d0e8bfaf25 nrhw18: update fpga bitstream to v1.0
update fpga bitstream to v1.0 (imported from:
https://svn.netmodule.intranet/svn/projects/Projects/9100026_NRHW_18/FW_NRHW_18-MB/tags/20190314_FW_NBHW_18_v01.00/NBHW_18_deployement/LatticeDiamond/impl_nbhw18/output/LG00000000)

BugzID: 56159

Signed-off-by: Patrick Zysset <patrick.zysset@netmodule.com>
2019-03-17 01:17:58 +01:00
Patrick Zysset 1f23dae1db u-boot: am335x: nrhw20: fix srcrev to 2018.07.17
use last known functional nrhw20 revision.

Signed-off-by: Patrick Zysset <patrick.zysset@netmodule.com>
2019-03-08 17:01:05 +01:00
Patrick Zysset 064ed29756 u-boot: am335x: update u-boot deployments
u-boot deployed files of am335x based platforms (nrhw16/20) should be renamed according former nmhw21 refactoring.

Signed-off-by: Patrick Zysset <patrick.zysset@netmodule.com>
2019-03-08 14:58:55 +01:00
Patrick Zysset 4aa5842711 conf: streamline machine config of am335x-nrhw20
sync with latest changes introduced to am335x-nmhw21.

Signed-off-by: Patrick Zysset <patrick.zysset@netmodule.com>
2019-03-01 17:53:05 +01:00
Patrick Zysset 4e12267cf4 nmhw21: remove v1 from am335x-nmhw21 u-boot name
since u-boot is backward compatible and today mainly used on v2 boards,
this naming is misleading.

BugzId: 55650

Signed-off-by: Patrick Zysset <patrick.zysset@netmodule.com>
2019-02-09 19:09:01 +01:00
Patrick Zysset e2dba2dc79 board-descriptor: allow 0xffff as end tag
with latest nmhw21 boards 0xffff have been introduced as a new end tag
(with or without intention). Tag 65535 is now handled the same way as
Tag 0 (aka end-tag).

BugzId: 55411

Signed-off-by: Patrick Zysset <patrick.zysset@netmodule.com>
2019-02-07 14:26:58 +01:00
Patrick Zysset f1f908ce59 board-descriptor: fix partitioning of bd eeprom
the expected partitions are:
- board:       0.. 512
- product:   512..1024

start address and name of product partition was not correct. and there
is no 3rd partition available on this board.

BugzID: 55411

Signed-off-by: Patrick Zysset <patrick.zysset@netmodule.com>
2019-02-07 14:25:10 +01:00
32 changed files with 577 additions and 111 deletions

View File

@ -0,0 +1 @@
WKS_FILE_sota = "sdimage-sota-mek.wks"

View File

@ -25,4 +25,4 @@ UBOOT_ENTRYPOINT ?= "0x80008000"
IMAGE_BOOT_FILES = "MLO u-boot.img"
PREFERRED_PROVIDER_virtual/kernel = "linux-netmodule"
PREFERRED_PROVIDER_virtual/bootloader = "u-boot-am335x-nmhw21-v1"
PREFERRED_PROVIDER_virtual/bootloader = "u-boot-am335x-nmhw21"

View File

@ -12,10 +12,17 @@ MACHINE_EXTRA_RRECOMMENDS = " kernel-modules kernel-devicetree"
KERNEL_DEFCONFIG ??= "am335x-nrhw20_defconfig"
KERNEL_DEVICETREE = "am335x-nrhw20-prod1.dtb \
"
SOTA_MACHINE = "${MACHINE}"
KERNEL_CLASSES_append = " kernel-fitimage"
KERNEL_IMAGETYPE = "zImage"
KERNEL_IMAGETYPES = "fitImage zImage"
KERNEL_IMAGETYPE_sota = "fitImage"
KERNEL_IMAGETYPES_sota = "fitImage"
UBOOT_ENTRYPOINT ?= "0x80008000"
IMAGE_BOOT_FILES = "MLO u-boot.img"
PREFERRED_PROVIDER_virtual/bootloader = "u-boot-am335x-nrhw20-v1"
PREFERRED_PROVIDER_virtual/kernel = "linux-netmodule"
PV_pn-linux-netmodule = "4.14.14-${SRCPV}"
SRC_URI_pn-linux-netmodule ?= "git://git.netmodule.intranet/yoctoproject/linux-netmodule.git;protocol=ssh;user=gitea;branch=4.14/standard/nrhw20"
PREFERRED_PROVIDER_virtual/bootloader = "u-boot-am335x-nrhw20-v1"

View File

@ -0,0 +1,28 @@
#@TYPE: Machine
#@NAME: NXP MEK Board
#@DESCRIPTION: Machine configuration for the mek evalboard
require conf/machine/include/arm/arch-arm64.inc
IMAGE_FSTYPES += "tar.gz cpio cpio.gz.u-boot"
IMAGE_CLASSES += "image_types"
MACHINE_EXTRA_RRECOMMENDS = " kernel-modules kernel-devicetree"
KERNEL_DEFCONFIG = ""
KERNEL_DEVICETREE = "freescale/fsl-imx8qxp-mek.dtb freescale/fsl-imx8qxp-mek-dom0.dtb"
SOTA_MACHINE = "${MACHINE}"
KERNEL_CLASSES_append = " kernel-fitimage"
KERNEL_IMAGETYPE = "Image"
KERNEL_IMAGETYPES = "fitImage Image"
KERNEL_IMAGETYPE_sota = "fitImage"
KERNEL_IMAGETYPES_sota = "fitImage"
UBOOT_ENTRYPOINT ?= "0x80020000"
UBOOT_MACHINE = "imx8qxp_mek_defconfig"
IMAGE_BOOT_FILES = "flash.bin"
PREFERRED_PROVIDER_virtual/kernel = "linux-netmodule"
PREFERRED_PROVIDER_virtual/bootloader = "u-boot-imx8-mek"

View File

@ -0,0 +1,11 @@
[Unit]
After=tibluetooth.service
[Service]
Type=oneshot
ExecStart=/usr/bin/mac-address-set
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
eth_mac=$(ip addr show eth0 | awk '$1 == "link/ether" {gsub(/\/.*$/, "", $2); print $2}')
wlan_mac=$(echo $eth_mac | sed -r "s/^(.{9})50(.{6})/\170\2/")
bt_addr=$(echo $eth_mac | sed -r "s/^(.{9})50(.{6})/\180\2/")
# Set WLAN address
ifconfig wlan0 | grep UP > /dev/null
up=$?
if [[ $up == 0 ]]; then
ifconfig wlan0 down
fi
ip link set wlan0 address $wlan_mac
if [[ $up == 0 ]]; then
ifconfig wlan0 up
fi
# Set BT address
bt_addr_rev=$(echo $bt_addr | sed -r "s/^(.{2}):(.{2}):(.{2}):(.{2}):(.{2}):(.{2})/\6:\5:\4:\3:\2:\1/")
bdaddr $bt_addr_rev
hciconfig hci0 reset
systemctl restart bluetooth

View File

@ -1,26 +1,23 @@
SUMMARY = "Ublox gsm configuration"
DESCRIPTION = "Configure ublox gsm modem on first boot"
SUMMARY = "Set mac addresses of Wifi and bluetooth chips"
DESCRIPTION = "Small scripts that set the mac addresses based on ethernet mac"
AUTHOR = "Alexandre Bard"
SECTION = "connectivity"
LICENSE = "GPLv2+"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"
PR = "r2"
RDEPENDS_${PN}="python3-pyserial"
inherit systemd
SRC_URI = " \
file://ublox-config.service \
file://ublox-config.py \
file://mac-address-set.service \
file://mac-address-set.sh \
"
S = "${WORKDIR}"
INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
SYSTEMD_SERVICE_${PN} = "ublox-config.service"
SYSTEMD_SERVICE_${PN} = "mac-address-set.service"
SYSTEMD_AUTO_ENABLE ?= "enable"
FILES_${PN}_append = " \
@ -30,9 +27,9 @@ FILES_${PN}_append = " \
do_install () {
install -d ${D}${systemd_unitdir}/system/
install -m 0644 ublox-config.service ${D}${systemd_unitdir}/system/
install -m 0644 mac-address-set.service ${D}${systemd_unitdir}/system/
install -d ${D}/usr/bin
install -m 0755 ublox-config.py ${D}/usr/bin
install -m 0755 mac-address-set.sh ${D}/usr/bin/mac-address-set
}

View File

@ -7,7 +7,7 @@ UBOOT_MACHINE = "am335x_nmhw21_defconfig"
SRC_URI = "git://git.netmodule.intranet/nmrouter/u-boot;protocol=ssh;user=gitea;branch=2016.05-am335x-netmodule"
# Should be updated when a new U-Boot Version is available
SRCREV ?= "${AUTOREV}"
SRCREV ?= "5c5c0b98fea0e9514d56de05c2033440608a53ef"
PV = "v2016.05+git${SRCPV}"
SPL_BINARY = "MLO"

View File

@ -1,8 +1,8 @@
require u-boot-nm.inc
# Force machine configuration for this recipe
UBOOT_MACHINE = "am335x_nbhw16_defconfig"
require u-boot-nm.inc
# Be aware github/netmodule git
SRC_URI = "git://git.netmodule.intranet/nmrouter/u-boot;protocol=ssh;user=gitea;branch=2016.05-am335x-netmodule"
@ -14,13 +14,11 @@ 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}
rm -f ${DEPLOYDIR}/*${PN}.xmodem.bin
rm -f ${DEPLOYDIR}/*${PN}.${UBOOT_SUFFIX}
cp ${S}/spl/u-boot-spl.bin ${DEPLOYDIR}/spl-${PN}.xmodem.bin
cp ${S}/u-boot.bin ${DEPLOYDIR}/${PN}.xmodem.bin
cp ${S}/u-boot.img ${DEPLOYDIR}/${PN}.${UBOOT_SUFFIX}
cp ${S}/MLO ${DEPLOYDIR}/spl-${PN}.${UBOOT_SUFFIX}
}

View File

@ -3,5 +3,5 @@ require u-boot-am335x-nrhw16-v1_git.bb
# Force machine configuration for this recipe
UBOOT_MACHINE = "am335x_nbhw16_v2_defconfig"
SRCREV = "0b985705d558caceeb968b234af27cfc536ef019"
SRCREV ?= "${AUTOREV}"

View File

@ -7,21 +7,18 @@ UBOOT_MACHINE = "am335x_nrhw20_defconfig"
SRC_URI = "git://git.netmodule.intranet/nmrouter/u-boot;protocol=ssh;user=gitea;branch=2016.05-am335x-netmodule"
# Should be updated when a new U-Boot Version is available
SRCREV ?= "297c60c69942e7d377925181b29a1f8e9515284d"
PV = "v2016.04+git${SRCPV}"
SRCREV ?= "88720cc579ddc712aa73a61e3426fe4bd1b8628e"
PV = "v2016.05+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}
rm -f ${DEPLOYDIR}/*${PN}.xmodem.bin
rm -f ${DEPLOYDIR}/*${PN}.${UBOOT_SUFFIX}
cp ${S}/spl/u-boot-spl.bin ${DEPLOYDIR}/spl-${PN}.xmodem.bin
cp ${S}/u-boot.bin ${DEPLOYDIR}/${PN}.xmodem.bin
cp ${S}/u-boot.img ${DEPLOYDIR}/${PN}.${UBOOT_SUFFIX}
cp ${S}/MLO ${DEPLOYDIR}/spl-${PN}.${UBOOT_SUFFIX}
}

View File

@ -0,0 +1,36 @@
require u-boot-nm.inc
DEPENDS += "bc-native coreutils-native dtc-native"
# Force machine configuration for this recipe
UBOOT_MACHINE = "imx8qxp_mek_defconfig"
# Be aware github/netmodule git
SRC_URI = "git://git.netmodule.intranet/nmrouter/u-boot;protocol=ssh;user=gitea;branch=2019.04/standard/imx8-mek"
# License
LICENSE = "GPLv2+"
LIC_FILES_CHKSUM = "file://Licenses/README;md5=30503fd321432fc713238f582193b78e"
# Should be updated when a new U-Boot Version is available
SRCREV ?= "${AUTOREV}"
PV = "v2019.04pre+git${SRCPV}"
UBOOT_BINARY = "flash.bin"
UBOOT_MAKE_TARGET = "flash.bin"
do_compile() {
export ATF_LOAD_ADDR=0x80000000
export BL33_LOAD_ADDR=0x80020000
oe_runmake ${UBOOT_MACHINE}
# TODO: move this to U-Boot defconfig
echo "CONFIG_CMD_EXT2=y" >> ${B}/.config
echo "CONFIG_CMD_EXT4=y" >> ${B}/.config
echo "CONFIG_CMD_EXT4_WRITE=y" >> ${B}/.config
oe_runmake ${UBOOT_MAKE_TARGET}
dd if=${S}/u-boot.itb of=${S}/flash.bin bs=512 seek=528
}
do_deploy_append() {
cp ${S}/flash.bin ${DEPLOYDIR}/flash.bin
}

View File

@ -65,20 +65,20 @@ UBOOT_ENV_IMAGE ?= "${UBOOT_ENV}-${MACHINE}-${PV}-${PR}.${UBOOT_ENV_SUFFIX}"
UBOOT_ENV_SYMLINK ?= "${UBOOT_ENV}-${MACHINE}.${UBOOT_ENV_SUFFIX}"
do_compile () {
if [ "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', 'ld-is-gold', '', d)}" = "ld-is-gold" ] ; then
sed -i 's/$(CROSS_COMPILE)ld$/$(CROSS_COMPILE)ld.bfd/g' config.mk
fi
if [ "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-gold', 'ld-is-gold', '', d)}" = "ld-is-gold" ] ; then
sed -i 's/$(CROSS_COMPILE)ld$/$(CROSS_COMPILE)ld.bfd/g' config.mk
fi
unset LDFLAGS
unset CFLAGS
unset CPPFLAGS
unset LDFLAGS
unset CFLAGS
unset CPPFLAGS
if [ ! -e ${B}/.scmversion -a ! -e ${S}/.scmversion ]
then
echo ${UBOOT_LOCALVERSION} > ${B}/.scmversion
echo ${UBOOT_LOCALVERSION} > ${S}/.scmversion
fi
if [ ! -e ${B}/.scmversion -a ! -e ${S}/.scmversion ]
then
echo ${UBOOT_LOCALVERSION} > ${B}/.scmversion
echo ${UBOOT_LOCALVERSION} > ${S}/.scmversion
fi
if [ "x${UBOOT_CONFIG}" != "x" ]
then
for config in ${UBOOT_MACHINE}; do

View File

@ -1,9 +1,13 @@
FILESEXTRAPATHS_prepend_am335x-nrhw20 := "${THISDIR}/${PN}:"
FILESEXTRAPATHS_prepend_am335x-nmhw21 := "${THISDIR}/${PN}:"
#SRC_URI_append = " file://gpsd.service"
SRC_URI =+ "git://git.netmodule.intranet/nmsw/gpsd.git;protocol=ssh;user=gitea;branch=imu-integration"
SRC_URI_remove = "http://download.savannah.gnu.org/releases/gpsd/gpsd-3.17.tar.gz"
# overwrite default gpsd.service file with our configuration
SRCREV = "${AUTOREV}"
S = "${WORKDIR}/git"
TTY_DEVICE = "/dev/ttyS3"
USBAUTO_STATE = "false"

View File

@ -0,0 +1,2 @@
[device]
wifi.scan-rand-mac-address=no

View File

@ -1,12 +1,16 @@
PACKAGECONFIG_append = " modemmanager bluez5"
FILESEXTRAPATHS_append := "${THISDIR}/${PN}"
SRC_URI_append = " file://system-connections.tar.gz"
SRC_URI_append = "\
file://system-connections.tar.gz \
file://NetworkManager.conf \
"
do_install_append() {
rm -rf ${D}/run ${D}${localstatedir}/run
mkdir -p ${D}${sysconfdir}/NetworkManager/system-connections
install -m 0600 ${WORKDIR}/system-connections/* ${D}${sysconfdir}/NetworkManager/system-connections/
install -m 0644 ${WORKDIR}/NetworkManager.conf ${D}${sysconfdir}/NetworkManager/
}

View File

@ -5,6 +5,7 @@ Requires=bluetooth.target
[Service]
Type=forking
ExecStartPre=/bin/sleep 10
ExecStartPre=-/bin/sh -c "/bin/echo 100 > /sys/class/gpio/export"
ExecStartPre=-/bin/sh -c "/bin/echo out > /sys/class/gpio/gpio100/direction"
ExecStartPre=/bin/sh -c "/bin/echo 1 > /sys/class/gpio/gpio100/value"

View File

@ -1,39 +0,0 @@
#!/usr/bin/env python3
import serial
import sys
import time
MAX_TRY = 5
tries = 0
ser = serial.Serial('/dev/ttyACM0', 115200, timeout=0.5)
def execute_and_check(cmd):
global tries
ser.flushInput()
ser.write(cmd)
ser.write(b'\r')
s = ser.read_until(b'OK')
if b'OK' not in s:
print("Failed cmd : " + str(cmd))
print("Output: " + str(s))
tries += 1
if tries < MAX_TRY:
time.sleep(1)
execute_and_check(cmd)
else:
sys.exit(-1)
tries = 0
print("Setting up bridge mode")
execute_and_check(b'AT+UBMCONF=2')
print("Setting up USB mode to ECM")
execute_and_check(b'AT+UUSBCONF=2,"ECM",0')
print("Resetting modem")
ser.write(b'AT+CFUN=16\r')

View File

@ -1,11 +0,0 @@
[Unit]
Before=ModemManager.service
[Service]
Type=oneshot
ExecStart=/bin/bash -c "ifconfig wwan0 && { echo 'already configured'; exit 0; };/usr/bin/ublox-config.py;"
[Install]
WantedBy=ModemManager.service

View File

@ -0,0 +1,89 @@
#!/usr/bin/env python3
import serial
import os
import time
import re
CONF_PATH = '/run/modem'
def usb_profile_parser(output):
x = re.search('UUSBCONF:\s\d,"(.*)",', output)
return x.group(1)
def mode_parser(output):
x = re.search('UBMCONF:\s(\d)', output)
mode = int(x.group(1))
if mode == 1:
return "Router"
elif mode == 2:
return "Bridge"
else:
return "unsupported"
def apn_parser(output):
x = re.search('","(.*)",', output)
return x.group(1)
def default_parser(output):
x = re.search('(.*)\n.*\nOK',output)
return x.group(1)
def execute_command(ser, cmd):
while True:
try:
ser.flushInput()
ser.write(cmd)
ser.write(b'\r')
s = ser.read_until(b'OK')
if(len(s.decode('utf-8')) < 4): # Avoid empty response just after reset
continue
break
except Exception as e:
print("Exception : " + str(e))
time.sleep(1)
continue
return s
def read_config(ser, config_file, full_config_file, cmd, label='', parser=default_parser):
s = execute_command(ser, cmd)
if s is None:
print('Failed to execute command : ' + str(cmd))
return
full_conf = label + '\n' + s.decode('utf-8').strip("OK")
conf = (label + ':').ljust(20) + parser(s.decode('utf-8')) + '\n'
full_config_file.write(full_conf)
config_file.write(conf)
def dump_modem_config(ser):
os.makedirs(CONF_PATH, exist_ok=True)
full_config_file = open(CONF_PATH + '/modem-at.config', 'w')
config_file = open(CONF_PATH + '/modem.config', 'w')
read_config(ser, config_file, full_config_file, b'AT+CGMI', 'VendorID')
read_config(ser, config_file, full_config_file, b'AT+CGMM', 'ModelID')
read_config(ser, config_file, full_config_file, b'AT+CGMR', 'Firmware')
full_config_file.write('-' * 80 + '\n' * 2)
read_config(ser, config_file, full_config_file, b'AT+UCGDFLT?', 'Default APN', apn_parser)
read_config(ser, config_file, full_config_file, b'AT+UBMCONF?', 'Mode', mode_parser)
read_config(ser, config_file, full_config_file, b'AT+UUSBCONF?', 'USBprofile', usb_profile_parser)
def get_usb_profile(ser):
s = execute_command(ser, b'AT+UUSBCONF?')
if s is None:
print('Failed to get UUSBCONF')
return None
return usb_profile_parser(s.decode('utf-8'))
def get_mode(ser):
s = execute_command(ser, b'AT+UBMCONF?')
if s is None:
print('Failed to get UBMCONF')
return None
return mode_parser(s.decode('utf-8'))

View File

@ -0,0 +1,19 @@
#
# Select the SIM card to be used by the modem
# This file is part of ublox-gsm-config service
#
# auto: The script will detect if a physical SIM card is
# present and switch to eSIM if it is not the case
# main: Use the physical SIM card on the main board
# esim: Use the eSIM of the main bard
# ui-top: Use the SIM card that is on top of the User Interface
# ui-btm: Use the SIM card that is on the bottom of the User Interface
#
[default]
#SIM=esim
#SIM=main
#SIM=ui-top
#SIM=ui-btm
SIM=auto

View File

@ -0,0 +1,195 @@
#!/usr/bin/env python3
import serial
import sys
import time
import os
import configparser
import gpiod
config_dump = __import__("modem-config-dump")
SERIAL_DEV = '/dev/ttyACM0'
WWAN_DEV = '/sys/class/net/wwan0'
SIM_CONFIG = '/etc/sim.conf'
APN_CONFIG = '/etc/apn.conf'
def execute_and_check(ser, cmd):
tries = 0
MAX_TRY = 5
ser.flushInput()
ser.write(cmd)
ser.write(b'\r')
s = ser.read_until(b'OK')
if b'OK' not in s:
print("Failed cmd : " + str(cmd))
print("Output: " + str(s))
tries += 1
if tries < MAX_TRY:
time.sleep(1)
execute_and_check(ser, cmd)
else:
sys.exit(-1)
tries = 0
def switch_sim():
line = gpiod.find_line('SIM_SW')
line.request(consumer='ublox-config', type=gpiod.LINE_REQ_DIR_OUT)
line.set_value(0)
def sim_present(ser):
cmd = b'AT+CCID?'
while True:
try:
ser.flushInput()
ser.write(cmd)
ser.write(b'\r')
s = ser.read_until(b'OK')
if b'ERROR' in s:
return False
elif b'OK' in s:
return True
except Exception as e:
print("Exception : " + str(e))
time.sleep(1)
return s
def check_sim_presence(ser):
if sim_present(ser):
print("SIM present")
return False
else:
print("no SIM card, switching to eSIM")
switch_sim()
return True
def sim_config(ser):
config = configparser.ConfigParser()
config.read(SIM_CONFIG)
sim = config.get('default', 'SIM')
print(sim)
if sim == 'auto':
return check_sim_presence(ser)
elif sim == 'esim' or sim == 'ui-top':
switch_sim()
return True
# ui-btm and main are default
return False
def apn_setup(ser):
if not os.path.exists(APN_CONFIG):
print('No APN configured')
return
config = configparser.ConfigParser()
config.read(APN_CONFIG)
try:
apn = config.get('default', 'apn')
except:
print('apn.conf malformed : no apn found\n')
return
try:
user = '"' + config.get('default', 'user') + '"'
try:
password = '"' + config.get('default', 'password') + '"'
except:
print("No password for APN")
password = 'NULL'
except:
print("No user for APN")
user = 'NULL'
password = 'NULL'
if not apn:
return
auth = '1' if user is not 'NULL' else '0'
print("Switching to airplane mode")
execute_and_check(ser, b'AT+CFUN=4\r')
print("Configuring default ctx")
cmd = 'AT+UCGDFLT=0,"IP","' + str(apn) + '",0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,' + auth + ',' + str(user) + ',' + str(password) + ',""\r'
execute_and_check(ser, bytes(cmd, 'utf8'))
print("Full functionality mode")
execute_and_check(ser, b'AT+CFUN=1\r')
def reset_modem(ser):
print("Resetting modem")
ser.write(b'AT+CFUN=16\r')
ser.close()
while os.path.exists(SERIAL_DEV):
time.sleep(1)
while not os.path.exists(SERIAL_DEV):
time.sleep(1)
return serial.Serial(SERIAL_DEV, 115200, timeout=0.5)
def factory_reset():
print('factory reset the modem')
if not os.path.exists(SERIAL_DEV):
print('serial interface is not available, abort')
return -1
ser = serial.Serial(SERIAL_DEV, 115200, timeout=0.5)
execute_and_check(ser, b'AT+UFACTORY=2,1')
reset_modem(ser)
def poweroff(gpio):
print('poweroff')
if not os.path.exists(SERIAL_DEV):
print('serial interface is not available')
gpio.set_value(0)
return -1
ser = serial.Serial(SERIAL_DEV, 115200, timeout=0.5)
ser.write(b'AT+CPWROFF\r')
ser.close()
time.sleep(7.5)
gpio.set_value(0)
def help():
print('Usage : {} [stop|factory-reset]'.format(sys.argv[0]))
def main():
line = gpiod.find_line('GSM_SUP_EN')
line.request(consumer='ublox-config', type=gpiod.LINE_REQ_DIR_OUT)
if len(sys.argv) == 2:
if sys.argv[1] == 'stop':
return poweroff(line)
elif sys.argv[1] == 'factory-reset':
return factory_reset()
else:
return help()
# Power on
line.set_value(1)
# Wait on device
while not os.path.exists(SERIAL_DEV):
time.sleep(1)
ser = serial.Serial(SERIAL_DEV, 115200, timeout=0.5)
rst = False
if 'Bridge' != config_dump.get_mode(ser):
print("Setting up bridge mode")
execute_and_check(ser, b'AT+UBMCONF=2')
rst = True
if 'ECM' != config_dump.get_usb_profile(ser):
print("Setting up USB mode to ECM")
execute_and_check(ser, b'AT+UUSBCONF=2,"ECM",0')
rst = True
rst = sim_config(ser) or rst
if rst:
ser = reset_modem(ser)
apn_setup(ser)
config_dump.dump_modem_config(ser)
ser.close()
if __name__ == '__main__':
main()

View File

@ -0,0 +1,15 @@
[Unit]
Description=ublox GSM Modem configuration
Before=ModemManager.service
[Service]
Type=oneshot
ExecStart=/usr/bin/ublox-gsm-config
ExecStop=/usr/bin/ublox-gsm-config stop
RemainAfterExit=yes
TimeoutStopSec=20
[Install]
RequiredBy=ModemManager.service

View File

@ -0,0 +1,48 @@
SUMMARY = "Ublox gsm configuration"
DESCRIPTION = "Configure ublox gsm modem on first boot"
AUTHOR = "Alexandre Bard"
SECTION = "connectivity"
LICENSE = "GPLv2+"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"
PR = "r2"
RDEPENDS_${PN}="python3-pyserial"
inherit systemd python3-dir
SRC_URI = " \
file://ublox-gsm-config.service \
file://ublox-gsm-config.py \
file://modem-config-dump.py \
file://sim.conf \
"
S = "${WORKDIR}"
INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
SYSTEMD_SERVICE_${PN} = "ublox-gsm-config.service"
SYSTEMD_AUTO_ENABLE ?= "enable"
FILES_${PN}_append = " \
/lib \
/usr \
"
do_install () {
install -d ${D}${systemd_unitdir}/system/
install -m 0644 ublox-gsm-config.service ${D}${systemd_unitdir}/system/
install -d ${D}/usr/bin
install -m 0755 ublox-gsm-config.py ${D}/usr/bin/ublox-gsm-config
install -d ${D}${PYTHON_SITEPACKAGES_DIR}
install -m 0755 modem-config-dump.py ${D}${PYTHON_SITEPACKAGES_DIR}/
install -d ${D}/etc
install -m 0644 sim.conf ${D}/etc/
}

View File

@ -2,9 +2,8 @@
"tag_list": "/etc/bd/bd.json",
"eeprom": [
{ "path": "/sys/bus/i2c/devices/1-0050/eeprom", "valid_bds": [
{"name": "board", "start": 0, "size": 1024},
{"name": "platform", "start": 512, "size": 512},
{"name": "settings", "start": 1536, "size": 512}
{"name": "board", "start": 0, "size": 512},
{"name": "product", "start": 512, "size": 512}
]
}
]

View File

@ -3,7 +3,7 @@
"eeprom": [
{ "path": "/sys/bus/i2c/devices/2-0050/eeprom", "valid_bds": [
{"name": "board", "start": 0, "size": 1024},
{"name": "platform", "start": 512, "size": 512},
{"name": "platform", "start": 1024, "size": 512},
{"name": "settings", "start": 1536, "size": 512}
]
}

View File

@ -3,7 +3,7 @@
"eeprom": [
{ "path": "/sys/bus/i2c/devices/0-0050/eeprom", "valid_bds": [
{"name": "board", "start": 0, "size": 1024},
{"name": "platform", "start": 512, "size": 512},
{"name": "platform", "start": 1024, "size": 512},
{"name": "settings", "start": 1536, "size": 512}
]
}

View File

@ -155,10 +155,10 @@ class _BdRaw:
j = 0
self.tlvs = []
while i < self.buffer_len + 8:
# Zero means end of bd
# Zero or 0xffff means end of bd
tag = self._get_hw(data[i:i + 2])
i += 2
if tag == 0:
if tag == 0 or tag == 0xffff:
i -= 2
break
length = self._get_hw(data[i:i + 2])
@ -175,7 +175,7 @@ class _BdRaw:
data_length = self._read_binary(data)
if self.checksum != 0:
if self.checksum != 0 and self.checksum != 0xffff:
self._verify_checksum(data[8:data_length], self.checksum)
else:
self.is_writable = True

View File

@ -10,7 +10,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=d7810fab7487fb0aad327b76f1be7cd7"
BRANCH_NAME = "${@'${MACHINE}'.split('-')[-1]}"
SRC_URI = "git://git.netmodule.intranet/yoctoproject/linux-netmodule.git;protocol=ssh;user=gitea;branch=4.14/standard/${BRANCH_NAME}"
SRCREV ?= "${AUTOREV}"
PV ?= "4.14.77-${SRCPV}"
PV ?= "4.14.y-${SRCPV}"
PR = "r0"
@ -43,6 +43,24 @@ do_install_append(){
cp Module.symvers ${STAGING_KERNEL_BUILDDIR}/
}
# NRHW18
do_install_append_armada-385-nrhw18() {
ln -s devicetree-${DTB_SYMLINK_NAME}.dtb ${D}/${KERNEL_IMAGEDEST}/armada-385-nbhw18-prod4.dtb
}
# MEK
do_configure_prepend_imx8-mek() {
install -d ${B}
mkdir -p ${B}
cp ${S}/arch/arm64/configs/defconfig ${B}/.config
echo "CONFIG_BLK_DEV_RAM=y" >> ${B}/.config
echo "CONFIG_BLK_DEV_RAM_COUNT=1" >> ${B}/.config
echo "CONFIG_BLK_DEV_RAM_SIZE=131072" >> ${B}/.config
echo "CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024" >> ${B}/.config
echo "CONFIG_INITRAMFS_COMPRESSION_GZIP=y" >> ${B}/.config
}
EXTRA_OEMAKE_append_imx8-mek = " ARCH=arm64"
KERNEL_EXTRA_ARGS_append_imx8-mek += "LOADADDR=${UBOOT_ENTRYPOINT}"

View File

@ -0,0 +1,17 @@
require recipes-support/libgpiod/libgpiod.inc
DEPENDS += "autoconf-archive-native"
SRC_URI[md5sum] = "34a9972f2f4e9c32fa940301301b007d"
SRC_URI[sha256sum] = "b6b9079c933f7c8524815437937dda6b795a16141bca202a9eec70ba5844b5ba"
PACKAGECONFIG[cxx] = "--enable-bindings-cxx,--disable-bindings-cxx"
PACKAGECONFIG[python3] = "--enable-bindings-python,--disable-bindings-python,python3,python3-core"
inherit ${@bb.utils.contains('PACKAGECONFIG', 'python3', 'python3native', '', d)}
PACKAGES =+ "${PN}-python"
FILES_${PN}-python = "${PYTHON_SITEPACKAGES_DIR}"
RRECOMMENDS_PYTHON = "${@bb.utils.contains('PACKAGECONFIG', 'python3', '${PN}-python', '',d)}"
RRECOMMENDS_${PN} += "${RRECOMMENDS_PYTHON}"

5
wic/sdimage-sota-mek.wks Normal file
View File

@ -0,0 +1,5 @@
# short-description: Create OTA-enabled SD card image
# long-description: Creates a partitioned SD card image with OSTree
part u-boot --source rawcopy --sourceparams="file=flash.bin" --ondisk mmcblk --no-table --align 32
part / --source otaimage --ondisk mmcblk --fstype=ext4 --align 4096