nerves-networking / vintage_net_mobile

Mobile networking for VintageNet
Apache License 2.0
27 stars 11 forks source link

Configuring BG96 module over UART #219

Open gworkman opened 1 year ago

gworkman commented 1 year ago

I'm trying to get a BG96 module running with a RPi 0 2W via a UART. This is their Mini PCIe module, mounted on the Sixfab Base Hat. After fiddling with the IEx console output settings, I am able to query the module using Circuits.UART and get a response:

iex(3)> {:ok, pid} = Circuits.UART.start_link()
{:ok, #PID<0.1175.0>}
iex(4)> Circuits.UART.open(pid, "/dev/ttyAMA0", speed: 115200)
:ok
iex(11)> Circuits.UART.write(pid, "AT\r\n")
:ok
iex(12)> flush
{:circuits_uart, "/dev/ttyAMA0", "AT\r\r\nOK\r"}
{:circuits_uart, "/dev/ttyAMA0", "\n"}
:ok

However, I'm unable to get VintageNet to configure the network interface. I'm not sure why, either, as there are pretty much no logs. The following is the steps I've tried:

iex(23)> config =      %{
...(23)>        type: VintageNetMobile,
...(23)>        vintage_net_mobile: %{
...(23)>          modem: VintageNetMobile.Modem.QuectelBG96,
...(23)>          at_tty: "ttyAMA0",
...(23)>          ppp_tty: "ttyAMA0",
...(23)>          service_providers: [
...(23)>            %{apn: "the_apn"}
...(23)>          ]
...(23)>        }
...(23)>      }

iex(24)> VintageNet.configure("ppp0", config, persist: true)

18:17:48.108 [debug] VintageNet(ppp0): :configured -> configure (VintageNetMobile)
:ok

The only log generated from this is as shown: 18:17:48.108 [debug] VintageNet(ppp0): :configured -> configure (VintageNetMobile)

Following the info in ExChat.ex, I tried the debugging steps:

iex(20)> require Logger
Logger
iex(21)> RingLogger.attach
:ok
iex(22)> tty_name = "ttyAMA0"
"ttyAMA0"
iex(23)> VintageNetMobile.ExChat.register(tty_name, "+", fn m -> Logger.debug("Got: " <> inspect(m)) end)
** (exit) exited in: GenServer.call(:"Elixir.VintageNetMobile.ExChat.ttyAMA0", {:register, "+", #Function<42.105768164/1 in :erl_eval.expr/6>}, 5000)
    ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
    (elixir 1.15.4) lib/gen_server.ex:1063: GenServer.call/3
    iex:23: (file)

This indicates to me that VintageNet isn't starting a process correctly? Or something, kinda stumped now.

The following is output from mix nerves.info, and asdf list

❯ asdf list
elixir
 *1.15.4-otp-26
erlang
 *26.0.2
|nerves| Environment Package List

  Pkg:         custom_rpi0_2w
  Vsn:         1.24.1
  Type:        system
  BuildRunner: {Nerves.Artifact.BuildRunners.Docker, [make_args: ["source", "all", "legal-info"]]}

  Pkg:         nerves_system_br
  Vsn:         1.24.1
  Type:        system_platform
  BuildRunner: {nil, []}

  Pkg:         nerves_toolchain_aarch64_nerves_linux_gnu
  Vsn:         1.8.0
  Type:        toolchain
  BuildRunner: {Nerves.Artifact.BuildRunners.Local, []}

  Pkg:         nerves_toolchain_ctng
  Vsn:         1.9.3
  Type:        toolchain_platform
  BuildRunner: {nil, []}

|nerves| Loadpaths Start

Nerves environment
  MIX_TARGET:   custom_rpi0_2w
  MIX_ENV:      dev

|nerves| Environment Variable List
  target:     custom_rpi0_2w
  toolchain:  /Users/gus.workman/.nerves/artifacts/nerves_toolchain_aarch64_nerves_linux_gnu-darwin_arm-1.8.0
  system:     /Users/gus.workman/.nerves/artifacts/nautic_os-portable-1.24.1
  app:        .

|nerves| Loadpaths End

Nerves:           1.10.4
Nerves Bootstrap: 1.12.1
Elixir:           1.15.4
|nerves| Info End

Any suggestions?

gworkman commented 1 year ago

Here's my linux-6.1.defconfig:

CONFIG_LOCALVERSION="-v8"
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_SYSVIPC=y
CONFIG_POSIX_MQUEUE=y
CONFIG_NO_HZ=y
CONFIG_HIGH_RES_TIMERS=y
CONFIG_PREEMPT=y
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
CONFIG_MEMCG=y
CONFIG_BLK_CGROUP=y
CONFIG_RT_GROUP_SCHED=y
CONFIG_CGROUP_PIDS=y
CONFIG_CGROUP_FREEZER=y
CONFIG_CPUSETS=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CGROUP_CPUACCT=y
CONFIG_NAMESPACES=y
# CONFIG_UTS_NS is not set
# CONFIG_IPC_NS is not set
# CONFIG_PID_NS is not set
# CONFIG_NET_NS is not set
CONFIG_SCHED_AUTOGROUP=y
CONFIG_EMBEDDED=y
# CONFIG_PERF_EVENTS is not set
CONFIG_PROFILING=y
CONFIG_ARCH_BCM=y
CONFIG_ARCH_BCM2835=y
# CONFIG_CAVIUM_ERRATUM_22375 is not set
# CONFIG_CAVIUM_ERRATUM_23154 is not set
# CONFIG_CAVIUM_ERRATUM_27456 is not set
CONFIG_NR_CPUS=4
CONFIG_HZ_1000=y
CONFIG_COMPAT=y
CONFIG_ARMV8_DEPRECATED=y
CONFIG_SWP_EMULATION=y
CONFIG_CP15_BARRIER_EMULATION=y
CONFIG_SETEND_EMULATION=y
CONFIG_RANDOMIZE_BASE=y
CONFIG_CMDLINE="console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait"
# CONFIG_EFI is not set
# CONFIG_SUSPEND is not set
CONFIG_PM=y
CONFIG_CPU_IDLE=y
CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_STAT=y
CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=y
CONFIG_CPU_FREQ_GOV_USERSPACE=y
CONFIG_CPU_FREQ_GOV_ONDEMAND=y
CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y
CONFIG_CPUFREQ_DT=y
CONFIG_ARM_RASPBERRYPI_CPUFREQ=y
CONFIG_KPROBES=y
CONFIG_JUMP_LABEL=y
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
CONFIG_MODVERSIONS=y
CONFIG_MODULE_SRCVERSION_ALL=y
CONFIG_PARTITION_ADVANCED=y
# CONFIG_EFI_PARTITION is not set
# CONFIG_MQ_IOSCHED_DEADLINE is not set
# CONFIG_MQ_IOSCHED_KYBER is not set
CONFIG_SLAB_FREELIST_RANDOM=y
# CONFIG_COMPAT_BRK is not set
CONFIG_CMA=y
CONFIG_NET=y
CONFIG_PACKET=y
CONFIG_UNIX=y
CONFIG_INET=y
CONFIG_IP_MULTICAST=y
CONFIG_IP_ADVANCED_ROUTER=y
CONFIG_IP_MULTIPLE_TABLES=y
# CONFIG_INET_DIAG is not set
# CONFIG_IPV6_SIT is not set
CONFIG_CFG80211=m
CONFIG_MAC80211=m
CONFIG_MAC80211_MESH=y
CONFIG_RFKILL=y
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
CONFIG_RASPBERRYPI_FIRMWARE=y
CONFIG_OF_CONFIGFS=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_RAM=y
CONFIG_EEPROM_AT24=m
CONFIG_NETDEVICES=y
CONFIG_WIREGUARD=m
CONFIG_TUN=m
# CONFIG_NET_VENDOR_AMAZON is not set
# CONFIG_NET_VENDOR_ARC is not set
# CONFIG_NET_VENDOR_BROADCOM is not set
# CONFIG_NET_VENDOR_EZCHIP is not set
# CONFIG_NET_VENDOR_HISILICON is not set
# CONFIG_NET_VENDOR_INTEL is not set
# CONFIG_NET_VENDOR_MARVELL is not set
# CONFIG_NET_VENDOR_MICREL is not set
# CONFIG_NET_VENDOR_MICROCHIP is not set
# CONFIG_NET_VENDOR_NATSEMI is not set
# CONFIG_NET_VENDOR_NETRONOME is not set
# CONFIG_NET_VENDOR_QUALCOMM is not set
# CONFIG_NET_VENDOR_RENESAS is not set
# CONFIG_NET_VENDOR_ROCKER is not set
# CONFIG_NET_VENDOR_SAMSUNG is not set
# CONFIG_NET_VENDOR_SEEQ is not set
# CONFIG_NET_VENDOR_SMSC is not set
# CONFIG_NET_VENDOR_STMICRO is not set
# CONFIG_NET_VENDOR_SYNOPSYS is not set
# CONFIG_NET_VENDOR_VIA is not set
# CONFIG_NET_VENDOR_WIZNET is not set
CONFIG_PPP=m
CONFIG_PPP_BSDCOMP=m
CONFIG_PPP_DEFLATE=m
CONFIG_PPP_FILTER=y
CONFIG_PPP_MPPE=m
CONFIG_PPP_MULTILINK=y
CONFIG_PPP_ASYNC=m
CONFIG_PPP_SYNC_TTY=m
CONFIG_USB_USBNET=y
CONFIG_USB_NET_CDC_NCM=m
CONFIG_USB_NET_HUAWEI_CDC_NCM=m
CONFIG_USB_NET_QMI_WWAN=m
# CONFIG_WLAN_VENDOR_ADMTEK is not set
# CONFIG_WLAN_VENDOR_ATH is not set
# CONFIG_WLAN_VENDOR_ATMEL is not set
CONFIG_BRCMFMAC=m
# CONFIG_WLAN_VENDOR_CISCO is not set
# CONFIG_WLAN_VENDOR_INTEL is not set
# CONFIG_WLAN_VENDOR_INTERSIL is not set
# CONFIG_WLAN_VENDOR_MARVELL is not set
# CONFIG_WLAN_VENDOR_MEDIATEK is not set
# CONFIG_WLAN_VENDOR_MICROCHIP is not set
# CONFIG_WLAN_VENDOR_PURELIFI is not set
# CONFIG_WLAN_VENDOR_RALINK is not set
# CONFIG_WLAN_VENDOR_REALTEK is not set
# CONFIG_WLAN_VENDOR_RSI is not set
# CONFIG_WLAN_VENDOR_SILABS is not set
# CONFIG_WLAN_VENDOR_ST is not set
# CONFIG_WLAN_VENDOR_TI is not set
# CONFIG_WLAN_VENDOR_ZYDAS is not set
# CONFIG_WLAN_VENDOR_QUANTENNA is not set
# CONFIG_INPUT_LEDS is not set
CONFIG_INPUT_EVDEV=y
# CONFIG_INPUT_KEYBOARD is not set
# CONFIG_INPUT_MOUSE is not set
CONFIG_INPUT_JOYSTICK=y
CONFIG_JOYSTICK_RPISENSE=m
CONFIG_INPUT_TOUCHSCREEN=y
CONFIG_TOUCHSCREEN_RASPBERRYPI_FW=m
# CONFIG_SERIO is not set
CONFIG_BRCM_CHAR_DRIVERS=y
CONFIG_BCM_VCIO=y
CONFIG_BCM2835_DEVGPIOMEM=y
# CONFIG_LEGACY_PTYS is not set
CONFIG_SERIAL_8250=y
# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
CONFIG_SERIAL_8250_CONSOLE=y
# CONFIG_SERIAL_8250_DMA is not set
CONFIG_SERIAL_8250_NR_UARTS=1
CONFIG_SERIAL_8250_RUNTIME_UARTS=0
CONFIG_SERIAL_8250_EXTENDED=y
CONFIG_SERIAL_8250_SHARE_IRQ=y
CONFIG_SERIAL_8250_BCM2835AUX=y
CONFIG_SERIAL_OF_PLATFORM=y
CONFIG_SERIAL_AMBA_PL011=y
CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
CONFIG_TTY_PRINTK=y
CONFIG_HW_RANDOM=y
CONFIG_I2C=y
CONFIG_I2C_CHARDEV=y
CONFIG_I2C_MUX=m
CONFIG_I2C_MUX_PINCTRL=m
CONFIG_I2C_BCM2708=y
CONFIG_I2C_BCM2835=y
CONFIG_SPI=y
CONFIG_SPI_BCM2835=y
CONFIG_SPI_BCM2835AUX=y
CONFIG_SPI_SPIDEV=y
CONFIG_GPIO_SYSFS=y
CONFIG_GPIO_BCM_VIRT=y
CONFIG_W1=m
CONFIG_W1_MASTER_GPIO=m
CONFIG_W1_SLAVE_THERM=m
CONFIG_POWER_RESET_GPIO=y
CONFIG_RPI_POE_POWER=m
CONFIG_SENSORS_RASPBERRYPI_HWMON=m
CONFIG_THERMAL=y
CONFIG_BCM2711_THERMAL=y
CONFIG_WATCHDOG=y
CONFIG_WATCHDOG_NOWAYOUT=y
CONFIG_BCM2835_WDT=y
CONFIG_BCMA=m
CONFIG_MFD_SYSCON=y
CONFIG_REGULATOR=y
CONFIG_REGULATOR_FIXED_VOLTAGE=y
CONFIG_REGULATOR_AD5398=m
CONFIG_REGULATOR_GPIO=y
CONFIG_REGULATOR_RASPBERRYPI_TOUCHSCREEN_ATTINY=m
CONFIG_MEDIA_SUPPORT=m
# CONFIG_DVB_NET is not set
# CONFIG_DVB_DYNAMIC_MINORS is not set
# CONFIG_RADIO_ADAPTERS is not set
CONFIG_V4L_PLATFORM_DRIVERS=y
CONFIG_VIDEO_BCM2835_UNICAM=m
CONFIG_VIDEO_IMX219=m
CONFIG_VIDEO_IMX708=m
CONFIG_VIDEO_OV5647=m
CONFIG_VIDEO_AD5398=m
CONFIG_VIDEO_DW9807_VCM=m
CONFIG_VIDEO_IMX477=m
# CONFIG_CXD2880_SPI_DRV is not set
# CONFIG_MEDIA_TUNER_E4000 is not set
# CONFIG_MEDIA_TUNER_FC0011 is not set
# CONFIG_MEDIA_TUNER_FC0012 is not set
# CONFIG_MEDIA_TUNER_FC0013 is not set
# CONFIG_MEDIA_TUNER_FC2580 is not set
# CONFIG_MEDIA_TUNER_IT913X is not set
# CONFIG_MEDIA_TUNER_M88RS6000T is not set
# CONFIG_MEDIA_TUNER_MAX2165 is not set
# CONFIG_MEDIA_TUNER_MC44S803 is not set
# CONFIG_MEDIA_TUNER_MSI001 is not set
# CONFIG_MEDIA_TUNER_MT2060 is not set
# CONFIG_MEDIA_TUNER_MT2063 is not set
# CONFIG_MEDIA_TUNER_MT20XX is not set
# CONFIG_MEDIA_TUNER_MT2131 is not set
# CONFIG_MEDIA_TUNER_MT2266 is not set
# CONFIG_MEDIA_TUNER_MXL301RF is not set
# CONFIG_MEDIA_TUNER_MXL5005S is not set
# CONFIG_MEDIA_TUNER_MXL5007T is not set
# CONFIG_MEDIA_TUNER_QM1D1B0004 is not set
# CONFIG_MEDIA_TUNER_QM1D1C0042 is not set
# CONFIG_MEDIA_TUNER_QT1010 is not set
# CONFIG_MEDIA_TUNER_R820T is not set
# CONFIG_MEDIA_TUNER_SI2157 is not set
# CONFIG_MEDIA_TUNER_SIMPLE is not set
# CONFIG_MEDIA_TUNER_TDA18212 is not set
# CONFIG_MEDIA_TUNER_TDA18218 is not set
# CONFIG_MEDIA_TUNER_TDA18250 is not set
# CONFIG_MEDIA_TUNER_TDA18271 is not set
# CONFIG_MEDIA_TUNER_TDA827X is not set
# CONFIG_MEDIA_TUNER_TDA8290 is not set
# CONFIG_MEDIA_TUNER_TDA9887 is not set
# CONFIG_MEDIA_TUNER_TEA5761 is not set
# CONFIG_MEDIA_TUNER_TEA5767 is not set
# CONFIG_MEDIA_TUNER_TUA9001 is not set
# CONFIG_MEDIA_TUNER_XC2028 is not set
# CONFIG_MEDIA_TUNER_XC4000 is not set
# CONFIG_MEDIA_TUNER_XC5000 is not set
# CONFIG_DVB_MXL5XX is not set
# CONFIG_DVB_STB0899 is not set
# CONFIG_DVB_STB6100 is not set
# CONFIG_DVB_STV090x is not set
# CONFIG_DVB_STV0910 is not set
# CONFIG_DVB_STV6110x is not set
# CONFIG_DVB_STV6111 is not set
# CONFIG_DVB_DRXK is not set
# CONFIG_DVB_MN88472 is not set
# CONFIG_DVB_MN88473 is not set
# CONFIG_DVB_SI2165 is not set
# CONFIG_DVB_TDA18271C2DD is not set
# CONFIG_DVB_CX24110 is not set
# CONFIG_DVB_CX24116 is not set
# CONFIG_DVB_CX24117 is not set
# CONFIG_DVB_CX24120 is not set
# CONFIG_DVB_CX24123 is not set
# CONFIG_DVB_DS3000 is not set
# CONFIG_DVB_MB86A16 is not set
# CONFIG_DVB_MT312 is not set
# CONFIG_DVB_S5H1420 is not set
# CONFIG_DVB_SI21XX is not set
# CONFIG_DVB_STB6000 is not set
# CONFIG_DVB_STV0288 is not set
# CONFIG_DVB_STV0299 is not set
# CONFIG_DVB_STV0900 is not set
# CONFIG_DVB_STV6110 is not set
# CONFIG_DVB_TDA10071 is not set
# CONFIG_DVB_TDA10086 is not set
# CONFIG_DVB_TDA8083 is not set
# CONFIG_DVB_TDA8261 is not set
# CONFIG_DVB_TDA826X is not set
# CONFIG_DVB_TS2020 is not set
# CONFIG_DVB_TUA6100 is not set
# CONFIG_DVB_TUNER_CX24113 is not set
# CONFIG_DVB_TUNER_ITD1000 is not set
# CONFIG_DVB_VES1X93 is not set
# CONFIG_DVB_ZL10036 is not set
# CONFIG_DVB_ZL10039 is not set
# CONFIG_DVB_CX22700 is not set
# CONFIG_DVB_CX22702 is not set
# CONFIG_DVB_CXD2820R is not set
# CONFIG_DVB_CXD2841ER is not set
# CONFIG_DVB_DIB3000MB is not set
# CONFIG_DVB_DIB3000MC is not set
# CONFIG_DVB_DIB7000M is not set
# CONFIG_DVB_DIB7000P is not set
# CONFIG_DVB_DIB9000 is not set
# CONFIG_DVB_DRXD is not set
# CONFIG_DVB_EC100 is not set
# CONFIG_DVB_L64781 is not set
# CONFIG_DVB_MT352 is not set
# CONFIG_DVB_NXT6000 is not set
# CONFIG_DVB_S5H1432 is not set
# CONFIG_DVB_SP887X is not set
# CONFIG_DVB_STV0367 is not set
# CONFIG_DVB_TDA10048 is not set
# CONFIG_DVB_TDA1004X is not set
# CONFIG_DVB_ZD1301_DEMOD is not set
# CONFIG_DVB_ZL10353 is not set
# CONFIG_DVB_CXD2880 is not set
# CONFIG_DVB_STV0297 is not set
# CONFIG_DVB_TDA10021 is not set
# CONFIG_DVB_TDA10023 is not set
# CONFIG_DVB_VES1820 is not set
# CONFIG_DVB_AU8522_DTV is not set
# CONFIG_DVB_AU8522_V4L is not set
# CONFIG_DVB_BCM3510 is not set
# CONFIG_DVB_LG2160 is not set
# CONFIG_DVB_LGDT3305 is not set
# CONFIG_DVB_LGDT330X is not set
# CONFIG_DVB_MXL692 is not set
# CONFIG_DVB_NXT200X is not set
# CONFIG_DVB_OR51132 is not set
# CONFIG_DVB_OR51211 is not set
# CONFIG_DVB_S5H1409 is not set
# CONFIG_DVB_S5H1411 is not set
# CONFIG_DVB_DIB8000 is not set
# CONFIG_DVB_MB86A20S is not set
# CONFIG_DVB_S921 is not set
# CONFIG_DVB_MN88443X is not set
# CONFIG_DVB_TC90522 is not set
# CONFIG_DVB_PLL is not set
# CONFIG_DVB_TUNER_DIB0070 is not set
# CONFIG_DVB_TUNER_DIB0090 is not set
# CONFIG_DVB_A8293 is not set
# CONFIG_DVB_AF9033 is not set
# CONFIG_DVB_ASCOT2E is not set
# CONFIG_DVB_ATBM8830 is not set
# CONFIG_DVB_HELENE is not set
# CONFIG_DVB_HORUS3A is not set
# CONFIG_DVB_ISL6405 is not set
# CONFIG_DVB_ISL6421 is not set
# CONFIG_DVB_ISL6423 is not set
# CONFIG_DVB_IX2505V is not set
# CONFIG_DVB_LGS8GL5 is not set
# CONFIG_DVB_LGS8GXX is not set
# CONFIG_DVB_LNBH25 is not set
# CONFIG_DVB_LNBH29 is not set
# CONFIG_DVB_LNBP21 is not set
# CONFIG_DVB_LNBP22 is not set
# CONFIG_DVB_M88RS2000 is not set
# CONFIG_DVB_TDA665x is not set
# CONFIG_DVB_DRX39XYJ is not set
# CONFIG_DVB_CXD2099 is not set
# CONFIG_DVB_SP2 is not set
CONFIG_DRM=m
CONFIG_DRM_LOAD_EDID_FIRMWARE=y
CONFIG_DRM_PANEL_RASPBERRYPI_TOUCHSCREEN=m
CONFIG_DRM_VC4=m
CONFIG_TINYDRM_REPAPER=m
CONFIG_FB=y
CONFIG_FB_BCM2708=y
CONFIG_FB_RPISENSE=m
CONFIG_BACKLIGHT_CLASS_DEVICE=m
CONFIG_BACKLIGHT_RPI=m
CONFIG_BACKLIGHT_GPIO=m
CONFIG_FRAMEBUFFER_CONSOLE=y
CONFIG_LOGO=y
# CONFIG_LOGO_LINUX_MONO is not set
# CONFIG_LOGO_LINUX_VGA16 is not set
CONFIG_SOUND=y
CONFIG_SND=m
# CONFIG_SND_SUPPORT_OLD_API is not set
CONFIG_SND_SEQUENCER=m
CONFIG_SND_ALOOP=m
CONFIG_SND_SOC=m
CONFIG_SND_BCM2835_SOC_I2S=m
CONFIG_SND_BCM2708_SOC_GOOGLEVOICEHAT_SOUNDCARD=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC=m
CONFIG_SND_SIMPLE_CARD=m
# CONFIG_HID_GENERIC is not set
CONFIG_USB=y
CONFIG_USB_DWC2=m
CONFIG_USB_SERIAL=m
CONFIG_USB_SERIAL_OPTION=m
CONFIG_NOP_USB_XCEIV=y
CONFIG_MMC=y
CONFIG_MMC_BLOCK_MINORS=32
CONFIG_MMC_BCM2835_MMC=y
CONFIG_MMC_BCM2835_DMA=y
CONFIG_MMC_BCM2835_SDHOST=y
CONFIG_MMC_SDHCI=y
CONFIG_MMC_SDHCI_PLTFM=y
CONFIG_NEW_LEDS=y
CONFIG_LEDS_CLASS=y
CONFIG_LEDS_GPIO=y
CONFIG_LEDS_TRIGGERS=y
CONFIG_LEDS_TRIGGER_TIMER=y
CONFIG_LEDS_TRIGGER_ONESHOT=y
CONFIG_LEDS_TRIGGER_HEARTBEAT=y
CONFIG_LEDS_TRIGGER_BACKLIGHT=y
CONFIG_LEDS_TRIGGER_CPU=y
CONFIG_LEDS_TRIGGER_GPIO=y
CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
CONFIG_LEDS_TRIGGER_TRANSIENT=y
CONFIG_LEDS_TRIGGER_INPUT=y
CONFIG_LEDS_TRIGGER_PANIC=y
CONFIG_LEDS_TRIGGER_PATTERN=y
CONFIG_RTC_CLASS=y
# CONFIG_RTC_HCTOSYS is not set
CONFIG_DMADEVICES=y
CONFIG_DMA_BCM2835=y
CONFIG_DMA_BCM2708=y
CONFIG_DMABUF_HEAPS=y
CONFIG_DMABUF_HEAPS_SYSTEM=y
CONFIG_DMABUF_HEAPS_CMA=y
# CONFIG_VHOST_MENU is not set
CONFIG_STAGING=y
CONFIG_STAGING_MEDIA=y
CONFIG_BCM2835_VCHIQ=y
CONFIG_SND_BCM2835=m
CONFIG_VIDEO_BCM2835=m
CONFIG_VIDEO_CODEC_BCM2835=m
CONFIG_VIDEO_ISP_BCM2835=m
CONFIG_CLK_RASPBERRYPI=y
CONFIG_MAILBOX=y
CONFIG_BCM2835_MBOX=y
# CONFIG_IOMMU_SUPPORT is not set
CONFIG_RASPBERRYPI_POWER=y
CONFIG_EXT4_FS=y
CONFIG_FANOTIFY=y
CONFIG_VFAT_FS=y
CONFIG_TMPFS=y
CONFIG_SQUASHFS=y
CONFIG_SQUASHFS_FILE_DIRECT=y
CONFIG_SQUASHFS_DECOMP_MULTI_PERCPU=y
CONFIG_PSTORE=y
CONFIG_PSTORE_CONSOLE=y
CONFIG_PSTORE_PMSG=y
CONFIG_PSTORE_RAM=y
# CONFIG_NETWORK_FILESYSTEMS is not set
CONFIG_NLS_DEFAULT="utf8"
CONFIG_NLS_CODEPAGE_437=y
CONFIG_NLS_CODEPAGE_850=y
CONFIG_NLS_ASCII=y
CONFIG_NLS_ISO8859_1=y
CONFIG_NLS_UTF8=y
CONFIG_LSM=""
CONFIG_CRYPTO_AES_ARM64_BS=m
# CONFIG_CRYPTO_HW is not set
CONFIG_CRC_ITU_T=m
CONFIG_CRC7=m
CONFIG_DMA_CMA=y
CONFIG_CMA_SIZE_MBYTES=5
CONFIG_PRINTK_TIME=y
CONFIG_PANIC_TIMEOUT=10

And the nerves_defconfig:

BR2_aarch64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
BR2_TOOLCHAIN_EXTERNAL_URL="https://github.com/nerves-project/toolchains/releases/download/v1.8.0/nerves_toolchain_aarch64_nerves_linux_gnu-linux_${shell uname -m}-1.8.0-E9F5B2A.tar.xz"
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="aarch64-nerves-linux-gnu"
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_19=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
# BR2_TOOLCHAIN_EXTERNAL_INET_RPC is not set
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_TOOLCHAIN_EXTERNAL_OPENMP=y
BR2_TAR_OPTIONS="--no-same-owner"
BR2_BACKUP_SITE="http://dl.nerves-project.org"
BR2_ENABLE_DEBUG=y
BR2_OPTIMIZE_2=y
BR2_GLOBAL_PATCH_DIR="${BR2_EXTERNAL_NERVES_PATH}/patches"
BR2_REPRODUCIBLE=y
BR2_ROOTFS_SKELETON_CUSTOM=y
BR2_ROOTFS_SKELETON_CUSTOM_PATH="${BR2_EXTERNAL_NERVES_PATH}/board/nerves-common/skeleton"
BR2_INIT_NONE=y
BR2_ROOTFS_DEVICE_TABLE="${BR2_EXTERNAL_NERVES_PATH}/board/nerves-common/device_table.txt"
BR2_ENABLE_LOCALE_WHITELIST="locale-archive"
BR2_GENERATE_LOCALE="en_US.UTF-8"
BR2_ROOTFS_OVERLAY="${BR2_EXTERNAL_NERVES_PATH}/board/nerves-common/rootfs_overlay ${NERVES_DEFCONFIG_DIR}/rootfs_overlay"
BR2_ROOTFS_POST_BUILD_SCRIPT="${NERVES_DEFCONFIG_DIR}/post-build.sh ${BR2_EXTERNAL_NERVES_PATH}/board/nerves-common/post-build.sh"
BR2_ROOTFS_POST_IMAGE_SCRIPT="${NERVES_DEFCONFIG_DIR}/post-createfs.sh"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="https://github.com/raspberrypi/linux/archive/refs/tags/1.20230405.tar.gz"
BR2_LINUX_KERNEL_PATCH="${NERVES_DEFCONFIG_DIR}/linux"
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="${NERVES_DEFCONFIG_DIR}/linux-6.1.defconfig"
BR2_LINUX_KERNEL_XZ=y
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="broadcom/bcm2710-rpi-3-b broadcom/bcm2710-rpi-cm3 broadcom/bcm2710-rpi-3-b-plus broadcom/bcm2710-rpi-zero-2-w"
BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
BR2_PACKAGE_BUSYBOX_CONFIG="${BR2_EXTERNAL_NERVES_PATH}/board/nerves-common/busybox.config"
BR2_PACKAGE_ALSA_UTILS=y
# BR2_PACKAGE_ALSA_UTILS_ALSAMIXER is not set
BR2_PACKAGE_ALSA_UTILS_AMIXER=y
BR2_PACKAGE_ALSA_UTILS_APLAY=y
BR2_PACKAGE_E2FSPROGS=y
# BR2_PACKAGE_E2FSPROGS_FSCK is not set
BR2_PACKAGE_RPI_FIRMWARE=y
BR2_PACKAGE_RPI_FIRMWARE_CUSTOM_VERSION="1.20230405"
BR2_PACKAGE_RPI_FIRMWARE_BOOTCODE_BIN=y
BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI=y
BR2_PACKAGE_RPI_FIRMWARE_VARIANT_PI_X=y
BR2_PACKAGE_PIGPIO=y
# BR2_PACKAGE_RNG_TOOLS_JITTERENTROPY_LIBRARY is not set
BR2_PACKAGE_RPI_USERLAND=y
BR2_PACKAGE_USB_MODESWITCH=y
# BR2_PACKAGE_ALSA_LIB_RAWMIDI is not set
# BR2_PACKAGE_ALSA_LIB_HWDEP is not set
# BR2_PACKAGE_ALSA_LIB_SEQ is not set
# BR2_PACKAGE_ALSA_LIB_ALISP is not set
# BR2_PACKAGE_ALSA_LIB_OLD_SYMBOLS is not set
BR2_PACKAGE_CA_CERTIFICATES=y
BR2_PACKAGE_LIBP11=y
BR2_PACKAGE_UNIXODBC=y
BR2_PACKAGE_DTC=y
BR2_PACKAGE_LIBCAMERA_V4L2=y
BR2_PACKAGE_LIBCAMERA_PIPELINE_RASPBERRYPI=y
BR2_PACKAGE_LIBCAMERA_APPS=y
BR2_PACKAGE_LIBMNL=y
BR2_PACKAGE_PPPD=y
BR2_PACKAGE_PPPD_FILTER=y
BR2_PACKAGE_WIRELESS_REGDB=y
BR2_PACKAGE_WPA_SUPPLICANT=y
BR2_PACKAGE_WPA_SUPPLICANT_AP_SUPPORT=y
BR2_PACKAGE_WPA_SUPPLICANT_MESH_NETWORKING=y
BR2_PACKAGE_WPA_SUPPLICANT_AUTOSCAN=y
BR2_PACKAGE_WPA_SUPPLICANT_HOTSPOT=y
BR2_PACKAGE_WPA_SUPPLICANT_DEBUG_SYSLOG=y
BR2_PACKAGE_WPA_SUPPLICANT_WPS=y
BR2_PACKAGE_WPA_SUPPLICANT_WPA3=y
BR2_PACKAGE_WPA_SUPPLICANT_CTRL_IFACE=y
# BR2_TARGET_ROOTFS_TAR is not set
BR2_NERVES_SYSTEM_NAME="nerves_system_rpi0_2"
BR2_NERVES_ADDITIONAL_IMAGE_FILES="${NERVES_DEFCONFIG_DIR}/fwup.conf ${NERVES_DEFCONFIG_DIR}/cmdline.txt ${NERVES_DEFCONFIG_DIR}/config.txt"
BR2_PACKAGE_NBTTY=y
BR2_PACKAGE_NERVES_CONFIG=y
BR2_PACKAGE_RPI_DISTRO_FIRMWARE_NONFREE=y
BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES="${NERVES_DEFCONFIG_DIR}/busybox.fragment"
fhunleth commented 12 months ago

Hi @gworkman,

Unfortunately, I don't use vintage_net_mobile in my projects any more, so my help here is going to be a little limited. I use vintage_net_qmi.

The main problem is that USB isn't supported in two main ways:

  1. VintageNet requires a network interface to exist to run the modem. The hack that was put in was to trigger off the QMI interface ("wwan0") existing, but QMI is a USB protocol, so that's not going to work. "ppp0" can't be used because of a chicken and egg problem. VintageNetMobile needs to know when the modem is inserted to run the AT commands to start PPP mode to make "ppp0" show up, but VintageNet won't call VintageNetMobile until "ppp0" shows up.
  2. The BG96 support requires two UART different UARTs - one for AT commands and one for ppp. That lets you do things like check signal strength when Internet connected. Long story short, showing the number of bars at all times was a project requirement when this library was written and you can't do that with one UART. (well, Quectel has a UART multiplexing protocol, but that's even more work.)

If you can use USB, then that will be easier. You'll need to patch the Linux kernel. There's a comment at https://github.com/nerves-networking/vintage_net_mobile/blob/main/lib/vintage_net_mobile/modem/quectel_BG96.ex#L204-L218, but we've upgraded to Linux 6.1 and the warning doesn't show any more.

Now if you want to try to work harder to run over UART, here's what I'd try doing:

  1. Configure VintageNet with a "ppp0" interface like you would with a wired Ethernet one. In your config as {"ppp0", %{type: VintageNetEthernet, ipv4: %{method: :dhcp}}}. Using VintageNet.configure to do it at runtime is fine too. Wired Ethernet is the simplest network interface, so this is pretty featureless.
  2. Manually send AT commands to the modem and enable ppp.

Step 2 is not as hard as it sounds once you figure out the right recipe to send. See https://github.com/nerves-networking/vintage_net_mobile/blob/main/test/vintage_net_mobile/modem/quectel_BG96_test.exs#L36-L80. My first try would be to do the following:

iex> cmd("mknod /dev/ppp c 108 0")
# Replace "super" in the next line with your service provider's APN
iex> File.write("/tmp/vintage_net/chatscript.ppp0",
         """
         ABORT 'BUSY'
         ABORT 'NO CARRIER'
         ABORT 'NO DIALTONE'
         ABORT 'NO DIAL TONE'
         ABORT 'NO ANSWER'
         ABORT 'DELAYED'
         TIMEOUT 10
         REPORT CONNECT
         "" +++
         "" AT
         OK ATH
         OK ATZ
         OK ATQ0
         OK AT+CGDCONT=1,"IP","super"
         OK AT+QCFG=\"nwscanseq\",020301
         OK AT+QCFG=\"nwscanmode\",0
         OK AT+QCFG=\"iotopmode\",2
         OK ATDT*99***1#
         CONNECT ''
         """)
# This next line runs pppd in the foreground, so this console session won't be usable
# if it succeeds, but hopefully you can ssh in a second time to check the connection.
# If this all works, I'd create a GenServer to do the above lines and then this one and put it under a supervision tree.
iex> System.cmd("pppd",
           [
             "connect",
             "chat -v -f /tmp/vintage_net/chatscript.ppp0",
             "ttyAMA0",
             "9600",
             "noipdefault",
             "usepeerdns",
             "persist",
             "noauth",
             "nodetach",
             "debug"
           ])

I wrote that last line as System.cmd so I didn't need to combine the whole thing in one line to be called by the cmd helper. However, I might do that since you'll get the output printed if pppd is struggling.

I hope this works. Sorry if there are typos. It's been a while and I've forgotten lots, but this hopefully gets you closer.

gworkman commented 11 months ago

Hi @fhunleth, huge thank you for the response! This is incredibly helpful to point me in the right direction.

I ran everything above as you described, with only making the changes to the APN and the baud rate (9600 -> 115200, as per the module). Unfortunately, it doesn't seem like it is receiving responses from the module. The AT command list is incredibly helpful - I tested them as I showed above with Circuits.UART and was able to get the expected responses back from most of the commands, albeit with some strange formatting issues (such as line endings \r\n partially trimmed - I'm guessing a result of Circuits.UART trying to split/trim the messages)

Logs:

13:28:41.616 [info] PPP generic driver version 2.4.2

13:28:41.618 [info] Dec  4 13:28:41  pppd[211]: pppd 2.4.9 started by root, uid 0

13:28:42.638 [info] Dec  4 13:28:42  chat[213]: abort on (BUSY)

13:28:42.638 [info] Dec  4 13:28:42  chat[213]: abort on (NO CARRIER)

13:28:42.638 [info] Dec  4 13:28:42  chat[213]: abort on (NO DIALTONE)

13:28:42.638 [info] Dec  4 13:28:42  chat[213]: abort on (NO DIAL TONE)

13:28:42.638 [info] Dec  4 13:28:42  chat[213]: abort on (NO ANSWER)

13:28:42.639 [info] Dec  4 13:28:42  chat[213]: abort on (DELAYED)

13:28:42.639 [info] Dec  4 13:28:42  chat[213]: timeout set to 10 seconds

13:28:42.639 [info] Dec  4 13:28:42  chat[213]: report (CONNECT)

13:28:42.639 [info] Dec  4 13:28:42  chat[213]: send (+++^M)

13:28:42.678 [info] Dec  4 13:28:42  chat[213]: send (AT^M)

13:28:42.709 [info] Dec  4 13:28:42  chat[213]: expect (OK)

13:28:52.709 [info] Dec  4 13:28:52  chat[213]: alarm

13:28:52.709 [info] Dec  4 13:28:52  chat[213]: Failed

13:28:52.710 [debug] Dec  4 13:28:52  pppd[211]: Script chat -v -f /tmp/vintage_net/chatscript.ppp0 finished (pid 213), status = 0x3

13:28:52.710 [error] Dec  4 13:28:52  pppd[211]: Connect script failed

Documentation of the changes I tried:

System.cmd("pppd",
           [
             "connect",
             "chat -v -f /tmp/vintage_net/chatscript.ppp0",
             "ttyAMA0", # also tried /dev/ttyAMA0
             "115200", # also tried 9600, but 115200 is what I used successfully with Circuits.UART
             "noipdefault",
             "usepeerdns",
             "persist",
             "noauth",
             "nodetach",
             "debug"
           ])

Example with Circuits.UART. I realize now that not all of the response is being returned (or at least there was no OK on ATZ0? But chatscript seems to be hanging on the first AT command, so it isn't even getting this far)

iex(1)> {:ok, pid} = Circuits.UART.start_link()

{:ok, #PID<0.1188.0>}
iex(2)> Circuits.UART.open(pid, "/dev/ttyAMA0", speed: 115200)

:ok
iex(3)> Circuits.UART.write(pid, "AT\r\n")

:ok
iex(4)> flush

{:circuits_uart, "/dev/ttyAMA0", "AT\r\r\nOK\r"}
:ok
iex(5)> Circuits.UART.write(pid, "ATH\r\n")

:ok
iex(6)> flush

{:circuits_uart, "/dev/ttyAMA0", "ATH\r\r\nOK"}
:ok
iex(7)> Circuits.UART.write(pid, "ATZ\r\n")

:ok
iex(8)> flush

{:circuits_uart, "/dev/ttyAMA0", "ATZ\r"}
:ok
iex(9)> flush

:ok
iex(10)> Circuits.UART.write(pid, "ATZ0\r\n")

:ok
iex(11)> flush
{:circuits_uart, "/dev/ttyAMA0", "ATZ0\r"}
:ok
gworkman commented 11 months ago

Another update, as I'm digging into this: I got the logic analyzer out and I can confirm that chatscript is sending data, but not receiving any in return. And, when I send AT command with Circuits.UART, it is contiguous (no space between characters sent) and gets a response from the module, but it also dumps a chunk of the iex console out for some reason.

I also tried the two hardware control options from the pppd man page: crtscts and nocrtscts, but that didn't make a difference.

As sent with pppd (note there is no response on channel 4):

Screenshot 2023-12-04 at 3 56 29 PM

As sent with Circuits.UART:

(zoomed in to see the AT command + response)

Screenshot 2023-12-04 at 3 59 34 PM

(zoomed out, so you can see the IEX data)

Screenshot 2023-12-04 at 3 59 56 PM